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__ "PetscScanString" 166 /* 167 PetscScanString - 168 169 Bugs: 170 . Assumes process 0 of the given communicator has access to stdin 171 172 */ 173 static PetscErrorCode PetscScanString(MPI_Comm comm,PetscInt n,char str[],PetscTruth *set) 174 { 175 PetscInt i; 176 char c; 177 PetscMPIInt rank; 178 PetscErrorCode ierr; 179 180 PetscFunctionBegin; 181 ierr = MPI_Comm_rank(comm,&rank);CHKERRQ(ierr); 182 if (!rank) { 183 c = (char) getchar(); 184 i = 0; 185 while ( c != '\n' && i < n-1) { 186 str[i++] = c; 187 c = (char) getchar(); 188 } 189 str[i] = 0; 190 } 191 ierr = MPI_Bcast(str,n,MPI_CHAR,0,comm);CHKERRQ(ierr); 192 if (str[0]) *set = PETSC_TRUE; else *set = PETSC_FALSE; 193 PetscFunctionReturn(0); 194 } 195 196 #undef __FUNCT__ 197 #define __FUNCT__ "PetscOptionsGetFromTextInput" 198 /* 199 PetscOptionsGetFromTextInput 200 201 Notes: this isn't really practical, it is just to demonstrate the principle 202 203 Bugs: 204 + All processes must traverse through the exact same set of option queries do to the call to PetscScanString() 205 - Only works for PetscInt == int, PetscReal == double etc 206 207 */ 208 PetscErrorCode PetscOptionsGetFromTextInput() 209 { 210 PetscErrorCode ierr; 211 PetscOptions next = PetscOptionsObject.next; 212 char str[512]; 213 int id; 214 PetscTruth set; 215 double ir; 216 217 ierr = (*PetscPrintf)(PetscOptionsObject.comm,"%s -------------------------------------------------\n",PetscOptionsObject.title);CHKERRQ(ierr); 218 while (next) { 219 switch (next->type) { 220 case OPTION_HEAD: 221 break; 222 case OPTION_INT: 223 ierr = PetscPrintf(PetscOptionsObject.comm,"-%s%s <%d>: %s (%s)",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",next->option+1,*(int*)next->data,next->text,next->man);CHKERRQ(ierr); 224 ierr = PetscScanString(PETSC_COMM_WORLD,512,str,&set);CHKERRQ(ierr); 225 if (set) { 226 sscanf(str,"%d",&id); 227 next->set = PETSC_TRUE; 228 *((PetscInt*)next->data) = id; 229 } 230 break; 231 case OPTION_REAL: 232 ierr = PetscPrintf(PetscOptionsObject.comm,"-%s%s <%g>: %s (%s)",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",next->option+1,*(double*)next->data,next->text,next->man);CHKERRQ(ierr); 233 ierr = PetscScanString(PETSC_COMM_WORLD,512,str,&set);CHKERRQ(ierr); 234 if (set) { 235 sscanf(str,"%le",&ir); 236 next->set = PETSC_TRUE; 237 *((PetscReal*)next->data) = ir; 238 } 239 break; 240 case OPTION_LOGICAL: 241 case OPTION_STRING: 242 ierr = PetscPrintf(PetscOptionsObject.comm,"-%s%s <%s>: %s (%s)",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",next->option+1,(char*)next->data,next->text,next->man);CHKERRQ(ierr); 243 ierr = PetscScanString(PETSC_COMM_WORLD,512,str,&set);CHKERRQ(ierr); 244 if (set) { 245 next->set = PETSC_TRUE; 246 ierr = PetscStrcpy(next->data,str);CHKERRQ(ierr); 247 } 248 break; 249 default: 250 break; 251 } 252 next = next->next; 253 } 254 PetscFunctionReturn(0); 255 } 256 257 #undef __FUNCT__ 258 #define __FUNCT__ "PetscOptionsEnd_Private" 259 PetscErrorCode PetscOptionsEnd_Private(void) 260 { 261 PetscErrorCode ierr; 262 PetscOptions last; 263 char option[256],value[1024],tmp[32]; 264 PetscInt j; 265 266 PetscFunctionBegin; 267 268 if (PetscOptionsObject.next) { 269 if (PetscOptionsPublishCount == 0) { 270 ierr = PetscOptionsGetFromTextInput(); 271 } 272 } 273 274 ierr = PetscStrfree(PetscOptionsObject.title);CHKERRQ(ierr); PetscOptionsObject.title = 0; 275 ierr = PetscStrfree(PetscOptionsObject.prefix);CHKERRQ(ierr); PetscOptionsObject.prefix = 0; 276 277 /* reset counter to -2; this updates the screen with the new options for the selected method */ 278 if (PetscOptionsObject.changedmethod) PetscOptionsPublishCount = -2; 279 /* reset alreadyprinted flag */ 280 PetscOptionsObject.alreadyprinted = PETSC_FALSE; 281 282 while (PetscOptionsObject.next) { 283 if (PetscOptionsObject.next->set) { 284 if (PetscOptionsObject.prefix) { 285 ierr = PetscStrcpy(option,"-");CHKERRQ(ierr); 286 ierr = PetscStrcat(option,PetscOptionsObject.prefix);CHKERRQ(ierr); 287 ierr = PetscStrcat(option,PetscOptionsObject.next->option+1);CHKERRQ(ierr); 288 } else { 289 ierr = PetscStrcpy(option,PetscOptionsObject.next->option);CHKERRQ(ierr); 290 } 291 292 switch (PetscOptionsObject.next->type) { 293 case OPTION_HEAD: 294 break; 295 case OPTION_INT: 296 sprintf(value,"%d",(int) *(PetscInt*)PetscOptionsObject.next->data); 297 break; 298 case OPTION_REAL: 299 sprintf(value,"%g",(double) *(PetscReal*)PetscOptionsObject.next->data); 300 break; 301 case OPTION_REAL_ARRAY: 302 sprintf(value,"%g",(double)((PetscReal*)PetscOptionsObject.next->data)[0]); 303 for (j=1; j<PetscOptionsObject.next->arraylength; j++) { 304 sprintf(tmp,"%g",(double)((PetscReal*)PetscOptionsObject.next->data)[j]); 305 ierr = PetscStrcat(value,",");CHKERRQ(ierr); 306 ierr = PetscStrcat(value,tmp);CHKERRQ(ierr); 307 } 308 break; 309 case OPTION_LOGICAL: 310 ierr = PetscStrcpy(value,(char*)PetscOptionsObject.next->data);CHKERRQ(ierr); 311 break; 312 case OPTION_LIST: 313 ierr = PetscStrcpy(value,(char*)PetscOptionsObject.next->data);CHKERRQ(ierr); 314 break; 315 case OPTION_STRING: /* also handles string arrays */ 316 ierr = PetscStrcpy(value,(char*)PetscOptionsObject.next->data);CHKERRQ(ierr); 317 break; 318 } 319 ierr = PetscOptionsSetValue(option,value);CHKERRQ(ierr); 320 } 321 ierr = PetscStrfree(PetscOptionsObject.next->text);CHKERRQ(ierr); 322 ierr = PetscStrfree(PetscOptionsObject.next->option);CHKERRQ(ierr); 323 ierr = PetscFree(PetscOptionsObject.next->man);CHKERRQ(ierr); 324 ierr = PetscFree(PetscOptionsObject.next->data);CHKERRQ(ierr); 325 ierr = PetscFree(PetscOptionsObject.next->edata);CHKERRQ(ierr); 326 last = PetscOptionsObject.next; 327 PetscOptionsObject.next = PetscOptionsObject.next->next; 328 ierr = PetscFree(last);CHKERRQ(ierr); 329 } 330 PetscOptionsObject.next = 0; 331 PetscFunctionReturn(0); 332 } 333 334 #undef __FUNCT__ 335 #define __FUNCT__ "PetscOptionsEnum" 336 /*@C 337 PetscOptionsEnum - Gets the enum value for a particular option in the database. 338 339 Collective on the communicator passed in PetscOptionsBegin() 340 341 Input Parameters: 342 + opt - option name 343 . text - short string that describes the option 344 . man - manual page with additional information on option 345 . list - array containing the list of choices, followed by the enum name, followed by the enum prefix, followed by a null 346 - defaultv - the default (current) value 347 348 Output Parameter: 349 + value - the value to return 350 - flg - PETSC_TRUE if found, else PETSC_FALSE 351 352 Level: beginner 353 354 Concepts: options database 355 356 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 357 358 list is usually something like PCASMTypes or some other predefined list of enum names 359 360 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 361 PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 362 PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 363 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 364 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 365 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 366 PetscOptionsList(), PetscOptionsEList() 367 @*/ 368 PetscErrorCode PETSC_DLLEXPORT PetscOptionsEnum(const char opt[],const char text[],const char man[],const char **list,PetscEnum defaultv,PetscEnum *value,PetscTruth *set) 369 { 370 PetscErrorCode ierr; 371 PetscInt ntext = 0; 372 PetscInt tval; 373 PetscTruth tflg; 374 375 PetscFunctionBegin; 376 while (list[ntext++]) { 377 if (ntext > 50) SETERRQ(PETSC_ERR_ARG_WRONG,"List argument appears to be wrong or have more than 50 entries"); 378 } 379 if (ntext < 3) SETERRQ(PETSC_ERR_ARG_WRONG,"List argument must have at least two entries: typename and type prefix"); 380 ntext -= 3; 381 ierr = PetscOptionsEList(opt,text,man,list,ntext,list[defaultv],&tval,&tflg);CHKERRQ(ierr); 382 /* with PETSC_USE_64BIT_INDICES sizeof(PetscInt) != sizeof(PetscEnum) */ 383 if (tflg) *value = (PetscEnum)tval; 384 if (set) *set = tflg; 385 PetscFunctionReturn(0); 386 } 387 388 /* -------------------------------------------------------------------------------------------------------------*/ 389 #undef __FUNCT__ 390 #define __FUNCT__ "PetscOptionsInt" 391 /*@C 392 PetscOptionsInt - Gets the integer value for a particular option in the database. 393 394 Collective on the communicator passed in PetscOptionsBegin() 395 396 Input Parameters: 397 + opt - option name 398 . text - short string that describes the option 399 . man - manual page with additional information on option 400 - defaultv - the default (current) value 401 402 Output Parameter: 403 + value - the integer value to return 404 - flg - PETSC_TRUE if found, else PETSC_FALSE 405 406 Level: beginner 407 408 Concepts: options database^has int 409 410 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 411 412 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 413 PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 414 PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 415 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 416 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 417 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 418 PetscOptionsList(), PetscOptionsEList() 419 @*/ 420 PetscErrorCode PETSC_DLLEXPORT PetscOptionsInt(const char opt[],const char text[],const char man[],PetscInt defaultv,PetscInt *value,PetscTruth *set) 421 { 422 PetscErrorCode ierr; 423 PetscOptions amsopt; 424 425 PetscFunctionBegin; 426 if (PetscOptionsPublishCount == 0) { 427 ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_INT,&amsopt);CHKERRQ(ierr); 428 ierr = PetscMalloc(sizeof(PetscInt),&amsopt->data);CHKERRQ(ierr); 429 *(PetscInt*)amsopt->data = defaultv; 430 } 431 ierr = PetscOptionsGetInt(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr); 432 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 433 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%d>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,man);CHKERRQ(ierr); 434 } 435 PetscFunctionReturn(0); 436 } 437 438 #undef __FUNCT__ 439 #define __FUNCT__ "PetscOptionsString" 440 /*@C 441 PetscOptionsString - Gets the string value for a particular option in the database. 442 443 Collective on the communicator passed in PetscOptionsBegin() 444 445 Input Parameters: 446 + opt - option name 447 . text - short string that describes the option 448 . man - manual page with additional information on option 449 - defaultv - the default (current) value 450 451 Output Parameter: 452 + value - the value to return 453 - flg - PETSC_TRUE if found, else PETSC_FALSE 454 455 Level: beginner 456 457 Concepts: options database^has int 458 459 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 460 461 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 462 PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 463 PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 464 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 465 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 466 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 467 PetscOptionsList(), PetscOptionsEList() 468 @*/ 469 PetscErrorCode PETSC_DLLEXPORT PetscOptionsString(const char opt[],const char text[],const char man[],const char defaultv[],char value[],size_t len,PetscTruth *set) 470 { 471 PetscErrorCode ierr; 472 PetscOptions amsopt; 473 474 PetscFunctionBegin; 475 if (PetscOptionsPublishCount == 0) { 476 ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_STRING,&amsopt);CHKERRQ(ierr); 477 ierr = PetscMalloc(len*sizeof(char),&amsopt->data);CHKERRQ(ierr); 478 ierr = PetscStrcpy((char*)amsopt->data,defaultv);CHKERRQ(ierr); 479 } 480 ierr = PetscOptionsGetString(PetscOptionsObject.prefix,opt,value,len,set);CHKERRQ(ierr); 481 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 482 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%s>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,man);CHKERRQ(ierr); 483 } 484 PetscFunctionReturn(0); 485 } 486 487 #undef __FUNCT__ 488 #define __FUNCT__ "PetscOptionsReal" 489 /*@C 490 PetscOptionsReal - Gets the PetscReal value for a particular option in the database. 491 492 Collective on the communicator passed in PetscOptionsBegin() 493 494 Input Parameters: 495 + opt - option name 496 . text - short string that describes the option 497 . man - manual page with additional information on option 498 - defaultv - the default (current) value 499 500 Output Parameter: 501 + value - the value to return 502 - flg - PETSC_TRUE if found, else PETSC_FALSE 503 504 Level: beginner 505 506 Concepts: options database^has int 507 508 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 509 510 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 511 PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 512 PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 513 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 514 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 515 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 516 PetscOptionsList(), PetscOptionsEList() 517 @*/ 518 PetscErrorCode PETSC_DLLEXPORT PetscOptionsReal(const char opt[],const char text[],const char man[],PetscReal defaultv,PetscReal *value,PetscTruth *set) 519 { 520 PetscErrorCode ierr; 521 522 PetscFunctionBegin; 523 ierr = PetscOptionsGetReal(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr); 524 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 525 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%G>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,man);CHKERRQ(ierr); 526 } 527 PetscFunctionReturn(0); 528 } 529 530 #undef __FUNCT__ 531 #define __FUNCT__ "PetscOptionsScalar" 532 /*@C 533 PetscOptionsScalar - Gets the scalar value for a particular option in the database. 534 535 Collective on the communicator passed in PetscOptionsBegin() 536 537 Input Parameters: 538 + opt - option name 539 . text - short string that describes the option 540 . man - manual page with additional information on option 541 - defaultv - the default (current) value 542 543 Output Parameter: 544 + value - the value to return 545 - flg - PETSC_TRUE if found, else PETSC_FALSE 546 547 Level: beginner 548 549 Concepts: options database^has int 550 551 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 552 553 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 554 PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 555 PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 556 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 557 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 558 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 559 PetscOptionsList(), PetscOptionsEList() 560 @*/ 561 PetscErrorCode PETSC_DLLEXPORT PetscOptionsScalar(const char opt[],const char text[],const char man[],PetscScalar defaultv,PetscScalar *value,PetscTruth *set) 562 { 563 PetscErrorCode ierr; 564 565 PetscFunctionBegin; 566 #if !defined(PETSC_USE_COMPLEX) 567 ierr = PetscOptionsReal(opt,text,man,defaultv,value,set);CHKERRQ(ierr); 568 #else 569 ierr = PetscOptionsGetScalar(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr); 570 #endif 571 PetscFunctionReturn(0); 572 } 573 574 #undef __FUNCT__ 575 #define __FUNCT__ "PetscOptionsName" 576 /*@C 577 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 578 its value is set to false. 579 580 Collective on the communicator passed in PetscOptionsBegin() 581 582 Input Parameters: 583 + opt - option name 584 . text - short string that describes the option 585 - man - manual page with additional information on option 586 587 Output Parameter: 588 . flg - PETSC_TRUE if found, else PETSC_FALSE 589 590 Level: beginner 591 592 Concepts: options database^has int 593 594 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 595 596 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 597 PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 598 PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 599 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 600 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 601 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 602 PetscOptionsList(), PetscOptionsEList() 603 @*/ 604 PetscErrorCode PETSC_DLLEXPORT PetscOptionsName(const char opt[],const char text[],const char man[],PetscTruth *flg) 605 { 606 PetscErrorCode ierr; 607 608 PetscFunctionBegin; 609 ierr = PetscOptionsHasName(PetscOptionsObject.prefix,opt,flg);CHKERRQ(ierr); 610 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 611 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 612 } 613 PetscFunctionReturn(0); 614 } 615 616 #undef __FUNCT__ 617 #define __FUNCT__ "PetscOptionsList" 618 /*@C 619 PetscOptionsList - Puts a list of option values that a single one may be selected from 620 621 Collective on the communicator passed in PetscOptionsBegin() 622 623 Input Parameters: 624 + opt - option name 625 . text - short string that describes the option 626 . man - manual page with additional information on option 627 . list - the possible choices 628 - defaultv - the default (current) value 629 630 Output Parameter: 631 + value - the value to return 632 - set - PETSC_TRUE if found, else PETSC_FALSE 633 634 Level: intermediate 635 636 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 637 638 See PetscOptionsEList() for when the choices are given in a string array 639 640 To get a listing of all currently specified options, 641 see PetscOptionsPrint() or PetscOptionsGetAll() 642 643 Concepts: options database^list 644 645 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 646 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 647 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 648 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 649 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 650 PetscOptionsList(), PetscOptionsEList() 651 @*/ 652 PetscErrorCode PETSC_DLLEXPORT PetscOptionsList(const char opt[],const char ltext[],const char man[],PetscFList list,const char defaultv[],char value[],PetscInt len,PetscTruth *set) 653 { 654 PetscErrorCode ierr; 655 656 PetscFunctionBegin; 657 ierr = PetscOptionsGetString(PetscOptionsObject.prefix,opt,value,len,set);CHKERRQ(ierr); 658 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 659 ierr = PetscFListPrintTypes(list,PetscOptionsObject.comm,stdout,PetscOptionsObject.prefix,opt,ltext,man);CHKERRQ(ierr);CHKERRQ(ierr); 660 } 661 PetscFunctionReturn(0); 662 } 663 664 #undef __FUNCT__ 665 #define __FUNCT__ "PetscOptionsEList" 666 /*@C 667 PetscOptionsEList - Puts a list of option values that a single one may be selected from 668 669 Collective on the communicator passed in PetscOptionsBegin() 670 671 Input Parameters: 672 + opt - option name 673 . ltext - short string that describes the option 674 . man - manual page with additional information on option 675 . list - the possible choices 676 . ntext - number of choices 677 - defaultv - the default (current) value 678 679 Output Parameter: 680 + value - the index of the value to return 681 - set - PETSC_TRUE if found, else PETSC_FALSE 682 683 Level: intermediate 684 685 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 686 687 See PetscOptionsList() for when the choices are given in a PetscFList() 688 689 Concepts: options database^list 690 691 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 692 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 693 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 694 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 695 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 696 PetscOptionsList(), PetscOptionsEList() 697 @*/ 698 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) 699 { 700 PetscErrorCode ierr; 701 PetscInt i; 702 703 PetscFunctionBegin; 704 ierr = PetscOptionsGetEList(PetscOptionsObject.prefix,opt,list,ntext,value,set);CHKERRQ(ierr); 705 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 706 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%s> (choose one of)",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv);CHKERRQ(ierr); 707 for (i=0; i<ntext; i++){ 708 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," %s",list[i]);CHKERRQ(ierr); 709 } 710 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"\n");CHKERRQ(ierr); 711 } 712 PetscFunctionReturn(0); 713 } 714 715 #undef __FUNCT__ 716 #define __FUNCT__ "PetscOptionsTruthGroupBegin" 717 /*@C 718 PetscOptionsTruthGroupBegin - First in a series of logical queries on the options database for 719 which only a single value can be true. 720 721 Collective on the communicator passed in PetscOptionsBegin() 722 723 Input Parameters: 724 + opt - option name 725 . text - short string that describes the option 726 - man - manual page with additional information on option 727 728 Output Parameter: 729 . flg - whether that option was set or not 730 731 Level: intermediate 732 733 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 734 735 Must be followed by 0 or more PetscOptionsTruthGroup()s and PetscOptionsTruthGroupEnd() 736 737 Concepts: options database^logical group 738 739 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 740 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 741 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 742 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 743 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 744 PetscOptionsList(), PetscOptionsEList() 745 @*/ 746 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroupBegin(const char opt[],const char text[],const char man[],PetscTruth *flg) 747 { 748 PetscErrorCode ierr; 749 750 PetscFunctionBegin; 751 *flg = PETSC_FALSE; 752 ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,PETSC_NULL);CHKERRQ(ierr); 753 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 754 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," Pick at most one of -------------\n");CHKERRQ(ierr); 755 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 756 } 757 PetscFunctionReturn(0); 758 } 759 760 #undef __FUNCT__ 761 #define __FUNCT__ "PetscOptionsTruthGroup" 762 /*@C 763 PetscOptionsTruthGroup - One in a series of logical queries on the options database for 764 which only a single value can be true. 765 766 Collective on the communicator passed in PetscOptionsBegin() 767 768 Input Parameters: 769 + opt - option name 770 . text - short string that describes the option 771 - man - manual page with additional information on option 772 773 Output Parameter: 774 . flg - PETSC_TRUE if found, else PETSC_FALSE 775 776 Level: intermediate 777 778 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 779 780 Must follow a PetscOptionsTruthGroupBegin() and preceded a PetscOptionsTruthGroupEnd() 781 782 Concepts: options database^logical group 783 784 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 785 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 786 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 787 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 788 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 789 PetscOptionsList(), PetscOptionsEList() 790 @*/ 791 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroup(const char opt[],const char text[],const char man[],PetscTruth *flg) 792 { 793 PetscErrorCode ierr; 794 795 PetscFunctionBegin; 796 *flg = PETSC_FALSE; 797 ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,PETSC_NULL);CHKERRQ(ierr); 798 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 799 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 800 } 801 PetscFunctionReturn(0); 802 } 803 804 #undef __FUNCT__ 805 #define __FUNCT__ "PetscOptionsTruthGroupEnd" 806 /*@C 807 PetscOptionsTruthGroupEnd - Last in a series of logical queries on the options database for 808 which only a single value can be true. 809 810 Collective on the communicator passed in PetscOptionsBegin() 811 812 Input Parameters: 813 + opt - option name 814 . text - short string that describes the option 815 - man - manual page with additional information on option 816 817 Output Parameter: 818 . flg - PETSC_TRUE if found, else PETSC_FALSE 819 820 Level: intermediate 821 822 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 823 824 Must follow a PetscOptionsTruthGroupBegin() 825 826 Concepts: options database^logical group 827 828 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 829 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 830 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 831 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 832 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 833 PetscOptionsList(), PetscOptionsEList() 834 @*/ 835 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroupEnd(const char opt[],const char text[],const char man[],PetscTruth *flg) 836 { 837 PetscErrorCode ierr; 838 839 PetscFunctionBegin; 840 *flg = PETSC_FALSE; 841 ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,PETSC_NULL);CHKERRQ(ierr); 842 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 843 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 844 } 845 PetscFunctionReturn(0); 846 } 847 848 #undef __FUNCT__ 849 #define __FUNCT__ "PetscOptionsTruth" 850 /*@C 851 PetscOptionsTruth - Determines if a particular option is in the database with a true or false 852 853 Collective on the communicator passed in PetscOptionsBegin() 854 855 Input Parameters: 856 + opt - option name 857 . text - short string that describes the option 858 - man - manual page with additional information on option 859 860 Output Parameter: 861 . flg - PETSC_TRUE or PETSC_FALSE 862 . set - PETSC_TRUE if found, else PETSC_FALSE 863 864 Level: beginner 865 866 Concepts: options database^logical 867 868 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 869 870 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 871 PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 872 PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 873 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 874 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 875 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 876 PetscOptionsList(), PetscOptionsEList() 877 @*/ 878 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruth(const char opt[],const char text[],const char man[],PetscTruth deflt,PetscTruth *flg,PetscTruth *set) 879 { 880 PetscErrorCode ierr; 881 PetscTruth iset; 882 PetscOptions amsopt; 883 884 PetscFunctionBegin; 885 if (PetscOptionsPublishCount == 0) { 886 ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL,&amsopt);CHKERRQ(ierr); 887 ierr = PetscMalloc(16*sizeof(char),&amsopt->data);CHKERRQ(ierr); 888 ierr = PetscStrcpy((char*)amsopt->data,deflt ? "true" : "false");CHKERRQ(ierr); 889 } 890 ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,&iset);CHKERRQ(ierr); 891 if (!iset) { 892 if (flg) *flg = deflt; 893 } 894 if (set) *set = iset; 895 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 896 const char *v = PetscTruths[deflt]; 897 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: <%s> %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,v,text,man);CHKERRQ(ierr); 898 } 899 PetscFunctionReturn(0); 900 } 901 902 #undef __FUNCT__ 903 #define __FUNCT__ "PetscOptionsRealArray" 904 /*@C 905 PetscOptionsRealArray - Gets an array of double values for a particular 906 option in the database. The values must be separated with commas with 907 no intervening spaces. 908 909 Collective on the communicator passed in PetscOptionsBegin() 910 911 Input Parameters: 912 + opt - the option one is seeking 913 . text - short string describing option 914 . man - manual page for option 915 - nmax - maximum number of values 916 917 Output Parameter: 918 + value - location to copy values 919 . nmax - actual number of values found 920 - set - PETSC_TRUE if found, else PETSC_FALSE 921 922 Level: beginner 923 924 Notes: 925 The user should pass in an array of doubles 926 927 Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 928 929 Concepts: options database^array of strings 930 931 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 932 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 933 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 934 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 935 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 936 PetscOptionsList(), PetscOptionsEList() 937 @*/ 938 PetscErrorCode PETSC_DLLEXPORT PetscOptionsRealArray(const char opt[],const char text[],const char man[],PetscReal value[],PetscInt *n,PetscTruth *set) 939 { 940 PetscErrorCode ierr; 941 PetscInt i; 942 943 PetscFunctionBegin; 944 ierr = PetscOptionsGetRealArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr); 945 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 946 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%G",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr); 947 for (i=1; i<*n; i++) { 948 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%G",value[i]);CHKERRQ(ierr); 949 } 950 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr); 951 } 952 PetscFunctionReturn(0); 953 } 954 955 956 #undef __FUNCT__ 957 #define __FUNCT__ "PetscOptionsIntArray" 958 /*@C 959 PetscOptionsIntArray - Gets an array of integers for a particular 960 option in the database. The values must be separated with commas with 961 no intervening spaces. 962 963 Collective on the communicator passed in PetscOptionsBegin() 964 965 Input Parameters: 966 + opt - the option one is seeking 967 . text - short string describing option 968 . man - manual page for option 969 - n - maximum number of values 970 971 Output Parameter: 972 + value - location to copy values 973 . n - actual number of values found 974 - set - PETSC_TRUE if found, else PETSC_FALSE 975 976 Level: beginner 977 978 Notes: 979 The user should pass in an array of integers 980 981 Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 982 983 Concepts: options database^array of strings 984 985 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 986 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 987 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 988 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 989 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 990 PetscOptionsList(), PetscOptionsEList(), PetscOptionsRealArray() 991 @*/ 992 PetscErrorCode PETSC_DLLEXPORT PetscOptionsIntArray(const char opt[],const char text[],const char man[],PetscInt value[],PetscInt *n,PetscTruth *set) 993 { 994 PetscErrorCode ierr; 995 PetscInt i; 996 997 PetscFunctionBegin; 998 ierr = PetscOptionsGetIntArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr); 999 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 1000 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%d",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr); 1001 for (i=1; i<*n; i++) { 1002 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%d",value[i]);CHKERRQ(ierr); 1003 } 1004 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr); 1005 } 1006 PetscFunctionReturn(0); 1007 } 1008 1009 #undef __FUNCT__ 1010 #define __FUNCT__ "PetscOptionsStringArray" 1011 /*@C 1012 PetscOptionsStringArray - Gets an array of string values for a particular 1013 option in the database. The values must be separated with commas with 1014 no intervening spaces. 1015 1016 Collective on the communicator passed in PetscOptionsBegin() 1017 1018 Input Parameters: 1019 + opt - the option one is seeking 1020 . text - short string describing option 1021 . man - manual page for option 1022 - nmax - maximum number of strings 1023 1024 Output Parameter: 1025 + value - location to copy strings 1026 . nmax - actual number of strings found 1027 - set - PETSC_TRUE if found, else PETSC_FALSE 1028 1029 Level: beginner 1030 1031 Notes: 1032 The user should pass in an array of pointers to char, to hold all the 1033 strings returned by this function. 1034 1035 The user is responsible for deallocating the strings that are 1036 returned. The Fortran interface for this routine is not supported. 1037 1038 Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 1039 1040 Concepts: options database^array of strings 1041 1042 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1043 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 1044 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 1045 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1046 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 1047 PetscOptionsList(), PetscOptionsEList() 1048 @*/ 1049 PetscErrorCode PETSC_DLLEXPORT PetscOptionsStringArray(const char opt[],const char text[],const char man[],char *value[],PetscInt *nmax,PetscTruth *set) 1050 { 1051 PetscErrorCode ierr; 1052 1053 PetscFunctionBegin; 1054 ierr = PetscOptionsGetStringArray(PetscOptionsObject.prefix,opt,value,nmax,set);CHKERRQ(ierr); 1055 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 1056 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <string1,string2,...>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 1057 } 1058 PetscFunctionReturn(0); 1059 } 1060 1061 #undef __FUNCT__ 1062 #define __FUNCT__ "PetscOptionsTruthArray" 1063 /*@C 1064 PetscOptionsTruthArray - Gets an array of logical values (true or false) for a particular 1065 option in the database. The values must be separated with commas with 1066 no intervening spaces. 1067 1068 Collective on the communicator passed in PetscOptionsBegin() 1069 1070 Input Parameters: 1071 + opt - the option one is seeking 1072 . text - short string describing option 1073 . man - manual page for option 1074 - nmax - maximum number of values 1075 1076 Output Parameter: 1077 + value - location to copy values 1078 . nmax - actual number of values found 1079 - set - PETSC_TRUE if found, else PETSC_FALSE 1080 1081 Level: beginner 1082 1083 Notes: 1084 The user should pass in an array of doubles 1085 1086 Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 1087 1088 Concepts: options database^array of strings 1089 1090 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1091 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 1092 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 1093 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1094 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 1095 PetscOptionsList(), PetscOptionsEList() 1096 @*/ 1097 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthArray(const char opt[],const char text[],const char man[],PetscTruth value[],PetscInt *n,PetscTruth *set) 1098 { 1099 PetscErrorCode ierr; 1100 PetscInt i; 1101 1102 PetscFunctionBegin; 1103 ierr = PetscOptionsGetTruthArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr); 1104 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 1105 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%d",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr); 1106 for (i=1; i<*n; i++) { 1107 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%d",value[i]);CHKERRQ(ierr); 1108 } 1109 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr); 1110 } 1111 PetscFunctionReturn(0); 1112 } 1113 1114 1115 #undef __FUNCT__ 1116 #define __FUNCT__ "PetscOptionsHead" 1117 /*@C 1118 PetscOptionsHead - Puts a heading before listing any more published options. Used, for example, 1119 in KSPSetFromOptions_GMRES(). 1120 1121 Collective on the communicator passed in PetscOptionsBegin() 1122 1123 Input Parameter: 1124 . head - the heading text 1125 1126 1127 Level: intermediate 1128 1129 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 1130 1131 Can be followed by a call to PetscOptionsTail() in the same function. 1132 1133 Concepts: options database^subheading 1134 1135 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1136 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 1137 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 1138 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1139 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 1140 PetscOptionsList(), PetscOptionsEList() 1141 @*/ 1142 PetscErrorCode PETSC_DLLEXPORT PetscOptionsHead(const char head[]) 1143 { 1144 PetscErrorCode ierr; 1145 1146 PetscFunctionBegin; 1147 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 1148 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," %s\n",head);CHKERRQ(ierr); 1149 } 1150 PetscFunctionReturn(0); 1151 } 1152 1153 1154 1155 1156 1157 1158