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 "petscsys.h" /*I "petscsys.h" I*/ 9 #if defined(PETSC_HAVE_STDLIB_H) 10 #include <stdlib.h> 11 #endif 12 13 /* 14 Keep a linked list of options that have been posted and we are waiting for 15 user selection. See the manual page for PetscOptionsBegin() 16 17 Eventually we'll attach this beast to a MPI_Comm 18 */ 19 PetscOptionsObjectType PetscOptionsObject; 20 PetscInt PetscOptionsPublishCount = 0; 21 22 #undef __FUNCT__ 23 #define __FUNCT__ "PetscOptionsBegin_Private" 24 /* 25 Handles setting up the data structure in a call to PetscOptionsBegin() 26 */ 27 PetscErrorCode PetscOptionsBegin_Private(MPI_Comm comm,const char prefix[],const char title[],const char mansec[]) 28 { 29 PetscErrorCode ierr; 30 31 PetscFunctionBegin; 32 PetscOptionsObject.next = 0; 33 PetscOptionsObject.comm = comm; 34 PetscOptionsObject.changedmethod = PETSC_FALSE; 35 if (PetscOptionsObject.prefix) { 36 ierr = PetscFree(PetscOptionsObject.prefix);CHKERRQ(ierr); PetscOptionsObject.prefix = 0; 37 } 38 ierr = PetscStrallocpy(prefix,&PetscOptionsObject.prefix);CHKERRQ(ierr); 39 if (PetscOptionsObject.title) { 40 ierr = PetscFree(PetscOptionsObject.title);CHKERRQ(ierr); PetscOptionsObject.title = 0; 41 } 42 ierr = PetscStrallocpy(title,&PetscOptionsObject.title);CHKERRQ(ierr); 43 44 ierr = PetscOptionsHasName(PETSC_NULL,"-help",&PetscOptionsObject.printhelp);CHKERRQ(ierr); 45 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1) { 46 if (!PetscOptionsObject.alreadyprinted) { 47 ierr = (*PetscHelpPrintf)(comm,"%s -------------------------------------------------\n",title);CHKERRQ(ierr); 48 } 49 } 50 PetscFunctionReturn(0); 51 } 52 53 /* 54 Handles adding another option to the list of options within this particular PetscOptionsBegin() PetscOptionsEnd() 55 */ 56 #undef __FUNCT__ 57 #define __FUNCT__ "PetscOptionsCreate_Private" 58 static int PetscOptionsCreate_Private(const char opt[],const char text[],const char man[],PetscOptionType t,PetscOptions *amsopt) 59 { 60 int ierr; 61 PetscOptions next; 62 63 PetscFunctionBegin; 64 ierr = PetscNew(struct _p_PetscOptions,amsopt);CHKERRQ(ierr); 65 (*amsopt)->next = 0; 66 (*amsopt)->set = PETSC_FALSE; 67 (*amsopt)->type = t; 68 (*amsopt)->data = 0; 69 70 ierr = PetscStrallocpy(text,&(*amsopt)->text);CHKERRQ(ierr); 71 ierr = PetscStrallocpy(opt,&(*amsopt)->option);CHKERRQ(ierr); 72 ierr = PetscStrallocpy(man,&(*amsopt)->man);CHKERRQ(ierr); 73 74 if (!PetscOptionsObject.next) { 75 PetscOptionsObject.next = *amsopt; 76 } else { 77 next = PetscOptionsObject.next; 78 while (next->next) next = next->next; 79 next->next = *amsopt; 80 } 81 PetscFunctionReturn(0); 82 } 83 84 #undef __FUNCT__ 85 #define __FUNCT__ "PetscScanString" 86 /* 87 PetscScanString - Gets user input via stdin from process and broadcasts to all processes 88 89 Collective on MPI_Comm 90 91 Input Parameters: 92 + commm - communicator for the broadcast, must be PETSC_COMM_WORLD 93 . n - length of the string, must be the same on all processes 94 - str - location to store input 95 96 Bugs: 97 . Assumes process 0 of the given communicator has access to stdin 98 99 */ 100 static PetscErrorCode PetscScanString(MPI_Comm comm,size_t n,char str[]) 101 { 102 size_t i; 103 char c; 104 PetscMPIInt rank,nm; 105 PetscErrorCode ierr; 106 107 PetscFunctionBegin; 108 ierr = MPI_Comm_rank(comm,&rank);CHKERRQ(ierr); 109 if (!rank) { 110 c = (char) getchar(); 111 i = 0; 112 while ( c != '\n' && i < n-1) { 113 str[i++] = c; 114 c = (char) getchar(); 115 } 116 str[i] = 0; 117 } 118 nm = PetscMPIIntCast(n); 119 ierr = MPI_Bcast(str,nm,MPI_CHAR,0,comm);CHKERRQ(ierr); 120 PetscFunctionReturn(0); 121 } 122 123 #undef __FUNCT__ 124 #define __FUNCT__ "PetscOptionsGetFromTextInput" 125 /* 126 PetscOptionsGetFromTextInput - Presents all the PETSc Options processed by the program so the user may change them at runtime 127 128 Notes: this isn't really practical, it is just to demonstrate the principle 129 130 Bugs: 131 + All processes must traverse through the exact same set of option queries do to the call to PetscScanString() 132 . Internal strings have arbitrary length and string copies are not checked that they fit into string space 133 - Only works for PetscInt == int, PetscReal == double etc 134 135 Developer Notes: Normally the GUI that presents the options the user and retrieves the values would be running in a different 136 address space and communicating with the PETSc program 137 138 */ 139 PetscErrorCode PetscOptionsGetFromTextInput() 140 { 141 PetscErrorCode ierr; 142 PetscOptions next = PetscOptionsObject.next; 143 char str[512]; 144 PetscInt id; 145 PetscReal ir,*valr; 146 PetscInt *vald; 147 size_t i; 148 149 ierr = (*PetscPrintf)(PETSC_COMM_WORLD,"%s -------------------------------------------------\n",PetscOptionsObject.title);CHKERRQ(ierr); 150 while (next) { 151 switch (next->type) { 152 case OPTION_HEAD: 153 break; 154 case OPTION_INT_ARRAY: 155 ierr = PetscPrintf(PETSC_COMM_WORLD,"-%s%s <",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",next->option+1);CHKERRQ(ierr); 156 vald = (PetscInt*) next->data; 157 for (i=0; i<next->arraylength; i++) { 158 ierr = PetscPrintf(PETSC_COMM_WORLD,"%d",vald[i]);CHKERRQ(ierr); 159 if (i < next->arraylength-1) { 160 ierr = PetscPrintf(PETSC_COMM_WORLD,",");CHKERRQ(ierr); 161 } 162 } 163 ierr = PetscPrintf(PETSC_COMM_WORLD,">: %s (%s)",next->text,next->man);CHKERRQ(ierr); 164 ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr); 165 if (str[0]) { 166 PetscToken token; 167 PetscInt n=0,nmax = next->arraylength,*dvalue = (PetscInt*)next->data,start,end; 168 size_t len; 169 char* value; 170 PetscTruth foundrange; 171 172 next->set = PETSC_TRUE; 173 value = str; 174 ierr = PetscTokenCreate(value,',',&token);CHKERRQ(ierr); 175 ierr = PetscTokenFind(token,&value);CHKERRQ(ierr); 176 while (n < nmax) { 177 if (!value) break; 178 179 /* look for form d-D where d and D are integers */ 180 foundrange = PETSC_FALSE; 181 ierr = PetscStrlen(value,&len);CHKERRQ(ierr); 182 if (value[0] == '-') i=2; 183 else i=1; 184 for (;i<len; i++) { 185 if (value[i] == '-') { 186 if (i == len-1) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_USER,"Error in %D-th array entry %s\n",n,value); 187 value[i] = 0; 188 ierr = PetscOptionsAtoi(value,&start);CHKERRQ(ierr); 189 ierr = PetscOptionsAtoi(value+i+1,&end);CHKERRQ(ierr); 190 if (end <= start) SETERRQ3(PETSC_COMM_SELF,PETSC_ERR_USER,"Error in %D-th array entry, %s-%s cannot have decreasing list",n,value,value+i+1); 191 if (n + end - start - 1 >= nmax) SETERRQ4(PETSC_COMM_SELF,PETSC_ERR_USER,"Error in %D-th array entry, not enough space in left in array (%D) to contain entire range from %D to %D",n,nmax-n,start,end); 192 for (;start<end; start++) { 193 *dvalue = start; dvalue++;n++; 194 } 195 foundrange = PETSC_TRUE; 196 break; 197 } 198 } 199 if (!foundrange) { 200 ierr = PetscOptionsAtoi(value,dvalue);CHKERRQ(ierr); 201 dvalue++; 202 n++; 203 } 204 ierr = PetscTokenFind(token,&value);CHKERRQ(ierr); 205 } 206 ierr = PetscTokenDestroy(token);CHKERRQ(ierr); 207 } 208 break; 209 case OPTION_REAL_ARRAY: 210 ierr = PetscPrintf(PETSC_COMM_WORLD,"-%s%s <",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",next->option+1);CHKERRQ(ierr); 211 valr = (PetscReal*) next->data; 212 for (i=0; i<next->arraylength; i++) { 213 ierr = PetscPrintf(PETSC_COMM_WORLD,"%g",valr[i]);CHKERRQ(ierr); 214 if (i < next->arraylength-1) { 215 ierr = PetscPrintf(PETSC_COMM_WORLD,",");CHKERRQ(ierr); 216 } 217 } 218 ierr = PetscPrintf(PETSC_COMM_WORLD,">: %s (%s)",next->text,next->man);CHKERRQ(ierr); 219 ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr); 220 if (str[0]) { 221 PetscToken token; 222 PetscInt n=0,nmax = next->arraylength; 223 PetscReal *dvalue = (PetscReal*)next->data; 224 char* value; 225 226 next->set = PETSC_TRUE; 227 value = str; 228 ierr = PetscTokenCreate(value,',',&token);CHKERRQ(ierr); 229 ierr = PetscTokenFind(token,&value);CHKERRQ(ierr); 230 while (n < nmax) { 231 if (!value) break; 232 ierr = PetscOptionsAtod(value,dvalue);CHKERRQ(ierr); 233 dvalue++; 234 n++; 235 ierr = PetscTokenFind(token,&value);CHKERRQ(ierr); 236 } 237 ierr = PetscTokenDestroy(token);CHKERRQ(ierr); 238 } 239 break; 240 case OPTION_INT: 241 ierr = PetscPrintf(PETSC_COMM_WORLD,"-%s%s <%d>: %s (%s)",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",next->option+1,*(int*)next->data,next->text,next->man);CHKERRQ(ierr); 242 ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr); 243 if (str[0]) { 244 #if defined(PETSC_USE_64BIT_INDICES) 245 sscanf(str,"%lld",&id); 246 #else 247 sscanf(str,"%d",&id); 248 #endif 249 next->set = PETSC_TRUE; 250 *((PetscInt*)next->data) = id; 251 } 252 break; 253 case OPTION_REAL: 254 ierr = PetscPrintf(PETSC_COMM_WORLD,"-%s%s <%g>: %s (%s)",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",next->option+1,*(double*)next->data,next->text,next->man);CHKERRQ(ierr); 255 ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr); 256 if (str[0]) { 257 #if defined(PETSC_USE_SCALAR_SINGLE) 258 sscanf(str,"%e",&ir); 259 #else 260 sscanf(str,"%le",&ir); 261 #endif 262 next->set = PETSC_TRUE; 263 *((PetscReal*)next->data) = ir; 264 } 265 break; 266 case OPTION_LOGICAL: 267 case OPTION_STRING: 268 ierr = PetscPrintf(PETSC_COMM_WORLD,"-%s%s <%s>: %s (%s)",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",next->option+1,(char*)next->data,next->text,next->man);CHKERRQ(ierr); 269 ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr); 270 if (str[0]) { 271 next->set = PETSC_TRUE; 272 ierr = PetscStrcpy((char*)next->data,str);CHKERRQ(ierr); 273 } 274 break; 275 case OPTION_LIST: 276 ierr = PetscFListPrintTypes(PETSC_COMM_WORLD,stdout,PetscOptionsObject.prefix,next->option,next->text,next->man,next->flist,(char*)next->data);CHKERRQ(ierr); 277 ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr); 278 if (str[0]) { 279 PetscOptionsObject.changedmethod = PETSC_TRUE; 280 next->set = PETSC_TRUE; 281 ierr = PetscStrcpy((char*)next->data,str);CHKERRQ(ierr); 282 } 283 break; 284 default: 285 break; 286 } 287 next = next->next; 288 } 289 PetscFunctionReturn(0); 290 } 291 292 #if defined(PETSC_HAVE_AMS) 293 #define CHKERRAMS(err) if (err) {char *msg; AMS_Explain_error((err), &(msg)); SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"AMS Error: %s",msg);} 294 #define CHKERRAMSFieldName(err,fn) if (err) {char *msg; AMS_Explain_error((err), &(msg)); SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_LIB,"Fieldname %s, AMS Error: %s",fn,msg);} 295 296 static int count = 0; 297 298 #undef __FUNCT__ 299 #define __FUNCT__ "PetscOptionsAMSDestroy" 300 PetscErrorCode PetscOptionsAMSDestroy(void) 301 { 302 PetscErrorCode ierr; 303 AMS_Comm acomm = -1; 304 AMS_Memory amem = -1; 305 char options[16]; 306 const char *string = "Exit"; 307 308 /* the next line is a bug, this will only work if all processors are here, the comm passed in is ignored!!! */ 309 ierr = PetscViewerAMSGetAMSComm(PETSC_VIEWER_AMS_(PETSC_COMM_WORLD),&acomm);CHKERRQ(ierr); 310 sprintf(options,"Options_%d",count++); 311 ierr = AMS_Memory_create(acomm,options,&amem);CHKERRAMS(ierr); 312 ierr = AMS_Memory_add_field(amem,"Exit",&string,1,AMS_STRING,AMS_READ,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,"Exit"); 313 314 ierr = AMS_Memory_take_access(amem);CHKERRAMS(ierr); 315 ierr = AMS_Memory_publish(amem);CHKERRAMS(ierr); 316 ierr = AMS_Memory_grant_access(amem);CHKERRAMS(ierr); 317 /* wait until accessor has unlocked the memory */ 318 ierr = AMS_Memory_lock(amem,0);CHKERRAMS(ierr); 319 ierr = AMS_Memory_take_access(amem);CHKERRAMS(ierr); 320 ierr = AMS_Memory_grant_access(amem);CHKERRAMS(ierr); 321 ierr = AMS_Memory_destroy(amem);CHKERRAMS(ierr); 322 PetscFunctionReturn(0); 323 } 324 325 #undef __FUNCT__ 326 #define __FUNCT__ "PetscOptionsAMSInput" 327 /* 328 PetscOptionsAMSInput - Presents all the PETSc Options processed by the program so the user may change them at runtime using the AMS 329 330 Bugs: 331 + All processes must traverse through the exact same set of option queries do to the call to PetscScanString() 332 . Internal strings have arbitrary length and string copies are not checked that they fit into string space 333 - Only works for PetscInt == int, PetscReal == double etc 334 335 336 */ 337 PetscErrorCode PetscOptionsAMSInput() 338 { 339 PetscErrorCode ierr; 340 PetscOptions next = PetscOptionsObject.next; 341 static int mancount = 0; 342 char options[16]; 343 AMS_Comm acomm = -1; 344 AMS_Memory amem = -1; 345 PetscTruth changedmethod = PETSC_FALSE; 346 char manname[16]; 347 348 /* the next line is a bug, this will only work if all processors are here, the comm passed in is ignored!!! */ 349 ierr = PetscViewerAMSGetAMSComm(PETSC_VIEWER_AMS_(PETSC_COMM_WORLD),&acomm);CHKERRQ(ierr); 350 sprintf(options,"Options_%d",count++); 351 ierr = AMS_Memory_create(acomm,options,&amem);CHKERRAMS(ierr); 352 ierr = AMS_Memory_take_access(amem);CHKERRAMS(ierr); 353 PetscOptionsObject.pprefix = PetscOptionsObject.prefix; /* AMS will change this, so cannot pass prefix directly */ 354 355 ierr = AMS_Memory_add_field(amem,PetscOptionsObject.title,&PetscOptionsObject.pprefix,1,AMS_STRING,AMS_READ,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,PetscOptionsObject.title); 356 // ierr = AMS_Memory_add_field(amem,"mansec",&PetscOptionsObject.pprefix,1,AMS_STRING,AMS_READ,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMS(ierr); 357 ierr = AMS_Memory_add_field(amem,"ChangedMethod",&changedmethod,1,AMS_BOOLEAN,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,"ChangedMethod"); 358 359 while (next) { 360 ierr = AMS_Memory_add_field(amem,next->option,&next->set,1,AMS_INT,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->option); 361 ierr = PetscMalloc(sizeof(char*),&next->pman);CHKERRQ(ierr); 362 *(char **)next->pman = next->man; 363 sprintf(manname,"man_%d",mancount++); 364 ierr = AMS_Memory_add_field(amem,manname,next->pman,1,AMS_STRING,AMS_READ,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,manname); 365 366 switch (next->type) { 367 case OPTION_HEAD: 368 break; 369 case OPTION_INT_ARRAY: 370 ierr = AMS_Memory_add_field(amem,next->text,next->data,next->arraylength,AMS_INT,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->text); 371 break; 372 case OPTION_REAL_ARRAY: 373 ierr = AMS_Memory_add_field(amem,next->text,next->data,next->arraylength,AMS_DOUBLE,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->text); 374 break; 375 case OPTION_INT: 376 ierr = AMS_Memory_add_field(amem,next->text,next->data,1,AMS_INT,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->text); 377 break; 378 case OPTION_REAL: 379 ierr = AMS_Memory_add_field(amem,next->text,next->data,1,AMS_DOUBLE,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->text); 380 break; 381 case OPTION_LOGICAL: 382 ierr = AMS_Memory_add_field(amem,next->text,next->data,1,AMS_BOOLEAN,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->text); 383 break; 384 case OPTION_LOGICAL_ARRAY: 385 ierr = AMS_Memory_add_field(amem,next->text,next->data,next->arraylength,AMS_BOOLEAN,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->text); 386 break; 387 case OPTION_STRING: 388 ierr = AMS_Memory_add_field(amem,next->text,next->data,1,AMS_STRING,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->text); 389 break; 390 case OPTION_STRING_ARRAY: 391 ierr = AMS_Memory_add_field(amem,next->text,next->data,next->arraylength,AMS_STRING,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->text); 392 break; 393 case OPTION_LIST: 394 {PetscInt ntext; 395 char ldefault[128]; 396 ierr = PetscStrcpy(ldefault,"DEFAULT:");CHKERRQ(ierr); 397 ierr = PetscStrcat(ldefault,next->text);CHKERRQ(ierr); 398 ierr = AMS_Memory_add_field(amem,ldefault,next->data,1,AMS_STRING,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,ldefault); 399 ierr = PetscFListGet(next->flist,(char***)&next->edata,&ntext);CHKERRQ(ierr); 400 ierr = AMS_Memory_add_field(amem,next->text,next->edata,ntext-1,AMS_STRING,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->text); 401 break;} 402 case OPTION_ELIST: 403 {PetscInt ntext = next->nlist; 404 char ldefault[128]; 405 ierr = PetscStrcpy(ldefault,"DEFAULT:");CHKERRQ(ierr); 406 ierr = PetscStrcat(ldefault,next->text);CHKERRQ(ierr); 407 ierr = AMS_Memory_add_field(amem,ldefault,next->data,1,AMS_STRING,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,ldefault); 408 ierr = PetscMalloc((ntext+1)*sizeof(char**),&next->edata);CHKERRQ(ierr); 409 ierr = PetscMemcpy(next->edata,next->list,ntext*sizeof(char*));CHKERRQ(ierr); 410 ierr = AMS_Memory_add_field(amem,next->text,next->edata,ntext,AMS_STRING,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->text); 411 break;} 412 default: 413 break; 414 } 415 next = next->next; 416 } 417 418 ierr = AMS_Memory_publish(amem);CHKERRAMS(ierr); 419 ierr = AMS_Memory_grant_access(amem);CHKERRAMS(ierr); 420 /* wait until accessor has unlocked the memory */ 421 ierr = AMS_Memory_lock(amem,0);CHKERRAMS(ierr); 422 ierr = AMS_Memory_take_access(amem);CHKERRAMS(ierr); 423 424 /* reset counter to -2; this updates the screen with the new options for the selected method */ 425 if (changedmethod) PetscOptionsPublishCount = -2; 426 427 ierr = AMS_Memory_grant_access(amem);CHKERRAMS(ierr); 428 ierr = AMS_Memory_destroy(amem);CHKERRAMS(ierr); 429 PetscFunctionReturn(0); 430 } 431 #endif 432 433 #undef __FUNCT__ 434 #define __FUNCT__ "PetscOptionsEnd_Private" 435 PetscErrorCode PetscOptionsEnd_Private(void) 436 { 437 PetscErrorCode ierr; 438 PetscOptions last; 439 char option[256],value[1024],tmp[32]; 440 size_t j; 441 442 PetscFunctionBegin; 443 444 CHKMEMQ; 445 if (PetscOptionsObject.next) { 446 if (!PetscOptionsPublishCount) { 447 #if defined(PETSC_HAVE_AMS) 448 ierr = PetscOptionsAMSInput();CHKERRQ(ierr); 449 #else 450 ierr = PetscOptionsGetFromTextInput();CHKERRQ(ierr); 451 #endif 452 } 453 } 454 455 ierr = PetscFree(PetscOptionsObject.title);CHKERRQ(ierr); PetscOptionsObject.title = 0; 456 ierr = PetscFree(PetscOptionsObject.prefix);CHKERRQ(ierr); PetscOptionsObject.prefix = 0; 457 458 /* reset counter to -2; this updates the screen with the new options for the selected method */ 459 if (PetscOptionsObject.changedmethod) PetscOptionsPublishCount = -2; 460 /* reset alreadyprinted flag */ 461 PetscOptionsObject.alreadyprinted = PETSC_FALSE; 462 463 while (PetscOptionsObject.next) { 464 if (PetscOptionsObject.next->set) { 465 if (PetscOptionsObject.prefix) { 466 ierr = PetscStrcpy(option,"-");CHKERRQ(ierr); 467 ierr = PetscStrcat(option,PetscOptionsObject.prefix);CHKERRQ(ierr); 468 ierr = PetscStrcat(option,PetscOptionsObject.next->option+1);CHKERRQ(ierr); 469 } else { 470 ierr = PetscStrcpy(option,PetscOptionsObject.next->option);CHKERRQ(ierr); 471 } 472 473 switch (PetscOptionsObject.next->type) { 474 case OPTION_HEAD: 475 break; 476 case OPTION_INT_ARRAY: 477 sprintf(value,"%d",(int)((PetscInt*)PetscOptionsObject.next->data)[0]); 478 for (j=1; j<PetscOptionsObject.next->arraylength; j++) { 479 sprintf(tmp,"%d",(int)((PetscInt*)PetscOptionsObject.next->data)[j]); 480 ierr = PetscStrcat(value,",");CHKERRQ(ierr); 481 ierr = PetscStrcat(value,tmp);CHKERRQ(ierr); 482 } 483 break; 484 case OPTION_INT: 485 sprintf(value,"%d",(int) *(PetscInt*)PetscOptionsObject.next->data); 486 break; 487 case OPTION_REAL: 488 sprintf(value,"%g",(double) *(PetscReal*)PetscOptionsObject.next->data); 489 break; 490 case OPTION_REAL_ARRAY: 491 sprintf(value,"%g",(double)((PetscReal*)PetscOptionsObject.next->data)[0]); 492 for (j=1; j<PetscOptionsObject.next->arraylength; j++) { 493 sprintf(tmp,"%g",(double)((PetscReal*)PetscOptionsObject.next->data)[j]); 494 ierr = PetscStrcat(value,",");CHKERRQ(ierr); 495 ierr = PetscStrcat(value,tmp);CHKERRQ(ierr); 496 } 497 break; 498 case OPTION_LOGICAL: 499 sprintf(value,"%d",*(int*)PetscOptionsObject.next->data); 500 break; 501 case OPTION_LOGICAL_ARRAY: 502 sprintf(value,"%d",(int)((PetscTruth*)PetscOptionsObject.next->data)[0]); 503 for (j=1; j<PetscOptionsObject.next->arraylength; j++) { 504 sprintf(tmp,"%d",(int)((PetscTruth*)PetscOptionsObject.next->data)[j]); 505 ierr = PetscStrcat(value,",");CHKERRQ(ierr); 506 ierr = PetscStrcat(value,tmp);CHKERRQ(ierr); 507 } 508 break; 509 case OPTION_LIST: 510 case OPTION_ELIST: 511 ierr = PetscStrcpy(value,*(char**)PetscOptionsObject.next->data);CHKERRQ(ierr); 512 break; 513 case OPTION_STRING: 514 ierr = PetscStrcpy(value,*(char**)PetscOptionsObject.next->data);CHKERRQ(ierr); 515 case OPTION_STRING_ARRAY: 516 sprintf(value,"%s",((char**)PetscOptionsObject.next->data)[0]); 517 for (j=1; j<PetscOptionsObject.next->arraylength; j++) { 518 sprintf(tmp,"%s",((char**)PetscOptionsObject.next->data)[j]); 519 ierr = PetscStrcat(value,",");CHKERRQ(ierr); 520 ierr = PetscStrcat(value,tmp);CHKERRQ(ierr); 521 } 522 break; 523 } 524 ierr = PetscOptionsSetValue(option,value);CHKERRQ(ierr); 525 } 526 ierr = PetscFree(PetscOptionsObject.next->text);CHKERRQ(ierr); 527 ierr = PetscFree(PetscOptionsObject.next->option);CHKERRQ(ierr); 528 ierr = PetscFree(PetscOptionsObject.next->man);CHKERRQ(ierr); 529 ierr = PetscFree(PetscOptionsObject.next->data);CHKERRQ(ierr); 530 ierr = PetscFree(PetscOptionsObject.next->edata);CHKERRQ(ierr); 531 last = PetscOptionsObject.next; 532 PetscOptionsObject.next = PetscOptionsObject.next->next; 533 ierr = PetscFree(last);CHKERRQ(ierr); 534 CHKMEMQ; 535 } 536 CHKMEMQ; 537 PetscOptionsObject.next = 0; 538 PetscFunctionReturn(0); 539 } 540 541 #undef __FUNCT__ 542 #define __FUNCT__ "PetscOptionsEnum" 543 /*@C 544 PetscOptionsEnum - Gets the enum value for a particular option in the database. 545 546 Logically Collective on the communicator passed in PetscOptionsBegin() 547 548 Input Parameters: 549 + opt - option name 550 . text - short string that describes the option 551 . man - manual page with additional information on option 552 . list - array containing the list of choices, followed by the enum name, followed by the enum prefix, followed by a null 553 - defaultv - the default (current) value 554 555 Output Parameter: 556 + value - the value to return 557 - flg - PETSC_TRUE if found, else PETSC_FALSE 558 559 Level: beginner 560 561 Concepts: options database 562 563 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 564 565 list is usually something like PCASMTypes or some other predefined list of enum names 566 567 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 568 PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 569 PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 570 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 571 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 572 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 573 PetscOptionsList(), PetscOptionsEList() 574 @*/ 575 PetscErrorCode PETSC_DLLEXPORT PetscOptionsEnum(const char opt[],const char text[],const char man[],const char *const*list,PetscEnum defaultv,PetscEnum *value,PetscTruth *set) 576 { 577 PetscErrorCode ierr; 578 PetscInt ntext = 0; 579 PetscInt tval; 580 PetscTruth tflg; 581 582 PetscFunctionBegin; 583 while (list[ntext++]) { 584 if (ntext > 50) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"List argument appears to be wrong or have more than 50 entries"); 585 } 586 if (ntext < 3) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"List argument must have at least two entries: typename and type prefix"); 587 ntext -= 3; 588 ierr = PetscOptionsEList(opt,text,man,list,ntext,list[defaultv],&tval,&tflg);CHKERRQ(ierr); 589 /* with PETSC_USE_64BIT_INDICES sizeof(PetscInt) != sizeof(PetscEnum) */ 590 if (tflg) *value = (PetscEnum)tval; 591 if (set) *set = tflg; 592 PetscFunctionReturn(0); 593 } 594 595 /* -------------------------------------------------------------------------------------------------------------*/ 596 #undef __FUNCT__ 597 #define __FUNCT__ "PetscOptionsInt" 598 /*@C 599 PetscOptionsInt - Gets the integer value for a particular option in the database. 600 601 Logically Collective on the communicator passed in PetscOptionsBegin() 602 603 Input Parameters: 604 + opt - option name 605 . text - short string that describes the option 606 . man - manual page with additional information on option 607 - defaultv - the default (current) value 608 609 Output Parameter: 610 + value - the integer value to return 611 - flg - PETSC_TRUE if found, else PETSC_FALSE 612 613 Level: beginner 614 615 Concepts: options database^has int 616 617 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 618 619 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 620 PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 621 PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 622 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 623 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 624 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 625 PetscOptionsList(), PetscOptionsEList() 626 @*/ 627 PetscErrorCode PETSC_DLLEXPORT PetscOptionsInt(const char opt[],const char text[],const char man[],PetscInt defaultv,PetscInt *value,PetscTruth *set) 628 { 629 PetscErrorCode ierr; 630 PetscOptions amsopt; 631 632 PetscFunctionBegin; 633 if (!PetscOptionsPublishCount) { 634 ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_INT,&amsopt);CHKERRQ(ierr); 635 ierr = PetscMalloc(sizeof(PetscInt),&amsopt->data);CHKERRQ(ierr); 636 *(PetscInt*)amsopt->data = defaultv; 637 } 638 ierr = PetscOptionsGetInt(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr); 639 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 640 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%d>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,man);CHKERRQ(ierr); 641 } 642 PetscFunctionReturn(0); 643 } 644 645 #undef __FUNCT__ 646 #define __FUNCT__ "PetscOptionsString" 647 /*@C 648 PetscOptionsString - Gets the string value for a particular option in the database. 649 650 Logically Collective on the communicator passed in PetscOptionsBegin() 651 652 Input Parameters: 653 + opt - option name 654 . text - short string that describes the option 655 . man - manual page with additional information on option 656 . defaultv - the default (current) value 657 - len - length of the result string including null terminator 658 659 Output Parameter: 660 + value - the value to return 661 - flg - PETSC_TRUE if found, else PETSC_FALSE 662 663 Level: beginner 664 665 Concepts: options database^has int 666 667 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 668 669 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 670 PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 671 PetscOptionsInt(), PetscOptionsReal(), PetscOptionsTruth(), 672 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 673 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 674 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 675 PetscOptionsList(), PetscOptionsEList() 676 @*/ 677 PetscErrorCode PETSC_DLLEXPORT PetscOptionsString(const char opt[],const char text[],const char man[],const char defaultv[],char value[],size_t len,PetscTruth *set) 678 { 679 PetscErrorCode ierr; 680 PetscOptions amsopt; 681 682 PetscFunctionBegin; 683 if (!PetscOptionsPublishCount) { 684 ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_STRING,&amsopt);CHKERRQ(ierr); 685 ierr = PetscMalloc(sizeof(char*),&amsopt->data);CHKERRQ(ierr); 686 *(const char**)amsopt->data = defaultv; 687 } 688 ierr = PetscOptionsGetString(PetscOptionsObject.prefix,opt,value,len,set);CHKERRQ(ierr); 689 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 690 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%s>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,man);CHKERRQ(ierr); 691 } 692 PetscFunctionReturn(0); 693 } 694 695 #undef __FUNCT__ 696 #define __FUNCT__ "PetscOptionsReal" 697 /*@C 698 PetscOptionsReal - Gets the PetscReal value for a particular option in the database. 699 700 Logically 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 - defaultv - the default (current) value 707 708 Output Parameter: 709 + value - the value to return 710 - flg - PETSC_TRUE if found, else PETSC_FALSE 711 712 Level: beginner 713 714 Concepts: options database^has int 715 716 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 717 718 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 719 PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 720 PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 721 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 722 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 723 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 724 PetscOptionsList(), PetscOptionsEList() 725 @*/ 726 PetscErrorCode PETSC_DLLEXPORT PetscOptionsReal(const char opt[],const char text[],const char man[],PetscReal defaultv,PetscReal *value,PetscTruth *set) 727 { 728 PetscErrorCode ierr; 729 PetscOptions amsopt; 730 731 PetscFunctionBegin; 732 if (!PetscOptionsPublishCount) { 733 ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_REAL,&amsopt);CHKERRQ(ierr); 734 ierr = PetscMalloc(sizeof(PetscReal),&amsopt->data);CHKERRQ(ierr); 735 *(PetscReal*)amsopt->data = defaultv; 736 } 737 ierr = PetscOptionsGetReal(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr); 738 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 739 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%G>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,man);CHKERRQ(ierr); 740 } 741 PetscFunctionReturn(0); 742 } 743 744 #undef __FUNCT__ 745 #define __FUNCT__ "PetscOptionsScalar" 746 /*@C 747 PetscOptionsScalar - Gets the scalar value for a particular option in the database. 748 749 Logically Collective on the communicator passed in PetscOptionsBegin() 750 751 Input Parameters: 752 + opt - option name 753 . text - short string that describes the option 754 . man - manual page with additional information on option 755 - defaultv - the default (current) value 756 757 Output Parameter: 758 + value - the value to return 759 - flg - PETSC_TRUE if found, else PETSC_FALSE 760 761 Level: beginner 762 763 Concepts: options database^has int 764 765 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 766 767 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 768 PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 769 PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 770 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 771 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 772 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 773 PetscOptionsList(), PetscOptionsEList() 774 @*/ 775 PetscErrorCode PETSC_DLLEXPORT PetscOptionsScalar(const char opt[],const char text[],const char man[],PetscScalar defaultv,PetscScalar *value,PetscTruth *set) 776 { 777 PetscErrorCode ierr; 778 779 PetscFunctionBegin; 780 #if !defined(PETSC_USE_COMPLEX) 781 ierr = PetscOptionsReal(opt,text,man,defaultv,value,set);CHKERRQ(ierr); 782 #else 783 ierr = PetscOptionsGetScalar(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr); 784 #endif 785 PetscFunctionReturn(0); 786 } 787 788 #undef __FUNCT__ 789 #define __FUNCT__ "PetscOptionsName" 790 /*@C 791 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 792 its value is set to false. 793 794 Logically Collective on the communicator passed in PetscOptionsBegin() 795 796 Input Parameters: 797 + opt - option name 798 . text - short string that describes the option 799 - man - manual page with additional information on option 800 801 Output Parameter: 802 . flg - PETSC_TRUE if found, else PETSC_FALSE 803 804 Level: beginner 805 806 Concepts: options database^has int 807 808 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 809 810 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 811 PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 812 PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 813 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 814 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 815 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 816 PetscOptionsList(), PetscOptionsEList() 817 @*/ 818 PetscErrorCode PETSC_DLLEXPORT PetscOptionsName(const char opt[],const char text[],const char man[],PetscTruth *flg) 819 { 820 PetscErrorCode ierr; 821 PetscOptions amsopt; 822 823 PetscFunctionBegin; 824 if (!PetscOptionsPublishCount) { 825 ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL,&amsopt);CHKERRQ(ierr); 826 ierr = PetscMalloc(sizeof(PetscTruth),&amsopt->data);CHKERRQ(ierr); 827 *(PetscTruth*)amsopt->data = PETSC_FALSE; 828 } 829 ierr = PetscOptionsHasName(PetscOptionsObject.prefix,opt,flg);CHKERRQ(ierr); 830 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 831 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 832 } 833 PetscFunctionReturn(0); 834 } 835 836 #undef __FUNCT__ 837 #define __FUNCT__ "PetscOptionsList" 838 /*@C 839 PetscOptionsList - Puts a list of option values that a single one may be selected from 840 841 Logically Collective on the communicator passed in PetscOptionsBegin() 842 843 Input Parameters: 844 + opt - option name 845 . text - short string that describes the option 846 . man - manual page with additional information on option 847 . list - the possible choices 848 . defaultv - the default (current) value 849 - len - the length of the character array value 850 851 Output Parameter: 852 + value - the value to return 853 - set - PETSC_TRUE if found, else PETSC_FALSE 854 855 Level: intermediate 856 857 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 858 859 See PetscOptionsEList() for when the choices are given in a string array 860 861 To get a listing of all currently specified options, 862 see PetscOptionsPrint() or PetscOptionsGetAll() 863 864 Concepts: options database^list 865 866 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 867 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 868 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 869 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 870 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 871 PetscOptionsList(), PetscOptionsEList() 872 @*/ 873 PetscErrorCode PETSC_DLLEXPORT PetscOptionsList(const char opt[],const char ltext[],const char man[],PetscFList list,const char defaultv[],char value[],size_t len,PetscTruth *set) 874 { 875 PetscErrorCode ierr; 876 PetscOptions amsopt; 877 878 PetscFunctionBegin; 879 if (!PetscOptionsPublishCount) { 880 ierr = PetscOptionsCreate_Private(opt,ltext,man,OPTION_LIST,&amsopt);CHKERRQ(ierr); 881 ierr = PetscMalloc(sizeof(char*),&amsopt->data);CHKERRQ(ierr); 882 *(const char**)amsopt->data = defaultv; 883 amsopt->flist = list; 884 } 885 ierr = PetscOptionsGetString(PetscOptionsObject.prefix,opt,value,len,set);CHKERRQ(ierr); 886 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 887 ierr = PetscFListPrintTypes(PetscOptionsObject.comm,stdout,PetscOptionsObject.prefix,opt,ltext,man,list,defaultv);CHKERRQ(ierr);CHKERRQ(ierr); 888 } 889 PetscFunctionReturn(0); 890 } 891 892 #undef __FUNCT__ 893 #define __FUNCT__ "PetscOptionsEList" 894 /*@C 895 PetscOptionsEList - Puts a list of option values that a single one may be selected from 896 897 Logically Collective on the communicator passed in PetscOptionsBegin() 898 899 Input Parameters: 900 + opt - option name 901 . ltext - short string that describes the option 902 . man - manual page with additional information on option 903 . list - the possible choices 904 . ntext - number of choices 905 - defaultv - the default (current) value 906 907 Output Parameter: 908 + value - the index of the value to return 909 - set - PETSC_TRUE if found, else PETSC_FALSE 910 911 Level: intermediate 912 913 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 914 915 See PetscOptionsList() for when the choices are given in a PetscFList() 916 917 Concepts: options database^list 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() 925 @*/ 926 PetscErrorCode PETSC_DLLEXPORT PetscOptionsEList(const char opt[],const char ltext[],const char man[],const char *const*list,PetscInt ntext,const char defaultv[],PetscInt *value,PetscTruth *set) 927 { 928 PetscErrorCode ierr; 929 PetscInt i; 930 PetscOptions amsopt; 931 932 PetscFunctionBegin; 933 if (!PetscOptionsPublishCount) { 934 ierr = PetscOptionsCreate_Private(opt,ltext,man,OPTION_ELIST,&amsopt);CHKERRQ(ierr); 935 ierr = PetscMalloc(sizeof(char*),&amsopt->data);CHKERRQ(ierr); 936 *(const char**)amsopt->data = defaultv; 937 amsopt->list = list; 938 amsopt->nlist = ntext; 939 } 940 ierr = PetscOptionsGetEList(PetscOptionsObject.prefix,opt,list,ntext,value,set);CHKERRQ(ierr); 941 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 942 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%s> (choose one of)",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv);CHKERRQ(ierr); 943 for (i=0; i<ntext; i++){ 944 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," %s",list[i]);CHKERRQ(ierr); 945 } 946 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"\n");CHKERRQ(ierr); 947 } 948 PetscFunctionReturn(0); 949 } 950 951 #undef __FUNCT__ 952 #define __FUNCT__ "PetscOptionsTruthGroupBegin" 953 /*@C 954 PetscOptionsTruthGroupBegin - First in a series of logical queries on the options database for 955 which at most a single value can be true. 956 957 Logically Collective on the communicator passed in PetscOptionsBegin() 958 959 Input Parameters: 960 + opt - option name 961 . text - short string that describes the option 962 - man - manual page with additional information on option 963 964 Output Parameter: 965 . flg - whether that option was set or not 966 967 Level: intermediate 968 969 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 970 971 Must be followed by 0 or more PetscOptionsTruthGroup()s and PetscOptionsTruthGroupEnd() 972 973 Concepts: options database^logical group 974 975 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 976 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 977 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 978 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 979 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 980 PetscOptionsList(), PetscOptionsEList() 981 @*/ 982 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroupBegin(const char opt[],const char text[],const char man[],PetscTruth *flg) 983 { 984 PetscErrorCode ierr; 985 PetscOptions amsopt; 986 987 PetscFunctionBegin; 988 if (!PetscOptionsPublishCount) { 989 ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL,&amsopt);CHKERRQ(ierr); 990 ierr = PetscMalloc(sizeof(PetscTruth),&amsopt->data);CHKERRQ(ierr); 991 *(PetscTruth*)amsopt->data = PETSC_FALSE; 992 } 993 *flg = PETSC_FALSE; 994 ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,PETSC_NULL);CHKERRQ(ierr); 995 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 996 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," Pick at most one of -------------\n");CHKERRQ(ierr); 997 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 998 } 999 PetscFunctionReturn(0); 1000 } 1001 1002 #undef __FUNCT__ 1003 #define __FUNCT__ "PetscOptionsTruthGroup" 1004 /*@C 1005 PetscOptionsTruthGroup - One in a series of logical queries on the options database for 1006 which at most a single value can be true. 1007 1008 Logically Collective on the communicator passed in PetscOptionsBegin() 1009 1010 Input Parameters: 1011 + opt - option name 1012 . text - short string that describes the option 1013 - man - manual page with additional information on option 1014 1015 Output Parameter: 1016 . flg - PETSC_TRUE if found, else PETSC_FALSE 1017 1018 Level: intermediate 1019 1020 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 1021 1022 Must follow a PetscOptionsTruthGroupBegin() and preceded a PetscOptionsTruthGroupEnd() 1023 1024 Concepts: options database^logical group 1025 1026 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1027 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 1028 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 1029 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1030 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 1031 PetscOptionsList(), PetscOptionsEList() 1032 @*/ 1033 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroup(const char opt[],const char text[],const char man[],PetscTruth *flg) 1034 { 1035 PetscErrorCode ierr; 1036 PetscOptions amsopt; 1037 1038 PetscFunctionBegin; 1039 if (!PetscOptionsPublishCount) { 1040 ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL,&amsopt);CHKERRQ(ierr); 1041 ierr = PetscMalloc(sizeof(PetscTruth),&amsopt->data);CHKERRQ(ierr); 1042 *(PetscTruth*)amsopt->data = PETSC_FALSE; 1043 } 1044 *flg = PETSC_FALSE; 1045 ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,PETSC_NULL);CHKERRQ(ierr); 1046 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 1047 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 1048 } 1049 PetscFunctionReturn(0); 1050 } 1051 1052 #undef __FUNCT__ 1053 #define __FUNCT__ "PetscOptionsTruthGroupEnd" 1054 /*@C 1055 PetscOptionsTruthGroupEnd - Last in a series of logical queries on the options database for 1056 which at most a single value can be true. 1057 1058 Logically Collective on the communicator passed in PetscOptionsBegin() 1059 1060 Input Parameters: 1061 + opt - option name 1062 . text - short string that describes the option 1063 - man - manual page with additional information on option 1064 1065 Output Parameter: 1066 . flg - PETSC_TRUE if found, else PETSC_FALSE 1067 1068 Level: intermediate 1069 1070 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 1071 1072 Must follow a PetscOptionsTruthGroupBegin() 1073 1074 Concepts: options database^logical group 1075 1076 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1077 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 1078 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 1079 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1080 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 1081 PetscOptionsList(), PetscOptionsEList() 1082 @*/ 1083 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroupEnd(const char opt[],const char text[],const char man[],PetscTruth *flg) 1084 { 1085 PetscErrorCode ierr; 1086 PetscOptions amsopt; 1087 1088 PetscFunctionBegin; 1089 if (!PetscOptionsPublishCount) { 1090 ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL,&amsopt);CHKERRQ(ierr); 1091 ierr = PetscMalloc(sizeof(PetscTruth),&amsopt->data);CHKERRQ(ierr); 1092 *(PetscTruth*)amsopt->data = PETSC_FALSE; 1093 } 1094 *flg = PETSC_FALSE; 1095 ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,PETSC_NULL);CHKERRQ(ierr); 1096 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 1097 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 1098 } 1099 PetscFunctionReturn(0); 1100 } 1101 1102 #undef __FUNCT__ 1103 #define __FUNCT__ "PetscOptionsTruth" 1104 /*@C 1105 PetscOptionsTruth - Determines if a particular option is in the database with a true or false 1106 1107 Logically Collective on the communicator passed in PetscOptionsBegin() 1108 1109 Input Parameters: 1110 + opt - option name 1111 . text - short string that describes the option 1112 - man - manual page with additional information on option 1113 1114 Output Parameter: 1115 . flg - PETSC_TRUE or PETSC_FALSE 1116 . set - PETSC_TRUE if found, else PETSC_FALSE 1117 1118 Level: beginner 1119 1120 Concepts: options database^logical 1121 1122 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 1123 1124 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 1125 PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 1126 PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 1127 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 1128 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1129 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 1130 PetscOptionsList(), PetscOptionsEList() 1131 @*/ 1132 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruth(const char opt[],const char text[],const char man[],PetscTruth deflt,PetscTruth *flg,PetscTruth *set) 1133 { 1134 PetscErrorCode ierr; 1135 PetscTruth iset; 1136 PetscOptions amsopt; 1137 1138 PetscFunctionBegin; 1139 if (!PetscOptionsPublishCount) { 1140 ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL,&amsopt);CHKERRQ(ierr); 1141 ierr = PetscMalloc(sizeof(PetscTruth),&amsopt->data);CHKERRQ(ierr); 1142 *(PetscTruth*)amsopt->data = deflt; 1143 } 1144 ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,&iset);CHKERRQ(ierr); 1145 if (!iset) { 1146 if (flg) *flg = deflt; 1147 } 1148 if (set) *set = iset; 1149 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 1150 const char *v = PetscTruths[deflt]; 1151 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: <%s> %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,v,text,man);CHKERRQ(ierr); 1152 } 1153 PetscFunctionReturn(0); 1154 } 1155 1156 #undef __FUNCT__ 1157 #define __FUNCT__ "PetscOptionsRealArray" 1158 /*@C 1159 PetscOptionsRealArray - Gets an array of double values for a particular 1160 option in the database. The values must be separated with commas with 1161 no intervening spaces. 1162 1163 Logically Collective on the communicator passed in PetscOptionsBegin() 1164 1165 Input Parameters: 1166 + opt - the option one is seeking 1167 . text - short string describing option 1168 . man - manual page for option 1169 - nmax - maximum number of values 1170 1171 Output Parameter: 1172 + value - location to copy values 1173 . nmax - actual number of values found 1174 - set - PETSC_TRUE if found, else PETSC_FALSE 1175 1176 Level: beginner 1177 1178 Notes: 1179 The user should pass in an array of doubles 1180 1181 Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 1182 1183 Concepts: options database^array of strings 1184 1185 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1186 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 1187 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 1188 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1189 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 1190 PetscOptionsList(), PetscOptionsEList() 1191 @*/ 1192 PetscErrorCode PETSC_DLLEXPORT PetscOptionsRealArray(const char opt[],const char text[],const char man[],PetscReal value[],PetscInt *n,PetscTruth *set) 1193 { 1194 PetscErrorCode ierr; 1195 PetscInt i; 1196 PetscOptions amsopt; 1197 1198 PetscFunctionBegin; 1199 if (!PetscOptionsPublishCount) { 1200 PetscReal *vals; 1201 1202 ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_REAL_ARRAY,&amsopt);CHKERRQ(ierr); 1203 ierr = PetscMalloc((*n)*sizeof(PetscReal),&amsopt->data);CHKERRQ(ierr); 1204 vals = (PetscReal*)amsopt->data; 1205 for (i=0; i<*n; i++) vals[i] = value[i]; 1206 amsopt->arraylength = *n; 1207 } 1208 ierr = PetscOptionsGetRealArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr); 1209 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 1210 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%G",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr); 1211 for (i=1; i<*n; i++) { 1212 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%G",value[i]);CHKERRQ(ierr); 1213 } 1214 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr); 1215 } 1216 PetscFunctionReturn(0); 1217 } 1218 1219 1220 #undef __FUNCT__ 1221 #define __FUNCT__ "PetscOptionsIntArray" 1222 /*@C 1223 PetscOptionsIntArray - Gets an array of integers for a particular 1224 option in the database. The values must be separated with commas with 1225 no intervening spaces. 1226 1227 Logically Collective on the communicator passed in PetscOptionsBegin() 1228 1229 Input Parameters: 1230 + opt - the option one is seeking 1231 . text - short string describing option 1232 . man - manual page for option 1233 - n - maximum number of values 1234 1235 Output Parameter: 1236 + value - location to copy values 1237 . n - actual number of values found 1238 - set - PETSC_TRUE if found, else PETSC_FALSE 1239 1240 Level: beginner 1241 1242 Notes: 1243 The user should pass in an array of integers 1244 1245 Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 1246 1247 Concepts: options database^array of strings 1248 1249 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1250 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 1251 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 1252 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1253 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 1254 PetscOptionsList(), PetscOptionsEList(), PetscOptionsRealArray() 1255 @*/ 1256 PetscErrorCode PETSC_DLLEXPORT PetscOptionsIntArray(const char opt[],const char text[],const char man[],PetscInt value[],PetscInt *n,PetscTruth *set) 1257 { 1258 PetscErrorCode ierr; 1259 PetscInt i; 1260 PetscOptions amsopt; 1261 1262 PetscFunctionBegin; 1263 if (!PetscOptionsPublishCount) { 1264 PetscInt *vals; 1265 1266 ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_INT_ARRAY,&amsopt);CHKERRQ(ierr); 1267 ierr = PetscMalloc((*n)*sizeof(PetscInt),&amsopt->data);CHKERRQ(ierr); 1268 vals = (PetscInt*)amsopt->data; 1269 for (i=0; i<*n; i++) vals[i] = value[i]; 1270 amsopt->arraylength = *n; 1271 } 1272 ierr = PetscOptionsGetIntArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr); 1273 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 1274 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%d",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr); 1275 for (i=1; i<*n; i++) { 1276 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%d",value[i]);CHKERRQ(ierr); 1277 } 1278 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr); 1279 } 1280 PetscFunctionReturn(0); 1281 } 1282 1283 #undef __FUNCT__ 1284 #define __FUNCT__ "PetscOptionsStringArray" 1285 /*@C 1286 PetscOptionsStringArray - Gets an array of string values for a particular 1287 option in the database. The values must be separated with commas with 1288 no intervening spaces. 1289 1290 Logically Collective on the communicator passed in PetscOptionsBegin() 1291 1292 Input Parameters: 1293 + opt - the option one is seeking 1294 . text - short string describing option 1295 . man - manual page for option 1296 - nmax - maximum number of strings 1297 1298 Output Parameter: 1299 + value - location to copy strings 1300 . nmax - actual number of strings found 1301 - set - PETSC_TRUE if found, else PETSC_FALSE 1302 1303 Level: beginner 1304 1305 Notes: 1306 The user should pass in an array of pointers to char, to hold all the 1307 strings returned by this function. 1308 1309 The user is responsible for deallocating the strings that are 1310 returned. The Fortran interface for this routine is not supported. 1311 1312 Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 1313 1314 Concepts: options database^array of strings 1315 1316 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1317 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 1318 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 1319 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1320 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 1321 PetscOptionsList(), PetscOptionsEList() 1322 @*/ 1323 PetscErrorCode PETSC_DLLEXPORT PetscOptionsStringArray(const char opt[],const char text[],const char man[],char *value[],PetscInt *nmax,PetscTruth *set) 1324 { 1325 PetscErrorCode ierr; 1326 PetscOptions amsopt; 1327 1328 PetscFunctionBegin; 1329 if (!PetscOptionsPublishCount) { 1330 ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_STRING_ARRAY,&amsopt);CHKERRQ(ierr); 1331 ierr = PetscMalloc((*nmax)*sizeof(char*),&amsopt->data);CHKERRQ(ierr); 1332 amsopt->arraylength = *nmax; 1333 } 1334 ierr = PetscOptionsGetStringArray(PetscOptionsObject.prefix,opt,value,nmax,set);CHKERRQ(ierr); 1335 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 1336 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <string1,string2,...>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 1337 } 1338 PetscFunctionReturn(0); 1339 } 1340 1341 #undef __FUNCT__ 1342 #define __FUNCT__ "PetscOptionsTruthArray" 1343 /*@C 1344 PetscOptionsTruthArray - Gets an array of logical values (true or false) for a particular 1345 option in the database. The values must be separated with commas with 1346 no intervening spaces. 1347 1348 Logically Collective on the communicator passed in PetscOptionsBegin() 1349 1350 Input Parameters: 1351 + opt - the option one is seeking 1352 . text - short string describing option 1353 . man - manual page for option 1354 - nmax - maximum number of values 1355 1356 Output Parameter: 1357 + value - location to copy values 1358 . nmax - actual number of values found 1359 - set - PETSC_TRUE if found, else PETSC_FALSE 1360 1361 Level: beginner 1362 1363 Notes: 1364 The user should pass in an array of doubles 1365 1366 Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 1367 1368 Concepts: options database^array of strings 1369 1370 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1371 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 1372 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 1373 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1374 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 1375 PetscOptionsList(), PetscOptionsEList() 1376 @*/ 1377 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthArray(const char opt[],const char text[],const char man[],PetscTruth value[],PetscInt *n,PetscTruth *set) 1378 { 1379 PetscErrorCode ierr; 1380 PetscInt i; 1381 PetscOptions amsopt; 1382 1383 PetscFunctionBegin; 1384 if (!PetscOptionsPublishCount) { 1385 PetscTruth *vals; 1386 1387 ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL_ARRAY,&amsopt);CHKERRQ(ierr); 1388 ierr = PetscMalloc((*n)*sizeof(PetscTruth),&amsopt->data);CHKERRQ(ierr); 1389 vals = (PetscTruth*)amsopt->data; 1390 for (i=0; i<*n; i++) vals[i] = value[i]; 1391 amsopt->arraylength = *n; 1392 } 1393 ierr = PetscOptionsGetTruthArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr); 1394 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 1395 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%d",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr); 1396 for (i=1; i<*n; i++) { 1397 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%d",value[i]);CHKERRQ(ierr); 1398 } 1399 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr); 1400 } 1401 PetscFunctionReturn(0); 1402 } 1403 1404 1405 #undef __FUNCT__ 1406 #define __FUNCT__ "PetscOptionsHead" 1407 /*@C 1408 PetscOptionsHead - Puts a heading before listing any more published options. Used, for example, 1409 in KSPSetFromOptions_GMRES(). 1410 1411 Logically Collective on the communicator passed in PetscOptionsBegin() 1412 1413 Input Parameter: 1414 . head - the heading text 1415 1416 1417 Level: intermediate 1418 1419 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 1420 1421 Can be followed by a call to PetscOptionsTail() in the same function. 1422 1423 Concepts: options database^subheading 1424 1425 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1426 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 1427 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 1428 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1429 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 1430 PetscOptionsList(), PetscOptionsEList() 1431 @*/ 1432 PetscErrorCode PETSC_DLLEXPORT PetscOptionsHead(const char head[]) 1433 { 1434 PetscErrorCode ierr; 1435 1436 PetscFunctionBegin; 1437 if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 1438 ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," %s\n",head);CHKERRQ(ierr); 1439 } 1440 PetscFunctionReturn(0); 1441 } 1442 1443 1444 1445 1446 1447 1448