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__ 165aee2cecaSBarry Smith #define __FUNCT__ "PetscScanString" 166aee2cecaSBarry Smith /* 167aee2cecaSBarry Smith PetscScanString - 168aee2cecaSBarry Smith 169aee2cecaSBarry Smith Bugs: 170aee2cecaSBarry Smith . Assumes process 0 of the given communicator has access to stdin 171aee2cecaSBarry Smith 172aee2cecaSBarry Smith */ 173aee2cecaSBarry Smith static PetscErrorCode PetscScanString(MPI_Comm comm,PetscInt n,char str[],PetscTruth *set) 174aee2cecaSBarry Smith { 175aee2cecaSBarry Smith PetscInt i; 176aee2cecaSBarry Smith char c; 177aee2cecaSBarry Smith PetscMPIInt rank; 178aee2cecaSBarry Smith PetscErrorCode ierr; 179aee2cecaSBarry Smith 180aee2cecaSBarry Smith PetscFunctionBegin; 181aee2cecaSBarry Smith ierr = MPI_Comm_rank(comm,&rank);CHKERRQ(ierr); 182aee2cecaSBarry Smith if (!rank) { 183aee2cecaSBarry Smith c = (char) getchar(); 184aee2cecaSBarry Smith i = 0; 185aee2cecaSBarry Smith while ( c != '\n' && i < n-1) { 186aee2cecaSBarry Smith str[i++] = c; 187aee2cecaSBarry Smith c = (char) getchar(); 188aee2cecaSBarry Smith } 189aee2cecaSBarry Smith str[i] = 0; 190aee2cecaSBarry Smith } 191aee2cecaSBarry Smith ierr = MPI_Bcast(str,n,MPI_CHAR,0,comm);CHKERRQ(ierr); 192aee2cecaSBarry Smith if (str[0]) *set = PETSC_TRUE; else *set = PETSC_FALSE; 193aee2cecaSBarry Smith PetscFunctionReturn(0); 194aee2cecaSBarry Smith } 195aee2cecaSBarry Smith 196aee2cecaSBarry Smith #undef __FUNCT__ 197aee2cecaSBarry Smith #define __FUNCT__ "PetscOptionsGetFromTextInput" 198aee2cecaSBarry Smith /* 199aee2cecaSBarry Smith PetscOptionsGetFromTextInput 200aee2cecaSBarry Smith 201aee2cecaSBarry Smith Notes: this isn't really practical, it is just to demonstrate the principle 202aee2cecaSBarry Smith 203aee2cecaSBarry Smith Bugs: 204aee2cecaSBarry Smith + All processes must traverse through the exact same set of option queries do to the call to PetscScanString() 205aee2cecaSBarry Smith - Only works for PetscInt == int, PetscReal == double etc 206aee2cecaSBarry Smith 207aee2cecaSBarry Smith */ 208aee2cecaSBarry Smith PetscErrorCode PetscOptionsGetFromTextInput() 2096356e834SBarry Smith { 2106356e834SBarry Smith PetscErrorCode ierr; 2116356e834SBarry Smith PetscOptions next = PetscOptionsObject.next; 2126356e834SBarry Smith char str[512]; 213aee2cecaSBarry Smith int id; 214aee2cecaSBarry Smith PetscTruth set; 215aee2cecaSBarry Smith double ir; 2166356e834SBarry Smith 2176356e834SBarry Smith ierr = (*PetscPrintf)(PetscOptionsObject.comm,"%s -------------------------------------------------\n",PetscOptionsObject.title);CHKERRQ(ierr); 2186356e834SBarry Smith while (next) { 2196356e834SBarry Smith switch (next->type) { 2206356e834SBarry Smith case OPTION_HEAD: 2216356e834SBarry Smith break; 2226356e834SBarry Smith case OPTION_INT: 223*af6d86caSBarry 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); 224aee2cecaSBarry Smith ierr = PetscScanString(PETSC_COMM_WORLD,512,str,&set);CHKERRQ(ierr); 225aee2cecaSBarry Smith if (set) { 226aee2cecaSBarry Smith sscanf(str,"%d",&id); 227aee2cecaSBarry Smith next->set = PETSC_TRUE; 228aee2cecaSBarry Smith *((PetscInt*)next->data) = id; 229aee2cecaSBarry Smith } 230aee2cecaSBarry Smith break; 231aee2cecaSBarry Smith case OPTION_REAL: 232*af6d86caSBarry 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); 233aee2cecaSBarry Smith ierr = PetscScanString(PETSC_COMM_WORLD,512,str,&set);CHKERRQ(ierr); 234aee2cecaSBarry Smith if (set) { 235aee2cecaSBarry Smith sscanf(str,"%le",&ir); 236aee2cecaSBarry Smith next->set = PETSC_TRUE; 237aee2cecaSBarry Smith *((PetscReal*)next->data) = ir; 238aee2cecaSBarry Smith } 239aee2cecaSBarry Smith break; 240aee2cecaSBarry Smith case OPTION_LOGICAL: 241aee2cecaSBarry Smith case OPTION_STRING: 242*af6d86caSBarry 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); 243aee2cecaSBarry Smith ierr = PetscScanString(PETSC_COMM_WORLD,512,str,&set);CHKERRQ(ierr); 244aee2cecaSBarry Smith if (set) { 245aee2cecaSBarry Smith next->set = PETSC_TRUE; 246aee2cecaSBarry Smith ierr = PetscStrcpy(next->data,str);CHKERRQ(ierr); 2476356e834SBarry Smith } 2486356e834SBarry Smith break; 249b432afdaSMatthew Knepley default: 250b432afdaSMatthew Knepley break; 2516356e834SBarry Smith } 2526356e834SBarry Smith next = next->next; 2536356e834SBarry Smith } 2546356e834SBarry Smith PetscFunctionReturn(0); 2556356e834SBarry Smith } 2566356e834SBarry Smith 2576356e834SBarry Smith #undef __FUNCT__ 25853acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsEnd_Private" 25953acd3b1SBarry Smith PetscErrorCode PetscOptionsEnd_Private(void) 26053acd3b1SBarry Smith { 26153acd3b1SBarry Smith PetscErrorCode ierr; 2626356e834SBarry Smith PetscOptions last; 2636356e834SBarry Smith char option[256],value[1024],tmp[32]; 2646356e834SBarry Smith PetscInt j; 26553acd3b1SBarry Smith 26653acd3b1SBarry Smith PetscFunctionBegin; 2676356e834SBarry Smith 268aee2cecaSBarry Smith if (PetscOptionsObject.next) { 269aee2cecaSBarry Smith if (PetscOptionsPublishCount == 0) { 270aee2cecaSBarry Smith ierr = PetscOptionsGetFromTextInput(); 271aee2cecaSBarry Smith } 272aee2cecaSBarry Smith } 2736356e834SBarry Smith 27453acd3b1SBarry Smith ierr = PetscStrfree(PetscOptionsObject.title);CHKERRQ(ierr); PetscOptionsObject.title = 0; 27553acd3b1SBarry Smith ierr = PetscStrfree(PetscOptionsObject.prefix);CHKERRQ(ierr); PetscOptionsObject.prefix = 0; 2766356e834SBarry Smith 2776356e834SBarry Smith /* reset counter to -2; this updates the screen with the new options for the selected method */ 2786356e834SBarry Smith if (PetscOptionsObject.changedmethod) PetscOptionsPublishCount = -2; 27961b37b28SSatish Balay /* reset alreadyprinted flag */ 28061b37b28SSatish Balay PetscOptionsObject.alreadyprinted = PETSC_FALSE; 2816356e834SBarry Smith 2826356e834SBarry Smith while (PetscOptionsObject.next) { 2836356e834SBarry Smith if (PetscOptionsObject.next->set) { 2846356e834SBarry Smith if (PetscOptionsObject.prefix) { 2856356e834SBarry Smith ierr = PetscStrcpy(option,"-");CHKERRQ(ierr); 2866356e834SBarry Smith ierr = PetscStrcat(option,PetscOptionsObject.prefix);CHKERRQ(ierr); 2876356e834SBarry Smith ierr = PetscStrcat(option,PetscOptionsObject.next->option+1);CHKERRQ(ierr); 2886356e834SBarry Smith } else { 2896356e834SBarry Smith ierr = PetscStrcpy(option,PetscOptionsObject.next->option);CHKERRQ(ierr); 2906356e834SBarry Smith } 2916356e834SBarry Smith 2926356e834SBarry Smith switch (PetscOptionsObject.next->type) { 2936356e834SBarry Smith case OPTION_HEAD: 2946356e834SBarry Smith break; 2956356e834SBarry Smith case OPTION_INT: 2967a72a596SBarry Smith sprintf(value,"%d",(int) *(PetscInt*)PetscOptionsObject.next->data); 2976356e834SBarry Smith break; 2986356e834SBarry Smith case OPTION_REAL: 2997a72a596SBarry Smith sprintf(value,"%g",(double) *(PetscReal*)PetscOptionsObject.next->data); 3006356e834SBarry Smith break; 3016356e834SBarry Smith case OPTION_REAL_ARRAY: 3027a72a596SBarry Smith sprintf(value,"%g",(double)((PetscReal*)PetscOptionsObject.next->data)[0]); 3036356e834SBarry Smith for (j=1; j<PetscOptionsObject.next->arraylength; j++) { 3047a72a596SBarry Smith sprintf(tmp,"%g",(double)((PetscReal*)PetscOptionsObject.next->data)[j]); 3056356e834SBarry Smith ierr = PetscStrcat(value,",");CHKERRQ(ierr); 3066356e834SBarry Smith ierr = PetscStrcat(value,tmp);CHKERRQ(ierr); 3076356e834SBarry Smith } 3086356e834SBarry Smith break; 3096356e834SBarry Smith case OPTION_LOGICAL: 310aee2cecaSBarry Smith ierr = PetscStrcpy(value,(char*)PetscOptionsObject.next->data);CHKERRQ(ierr); 3116356e834SBarry Smith break; 3126356e834SBarry Smith case OPTION_LIST: 313aee2cecaSBarry Smith ierr = PetscStrcpy(value,(char*)PetscOptionsObject.next->data);CHKERRQ(ierr); 3146356e834SBarry Smith break; 3156356e834SBarry Smith case OPTION_STRING: /* also handles string arrays */ 316aee2cecaSBarry Smith ierr = PetscStrcpy(value,(char*)PetscOptionsObject.next->data);CHKERRQ(ierr); 3176356e834SBarry Smith break; 3186356e834SBarry Smith } 3196356e834SBarry Smith ierr = PetscOptionsSetValue(option,value);CHKERRQ(ierr); 3206356e834SBarry Smith } 3216356e834SBarry Smith ierr = PetscStrfree(PetscOptionsObject.next->text);CHKERRQ(ierr); 3226356e834SBarry Smith ierr = PetscStrfree(PetscOptionsObject.next->option);CHKERRQ(ierr); 3236356e834SBarry Smith ierr = PetscFree(PetscOptionsObject.next->man);CHKERRQ(ierr); 32405b42c5fSBarry Smith ierr = PetscFree(PetscOptionsObject.next->data);CHKERRQ(ierr); 32505b42c5fSBarry Smith ierr = PetscFree(PetscOptionsObject.next->edata);CHKERRQ(ierr); 3266356e834SBarry Smith last = PetscOptionsObject.next; 3276356e834SBarry Smith PetscOptionsObject.next = PetscOptionsObject.next->next; 3286356e834SBarry Smith ierr = PetscFree(last);CHKERRQ(ierr); 3296356e834SBarry Smith } 3306356e834SBarry Smith PetscOptionsObject.next = 0; 33153acd3b1SBarry Smith PetscFunctionReturn(0); 33253acd3b1SBarry Smith } 33353acd3b1SBarry Smith 33453acd3b1SBarry Smith #undef __FUNCT__ 33553acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsEnum" 33653acd3b1SBarry Smith /*@C 33753acd3b1SBarry Smith PetscOptionsEnum - Gets the enum value for a particular option in the database. 33853acd3b1SBarry Smith 33953acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 34053acd3b1SBarry Smith 34153acd3b1SBarry Smith Input Parameters: 34253acd3b1SBarry Smith + opt - option name 34353acd3b1SBarry Smith . text - short string that describes the option 34453acd3b1SBarry Smith . man - manual page with additional information on option 34553acd3b1SBarry Smith . list - array containing the list of choices, followed by the enum name, followed by the enum prefix, followed by a null 34653acd3b1SBarry Smith - defaultv - the default (current) value 34753acd3b1SBarry Smith 34853acd3b1SBarry Smith Output Parameter: 34953acd3b1SBarry Smith + value - the value to return 35053acd3b1SBarry Smith - flg - PETSC_TRUE if found, else PETSC_FALSE 35153acd3b1SBarry Smith 35253acd3b1SBarry Smith Level: beginner 35353acd3b1SBarry Smith 35453acd3b1SBarry Smith Concepts: options database 35553acd3b1SBarry Smith 35653acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 35753acd3b1SBarry Smith 35853acd3b1SBarry Smith list is usually something like PCASMTypes or some other predefined list of enum names 35953acd3b1SBarry Smith 36053acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 36153acd3b1SBarry Smith PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 36253acd3b1SBarry Smith PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 36353acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 36453acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 36553acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 36653acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 36753acd3b1SBarry Smith @*/ 36853acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsEnum(const char opt[],const char text[],const char man[],const char **list,PetscEnum defaultv,PetscEnum *value,PetscTruth *set) 36953acd3b1SBarry Smith { 37053acd3b1SBarry Smith PetscErrorCode ierr; 37153acd3b1SBarry Smith PetscInt ntext = 0; 372aa5bb8c0SSatish Balay PetscInt tval; 373aa5bb8c0SSatish Balay PetscTruth tflg; 37453acd3b1SBarry Smith 37553acd3b1SBarry Smith PetscFunctionBegin; 37653acd3b1SBarry Smith while (list[ntext++]) { 37753acd3b1SBarry Smith if (ntext > 50) SETERRQ(PETSC_ERR_ARG_WRONG,"List argument appears to be wrong or have more than 50 entries"); 37853acd3b1SBarry Smith } 37953acd3b1SBarry Smith if (ntext < 3) SETERRQ(PETSC_ERR_ARG_WRONG,"List argument must have at least two entries: typename and type prefix"); 38053acd3b1SBarry Smith ntext -= 3; 381aa5bb8c0SSatish Balay ierr = PetscOptionsEList(opt,text,man,list,ntext,list[defaultv],&tval,&tflg);CHKERRQ(ierr); 382aa5bb8c0SSatish Balay /* with PETSC_USE_64BIT_INDICES sizeof(PetscInt) != sizeof(PetscEnum) */ 383aa5bb8c0SSatish Balay if (tflg) *value = (PetscEnum)tval; 384aa5bb8c0SSatish Balay if (set) *set = tflg; 38553acd3b1SBarry Smith PetscFunctionReturn(0); 38653acd3b1SBarry Smith } 38753acd3b1SBarry Smith 38853acd3b1SBarry Smith /* -------------------------------------------------------------------------------------------------------------*/ 38953acd3b1SBarry Smith #undef __FUNCT__ 39053acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsInt" 39153acd3b1SBarry Smith /*@C 39253acd3b1SBarry Smith PetscOptionsInt - Gets the integer value for a particular option in the database. 39353acd3b1SBarry Smith 39453acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 39553acd3b1SBarry Smith 39653acd3b1SBarry Smith Input Parameters: 39753acd3b1SBarry Smith + opt - option name 39853acd3b1SBarry Smith . text - short string that describes the option 39953acd3b1SBarry Smith . man - manual page with additional information on option 40053acd3b1SBarry Smith - defaultv - the default (current) value 40153acd3b1SBarry Smith 40253acd3b1SBarry Smith Output Parameter: 40353acd3b1SBarry Smith + value - the integer value to return 40453acd3b1SBarry Smith - flg - PETSC_TRUE if found, else PETSC_FALSE 40553acd3b1SBarry Smith 40653acd3b1SBarry Smith Level: beginner 40753acd3b1SBarry Smith 40853acd3b1SBarry Smith Concepts: options database^has int 40953acd3b1SBarry Smith 41053acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 41153acd3b1SBarry Smith 41253acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 41353acd3b1SBarry Smith PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 41453acd3b1SBarry Smith PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 41553acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 41653acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 41753acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 41853acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 41953acd3b1SBarry Smith @*/ 42053acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsInt(const char opt[],const char text[],const char man[],PetscInt defaultv,PetscInt *value,PetscTruth *set) 42153acd3b1SBarry Smith { 42253acd3b1SBarry Smith PetscErrorCode ierr; 4236356e834SBarry Smith PetscOptions amsopt; 42453acd3b1SBarry Smith 42553acd3b1SBarry Smith PetscFunctionBegin; 426aee2cecaSBarry Smith if (PetscOptionsPublishCount == 0) { 4276356e834SBarry Smith ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_INT,&amsopt);CHKERRQ(ierr); 4286356e834SBarry Smith ierr = PetscMalloc(sizeof(PetscInt),&amsopt->data);CHKERRQ(ierr); 4296356e834SBarry Smith *(PetscInt*)amsopt->data = defaultv; 430*af6d86caSBarry Smith } 43153acd3b1SBarry Smith ierr = PetscOptionsGetInt(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr); 43261b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 43353acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%d>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,man);CHKERRQ(ierr); 43453acd3b1SBarry Smith } 43553acd3b1SBarry Smith PetscFunctionReturn(0); 43653acd3b1SBarry Smith } 43753acd3b1SBarry Smith 43853acd3b1SBarry Smith #undef __FUNCT__ 43953acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsString" 44053acd3b1SBarry Smith /*@C 44153acd3b1SBarry Smith PetscOptionsString - Gets the string value for a particular option in the database. 44253acd3b1SBarry Smith 44353acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 44453acd3b1SBarry Smith 44553acd3b1SBarry Smith Input Parameters: 44653acd3b1SBarry Smith + opt - option name 44753acd3b1SBarry Smith . text - short string that describes the option 44853acd3b1SBarry Smith . man - manual page with additional information on option 44953acd3b1SBarry Smith - defaultv - the default (current) value 45053acd3b1SBarry Smith 45153acd3b1SBarry Smith Output Parameter: 45253acd3b1SBarry Smith + value - the value to return 45353acd3b1SBarry Smith - flg - PETSC_TRUE if found, else PETSC_FALSE 45453acd3b1SBarry Smith 45553acd3b1SBarry Smith Level: beginner 45653acd3b1SBarry Smith 45753acd3b1SBarry Smith Concepts: options database^has int 45853acd3b1SBarry Smith 45953acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 46053acd3b1SBarry Smith 46153acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 46253acd3b1SBarry Smith PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 46353acd3b1SBarry Smith PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 46453acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 46553acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 46653acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 46753acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 46853acd3b1SBarry Smith @*/ 46953acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsString(const char opt[],const char text[],const char man[],const char defaultv[],char value[],size_t len,PetscTruth *set) 47053acd3b1SBarry Smith { 47153acd3b1SBarry Smith PetscErrorCode ierr; 472aee2cecaSBarry Smith PetscOptions amsopt; 47353acd3b1SBarry Smith 47453acd3b1SBarry Smith PetscFunctionBegin; 475aee2cecaSBarry Smith if (PetscOptionsPublishCount == 0) { 476aee2cecaSBarry Smith ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_STRING,&amsopt);CHKERRQ(ierr); 477aee2cecaSBarry Smith ierr = PetscMalloc(len*sizeof(char),&amsopt->data);CHKERRQ(ierr); 478aee2cecaSBarry Smith ierr = PetscStrcpy((char*)amsopt->data,defaultv);CHKERRQ(ierr); 479*af6d86caSBarry Smith } 48053acd3b1SBarry Smith ierr = PetscOptionsGetString(PetscOptionsObject.prefix,opt,value,len,set);CHKERRQ(ierr); 48161b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 48253acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%s>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,man);CHKERRQ(ierr); 48353acd3b1SBarry Smith } 48453acd3b1SBarry Smith PetscFunctionReturn(0); 48553acd3b1SBarry Smith } 48653acd3b1SBarry Smith 48753acd3b1SBarry Smith #undef __FUNCT__ 48853acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsReal" 48953acd3b1SBarry Smith /*@C 49053acd3b1SBarry Smith PetscOptionsReal - Gets the PetscReal value for a particular option in the database. 49153acd3b1SBarry Smith 49253acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 49353acd3b1SBarry Smith 49453acd3b1SBarry Smith Input Parameters: 49553acd3b1SBarry Smith + opt - option name 49653acd3b1SBarry Smith . text - short string that describes the option 49753acd3b1SBarry Smith . man - manual page with additional information on option 49853acd3b1SBarry Smith - defaultv - the default (current) value 49953acd3b1SBarry Smith 50053acd3b1SBarry Smith Output Parameter: 50153acd3b1SBarry Smith + value - the value to return 50253acd3b1SBarry Smith - flg - PETSC_TRUE if found, else PETSC_FALSE 50353acd3b1SBarry Smith 50453acd3b1SBarry Smith Level: beginner 50553acd3b1SBarry Smith 50653acd3b1SBarry Smith Concepts: options database^has int 50753acd3b1SBarry Smith 50853acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 50953acd3b1SBarry Smith 51053acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 51153acd3b1SBarry Smith PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 51253acd3b1SBarry Smith PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 51353acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 51453acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 51553acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 51653acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 51753acd3b1SBarry Smith @*/ 51853acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsReal(const char opt[],const char text[],const char man[],PetscReal defaultv,PetscReal *value,PetscTruth *set) 51953acd3b1SBarry Smith { 52053acd3b1SBarry Smith PetscErrorCode ierr; 52153acd3b1SBarry Smith 52253acd3b1SBarry Smith PetscFunctionBegin; 52353acd3b1SBarry Smith ierr = PetscOptionsGetReal(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr); 52461b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 525a83599f4SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%G>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,man);CHKERRQ(ierr); 52653acd3b1SBarry Smith } 52753acd3b1SBarry Smith PetscFunctionReturn(0); 52853acd3b1SBarry Smith } 52953acd3b1SBarry Smith 53053acd3b1SBarry Smith #undef __FUNCT__ 53153acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsScalar" 53253acd3b1SBarry Smith /*@C 53353acd3b1SBarry Smith PetscOptionsScalar - Gets the scalar value for a particular option in the database. 53453acd3b1SBarry Smith 53553acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 53653acd3b1SBarry Smith 53753acd3b1SBarry Smith Input Parameters: 53853acd3b1SBarry Smith + opt - option name 53953acd3b1SBarry Smith . text - short string that describes the option 54053acd3b1SBarry Smith . man - manual page with additional information on option 54153acd3b1SBarry Smith - defaultv - the default (current) value 54253acd3b1SBarry Smith 54353acd3b1SBarry Smith Output Parameter: 54453acd3b1SBarry Smith + value - the value to return 54553acd3b1SBarry Smith - flg - PETSC_TRUE if found, else PETSC_FALSE 54653acd3b1SBarry Smith 54753acd3b1SBarry Smith Level: beginner 54853acd3b1SBarry Smith 54953acd3b1SBarry Smith Concepts: options database^has int 55053acd3b1SBarry Smith 55153acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 55253acd3b1SBarry Smith 55353acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 55453acd3b1SBarry Smith PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 55553acd3b1SBarry Smith PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 55653acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 55753acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 55853acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 55953acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 56053acd3b1SBarry Smith @*/ 56153acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsScalar(const char opt[],const char text[],const char man[],PetscScalar defaultv,PetscScalar *value,PetscTruth *set) 56253acd3b1SBarry Smith { 56353acd3b1SBarry Smith PetscErrorCode ierr; 56453acd3b1SBarry Smith 56553acd3b1SBarry Smith PetscFunctionBegin; 56653acd3b1SBarry Smith #if !defined(PETSC_USE_COMPLEX) 56753acd3b1SBarry Smith ierr = PetscOptionsReal(opt,text,man,defaultv,value,set);CHKERRQ(ierr); 56853acd3b1SBarry Smith #else 56953acd3b1SBarry Smith ierr = PetscOptionsGetScalar(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr); 57053acd3b1SBarry Smith #endif 57153acd3b1SBarry Smith PetscFunctionReturn(0); 57253acd3b1SBarry Smith } 57353acd3b1SBarry Smith 57453acd3b1SBarry Smith #undef __FUNCT__ 57553acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsName" 57653acd3b1SBarry Smith /*@C 57790d69ab7SBarry 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 57890d69ab7SBarry Smith its value is set to false. 57953acd3b1SBarry Smith 58053acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 58153acd3b1SBarry Smith 58253acd3b1SBarry Smith Input Parameters: 58353acd3b1SBarry Smith + opt - option name 58453acd3b1SBarry Smith . text - short string that describes the option 58553acd3b1SBarry Smith - man - manual page with additional information on option 58653acd3b1SBarry Smith 58753acd3b1SBarry Smith Output Parameter: 58853acd3b1SBarry Smith . flg - PETSC_TRUE if found, else PETSC_FALSE 58953acd3b1SBarry Smith 59053acd3b1SBarry Smith Level: beginner 59153acd3b1SBarry Smith 59253acd3b1SBarry Smith Concepts: options database^has int 59353acd3b1SBarry Smith 59453acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 59553acd3b1SBarry Smith 59653acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 59753acd3b1SBarry Smith PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 59853acd3b1SBarry Smith PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 59953acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 60053acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 60153acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 60253acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 60353acd3b1SBarry Smith @*/ 60453acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsName(const char opt[],const char text[],const char man[],PetscTruth *flg) 60553acd3b1SBarry Smith { 60653acd3b1SBarry Smith PetscErrorCode ierr; 60753acd3b1SBarry Smith 60853acd3b1SBarry Smith PetscFunctionBegin; 60953acd3b1SBarry Smith ierr = PetscOptionsHasName(PetscOptionsObject.prefix,opt,flg);CHKERRQ(ierr); 61061b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 61153acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 61253acd3b1SBarry Smith } 61353acd3b1SBarry Smith PetscFunctionReturn(0); 61453acd3b1SBarry Smith } 61553acd3b1SBarry Smith 61653acd3b1SBarry Smith #undef __FUNCT__ 61753acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsList" 61853acd3b1SBarry Smith /*@C 61953acd3b1SBarry Smith PetscOptionsList - Puts a list of option values that a single one may be selected from 62053acd3b1SBarry Smith 62153acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 62253acd3b1SBarry Smith 62353acd3b1SBarry Smith Input Parameters: 62453acd3b1SBarry Smith + opt - option name 62553acd3b1SBarry Smith . text - short string that describes the option 62653acd3b1SBarry Smith . man - manual page with additional information on option 62753acd3b1SBarry Smith . list - the possible choices 62853acd3b1SBarry Smith - defaultv - the default (current) value 62953acd3b1SBarry Smith 63053acd3b1SBarry Smith Output Parameter: 63153acd3b1SBarry Smith + value - the value to return 63253acd3b1SBarry Smith - set - PETSC_TRUE if found, else PETSC_FALSE 63353acd3b1SBarry Smith 63453acd3b1SBarry Smith Level: intermediate 63553acd3b1SBarry Smith 63653acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 63753acd3b1SBarry Smith 63853acd3b1SBarry Smith See PetscOptionsEList() for when the choices are given in a string array 63953acd3b1SBarry Smith 64053acd3b1SBarry Smith To get a listing of all currently specified options, 64153acd3b1SBarry Smith see PetscOptionsPrint() or PetscOptionsGetAll() 64253acd3b1SBarry Smith 64353acd3b1SBarry Smith Concepts: options database^list 64453acd3b1SBarry Smith 64553acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 64653acd3b1SBarry Smith PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 64753acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 64853acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 64953acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 65053acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 65153acd3b1SBarry Smith @*/ 65253acd3b1SBarry 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) 65353acd3b1SBarry Smith { 65453acd3b1SBarry Smith PetscErrorCode ierr; 65553acd3b1SBarry Smith 65653acd3b1SBarry Smith PetscFunctionBegin; 65753acd3b1SBarry Smith ierr = PetscOptionsGetString(PetscOptionsObject.prefix,opt,value,len,set);CHKERRQ(ierr); 65861b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 6591d280d73SBarry Smith ierr = PetscFListPrintTypes(list,PetscOptionsObject.comm,stdout,PetscOptionsObject.prefix,opt,ltext,man);CHKERRQ(ierr);CHKERRQ(ierr); 66053acd3b1SBarry Smith } 66153acd3b1SBarry Smith PetscFunctionReturn(0); 66253acd3b1SBarry Smith } 66353acd3b1SBarry Smith 66453acd3b1SBarry Smith #undef __FUNCT__ 66553acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsEList" 66653acd3b1SBarry Smith /*@C 66753acd3b1SBarry Smith PetscOptionsEList - Puts a list of option values that a single one may be selected from 66853acd3b1SBarry Smith 66953acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 67053acd3b1SBarry Smith 67153acd3b1SBarry Smith Input Parameters: 67253acd3b1SBarry Smith + opt - option name 67353acd3b1SBarry Smith . ltext - short string that describes the option 67453acd3b1SBarry Smith . man - manual page with additional information on option 67553acd3b1SBarry Smith . list - the possible choices 67653acd3b1SBarry Smith . ntext - number of choices 67753acd3b1SBarry Smith - defaultv - the default (current) value 67853acd3b1SBarry Smith 67953acd3b1SBarry Smith Output Parameter: 68053acd3b1SBarry Smith + value - the index of the value to return 68153acd3b1SBarry Smith - set - PETSC_TRUE if found, else PETSC_FALSE 68253acd3b1SBarry Smith 68353acd3b1SBarry Smith Level: intermediate 68453acd3b1SBarry Smith 68553acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 68653acd3b1SBarry Smith 68753acd3b1SBarry Smith See PetscOptionsList() for when the choices are given in a PetscFList() 68853acd3b1SBarry Smith 68953acd3b1SBarry Smith Concepts: options database^list 69053acd3b1SBarry Smith 69153acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 69253acd3b1SBarry Smith PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 69353acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 69453acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 69553acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 69653acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 69753acd3b1SBarry Smith @*/ 69853acd3b1SBarry 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) 69953acd3b1SBarry Smith { 70053acd3b1SBarry Smith PetscErrorCode ierr; 70153acd3b1SBarry Smith PetscInt i; 70253acd3b1SBarry Smith 70353acd3b1SBarry Smith PetscFunctionBegin; 70453acd3b1SBarry Smith ierr = PetscOptionsGetEList(PetscOptionsObject.prefix,opt,list,ntext,value,set);CHKERRQ(ierr); 70561b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 70653acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%s> (choose one of)",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv);CHKERRQ(ierr); 70753acd3b1SBarry Smith for (i=0; i<ntext; i++){ 70853acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," %s",list[i]);CHKERRQ(ierr); 70953acd3b1SBarry Smith } 71053acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"\n");CHKERRQ(ierr); 71153acd3b1SBarry Smith } 71253acd3b1SBarry Smith PetscFunctionReturn(0); 71353acd3b1SBarry Smith } 71453acd3b1SBarry Smith 71553acd3b1SBarry Smith #undef __FUNCT__ 71653acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsTruthGroupBegin" 71753acd3b1SBarry Smith /*@C 71853acd3b1SBarry Smith PetscOptionsTruthGroupBegin - First in a series of logical queries on the options database for 71953acd3b1SBarry Smith which only a single value can be true. 72053acd3b1SBarry Smith 72153acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 72253acd3b1SBarry Smith 72353acd3b1SBarry Smith Input Parameters: 72453acd3b1SBarry Smith + opt - option name 72553acd3b1SBarry Smith . text - short string that describes the option 72653acd3b1SBarry Smith - man - manual page with additional information on option 72753acd3b1SBarry Smith 72853acd3b1SBarry Smith Output Parameter: 72953acd3b1SBarry Smith . flg - whether that option was set or not 73053acd3b1SBarry Smith 73153acd3b1SBarry Smith Level: intermediate 73253acd3b1SBarry Smith 73353acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 73453acd3b1SBarry Smith 73553acd3b1SBarry Smith Must be followed by 0 or more PetscOptionsTruthGroup()s and PetscOptionsTruthGroupEnd() 73653acd3b1SBarry Smith 73753acd3b1SBarry Smith Concepts: options database^logical group 73853acd3b1SBarry Smith 73953acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 74053acd3b1SBarry Smith PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 74153acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 74253acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 74353acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 74453acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 74553acd3b1SBarry Smith @*/ 74653acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroupBegin(const char opt[],const char text[],const char man[],PetscTruth *flg) 74753acd3b1SBarry Smith { 74853acd3b1SBarry Smith PetscErrorCode ierr; 74953acd3b1SBarry Smith 75053acd3b1SBarry Smith PetscFunctionBegin; 75117326d04SJed Brown *flg = PETSC_FALSE; 75217326d04SJed Brown ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,PETSC_NULL);CHKERRQ(ierr); 75361b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 75453acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," Pick at most one of -------------\n");CHKERRQ(ierr); 75553acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 75653acd3b1SBarry Smith } 75753acd3b1SBarry Smith PetscFunctionReturn(0); 75853acd3b1SBarry Smith } 75953acd3b1SBarry Smith 76053acd3b1SBarry Smith #undef __FUNCT__ 76153acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsTruthGroup" 76253acd3b1SBarry Smith /*@C 76353acd3b1SBarry Smith PetscOptionsTruthGroup - One in a series of logical queries on the options database for 76453acd3b1SBarry Smith which only a single value can be true. 76553acd3b1SBarry Smith 76653acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 76753acd3b1SBarry Smith 76853acd3b1SBarry Smith Input Parameters: 76953acd3b1SBarry Smith + opt - option name 77053acd3b1SBarry Smith . text - short string that describes the option 77153acd3b1SBarry Smith - man - manual page with additional information on option 77253acd3b1SBarry Smith 77353acd3b1SBarry Smith Output Parameter: 77453acd3b1SBarry Smith . flg - PETSC_TRUE if found, else PETSC_FALSE 77553acd3b1SBarry Smith 77653acd3b1SBarry Smith Level: intermediate 77753acd3b1SBarry Smith 77853acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 77953acd3b1SBarry Smith 78053acd3b1SBarry Smith Must follow a PetscOptionsTruthGroupBegin() and preceded a PetscOptionsTruthGroupEnd() 78153acd3b1SBarry Smith 78253acd3b1SBarry Smith Concepts: options database^logical group 78353acd3b1SBarry Smith 78453acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 78553acd3b1SBarry Smith PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 78653acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 78753acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 78853acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 78953acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 79053acd3b1SBarry Smith @*/ 79153acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroup(const char opt[],const char text[],const char man[],PetscTruth *flg) 79253acd3b1SBarry Smith { 79353acd3b1SBarry Smith PetscErrorCode ierr; 79453acd3b1SBarry Smith 79553acd3b1SBarry Smith PetscFunctionBegin; 79617326d04SJed Brown *flg = PETSC_FALSE; 79717326d04SJed Brown ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,PETSC_NULL);CHKERRQ(ierr); 79861b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 79953acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 80053acd3b1SBarry Smith } 80153acd3b1SBarry Smith PetscFunctionReturn(0); 80253acd3b1SBarry Smith } 80353acd3b1SBarry Smith 80453acd3b1SBarry Smith #undef __FUNCT__ 80553acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsTruthGroupEnd" 80653acd3b1SBarry Smith /*@C 80753acd3b1SBarry Smith PetscOptionsTruthGroupEnd - Last in a series of logical queries on the options database for 80853acd3b1SBarry Smith which only a single value can be true. 80953acd3b1SBarry Smith 81053acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 81153acd3b1SBarry Smith 81253acd3b1SBarry Smith Input Parameters: 81353acd3b1SBarry Smith + opt - option name 81453acd3b1SBarry Smith . text - short string that describes the option 81553acd3b1SBarry Smith - man - manual page with additional information on option 81653acd3b1SBarry Smith 81753acd3b1SBarry Smith Output Parameter: 81853acd3b1SBarry Smith . flg - PETSC_TRUE if found, else PETSC_FALSE 81953acd3b1SBarry Smith 82053acd3b1SBarry Smith Level: intermediate 82153acd3b1SBarry Smith 82253acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 82353acd3b1SBarry Smith 82453acd3b1SBarry Smith Must follow a PetscOptionsTruthGroupBegin() 82553acd3b1SBarry Smith 82653acd3b1SBarry Smith Concepts: options database^logical group 82753acd3b1SBarry Smith 82853acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 82953acd3b1SBarry Smith PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 83053acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 83153acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 83253acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 83353acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 83453acd3b1SBarry Smith @*/ 83553acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroupEnd(const char opt[],const char text[],const char man[],PetscTruth *flg) 83653acd3b1SBarry Smith { 83753acd3b1SBarry Smith PetscErrorCode ierr; 83853acd3b1SBarry Smith 83953acd3b1SBarry Smith PetscFunctionBegin; 84017326d04SJed Brown *flg = PETSC_FALSE; 84117326d04SJed Brown ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,PETSC_NULL);CHKERRQ(ierr); 84261b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 84353acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 84453acd3b1SBarry Smith } 84553acd3b1SBarry Smith PetscFunctionReturn(0); 84653acd3b1SBarry Smith } 84753acd3b1SBarry Smith 84853acd3b1SBarry Smith #undef __FUNCT__ 84953acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsTruth" 85053acd3b1SBarry Smith /*@C 85153acd3b1SBarry Smith PetscOptionsTruth - Determines if a particular option is in the database with a true or false 85253acd3b1SBarry Smith 85353acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 85453acd3b1SBarry Smith 85553acd3b1SBarry Smith Input Parameters: 85653acd3b1SBarry Smith + opt - option name 85753acd3b1SBarry Smith . text - short string that describes the option 85853acd3b1SBarry Smith - man - manual page with additional information on option 85953acd3b1SBarry Smith 86053acd3b1SBarry Smith Output Parameter: 86153acd3b1SBarry Smith . flg - PETSC_TRUE or PETSC_FALSE 86253acd3b1SBarry Smith . set - PETSC_TRUE if found, else PETSC_FALSE 86353acd3b1SBarry Smith 86453acd3b1SBarry Smith Level: beginner 86553acd3b1SBarry Smith 86653acd3b1SBarry Smith Concepts: options database^logical 86753acd3b1SBarry Smith 86853acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 86953acd3b1SBarry Smith 87053acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 87153acd3b1SBarry Smith PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 87253acd3b1SBarry Smith PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 87353acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 87453acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 87553acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 87653acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 87753acd3b1SBarry Smith @*/ 87853acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruth(const char opt[],const char text[],const char man[],PetscTruth deflt,PetscTruth *flg,PetscTruth *set) 87953acd3b1SBarry Smith { 88053acd3b1SBarry Smith PetscErrorCode ierr; 88153acd3b1SBarry Smith PetscTruth iset; 882aee2cecaSBarry Smith PetscOptions amsopt; 88353acd3b1SBarry Smith 88453acd3b1SBarry Smith PetscFunctionBegin; 885aee2cecaSBarry Smith if (PetscOptionsPublishCount == 0) { 886aee2cecaSBarry Smith ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL,&amsopt);CHKERRQ(ierr); 887aee2cecaSBarry Smith ierr = PetscMalloc(16*sizeof(char),&amsopt->data);CHKERRQ(ierr); 888aee2cecaSBarry Smith ierr = PetscStrcpy((char*)amsopt->data,deflt ? "true" : "false");CHKERRQ(ierr); 889*af6d86caSBarry Smith } 89053acd3b1SBarry Smith ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,&iset);CHKERRQ(ierr); 89153acd3b1SBarry Smith if (!iset) { 89253acd3b1SBarry Smith if (flg) *flg = deflt; 89353acd3b1SBarry Smith } 89453acd3b1SBarry Smith if (set) *set = iset; 89561b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 89653acd3b1SBarry Smith const char *v = PetscTruths[deflt]; 89753acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: <%s> %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,v,text,man);CHKERRQ(ierr); 89853acd3b1SBarry Smith } 89953acd3b1SBarry Smith PetscFunctionReturn(0); 90053acd3b1SBarry Smith } 90153acd3b1SBarry Smith 90253acd3b1SBarry Smith #undef __FUNCT__ 90353acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsRealArray" 90453acd3b1SBarry Smith /*@C 90553acd3b1SBarry Smith PetscOptionsRealArray - Gets an array of double values for a particular 90653acd3b1SBarry Smith option in the database. The values must be separated with commas with 90753acd3b1SBarry Smith no intervening spaces. 90853acd3b1SBarry Smith 90953acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 91053acd3b1SBarry Smith 91153acd3b1SBarry Smith Input Parameters: 91253acd3b1SBarry Smith + opt - the option one is seeking 91353acd3b1SBarry Smith . text - short string describing option 91453acd3b1SBarry Smith . man - manual page for option 91553acd3b1SBarry Smith - nmax - maximum number of values 91653acd3b1SBarry Smith 91753acd3b1SBarry Smith Output Parameter: 91853acd3b1SBarry Smith + value - location to copy values 91953acd3b1SBarry Smith . nmax - actual number of values found 92053acd3b1SBarry Smith - set - PETSC_TRUE if found, else PETSC_FALSE 92153acd3b1SBarry Smith 92253acd3b1SBarry Smith Level: beginner 92353acd3b1SBarry Smith 92453acd3b1SBarry Smith Notes: 92553acd3b1SBarry Smith The user should pass in an array of doubles 92653acd3b1SBarry Smith 92753acd3b1SBarry Smith Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 92853acd3b1SBarry Smith 92953acd3b1SBarry Smith Concepts: options database^array of strings 93053acd3b1SBarry Smith 93153acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 93253acd3b1SBarry Smith PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 93353acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 93453acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 93553acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 93653acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 93753acd3b1SBarry Smith @*/ 93853acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsRealArray(const char opt[],const char text[],const char man[],PetscReal value[],PetscInt *n,PetscTruth *set) 93953acd3b1SBarry Smith { 94053acd3b1SBarry Smith PetscErrorCode ierr; 94153acd3b1SBarry Smith PetscInt i; 94253acd3b1SBarry Smith 94353acd3b1SBarry Smith PetscFunctionBegin; 94453acd3b1SBarry Smith ierr = PetscOptionsGetRealArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr); 94561b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 946a83599f4SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%G",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr); 94753acd3b1SBarry Smith for (i=1; i<*n; i++) { 948a83599f4SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%G",value[i]);CHKERRQ(ierr); 94953acd3b1SBarry Smith } 95053acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr); 95153acd3b1SBarry Smith } 95253acd3b1SBarry Smith PetscFunctionReturn(0); 95353acd3b1SBarry Smith } 95453acd3b1SBarry Smith 95553acd3b1SBarry Smith 95653acd3b1SBarry Smith #undef __FUNCT__ 95753acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsIntArray" 95853acd3b1SBarry Smith /*@C 95953acd3b1SBarry Smith PetscOptionsIntArray - Gets an array of integers for a particular 96053acd3b1SBarry Smith option in the database. The values must be separated with commas with 96153acd3b1SBarry Smith no intervening spaces. 96253acd3b1SBarry Smith 96353acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 96453acd3b1SBarry Smith 96553acd3b1SBarry Smith Input Parameters: 96653acd3b1SBarry Smith + opt - the option one is seeking 96753acd3b1SBarry Smith . text - short string describing option 96853acd3b1SBarry Smith . man - manual page for option 969f8a50e2bSBarry Smith - n - maximum number of values 97053acd3b1SBarry Smith 97153acd3b1SBarry Smith Output Parameter: 97253acd3b1SBarry Smith + value - location to copy values 973f8a50e2bSBarry Smith . n - actual number of values found 97453acd3b1SBarry Smith - set - PETSC_TRUE if found, else PETSC_FALSE 97553acd3b1SBarry Smith 97653acd3b1SBarry Smith Level: beginner 97753acd3b1SBarry Smith 97853acd3b1SBarry Smith Notes: 97953acd3b1SBarry Smith The user should pass in an array of integers 98053acd3b1SBarry Smith 98153acd3b1SBarry Smith Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 98253acd3b1SBarry Smith 98353acd3b1SBarry Smith Concepts: options database^array of strings 98453acd3b1SBarry Smith 98553acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 98653acd3b1SBarry Smith PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 98753acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 98853acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 98953acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 99053acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList(), PetscOptionsRealArray() 99153acd3b1SBarry Smith @*/ 99253acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsIntArray(const char opt[],const char text[],const char man[],PetscInt value[],PetscInt *n,PetscTruth *set) 99353acd3b1SBarry Smith { 99453acd3b1SBarry Smith PetscErrorCode ierr; 99553acd3b1SBarry Smith PetscInt i; 99653acd3b1SBarry Smith 99753acd3b1SBarry Smith PetscFunctionBegin; 99853acd3b1SBarry Smith ierr = PetscOptionsGetIntArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr); 99961b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 100053acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%d",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr); 100153acd3b1SBarry Smith for (i=1; i<*n; i++) { 100253acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%d",value[i]);CHKERRQ(ierr); 100353acd3b1SBarry Smith } 100453acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr); 100553acd3b1SBarry Smith } 100653acd3b1SBarry Smith PetscFunctionReturn(0); 100753acd3b1SBarry Smith } 100853acd3b1SBarry Smith 100953acd3b1SBarry Smith #undef __FUNCT__ 101053acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsStringArray" 101153acd3b1SBarry Smith /*@C 101253acd3b1SBarry Smith PetscOptionsStringArray - Gets an array of string values for a particular 101353acd3b1SBarry Smith option in the database. The values must be separated with commas with 101453acd3b1SBarry Smith no intervening spaces. 101553acd3b1SBarry Smith 101653acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 101753acd3b1SBarry Smith 101853acd3b1SBarry Smith Input Parameters: 101953acd3b1SBarry Smith + opt - the option one is seeking 102053acd3b1SBarry Smith . text - short string describing option 102153acd3b1SBarry Smith . man - manual page for option 102253acd3b1SBarry Smith - nmax - maximum number of strings 102353acd3b1SBarry Smith 102453acd3b1SBarry Smith Output Parameter: 102553acd3b1SBarry Smith + value - location to copy strings 102653acd3b1SBarry Smith . nmax - actual number of strings found 102753acd3b1SBarry Smith - set - PETSC_TRUE if found, else PETSC_FALSE 102853acd3b1SBarry Smith 102953acd3b1SBarry Smith Level: beginner 103053acd3b1SBarry Smith 103153acd3b1SBarry Smith Notes: 103253acd3b1SBarry Smith The user should pass in an array of pointers to char, to hold all the 103353acd3b1SBarry Smith strings returned by this function. 103453acd3b1SBarry Smith 103553acd3b1SBarry Smith The user is responsible for deallocating the strings that are 103653acd3b1SBarry Smith returned. The Fortran interface for this routine is not supported. 103753acd3b1SBarry Smith 103853acd3b1SBarry Smith Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 103953acd3b1SBarry Smith 104053acd3b1SBarry Smith Concepts: options database^array of strings 104153acd3b1SBarry Smith 104253acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 104353acd3b1SBarry Smith PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 104453acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 104553acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 104653acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 104753acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 104853acd3b1SBarry Smith @*/ 104953acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsStringArray(const char opt[],const char text[],const char man[],char *value[],PetscInt *nmax,PetscTruth *set) 105053acd3b1SBarry Smith { 105153acd3b1SBarry Smith PetscErrorCode ierr; 105253acd3b1SBarry Smith 105353acd3b1SBarry Smith PetscFunctionBegin; 105453acd3b1SBarry Smith ierr = PetscOptionsGetStringArray(PetscOptionsObject.prefix,opt,value,nmax,set);CHKERRQ(ierr); 105561b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 105653acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <string1,string2,...>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr); 105753acd3b1SBarry Smith } 105853acd3b1SBarry Smith PetscFunctionReturn(0); 105953acd3b1SBarry Smith } 106053acd3b1SBarry Smith 1061e2446a98SMatthew Knepley #undef __FUNCT__ 1062e2446a98SMatthew Knepley #define __FUNCT__ "PetscOptionsTruthArray" 1063e2446a98SMatthew Knepley /*@C 1064e2446a98SMatthew Knepley PetscOptionsTruthArray - Gets an array of logical values (true or false) for a particular 1065e2446a98SMatthew Knepley option in the database. The values must be separated with commas with 1066e2446a98SMatthew Knepley no intervening spaces. 1067e2446a98SMatthew Knepley 1068e2446a98SMatthew Knepley Collective on the communicator passed in PetscOptionsBegin() 1069e2446a98SMatthew Knepley 1070e2446a98SMatthew Knepley Input Parameters: 1071e2446a98SMatthew Knepley + opt - the option one is seeking 1072e2446a98SMatthew Knepley . text - short string describing option 1073e2446a98SMatthew Knepley . man - manual page for option 1074e2446a98SMatthew Knepley - nmax - maximum number of values 1075e2446a98SMatthew Knepley 1076e2446a98SMatthew Knepley Output Parameter: 1077e2446a98SMatthew Knepley + value - location to copy values 1078e2446a98SMatthew Knepley . nmax - actual number of values found 1079e2446a98SMatthew Knepley - set - PETSC_TRUE if found, else PETSC_FALSE 1080e2446a98SMatthew Knepley 1081e2446a98SMatthew Knepley Level: beginner 1082e2446a98SMatthew Knepley 1083e2446a98SMatthew Knepley Notes: 1084e2446a98SMatthew Knepley The user should pass in an array of doubles 1085e2446a98SMatthew Knepley 1086e2446a98SMatthew Knepley Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 1087e2446a98SMatthew Knepley 1088e2446a98SMatthew Knepley Concepts: options database^array of strings 1089e2446a98SMatthew Knepley 1090e2446a98SMatthew Knepley .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1091e2446a98SMatthew Knepley PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 1092e2446a98SMatthew Knepley PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 1093e2446a98SMatthew Knepley PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1094e2446a98SMatthew Knepley PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 1095e2446a98SMatthew Knepley PetscOptionsList(), PetscOptionsEList() 1096e2446a98SMatthew Knepley @*/ 1097e2446a98SMatthew Knepley PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthArray(const char opt[],const char text[],const char man[],PetscTruth value[],PetscInt *n,PetscTruth *set) 1098e2446a98SMatthew Knepley { 1099e2446a98SMatthew Knepley PetscErrorCode ierr; 1100e2446a98SMatthew Knepley PetscInt i; 1101e2446a98SMatthew Knepley 1102e2446a98SMatthew Knepley PetscFunctionBegin; 1103e2446a98SMatthew Knepley ierr = PetscOptionsGetTruthArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr); 1104e2446a98SMatthew Knepley if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 1105e2446a98SMatthew Knepley ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%d",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr); 1106e2446a98SMatthew Knepley for (i=1; i<*n; i++) { 1107e2446a98SMatthew Knepley ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%d",value[i]);CHKERRQ(ierr); 1108e2446a98SMatthew Knepley } 1109e2446a98SMatthew Knepley ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr); 1110e2446a98SMatthew Knepley } 1111e2446a98SMatthew Knepley PetscFunctionReturn(0); 1112e2446a98SMatthew Knepley } 1113e2446a98SMatthew Knepley 111453acd3b1SBarry Smith 111553acd3b1SBarry Smith #undef __FUNCT__ 111653acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsHead" 111753acd3b1SBarry Smith /*@C 1118b52f573bSBarry Smith PetscOptionsHead - Puts a heading before listing any more published options. Used, for example, 111953acd3b1SBarry Smith in KSPSetFromOptions_GMRES(). 112053acd3b1SBarry Smith 112153acd3b1SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 112253acd3b1SBarry Smith 112353acd3b1SBarry Smith Input Parameter: 112453acd3b1SBarry Smith . head - the heading text 112553acd3b1SBarry Smith 112653acd3b1SBarry Smith 112753acd3b1SBarry Smith Level: intermediate 112853acd3b1SBarry Smith 112953acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 113053acd3b1SBarry Smith 1131b52f573bSBarry Smith Can be followed by a call to PetscOptionsTail() in the same function. 113253acd3b1SBarry Smith 113353acd3b1SBarry Smith Concepts: options database^subheading 113453acd3b1SBarry Smith 113553acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 113653acd3b1SBarry Smith PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 113753acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 113853acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 113953acd3b1SBarry Smith PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 114053acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 114153acd3b1SBarry Smith @*/ 114253acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsHead(const char head[]) 114353acd3b1SBarry Smith { 114453acd3b1SBarry Smith PetscErrorCode ierr; 114553acd3b1SBarry Smith 114653acd3b1SBarry Smith PetscFunctionBegin; 114761b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 114853acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," %s\n",head);CHKERRQ(ierr); 114953acd3b1SBarry Smith } 115053acd3b1SBarry Smith PetscFunctionReturn(0); 115153acd3b1SBarry Smith } 115253acd3b1SBarry Smith 115353acd3b1SBarry Smith 115453acd3b1SBarry Smith 115553acd3b1SBarry Smith 115653acd3b1SBarry Smith 115753acd3b1SBarry Smith 1158