1 #define PETSC_DLL 2 /* 3 These routines simplify the use of command line, file options, etc., 4 and are used to manipulate the options database. 5 6 This file uses regular malloc and free because it cannot know 7 what malloc is being used until it has already processed the input. 8 */ 9 10 #include "petsc.h" /*I "petsc.h" I*/ 11 #include "petscsys.h" 12 #if defined(PETSC_HAVE_STDLIB_H) 13 #include <stdlib.h> 14 #endif 15 16 /* 17 Keep a linked list of options that have been posted and we are waiting for 18 user selection 19 20 Eventually we'll attach this beast to a MPI_Comm 21 */ 22 PetscOptionsObjectType PetscOptionsObject; 23 PetscInt PetscOptionsPublishCount = 0; 24 25 26 #undef __FUNCT__ 27 #define __FUNCT__ "PetscOptionsHelpAddList" 28 PetscErrorCode PetscOptionsHelpAddList(const char prefix[],const char title[],const char mansec[]) 29 { 30 int ierr; 31 PetscOptionsHelp newhelp; 32 PetscFunctionBegin; 33 ierr = PetscNew(struct _p_PetscOptionsHelp,&newhelp);CHKERRQ(ierr); 34 ierr = PetscStrallocpy(prefix,&newhelp->prefix);CHKERRQ(ierr); 35 ierr = PetscStrallocpy(title,&newhelp->title);CHKERRQ(ierr); 36 ierr = PetscStrallocpy(mansec,&newhelp->mansec);CHKERRQ(ierr); 37 newhelp->next = 0; 38 39 if (!PetscOptionsObject.help) { 40 PetscOptionsObject.help = newhelp; 41 } else { 42 newhelp->next = PetscOptionsObject.help; 43 PetscOptionsObject.help = newhelp; 44 } 45 PetscFunctionReturn(0); 46 } 47 48 #undef __FUNCT__ 49 #define __FUNCT__ "PetscOptionsHelpDestroyList" 50 PetscErrorCode PetscOptionsHelpDestroyList(void) 51 { 52 PetscErrorCode ierr; 53 PetscOptionsHelp help = PetscOptionsObject.help, next; 54 55 PetscFunctionBegin; 56 while (help) { 57 next = help->next; 58 ierr = PetscStrfree(help->prefix);CHKERRQ(ierr); 59 ierr = PetscStrfree(help->title);CHKERRQ(ierr); 60 ierr = PetscStrfree(help->mansec);CHKERRQ(ierr); 61 ierr = PetscFree(help);CHKERRQ(ierr); 62 help = next; 63 } 64 PetscFunctionReturn(0); 65 } 66 67 68 #undef __FUNCT__ 69 #define __FUNCT__ "PetscOptionsHelpFindList" 70 PetscErrorCode PetscOptionsHelpFindList(const char prefix[],const char title[],const char mansec[],PetscTruth *flg) 71 { 72 PetscErrorCode ierr; 73 PetscTruth flg1,flg2,flg3; 74 PetscOptionsHelp help = PetscOptionsObject.help; 75 PetscFunctionBegin; 76 while (help) { 77 ierr = PetscStrcmp(help->prefix,prefix,&flg1);CHKERRQ(ierr); 78 ierr = PetscStrcmp(help->title,title,&flg2);CHKERRQ(ierr); 79 ierr = PetscStrcmp(help->mansec,mansec,&flg3);CHKERRQ(ierr); 80 if (flg1 && flg2 && flg3) { 81 *flg = PETSC_TRUE; 82 break; 83 } 84 help = help->next; 85 } 86 PetscFunctionReturn(0); 87 88 } 89 90 #undef __FUNCT__ 91 #define __FUNCT__ "PetscOptionsHelpCheckAddList" 92 PetscErrorCode PetscOptionsHelpCheckAddList(const char prefix[],const char title[],const char mansec[],PetscTruth *flg) 93 { 94 PetscFunctionBegin; 95 PetscOptionsHelpFindList(prefix,title,mansec,flg); 96 if (!(*flg)) PetscOptionsHelpAddList(prefix,title,mansec); 97 PetscFunctionReturn(0); 98 } 99 100 #undef __FUNCT__ 101 #define __FUNCT__ "PetscOptionsBegin_Private" 102 /* 103 Handles setting up the data structure in a call to PetscOptionsBegin() 104 */ 105 PetscErrorCode PetscOptionsBegin_Private(MPI_Comm comm,const char prefix[],const char title[],const char mansec[]) 106 { 107 PetscErrorCode ierr; 108 109 PetscFunctionBegin; 110 PetscOptionsObject.next = 0; 111 PetscOptionsObject.comm = comm; 112 PetscOptionsObject.changedmethod = PETSC_FALSE; 113 if (PetscOptionsObject.prefix) { 114 ierr = PetscStrfree(PetscOptionsObject.prefix);CHKERRQ(ierr); PetscOptionsObject.prefix = 0; 115 } 116 ierr = PetscStrallocpy(prefix,&PetscOptionsObject.prefix);CHKERRQ(ierr); 117 if (PetscOptionsObject.title) { 118 ierr = PetscStrfree(PetscOptionsObject.title);CHKERRQ(ierr); PetscOptionsObject.title = 0; 119 } 120 ierr = PetscStrallocpy(title,&PetscOptionsObject.title);CHKERRQ(ierr); 121 122 ierr = PetscOptionsHasName(PETSC_NULL,"-help",&PetscOptionsObject.printhelp);CHKERRQ(ierr); 123 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1) { 124 ierr = PetscOptionsHelpCheckAddList(prefix,title,mansec,&PetscOptionsObject.alreadyprinted); 125 if (!PetscOptionsObject.alreadyprinted) { 126 ierr = (*PetscHelpPrintf)(comm,"%s -------------------------------------------------\n",title);CHKERRQ(ierr); 127 } 128 } 129 PetscFunctionReturn(0); 130 } 131 132 /* 133 Handles adding another option to the list of options within this particular PetscOptionsBegin() PetscOptionsEnd() 134 */ 135 #undef __FUNCT__ 136 #define __FUNCT__ "PetscOptionsCreate_Private" 137 static int PetscOptionsCreate_Private(const char opt[],const char text[],const char man[],PetscOptionType t,PetscOptions *amsopt) 138 { 139 int ierr; 140 PetscOptions next; 141 142 PetscFunctionBegin; 143 ierr = PetscNew(struct _p_PetscOptions,amsopt);CHKERRQ(ierr); 144 (*amsopt)->next = 0; 145 (*amsopt)->set = PETSC_FALSE; 146 (*amsopt)->type = t; 147 (*amsopt)->data = 0; 148 (*amsopt)->edata = 0; 149 150 ierr = PetscStrallocpy(text,&(*amsopt)->text);CHKERRQ(ierr); 151 ierr = PetscStrallocpy(opt,&(*amsopt)->option);CHKERRQ(ierr); 152 ierr = PetscStrallocpy(man,&(*amsopt)->man);CHKERRQ(ierr); 153 154 if (!PetscOptionsObject.next) { 155 PetscOptionsObject.next = *amsopt; 156 } else { 157 next = PetscOptionsObject.next; 158 while (next->next) next = next->next; 159 next->next = *amsopt; 160 } 161 PetscFunctionReturn(0); 162 } 163 164 #undef __FUNCT__ 165 #define __FUNCT__ "PetscOptionsGetFromGui" 166 PetscErrorCode PetscOptionsGetFromGUI() 167 { 168 PetscErrorCode ierr; 169 PetscOptions next = PetscOptionsObject.next; 170 char str[512]; 171 172 ierr = (*PetscPrintf)(PetscOptionsObject.comm,"%s -------------------------------------------------\n",PetscOptionsObject.title);CHKERRQ(ierr); 173 while (next) { 174 switch (next->type) { 175 case OPTION_HEAD: 176 break; 177 case OPTION_INT: 178 ierr = PetscPrintf(PetscOptionsObject.comm,"-%s%s <%d>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",next->option,*(int*)next->data,next->text,next->man);CHKERRQ(ierr); 179 scanf("%s\n",str); 180 if (str[0] != '\n') { 181 printf("changing value\n"); 182 } 183 break; 184 default: 185 break; 186 } 187 next = next->next; 188 } 189 PetscFunctionReturn(0); 190 } 191 192 #undef __FUNCT__ 193 #define __FUNCT__ "PetscOptionsEnd_Private" 194 PetscErrorCode PetscOptionsEnd_Private(void) 195 { 196 PetscErrorCode ierr; 197 PetscOptions last; 198 char option[256],value[1024],tmp[32]; 199 PetscInt j; 200 201 PetscFunctionBegin; 202 203 /* if (PetscOptionsObject.next) { 204 ierr = PetscOptionsGetFromGUI(); 205 }*/ 206 207 ierr = PetscStrfree(PetscOptionsObject.title);CHKERRQ(ierr); PetscOptionsObject.title = 0; 208 ierr = PetscStrfree(PetscOptionsObject.prefix);CHKERRQ(ierr); PetscOptionsObject.prefix = 0; 209 210 /* reset counter to -2; this updates the screen with the new options for the selected method */ 211 if (PetscOptionsObject.changedmethod) PetscOptionsPublishCount = -2; 212 /* reset alreadyprinted flag */ 213 PetscOptionsObject.alreadyprinted = PETSC_FALSE; 214 215 while (PetscOptionsObject.next) { 216 if (PetscOptionsObject.next->set) { 217 if (PetscOptionsObject.prefix) { 218 ierr = PetscStrcpy(option,"-");CHKERRQ(ierr); 219 ierr = PetscStrcat(option,PetscOptionsObject.prefix);CHKERRQ(ierr); 220 ierr = PetscStrcat(option,PetscOptionsObject.next->option+1);CHKERRQ(ierr); 221 } else { 222 ierr = PetscStrcpy(option,PetscOptionsObject.next->option);CHKERRQ(ierr); 223 } 224 225 switch (PetscOptionsObject.next->type) { 226 case OPTION_HEAD: 227 break; 228 case OPTION_INT: 229 sprintf(value,"%d",(int) *(PetscInt*)PetscOptionsObject.next->data); 230 break; 231 case OPTION_REAL: 232 sprintf(value,"%g",(double) *(PetscReal*)PetscOptionsObject.next->data); 233 break; 234 case OPTION_REAL_ARRAY: 235 sprintf(value,"%g",(double)((PetscReal*)PetscOptionsObject.next->data)[0]); 236 for (j=1; j<PetscOptionsObject.next->arraylength; j++) { 237 sprintf(tmp,"%g",(double)((PetscReal*)PetscOptionsObject.next->data)[j]); 238 ierr = PetscStrcat(value,",");CHKERRQ(ierr); 239 ierr = PetscStrcat(value,tmp);CHKERRQ(ierr); 240 } 241 break; 242 case OPTION_LOGICAL: 243 sprintf(value,"%d",(int)*(PetscInt*)PetscOptionsObject.next->data); 244 break; 245 case OPTION_LIST: 246 ierr = PetscStrcpy(value,*(char**)PetscOptionsObject.next->data);CHKERRQ(ierr); 247 break; 248 case OPTION_STRING: /* also handles string arrays */ 249 ierr = PetscStrcpy(value,*(char**)PetscOptionsObject.next->data);CHKERRQ(ierr); 250 break; 251 } 252 ierr = PetscOptionsSetValue(option,value);CHKERRQ(ierr); 253 } 254 ierr = PetscStrfree(PetscOptionsObject.next->text);CHKERRQ(ierr); 255 ierr = PetscStrfree(PetscOptionsObject.next->option);CHKERRQ(ierr); 256 ierr = PetscFree(PetscOptionsObject.next->man);CHKERRQ(ierr); 257 ierr = PetscFree(PetscOptionsObject.next->data);CHKERRQ(ierr); 258 ierr = PetscFree(PetscOptionsObject.next->edata);CHKERRQ(ierr); 259 last = PetscOptionsObject.next; 260 PetscOptionsObject.next = PetscOptionsObject.next->next; 261 ierr = PetscFree(last);CHKERRQ(ierr); 262 } 263 PetscOptionsObject.next = 0; 264 PetscFunctionReturn(0); 265 } 266 267 #undef __FUNCT__ 268 #define __FUNCT__ "PetscOptionsEnum" 269 /*@C 270 PetscOptionsEnum - Gets the enum value for a particular option in the database. 271 272 Collective on the communicator passed in PetscOptionsBegin() 273 274 Input Parameters: 275 + opt - option name 276 . text - short string that describes the option 277 . man - manual page with additional information on option 278 . list - array containing the list of choices, followed by the enum name, followed by the enum prefix, followed by a null 279 - defaultv - the default (current) value 280 281 Output Parameter: 282 + value - the value to return 283 - flg - PETSC_TRUE if found, else PETSC_FALSE 284 285 Level: beginner 286 287 Concepts: options database 288 289 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 290 291 list is usually something like PCASMTypes or some other predefined list of enum names 292 293 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 294 PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 295 PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 296 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 297 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 298 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 299 PetscOptionsList(), PetscOptionsEList() 300 @*/ 301 PetscErrorCode PETSC_DLLEXPORT PetscOptionsEnum(const char opt[],const char text[],const char man[],const char **list,PetscEnum defaultv,PetscEnum *value,PetscTruth *set) 302 { 303 PetscErrorCode ierr; 304 PetscInt ntext = 0; 305 PetscInt tval; 306 PetscTruth tflg; 307 308 PetscFunctionBegin; 309 while (list[ntext++]) { 310 if (ntext > 50) SETERRQ(PETSC_ERR_ARG_WRONG,"List argument appears to be wrong or have more than 50 entries"); 311 } 312 if (ntext < 3) SETERRQ(PETSC_ERR_ARG_WRONG,"List argument must have at least two entries: typename and type prefix"); 313 ntext -= 3; 314 ierr = PetscOptionsEList(opt,text,man,list,ntext,list[defaultv],&tval,&tflg);CHKERRQ(ierr); 315 /* with PETSC_USE_64BIT_INDICES sizeof(PetscInt) != sizeof(PetscEnum) */ 316 if (tflg) *value = (PetscEnum)tval; 317 if (set) *set = tflg; 318 PetscFunctionReturn(0); 319 } 320 321 /* -------------------------------------------------------------------------------------------------------------*/ 322 #undef __FUNCT__ 323 #define __FUNCT__ "PetscOptionsInt" 324 /*@C 325 PetscOptionsInt - Gets the integer value for a particular option in the database. 326 327 Collective on the communicator passed in PetscOptionsBegin() 328 329 Input Parameters: 330 + opt - option name 331 . text - short string that describes the option 332 . man - manual page with additional information on option 333 - defaultv - the default (current) value 334 335 Output Parameter: 336 + value - the integer value to return 337 - flg - PETSC_TRUE if found, else PETSC_FALSE 338 339 Level: beginner 340 341 Concepts: options database^has int 342 343 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 344 345 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 346 PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 347 PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 348 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 349 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 350 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 351 PetscOptionsList(), PetscOptionsEList() 352 @*/ 353 PetscErrorCode PETSC_DLLEXPORT PetscOptionsInt(const char opt[],const char text[],const char man[],PetscInt defaultv,PetscInt *value,PetscTruth *set) 354 { 355 PetscErrorCode ierr; 356 PetscOptions amsopt; 357 358 PetscFunctionBegin; 359 if (PetscOptionsPublishCount == 1) { 360 ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_INT,&amsopt);CHKERRQ(ierr); 361 ierr = PetscMalloc(sizeof(PetscInt),&amsopt->data);CHKERRQ(ierr); 362 *(PetscInt*)amsopt->data = defaultv; 363 } 364 ierr = PetscOptionsGetInt(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr); 365 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 366 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%d>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,man);CHKERRQ(ierr); 367 } 368 PetscFunctionReturn(0); 369 } 370 371 #undef __FUNCT__ 372 #define __FUNCT__ "PetscOptionsString" 373 /*@C 374 PetscOptionsString - Gets the string value for a particular option in the database. 375 376 Collective on the communicator passed in PetscOptionsBegin() 377 378 Input Parameters: 379 + opt - option name 380 . text - short string that describes the option 381 . man - manual page with additional information on option 382 - defaultv - the default (current) value 383 384 Output Parameter: 385 + value - the value to return 386 - flg - PETSC_TRUE if found, else PETSC_FALSE 387 388 Level: beginner 389 390 Concepts: options database^has int 391 392 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 393 394 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 395 PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 396 PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 397 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 398 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 399 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 400 PetscOptionsList(), PetscOptionsEList() 401 @*/ 402 PetscErrorCode PETSC_DLLEXPORT PetscOptionsString(const char opt[],const char text[],const char man[],const char defaultv[],char value[],size_t len,PetscTruth *set) 403 { 404 PetscErrorCode ierr; 405 406 PetscFunctionBegin; 407 ierr = PetscOptionsGetString(PetscOptionsObject.prefix,opt,value,len,set);CHKERRQ(ierr); 408 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 409 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%s>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,man);CHKERRQ(ierr); 410 } 411 PetscFunctionReturn(0); 412 } 413 414 /* 415 Publishes an AMS double field (with the default value in it) and with a name 416 given by the text string 417 */ 418 #undef __FUNCT__ 419 #define __FUNCT__ "PetscOptionsReal" 420 /*@C 421 PetscOptionsReal - Gets the PetscReal value for a particular option in the database. 422 423 Collective on the communicator passed in PetscOptionsBegin() 424 425 Input Parameters: 426 + opt - option name 427 . text - short string that describes the option 428 . man - manual page with additional information on option 429 - defaultv - the default (current) value 430 431 Output Parameter: 432 + value - the value to return 433 - flg - PETSC_TRUE if found, else PETSC_FALSE 434 435 Level: beginner 436 437 Concepts: options database^has int 438 439 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 440 441 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 442 PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 443 PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 444 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 445 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 446 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 447 PetscOptionsList(), PetscOptionsEList() 448 @*/ 449 PetscErrorCode PETSC_DLLEXPORT PetscOptionsReal(const char opt[],const char text[],const char man[],PetscReal defaultv,PetscReal *value,PetscTruth *set) 450 { 451 PetscErrorCode ierr; 452 453 PetscFunctionBegin; 454 ierr = PetscOptionsGetReal(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr); 455 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 456 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%G>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,man);CHKERRQ(ierr); 457 } 458 PetscFunctionReturn(0); 459 } 460 461 #undef __FUNCT__ 462 #define __FUNCT__ "PetscOptionsScalar" 463 /*@C 464 PetscOptionsScalar - Gets the scalar value for a particular option in the database. 465 466 Collective on the communicator passed in PetscOptionsBegin() 467 468 Input Parameters: 469 + opt - option name 470 . text - short string that describes the option 471 . man - manual page with additional information on option 472 - defaultv - the default (current) value 473 474 Output Parameter: 475 + value - the value to return 476 - flg - PETSC_TRUE if found, else PETSC_FALSE 477 478 Level: beginner 479 480 Concepts: options database^has int 481 482 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 483 484 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 485 PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 486 PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 487 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 488 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 489 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 490 PetscOptionsList(), PetscOptionsEList() 491 @*/ 492 PetscErrorCode PETSC_DLLEXPORT PetscOptionsScalar(const char opt[],const char text[],const char man[],PetscScalar defaultv,PetscScalar *value,PetscTruth *set) 493 { 494 PetscErrorCode ierr; 495 496 PetscFunctionBegin; 497 #if !defined(PETSC_USE_COMPLEX) 498 ierr = PetscOptionsReal(opt,text,man,defaultv,value,set);CHKERRQ(ierr); 499 #else 500 ierr = PetscOptionsGetScalar(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr); 501 #endif 502 PetscFunctionReturn(0); 503 } 504 505 /* 506 Publishes an AMS logical field (with the default value in it) and with a name 507 given by the text string 508 */ 509 #undef __FUNCT__ 510 #define __FUNCT__ "PetscOptionsName" 511 /*@C 512 PetscOptionsName - Determines if a particular option has been set in the database. This returns true whether the option is a number, string or boolean, even 513 its value is set to false. 514 515 Collective on the communicator passed in PetscOptionsBegin() 516 517 Input Parameters: 518 + opt - option name 519 . text - short string that describes the option 520 - man - manual page with additional information on option 521 522 Output Parameter: 523 . flg - PETSC_TRUE if found, else PETSC_FALSE 524 525 Level: beginner 526 527 Concepts: options database^has int 528 529 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 530 531 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 532 PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 533 PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 534 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 535 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 536 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 537 PetscOptionsList(), PetscOptionsEList() 538 @*/ 539 PetscErrorCode PETSC_DLLEXPORT PetscOptionsName(const char opt[],const char text[],const char man[],PetscTruth *flg) 540 { 541 PetscErrorCode ierr; 542 543 PetscFunctionBegin; 544 ierr = PetscOptionsHasName(PetscOptionsObject.prefix,opt,flg);CHKERRQ(ierr); 545 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 546 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 547 } 548 PetscFunctionReturn(0); 549 } 550 551 #undef __FUNCT__ 552 #define __FUNCT__ "PetscOptionsList" 553 /*@C 554 PetscOptionsList - Puts a list of option values that a single one may be selected from 555 556 Collective on the communicator passed in PetscOptionsBegin() 557 558 Input Parameters: 559 + opt - option name 560 . text - short string that describes the option 561 . man - manual page with additional information on option 562 . list - the possible choices 563 - defaultv - the default (current) value 564 565 Output Parameter: 566 + value - the value to return 567 - set - PETSC_TRUE if found, else PETSC_FALSE 568 569 Level: intermediate 570 571 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 572 573 See PetscOptionsEList() for when the choices are given in a string array 574 575 To get a listing of all currently specified options, 576 see PetscOptionsPrint() or PetscOptionsGetAll() 577 578 Concepts: options database^list 579 580 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 581 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 582 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 583 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 584 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 585 PetscOptionsList(), PetscOptionsEList() 586 @*/ 587 PetscErrorCode PETSC_DLLEXPORT PetscOptionsList(const char opt[],const char ltext[],const char man[],PetscFList list,const char defaultv[],char value[],PetscInt len,PetscTruth *set) 588 { 589 PetscErrorCode ierr; 590 591 PetscFunctionBegin; 592 ierr = PetscOptionsGetString(PetscOptionsObject.prefix,opt,value,len,set);CHKERRQ(ierr); 593 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 594 ierr = PetscFListPrintTypes(list,PetscOptionsObject.comm,stdout,PetscOptionsObject.prefix,opt,ltext,man);CHKERRQ(ierr);CHKERRQ(ierr); 595 } 596 PetscFunctionReturn(0); 597 } 598 599 #undef __FUNCT__ 600 #define __FUNCT__ "PetscOptionsEList" 601 /*@C 602 PetscOptionsEList - Puts a list of option values that a single one may be selected from 603 604 Collective on the communicator passed in PetscOptionsBegin() 605 606 Input Parameters: 607 + opt - option name 608 . ltext - short string that describes the option 609 . man - manual page with additional information on option 610 . list - the possible choices 611 . ntext - number of choices 612 - defaultv - the default (current) value 613 614 Output Parameter: 615 + value - the index of the value to return 616 - set - PETSC_TRUE if found, else PETSC_FALSE 617 618 Level: intermediate 619 620 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 621 622 See PetscOptionsList() for when the choices are given in a PetscFList() 623 624 Concepts: options database^list 625 626 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 627 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 628 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 629 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 630 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 631 PetscOptionsList(), PetscOptionsEList() 632 @*/ 633 PetscErrorCode PETSC_DLLEXPORT PetscOptionsEList(const char opt[],const char ltext[],const char man[],const char **list,PetscInt ntext,const char defaultv[],PetscInt *value,PetscTruth *set) 634 { 635 PetscErrorCode ierr; 636 PetscInt i; 637 638 PetscFunctionBegin; 639 ierr = PetscOptionsGetEList(PetscOptionsObject.prefix,opt,list,ntext,value,set);CHKERRQ(ierr); 640 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 641 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%s> (choose one of)",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv);CHKERRQ(ierr); 642 for (i=0; i<ntext; i++){ 643 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," %s",list[i]);CHKERRQ(ierr); 644 } 645 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"\n");CHKERRQ(ierr); 646 } 647 PetscFunctionReturn(0); 648 } 649 650 #undef __FUNCT__ 651 #define __FUNCT__ "PetscOptionsTruthGroupBegin" 652 /*@C 653 PetscOptionsTruthGroupBegin - First in a series of logical queries on the options database for 654 which only a single value can be true. 655 656 Collective on the communicator passed in PetscOptionsBegin() 657 658 Input Parameters: 659 + opt - option name 660 . text - short string that describes the option 661 - man - manual page with additional information on option 662 663 Output Parameter: 664 . flg - whether that option was set or not 665 666 Level: intermediate 667 668 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 669 670 Must be followed by 0 or more PetscOptionsTruthGroup()s and PetscOptionsTruthGroupEnd() 671 672 Concepts: options database^logical group 673 674 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 675 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 676 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 677 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 678 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 679 PetscOptionsList(), PetscOptionsEList() 680 @*/ 681 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroupBegin(const char opt[],const char text[],const char man[],PetscTruth *flg) 682 { 683 PetscErrorCode ierr; 684 685 PetscFunctionBegin; 686 ierr = PetscOptionsHasName(PetscOptionsObject.prefix,opt,flg);CHKERRQ(ierr); 687 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 688 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," Pick at most one of -------------\n");CHKERRQ(ierr); 689 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 690 } 691 PetscFunctionReturn(0); 692 } 693 694 #undef __FUNCT__ 695 #define __FUNCT__ "PetscOptionsTruthGroup" 696 /*@C 697 PetscOptionsTruthGroup - One in a series of logical queries on the options database for 698 which only a single value can be true. 699 700 Collective on the communicator passed in PetscOptionsBegin() 701 702 Input Parameters: 703 + opt - option name 704 . text - short string that describes the option 705 - man - manual page with additional information on option 706 707 Output Parameter: 708 . flg - PETSC_TRUE if found, else PETSC_FALSE 709 710 Level: intermediate 711 712 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 713 714 Must follow a PetscOptionsTruthGroupBegin() and preceded a PetscOptionsTruthGroupEnd() 715 716 Concepts: options database^logical group 717 718 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 719 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 720 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 721 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 722 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 723 PetscOptionsList(), PetscOptionsEList() 724 @*/ 725 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroup(const char opt[],const char text[],const char man[],PetscTruth *flg) 726 { 727 PetscErrorCode ierr; 728 729 PetscFunctionBegin; 730 ierr = PetscOptionsHasName(PetscOptionsObject.prefix,opt,flg);CHKERRQ(ierr); 731 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 732 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 733 } 734 PetscFunctionReturn(0); 735 } 736 737 #undef __FUNCT__ 738 #define __FUNCT__ "PetscOptionsTruthGroupEnd" 739 /*@C 740 PetscOptionsTruthGroupEnd - Last in a series of logical queries on the options database for 741 which only a single value can be true. 742 743 Collective on the communicator passed in PetscOptionsBegin() 744 745 Input Parameters: 746 + opt - option name 747 . text - short string that describes the option 748 - man - manual page with additional information on option 749 750 Output Parameter: 751 . flg - PETSC_TRUE if found, else PETSC_FALSE 752 753 Level: intermediate 754 755 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 756 757 Must follow a PetscOptionsTruthGroupBegin() 758 759 Concepts: options database^logical group 760 761 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 762 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 763 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 764 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 765 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 766 PetscOptionsList(), PetscOptionsEList() 767 @*/ 768 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroupEnd(const char opt[],const char text[],const char man[],PetscTruth *flg) 769 { 770 PetscErrorCode ierr; 771 772 PetscFunctionBegin; 773 ierr = PetscOptionsHasName(PetscOptionsObject.prefix,opt,flg);CHKERRQ(ierr); 774 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 775 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 776 } 777 PetscFunctionReturn(0); 778 } 779 780 #undef __FUNCT__ 781 #define __FUNCT__ "PetscOptionsTruth" 782 /*@C 783 PetscOptionsTruth - Determines if a particular option is in the database with a true or false 784 785 Collective on the communicator passed in PetscOptionsBegin() 786 787 Input Parameters: 788 + opt - option name 789 . text - short string that describes the option 790 - man - manual page with additional information on option 791 792 Output Parameter: 793 . flg - PETSC_TRUE or PETSC_FALSE 794 . set - PETSC_TRUE if found, else PETSC_FALSE 795 796 Level: beginner 797 798 Concepts: options database^logical 799 800 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 801 802 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 803 PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 804 PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 805 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 806 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 807 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 808 PetscOptionsList(), PetscOptionsEList() 809 @*/ 810 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruth(const char opt[],const char text[],const char man[],PetscTruth deflt,PetscTruth *flg,PetscTruth *set) 811 { 812 PetscErrorCode ierr; 813 PetscTruth iset; 814 815 PetscFunctionBegin; 816 ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,&iset);CHKERRQ(ierr); 817 if (!iset) { 818 if (flg) *flg = deflt; 819 } 820 if (set) *set = iset; 821 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 822 const char *v = PetscTruths[deflt]; 823 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: <%s> %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,v,text,man);CHKERRQ(ierr); 824 } 825 PetscFunctionReturn(0); 826 } 827 828 #undef __FUNCT__ 829 #define __FUNCT__ "PetscOptionsRealArray" 830 /*@C 831 PetscOptionsRealArray - Gets an array of double values for a particular 832 option in the database. The values must be separated with commas with 833 no intervening spaces. 834 835 Collective on the communicator passed in PetscOptionsBegin() 836 837 Input Parameters: 838 + opt - the option one is seeking 839 . text - short string describing option 840 . man - manual page for option 841 - nmax - maximum number of values 842 843 Output Parameter: 844 + value - location to copy values 845 . nmax - actual number of values found 846 - set - PETSC_TRUE if found, else PETSC_FALSE 847 848 Level: beginner 849 850 Notes: 851 The user should pass in an array of doubles 852 853 Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 854 855 Concepts: options database^array of strings 856 857 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 858 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 859 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 860 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 861 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 862 PetscOptionsList(), PetscOptionsEList() 863 @*/ 864 PetscErrorCode PETSC_DLLEXPORT PetscOptionsRealArray(const char opt[],const char text[],const char man[],PetscReal value[],PetscInt *n,PetscTruth *set) 865 { 866 PetscErrorCode ierr; 867 PetscInt i; 868 869 PetscFunctionBegin; 870 ierr = PetscOptionsGetRealArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr); 871 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 872 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%G",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr); 873 for (i=1; i<*n; i++) { 874 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%G",value[i]);CHKERRQ(ierr); 875 } 876 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr); 877 } 878 PetscFunctionReturn(0); 879 } 880 881 882 #undef __FUNCT__ 883 #define __FUNCT__ "PetscOptionsIntArray" 884 /*@C 885 PetscOptionsIntArray - Gets an array of integers for a particular 886 option in the database. The values must be separated with commas with 887 no intervening spaces. 888 889 Collective on the communicator passed in PetscOptionsBegin() 890 891 Input Parameters: 892 + opt - the option one is seeking 893 . text - short string describing option 894 . man - manual page for option 895 - n - maximum number of values 896 897 Output Parameter: 898 + value - location to copy values 899 . n - actual number of values found 900 - set - PETSC_TRUE if found, else PETSC_FALSE 901 902 Level: beginner 903 904 Notes: 905 The user should pass in an array of integers 906 907 Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 908 909 Concepts: options database^array of strings 910 911 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 912 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 913 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 914 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 915 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 916 PetscOptionsList(), PetscOptionsEList(), PetscOptionsRealArray() 917 @*/ 918 PetscErrorCode PETSC_DLLEXPORT PetscOptionsIntArray(const char opt[],const char text[],const char man[],PetscInt value[],PetscInt *n,PetscTruth *set) 919 { 920 PetscErrorCode ierr; 921 PetscInt i; 922 923 PetscFunctionBegin; 924 ierr = PetscOptionsGetIntArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr); 925 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 926 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%d",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr); 927 for (i=1; i<*n; i++) { 928 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%d",value[i]);CHKERRQ(ierr); 929 } 930 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr); 931 } 932 PetscFunctionReturn(0); 933 } 934 935 #undef __FUNCT__ 936 #define __FUNCT__ "PetscOptionsStringArray" 937 /*@C 938 PetscOptionsStringArray - Gets an array of string values for a particular 939 option in the database. The values must be separated with commas with 940 no intervening spaces. 941 942 Collective on the communicator passed in PetscOptionsBegin() 943 944 Input Parameters: 945 + opt - the option one is seeking 946 . text - short string describing option 947 . man - manual page for option 948 - nmax - maximum number of strings 949 950 Output Parameter: 951 + value - location to copy strings 952 . nmax - actual number of strings found 953 - set - PETSC_TRUE if found, else PETSC_FALSE 954 955 Level: beginner 956 957 Notes: 958 The user should pass in an array of pointers to char, to hold all the 959 strings returned by this function. 960 961 The user is responsible for deallocating the strings that are 962 returned. The Fortran interface for this routine is not supported. 963 964 Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 965 966 Concepts: options database^array of strings 967 968 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 969 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 970 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 971 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 972 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 973 PetscOptionsList(), PetscOptionsEList() 974 @*/ 975 PetscErrorCode PETSC_DLLEXPORT PetscOptionsStringArray(const char opt[],const char text[],const char man[],char *value[],PetscInt *nmax,PetscTruth *set) 976 { 977 PetscErrorCode ierr; 978 979 PetscFunctionBegin; 980 ierr = PetscOptionsGetStringArray(PetscOptionsObject.prefix,opt,value,nmax,set);CHKERRQ(ierr); 981 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 982 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <string1,string2,...>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 983 } 984 PetscFunctionReturn(0); 985 } 986 987 #undef __FUNCT__ 988 #define __FUNCT__ "PetscOptionsTruthArray" 989 /*@C 990 PetscOptionsTruthArray - Gets an array of logical values (true or false) for a particular 991 option in the database. The values must be separated with commas with 992 no intervening spaces. 993 994 Collective on the communicator passed in PetscOptionsBegin() 995 996 Input Parameters: 997 + opt - the option one is seeking 998 . text - short string describing option 999 . man - manual page for option 1000 - nmax - maximum number of values 1001 1002 Output Parameter: 1003 + value - location to copy values 1004 . nmax - actual number of values found 1005 - set - PETSC_TRUE if found, else PETSC_FALSE 1006 1007 Level: beginner 1008 1009 Notes: 1010 The user should pass in an array of doubles 1011 1012 Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 1013 1014 Concepts: options database^array of strings 1015 1016 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1017 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 1018 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 1019 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1020 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 1021 PetscOptionsList(), PetscOptionsEList() 1022 @*/ 1023 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthArray(const char opt[],const char text[],const char man[],PetscTruth value[],PetscInt *n,PetscTruth *set) 1024 { 1025 PetscErrorCode ierr; 1026 PetscInt i; 1027 1028 PetscFunctionBegin; 1029 ierr = PetscOptionsGetTruthArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr); 1030 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 1031 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%d",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr); 1032 for (i=1; i<*n; i++) { 1033 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%d",value[i]);CHKERRQ(ierr); 1034 } 1035 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr); 1036 } 1037 PetscFunctionReturn(0); 1038 } 1039 1040 1041 #undef __FUNCT__ 1042 #define __FUNCT__ "PetscOptionsHead" 1043 /*@C 1044 PetscOptionsHead - Puts a heading before listing any more published options. Used, for example, 1045 in KSPSetFromOptions_GMRES(). 1046 1047 Collective on the communicator passed in PetscOptionsBegin() 1048 1049 Input Parameter: 1050 . head - the heading text 1051 1052 1053 Level: intermediate 1054 1055 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 1056 1057 Can be followed by a call to PetscOptionsTail() in the same function. 1058 1059 Concepts: options database^subheading 1060 1061 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1062 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 1063 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 1064 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1065 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 1066 PetscOptionsList(), PetscOptionsEList() 1067 @*/ 1068 PetscErrorCode PETSC_DLLEXPORT PetscOptionsHead(const char head[]) 1069 { 1070 PetscErrorCode ierr; 1071 1072 PetscFunctionBegin; 1073 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 1074 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," %s\n",head);CHKERRQ(ierr); 1075 } 1076 PetscFunctionReturn(0); 1077 } 1078 1079 1080 1081 1082 1083 1084