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