xref: /petsc/src/sys/objects/aoptions.c (revision aee2cecaeefd3e72544fa4788195f0bfc8b09c13)
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__
165*aee2cecaSBarry Smith #define __FUNCT__ "PetscScanString"
166*aee2cecaSBarry Smith /*
167*aee2cecaSBarry Smith     PetscScanString -
168*aee2cecaSBarry Smith 
169*aee2cecaSBarry Smith     Bugs:
170*aee2cecaSBarry Smith .   Assumes process 0 of the given communicator has access to stdin
171*aee2cecaSBarry Smith 
172*aee2cecaSBarry Smith */
173*aee2cecaSBarry Smith static PetscErrorCode PetscScanString(MPI_Comm comm,PetscInt n,char str[],PetscTruth *set)
174*aee2cecaSBarry Smith {
175*aee2cecaSBarry Smith   PetscInt       i;
176*aee2cecaSBarry Smith   char           c;
177*aee2cecaSBarry Smith   PetscMPIInt    rank;
178*aee2cecaSBarry Smith   PetscErrorCode ierr;
179*aee2cecaSBarry Smith 
180*aee2cecaSBarry Smith   PetscFunctionBegin;
181*aee2cecaSBarry Smith   ierr = MPI_Comm_rank(comm,&rank);CHKERRQ(ierr);
182*aee2cecaSBarry Smith   if (!rank) {
183*aee2cecaSBarry Smith     c = (char) getchar();
184*aee2cecaSBarry Smith     i = 0;
185*aee2cecaSBarry Smith     while ( c != '\n' && i < n-1) {
186*aee2cecaSBarry Smith       str[i++] = c;
187*aee2cecaSBarry Smith       c = (char) getchar();
188*aee2cecaSBarry Smith     }
189*aee2cecaSBarry Smith     str[i] = 0;
190*aee2cecaSBarry Smith   }
191*aee2cecaSBarry Smith   ierr = MPI_Bcast(str,n,MPI_CHAR,0,comm);CHKERRQ(ierr);
192*aee2cecaSBarry Smith   if (str[0]) *set = PETSC_TRUE; else *set = PETSC_FALSE;
193*aee2cecaSBarry Smith   PetscFunctionReturn(0);
194*aee2cecaSBarry Smith }
195*aee2cecaSBarry Smith 
196*aee2cecaSBarry Smith #undef __FUNCT__
197*aee2cecaSBarry Smith #define __FUNCT__ "PetscOptionsGetFromTextInput"
198*aee2cecaSBarry Smith /*
199*aee2cecaSBarry Smith     PetscOptionsGetFromTextInput
200*aee2cecaSBarry Smith 
201*aee2cecaSBarry Smith     Notes: this isn't really practical, it is just to demonstrate the principle
202*aee2cecaSBarry Smith 
203*aee2cecaSBarry Smith     Bugs:
204*aee2cecaSBarry Smith +    All processes must traverse through the exact same set of option queries do to the call to PetscScanString()
205*aee2cecaSBarry Smith -    Only works for PetscInt == int, PetscReal == double etc
206*aee2cecaSBarry Smith 
207*aee2cecaSBarry Smith */
208*aee2cecaSBarry Smith PetscErrorCode PetscOptionsGetFromTextInput()
2096356e834SBarry Smith {
2106356e834SBarry Smith   PetscErrorCode ierr;
2116356e834SBarry Smith   PetscOptions   next = PetscOptionsObject.next;
2126356e834SBarry Smith   char           str[512];
213*aee2cecaSBarry Smith   int            id;
214*aee2cecaSBarry Smith   PetscTruth     set;
215*aee2cecaSBarry 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*aee2cecaSBarry Smith         ierr = PetscPrintf(PetscOptionsObject.comm,"-%s%s <%d>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",next->option+1,*(int*)next->data,next->text,next->man);CHKERRQ(ierr);
224*aee2cecaSBarry Smith         ierr = PetscScanString(PETSC_COMM_WORLD,512,str,&set);CHKERRQ(ierr);
225*aee2cecaSBarry Smith         if (set) {
226*aee2cecaSBarry Smith            sscanf(str,"%d",&id);
227*aee2cecaSBarry Smith            next->set = PETSC_TRUE;
228*aee2cecaSBarry Smith            *((PetscInt*)next->data) = id;
229*aee2cecaSBarry Smith         }
230*aee2cecaSBarry Smith         break;
231*aee2cecaSBarry Smith       case OPTION_REAL:
232*aee2cecaSBarry Smith         ierr = PetscPrintf(PetscOptionsObject.comm,"-%s%s <%g>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",next->option+1,*(double*)next->data,next->text,next->man);CHKERRQ(ierr);
233*aee2cecaSBarry Smith         ierr = PetscScanString(PETSC_COMM_WORLD,512,str,&set);CHKERRQ(ierr);
234*aee2cecaSBarry Smith         if (set) {
235*aee2cecaSBarry Smith            sscanf(str,"%le",&ir);
236*aee2cecaSBarry Smith            next->set = PETSC_TRUE;
237*aee2cecaSBarry Smith            *((PetscReal*)next->data) = ir;
238*aee2cecaSBarry Smith         }
239*aee2cecaSBarry Smith         break;
240*aee2cecaSBarry Smith       case OPTION_LOGICAL:
241*aee2cecaSBarry Smith       case OPTION_STRING:
242*aee2cecaSBarry Smith         ierr = PetscPrintf(PetscOptionsObject.comm,"-%s%s <%s>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",next->option+1,(char*)next->data,next->text,next->man);CHKERRQ(ierr);
243*aee2cecaSBarry Smith         ierr = PetscScanString(PETSC_COMM_WORLD,512,str,&set);CHKERRQ(ierr);
244*aee2cecaSBarry Smith         if (set) {
245*aee2cecaSBarry Smith            next->set = PETSC_TRUE;
246*aee2cecaSBarry 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 
268*aee2cecaSBarry Smith   if (PetscOptionsObject.next) {
269*aee2cecaSBarry Smith     if (PetscOptionsPublishCount == 0) {
270*aee2cecaSBarry Smith       ierr = PetscOptionsGetFromTextInput();
271*aee2cecaSBarry Smith     }
272*aee2cecaSBarry 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:
310*aee2cecaSBarry Smith           ierr = PetscStrcpy(value,(char*)PetscOptionsObject.next->data);CHKERRQ(ierr);
3116356e834SBarry Smith           break;
3126356e834SBarry Smith         case OPTION_LIST:
313*aee2cecaSBarry Smith           ierr = PetscStrcpy(value,(char*)PetscOptionsObject.next->data);CHKERRQ(ierr);
3146356e834SBarry Smith           break;
3156356e834SBarry Smith         case OPTION_STRING: /* also handles string arrays */
316*aee2cecaSBarry 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;
426*aee2cecaSBarry 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*aee2cecaSBarry Smith   } else {
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     }
435*aee2cecaSBarry Smith   }
43653acd3b1SBarry Smith   PetscFunctionReturn(0);
43753acd3b1SBarry Smith }
43853acd3b1SBarry Smith 
43953acd3b1SBarry Smith #undef __FUNCT__
44053acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsString"
44153acd3b1SBarry Smith /*@C
44253acd3b1SBarry Smith    PetscOptionsString - Gets the string value for a particular option in the database.
44353acd3b1SBarry Smith 
44453acd3b1SBarry Smith    Collective on the communicator passed in PetscOptionsBegin()
44553acd3b1SBarry Smith 
44653acd3b1SBarry Smith    Input Parameters:
44753acd3b1SBarry Smith +  opt - option name
44853acd3b1SBarry Smith .  text - short string that describes the option
44953acd3b1SBarry Smith .  man - manual page with additional information on option
45053acd3b1SBarry Smith -  defaultv - the default (current) value
45153acd3b1SBarry Smith 
45253acd3b1SBarry Smith    Output Parameter:
45353acd3b1SBarry Smith +  value - the value to return
45453acd3b1SBarry Smith -  flg - PETSC_TRUE if found, else PETSC_FALSE
45553acd3b1SBarry Smith 
45653acd3b1SBarry Smith    Level: beginner
45753acd3b1SBarry Smith 
45853acd3b1SBarry Smith    Concepts: options database^has int
45953acd3b1SBarry Smith 
46053acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
46153acd3b1SBarry Smith 
46253acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
46353acd3b1SBarry Smith           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth()
46453acd3b1SBarry Smith           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(),
46553acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
46653acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
46753acd3b1SBarry Smith           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
46853acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
46953acd3b1SBarry Smith @*/
47053acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsString(const char opt[],const char text[],const char man[],const char defaultv[],char value[],size_t len,PetscTruth *set)
47153acd3b1SBarry Smith {
47253acd3b1SBarry Smith   PetscErrorCode ierr;
473*aee2cecaSBarry Smith   PetscOptions   amsopt;
47453acd3b1SBarry Smith 
47553acd3b1SBarry Smith   PetscFunctionBegin;
476*aee2cecaSBarry Smith   if (PetscOptionsPublishCount == 0) {
477*aee2cecaSBarry Smith     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_STRING,&amsopt);CHKERRQ(ierr);
478*aee2cecaSBarry Smith     ierr = PetscMalloc(len*sizeof(char),&amsopt->data);CHKERRQ(ierr);
479*aee2cecaSBarry Smith     ierr = PetscStrcpy((char*)amsopt->data,defaultv);CHKERRQ(ierr);
480*aee2cecaSBarry Smith   } else {
48153acd3b1SBarry Smith     ierr = PetscOptionsGetString(PetscOptionsObject.prefix,opt,value,len,set);CHKERRQ(ierr);
48261b37b28SSatish Balay     if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
48353acd3b1SBarry Smith       ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%s>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,man);CHKERRQ(ierr);
48453acd3b1SBarry Smith     }
485*aee2cecaSBarry Smith   }
48653acd3b1SBarry Smith   PetscFunctionReturn(0);
48753acd3b1SBarry Smith }
48853acd3b1SBarry Smith 
48953acd3b1SBarry Smith #undef __FUNCT__
49053acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsReal"
49153acd3b1SBarry Smith /*@C
49253acd3b1SBarry Smith    PetscOptionsReal - Gets the PetscReal value for a particular option in the database.
49353acd3b1SBarry Smith 
49453acd3b1SBarry Smith    Collective on the communicator passed in PetscOptionsBegin()
49553acd3b1SBarry Smith 
49653acd3b1SBarry Smith    Input Parameters:
49753acd3b1SBarry Smith +  opt - option name
49853acd3b1SBarry Smith .  text - short string that describes the option
49953acd3b1SBarry Smith .  man - manual page with additional information on option
50053acd3b1SBarry Smith -  defaultv - the default (current) value
50153acd3b1SBarry Smith 
50253acd3b1SBarry Smith    Output Parameter:
50353acd3b1SBarry Smith +  value - the value to return
50453acd3b1SBarry Smith -  flg - PETSC_TRUE if found, else PETSC_FALSE
50553acd3b1SBarry Smith 
50653acd3b1SBarry Smith    Level: beginner
50753acd3b1SBarry Smith 
50853acd3b1SBarry Smith    Concepts: options database^has int
50953acd3b1SBarry Smith 
51053acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
51153acd3b1SBarry Smith 
51253acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
51353acd3b1SBarry Smith           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth()
51453acd3b1SBarry Smith           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(),
51553acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
51653acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
51753acd3b1SBarry Smith           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
51853acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
51953acd3b1SBarry Smith @*/
52053acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsReal(const char opt[],const char text[],const char man[],PetscReal defaultv,PetscReal *value,PetscTruth *set)
52153acd3b1SBarry Smith {
52253acd3b1SBarry Smith   PetscErrorCode ierr;
52353acd3b1SBarry Smith 
52453acd3b1SBarry Smith   PetscFunctionBegin;
52553acd3b1SBarry Smith   ierr = PetscOptionsGetReal(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr);
52661b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
527a83599f4SBarry Smith     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%G>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,man);CHKERRQ(ierr);
52853acd3b1SBarry Smith   }
52953acd3b1SBarry Smith   PetscFunctionReturn(0);
53053acd3b1SBarry Smith }
53153acd3b1SBarry Smith 
53253acd3b1SBarry Smith #undef __FUNCT__
53353acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsScalar"
53453acd3b1SBarry Smith /*@C
53553acd3b1SBarry Smith    PetscOptionsScalar - Gets the scalar value for a particular option in the database.
53653acd3b1SBarry Smith 
53753acd3b1SBarry Smith    Collective on the communicator passed in PetscOptionsBegin()
53853acd3b1SBarry Smith 
53953acd3b1SBarry Smith    Input Parameters:
54053acd3b1SBarry Smith +  opt - option name
54153acd3b1SBarry Smith .  text - short string that describes the option
54253acd3b1SBarry Smith .  man - manual page with additional information on option
54353acd3b1SBarry Smith -  defaultv - the default (current) value
54453acd3b1SBarry Smith 
54553acd3b1SBarry Smith    Output Parameter:
54653acd3b1SBarry Smith +  value - the value to return
54753acd3b1SBarry Smith -  flg - PETSC_TRUE if found, else PETSC_FALSE
54853acd3b1SBarry Smith 
54953acd3b1SBarry Smith    Level: beginner
55053acd3b1SBarry Smith 
55153acd3b1SBarry Smith    Concepts: options database^has int
55253acd3b1SBarry Smith 
55353acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
55453acd3b1SBarry Smith 
55553acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
55653acd3b1SBarry Smith           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth()
55753acd3b1SBarry Smith           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(),
55853acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
55953acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
56053acd3b1SBarry Smith           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
56153acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
56253acd3b1SBarry Smith @*/
56353acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsScalar(const char opt[],const char text[],const char man[],PetscScalar defaultv,PetscScalar *value,PetscTruth *set)
56453acd3b1SBarry Smith {
56553acd3b1SBarry Smith   PetscErrorCode ierr;
56653acd3b1SBarry Smith 
56753acd3b1SBarry Smith   PetscFunctionBegin;
56853acd3b1SBarry Smith #if !defined(PETSC_USE_COMPLEX)
56953acd3b1SBarry Smith   ierr = PetscOptionsReal(opt,text,man,defaultv,value,set);CHKERRQ(ierr);
57053acd3b1SBarry Smith #else
57153acd3b1SBarry Smith   ierr = PetscOptionsGetScalar(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr);
57253acd3b1SBarry Smith #endif
57353acd3b1SBarry Smith   PetscFunctionReturn(0);
57453acd3b1SBarry Smith }
57553acd3b1SBarry Smith 
57653acd3b1SBarry Smith #undef __FUNCT__
57753acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsName"
57853acd3b1SBarry Smith /*@C
57990d69ab7SBarry 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
58090d69ab7SBarry Smith                       its value is set to false.
58153acd3b1SBarry Smith 
58253acd3b1SBarry Smith    Collective on the communicator passed in PetscOptionsBegin()
58353acd3b1SBarry Smith 
58453acd3b1SBarry Smith    Input Parameters:
58553acd3b1SBarry Smith +  opt - option name
58653acd3b1SBarry Smith .  text - short string that describes the option
58753acd3b1SBarry Smith -  man - manual page with additional information on option
58853acd3b1SBarry Smith 
58953acd3b1SBarry Smith    Output Parameter:
59053acd3b1SBarry Smith .  flg - PETSC_TRUE if found, else PETSC_FALSE
59153acd3b1SBarry Smith 
59253acd3b1SBarry Smith    Level: beginner
59353acd3b1SBarry Smith 
59453acd3b1SBarry Smith    Concepts: options database^has int
59553acd3b1SBarry Smith 
59653acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
59753acd3b1SBarry Smith 
59853acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
59953acd3b1SBarry Smith           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth()
60053acd3b1SBarry Smith           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(),
60153acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
60253acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
60353acd3b1SBarry Smith           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
60453acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
60553acd3b1SBarry Smith @*/
60653acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsName(const char opt[],const char text[],const char man[],PetscTruth *flg)
60753acd3b1SBarry Smith {
60853acd3b1SBarry Smith   PetscErrorCode ierr;
60953acd3b1SBarry Smith 
61053acd3b1SBarry Smith   PetscFunctionBegin;
61153acd3b1SBarry Smith   ierr = PetscOptionsHasName(PetscOptionsObject.prefix,opt,flg);CHKERRQ(ierr);
61261b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
61353acd3b1SBarry Smith     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr);
61453acd3b1SBarry Smith   }
61553acd3b1SBarry Smith   PetscFunctionReturn(0);
61653acd3b1SBarry Smith }
61753acd3b1SBarry Smith 
61853acd3b1SBarry Smith #undef __FUNCT__
61953acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsList"
62053acd3b1SBarry Smith /*@C
62153acd3b1SBarry Smith      PetscOptionsList - Puts a list of option values that a single one may be selected from
62253acd3b1SBarry Smith 
62353acd3b1SBarry Smith    Collective on the communicator passed in PetscOptionsBegin()
62453acd3b1SBarry Smith 
62553acd3b1SBarry Smith    Input Parameters:
62653acd3b1SBarry Smith +  opt - option name
62753acd3b1SBarry Smith .  text - short string that describes the option
62853acd3b1SBarry Smith .  man - manual page with additional information on option
62953acd3b1SBarry Smith .  list - the possible choices
63053acd3b1SBarry Smith -  defaultv - the default (current) value
63153acd3b1SBarry Smith 
63253acd3b1SBarry Smith    Output Parameter:
63353acd3b1SBarry Smith +  value - the value to return
63453acd3b1SBarry Smith -  set - PETSC_TRUE if found, else PETSC_FALSE
63553acd3b1SBarry Smith 
63653acd3b1SBarry Smith    Level: intermediate
63753acd3b1SBarry Smith 
63853acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
63953acd3b1SBarry Smith 
64053acd3b1SBarry Smith    See PetscOptionsEList() for when the choices are given in a string array
64153acd3b1SBarry Smith 
64253acd3b1SBarry Smith    To get a listing of all currently specified options,
64353acd3b1SBarry Smith     see PetscOptionsPrint() or PetscOptionsGetAll()
64453acd3b1SBarry Smith 
64553acd3b1SBarry Smith    Concepts: options database^list
64653acd3b1SBarry Smith 
64753acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
64853acd3b1SBarry Smith            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
64953acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
65053acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
65153acd3b1SBarry Smith           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
65253acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
65353acd3b1SBarry Smith @*/
65453acd3b1SBarry 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)
65553acd3b1SBarry Smith {
65653acd3b1SBarry Smith   PetscErrorCode ierr;
65753acd3b1SBarry Smith 
65853acd3b1SBarry Smith   PetscFunctionBegin;
65953acd3b1SBarry Smith   ierr = PetscOptionsGetString(PetscOptionsObject.prefix,opt,value,len,set);CHKERRQ(ierr);
66061b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
6611d280d73SBarry Smith     ierr = PetscFListPrintTypes(list,PetscOptionsObject.comm,stdout,PetscOptionsObject.prefix,opt,ltext,man);CHKERRQ(ierr);CHKERRQ(ierr);
66253acd3b1SBarry Smith   }
66353acd3b1SBarry Smith   PetscFunctionReturn(0);
66453acd3b1SBarry Smith }
66553acd3b1SBarry Smith 
66653acd3b1SBarry Smith #undef __FUNCT__
66753acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsEList"
66853acd3b1SBarry Smith /*@C
66953acd3b1SBarry Smith      PetscOptionsEList - Puts a list of option values that a single one may be selected from
67053acd3b1SBarry Smith 
67153acd3b1SBarry Smith    Collective on the communicator passed in PetscOptionsBegin()
67253acd3b1SBarry Smith 
67353acd3b1SBarry Smith    Input Parameters:
67453acd3b1SBarry Smith +  opt - option name
67553acd3b1SBarry Smith .  ltext - short string that describes the option
67653acd3b1SBarry Smith .  man - manual page with additional information on option
67753acd3b1SBarry Smith .  list - the possible choices
67853acd3b1SBarry Smith .  ntext - number of choices
67953acd3b1SBarry Smith -  defaultv - the default (current) value
68053acd3b1SBarry Smith 
68153acd3b1SBarry Smith    Output Parameter:
68253acd3b1SBarry Smith +  value - the index of the value to return
68353acd3b1SBarry Smith -  set - PETSC_TRUE if found, else PETSC_FALSE
68453acd3b1SBarry Smith 
68553acd3b1SBarry Smith    Level: intermediate
68653acd3b1SBarry Smith 
68753acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
68853acd3b1SBarry Smith 
68953acd3b1SBarry Smith    See PetscOptionsList() for when the choices are given in a PetscFList()
69053acd3b1SBarry Smith 
69153acd3b1SBarry Smith    Concepts: options database^list
69253acd3b1SBarry Smith 
69353acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
69453acd3b1SBarry Smith            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
69553acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
69653acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
69753acd3b1SBarry Smith           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
69853acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
69953acd3b1SBarry Smith @*/
70053acd3b1SBarry 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)
70153acd3b1SBarry Smith {
70253acd3b1SBarry Smith   PetscErrorCode ierr;
70353acd3b1SBarry Smith   PetscInt       i;
70453acd3b1SBarry Smith 
70553acd3b1SBarry Smith   PetscFunctionBegin;
70653acd3b1SBarry Smith   ierr = PetscOptionsGetEList(PetscOptionsObject.prefix,opt,list,ntext,value,set);CHKERRQ(ierr);
70761b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
70853acd3b1SBarry Smith     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%s> (choose one of)",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv);CHKERRQ(ierr);
70953acd3b1SBarry Smith     for (i=0; i<ntext; i++){
71053acd3b1SBarry Smith       ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," %s",list[i]);CHKERRQ(ierr);
71153acd3b1SBarry Smith     }
71253acd3b1SBarry Smith     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"\n");CHKERRQ(ierr);
71353acd3b1SBarry Smith   }
71453acd3b1SBarry Smith   PetscFunctionReturn(0);
71553acd3b1SBarry Smith }
71653acd3b1SBarry Smith 
71753acd3b1SBarry Smith #undef __FUNCT__
71853acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsTruthGroupBegin"
71953acd3b1SBarry Smith /*@C
72053acd3b1SBarry Smith      PetscOptionsTruthGroupBegin - First in a series of logical queries on the options database for
72153acd3b1SBarry Smith        which only a single value can be true.
72253acd3b1SBarry Smith 
72353acd3b1SBarry Smith    Collective on the communicator passed in PetscOptionsBegin()
72453acd3b1SBarry Smith 
72553acd3b1SBarry Smith    Input Parameters:
72653acd3b1SBarry Smith +  opt - option name
72753acd3b1SBarry Smith .  text - short string that describes the option
72853acd3b1SBarry Smith -  man - manual page with additional information on option
72953acd3b1SBarry Smith 
73053acd3b1SBarry Smith    Output Parameter:
73153acd3b1SBarry Smith .  flg - whether that option was set or not
73253acd3b1SBarry Smith 
73353acd3b1SBarry Smith    Level: intermediate
73453acd3b1SBarry Smith 
73553acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
73653acd3b1SBarry Smith 
73753acd3b1SBarry Smith    Must be followed by 0 or more PetscOptionsTruthGroup()s and PetscOptionsTruthGroupEnd()
73853acd3b1SBarry Smith 
73953acd3b1SBarry Smith     Concepts: options database^logical group
74053acd3b1SBarry Smith 
74153acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
74253acd3b1SBarry Smith            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
74353acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
74453acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
74553acd3b1SBarry Smith           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
74653acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
74753acd3b1SBarry Smith @*/
74853acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroupBegin(const char opt[],const char text[],const char man[],PetscTruth *flg)
74953acd3b1SBarry Smith {
75053acd3b1SBarry Smith   PetscErrorCode ierr;
75153acd3b1SBarry Smith 
75253acd3b1SBarry Smith   PetscFunctionBegin;
75317326d04SJed Brown   *flg = PETSC_FALSE;
75417326d04SJed Brown   ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,PETSC_NULL);CHKERRQ(ierr);
75561b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
75653acd3b1SBarry Smith     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  Pick at most one of -------------\n");CHKERRQ(ierr);
75753acd3b1SBarry Smith     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"    -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr);
75853acd3b1SBarry Smith   }
75953acd3b1SBarry Smith   PetscFunctionReturn(0);
76053acd3b1SBarry Smith }
76153acd3b1SBarry Smith 
76253acd3b1SBarry Smith #undef __FUNCT__
76353acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsTruthGroup"
76453acd3b1SBarry Smith /*@C
76553acd3b1SBarry Smith      PetscOptionsTruthGroup - One in a series of logical queries on the options database for
76653acd3b1SBarry Smith        which only a single value can be true.
76753acd3b1SBarry Smith 
76853acd3b1SBarry Smith    Collective on the communicator passed in PetscOptionsBegin()
76953acd3b1SBarry Smith 
77053acd3b1SBarry Smith    Input Parameters:
77153acd3b1SBarry Smith +  opt - option name
77253acd3b1SBarry Smith .  text - short string that describes the option
77353acd3b1SBarry Smith -  man - manual page with additional information on option
77453acd3b1SBarry Smith 
77553acd3b1SBarry Smith    Output Parameter:
77653acd3b1SBarry Smith .  flg - PETSC_TRUE if found, else PETSC_FALSE
77753acd3b1SBarry Smith 
77853acd3b1SBarry Smith    Level: intermediate
77953acd3b1SBarry Smith 
78053acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
78153acd3b1SBarry Smith 
78253acd3b1SBarry Smith    Must follow a PetscOptionsTruthGroupBegin() and preceded a PetscOptionsTruthGroupEnd()
78353acd3b1SBarry Smith 
78453acd3b1SBarry Smith     Concepts: options database^logical group
78553acd3b1SBarry Smith 
78653acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
78753acd3b1SBarry Smith            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
78853acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
78953acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
79053acd3b1SBarry Smith           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
79153acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
79253acd3b1SBarry Smith @*/
79353acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroup(const char opt[],const char text[],const char man[],PetscTruth *flg)
79453acd3b1SBarry Smith {
79553acd3b1SBarry Smith   PetscErrorCode ierr;
79653acd3b1SBarry Smith 
79753acd3b1SBarry Smith   PetscFunctionBegin;
79817326d04SJed Brown   *flg = PETSC_FALSE;
79917326d04SJed Brown   ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,PETSC_NULL);CHKERRQ(ierr);
80061b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
80153acd3b1SBarry Smith     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"    -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr);
80253acd3b1SBarry Smith   }
80353acd3b1SBarry Smith   PetscFunctionReturn(0);
80453acd3b1SBarry Smith }
80553acd3b1SBarry Smith 
80653acd3b1SBarry Smith #undef __FUNCT__
80753acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsTruthGroupEnd"
80853acd3b1SBarry Smith /*@C
80953acd3b1SBarry Smith      PetscOptionsTruthGroupEnd - Last in a series of logical queries on the options database for
81053acd3b1SBarry Smith        which only a single value can be true.
81153acd3b1SBarry Smith 
81253acd3b1SBarry Smith    Collective on the communicator passed in PetscOptionsBegin()
81353acd3b1SBarry Smith 
81453acd3b1SBarry Smith    Input Parameters:
81553acd3b1SBarry Smith +  opt - option name
81653acd3b1SBarry Smith .  text - short string that describes the option
81753acd3b1SBarry Smith -  man - manual page with additional information on option
81853acd3b1SBarry Smith 
81953acd3b1SBarry Smith    Output Parameter:
82053acd3b1SBarry Smith .  flg - PETSC_TRUE if found, else PETSC_FALSE
82153acd3b1SBarry Smith 
82253acd3b1SBarry Smith    Level: intermediate
82353acd3b1SBarry Smith 
82453acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
82553acd3b1SBarry Smith 
82653acd3b1SBarry Smith    Must follow a PetscOptionsTruthGroupBegin()
82753acd3b1SBarry Smith 
82853acd3b1SBarry Smith     Concepts: options database^logical group
82953acd3b1SBarry Smith 
83053acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
83153acd3b1SBarry Smith            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
83253acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
83353acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
83453acd3b1SBarry Smith           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
83553acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
83653acd3b1SBarry Smith @*/
83753acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroupEnd(const char opt[],const char text[],const char man[],PetscTruth *flg)
83853acd3b1SBarry Smith {
83953acd3b1SBarry Smith   PetscErrorCode ierr;
84053acd3b1SBarry Smith 
84153acd3b1SBarry Smith   PetscFunctionBegin;
84217326d04SJed Brown   *flg = PETSC_FALSE;
84317326d04SJed Brown   ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,PETSC_NULL);CHKERRQ(ierr);
84461b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
84553acd3b1SBarry Smith     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"    -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr);
84653acd3b1SBarry Smith   }
84753acd3b1SBarry Smith   PetscFunctionReturn(0);
84853acd3b1SBarry Smith }
84953acd3b1SBarry Smith 
85053acd3b1SBarry Smith #undef __FUNCT__
85153acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsTruth"
85253acd3b1SBarry Smith /*@C
85353acd3b1SBarry Smith    PetscOptionsTruth - Determines if a particular option is in the database with a true or false
85453acd3b1SBarry Smith 
85553acd3b1SBarry Smith    Collective on the communicator passed in PetscOptionsBegin()
85653acd3b1SBarry Smith 
85753acd3b1SBarry Smith    Input Parameters:
85853acd3b1SBarry Smith +  opt - option name
85953acd3b1SBarry Smith .  text - short string that describes the option
86053acd3b1SBarry Smith -  man - manual page with additional information on option
86153acd3b1SBarry Smith 
86253acd3b1SBarry Smith    Output Parameter:
86353acd3b1SBarry Smith .  flg - PETSC_TRUE or PETSC_FALSE
86453acd3b1SBarry Smith .  set - PETSC_TRUE if found, else PETSC_FALSE
86553acd3b1SBarry Smith 
86653acd3b1SBarry Smith    Level: beginner
86753acd3b1SBarry Smith 
86853acd3b1SBarry Smith    Concepts: options database^logical
86953acd3b1SBarry Smith 
87053acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
87153acd3b1SBarry Smith 
87253acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
87353acd3b1SBarry Smith           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth()
87453acd3b1SBarry Smith           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(),
87553acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
87653acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
87753acd3b1SBarry Smith           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
87853acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
87953acd3b1SBarry Smith @*/
88053acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruth(const char opt[],const char text[],const char man[],PetscTruth deflt,PetscTruth *flg,PetscTruth *set)
88153acd3b1SBarry Smith {
88253acd3b1SBarry Smith   PetscErrorCode ierr;
88353acd3b1SBarry Smith   PetscTruth     iset;
884*aee2cecaSBarry Smith   PetscOptions   amsopt;
88553acd3b1SBarry Smith 
88653acd3b1SBarry Smith   PetscFunctionBegin;
887*aee2cecaSBarry Smith   if (PetscOptionsPublishCount == 0) {
888*aee2cecaSBarry Smith     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL,&amsopt);CHKERRQ(ierr);
889*aee2cecaSBarry Smith     ierr = PetscMalloc(16*sizeof(char),&amsopt->data);CHKERRQ(ierr);
890*aee2cecaSBarry Smith     ierr = PetscStrcpy((char*)amsopt->data,deflt ? "true" : "false");CHKERRQ(ierr);
891*aee2cecaSBarry Smith   } else {
89253acd3b1SBarry Smith     ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,&iset);CHKERRQ(ierr);
89353acd3b1SBarry Smith     if (!iset) {
89453acd3b1SBarry Smith       if (flg) *flg = deflt;
89553acd3b1SBarry Smith     }
89653acd3b1SBarry Smith     if (set) *set = iset;
89761b37b28SSatish Balay     if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
89853acd3b1SBarry Smith       const char *v = PetscTruths[deflt];
89953acd3b1SBarry Smith       ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s: <%s> %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,v,text,man);CHKERRQ(ierr);
90053acd3b1SBarry Smith     }
901*aee2cecaSBarry Smith   }
90253acd3b1SBarry Smith   PetscFunctionReturn(0);
90353acd3b1SBarry Smith }
90453acd3b1SBarry Smith 
90553acd3b1SBarry Smith #undef __FUNCT__
90653acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsRealArray"
90753acd3b1SBarry Smith /*@C
90853acd3b1SBarry Smith    PetscOptionsRealArray - Gets an array of double values for a particular
90953acd3b1SBarry Smith    option in the database. The values must be separated with commas with
91053acd3b1SBarry Smith    no intervening spaces.
91153acd3b1SBarry Smith 
91253acd3b1SBarry Smith    Collective on the communicator passed in PetscOptionsBegin()
91353acd3b1SBarry Smith 
91453acd3b1SBarry Smith    Input Parameters:
91553acd3b1SBarry Smith +  opt - the option one is seeking
91653acd3b1SBarry Smith .  text - short string describing option
91753acd3b1SBarry Smith .  man - manual page for option
91853acd3b1SBarry Smith -  nmax - maximum number of values
91953acd3b1SBarry Smith 
92053acd3b1SBarry Smith    Output Parameter:
92153acd3b1SBarry Smith +  value - location to copy values
92253acd3b1SBarry Smith .  nmax - actual number of values found
92353acd3b1SBarry Smith -  set - PETSC_TRUE if found, else PETSC_FALSE
92453acd3b1SBarry Smith 
92553acd3b1SBarry Smith    Level: beginner
92653acd3b1SBarry Smith 
92753acd3b1SBarry Smith    Notes:
92853acd3b1SBarry Smith    The user should pass in an array of doubles
92953acd3b1SBarry Smith 
93053acd3b1SBarry Smith    Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
93153acd3b1SBarry Smith 
93253acd3b1SBarry Smith    Concepts: options database^array of strings
93353acd3b1SBarry Smith 
93453acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
93553acd3b1SBarry Smith            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
93653acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
93753acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
93853acd3b1SBarry Smith           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
93953acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
94053acd3b1SBarry Smith @*/
94153acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsRealArray(const char opt[],const char text[],const char man[],PetscReal value[],PetscInt *n,PetscTruth *set)
94253acd3b1SBarry Smith {
94353acd3b1SBarry Smith   PetscErrorCode ierr;
94453acd3b1SBarry Smith   PetscInt       i;
94553acd3b1SBarry Smith 
94653acd3b1SBarry Smith   PetscFunctionBegin;
94753acd3b1SBarry Smith   ierr = PetscOptionsGetRealArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr);
94861b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
949a83599f4SBarry Smith     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%G",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr);
95053acd3b1SBarry Smith     for (i=1; i<*n; i++) {
951a83599f4SBarry Smith       ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%G",value[i]);CHKERRQ(ierr);
95253acd3b1SBarry Smith     }
95353acd3b1SBarry Smith     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr);
95453acd3b1SBarry Smith   }
95553acd3b1SBarry Smith   PetscFunctionReturn(0);
95653acd3b1SBarry Smith }
95753acd3b1SBarry Smith 
95853acd3b1SBarry Smith 
95953acd3b1SBarry Smith #undef __FUNCT__
96053acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsIntArray"
96153acd3b1SBarry Smith /*@C
96253acd3b1SBarry Smith    PetscOptionsIntArray - Gets an array of integers for a particular
96353acd3b1SBarry Smith    option in the database. The values must be separated with commas with
96453acd3b1SBarry Smith    no intervening spaces.
96553acd3b1SBarry Smith 
96653acd3b1SBarry Smith    Collective on the communicator passed in PetscOptionsBegin()
96753acd3b1SBarry Smith 
96853acd3b1SBarry Smith    Input Parameters:
96953acd3b1SBarry Smith +  opt - the option one is seeking
97053acd3b1SBarry Smith .  text - short string describing option
97153acd3b1SBarry Smith .  man - manual page for option
972f8a50e2bSBarry Smith -  n - maximum number of values
97353acd3b1SBarry Smith 
97453acd3b1SBarry Smith    Output Parameter:
97553acd3b1SBarry Smith +  value - location to copy values
976f8a50e2bSBarry Smith .  n - actual number of values found
97753acd3b1SBarry Smith -  set - PETSC_TRUE if found, else PETSC_FALSE
97853acd3b1SBarry Smith 
97953acd3b1SBarry Smith    Level: beginner
98053acd3b1SBarry Smith 
98153acd3b1SBarry Smith    Notes:
98253acd3b1SBarry Smith    The user should pass in an array of integers
98353acd3b1SBarry Smith 
98453acd3b1SBarry Smith    Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
98553acd3b1SBarry Smith 
98653acd3b1SBarry Smith    Concepts: options database^array of strings
98753acd3b1SBarry Smith 
98853acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
98953acd3b1SBarry Smith            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
99053acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
99153acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
99253acd3b1SBarry Smith           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
99353acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList(), PetscOptionsRealArray()
99453acd3b1SBarry Smith @*/
99553acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsIntArray(const char opt[],const char text[],const char man[],PetscInt value[],PetscInt *n,PetscTruth *set)
99653acd3b1SBarry Smith {
99753acd3b1SBarry Smith   PetscErrorCode ierr;
99853acd3b1SBarry Smith   PetscInt       i;
99953acd3b1SBarry Smith 
100053acd3b1SBarry Smith   PetscFunctionBegin;
100153acd3b1SBarry Smith   ierr = PetscOptionsGetIntArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr);
100261b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
100353acd3b1SBarry Smith     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%d",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr);
100453acd3b1SBarry Smith     for (i=1; i<*n; i++) {
100553acd3b1SBarry Smith       ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%d",value[i]);CHKERRQ(ierr);
100653acd3b1SBarry Smith     }
100753acd3b1SBarry Smith     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr);
100853acd3b1SBarry Smith   }
100953acd3b1SBarry Smith   PetscFunctionReturn(0);
101053acd3b1SBarry Smith }
101153acd3b1SBarry Smith 
101253acd3b1SBarry Smith #undef __FUNCT__
101353acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsStringArray"
101453acd3b1SBarry Smith /*@C
101553acd3b1SBarry Smith    PetscOptionsStringArray - Gets an array of string values for a particular
101653acd3b1SBarry Smith    option in the database. The values must be separated with commas with
101753acd3b1SBarry Smith    no intervening spaces.
101853acd3b1SBarry Smith 
101953acd3b1SBarry Smith    Collective on the communicator passed in PetscOptionsBegin()
102053acd3b1SBarry Smith 
102153acd3b1SBarry Smith    Input Parameters:
102253acd3b1SBarry Smith +  opt - the option one is seeking
102353acd3b1SBarry Smith .  text - short string describing option
102453acd3b1SBarry Smith .  man - manual page for option
102553acd3b1SBarry Smith -  nmax - maximum number of strings
102653acd3b1SBarry Smith 
102753acd3b1SBarry Smith    Output Parameter:
102853acd3b1SBarry Smith +  value - location to copy strings
102953acd3b1SBarry Smith .  nmax - actual number of strings found
103053acd3b1SBarry Smith -  set - PETSC_TRUE if found, else PETSC_FALSE
103153acd3b1SBarry Smith 
103253acd3b1SBarry Smith    Level: beginner
103353acd3b1SBarry Smith 
103453acd3b1SBarry Smith    Notes:
103553acd3b1SBarry Smith    The user should pass in an array of pointers to char, to hold all the
103653acd3b1SBarry Smith    strings returned by this function.
103753acd3b1SBarry Smith 
103853acd3b1SBarry Smith    The user is responsible for deallocating the strings that are
103953acd3b1SBarry Smith    returned. The Fortran interface for this routine is not supported.
104053acd3b1SBarry Smith 
104153acd3b1SBarry Smith    Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
104253acd3b1SBarry Smith 
104353acd3b1SBarry Smith    Concepts: options database^array of strings
104453acd3b1SBarry Smith 
104553acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
104653acd3b1SBarry Smith            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
104753acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
104853acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
104953acd3b1SBarry Smith           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
105053acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
105153acd3b1SBarry Smith @*/
105253acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsStringArray(const char opt[],const char text[],const char man[],char *value[],PetscInt *nmax,PetscTruth *set)
105353acd3b1SBarry Smith {
105453acd3b1SBarry Smith   PetscErrorCode ierr;
105553acd3b1SBarry Smith 
105653acd3b1SBarry Smith   PetscFunctionBegin;
105753acd3b1SBarry Smith   ierr = PetscOptionsGetStringArray(PetscOptionsObject.prefix,opt,value,nmax,set);CHKERRQ(ierr);
105861b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
105953acd3b1SBarry Smith     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <string1,string2,...>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr);
106053acd3b1SBarry Smith   }
106153acd3b1SBarry Smith   PetscFunctionReturn(0);
106253acd3b1SBarry Smith }
106353acd3b1SBarry Smith 
1064e2446a98SMatthew Knepley #undef __FUNCT__
1065e2446a98SMatthew Knepley #define __FUNCT__ "PetscOptionsTruthArray"
1066e2446a98SMatthew Knepley /*@C
1067e2446a98SMatthew Knepley    PetscOptionsTruthArray - Gets an array of logical values (true or false) for a particular
1068e2446a98SMatthew Knepley    option in the database. The values must be separated with commas with
1069e2446a98SMatthew Knepley    no intervening spaces.
1070e2446a98SMatthew Knepley 
1071e2446a98SMatthew Knepley    Collective on the communicator passed in PetscOptionsBegin()
1072e2446a98SMatthew Knepley 
1073e2446a98SMatthew Knepley    Input Parameters:
1074e2446a98SMatthew Knepley +  opt - the option one is seeking
1075e2446a98SMatthew Knepley .  text - short string describing option
1076e2446a98SMatthew Knepley .  man - manual page for option
1077e2446a98SMatthew Knepley -  nmax - maximum number of values
1078e2446a98SMatthew Knepley 
1079e2446a98SMatthew Knepley    Output Parameter:
1080e2446a98SMatthew Knepley +  value - location to copy values
1081e2446a98SMatthew Knepley .  nmax - actual number of values found
1082e2446a98SMatthew Knepley -  set - PETSC_TRUE if found, else PETSC_FALSE
1083e2446a98SMatthew Knepley 
1084e2446a98SMatthew Knepley    Level: beginner
1085e2446a98SMatthew Knepley 
1086e2446a98SMatthew Knepley    Notes:
1087e2446a98SMatthew Knepley    The user should pass in an array of doubles
1088e2446a98SMatthew Knepley 
1089e2446a98SMatthew Knepley    Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1090e2446a98SMatthew Knepley 
1091e2446a98SMatthew Knepley    Concepts: options database^array of strings
1092e2446a98SMatthew Knepley 
1093e2446a98SMatthew Knepley .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1094e2446a98SMatthew Knepley            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
1095e2446a98SMatthew Knepley           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1096e2446a98SMatthew Knepley           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1097e2446a98SMatthew Knepley           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
1098e2446a98SMatthew Knepley           PetscOptionsList(), PetscOptionsEList()
1099e2446a98SMatthew Knepley @*/
1100e2446a98SMatthew Knepley PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthArray(const char opt[],const char text[],const char man[],PetscTruth value[],PetscInt *n,PetscTruth *set)
1101e2446a98SMatthew Knepley {
1102e2446a98SMatthew Knepley   PetscErrorCode ierr;
1103e2446a98SMatthew Knepley   PetscInt       i;
1104e2446a98SMatthew Knepley 
1105e2446a98SMatthew Knepley   PetscFunctionBegin;
1106e2446a98SMatthew Knepley   ierr = PetscOptionsGetTruthArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr);
1107e2446a98SMatthew Knepley   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
1108e2446a98SMatthew Knepley     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%d",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr);
1109e2446a98SMatthew Knepley     for (i=1; i<*n; i++) {
1110e2446a98SMatthew Knepley       ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%d",value[i]);CHKERRQ(ierr);
1111e2446a98SMatthew Knepley     }
1112e2446a98SMatthew Knepley     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr);
1113e2446a98SMatthew Knepley   }
1114e2446a98SMatthew Knepley   PetscFunctionReturn(0);
1115e2446a98SMatthew Knepley }
1116e2446a98SMatthew Knepley 
111753acd3b1SBarry Smith 
111853acd3b1SBarry Smith #undef __FUNCT__
111953acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsHead"
112053acd3b1SBarry Smith /*@C
1121b52f573bSBarry Smith      PetscOptionsHead - Puts a heading before listing any more published options. Used, for example,
112253acd3b1SBarry Smith             in KSPSetFromOptions_GMRES().
112353acd3b1SBarry Smith 
112453acd3b1SBarry Smith    Collective on the communicator passed in PetscOptionsBegin()
112553acd3b1SBarry Smith 
112653acd3b1SBarry Smith    Input Parameter:
112753acd3b1SBarry Smith .   head - the heading text
112853acd3b1SBarry Smith 
112953acd3b1SBarry Smith 
113053acd3b1SBarry Smith    Level: intermediate
113153acd3b1SBarry Smith 
113253acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
113353acd3b1SBarry Smith 
1134b52f573bSBarry Smith           Can be followed by a call to PetscOptionsTail() in the same function.
113553acd3b1SBarry Smith 
113653acd3b1SBarry Smith    Concepts: options database^subheading
113753acd3b1SBarry Smith 
113853acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
113953acd3b1SBarry Smith            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
114053acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
114153acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
114253acd3b1SBarry Smith           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
114353acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
114453acd3b1SBarry Smith @*/
114553acd3b1SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscOptionsHead(const char head[])
114653acd3b1SBarry Smith {
114753acd3b1SBarry Smith   PetscErrorCode ierr;
114853acd3b1SBarry Smith 
114953acd3b1SBarry Smith   PetscFunctionBegin;
115061b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
115153acd3b1SBarry Smith     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  %s\n",head);CHKERRQ(ierr);
115253acd3b1SBarry Smith   }
115353acd3b1SBarry Smith   PetscFunctionReturn(0);
115453acd3b1SBarry Smith }
115553acd3b1SBarry Smith 
115653acd3b1SBarry Smith 
115753acd3b1SBarry Smith 
115853acd3b1SBarry Smith 
115953acd3b1SBarry Smith 
116053acd3b1SBarry Smith 
1161