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 *flg = PETSC_FALSE; 687 ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,PETSC_NULL);CHKERRQ(ierr); 688 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 689 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," Pick at most one of -------------\n");CHKERRQ(ierr); 690 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 691 } 692 PetscFunctionReturn(0); 693 } 694 695 #undef __FUNCT__ 696 #define __FUNCT__ "PetscOptionsTruthGroup" 697 /*@C 698 PetscOptionsTruthGroup - One in a series of logical queries on the options database for 699 which only a single value can be true. 700 701 Collective on the communicator passed in PetscOptionsBegin() 702 703 Input Parameters: 704 + opt - option name 705 . text - short string that describes the option 706 - man - manual page with additional information on option 707 708 Output Parameter: 709 . flg - PETSC_TRUE if found, else PETSC_FALSE 710 711 Level: intermediate 712 713 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 714 715 Must follow a PetscOptionsTruthGroupBegin() and preceded a PetscOptionsTruthGroupEnd() 716 717 Concepts: options database^logical group 718 719 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 720 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 721 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 722 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 723 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 724 PetscOptionsList(), PetscOptionsEList() 725 @*/ 726 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroup(const char opt[],const char text[],const char man[],PetscTruth *flg) 727 { 728 PetscErrorCode ierr; 729 730 PetscFunctionBegin; 731 *flg = PETSC_FALSE; 732 ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,PETSC_NULL);CHKERRQ(ierr); 733 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 734 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 735 } 736 PetscFunctionReturn(0); 737 } 738 739 #undef __FUNCT__ 740 #define __FUNCT__ "PetscOptionsTruthGroupEnd" 741 /*@C 742 PetscOptionsTruthGroupEnd - Last in a series of logical queries on the options database for 743 which only a single value can be true. 744 745 Collective on the communicator passed in PetscOptionsBegin() 746 747 Input Parameters: 748 + opt - option name 749 . text - short string that describes the option 750 - man - manual page with additional information on option 751 752 Output Parameter: 753 . flg - PETSC_TRUE if found, else PETSC_FALSE 754 755 Level: intermediate 756 757 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 758 759 Must follow a PetscOptionsTruthGroupBegin() 760 761 Concepts: options database^logical group 762 763 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 764 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 765 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 766 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 767 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 768 PetscOptionsList(), PetscOptionsEList() 769 @*/ 770 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroupEnd(const char opt[],const char text[],const char man[],PetscTruth *flg) 771 { 772 PetscErrorCode ierr; 773 774 PetscFunctionBegin; 775 *flg = PETSC_FALSE; 776 ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,PETSC_NULL);CHKERRQ(ierr); 777 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 778 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 779 } 780 PetscFunctionReturn(0); 781 } 782 783 #undef __FUNCT__ 784 #define __FUNCT__ "PetscOptionsTruth" 785 /*@C 786 PetscOptionsTruth - Determines if a particular option is in the database with a true or false 787 788 Collective on the communicator passed in PetscOptionsBegin() 789 790 Input Parameters: 791 + opt - option name 792 . text - short string that describes the option 793 - man - manual page with additional information on option 794 795 Output Parameter: 796 . flg - PETSC_TRUE or PETSC_FALSE 797 . set - PETSC_TRUE if found, else PETSC_FALSE 798 799 Level: beginner 800 801 Concepts: options database^logical 802 803 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 804 805 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 806 PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 807 PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 808 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 809 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 810 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 811 PetscOptionsList(), PetscOptionsEList() 812 @*/ 813 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruth(const char opt[],const char text[],const char man[],PetscTruth deflt,PetscTruth *flg,PetscTruth *set) 814 { 815 PetscErrorCode ierr; 816 PetscTruth iset; 817 818 PetscFunctionBegin; 819 ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,&iset);CHKERRQ(ierr); 820 if (!iset) { 821 if (flg) *flg = deflt; 822 } 823 if (set) *set = iset; 824 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 825 const char *v = PetscTruths[deflt]; 826 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: <%s> %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,v,text,man);CHKERRQ(ierr); 827 } 828 PetscFunctionReturn(0); 829 } 830 831 #undef __FUNCT__ 832 #define __FUNCT__ "PetscOptionsRealArray" 833 /*@C 834 PetscOptionsRealArray - Gets an array of double values for a particular 835 option in the database. The values must be separated with commas with 836 no intervening spaces. 837 838 Collective on the communicator passed in PetscOptionsBegin() 839 840 Input Parameters: 841 + opt - the option one is seeking 842 . text - short string describing option 843 . man - manual page for option 844 - nmax - maximum number of values 845 846 Output Parameter: 847 + value - location to copy values 848 . nmax - actual number of values found 849 - set - PETSC_TRUE if found, else PETSC_FALSE 850 851 Level: beginner 852 853 Notes: 854 The user should pass in an array of doubles 855 856 Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 857 858 Concepts: options database^array of strings 859 860 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 861 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 862 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 863 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 864 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 865 PetscOptionsList(), PetscOptionsEList() 866 @*/ 867 PetscErrorCode PETSC_DLLEXPORT PetscOptionsRealArray(const char opt[],const char text[],const char man[],PetscReal value[],PetscInt *n,PetscTruth *set) 868 { 869 PetscErrorCode ierr; 870 PetscInt i; 871 872 PetscFunctionBegin; 873 ierr = PetscOptionsGetRealArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr); 874 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 875 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%G",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr); 876 for (i=1; i<*n; i++) { 877 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%G",value[i]);CHKERRQ(ierr); 878 } 879 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr); 880 } 881 PetscFunctionReturn(0); 882 } 883 884 885 #undef __FUNCT__ 886 #define __FUNCT__ "PetscOptionsIntArray" 887 /*@C 888 PetscOptionsIntArray - Gets an array of integers for a particular 889 option in the database. The values must be separated with commas with 890 no intervening spaces. 891 892 Collective on the communicator passed in PetscOptionsBegin() 893 894 Input Parameters: 895 + opt - the option one is seeking 896 . text - short string describing option 897 . man - manual page for option 898 - n - maximum number of values 899 900 Output Parameter: 901 + value - location to copy values 902 . n - actual number of values found 903 - set - PETSC_TRUE if found, else PETSC_FALSE 904 905 Level: beginner 906 907 Notes: 908 The user should pass in an array of integers 909 910 Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 911 912 Concepts: options database^array of strings 913 914 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 915 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 916 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 917 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 918 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 919 PetscOptionsList(), PetscOptionsEList(), PetscOptionsRealArray() 920 @*/ 921 PetscErrorCode PETSC_DLLEXPORT PetscOptionsIntArray(const char opt[],const char text[],const char man[],PetscInt value[],PetscInt *n,PetscTruth *set) 922 { 923 PetscErrorCode ierr; 924 PetscInt i; 925 926 PetscFunctionBegin; 927 ierr = PetscOptionsGetIntArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr); 928 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 929 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%d",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr); 930 for (i=1; i<*n; i++) { 931 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%d",value[i]);CHKERRQ(ierr); 932 } 933 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr); 934 } 935 PetscFunctionReturn(0); 936 } 937 938 #undef __FUNCT__ 939 #define __FUNCT__ "PetscOptionsStringArray" 940 /*@C 941 PetscOptionsStringArray - Gets an array of string values for a particular 942 option in the database. The values must be separated with commas with 943 no intervening spaces. 944 945 Collective on the communicator passed in PetscOptionsBegin() 946 947 Input Parameters: 948 + opt - the option one is seeking 949 . text - short string describing option 950 . man - manual page for option 951 - nmax - maximum number of strings 952 953 Output Parameter: 954 + value - location to copy strings 955 . nmax - actual number of strings found 956 - set - PETSC_TRUE if found, else PETSC_FALSE 957 958 Level: beginner 959 960 Notes: 961 The user should pass in an array of pointers to char, to hold all the 962 strings returned by this function. 963 964 The user is responsible for deallocating the strings that are 965 returned. The Fortran interface for this routine is not supported. 966 967 Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 968 969 Concepts: options database^array of strings 970 971 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 972 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 973 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 974 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 975 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 976 PetscOptionsList(), PetscOptionsEList() 977 @*/ 978 PetscErrorCode PETSC_DLLEXPORT PetscOptionsStringArray(const char opt[],const char text[],const char man[],char *value[],PetscInt *nmax,PetscTruth *set) 979 { 980 PetscErrorCode ierr; 981 982 PetscFunctionBegin; 983 ierr = PetscOptionsGetStringArray(PetscOptionsObject.prefix,opt,value,nmax,set);CHKERRQ(ierr); 984 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 985 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <string1,string2,...>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 986 } 987 PetscFunctionReturn(0); 988 } 989 990 #undef __FUNCT__ 991 #define __FUNCT__ "PetscOptionsTruthArray" 992 /*@C 993 PetscOptionsTruthArray - Gets an array of logical values (true or false) for a particular 994 option in the database. The values must be separated with commas with 995 no intervening spaces. 996 997 Collective on the communicator passed in PetscOptionsBegin() 998 999 Input Parameters: 1000 + opt - the option one is seeking 1001 . text - short string describing option 1002 . man - manual page for option 1003 - nmax - maximum number of values 1004 1005 Output Parameter: 1006 + value - location to copy values 1007 . nmax - actual number of values found 1008 - set - PETSC_TRUE if found, else PETSC_FALSE 1009 1010 Level: beginner 1011 1012 Notes: 1013 The user should pass in an array of doubles 1014 1015 Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 1016 1017 Concepts: options database^array of strings 1018 1019 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1020 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 1021 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 1022 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1023 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 1024 PetscOptionsList(), PetscOptionsEList() 1025 @*/ 1026 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthArray(const char opt[],const char text[],const char man[],PetscTruth value[],PetscInt *n,PetscTruth *set) 1027 { 1028 PetscErrorCode ierr; 1029 PetscInt i; 1030 1031 PetscFunctionBegin; 1032 ierr = PetscOptionsGetTruthArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr); 1033 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 1034 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%d",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr); 1035 for (i=1; i<*n; i++) { 1036 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%d",value[i]);CHKERRQ(ierr); 1037 } 1038 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr); 1039 } 1040 PetscFunctionReturn(0); 1041 } 1042 1043 1044 #undef __FUNCT__ 1045 #define __FUNCT__ "PetscOptionsHead" 1046 /*@C 1047 PetscOptionsHead - Puts a heading before listing any more published options. Used, for example, 1048 in KSPSetFromOptions_GMRES(). 1049 1050 Collective on the communicator passed in PetscOptionsBegin() 1051 1052 Input Parameter: 1053 . head - the heading text 1054 1055 1056 Level: intermediate 1057 1058 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 1059 1060 Can be followed by a call to PetscOptionsTail() in the same function. 1061 1062 Concepts: options database^subheading 1063 1064 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1065 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 1066 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 1067 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1068 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 1069 PetscOptionsList(), PetscOptionsEList() 1070 @*/ 1071 PetscErrorCode PETSC_DLLEXPORT PetscOptionsHead(const char head[]) 1072 { 1073 PetscErrorCode ierr; 1074 1075 PetscFunctionBegin; 1076 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 1077 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," %s\n",head);CHKERRQ(ierr); 1078 } 1079 PetscFunctionReturn(0); 1080 } 1081 1082 1083 1084 1085 1086 1087