153acd3b1SBarry Smith #define PETSC_DLL 253acd3b1SBarry Smith /* 3*3fc1eb6aSBarry Smith Implements the higher-level options database querying methods. These are self-documenting and can attach at runtime to 4*3fc1eb6aSBarry Smith GUI code to display the options and get values from the users. 553acd3b1SBarry Smith 653acd3b1SBarry Smith */ 753acd3b1SBarry Smith 853acd3b1SBarry Smith #include "petsc.h" /*I "petsc.h" I*/ 953acd3b1SBarry Smith #include "petscsys.h" 1053acd3b1SBarry Smith #if defined(PETSC_HAVE_STDLIB_H) 1153acd3b1SBarry Smith #include <stdlib.h> 1253acd3b1SBarry Smith #endif 1353acd3b1SBarry Smith 1453acd3b1SBarry Smith /* 1553acd3b1SBarry Smith Keep a linked list of options that have been posted and we are waiting for 16*3fc1eb6aSBarry Smith user selection. See the manual page for PetscOptionsBegin() 1753acd3b1SBarry Smith 1853acd3b1SBarry Smith Eventually we'll attach this beast to a MPI_Comm 1953acd3b1SBarry Smith */ 20f8d0b74dSMatthew Knepley PetscOptionsObjectType PetscOptionsObject; 2153acd3b1SBarry Smith PetscInt PetscOptionsPublishCount = 0; 2253acd3b1SBarry Smith 2353acd3b1SBarry Smith #undef __FUNCT__ 2453acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsBegin_Private" 2553acd3b1SBarry Smith /* 2653acd3b1SBarry Smith Handles setting up the data structure in a call to PetscOptionsBegin() 2753acd3b1SBarry Smith */ 2853acd3b1SBarry Smith PetscErrorCode PetscOptionsBegin_Private(MPI_Comm comm,const char prefix[],const char title[],const char mansec[]) 2953acd3b1SBarry Smith { 3053acd3b1SBarry Smith PetscErrorCode ierr; 3153acd3b1SBarry Smith 3253acd3b1SBarry Smith PetscFunctionBegin; 3353acd3b1SBarry Smith PetscOptionsObject.next = 0; 3453acd3b1SBarry Smith PetscOptionsObject.comm = comm; 356356e834SBarry Smith PetscOptionsObject.changedmethod = PETSC_FALSE; 36f8d0b74dSMatthew Knepley if (PetscOptionsObject.prefix) { 37f8d0b74dSMatthew Knepley ierr = PetscStrfree(PetscOptionsObject.prefix);CHKERRQ(ierr); PetscOptionsObject.prefix = 0; 38f8d0b74dSMatthew Knepley } 3953acd3b1SBarry Smith ierr = PetscStrallocpy(prefix,&PetscOptionsObject.prefix);CHKERRQ(ierr); 40f8d0b74dSMatthew Knepley if (PetscOptionsObject.title) { 41f8d0b74dSMatthew Knepley ierr = PetscStrfree(PetscOptionsObject.title);CHKERRQ(ierr); PetscOptionsObject.title = 0; 42f8d0b74dSMatthew Knepley } 4353acd3b1SBarry Smith ierr = PetscStrallocpy(title,&PetscOptionsObject.title);CHKERRQ(ierr); 4453acd3b1SBarry Smith 4553acd3b1SBarry Smith ierr = PetscOptionsHasName(PETSC_NULL,"-help",&PetscOptionsObject.printhelp);CHKERRQ(ierr); 4653acd3b1SBarry Smith if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1) { 4761b37b28SSatish Balay if (!PetscOptionsObject.alreadyprinted) { 4853acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(comm,"%s -------------------------------------------------\n",title);CHKERRQ(ierr); 4953acd3b1SBarry Smith } 5061b37b28SSatish Balay } 5153acd3b1SBarry Smith PetscFunctionReturn(0); 5253acd3b1SBarry Smith } 5353acd3b1SBarry Smith 5453acd3b1SBarry Smith /* 5553acd3b1SBarry Smith Handles adding another option to the list of options within this particular PetscOptionsBegin() PetscOptionsEnd() 5653acd3b1SBarry Smith */ 5753acd3b1SBarry Smith #undef __FUNCT__ 5853acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsCreate_Private" 59e3ed6ec8SBarry Smith static int PetscOptionsCreate_Private(const char opt[],const char text[],const char man[],PetscOptionType t,PetscOptions *amsopt) 6053acd3b1SBarry Smith { 6153acd3b1SBarry Smith int ierr; 6253acd3b1SBarry Smith PetscOptions next; 6353acd3b1SBarry Smith 6453acd3b1SBarry Smith PetscFunctionBegin; 65e3ed6ec8SBarry Smith ierr = PetscNew(struct _p_PetscOptions,amsopt);CHKERRQ(ierr); 6653acd3b1SBarry Smith (*amsopt)->next = 0; 6753acd3b1SBarry Smith (*amsopt)->set = PETSC_FALSE; 686356e834SBarry Smith (*amsopt)->type = t; 6953acd3b1SBarry Smith (*amsopt)->data = 0; 7053acd3b1SBarry Smith (*amsopt)->edata = 0; 7161b37b28SSatish Balay 7253acd3b1SBarry Smith ierr = PetscStrallocpy(text,&(*amsopt)->text);CHKERRQ(ierr); 7353acd3b1SBarry Smith ierr = PetscStrallocpy(opt,&(*amsopt)->option);CHKERRQ(ierr); 746356e834SBarry Smith ierr = PetscStrallocpy(man,&(*amsopt)->man);CHKERRQ(ierr); 7553acd3b1SBarry Smith 7653acd3b1SBarry Smith if (!PetscOptionsObject.next) { 7753acd3b1SBarry Smith PetscOptionsObject.next = *amsopt; 7853acd3b1SBarry Smith } else { 7953acd3b1SBarry Smith next = PetscOptionsObject.next; 8053acd3b1SBarry Smith while (next->next) next = next->next; 8153acd3b1SBarry Smith next->next = *amsopt; 8253acd3b1SBarry Smith } 8353acd3b1SBarry Smith PetscFunctionReturn(0); 8453acd3b1SBarry Smith } 8553acd3b1SBarry Smith 8653acd3b1SBarry Smith #undef __FUNCT__ 87aee2cecaSBarry Smith #define __FUNCT__ "PetscScanString" 88aee2cecaSBarry Smith /* 89*3fc1eb6aSBarry Smith PetscScanString - Gets user input via stdin from process and broadcasts to all processes 90*3fc1eb6aSBarry Smith 91*3fc1eb6aSBarry Smith Collective on MPI_Comm 92*3fc1eb6aSBarry Smith 93*3fc1eb6aSBarry Smith Input Parameters: 94*3fc1eb6aSBarry Smith + commm - communicator for the broadcast, must be PETSC_COMM_WORLD 95*3fc1eb6aSBarry Smith . n - length of the string, must be the same on all processes 96*3fc1eb6aSBarry Smith - str - location to store input 97aee2cecaSBarry Smith 98aee2cecaSBarry Smith Bugs: 99aee2cecaSBarry Smith . Assumes process 0 of the given communicator has access to stdin 100aee2cecaSBarry Smith 101aee2cecaSBarry Smith */ 102*3fc1eb6aSBarry Smith static PetscErrorCode PetscScanString(MPI_Comm comm,size_t n,char str[]) 103aee2cecaSBarry Smith { 104aee2cecaSBarry Smith PetscInt i; 105aee2cecaSBarry Smith char c; 106*3fc1eb6aSBarry Smith PetscMPIInt rank,nm; 107aee2cecaSBarry Smith PetscErrorCode ierr; 108aee2cecaSBarry Smith 109aee2cecaSBarry Smith PetscFunctionBegin; 110aee2cecaSBarry Smith ierr = MPI_Comm_rank(comm,&rank);CHKERRQ(ierr); 111aee2cecaSBarry Smith if (!rank) { 112aee2cecaSBarry Smith c = (char) getchar(); 113aee2cecaSBarry Smith i = 0; 114aee2cecaSBarry Smith while ( c != '\n' && i < n-1) { 115aee2cecaSBarry Smith str[i++] = c; 116aee2cecaSBarry Smith c = (char) getchar(); 117aee2cecaSBarry Smith } 118aee2cecaSBarry Smith str[i] = 0; 119aee2cecaSBarry Smith } 120*3fc1eb6aSBarry Smith nm = PetscMPIIntCast(n); 121*3fc1eb6aSBarry Smith ierr = MPI_Bcast(str,nm,MPI_CHAR,0,comm);CHKERRQ(ierr); 122aee2cecaSBarry Smith PetscFunctionReturn(0); 123aee2cecaSBarry Smith } 124aee2cecaSBarry Smith 125aee2cecaSBarry Smith #undef __FUNCT__ 126aee2cecaSBarry Smith #define __FUNCT__ "PetscOptionsGetFromTextInput" 127aee2cecaSBarry Smith /* 128aee2cecaSBarry Smith PetscOptionsGetFromTextInput 129aee2cecaSBarry Smith 130aee2cecaSBarry Smith Notes: this isn't really practical, it is just to demonstrate the principle 131aee2cecaSBarry Smith 132aee2cecaSBarry Smith Bugs: 133aee2cecaSBarry Smith + All processes must traverse through the exact same set of option queries do to the call to PetscScanString() 134aee2cecaSBarry Smith - Only works for PetscInt == int, PetscReal == double etc 135aee2cecaSBarry Smith 136aee2cecaSBarry Smith */ 137aee2cecaSBarry Smith PetscErrorCode PetscOptionsGetFromTextInput() 1386356e834SBarry Smith { 1396356e834SBarry Smith PetscErrorCode ierr; 1406356e834SBarry Smith PetscOptions next = PetscOptionsObject.next; 1416356e834SBarry Smith char str[512]; 142aee2cecaSBarry Smith int id; 143aee2cecaSBarry Smith double ir; 1446356e834SBarry Smith 1456356e834SBarry Smith ierr = (*PetscPrintf)(PetscOptionsObject.comm,"%s -------------------------------------------------\n",PetscOptionsObject.title);CHKERRQ(ierr); 1466356e834SBarry Smith while (next) { 1476356e834SBarry Smith switch (next->type) { 1486356e834SBarry Smith case OPTION_HEAD: 1496356e834SBarry Smith break; 1506356e834SBarry Smith case OPTION_INT: 151af6d86caSBarry Smith 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*3fc1eb6aSBarry Smith ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr); 153*3fc1eb6aSBarry Smith if (str[0]) { 154aee2cecaSBarry Smith sscanf(str,"%d",&id); 155aee2cecaSBarry Smith next->set = PETSC_TRUE; 156aee2cecaSBarry Smith *((PetscInt*)next->data) = id; 157aee2cecaSBarry Smith } 158aee2cecaSBarry Smith break; 159aee2cecaSBarry Smith case OPTION_REAL: 160af6d86caSBarry Smith 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*3fc1eb6aSBarry Smith ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr); 162*3fc1eb6aSBarry Smith if (str[0]) { 163aee2cecaSBarry Smith sscanf(str,"%le",&ir); 164aee2cecaSBarry Smith next->set = PETSC_TRUE; 165aee2cecaSBarry Smith *((PetscReal*)next->data) = ir; 166aee2cecaSBarry Smith } 167aee2cecaSBarry Smith break; 168aee2cecaSBarry Smith case OPTION_LOGICAL: 169aee2cecaSBarry Smith case OPTION_STRING: 170af6d86caSBarry Smith 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*3fc1eb6aSBarry Smith ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr); 172*3fc1eb6aSBarry Smith if (str[0]) { 173aee2cecaSBarry Smith next->set = PETSC_TRUE; 174aee2cecaSBarry Smith ierr = PetscStrcpy(next->data,str);CHKERRQ(ierr); 1756356e834SBarry Smith } 1766356e834SBarry Smith break; 177b432afdaSMatthew Knepley default: 178b432afdaSMatthew Knepley break; 1796356e834SBarry Smith } 1806356e834SBarry Smith next = next->next; 1816356e834SBarry Smith } 1826356e834SBarry Smith PetscFunctionReturn(0); 1836356e834SBarry Smith } 1846356e834SBarry Smith 1856356e834SBarry Smith #undef __FUNCT__ 18653acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsEnd_Private" 18753acd3b1SBarry Smith PetscErrorCode PetscOptionsEnd_Private(void) 18853acd3b1SBarry Smith { 18953acd3b1SBarry Smith PetscErrorCode ierr; 1906356e834SBarry Smith PetscOptions last; 1916356e834SBarry Smith char option[256],value[1024],tmp[32]; 1926356e834SBarry Smith PetscInt j; 19353acd3b1SBarry Smith 19453acd3b1SBarry Smith PetscFunctionBegin; 1956356e834SBarry Smith 196aee2cecaSBarry Smith if (PetscOptionsObject.next) { 197aee2cecaSBarry Smith if (PetscOptionsPublishCount == 0) { 198aee2cecaSBarry Smith ierr = PetscOptionsGetFromTextInput(); 199aee2cecaSBarry Smith } 200aee2cecaSBarry Smith } 2016356e834SBarry Smith 20253acd3b1SBarry Smith ierr = PetscStrfree(PetscOptionsObject.title);CHKERRQ(ierr); PetscOptionsObject.title = 0; 20353acd3b1SBarry Smith ierr = PetscStrfree(PetscOptionsObject.prefix);CHKERRQ(ierr); PetscOptionsObject.prefix = 0; 2046356e834SBarry Smith 2056356e834SBarry Smith /* reset counter to -2; this updates the screen with the new options for the selected method */ 2066356e834SBarry Smith if (PetscOptionsObject.changedmethod) PetscOptionsPublishCount = -2; 20761b37b28SSatish Balay /* reset alreadyprinted flag */ 20861b37b28SSatish Balay PetscOptionsObject.alreadyprinted = PETSC_FALSE; 2096356e834SBarry Smith 2106356e834SBarry Smith while (PetscOptionsObject.next) { 2116356e834SBarry Smith if (PetscOptionsObject.next->set) { 2126356e834SBarry Smith if (PetscOptionsObject.prefix) { 2136356e834SBarry Smith ierr = PetscStrcpy(option,"-");CHKERRQ(ierr); 2146356e834SBarry Smith ierr = PetscStrcat(option,PetscOptionsObject.prefix);CHKERRQ(ierr); 2156356e834SBarry Smith ierr = PetscStrcat(option,PetscOptionsObject.next->option+1);CHKERRQ(ierr); 2166356e834SBarry Smith } else { 2176356e834SBarry Smith ierr = PetscStrcpy(option,PetscOptionsObject.next->option);CHKERRQ(ierr); 2186356e834SBarry Smith } 2196356e834SBarry Smith 2206356e834SBarry Smith switch (PetscOptionsObject.next->type) { 2216356e834SBarry Smith case OPTION_HEAD: 2226356e834SBarry Smith break; 2236356e834SBarry Smith case OPTION_INT: 2247a72a596SBarry Smith sprintf(value,"%d",(int) *(PetscInt*)PetscOptionsObject.next->data); 2256356e834SBarry Smith break; 2266356e834SBarry Smith case OPTION_REAL: 2277a72a596SBarry Smith sprintf(value,"%g",(double) *(PetscReal*)PetscOptionsObject.next->data); 2286356e834SBarry Smith break; 2296356e834SBarry Smith case OPTION_REAL_ARRAY: 2307a72a596SBarry Smith sprintf(value,"%g",(double)((PetscReal*)PetscOptionsObject.next->data)[0]); 2316356e834SBarry Smith for (j=1; j<PetscOptionsObject.next->arraylength; j++) { 2327a72a596SBarry Smith sprintf(tmp,"%g",(double)((PetscReal*)PetscOptionsObject.next->data)[j]); 2336356e834SBarry Smith ierr = PetscStrcat(value,",");CHKERRQ(ierr); 2346356e834SBarry Smith ierr = PetscStrcat(value,tmp);CHKERRQ(ierr); 2356356e834SBarry Smith } 2366356e834SBarry Smith break; 2376356e834SBarry Smith case OPTION_LOGICAL: 238aee2cecaSBarry Smith ierr = PetscStrcpy(value,(char*)PetscOptionsObject.next->data);CHKERRQ(ierr); 2396356e834SBarry Smith break; 2406356e834SBarry Smith case OPTION_LIST: 241aee2cecaSBarry Smith ierr = PetscStrcpy(value,(char*)PetscOptionsObject.next->data);CHKERRQ(ierr); 2426356e834SBarry Smith break; 2436356e834SBarry Smith case OPTION_STRING: /* also handles string arrays */ 244aee2cecaSBarry Smith ierr = PetscStrcpy(value,(char*)PetscOptionsObject.next->data);CHKERRQ(ierr); 2456356e834SBarry Smith break; 2466356e834SBarry Smith } 2476356e834SBarry Smith ierr = PetscOptionsSetValue(option,value);CHKERRQ(ierr); 2486356e834SBarry Smith } 2496356e834SBarry Smith ierr = PetscStrfree(PetscOptionsObject.next->text);CHKERRQ(ierr); 2506356e834SBarry Smith ierr = PetscStrfree(PetscOptionsObject.next->option);CHKERRQ(ierr); 2516356e834SBarry Smith ierr = PetscFree(PetscOptionsObject.next->man);CHKERRQ(ierr); 25205b42c5fSBarry Smith ierr = PetscFree(PetscOptionsObject.next->data);CHKERRQ(ierr); 25305b42c5fSBarry Smith ierr = PetscFree(PetscOptionsObject.next->edata);CHKERRQ(ierr); 2546356e834SBarry Smith last = PetscOptionsObject.next; 2556356e834SBarry Smith PetscOptionsObject.next = PetscOptionsObject.next->next; 2566356e834SBarry Smith ierr = PetscFree(last);CHKERRQ(ierr); 2576356e834SBarry Smith } 2586356e834SBarry Smith PetscOptionsObject.next = 0; 25953acd3b1SBarry Smith PetscFunctionReturn(0); 26053acd3b1SBarry Smith } 26153acd3b1SBarry Smith 26253acd3b1SBarry Smith #undef __FUNCT__ 26353acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsEnum" 26453acd3b1SBarry Smith /*@C 26553acd3b1SBarry Smith PetscOptionsEnum - Gets the enum value for a particular option in the database. 26653acd3b1SBarry Smith 26753acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 26853acd3b1SBarry Smith 26953acd3b1SBarry Smith Input Parameters: 27053acd3b1SBarry Smith + opt - option name 27153acd3b1SBarry Smith . text - short string that describes the option 27253acd3b1SBarry Smith . man - manual page with additional information on option 27353acd3b1SBarry Smith . list - array containing the list of choices, followed by the enum name, followed by the enum prefix, followed by a null 27453acd3b1SBarry Smith - defaultv - the default (current) value 27553acd3b1SBarry Smith 27653acd3b1SBarry Smith Output Parameter: 27753acd3b1SBarry Smith + value - the value to return 27853acd3b1SBarry Smith - flg - PETSC_TRUE if found, else PETSC_FALSE 27953acd3b1SBarry Smith 28053acd3b1SBarry Smith Level: beginner 28153acd3b1SBarry Smith 28253acd3b1SBarry Smith Concepts: options database 28353acd3b1SBarry Smith 28453acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 28553acd3b1SBarry Smith 28653acd3b1SBarry Smith list is usually something like PCASMTypes or some other predefined list of enum names 28753acd3b1SBarry Smith 28853acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 28953acd3b1SBarry Smith PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 29053acd3b1SBarry Smith PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 29153acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 29253acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 29353acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 29453acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 29553acd3b1SBarry Smith @*/ 29653acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsEnum(const char opt[],const char text[],const char man[],const char **list,PetscEnum defaultv,PetscEnum *value,PetscTruth *set) 29753acd3b1SBarry Smith { 29853acd3b1SBarry Smith PetscErrorCode ierr; 29953acd3b1SBarry Smith PetscInt ntext = 0; 300aa5bb8c0SSatish Balay PetscInt tval; 301aa5bb8c0SSatish Balay PetscTruth tflg; 30253acd3b1SBarry Smith 30353acd3b1SBarry Smith PetscFunctionBegin; 30453acd3b1SBarry Smith while (list[ntext++]) { 30553acd3b1SBarry Smith if (ntext > 50) SETERRQ(PETSC_ERR_ARG_WRONG,"List argument appears to be wrong or have more than 50 entries"); 30653acd3b1SBarry Smith } 30753acd3b1SBarry Smith if (ntext < 3) SETERRQ(PETSC_ERR_ARG_WRONG,"List argument must have at least two entries: typename and type prefix"); 30853acd3b1SBarry Smith ntext -= 3; 309aa5bb8c0SSatish Balay ierr = PetscOptionsEList(opt,text,man,list,ntext,list[defaultv],&tval,&tflg);CHKERRQ(ierr); 310aa5bb8c0SSatish Balay /* with PETSC_USE_64BIT_INDICES sizeof(PetscInt) != sizeof(PetscEnum) */ 311aa5bb8c0SSatish Balay if (tflg) *value = (PetscEnum)tval; 312aa5bb8c0SSatish Balay if (set) *set = tflg; 31353acd3b1SBarry Smith PetscFunctionReturn(0); 31453acd3b1SBarry Smith } 31553acd3b1SBarry Smith 31653acd3b1SBarry Smith /* -------------------------------------------------------------------------------------------------------------*/ 31753acd3b1SBarry Smith #undef __FUNCT__ 31853acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsInt" 31953acd3b1SBarry Smith /*@C 32053acd3b1SBarry Smith PetscOptionsInt - Gets the integer value for a particular option in the database. 32153acd3b1SBarry Smith 32253acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 32353acd3b1SBarry Smith 32453acd3b1SBarry Smith Input Parameters: 32553acd3b1SBarry Smith + opt - option name 32653acd3b1SBarry Smith . text - short string that describes the option 32753acd3b1SBarry Smith . man - manual page with additional information on option 32853acd3b1SBarry Smith - defaultv - the default (current) value 32953acd3b1SBarry Smith 33053acd3b1SBarry Smith Output Parameter: 33153acd3b1SBarry Smith + value - the integer value to return 33253acd3b1SBarry Smith - flg - PETSC_TRUE if found, else PETSC_FALSE 33353acd3b1SBarry Smith 33453acd3b1SBarry Smith Level: beginner 33553acd3b1SBarry Smith 33653acd3b1SBarry Smith Concepts: options database^has int 33753acd3b1SBarry Smith 33853acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 33953acd3b1SBarry Smith 34053acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 34153acd3b1SBarry Smith PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 34253acd3b1SBarry Smith PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 34353acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 34453acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 34553acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 34653acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 34753acd3b1SBarry Smith @*/ 34853acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsInt(const char opt[],const char text[],const char man[],PetscInt defaultv,PetscInt *value,PetscTruth *set) 34953acd3b1SBarry Smith { 35053acd3b1SBarry Smith PetscErrorCode ierr; 3516356e834SBarry Smith PetscOptions amsopt; 35253acd3b1SBarry Smith 35353acd3b1SBarry Smith PetscFunctionBegin; 354aee2cecaSBarry Smith if (PetscOptionsPublishCount == 0) { 3556356e834SBarry Smith ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_INT,&amsopt);CHKERRQ(ierr); 3566356e834SBarry Smith ierr = PetscMalloc(sizeof(PetscInt),&amsopt->data);CHKERRQ(ierr); 3576356e834SBarry Smith *(PetscInt*)amsopt->data = defaultv; 358af6d86caSBarry Smith } 35953acd3b1SBarry Smith ierr = PetscOptionsGetInt(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr); 36061b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 36153acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%d>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,man);CHKERRQ(ierr); 36253acd3b1SBarry Smith } 36353acd3b1SBarry Smith PetscFunctionReturn(0); 36453acd3b1SBarry Smith } 36553acd3b1SBarry Smith 36653acd3b1SBarry Smith #undef __FUNCT__ 36753acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsString" 36853acd3b1SBarry Smith /*@C 36953acd3b1SBarry Smith PetscOptionsString - Gets the string value for a particular option in the database. 37053acd3b1SBarry Smith 37153acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 37253acd3b1SBarry Smith 37353acd3b1SBarry Smith Input Parameters: 37453acd3b1SBarry Smith + opt - option name 37553acd3b1SBarry Smith . text - short string that describes the option 37653acd3b1SBarry Smith . man - manual page with additional information on option 37753acd3b1SBarry Smith - defaultv - the default (current) value 37853acd3b1SBarry Smith 37953acd3b1SBarry Smith Output Parameter: 38053acd3b1SBarry Smith + value - the value to return 38153acd3b1SBarry Smith - flg - PETSC_TRUE if found, else PETSC_FALSE 38253acd3b1SBarry Smith 38353acd3b1SBarry Smith Level: beginner 38453acd3b1SBarry Smith 38553acd3b1SBarry Smith Concepts: options database^has int 38653acd3b1SBarry Smith 38753acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 38853acd3b1SBarry Smith 38953acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 39053acd3b1SBarry Smith PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 39153acd3b1SBarry Smith PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 39253acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 39353acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 39453acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 39553acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 39653acd3b1SBarry Smith @*/ 39753acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsString(const char opt[],const char text[],const char man[],const char defaultv[],char value[],size_t len,PetscTruth *set) 39853acd3b1SBarry Smith { 39953acd3b1SBarry Smith PetscErrorCode ierr; 400aee2cecaSBarry Smith PetscOptions amsopt; 40153acd3b1SBarry Smith 40253acd3b1SBarry Smith PetscFunctionBegin; 403aee2cecaSBarry Smith if (PetscOptionsPublishCount == 0) { 404aee2cecaSBarry Smith ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_STRING,&amsopt);CHKERRQ(ierr); 405aee2cecaSBarry Smith ierr = PetscMalloc(len*sizeof(char),&amsopt->data);CHKERRQ(ierr); 406aee2cecaSBarry Smith ierr = PetscStrcpy((char*)amsopt->data,defaultv);CHKERRQ(ierr); 407af6d86caSBarry Smith } 40853acd3b1SBarry Smith ierr = PetscOptionsGetString(PetscOptionsObject.prefix,opt,value,len,set);CHKERRQ(ierr); 40961b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 41053acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%s>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,man);CHKERRQ(ierr); 41153acd3b1SBarry Smith } 41253acd3b1SBarry Smith PetscFunctionReturn(0); 41353acd3b1SBarry Smith } 41453acd3b1SBarry Smith 41553acd3b1SBarry Smith #undef __FUNCT__ 41653acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsReal" 41753acd3b1SBarry Smith /*@C 41853acd3b1SBarry Smith PetscOptionsReal - Gets the PetscReal value for a particular option in the database. 41953acd3b1SBarry Smith 42053acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 42153acd3b1SBarry Smith 42253acd3b1SBarry Smith Input Parameters: 42353acd3b1SBarry Smith + opt - option name 42453acd3b1SBarry Smith . text - short string that describes the option 42553acd3b1SBarry Smith . man - manual page with additional information on option 42653acd3b1SBarry Smith - defaultv - the default (current) value 42753acd3b1SBarry Smith 42853acd3b1SBarry Smith Output Parameter: 42953acd3b1SBarry Smith + value - the value to return 43053acd3b1SBarry Smith - flg - PETSC_TRUE if found, else PETSC_FALSE 43153acd3b1SBarry Smith 43253acd3b1SBarry Smith Level: beginner 43353acd3b1SBarry Smith 43453acd3b1SBarry Smith Concepts: options database^has int 43553acd3b1SBarry Smith 43653acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 43753acd3b1SBarry Smith 43853acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 43953acd3b1SBarry Smith PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 44053acd3b1SBarry Smith PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 44153acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 44253acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 44353acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 44453acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 44553acd3b1SBarry Smith @*/ 44653acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsReal(const char opt[],const char text[],const char man[],PetscReal defaultv,PetscReal *value,PetscTruth *set) 44753acd3b1SBarry Smith { 44853acd3b1SBarry Smith PetscErrorCode ierr; 449538aa990SBarry Smith PetscOptions amsopt; 45053acd3b1SBarry Smith 45153acd3b1SBarry Smith PetscFunctionBegin; 452538aa990SBarry Smith if (PetscOptionsPublishCount == 0) { 453538aa990SBarry Smith ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_REAL,&amsopt);CHKERRQ(ierr); 454538aa990SBarry Smith ierr = PetscMalloc(sizeof(PetscReal),&amsopt->data);CHKERRQ(ierr); 455538aa990SBarry Smith *(PetscReal*)amsopt->data = defaultv; 456538aa990SBarry Smith } 45753acd3b1SBarry Smith ierr = PetscOptionsGetReal(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr); 45861b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 459a83599f4SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%G>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,man);CHKERRQ(ierr); 46053acd3b1SBarry Smith } 46153acd3b1SBarry Smith PetscFunctionReturn(0); 46253acd3b1SBarry Smith } 46353acd3b1SBarry Smith 46453acd3b1SBarry Smith #undef __FUNCT__ 46553acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsScalar" 46653acd3b1SBarry Smith /*@C 46753acd3b1SBarry Smith PetscOptionsScalar - Gets the scalar value for a particular option in the database. 46853acd3b1SBarry Smith 46953acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 47053acd3b1SBarry Smith 47153acd3b1SBarry Smith Input Parameters: 47253acd3b1SBarry Smith + opt - option name 47353acd3b1SBarry Smith . text - short string that describes the option 47453acd3b1SBarry Smith . man - manual page with additional information on option 47553acd3b1SBarry Smith - defaultv - the default (current) value 47653acd3b1SBarry Smith 47753acd3b1SBarry Smith Output Parameter: 47853acd3b1SBarry Smith + value - the value to return 47953acd3b1SBarry Smith - flg - PETSC_TRUE if found, else PETSC_FALSE 48053acd3b1SBarry Smith 48153acd3b1SBarry Smith Level: beginner 48253acd3b1SBarry Smith 48353acd3b1SBarry Smith Concepts: options database^has int 48453acd3b1SBarry Smith 48553acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 48653acd3b1SBarry Smith 48753acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 48853acd3b1SBarry Smith PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 48953acd3b1SBarry Smith PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 49053acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 49153acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 49253acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 49353acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 49453acd3b1SBarry Smith @*/ 49553acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsScalar(const char opt[],const char text[],const char man[],PetscScalar defaultv,PetscScalar *value,PetscTruth *set) 49653acd3b1SBarry Smith { 49753acd3b1SBarry Smith PetscErrorCode ierr; 49853acd3b1SBarry Smith 49953acd3b1SBarry Smith PetscFunctionBegin; 50053acd3b1SBarry Smith #if !defined(PETSC_USE_COMPLEX) 50153acd3b1SBarry Smith ierr = PetscOptionsReal(opt,text,man,defaultv,value,set);CHKERRQ(ierr); 50253acd3b1SBarry Smith #else 50353acd3b1SBarry Smith ierr = PetscOptionsGetScalar(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr); 50453acd3b1SBarry Smith #endif 50553acd3b1SBarry Smith PetscFunctionReturn(0); 50653acd3b1SBarry Smith } 50753acd3b1SBarry Smith 50853acd3b1SBarry Smith #undef __FUNCT__ 50953acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsName" 51053acd3b1SBarry Smith /*@C 51190d69ab7SBarry Smith 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 51290d69ab7SBarry Smith its value is set to false. 51353acd3b1SBarry Smith 51453acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 51553acd3b1SBarry Smith 51653acd3b1SBarry Smith Input Parameters: 51753acd3b1SBarry Smith + opt - option name 51853acd3b1SBarry Smith . text - short string that describes the option 51953acd3b1SBarry Smith - man - manual page with additional information on option 52053acd3b1SBarry Smith 52153acd3b1SBarry Smith Output Parameter: 52253acd3b1SBarry Smith . flg - PETSC_TRUE if found, else PETSC_FALSE 52353acd3b1SBarry Smith 52453acd3b1SBarry Smith Level: beginner 52553acd3b1SBarry Smith 52653acd3b1SBarry Smith Concepts: options database^has int 52753acd3b1SBarry Smith 52853acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 52953acd3b1SBarry Smith 53053acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 53153acd3b1SBarry Smith PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 53253acd3b1SBarry Smith PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 53353acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 53453acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 53553acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 53653acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 53753acd3b1SBarry Smith @*/ 53853acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsName(const char opt[],const char text[],const char man[],PetscTruth *flg) 53953acd3b1SBarry Smith { 54053acd3b1SBarry Smith PetscErrorCode ierr; 54153acd3b1SBarry Smith 54253acd3b1SBarry Smith PetscFunctionBegin; 54353acd3b1SBarry Smith ierr = PetscOptionsHasName(PetscOptionsObject.prefix,opt,flg);CHKERRQ(ierr); 54461b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 54553acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 54653acd3b1SBarry Smith } 54753acd3b1SBarry Smith PetscFunctionReturn(0); 54853acd3b1SBarry Smith } 54953acd3b1SBarry Smith 55053acd3b1SBarry Smith #undef __FUNCT__ 55153acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsList" 55253acd3b1SBarry Smith /*@C 55353acd3b1SBarry Smith PetscOptionsList - Puts a list of option values that a single one may be selected from 55453acd3b1SBarry Smith 55553acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 55653acd3b1SBarry Smith 55753acd3b1SBarry Smith Input Parameters: 55853acd3b1SBarry Smith + opt - option name 55953acd3b1SBarry Smith . text - short string that describes the option 56053acd3b1SBarry Smith . man - manual page with additional information on option 56153acd3b1SBarry Smith . list - the possible choices 56253acd3b1SBarry Smith - defaultv - the default (current) value 56353acd3b1SBarry Smith 56453acd3b1SBarry Smith Output Parameter: 56553acd3b1SBarry Smith + value - the value to return 56653acd3b1SBarry Smith - set - PETSC_TRUE if found, else PETSC_FALSE 56753acd3b1SBarry Smith 56853acd3b1SBarry Smith Level: intermediate 56953acd3b1SBarry Smith 57053acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 57153acd3b1SBarry Smith 57253acd3b1SBarry Smith See PetscOptionsEList() for when the choices are given in a string array 57353acd3b1SBarry Smith 57453acd3b1SBarry Smith To get a listing of all currently specified options, 57553acd3b1SBarry Smith see PetscOptionsPrint() or PetscOptionsGetAll() 57653acd3b1SBarry Smith 57753acd3b1SBarry Smith Concepts: options database^list 57853acd3b1SBarry Smith 57953acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 58053acd3b1SBarry Smith PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 58153acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 58253acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 58353acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 58453acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 58553acd3b1SBarry Smith @*/ 58653acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsList(const char opt[],const char ltext[],const char man[],PetscFList list,const char defaultv[],char value[],PetscInt len,PetscTruth *set) 58753acd3b1SBarry Smith { 58853acd3b1SBarry Smith PetscErrorCode ierr; 58953acd3b1SBarry Smith 59053acd3b1SBarry Smith PetscFunctionBegin; 59153acd3b1SBarry Smith ierr = PetscOptionsGetString(PetscOptionsObject.prefix,opt,value,len,set);CHKERRQ(ierr); 59261b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 5931d280d73SBarry Smith ierr = PetscFListPrintTypes(list,PetscOptionsObject.comm,stdout,PetscOptionsObject.prefix,opt,ltext,man);CHKERRQ(ierr);CHKERRQ(ierr); 59453acd3b1SBarry Smith } 59553acd3b1SBarry Smith PetscFunctionReturn(0); 59653acd3b1SBarry Smith } 59753acd3b1SBarry Smith 59853acd3b1SBarry Smith #undef __FUNCT__ 59953acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsEList" 60053acd3b1SBarry Smith /*@C 60153acd3b1SBarry Smith PetscOptionsEList - Puts a list of option values that a single one may be selected from 60253acd3b1SBarry Smith 60353acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 60453acd3b1SBarry Smith 60553acd3b1SBarry Smith Input Parameters: 60653acd3b1SBarry Smith + opt - option name 60753acd3b1SBarry Smith . ltext - short string that describes the option 60853acd3b1SBarry Smith . man - manual page with additional information on option 60953acd3b1SBarry Smith . list - the possible choices 61053acd3b1SBarry Smith . ntext - number of choices 61153acd3b1SBarry Smith - defaultv - the default (current) value 61253acd3b1SBarry Smith 61353acd3b1SBarry Smith Output Parameter: 61453acd3b1SBarry Smith + value - the index of the value to return 61553acd3b1SBarry Smith - set - PETSC_TRUE if found, else PETSC_FALSE 61653acd3b1SBarry Smith 61753acd3b1SBarry Smith Level: intermediate 61853acd3b1SBarry Smith 61953acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 62053acd3b1SBarry Smith 62153acd3b1SBarry Smith See PetscOptionsList() for when the choices are given in a PetscFList() 62253acd3b1SBarry Smith 62353acd3b1SBarry Smith Concepts: options database^list 62453acd3b1SBarry Smith 62553acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 62653acd3b1SBarry Smith PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 62753acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 62853acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 62953acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 63053acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 63153acd3b1SBarry Smith @*/ 63253acd3b1SBarry Smith 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) 63353acd3b1SBarry Smith { 63453acd3b1SBarry Smith PetscErrorCode ierr; 63553acd3b1SBarry Smith PetscInt i; 63653acd3b1SBarry Smith 63753acd3b1SBarry Smith PetscFunctionBegin; 63853acd3b1SBarry Smith ierr = PetscOptionsGetEList(PetscOptionsObject.prefix,opt,list,ntext,value,set);CHKERRQ(ierr); 63961b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 64053acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%s> (choose one of)",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv);CHKERRQ(ierr); 64153acd3b1SBarry Smith for (i=0; i<ntext; i++){ 64253acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," %s",list[i]);CHKERRQ(ierr); 64353acd3b1SBarry Smith } 64453acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"\n");CHKERRQ(ierr); 64553acd3b1SBarry Smith } 64653acd3b1SBarry Smith PetscFunctionReturn(0); 64753acd3b1SBarry Smith } 64853acd3b1SBarry Smith 64953acd3b1SBarry Smith #undef __FUNCT__ 65053acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsTruthGroupBegin" 65153acd3b1SBarry Smith /*@C 65253acd3b1SBarry Smith PetscOptionsTruthGroupBegin - First in a series of logical queries on the options database for 65353acd3b1SBarry Smith which only a single value can be true. 65453acd3b1SBarry Smith 65553acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 65653acd3b1SBarry Smith 65753acd3b1SBarry Smith Input Parameters: 65853acd3b1SBarry Smith + opt - option name 65953acd3b1SBarry Smith . text - short string that describes the option 66053acd3b1SBarry Smith - man - manual page with additional information on option 66153acd3b1SBarry Smith 66253acd3b1SBarry Smith Output Parameter: 66353acd3b1SBarry Smith . flg - whether that option was set or not 66453acd3b1SBarry Smith 66553acd3b1SBarry Smith Level: intermediate 66653acd3b1SBarry Smith 66753acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 66853acd3b1SBarry Smith 66953acd3b1SBarry Smith Must be followed by 0 or more PetscOptionsTruthGroup()s and PetscOptionsTruthGroupEnd() 67053acd3b1SBarry Smith 67153acd3b1SBarry Smith Concepts: options database^logical group 67253acd3b1SBarry Smith 67353acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 67453acd3b1SBarry Smith PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 67553acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 67653acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 67753acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 67853acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 67953acd3b1SBarry Smith @*/ 68053acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroupBegin(const char opt[],const char text[],const char man[],PetscTruth *flg) 68153acd3b1SBarry Smith { 68253acd3b1SBarry Smith PetscErrorCode ierr; 68353acd3b1SBarry Smith 68453acd3b1SBarry Smith PetscFunctionBegin; 68517326d04SJed Brown *flg = PETSC_FALSE; 68617326d04SJed Brown ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,PETSC_NULL);CHKERRQ(ierr); 68761b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 68853acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," Pick at most one of -------------\n");CHKERRQ(ierr); 68953acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 69053acd3b1SBarry Smith } 69153acd3b1SBarry Smith PetscFunctionReturn(0); 69253acd3b1SBarry Smith } 69353acd3b1SBarry Smith 69453acd3b1SBarry Smith #undef __FUNCT__ 69553acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsTruthGroup" 69653acd3b1SBarry Smith /*@C 69753acd3b1SBarry Smith PetscOptionsTruthGroup - One in a series of logical queries on the options database for 69853acd3b1SBarry Smith which only a single value can be true. 69953acd3b1SBarry Smith 70053acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 70153acd3b1SBarry Smith 70253acd3b1SBarry Smith Input Parameters: 70353acd3b1SBarry Smith + opt - option name 70453acd3b1SBarry Smith . text - short string that describes the option 70553acd3b1SBarry Smith - man - manual page with additional information on option 70653acd3b1SBarry Smith 70753acd3b1SBarry Smith Output Parameter: 70853acd3b1SBarry Smith . flg - PETSC_TRUE if found, else PETSC_FALSE 70953acd3b1SBarry Smith 71053acd3b1SBarry Smith Level: intermediate 71153acd3b1SBarry Smith 71253acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 71353acd3b1SBarry Smith 71453acd3b1SBarry Smith Must follow a PetscOptionsTruthGroupBegin() and preceded a PetscOptionsTruthGroupEnd() 71553acd3b1SBarry Smith 71653acd3b1SBarry Smith Concepts: options database^logical group 71753acd3b1SBarry Smith 71853acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 71953acd3b1SBarry Smith PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 72053acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 72153acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 72253acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 72353acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 72453acd3b1SBarry Smith @*/ 72553acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroup(const char opt[],const char text[],const char man[],PetscTruth *flg) 72653acd3b1SBarry Smith { 72753acd3b1SBarry Smith PetscErrorCode ierr; 72853acd3b1SBarry Smith 72953acd3b1SBarry Smith PetscFunctionBegin; 73017326d04SJed Brown *flg = PETSC_FALSE; 73117326d04SJed Brown ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,PETSC_NULL);CHKERRQ(ierr); 73261b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 73353acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 73453acd3b1SBarry Smith } 73553acd3b1SBarry Smith PetscFunctionReturn(0); 73653acd3b1SBarry Smith } 73753acd3b1SBarry Smith 73853acd3b1SBarry Smith #undef __FUNCT__ 73953acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsTruthGroupEnd" 74053acd3b1SBarry Smith /*@C 74153acd3b1SBarry Smith PetscOptionsTruthGroupEnd - Last in a series of logical queries on the options database for 74253acd3b1SBarry Smith which only a single value can be true. 74353acd3b1SBarry Smith 74453acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 74553acd3b1SBarry Smith 74653acd3b1SBarry Smith Input Parameters: 74753acd3b1SBarry Smith + opt - option name 74853acd3b1SBarry Smith . text - short string that describes the option 74953acd3b1SBarry Smith - man - manual page with additional information on option 75053acd3b1SBarry Smith 75153acd3b1SBarry Smith Output Parameter: 75253acd3b1SBarry Smith . flg - PETSC_TRUE if found, else PETSC_FALSE 75353acd3b1SBarry Smith 75453acd3b1SBarry Smith Level: intermediate 75553acd3b1SBarry Smith 75653acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 75753acd3b1SBarry Smith 75853acd3b1SBarry Smith Must follow a PetscOptionsTruthGroupBegin() 75953acd3b1SBarry Smith 76053acd3b1SBarry Smith Concepts: options database^logical group 76153acd3b1SBarry Smith 76253acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 76353acd3b1SBarry Smith PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 76453acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 76553acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 76653acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 76753acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 76853acd3b1SBarry Smith @*/ 76953acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroupEnd(const char opt[],const char text[],const char man[],PetscTruth *flg) 77053acd3b1SBarry Smith { 77153acd3b1SBarry Smith PetscErrorCode ierr; 77253acd3b1SBarry Smith 77353acd3b1SBarry Smith PetscFunctionBegin; 77417326d04SJed Brown *flg = PETSC_FALSE; 77517326d04SJed Brown ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,PETSC_NULL);CHKERRQ(ierr); 77661b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 77753acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 77853acd3b1SBarry Smith } 77953acd3b1SBarry Smith PetscFunctionReturn(0); 78053acd3b1SBarry Smith } 78153acd3b1SBarry Smith 78253acd3b1SBarry Smith #undef __FUNCT__ 78353acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsTruth" 78453acd3b1SBarry Smith /*@C 78553acd3b1SBarry Smith PetscOptionsTruth - Determines if a particular option is in the database with a true or false 78653acd3b1SBarry Smith 78753acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 78853acd3b1SBarry Smith 78953acd3b1SBarry Smith Input Parameters: 79053acd3b1SBarry Smith + opt - option name 79153acd3b1SBarry Smith . text - short string that describes the option 79253acd3b1SBarry Smith - man - manual page with additional information on option 79353acd3b1SBarry Smith 79453acd3b1SBarry Smith Output Parameter: 79553acd3b1SBarry Smith . flg - PETSC_TRUE or PETSC_FALSE 79653acd3b1SBarry Smith . set - PETSC_TRUE if found, else PETSC_FALSE 79753acd3b1SBarry Smith 79853acd3b1SBarry Smith Level: beginner 79953acd3b1SBarry Smith 80053acd3b1SBarry Smith Concepts: options database^logical 80153acd3b1SBarry Smith 80253acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 80353acd3b1SBarry Smith 80453acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 80553acd3b1SBarry Smith PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 80653acd3b1SBarry Smith PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 80753acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 80853acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 80953acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 81053acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 81153acd3b1SBarry Smith @*/ 81253acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruth(const char opt[],const char text[],const char man[],PetscTruth deflt,PetscTruth *flg,PetscTruth *set) 81353acd3b1SBarry Smith { 81453acd3b1SBarry Smith PetscErrorCode ierr; 81553acd3b1SBarry Smith PetscTruth iset; 816aee2cecaSBarry Smith PetscOptions amsopt; 81753acd3b1SBarry Smith 81853acd3b1SBarry Smith PetscFunctionBegin; 819aee2cecaSBarry Smith if (PetscOptionsPublishCount == 0) { 820aee2cecaSBarry Smith ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL,&amsopt);CHKERRQ(ierr); 821aee2cecaSBarry Smith ierr = PetscMalloc(16*sizeof(char),&amsopt->data);CHKERRQ(ierr); 822aee2cecaSBarry Smith ierr = PetscStrcpy((char*)amsopt->data,deflt ? "true" : "false");CHKERRQ(ierr); 823af6d86caSBarry Smith } 82453acd3b1SBarry Smith ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,&iset);CHKERRQ(ierr); 82553acd3b1SBarry Smith if (!iset) { 82653acd3b1SBarry Smith if (flg) *flg = deflt; 82753acd3b1SBarry Smith } 82853acd3b1SBarry Smith if (set) *set = iset; 82961b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 83053acd3b1SBarry Smith const char *v = PetscTruths[deflt]; 83153acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: <%s> %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,v,text,man);CHKERRQ(ierr); 83253acd3b1SBarry Smith } 83353acd3b1SBarry Smith PetscFunctionReturn(0); 83453acd3b1SBarry Smith } 83553acd3b1SBarry Smith 83653acd3b1SBarry Smith #undef __FUNCT__ 83753acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsRealArray" 83853acd3b1SBarry Smith /*@C 83953acd3b1SBarry Smith PetscOptionsRealArray - Gets an array of double values for a particular 84053acd3b1SBarry Smith option in the database. The values must be separated with commas with 84153acd3b1SBarry Smith no intervening spaces. 84253acd3b1SBarry Smith 84353acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 84453acd3b1SBarry Smith 84553acd3b1SBarry Smith Input Parameters: 84653acd3b1SBarry Smith + opt - the option one is seeking 84753acd3b1SBarry Smith . text - short string describing option 84853acd3b1SBarry Smith . man - manual page for option 84953acd3b1SBarry Smith - nmax - maximum number of values 85053acd3b1SBarry Smith 85153acd3b1SBarry Smith Output Parameter: 85253acd3b1SBarry Smith + value - location to copy values 85353acd3b1SBarry Smith . nmax - actual number of values found 85453acd3b1SBarry Smith - set - PETSC_TRUE if found, else PETSC_FALSE 85553acd3b1SBarry Smith 85653acd3b1SBarry Smith Level: beginner 85753acd3b1SBarry Smith 85853acd3b1SBarry Smith Notes: 85953acd3b1SBarry Smith The user should pass in an array of doubles 86053acd3b1SBarry Smith 86153acd3b1SBarry Smith Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 86253acd3b1SBarry Smith 86353acd3b1SBarry Smith Concepts: options database^array of strings 86453acd3b1SBarry Smith 86553acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 86653acd3b1SBarry Smith PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 86753acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 86853acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 86953acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 87053acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 87153acd3b1SBarry Smith @*/ 87253acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsRealArray(const char opt[],const char text[],const char man[],PetscReal value[],PetscInt *n,PetscTruth *set) 87353acd3b1SBarry Smith { 87453acd3b1SBarry Smith PetscErrorCode ierr; 87553acd3b1SBarry Smith PetscInt i; 87653acd3b1SBarry Smith 87753acd3b1SBarry Smith PetscFunctionBegin; 87853acd3b1SBarry Smith ierr = PetscOptionsGetRealArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr); 87961b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 880a83599f4SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%G",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr); 88153acd3b1SBarry Smith for (i=1; i<*n; i++) { 882a83599f4SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%G",value[i]);CHKERRQ(ierr); 88353acd3b1SBarry Smith } 88453acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr); 88553acd3b1SBarry Smith } 88653acd3b1SBarry Smith PetscFunctionReturn(0); 88753acd3b1SBarry Smith } 88853acd3b1SBarry Smith 88953acd3b1SBarry Smith 89053acd3b1SBarry Smith #undef __FUNCT__ 89153acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsIntArray" 89253acd3b1SBarry Smith /*@C 89353acd3b1SBarry Smith PetscOptionsIntArray - Gets an array of integers for a particular 89453acd3b1SBarry Smith option in the database. The values must be separated with commas with 89553acd3b1SBarry Smith no intervening spaces. 89653acd3b1SBarry Smith 89753acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 89853acd3b1SBarry Smith 89953acd3b1SBarry Smith Input Parameters: 90053acd3b1SBarry Smith + opt - the option one is seeking 90153acd3b1SBarry Smith . text - short string describing option 90253acd3b1SBarry Smith . man - manual page for option 903f8a50e2bSBarry Smith - n - maximum number of values 90453acd3b1SBarry Smith 90553acd3b1SBarry Smith Output Parameter: 90653acd3b1SBarry Smith + value - location to copy values 907f8a50e2bSBarry Smith . n - actual number of values found 90853acd3b1SBarry Smith - set - PETSC_TRUE if found, else PETSC_FALSE 90953acd3b1SBarry Smith 91053acd3b1SBarry Smith Level: beginner 91153acd3b1SBarry Smith 91253acd3b1SBarry Smith Notes: 91353acd3b1SBarry Smith The user should pass in an array of integers 91453acd3b1SBarry Smith 91553acd3b1SBarry Smith Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 91653acd3b1SBarry Smith 91753acd3b1SBarry Smith Concepts: options database^array of strings 91853acd3b1SBarry Smith 91953acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 92053acd3b1SBarry Smith PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 92153acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 92253acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 92353acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 92453acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList(), PetscOptionsRealArray() 92553acd3b1SBarry Smith @*/ 92653acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsIntArray(const char opt[],const char text[],const char man[],PetscInt value[],PetscInt *n,PetscTruth *set) 92753acd3b1SBarry Smith { 92853acd3b1SBarry Smith PetscErrorCode ierr; 92953acd3b1SBarry Smith PetscInt i; 93053acd3b1SBarry Smith 93153acd3b1SBarry Smith PetscFunctionBegin; 93253acd3b1SBarry Smith ierr = PetscOptionsGetIntArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr); 93361b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 93453acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%d",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr); 93553acd3b1SBarry Smith for (i=1; i<*n; i++) { 93653acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%d",value[i]);CHKERRQ(ierr); 93753acd3b1SBarry Smith } 93853acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr); 93953acd3b1SBarry Smith } 94053acd3b1SBarry Smith PetscFunctionReturn(0); 94153acd3b1SBarry Smith } 94253acd3b1SBarry Smith 94353acd3b1SBarry Smith #undef __FUNCT__ 94453acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsStringArray" 94553acd3b1SBarry Smith /*@C 94653acd3b1SBarry Smith PetscOptionsStringArray - Gets an array of string values for a particular 94753acd3b1SBarry Smith option in the database. The values must be separated with commas with 94853acd3b1SBarry Smith no intervening spaces. 94953acd3b1SBarry Smith 95053acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 95153acd3b1SBarry Smith 95253acd3b1SBarry Smith Input Parameters: 95353acd3b1SBarry Smith + opt - the option one is seeking 95453acd3b1SBarry Smith . text - short string describing option 95553acd3b1SBarry Smith . man - manual page for option 95653acd3b1SBarry Smith - nmax - maximum number of strings 95753acd3b1SBarry Smith 95853acd3b1SBarry Smith Output Parameter: 95953acd3b1SBarry Smith + value - location to copy strings 96053acd3b1SBarry Smith . nmax - actual number of strings found 96153acd3b1SBarry Smith - set - PETSC_TRUE if found, else PETSC_FALSE 96253acd3b1SBarry Smith 96353acd3b1SBarry Smith Level: beginner 96453acd3b1SBarry Smith 96553acd3b1SBarry Smith Notes: 96653acd3b1SBarry Smith The user should pass in an array of pointers to char, to hold all the 96753acd3b1SBarry Smith strings returned by this function. 96853acd3b1SBarry Smith 96953acd3b1SBarry Smith The user is responsible for deallocating the strings that are 97053acd3b1SBarry Smith returned. The Fortran interface for this routine is not supported. 97153acd3b1SBarry Smith 97253acd3b1SBarry Smith Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 97353acd3b1SBarry Smith 97453acd3b1SBarry Smith Concepts: options database^array of strings 97553acd3b1SBarry Smith 97653acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 97753acd3b1SBarry Smith PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 97853acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 97953acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 98053acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 98153acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 98253acd3b1SBarry Smith @*/ 98353acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsStringArray(const char opt[],const char text[],const char man[],char *value[],PetscInt *nmax,PetscTruth *set) 98453acd3b1SBarry Smith { 98553acd3b1SBarry Smith PetscErrorCode ierr; 98653acd3b1SBarry Smith 98753acd3b1SBarry Smith PetscFunctionBegin; 98853acd3b1SBarry Smith ierr = PetscOptionsGetStringArray(PetscOptionsObject.prefix,opt,value,nmax,set);CHKERRQ(ierr); 98961b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 99053acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <string1,string2,...>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 99153acd3b1SBarry Smith } 99253acd3b1SBarry Smith PetscFunctionReturn(0); 99353acd3b1SBarry Smith } 99453acd3b1SBarry Smith 995e2446a98SMatthew Knepley #undef __FUNCT__ 996e2446a98SMatthew Knepley #define __FUNCT__ "PetscOptionsTruthArray" 997e2446a98SMatthew Knepley /*@C 998e2446a98SMatthew Knepley PetscOptionsTruthArray - Gets an array of logical values (true or false) for a particular 999e2446a98SMatthew Knepley option in the database. The values must be separated with commas with 1000e2446a98SMatthew Knepley no intervening spaces. 1001e2446a98SMatthew Knepley 1002e2446a98SMatthew Knepley Collective on the communicator passed in PetscOptionsBegin() 1003e2446a98SMatthew Knepley 1004e2446a98SMatthew Knepley Input Parameters: 1005e2446a98SMatthew Knepley + opt - the option one is seeking 1006e2446a98SMatthew Knepley . text - short string describing option 1007e2446a98SMatthew Knepley . man - manual page for option 1008e2446a98SMatthew Knepley - nmax - maximum number of values 1009e2446a98SMatthew Knepley 1010e2446a98SMatthew Knepley Output Parameter: 1011e2446a98SMatthew Knepley + value - location to copy values 1012e2446a98SMatthew Knepley . nmax - actual number of values found 1013e2446a98SMatthew Knepley - set - PETSC_TRUE if found, else PETSC_FALSE 1014e2446a98SMatthew Knepley 1015e2446a98SMatthew Knepley Level: beginner 1016e2446a98SMatthew Knepley 1017e2446a98SMatthew Knepley Notes: 1018e2446a98SMatthew Knepley The user should pass in an array of doubles 1019e2446a98SMatthew Knepley 1020e2446a98SMatthew Knepley Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 1021e2446a98SMatthew Knepley 1022e2446a98SMatthew Knepley Concepts: options database^array of strings 1023e2446a98SMatthew Knepley 1024e2446a98SMatthew Knepley .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1025e2446a98SMatthew Knepley PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 1026e2446a98SMatthew Knepley PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 1027e2446a98SMatthew Knepley PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1028e2446a98SMatthew Knepley PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 1029e2446a98SMatthew Knepley PetscOptionsList(), PetscOptionsEList() 1030e2446a98SMatthew Knepley @*/ 1031e2446a98SMatthew Knepley PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthArray(const char opt[],const char text[],const char man[],PetscTruth value[],PetscInt *n,PetscTruth *set) 1032e2446a98SMatthew Knepley { 1033e2446a98SMatthew Knepley PetscErrorCode ierr; 1034e2446a98SMatthew Knepley PetscInt i; 1035e2446a98SMatthew Knepley 1036e2446a98SMatthew Knepley PetscFunctionBegin; 1037e2446a98SMatthew Knepley ierr = PetscOptionsGetTruthArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr); 1038e2446a98SMatthew Knepley if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 1039e2446a98SMatthew Knepley ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%d",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr); 1040e2446a98SMatthew Knepley for (i=1; i<*n; i++) { 1041e2446a98SMatthew Knepley ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%d",value[i]);CHKERRQ(ierr); 1042e2446a98SMatthew Knepley } 1043e2446a98SMatthew Knepley ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr); 1044e2446a98SMatthew Knepley } 1045e2446a98SMatthew Knepley PetscFunctionReturn(0); 1046e2446a98SMatthew Knepley } 1047e2446a98SMatthew Knepley 104853acd3b1SBarry Smith 104953acd3b1SBarry Smith #undef __FUNCT__ 105053acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsHead" 105153acd3b1SBarry Smith /*@C 1052b52f573bSBarry Smith PetscOptionsHead - Puts a heading before listing any more published options. Used, for example, 105353acd3b1SBarry Smith in KSPSetFromOptions_GMRES(). 105453acd3b1SBarry Smith 105553acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 105653acd3b1SBarry Smith 105753acd3b1SBarry Smith Input Parameter: 105853acd3b1SBarry Smith . head - the heading text 105953acd3b1SBarry Smith 106053acd3b1SBarry Smith 106153acd3b1SBarry Smith Level: intermediate 106253acd3b1SBarry Smith 106353acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 106453acd3b1SBarry Smith 1065b52f573bSBarry Smith Can be followed by a call to PetscOptionsTail() in the same function. 106653acd3b1SBarry Smith 106753acd3b1SBarry Smith Concepts: options database^subheading 106853acd3b1SBarry Smith 106953acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 107053acd3b1SBarry Smith PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 107153acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 107253acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 107353acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 107453acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 107553acd3b1SBarry Smith @*/ 107653acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsHead(const char head[]) 107753acd3b1SBarry Smith { 107853acd3b1SBarry Smith PetscErrorCode ierr; 107953acd3b1SBarry Smith 108053acd3b1SBarry Smith PetscFunctionBegin; 108161b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 108253acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," %s\n",head);CHKERRQ(ierr); 108353acd3b1SBarry Smith } 108453acd3b1SBarry Smith PetscFunctionReturn(0); 108553acd3b1SBarry Smith } 108653acd3b1SBarry Smith 108753acd3b1SBarry Smith 108853acd3b1SBarry Smith 108953acd3b1SBarry Smith 109053acd3b1SBarry Smith 109153acd3b1SBarry Smith 1092