153acd3b1SBarry Smith #define PETSC_DLL 253acd3b1SBarry Smith /* 353acd3b1SBarry Smith These routines simplify the use of command line, file options, etc., 453acd3b1SBarry Smith and are used to manipulate the options database. 553acd3b1SBarry Smith 653acd3b1SBarry Smith This file uses regular malloc and free because it cannot know 753acd3b1SBarry Smith what malloc is being used until it has already processed the input. 853acd3b1SBarry Smith */ 953acd3b1SBarry Smith 1053acd3b1SBarry Smith #include "petsc.h" /*I "petsc.h" I*/ 1153acd3b1SBarry Smith #include "petscsys.h" 1253acd3b1SBarry Smith #if defined(PETSC_HAVE_STDLIB_H) 1353acd3b1SBarry Smith #include <stdlib.h> 1453acd3b1SBarry Smith #endif 1553acd3b1SBarry Smith 1653acd3b1SBarry Smith /* 1753acd3b1SBarry Smith Keep a linked list of options that have been posted and we are waiting for 1853acd3b1SBarry Smith user selection 1953acd3b1SBarry Smith 2053acd3b1SBarry Smith Eventually we'll attach this beast to a MPI_Comm 2153acd3b1SBarry Smith */ 22f8d0b74dSMatthew Knepley PetscOptionsObjectType PetscOptionsObject; 2353acd3b1SBarry Smith PetscInt PetscOptionsPublishCount = 0; 2453acd3b1SBarry Smith 2561b37b28SSatish Balay 2661b37b28SSatish Balay #undef __FUNCT__ 2761b37b28SSatish Balay #define __FUNCT__ "PetscOptionsHelpAddList" 2861b37b28SSatish Balay PetscErrorCode PetscOptionsHelpAddList(const char prefix[],const char title[],const char mansec[]) 2961b37b28SSatish Balay { 3061b37b28SSatish Balay int ierr; 31e3ed6ec8SBarry Smith PetscOptionsHelp newhelp; 3261b37b28SSatish Balay PetscFunctionBegin; 33e3ed6ec8SBarry Smith ierr = PetscNew(struct _p_PetscOptionsHelp,&newhelp);CHKERRQ(ierr); 3461b37b28SSatish Balay ierr = PetscStrallocpy(prefix,&newhelp->prefix);CHKERRQ(ierr); 3561b37b28SSatish Balay ierr = PetscStrallocpy(title,&newhelp->title);CHKERRQ(ierr); 3661b37b28SSatish Balay ierr = PetscStrallocpy(mansec,&newhelp->mansec);CHKERRQ(ierr); 3761b37b28SSatish Balay newhelp->next = 0; 3861b37b28SSatish Balay 3961b37b28SSatish Balay if (!PetscOptionsObject.help) { 4061b37b28SSatish Balay PetscOptionsObject.help = newhelp; 4161b37b28SSatish Balay } else { 4261b37b28SSatish Balay newhelp->next = PetscOptionsObject.help; 4361b37b28SSatish Balay PetscOptionsObject.help = newhelp; 4461b37b28SSatish Balay } 4561b37b28SSatish Balay PetscFunctionReturn(0); 4661b37b28SSatish Balay } 4761b37b28SSatish Balay 4861b37b28SSatish Balay #undef __FUNCT__ 4961b37b28SSatish Balay #define __FUNCT__ "PetscOptionsHelpDestroyList" 5061b37b28SSatish Balay PetscErrorCode PetscOptionsHelpDestroyList(void) 5161b37b28SSatish Balay { 5261b37b28SSatish Balay PetscErrorCode ierr; 53e3ed6ec8SBarry Smith PetscOptionsHelp help = PetscOptionsObject.help, next; 5461b37b28SSatish Balay 5561b37b28SSatish Balay PetscFunctionBegin; 5661b37b28SSatish Balay while (help) { 5761b37b28SSatish Balay next = help->next; 5861b37b28SSatish Balay ierr = PetscStrfree(help->prefix);CHKERRQ(ierr); 5961b37b28SSatish Balay ierr = PetscStrfree(help->title);CHKERRQ(ierr); 6061b37b28SSatish Balay ierr = PetscStrfree(help->mansec);CHKERRQ(ierr); 6161b37b28SSatish Balay ierr = PetscFree(help);CHKERRQ(ierr); 6261b37b28SSatish Balay help = next; 6361b37b28SSatish Balay } 6461b37b28SSatish Balay PetscFunctionReturn(0); 6561b37b28SSatish Balay } 6661b37b28SSatish Balay 6761b37b28SSatish Balay 6861b37b28SSatish Balay #undef __FUNCT__ 6961b37b28SSatish Balay #define __FUNCT__ "PetscOptionsHelpFindList" 7061b37b28SSatish Balay PetscErrorCode PetscOptionsHelpFindList(const char prefix[],const char title[],const char mansec[],PetscTruth *flg) 7161b37b28SSatish Balay { 7261b37b28SSatish Balay PetscErrorCode ierr; 7361b37b28SSatish Balay PetscTruth flg1,flg2,flg3; 74e3ed6ec8SBarry Smith PetscOptionsHelp help = PetscOptionsObject.help; 752c33bbaeSSatish Balay PetscFunctionBegin; 7661b37b28SSatish Balay while (help) { 7761b37b28SSatish Balay ierr = PetscStrcmp(help->prefix,prefix,&flg1);CHKERRQ(ierr); 7861b37b28SSatish Balay ierr = PetscStrcmp(help->title,title,&flg2);CHKERRQ(ierr); 7961b37b28SSatish Balay ierr = PetscStrcmp(help->mansec,mansec,&flg3);CHKERRQ(ierr); 8061b37b28SSatish Balay if (flg1 && flg2 && flg3) { 81115b5ef7SSatish Balay *flg = PETSC_TRUE; 8261b37b28SSatish Balay break; 8361b37b28SSatish Balay } 8461b37b28SSatish Balay help = help->next; 8561b37b28SSatish Balay } 8661b37b28SSatish Balay PetscFunctionReturn(0); 8761b37b28SSatish Balay 8861b37b28SSatish Balay } 8961b37b28SSatish Balay 9061b37b28SSatish Balay #undef __FUNCT__ 9161b37b28SSatish Balay #define __FUNCT__ "PetscOptionsHelpCheckAddList" 9261b37b28SSatish Balay PetscErrorCode PetscOptionsHelpCheckAddList(const char prefix[],const char title[],const char mansec[],PetscTruth *flg) 9361b37b28SSatish Balay { 9461b37b28SSatish Balay PetscFunctionBegin; 9561b37b28SSatish Balay PetscOptionsHelpFindList(prefix,title,mansec,flg); 9661b37b28SSatish Balay if (!(*flg)) PetscOptionsHelpAddList(prefix,title,mansec); 9761b37b28SSatish Balay PetscFunctionReturn(0); 9861b37b28SSatish Balay } 9961b37b28SSatish Balay 10053acd3b1SBarry Smith #undef __FUNCT__ 10153acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsBegin_Private" 10253acd3b1SBarry Smith /* 10353acd3b1SBarry Smith Handles setting up the data structure in a call to PetscOptionsBegin() 10453acd3b1SBarry Smith */ 10553acd3b1SBarry Smith PetscErrorCode PetscOptionsBegin_Private(MPI_Comm comm,const char prefix[],const char title[],const char mansec[]) 10653acd3b1SBarry Smith { 10753acd3b1SBarry Smith PetscErrorCode ierr; 10853acd3b1SBarry Smith 10953acd3b1SBarry Smith PetscFunctionBegin; 11053acd3b1SBarry Smith PetscOptionsObject.next = 0; 11153acd3b1SBarry Smith PetscOptionsObject.comm = comm; 1126356e834SBarry Smith PetscOptionsObject.changedmethod = PETSC_FALSE; 113f8d0b74dSMatthew Knepley if (PetscOptionsObject.prefix) { 114f8d0b74dSMatthew Knepley ierr = PetscStrfree(PetscOptionsObject.prefix);CHKERRQ(ierr); PetscOptionsObject.prefix = 0; 115f8d0b74dSMatthew Knepley } 11653acd3b1SBarry Smith ierr = PetscStrallocpy(prefix,&PetscOptionsObject.prefix);CHKERRQ(ierr); 117f8d0b74dSMatthew Knepley if (PetscOptionsObject.title) { 118f8d0b74dSMatthew Knepley ierr = PetscStrfree(PetscOptionsObject.title);CHKERRQ(ierr); PetscOptionsObject.title = 0; 119f8d0b74dSMatthew Knepley } 12053acd3b1SBarry Smith ierr = PetscStrallocpy(title,&PetscOptionsObject.title);CHKERRQ(ierr); 12153acd3b1SBarry Smith 12253acd3b1SBarry Smith ierr = PetscOptionsHasName(PETSC_NULL,"-help",&PetscOptionsObject.printhelp);CHKERRQ(ierr); 12353acd3b1SBarry Smith if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1) { 12461b37b28SSatish Balay ierr = PetscOptionsHelpCheckAddList(prefix,title,mansec,&PetscOptionsObject.alreadyprinted); 12561b37b28SSatish Balay if (!PetscOptionsObject.alreadyprinted) { 12653acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(comm,"%s -------------------------------------------------\n",title);CHKERRQ(ierr); 12753acd3b1SBarry Smith } 12861b37b28SSatish Balay } 12953acd3b1SBarry Smith PetscFunctionReturn(0); 13053acd3b1SBarry Smith } 13153acd3b1SBarry Smith 13253acd3b1SBarry Smith /* 13353acd3b1SBarry Smith Handles adding another option to the list of options within this particular PetscOptionsBegin() PetscOptionsEnd() 13453acd3b1SBarry Smith */ 13553acd3b1SBarry Smith #undef __FUNCT__ 13653acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsCreate_Private" 137e3ed6ec8SBarry Smith static int PetscOptionsCreate_Private(const char opt[],const char text[],const char man[],PetscOptionType t,PetscOptions *amsopt) 13853acd3b1SBarry Smith { 13953acd3b1SBarry Smith int ierr; 14053acd3b1SBarry Smith PetscOptions next; 14153acd3b1SBarry Smith 14253acd3b1SBarry Smith PetscFunctionBegin; 143e3ed6ec8SBarry Smith ierr = PetscNew(struct _p_PetscOptions,amsopt);CHKERRQ(ierr); 14453acd3b1SBarry Smith (*amsopt)->next = 0; 14553acd3b1SBarry Smith (*amsopt)->set = PETSC_FALSE; 1466356e834SBarry Smith (*amsopt)->type = t; 14753acd3b1SBarry Smith (*amsopt)->data = 0; 14853acd3b1SBarry Smith (*amsopt)->edata = 0; 14961b37b28SSatish Balay 15053acd3b1SBarry Smith ierr = PetscStrallocpy(text,&(*amsopt)->text);CHKERRQ(ierr); 15153acd3b1SBarry Smith ierr = PetscStrallocpy(opt,&(*amsopt)->option);CHKERRQ(ierr); 1526356e834SBarry Smith ierr = PetscStrallocpy(man,&(*amsopt)->man);CHKERRQ(ierr); 15353acd3b1SBarry Smith 15453acd3b1SBarry Smith if (!PetscOptionsObject.next) { 15553acd3b1SBarry Smith PetscOptionsObject.next = *amsopt; 15653acd3b1SBarry Smith } else { 15753acd3b1SBarry Smith next = PetscOptionsObject.next; 15853acd3b1SBarry Smith while (next->next) next = next->next; 15953acd3b1SBarry Smith next->next = *amsopt; 16053acd3b1SBarry Smith } 16153acd3b1SBarry Smith PetscFunctionReturn(0); 16253acd3b1SBarry Smith } 16353acd3b1SBarry Smith 16453acd3b1SBarry Smith #undef __FUNCT__ 1656356e834SBarry Smith #define __FUNCT__ "PetscOptionsGetFromGui" 166b47fd4b1SSatish Balay PetscErrorCode PetscOptionsGetFromGUI() 1676356e834SBarry Smith { 1686356e834SBarry Smith PetscErrorCode ierr; 1696356e834SBarry Smith PetscOptions next = PetscOptionsObject.next; 1706356e834SBarry Smith char str[512]; 1716356e834SBarry Smith 1726356e834SBarry Smith ierr = (*PetscPrintf)(PetscOptionsObject.comm,"%s -------------------------------------------------\n",PetscOptionsObject.title);CHKERRQ(ierr); 1736356e834SBarry Smith while (next) { 1746356e834SBarry Smith switch (next->type) { 1756356e834SBarry Smith case OPTION_HEAD: 1766356e834SBarry Smith break; 1776356e834SBarry Smith case OPTION_INT: 1786356e834SBarry Smith ierr = PetscPrintf(PetscOptionsObject.comm,"-%s%s <%d>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",next->option,*(int*)next->data,next->text,next->man);CHKERRQ(ierr); 1796356e834SBarry Smith scanf("%s\n",str); 1806356e834SBarry Smith if (str[0] != '\n') { 181b432afdaSMatthew Knepley printf("changing value\n"); 1826356e834SBarry Smith } 1836356e834SBarry Smith break; 184b432afdaSMatthew Knepley default: 185b432afdaSMatthew Knepley break; 1866356e834SBarry Smith } 1876356e834SBarry Smith next = next->next; 1886356e834SBarry Smith } 1896356e834SBarry Smith PetscFunctionReturn(0); 1906356e834SBarry Smith } 1916356e834SBarry Smith 1926356e834SBarry Smith #undef __FUNCT__ 19353acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsEnd_Private" 19453acd3b1SBarry Smith PetscErrorCode PetscOptionsEnd_Private(void) 19553acd3b1SBarry Smith { 19653acd3b1SBarry Smith PetscErrorCode ierr; 1976356e834SBarry Smith PetscOptions last; 1986356e834SBarry Smith char option[256],value[1024],tmp[32]; 1996356e834SBarry Smith PetscInt j; 20053acd3b1SBarry Smith 20153acd3b1SBarry Smith PetscFunctionBegin; 2026356e834SBarry Smith 203265dcc83SBarry Smith /* if (PetscOptionsObject.next) { 2046356e834SBarry Smith ierr = PetscOptionsGetFromGUI(); 205265dcc83SBarry Smith }*/ 2066356e834SBarry Smith 20753acd3b1SBarry Smith ierr = PetscStrfree(PetscOptionsObject.title);CHKERRQ(ierr); PetscOptionsObject.title = 0; 20853acd3b1SBarry Smith ierr = PetscStrfree(PetscOptionsObject.prefix);CHKERRQ(ierr); PetscOptionsObject.prefix = 0; 2096356e834SBarry Smith 2106356e834SBarry Smith /* reset counter to -2; this updates the screen with the new options for the selected method */ 2116356e834SBarry Smith if (PetscOptionsObject.changedmethod) PetscOptionsPublishCount = -2; 21261b37b28SSatish Balay /* reset alreadyprinted flag */ 21361b37b28SSatish Balay PetscOptionsObject.alreadyprinted = PETSC_FALSE; 2146356e834SBarry Smith 2156356e834SBarry Smith while (PetscOptionsObject.next) { 2166356e834SBarry Smith if (PetscOptionsObject.next->set) { 2176356e834SBarry Smith if (PetscOptionsObject.prefix) { 2186356e834SBarry Smith ierr = PetscStrcpy(option,"-");CHKERRQ(ierr); 2196356e834SBarry Smith ierr = PetscStrcat(option,PetscOptionsObject.prefix);CHKERRQ(ierr); 2206356e834SBarry Smith ierr = PetscStrcat(option,PetscOptionsObject.next->option+1);CHKERRQ(ierr); 2216356e834SBarry Smith } else { 2226356e834SBarry Smith ierr = PetscStrcpy(option,PetscOptionsObject.next->option);CHKERRQ(ierr); 2236356e834SBarry Smith } 2246356e834SBarry Smith 2256356e834SBarry Smith switch (PetscOptionsObject.next->type) { 2266356e834SBarry Smith case OPTION_HEAD: 2276356e834SBarry Smith break; 2286356e834SBarry Smith case OPTION_INT: 2297a72a596SBarry Smith sprintf(value,"%d",(int) *(PetscInt*)PetscOptionsObject.next->data); 2306356e834SBarry Smith break; 2316356e834SBarry Smith case OPTION_REAL: 2327a72a596SBarry Smith sprintf(value,"%g",(double) *(PetscReal*)PetscOptionsObject.next->data); 2336356e834SBarry Smith break; 2346356e834SBarry Smith case OPTION_REAL_ARRAY: 2357a72a596SBarry Smith sprintf(value,"%g",(double)((PetscReal*)PetscOptionsObject.next->data)[0]); 2366356e834SBarry Smith for (j=1; j<PetscOptionsObject.next->arraylength; j++) { 2377a72a596SBarry Smith sprintf(tmp,"%g",(double)((PetscReal*)PetscOptionsObject.next->data)[j]); 2386356e834SBarry Smith ierr = PetscStrcat(value,",");CHKERRQ(ierr); 2396356e834SBarry Smith ierr = PetscStrcat(value,tmp);CHKERRQ(ierr); 2406356e834SBarry Smith } 2416356e834SBarry Smith break; 2426356e834SBarry Smith case OPTION_LOGICAL: 2437a72a596SBarry Smith sprintf(value,"%d",(int)*(PetscInt*)PetscOptionsObject.next->data); 2446356e834SBarry Smith break; 2456356e834SBarry Smith case OPTION_LIST: 2466356e834SBarry Smith ierr = PetscStrcpy(value,*(char**)PetscOptionsObject.next->data);CHKERRQ(ierr); 2476356e834SBarry Smith break; 2486356e834SBarry Smith case OPTION_STRING: /* also handles string arrays */ 2496356e834SBarry Smith ierr = PetscStrcpy(value,*(char**)PetscOptionsObject.next->data);CHKERRQ(ierr); 2506356e834SBarry Smith break; 2516356e834SBarry Smith } 2526356e834SBarry Smith ierr = PetscOptionsSetValue(option,value);CHKERRQ(ierr); 2536356e834SBarry Smith } 2546356e834SBarry Smith ierr = PetscStrfree(PetscOptionsObject.next->text);CHKERRQ(ierr); 2556356e834SBarry Smith ierr = PetscStrfree(PetscOptionsObject.next->option);CHKERRQ(ierr); 2566356e834SBarry Smith ierr = PetscFree(PetscOptionsObject.next->man);CHKERRQ(ierr); 25705b42c5fSBarry Smith ierr = PetscFree(PetscOptionsObject.next->data);CHKERRQ(ierr); 25805b42c5fSBarry Smith ierr = PetscFree(PetscOptionsObject.next->edata);CHKERRQ(ierr); 2596356e834SBarry Smith last = PetscOptionsObject.next; 2606356e834SBarry Smith PetscOptionsObject.next = PetscOptionsObject.next->next; 2616356e834SBarry Smith ierr = PetscFree(last);CHKERRQ(ierr); 2626356e834SBarry Smith } 2636356e834SBarry Smith PetscOptionsObject.next = 0; 26453acd3b1SBarry Smith PetscFunctionReturn(0); 26553acd3b1SBarry Smith } 26653acd3b1SBarry Smith 26753acd3b1SBarry Smith #undef __FUNCT__ 26853acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsEnum" 26953acd3b1SBarry Smith /*@C 27053acd3b1SBarry Smith PetscOptionsEnum - Gets the enum value for a particular option in the database. 27153acd3b1SBarry Smith 27253acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 27353acd3b1SBarry Smith 27453acd3b1SBarry Smith Input Parameters: 27553acd3b1SBarry Smith + opt - option name 27653acd3b1SBarry Smith . text - short string that describes the option 27753acd3b1SBarry Smith . man - manual page with additional information on option 27853acd3b1SBarry Smith . list - array containing the list of choices, followed by the enum name, followed by the enum prefix, followed by a null 27953acd3b1SBarry Smith - defaultv - the default (current) value 28053acd3b1SBarry Smith 28153acd3b1SBarry Smith Output Parameter: 28253acd3b1SBarry Smith + value - the value to return 28353acd3b1SBarry Smith - flg - PETSC_TRUE if found, else PETSC_FALSE 28453acd3b1SBarry Smith 28553acd3b1SBarry Smith Level: beginner 28653acd3b1SBarry Smith 28753acd3b1SBarry Smith Concepts: options database 28853acd3b1SBarry Smith 28953acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 29053acd3b1SBarry Smith 29153acd3b1SBarry Smith list is usually something like PCASMTypes or some other predefined list of enum names 29253acd3b1SBarry Smith 29353acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 29453acd3b1SBarry Smith PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 29553acd3b1SBarry Smith PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 29653acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 29753acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 29853acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 29953acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 30053acd3b1SBarry Smith @*/ 30153acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsEnum(const char opt[],const char text[],const char man[],const char **list,PetscEnum defaultv,PetscEnum *value,PetscTruth *set) 30253acd3b1SBarry Smith { 30353acd3b1SBarry Smith PetscErrorCode ierr; 30453acd3b1SBarry Smith PetscInt ntext = 0; 305aa5bb8c0SSatish Balay PetscInt tval; 306aa5bb8c0SSatish Balay PetscTruth tflg; 30753acd3b1SBarry Smith 30853acd3b1SBarry Smith PetscFunctionBegin; 30953acd3b1SBarry Smith while (list[ntext++]) { 31053acd3b1SBarry Smith if (ntext > 50) SETERRQ(PETSC_ERR_ARG_WRONG,"List argument appears to be wrong or have more than 50 entries"); 31153acd3b1SBarry Smith } 31253acd3b1SBarry Smith if (ntext < 3) SETERRQ(PETSC_ERR_ARG_WRONG,"List argument must have at least two entries: typename and type prefix"); 31353acd3b1SBarry Smith ntext -= 3; 314aa5bb8c0SSatish Balay ierr = PetscOptionsEList(opt,text,man,list,ntext,list[defaultv],&tval,&tflg);CHKERRQ(ierr); 315aa5bb8c0SSatish Balay /* with PETSC_USE_64BIT_INDICES sizeof(PetscInt) != sizeof(PetscEnum) */ 316aa5bb8c0SSatish Balay if (tflg) *value = (PetscEnum)tval; 317aa5bb8c0SSatish Balay if (set) *set = tflg; 31853acd3b1SBarry Smith PetscFunctionReturn(0); 31953acd3b1SBarry Smith } 32053acd3b1SBarry Smith 32153acd3b1SBarry Smith /* -------------------------------------------------------------------------------------------------------------*/ 32253acd3b1SBarry Smith #undef __FUNCT__ 32353acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsInt" 32453acd3b1SBarry Smith /*@C 32553acd3b1SBarry Smith PetscOptionsInt - Gets the integer value for a particular option in the database. 32653acd3b1SBarry Smith 32753acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 32853acd3b1SBarry Smith 32953acd3b1SBarry Smith Input Parameters: 33053acd3b1SBarry Smith + opt - option name 33153acd3b1SBarry Smith . text - short string that describes the option 33253acd3b1SBarry Smith . man - manual page with additional information on option 33353acd3b1SBarry Smith - defaultv - the default (current) value 33453acd3b1SBarry Smith 33553acd3b1SBarry Smith Output Parameter: 33653acd3b1SBarry Smith + value - the integer value to return 33753acd3b1SBarry Smith - flg - PETSC_TRUE if found, else PETSC_FALSE 33853acd3b1SBarry Smith 33953acd3b1SBarry Smith Level: beginner 34053acd3b1SBarry Smith 34153acd3b1SBarry Smith Concepts: options database^has int 34253acd3b1SBarry Smith 34353acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 34453acd3b1SBarry Smith 34553acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 34653acd3b1SBarry Smith PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 34753acd3b1SBarry Smith PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 34853acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 34953acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 35053acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 35153acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 35253acd3b1SBarry Smith @*/ 35353acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsInt(const char opt[],const char text[],const char man[],PetscInt defaultv,PetscInt *value,PetscTruth *set) 35453acd3b1SBarry Smith { 35553acd3b1SBarry Smith PetscErrorCode ierr; 3566356e834SBarry Smith PetscOptions amsopt; 35753acd3b1SBarry Smith 35853acd3b1SBarry Smith PetscFunctionBegin; 3596356e834SBarry Smith if (PetscOptionsPublishCount == 1) { 3606356e834SBarry Smith ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_INT,&amsopt);CHKERRQ(ierr); 3616356e834SBarry Smith ierr = PetscMalloc(sizeof(PetscInt),&amsopt->data);CHKERRQ(ierr); 3626356e834SBarry Smith *(PetscInt*)amsopt->data = defaultv; 3636356e834SBarry Smith } 36453acd3b1SBarry Smith ierr = PetscOptionsGetInt(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr); 36561b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 36653acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%d>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,man);CHKERRQ(ierr); 36753acd3b1SBarry Smith } 36853acd3b1SBarry Smith PetscFunctionReturn(0); 36953acd3b1SBarry Smith } 37053acd3b1SBarry Smith 37153acd3b1SBarry Smith #undef __FUNCT__ 37253acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsString" 37353acd3b1SBarry Smith /*@C 37453acd3b1SBarry Smith PetscOptionsString - Gets the string value for a particular option in the database. 37553acd3b1SBarry Smith 37653acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 37753acd3b1SBarry Smith 37853acd3b1SBarry Smith Input Parameters: 37953acd3b1SBarry Smith + opt - option name 38053acd3b1SBarry Smith . text - short string that describes the option 38153acd3b1SBarry Smith . man - manual page with additional information on option 38253acd3b1SBarry Smith - defaultv - the default (current) value 38353acd3b1SBarry Smith 38453acd3b1SBarry Smith Output Parameter: 38553acd3b1SBarry Smith + value - the value to return 38653acd3b1SBarry Smith - flg - PETSC_TRUE if found, else PETSC_FALSE 38753acd3b1SBarry Smith 38853acd3b1SBarry Smith Level: beginner 38953acd3b1SBarry Smith 39053acd3b1SBarry Smith Concepts: options database^has int 39153acd3b1SBarry Smith 39253acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 39353acd3b1SBarry Smith 39453acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 39553acd3b1SBarry Smith PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 39653acd3b1SBarry Smith PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 39753acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 39853acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 39953acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 40053acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 40153acd3b1SBarry Smith @*/ 40253acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsString(const char opt[],const char text[],const char man[],const char defaultv[],char value[],size_t len,PetscTruth *set) 40353acd3b1SBarry Smith { 40453acd3b1SBarry Smith PetscErrorCode ierr; 40553acd3b1SBarry Smith 40653acd3b1SBarry Smith PetscFunctionBegin; 40753acd3b1SBarry Smith ierr = PetscOptionsGetString(PetscOptionsObject.prefix,opt,value,len,set);CHKERRQ(ierr); 40861b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 40953acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%s>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,man);CHKERRQ(ierr); 41053acd3b1SBarry Smith } 41153acd3b1SBarry Smith PetscFunctionReturn(0); 41253acd3b1SBarry Smith } 41353acd3b1SBarry Smith 41453acd3b1SBarry Smith /* 41553acd3b1SBarry Smith Publishes an AMS double field (with the default value in it) and with a name 41653acd3b1SBarry Smith given by the text string 41753acd3b1SBarry Smith */ 41853acd3b1SBarry Smith #undef __FUNCT__ 41953acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsReal" 42053acd3b1SBarry Smith /*@C 42153acd3b1SBarry Smith PetscOptionsReal - Gets the PetscReal value for a particular option in the database. 42253acd3b1SBarry Smith 42353acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 42453acd3b1SBarry Smith 42553acd3b1SBarry Smith Input Parameters: 42653acd3b1SBarry Smith + opt - option name 42753acd3b1SBarry Smith . text - short string that describes the option 42853acd3b1SBarry Smith . man - manual page with additional information on option 42953acd3b1SBarry Smith - defaultv - the default (current) value 43053acd3b1SBarry Smith 43153acd3b1SBarry Smith Output Parameter: 43253acd3b1SBarry Smith + value - the value to return 43353acd3b1SBarry Smith - flg - PETSC_TRUE if found, else PETSC_FALSE 43453acd3b1SBarry Smith 43553acd3b1SBarry Smith Level: beginner 43653acd3b1SBarry Smith 43753acd3b1SBarry Smith Concepts: options database^has int 43853acd3b1SBarry Smith 43953acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 44053acd3b1SBarry Smith 44153acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 44253acd3b1SBarry Smith PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 44353acd3b1SBarry Smith PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 44453acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 44553acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 44653acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 44753acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 44853acd3b1SBarry Smith @*/ 44953acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsReal(const char opt[],const char text[],const char man[],PetscReal defaultv,PetscReal *value,PetscTruth *set) 45053acd3b1SBarry Smith { 45153acd3b1SBarry Smith PetscErrorCode ierr; 45253acd3b1SBarry Smith 45353acd3b1SBarry Smith PetscFunctionBegin; 45453acd3b1SBarry Smith ierr = PetscOptionsGetReal(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr); 45561b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 456a83599f4SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%G>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,man);CHKERRQ(ierr); 45753acd3b1SBarry Smith } 45853acd3b1SBarry Smith PetscFunctionReturn(0); 45953acd3b1SBarry Smith } 46053acd3b1SBarry Smith 46153acd3b1SBarry Smith #undef __FUNCT__ 46253acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsScalar" 46353acd3b1SBarry Smith /*@C 46453acd3b1SBarry Smith PetscOptionsScalar - Gets the scalar value for a particular option in the database. 46553acd3b1SBarry Smith 46653acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 46753acd3b1SBarry Smith 46853acd3b1SBarry Smith Input Parameters: 46953acd3b1SBarry Smith + opt - option name 47053acd3b1SBarry Smith . text - short string that describes the option 47153acd3b1SBarry Smith . man - manual page with additional information on option 47253acd3b1SBarry Smith - defaultv - the default (current) value 47353acd3b1SBarry Smith 47453acd3b1SBarry Smith Output Parameter: 47553acd3b1SBarry Smith + value - the value to return 47653acd3b1SBarry Smith - flg - PETSC_TRUE if found, else PETSC_FALSE 47753acd3b1SBarry Smith 47853acd3b1SBarry Smith Level: beginner 47953acd3b1SBarry Smith 48053acd3b1SBarry Smith Concepts: options database^has int 48153acd3b1SBarry Smith 48253acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 48353acd3b1SBarry Smith 48453acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 48553acd3b1SBarry Smith PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 48653acd3b1SBarry Smith PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 48753acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 48853acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 48953acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 49053acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 49153acd3b1SBarry Smith @*/ 49253acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsScalar(const char opt[],const char text[],const char man[],PetscScalar defaultv,PetscScalar *value,PetscTruth *set) 49353acd3b1SBarry Smith { 49453acd3b1SBarry Smith PetscErrorCode ierr; 49553acd3b1SBarry Smith 49653acd3b1SBarry Smith PetscFunctionBegin; 49753acd3b1SBarry Smith #if !defined(PETSC_USE_COMPLEX) 49853acd3b1SBarry Smith ierr = PetscOptionsReal(opt,text,man,defaultv,value,set);CHKERRQ(ierr); 49953acd3b1SBarry Smith #else 50053acd3b1SBarry Smith ierr = PetscOptionsGetScalar(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr); 50153acd3b1SBarry Smith #endif 50253acd3b1SBarry Smith PetscFunctionReturn(0); 50353acd3b1SBarry Smith } 50453acd3b1SBarry Smith 50553acd3b1SBarry Smith /* 50653acd3b1SBarry Smith Publishes an AMS logical field (with the default value in it) and with a name 50753acd3b1SBarry Smith given by the text string 50853acd3b1SBarry Smith */ 50953acd3b1SBarry Smith #undef __FUNCT__ 51053acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsName" 51153acd3b1SBarry Smith /*@C 512*90d69ab7SBarry 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 513*90d69ab7SBarry Smith its value is set to false. 51453acd3b1SBarry Smith 51553acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 51653acd3b1SBarry Smith 51753acd3b1SBarry Smith Input Parameters: 51853acd3b1SBarry Smith + opt - option name 51953acd3b1SBarry Smith . text - short string that describes the option 52053acd3b1SBarry Smith - man - manual page with additional information on option 52153acd3b1SBarry Smith 52253acd3b1SBarry Smith Output Parameter: 52353acd3b1SBarry Smith . flg - PETSC_TRUE if found, else PETSC_FALSE 52453acd3b1SBarry Smith 52553acd3b1SBarry Smith Level: beginner 52653acd3b1SBarry Smith 52753acd3b1SBarry Smith Concepts: options database^has int 52853acd3b1SBarry Smith 52953acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 53053acd3b1SBarry Smith 53153acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 53253acd3b1SBarry Smith PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 53353acd3b1SBarry Smith PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 53453acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 53553acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 53653acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 53753acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 53853acd3b1SBarry Smith @*/ 53953acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsName(const char opt[],const char text[],const char man[],PetscTruth *flg) 54053acd3b1SBarry Smith { 54153acd3b1SBarry Smith PetscErrorCode ierr; 54253acd3b1SBarry Smith 54353acd3b1SBarry Smith PetscFunctionBegin; 54453acd3b1SBarry Smith ierr = PetscOptionsHasName(PetscOptionsObject.prefix,opt,flg);CHKERRQ(ierr); 54561b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 54653acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 54753acd3b1SBarry Smith } 54853acd3b1SBarry Smith PetscFunctionReturn(0); 54953acd3b1SBarry Smith } 55053acd3b1SBarry Smith 55153acd3b1SBarry Smith #undef __FUNCT__ 55253acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsList" 55353acd3b1SBarry Smith /*@C 55453acd3b1SBarry Smith PetscOptionsList - Puts a list of option values that a single one may be selected from 55553acd3b1SBarry Smith 55653acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 55753acd3b1SBarry Smith 55853acd3b1SBarry Smith Input Parameters: 55953acd3b1SBarry Smith + opt - option name 56053acd3b1SBarry Smith . text - short string that describes the option 56153acd3b1SBarry Smith . man - manual page with additional information on option 56253acd3b1SBarry Smith . list - the possible choices 56353acd3b1SBarry Smith - defaultv - the default (current) value 56453acd3b1SBarry Smith 56553acd3b1SBarry Smith Output Parameter: 56653acd3b1SBarry Smith + value - the value to return 56753acd3b1SBarry Smith - set - PETSC_TRUE if found, else PETSC_FALSE 56853acd3b1SBarry Smith 56953acd3b1SBarry Smith Level: intermediate 57053acd3b1SBarry Smith 57153acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 57253acd3b1SBarry Smith 57353acd3b1SBarry Smith See PetscOptionsEList() for when the choices are given in a string array 57453acd3b1SBarry Smith 57553acd3b1SBarry Smith To get a listing of all currently specified options, 57653acd3b1SBarry Smith see PetscOptionsPrint() or PetscOptionsGetAll() 57753acd3b1SBarry Smith 57853acd3b1SBarry Smith Concepts: options database^list 57953acd3b1SBarry Smith 58053acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 58153acd3b1SBarry Smith PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 58253acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 58353acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 58453acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 58553acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 58653acd3b1SBarry Smith @*/ 58753acd3b1SBarry 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) 58853acd3b1SBarry Smith { 58953acd3b1SBarry Smith PetscErrorCode ierr; 59053acd3b1SBarry Smith 59153acd3b1SBarry Smith PetscFunctionBegin; 59253acd3b1SBarry Smith ierr = PetscOptionsGetString(PetscOptionsObject.prefix,opt,value,len,set);CHKERRQ(ierr); 59361b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 5941d280d73SBarry Smith ierr = PetscFListPrintTypes(list,PetscOptionsObject.comm,stdout,PetscOptionsObject.prefix,opt,ltext,man);CHKERRQ(ierr);CHKERRQ(ierr); 59553acd3b1SBarry Smith } 59653acd3b1SBarry Smith PetscFunctionReturn(0); 59753acd3b1SBarry Smith } 59853acd3b1SBarry Smith 59953acd3b1SBarry Smith #undef __FUNCT__ 60053acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsEList" 60153acd3b1SBarry Smith /*@C 60253acd3b1SBarry Smith PetscOptionsEList - Puts a list of option values that a single one may be selected from 60353acd3b1SBarry Smith 60453acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 60553acd3b1SBarry Smith 60653acd3b1SBarry Smith Input Parameters: 60753acd3b1SBarry Smith + opt - option name 60853acd3b1SBarry Smith . ltext - short string that describes the option 60953acd3b1SBarry Smith . man - manual page with additional information on option 61053acd3b1SBarry Smith . list - the possible choices 61153acd3b1SBarry Smith . ntext - number of choices 61253acd3b1SBarry Smith - defaultv - the default (current) value 61353acd3b1SBarry Smith 61453acd3b1SBarry Smith Output Parameter: 61553acd3b1SBarry Smith + value - the index of the value to return 61653acd3b1SBarry Smith - set - PETSC_TRUE if found, else PETSC_FALSE 61753acd3b1SBarry Smith 61853acd3b1SBarry Smith Level: intermediate 61953acd3b1SBarry Smith 62053acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 62153acd3b1SBarry Smith 62253acd3b1SBarry Smith See PetscOptionsList() for when the choices are given in a PetscFList() 62353acd3b1SBarry Smith 62453acd3b1SBarry Smith Concepts: options database^list 62553acd3b1SBarry Smith 62653acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 62753acd3b1SBarry Smith PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 62853acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 62953acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 63053acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 63153acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 63253acd3b1SBarry Smith @*/ 63353acd3b1SBarry 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) 63453acd3b1SBarry Smith { 63553acd3b1SBarry Smith PetscErrorCode ierr; 63653acd3b1SBarry Smith PetscInt i; 63753acd3b1SBarry Smith 63853acd3b1SBarry Smith PetscFunctionBegin; 63953acd3b1SBarry Smith ierr = PetscOptionsGetEList(PetscOptionsObject.prefix,opt,list,ntext,value,set);CHKERRQ(ierr); 64061b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 64153acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%s> (choose one of)",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv);CHKERRQ(ierr); 64253acd3b1SBarry Smith for (i=0; i<ntext; i++){ 64353acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," %s",list[i]);CHKERRQ(ierr); 64453acd3b1SBarry Smith } 64553acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"\n");CHKERRQ(ierr); 64653acd3b1SBarry Smith } 64753acd3b1SBarry Smith PetscFunctionReturn(0); 64853acd3b1SBarry Smith } 64953acd3b1SBarry Smith 65053acd3b1SBarry Smith #undef __FUNCT__ 65153acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsTruthGroupBegin" 65253acd3b1SBarry Smith /*@C 65353acd3b1SBarry Smith PetscOptionsTruthGroupBegin - First in a series of logical queries on the options database for 65453acd3b1SBarry Smith which only a single value can be true. 65553acd3b1SBarry Smith 65653acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 65753acd3b1SBarry Smith 65853acd3b1SBarry Smith Input Parameters: 65953acd3b1SBarry Smith + opt - option name 66053acd3b1SBarry Smith . text - short string that describes the option 66153acd3b1SBarry Smith - man - manual page with additional information on option 66253acd3b1SBarry Smith 66353acd3b1SBarry Smith Output Parameter: 66453acd3b1SBarry Smith . flg - whether that option was set or not 66553acd3b1SBarry Smith 66653acd3b1SBarry Smith Level: intermediate 66753acd3b1SBarry Smith 66853acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 66953acd3b1SBarry Smith 67053acd3b1SBarry Smith Must be followed by 0 or more PetscOptionsTruthGroup()s and PetscOptionsTruthGroupEnd() 67153acd3b1SBarry Smith 67253acd3b1SBarry Smith Concepts: options database^logical group 67353acd3b1SBarry Smith 67453acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 67553acd3b1SBarry Smith PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 67653acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 67753acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 67853acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 67953acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 68053acd3b1SBarry Smith @*/ 68153acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroupBegin(const char opt[],const char text[],const char man[],PetscTruth *flg) 68253acd3b1SBarry Smith { 68353acd3b1SBarry Smith PetscErrorCode ierr; 68453acd3b1SBarry Smith 68553acd3b1SBarry Smith PetscFunctionBegin; 68653acd3b1SBarry Smith ierr = PetscOptionsHasName(PetscOptionsObject.prefix,opt,flg);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; 73053acd3b1SBarry Smith ierr = PetscOptionsHasName(PetscOptionsObject.prefix,opt,flg);CHKERRQ(ierr); 73161b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 73253acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 73353acd3b1SBarry Smith } 73453acd3b1SBarry Smith PetscFunctionReturn(0); 73553acd3b1SBarry Smith } 73653acd3b1SBarry Smith 73753acd3b1SBarry Smith #undef __FUNCT__ 73853acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsTruthGroupEnd" 73953acd3b1SBarry Smith /*@C 74053acd3b1SBarry Smith PetscOptionsTruthGroupEnd - Last in a series of logical queries on the options database for 74153acd3b1SBarry Smith which only a single value can be true. 74253acd3b1SBarry Smith 74353acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 74453acd3b1SBarry Smith 74553acd3b1SBarry Smith Input Parameters: 74653acd3b1SBarry Smith + opt - option name 74753acd3b1SBarry Smith . text - short string that describes the option 74853acd3b1SBarry Smith - man - manual page with additional information on option 74953acd3b1SBarry Smith 75053acd3b1SBarry Smith Output Parameter: 75153acd3b1SBarry Smith . flg - PETSC_TRUE if found, else PETSC_FALSE 75253acd3b1SBarry Smith 75353acd3b1SBarry Smith Level: intermediate 75453acd3b1SBarry Smith 75553acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 75653acd3b1SBarry Smith 75753acd3b1SBarry Smith Must follow a PetscOptionsTruthGroupBegin() 75853acd3b1SBarry Smith 75953acd3b1SBarry Smith Concepts: options database^logical group 76053acd3b1SBarry Smith 76153acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 76253acd3b1SBarry Smith PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 76353acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 76453acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 76553acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 76653acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 76753acd3b1SBarry Smith @*/ 76853acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroupEnd(const char opt[],const char text[],const char man[],PetscTruth *flg) 76953acd3b1SBarry Smith { 77053acd3b1SBarry Smith PetscErrorCode ierr; 77153acd3b1SBarry Smith 77253acd3b1SBarry Smith PetscFunctionBegin; 77353acd3b1SBarry Smith ierr = PetscOptionsHasName(PetscOptionsObject.prefix,opt,flg);CHKERRQ(ierr); 77461b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 77553acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 77653acd3b1SBarry Smith } 77753acd3b1SBarry Smith PetscFunctionReturn(0); 77853acd3b1SBarry Smith } 77953acd3b1SBarry Smith 78053acd3b1SBarry Smith #undef __FUNCT__ 78153acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsTruth" 78253acd3b1SBarry Smith /*@C 78353acd3b1SBarry Smith PetscOptionsTruth - Determines if a particular option is in the database with a true or false 78453acd3b1SBarry Smith 78553acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 78653acd3b1SBarry Smith 78753acd3b1SBarry Smith Input Parameters: 78853acd3b1SBarry Smith + opt - option name 78953acd3b1SBarry Smith . text - short string that describes the option 79053acd3b1SBarry Smith - man - manual page with additional information on option 79153acd3b1SBarry Smith 79253acd3b1SBarry Smith Output Parameter: 79353acd3b1SBarry Smith . flg - PETSC_TRUE or PETSC_FALSE 79453acd3b1SBarry Smith . set - PETSC_TRUE if found, else PETSC_FALSE 79553acd3b1SBarry Smith 79653acd3b1SBarry Smith Level: beginner 79753acd3b1SBarry Smith 79853acd3b1SBarry Smith Concepts: options database^logical 79953acd3b1SBarry Smith 80053acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 80153acd3b1SBarry Smith 80253acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 80353acd3b1SBarry Smith PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 80453acd3b1SBarry Smith PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 80553acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 80653acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 80753acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 80853acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 80953acd3b1SBarry Smith @*/ 81053acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruth(const char opt[],const char text[],const char man[],PetscTruth deflt,PetscTruth *flg,PetscTruth *set) 81153acd3b1SBarry Smith { 81253acd3b1SBarry Smith PetscErrorCode ierr; 81353acd3b1SBarry Smith PetscTruth iset; 81453acd3b1SBarry Smith 81553acd3b1SBarry Smith PetscFunctionBegin; 81653acd3b1SBarry Smith ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,&iset);CHKERRQ(ierr); 81753acd3b1SBarry Smith if (!iset) { 81853acd3b1SBarry Smith if (flg) *flg = deflt; 81953acd3b1SBarry Smith } 82053acd3b1SBarry Smith if (set) *set = iset; 82161b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 82253acd3b1SBarry Smith const char *v = PetscTruths[deflt]; 82353acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: <%s> %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,v,text,man);CHKERRQ(ierr); 82453acd3b1SBarry Smith } 82553acd3b1SBarry Smith PetscFunctionReturn(0); 82653acd3b1SBarry Smith } 82753acd3b1SBarry Smith 82853acd3b1SBarry Smith #undef __FUNCT__ 82953acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsRealArray" 83053acd3b1SBarry Smith /*@C 83153acd3b1SBarry Smith PetscOptionsRealArray - Gets an array of double values for a particular 83253acd3b1SBarry Smith option in the database. The values must be separated with commas with 83353acd3b1SBarry Smith no intervening spaces. 83453acd3b1SBarry Smith 83553acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 83653acd3b1SBarry Smith 83753acd3b1SBarry Smith Input Parameters: 83853acd3b1SBarry Smith + opt - the option one is seeking 83953acd3b1SBarry Smith . text - short string describing option 84053acd3b1SBarry Smith . man - manual page for option 84153acd3b1SBarry Smith - nmax - maximum number of values 84253acd3b1SBarry Smith 84353acd3b1SBarry Smith Output Parameter: 84453acd3b1SBarry Smith + value - location to copy values 84553acd3b1SBarry Smith . nmax - actual number of values found 84653acd3b1SBarry Smith - set - PETSC_TRUE if found, else PETSC_FALSE 84753acd3b1SBarry Smith 84853acd3b1SBarry Smith Level: beginner 84953acd3b1SBarry Smith 85053acd3b1SBarry Smith Notes: 85153acd3b1SBarry Smith The user should pass in an array of doubles 85253acd3b1SBarry Smith 85353acd3b1SBarry Smith Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 85453acd3b1SBarry Smith 85553acd3b1SBarry Smith Concepts: options database^array of strings 85653acd3b1SBarry Smith 85753acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 85853acd3b1SBarry Smith PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 85953acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 86053acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 86153acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 86253acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 86353acd3b1SBarry Smith @*/ 86453acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsRealArray(const char opt[],const char text[],const char man[],PetscReal value[],PetscInt *n,PetscTruth *set) 86553acd3b1SBarry Smith { 86653acd3b1SBarry Smith PetscErrorCode ierr; 86753acd3b1SBarry Smith PetscInt i; 86853acd3b1SBarry Smith 86953acd3b1SBarry Smith PetscFunctionBegin; 87053acd3b1SBarry Smith ierr = PetscOptionsGetRealArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr); 87161b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 872a83599f4SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%G",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr); 87353acd3b1SBarry Smith for (i=1; i<*n; i++) { 874a83599f4SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%G",value[i]);CHKERRQ(ierr); 87553acd3b1SBarry Smith } 87653acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr); 87753acd3b1SBarry Smith } 87853acd3b1SBarry Smith PetscFunctionReturn(0); 87953acd3b1SBarry Smith } 88053acd3b1SBarry Smith 88153acd3b1SBarry Smith 88253acd3b1SBarry Smith #undef __FUNCT__ 88353acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsIntArray" 88453acd3b1SBarry Smith /*@C 88553acd3b1SBarry Smith PetscOptionsIntArray - Gets an array of integers for a particular 88653acd3b1SBarry Smith option in the database. The values must be separated with commas with 88753acd3b1SBarry Smith no intervening spaces. 88853acd3b1SBarry Smith 88953acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 89053acd3b1SBarry Smith 89153acd3b1SBarry Smith Input Parameters: 89253acd3b1SBarry Smith + opt - the option one is seeking 89353acd3b1SBarry Smith . text - short string describing option 89453acd3b1SBarry Smith . man - manual page for option 895f8a50e2bSBarry Smith - n - maximum number of values 89653acd3b1SBarry Smith 89753acd3b1SBarry Smith Output Parameter: 89853acd3b1SBarry Smith + value - location to copy values 899f8a50e2bSBarry Smith . n - actual number of values found 90053acd3b1SBarry Smith - set - PETSC_TRUE if found, else PETSC_FALSE 90153acd3b1SBarry Smith 90253acd3b1SBarry Smith Level: beginner 90353acd3b1SBarry Smith 90453acd3b1SBarry Smith Notes: 90553acd3b1SBarry Smith The user should pass in an array of integers 90653acd3b1SBarry Smith 90753acd3b1SBarry Smith Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 90853acd3b1SBarry Smith 90953acd3b1SBarry Smith Concepts: options database^array of strings 91053acd3b1SBarry Smith 91153acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 91253acd3b1SBarry Smith PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 91353acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 91453acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 91553acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 91653acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList(), PetscOptionsRealArray() 91753acd3b1SBarry Smith @*/ 91853acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsIntArray(const char opt[],const char text[],const char man[],PetscInt value[],PetscInt *n,PetscTruth *set) 91953acd3b1SBarry Smith { 92053acd3b1SBarry Smith PetscErrorCode ierr; 92153acd3b1SBarry Smith PetscInt i; 92253acd3b1SBarry Smith 92353acd3b1SBarry Smith PetscFunctionBegin; 92453acd3b1SBarry Smith ierr = PetscOptionsGetIntArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr); 92561b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 92653acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%d",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr); 92753acd3b1SBarry Smith for (i=1; i<*n; i++) { 92853acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%d",value[i]);CHKERRQ(ierr); 92953acd3b1SBarry Smith } 93053acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr); 93153acd3b1SBarry Smith } 93253acd3b1SBarry Smith PetscFunctionReturn(0); 93353acd3b1SBarry Smith } 93453acd3b1SBarry Smith 93553acd3b1SBarry Smith #undef __FUNCT__ 93653acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsStringArray" 93753acd3b1SBarry Smith /*@C 93853acd3b1SBarry Smith PetscOptionsStringArray - Gets an array of string values for a particular 93953acd3b1SBarry Smith option in the database. The values must be separated with commas with 94053acd3b1SBarry Smith no intervening spaces. 94153acd3b1SBarry Smith 94253acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 94353acd3b1SBarry Smith 94453acd3b1SBarry Smith Input Parameters: 94553acd3b1SBarry Smith + opt - the option one is seeking 94653acd3b1SBarry Smith . text - short string describing option 94753acd3b1SBarry Smith . man - manual page for option 94853acd3b1SBarry Smith - nmax - maximum number of strings 94953acd3b1SBarry Smith 95053acd3b1SBarry Smith Output Parameter: 95153acd3b1SBarry Smith + value - location to copy strings 95253acd3b1SBarry Smith . nmax - actual number of strings found 95353acd3b1SBarry Smith - set - PETSC_TRUE if found, else PETSC_FALSE 95453acd3b1SBarry Smith 95553acd3b1SBarry Smith Level: beginner 95653acd3b1SBarry Smith 95753acd3b1SBarry Smith Notes: 95853acd3b1SBarry Smith The user should pass in an array of pointers to char, to hold all the 95953acd3b1SBarry Smith strings returned by this function. 96053acd3b1SBarry Smith 96153acd3b1SBarry Smith The user is responsible for deallocating the strings that are 96253acd3b1SBarry Smith returned. The Fortran interface for this routine is not supported. 96353acd3b1SBarry Smith 96453acd3b1SBarry Smith Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 96553acd3b1SBarry Smith 96653acd3b1SBarry Smith Concepts: options database^array of strings 96753acd3b1SBarry Smith 96853acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 96953acd3b1SBarry Smith PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 97053acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 97153acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 97253acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 97353acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 97453acd3b1SBarry Smith @*/ 97553acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsStringArray(const char opt[],const char text[],const char man[],char *value[],PetscInt *nmax,PetscTruth *set) 97653acd3b1SBarry Smith { 97753acd3b1SBarry Smith PetscErrorCode ierr; 97853acd3b1SBarry Smith 97953acd3b1SBarry Smith PetscFunctionBegin; 98053acd3b1SBarry Smith ierr = PetscOptionsGetStringArray(PetscOptionsObject.prefix,opt,value,nmax,set);CHKERRQ(ierr); 98161b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 98253acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <string1,string2,...>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 98353acd3b1SBarry Smith } 98453acd3b1SBarry Smith PetscFunctionReturn(0); 98553acd3b1SBarry Smith } 98653acd3b1SBarry Smith 987e2446a98SMatthew Knepley #undef __FUNCT__ 988e2446a98SMatthew Knepley #define __FUNCT__ "PetscOptionsTruthArray" 989e2446a98SMatthew Knepley /*@C 990e2446a98SMatthew Knepley PetscOptionsTruthArray - Gets an array of logical values (true or false) for a particular 991e2446a98SMatthew Knepley option in the database. The values must be separated with commas with 992e2446a98SMatthew Knepley no intervening spaces. 993e2446a98SMatthew Knepley 994e2446a98SMatthew Knepley Collective on the communicator passed in PetscOptionsBegin() 995e2446a98SMatthew Knepley 996e2446a98SMatthew Knepley Input Parameters: 997e2446a98SMatthew Knepley + opt - the option one is seeking 998e2446a98SMatthew Knepley . text - short string describing option 999e2446a98SMatthew Knepley . man - manual page for option 1000e2446a98SMatthew Knepley - nmax - maximum number of values 1001e2446a98SMatthew Knepley 1002e2446a98SMatthew Knepley Output Parameter: 1003e2446a98SMatthew Knepley + value - location to copy values 1004e2446a98SMatthew Knepley . nmax - actual number of values found 1005e2446a98SMatthew Knepley - set - PETSC_TRUE if found, else PETSC_FALSE 1006e2446a98SMatthew Knepley 1007e2446a98SMatthew Knepley Level: beginner 1008e2446a98SMatthew Knepley 1009e2446a98SMatthew Knepley Notes: 1010e2446a98SMatthew Knepley The user should pass in an array of doubles 1011e2446a98SMatthew Knepley 1012e2446a98SMatthew Knepley Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 1013e2446a98SMatthew Knepley 1014e2446a98SMatthew Knepley Concepts: options database^array of strings 1015e2446a98SMatthew Knepley 1016e2446a98SMatthew Knepley .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1017e2446a98SMatthew Knepley PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 1018e2446a98SMatthew Knepley PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 1019e2446a98SMatthew Knepley PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1020e2446a98SMatthew Knepley PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 1021e2446a98SMatthew Knepley PetscOptionsList(), PetscOptionsEList() 1022e2446a98SMatthew Knepley @*/ 1023e2446a98SMatthew Knepley PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthArray(const char opt[],const char text[],const char man[],PetscTruth value[],PetscInt *n,PetscTruth *set) 1024e2446a98SMatthew Knepley { 1025e2446a98SMatthew Knepley PetscErrorCode ierr; 1026e2446a98SMatthew Knepley PetscInt i; 1027e2446a98SMatthew Knepley 1028e2446a98SMatthew Knepley PetscFunctionBegin; 1029e2446a98SMatthew Knepley ierr = PetscOptionsGetTruthArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr); 1030e2446a98SMatthew Knepley if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 1031e2446a98SMatthew Knepley ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%d",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr); 1032e2446a98SMatthew Knepley for (i=1; i<*n; i++) { 1033e2446a98SMatthew Knepley ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%d",value[i]);CHKERRQ(ierr); 1034e2446a98SMatthew Knepley } 1035e2446a98SMatthew Knepley ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr); 1036e2446a98SMatthew Knepley } 1037e2446a98SMatthew Knepley PetscFunctionReturn(0); 1038e2446a98SMatthew Knepley } 1039e2446a98SMatthew Knepley 104053acd3b1SBarry Smith 104153acd3b1SBarry Smith #undef __FUNCT__ 104253acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsHead" 104353acd3b1SBarry Smith /*@C 1044b52f573bSBarry Smith PetscOptionsHead - Puts a heading before listing any more published options. Used, for example, 104553acd3b1SBarry Smith in KSPSetFromOptions_GMRES(). 104653acd3b1SBarry Smith 104753acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 104853acd3b1SBarry Smith 104953acd3b1SBarry Smith Input Parameter: 105053acd3b1SBarry Smith . head - the heading text 105153acd3b1SBarry Smith 105253acd3b1SBarry Smith 105353acd3b1SBarry Smith Level: intermediate 105453acd3b1SBarry Smith 105553acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 105653acd3b1SBarry Smith 1057b52f573bSBarry Smith Can be followed by a call to PetscOptionsTail() in the same function. 105853acd3b1SBarry Smith 105953acd3b1SBarry Smith Concepts: options database^subheading 106053acd3b1SBarry Smith 106153acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 106253acd3b1SBarry Smith PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 106353acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 106453acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 106553acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 106653acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 106753acd3b1SBarry Smith @*/ 106853acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsHead(const char head[]) 106953acd3b1SBarry Smith { 107053acd3b1SBarry Smith PetscErrorCode ierr; 107153acd3b1SBarry Smith 107253acd3b1SBarry Smith PetscFunctionBegin; 107361b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 107453acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," %s\n",head);CHKERRQ(ierr); 107553acd3b1SBarry Smith } 107653acd3b1SBarry Smith PetscFunctionReturn(0); 107753acd3b1SBarry Smith } 107853acd3b1SBarry Smith 107953acd3b1SBarry Smith 108053acd3b1SBarry Smith 108153acd3b1SBarry Smith 108253acd3b1SBarry Smith 108353acd3b1SBarry Smith 1084