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)\n",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)\n",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)\n",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 } else { 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 } 436 PetscFunctionReturn(0); 437 } 438 439 #undef __FUNCT__ 440 #define __FUNCT__ "PetscOptionsString" 441 /*@C 442 PetscOptionsString - Gets the string value for a particular option in the database. 443 444 Collective on the communicator passed in PetscOptionsBegin() 445 446 Input Parameters: 447 + opt - option name 448 . text - short string that describes the option 449 . man - manual page with additional information on option 450 - defaultv - the default (current) value 451 452 Output Parameter: 453 + value - the value to return 454 - flg - PETSC_TRUE if found, else PETSC_FALSE 455 456 Level: beginner 457 458 Concepts: options database^has int 459 460 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 461 462 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 463 PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 464 PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 465 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 466 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 467 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 468 PetscOptionsList(), PetscOptionsEList() 469 @*/ 470 PetscErrorCode PETSC_DLLEXPORT PetscOptionsString(const char opt[],const char text[],const char man[],const char defaultv[],char value[],size_t len,PetscTruth *set) 471 { 472 PetscErrorCode ierr; 473 PetscOptions amsopt; 474 475 PetscFunctionBegin; 476 if (PetscOptionsPublishCount == 0) { 477 ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_STRING,&amsopt);CHKERRQ(ierr); 478 ierr = PetscMalloc(len*sizeof(char),&amsopt->data);CHKERRQ(ierr); 479 ierr = PetscStrcpy((char*)amsopt->data,defaultv);CHKERRQ(ierr); 480 } else { 481 ierr = PetscOptionsGetString(PetscOptionsObject.prefix,opt,value,len,set);CHKERRQ(ierr); 482 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 483 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%s>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,man);CHKERRQ(ierr); 484 } 485 } 486 PetscFunctionReturn(0); 487 } 488 489 #undef __FUNCT__ 490 #define __FUNCT__ "PetscOptionsReal" 491 /*@C 492 PetscOptionsReal - Gets the PetscReal value for a particular option in the database. 493 494 Collective on the communicator passed in PetscOptionsBegin() 495 496 Input Parameters: 497 + opt - option name 498 . text - short string that describes the option 499 . man - manual page with additional information on option 500 - defaultv - the default (current) value 501 502 Output Parameter: 503 + value - the value to return 504 - flg - PETSC_TRUE if found, else PETSC_FALSE 505 506 Level: beginner 507 508 Concepts: options database^has int 509 510 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 511 512 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 513 PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 514 PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 515 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 516 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 517 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 518 PetscOptionsList(), PetscOptionsEList() 519 @*/ 520 PetscErrorCode PETSC_DLLEXPORT PetscOptionsReal(const char opt[],const char text[],const char man[],PetscReal defaultv,PetscReal *value,PetscTruth *set) 521 { 522 PetscErrorCode ierr; 523 524 PetscFunctionBegin; 525 ierr = PetscOptionsGetReal(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr); 526 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 527 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%G>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,man);CHKERRQ(ierr); 528 } 529 PetscFunctionReturn(0); 530 } 531 532 #undef __FUNCT__ 533 #define __FUNCT__ "PetscOptionsScalar" 534 /*@C 535 PetscOptionsScalar - Gets the scalar value for a particular option in the database. 536 537 Collective on the communicator passed in PetscOptionsBegin() 538 539 Input Parameters: 540 + opt - option name 541 . text - short string that describes the option 542 . man - manual page with additional information on option 543 - defaultv - the default (current) value 544 545 Output Parameter: 546 + value - the value to return 547 - flg - PETSC_TRUE if found, else PETSC_FALSE 548 549 Level: beginner 550 551 Concepts: options database^has int 552 553 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 554 555 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 556 PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 557 PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 558 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 559 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 560 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 561 PetscOptionsList(), PetscOptionsEList() 562 @*/ 563 PetscErrorCode PETSC_DLLEXPORT PetscOptionsScalar(const char opt[],const char text[],const char man[],PetscScalar defaultv,PetscScalar *value,PetscTruth *set) 564 { 565 PetscErrorCode ierr; 566 567 PetscFunctionBegin; 568 #if !defined(PETSC_USE_COMPLEX) 569 ierr = PetscOptionsReal(opt,text,man,defaultv,value,set);CHKERRQ(ierr); 570 #else 571 ierr = PetscOptionsGetScalar(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr); 572 #endif 573 PetscFunctionReturn(0); 574 } 575 576 #undef __FUNCT__ 577 #define __FUNCT__ "PetscOptionsName" 578 /*@C 579 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 580 its value is set to false. 581 582 Collective on the communicator passed in PetscOptionsBegin() 583 584 Input Parameters: 585 + opt - option name 586 . text - short string that describes the option 587 - man - manual page with additional information on option 588 589 Output Parameter: 590 . flg - PETSC_TRUE if found, else PETSC_FALSE 591 592 Level: beginner 593 594 Concepts: options database^has int 595 596 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 597 598 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 599 PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 600 PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 601 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 602 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 603 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 604 PetscOptionsList(), PetscOptionsEList() 605 @*/ 606 PetscErrorCode PETSC_DLLEXPORT PetscOptionsName(const char opt[],const char text[],const char man[],PetscTruth *flg) 607 { 608 PetscErrorCode ierr; 609 610 PetscFunctionBegin; 611 ierr = PetscOptionsHasName(PetscOptionsObject.prefix,opt,flg);CHKERRQ(ierr); 612 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 613 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 614 } 615 PetscFunctionReturn(0); 616 } 617 618 #undef __FUNCT__ 619 #define __FUNCT__ "PetscOptionsList" 620 /*@C 621 PetscOptionsList - Puts a list of option values that a single one may be selected from 622 623 Collective on the communicator passed in PetscOptionsBegin() 624 625 Input Parameters: 626 + opt - option name 627 . text - short string that describes the option 628 . man - manual page with additional information on option 629 . list - the possible choices 630 - defaultv - the default (current) value 631 632 Output Parameter: 633 + value - the value to return 634 - set - PETSC_TRUE if found, else PETSC_FALSE 635 636 Level: intermediate 637 638 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 639 640 See PetscOptionsEList() for when the choices are given in a string array 641 642 To get a listing of all currently specified options, 643 see PetscOptionsPrint() or PetscOptionsGetAll() 644 645 Concepts: options database^list 646 647 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 648 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 649 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 650 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 651 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 652 PetscOptionsList(), PetscOptionsEList() 653 @*/ 654 PetscErrorCode PETSC_DLLEXPORT PetscOptionsList(const char opt[],const char ltext[],const char man[],PetscFList list,const char defaultv[],char value[],PetscInt len,PetscTruth *set) 655 { 656 PetscErrorCode ierr; 657 658 PetscFunctionBegin; 659 ierr = PetscOptionsGetString(PetscOptionsObject.prefix,opt,value,len,set);CHKERRQ(ierr); 660 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 661 ierr = PetscFListPrintTypes(list,PetscOptionsObject.comm,stdout,PetscOptionsObject.prefix,opt,ltext,man);CHKERRQ(ierr);CHKERRQ(ierr); 662 } 663 PetscFunctionReturn(0); 664 } 665 666 #undef __FUNCT__ 667 #define __FUNCT__ "PetscOptionsEList" 668 /*@C 669 PetscOptionsEList - Puts a list of option values that a single one may be selected from 670 671 Collective on the communicator passed in PetscOptionsBegin() 672 673 Input Parameters: 674 + opt - option name 675 . ltext - short string that describes the option 676 . man - manual page with additional information on option 677 . list - the possible choices 678 . ntext - number of choices 679 - defaultv - the default (current) value 680 681 Output Parameter: 682 + value - the index of the value to return 683 - set - PETSC_TRUE if found, else PETSC_FALSE 684 685 Level: intermediate 686 687 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 688 689 See PetscOptionsList() for when the choices are given in a PetscFList() 690 691 Concepts: options database^list 692 693 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 694 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 695 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 696 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 697 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 698 PetscOptionsList(), PetscOptionsEList() 699 @*/ 700 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) 701 { 702 PetscErrorCode ierr; 703 PetscInt i; 704 705 PetscFunctionBegin; 706 ierr = PetscOptionsGetEList(PetscOptionsObject.prefix,opt,list,ntext,value,set);CHKERRQ(ierr); 707 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 708 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%s> (choose one of)",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv);CHKERRQ(ierr); 709 for (i=0; i<ntext; i++){ 710 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," %s",list[i]);CHKERRQ(ierr); 711 } 712 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"\n");CHKERRQ(ierr); 713 } 714 PetscFunctionReturn(0); 715 } 716 717 #undef __FUNCT__ 718 #define __FUNCT__ "PetscOptionsTruthGroupBegin" 719 /*@C 720 PetscOptionsTruthGroupBegin - First in a series of logical queries on the options database for 721 which only a single value can be true. 722 723 Collective on the communicator passed in PetscOptionsBegin() 724 725 Input Parameters: 726 + opt - option name 727 . text - short string that describes the option 728 - man - manual page with additional information on option 729 730 Output Parameter: 731 . flg - whether that option was set or not 732 733 Level: intermediate 734 735 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 736 737 Must be followed by 0 or more PetscOptionsTruthGroup()s and PetscOptionsTruthGroupEnd() 738 739 Concepts: options database^logical group 740 741 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 742 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 743 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 744 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 745 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 746 PetscOptionsList(), PetscOptionsEList() 747 @*/ 748 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroupBegin(const char opt[],const char text[],const char man[],PetscTruth *flg) 749 { 750 PetscErrorCode ierr; 751 752 PetscFunctionBegin; 753 *flg = PETSC_FALSE; 754 ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,PETSC_NULL);CHKERRQ(ierr); 755 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 756 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," Pick at most one of -------------\n");CHKERRQ(ierr); 757 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 758 } 759 PetscFunctionReturn(0); 760 } 761 762 #undef __FUNCT__ 763 #define __FUNCT__ "PetscOptionsTruthGroup" 764 /*@C 765 PetscOptionsTruthGroup - One in a series of logical queries on the options database for 766 which only a single value can be true. 767 768 Collective on the communicator passed in PetscOptionsBegin() 769 770 Input Parameters: 771 + opt - option name 772 . text - short string that describes the option 773 - man - manual page with additional information on option 774 775 Output Parameter: 776 . flg - PETSC_TRUE if found, else PETSC_FALSE 777 778 Level: intermediate 779 780 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 781 782 Must follow a PetscOptionsTruthGroupBegin() and preceded a PetscOptionsTruthGroupEnd() 783 784 Concepts: options database^logical group 785 786 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 787 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 788 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 789 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 790 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 791 PetscOptionsList(), PetscOptionsEList() 792 @*/ 793 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroup(const char opt[],const char text[],const char man[],PetscTruth *flg) 794 { 795 PetscErrorCode ierr; 796 797 PetscFunctionBegin; 798 *flg = PETSC_FALSE; 799 ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,PETSC_NULL);CHKERRQ(ierr); 800 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 801 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 802 } 803 PetscFunctionReturn(0); 804 } 805 806 #undef __FUNCT__ 807 #define __FUNCT__ "PetscOptionsTruthGroupEnd" 808 /*@C 809 PetscOptionsTruthGroupEnd - Last in a series of logical queries on the options database for 810 which only a single value can be true. 811 812 Collective on the communicator passed in PetscOptionsBegin() 813 814 Input Parameters: 815 + opt - option name 816 . text - short string that describes the option 817 - man - manual page with additional information on option 818 819 Output Parameter: 820 . flg - PETSC_TRUE if found, else PETSC_FALSE 821 822 Level: intermediate 823 824 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 825 826 Must follow a PetscOptionsTruthGroupBegin() 827 828 Concepts: options database^logical group 829 830 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 831 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 832 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 833 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 834 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 835 PetscOptionsList(), PetscOptionsEList() 836 @*/ 837 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroupEnd(const char opt[],const char text[],const char man[],PetscTruth *flg) 838 { 839 PetscErrorCode ierr; 840 841 PetscFunctionBegin; 842 *flg = PETSC_FALSE; 843 ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,PETSC_NULL);CHKERRQ(ierr); 844 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 845 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 846 } 847 PetscFunctionReturn(0); 848 } 849 850 #undef __FUNCT__ 851 #define __FUNCT__ "PetscOptionsTruth" 852 /*@C 853 PetscOptionsTruth - Determines if a particular option is in the database with a true or false 854 855 Collective on the communicator passed in PetscOptionsBegin() 856 857 Input Parameters: 858 + opt - option name 859 . text - short string that describes the option 860 - man - manual page with additional information on option 861 862 Output Parameter: 863 . flg - PETSC_TRUE or PETSC_FALSE 864 . set - PETSC_TRUE if found, else PETSC_FALSE 865 866 Level: beginner 867 868 Concepts: options database^logical 869 870 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 871 872 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 873 PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 874 PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 875 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 876 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 877 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 878 PetscOptionsList(), PetscOptionsEList() 879 @*/ 880 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruth(const char opt[],const char text[],const char man[],PetscTruth deflt,PetscTruth *flg,PetscTruth *set) 881 { 882 PetscErrorCode ierr; 883 PetscTruth iset; 884 PetscOptions amsopt; 885 886 PetscFunctionBegin; 887 if (PetscOptionsPublishCount == 0) { 888 ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL,&amsopt);CHKERRQ(ierr); 889 ierr = PetscMalloc(16*sizeof(char),&amsopt->data);CHKERRQ(ierr); 890 ierr = PetscStrcpy((char*)amsopt->data,deflt ? "true" : "false");CHKERRQ(ierr); 891 } else { 892 ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,&iset);CHKERRQ(ierr); 893 if (!iset) { 894 if (flg) *flg = deflt; 895 } 896 if (set) *set = iset; 897 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 898 const char *v = PetscTruths[deflt]; 899 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: <%s> %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,v,text,man);CHKERRQ(ierr); 900 } 901 } 902 PetscFunctionReturn(0); 903 } 904 905 #undef __FUNCT__ 906 #define __FUNCT__ "PetscOptionsRealArray" 907 /*@C 908 PetscOptionsRealArray - Gets an array of double values for a particular 909 option in the database. The values must be separated with commas with 910 no intervening spaces. 911 912 Collective on the communicator passed in PetscOptionsBegin() 913 914 Input Parameters: 915 + opt - the option one is seeking 916 . text - short string describing option 917 . man - manual page for option 918 - nmax - maximum number of values 919 920 Output Parameter: 921 + value - location to copy values 922 . nmax - actual number of values found 923 - set - PETSC_TRUE if found, else PETSC_FALSE 924 925 Level: beginner 926 927 Notes: 928 The user should pass in an array of doubles 929 930 Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 931 932 Concepts: options database^array of strings 933 934 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 935 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 936 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 937 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 938 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 939 PetscOptionsList(), PetscOptionsEList() 940 @*/ 941 PetscErrorCode PETSC_DLLEXPORT PetscOptionsRealArray(const char opt[],const char text[],const char man[],PetscReal value[],PetscInt *n,PetscTruth *set) 942 { 943 PetscErrorCode ierr; 944 PetscInt i; 945 946 PetscFunctionBegin; 947 ierr = PetscOptionsGetRealArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr); 948 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 949 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%G",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr); 950 for (i=1; i<*n; i++) { 951 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%G",value[i]);CHKERRQ(ierr); 952 } 953 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr); 954 } 955 PetscFunctionReturn(0); 956 } 957 958 959 #undef __FUNCT__ 960 #define __FUNCT__ "PetscOptionsIntArray" 961 /*@C 962 PetscOptionsIntArray - Gets an array of integers for a particular 963 option in the database. The values must be separated with commas with 964 no intervening spaces. 965 966 Collective on the communicator passed in PetscOptionsBegin() 967 968 Input Parameters: 969 + opt - the option one is seeking 970 . text - short string describing option 971 . man - manual page for option 972 - n - maximum number of values 973 974 Output Parameter: 975 + value - location to copy values 976 . n - actual number of values found 977 - set - PETSC_TRUE if found, else PETSC_FALSE 978 979 Level: beginner 980 981 Notes: 982 The user should pass in an array of integers 983 984 Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 985 986 Concepts: options database^array of strings 987 988 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 989 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 990 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 991 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 992 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 993 PetscOptionsList(), PetscOptionsEList(), PetscOptionsRealArray() 994 @*/ 995 PetscErrorCode PETSC_DLLEXPORT PetscOptionsIntArray(const char opt[],const char text[],const char man[],PetscInt value[],PetscInt *n,PetscTruth *set) 996 { 997 PetscErrorCode ierr; 998 PetscInt i; 999 1000 PetscFunctionBegin; 1001 ierr = PetscOptionsGetIntArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr); 1002 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 1003 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%d",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr); 1004 for (i=1; i<*n; i++) { 1005 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%d",value[i]);CHKERRQ(ierr); 1006 } 1007 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr); 1008 } 1009 PetscFunctionReturn(0); 1010 } 1011 1012 #undef __FUNCT__ 1013 #define __FUNCT__ "PetscOptionsStringArray" 1014 /*@C 1015 PetscOptionsStringArray - Gets an array of string values for a particular 1016 option in the database. The values must be separated with commas with 1017 no intervening spaces. 1018 1019 Collective on the communicator passed in PetscOptionsBegin() 1020 1021 Input Parameters: 1022 + opt - the option one is seeking 1023 . text - short string describing option 1024 . man - manual page for option 1025 - nmax - maximum number of strings 1026 1027 Output Parameter: 1028 + value - location to copy strings 1029 . nmax - actual number of strings found 1030 - set - PETSC_TRUE if found, else PETSC_FALSE 1031 1032 Level: beginner 1033 1034 Notes: 1035 The user should pass in an array of pointers to char, to hold all the 1036 strings returned by this function. 1037 1038 The user is responsible for deallocating the strings that are 1039 returned. The Fortran interface for this routine is not supported. 1040 1041 Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 1042 1043 Concepts: options database^array of strings 1044 1045 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1046 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 1047 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 1048 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1049 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 1050 PetscOptionsList(), PetscOptionsEList() 1051 @*/ 1052 PetscErrorCode PETSC_DLLEXPORT PetscOptionsStringArray(const char opt[],const char text[],const char man[],char *value[],PetscInt *nmax,PetscTruth *set) 1053 { 1054 PetscErrorCode ierr; 1055 1056 PetscFunctionBegin; 1057 ierr = PetscOptionsGetStringArray(PetscOptionsObject.prefix,opt,value,nmax,set);CHKERRQ(ierr); 1058 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 1059 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <string1,string2,...>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 1060 } 1061 PetscFunctionReturn(0); 1062 } 1063 1064 #undef __FUNCT__ 1065 #define __FUNCT__ "PetscOptionsTruthArray" 1066 /*@C 1067 PetscOptionsTruthArray - Gets an array of logical values (true or false) for a particular 1068 option in the database. The values must be separated with commas with 1069 no intervening spaces. 1070 1071 Collective on the communicator passed in PetscOptionsBegin() 1072 1073 Input Parameters: 1074 + opt - the option one is seeking 1075 . text - short string describing option 1076 . man - manual page for option 1077 - nmax - maximum number of values 1078 1079 Output Parameter: 1080 + value - location to copy values 1081 . nmax - actual number of values found 1082 - set - PETSC_TRUE if found, else PETSC_FALSE 1083 1084 Level: beginner 1085 1086 Notes: 1087 The user should pass in an array of doubles 1088 1089 Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 1090 1091 Concepts: options database^array of strings 1092 1093 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1094 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 1095 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 1096 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1097 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 1098 PetscOptionsList(), PetscOptionsEList() 1099 @*/ 1100 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthArray(const char opt[],const char text[],const char man[],PetscTruth value[],PetscInt *n,PetscTruth *set) 1101 { 1102 PetscErrorCode ierr; 1103 PetscInt i; 1104 1105 PetscFunctionBegin; 1106 ierr = PetscOptionsGetTruthArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr); 1107 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 1108 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%d",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr); 1109 for (i=1; i<*n; i++) { 1110 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%d",value[i]);CHKERRQ(ierr); 1111 } 1112 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr); 1113 } 1114 PetscFunctionReturn(0); 1115 } 1116 1117 1118 #undef __FUNCT__ 1119 #define __FUNCT__ "PetscOptionsHead" 1120 /*@C 1121 PetscOptionsHead - Puts a heading before listing any more published options. Used, for example, 1122 in KSPSetFromOptions_GMRES(). 1123 1124 Collective on the communicator passed in PetscOptionsBegin() 1125 1126 Input Parameter: 1127 . head - the heading text 1128 1129 1130 Level: intermediate 1131 1132 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 1133 1134 Can be followed by a call to PetscOptionsTail() in the same function. 1135 1136 Concepts: options database^subheading 1137 1138 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1139 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 1140 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 1141 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1142 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 1143 PetscOptionsList(), PetscOptionsEList() 1144 @*/ 1145 PetscErrorCode PETSC_DLLEXPORT PetscOptionsHead(const char head[]) 1146 { 1147 PetscErrorCode ierr; 1148 1149 PetscFunctionBegin; 1150 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 1151 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," %s\n",head);CHKERRQ(ierr); 1152 } 1153 PetscFunctionReturn(0); 1154 } 1155 1156 1157 1158 1159 1160 1161