xref: /petsc/src/sys/objects/aoptions.c (revision 475446a1e3a0611cf474352f86b06184959b6260)
17d0a6c19SBarry Smith 
253acd3b1SBarry Smith /*
33fc1eb6aSBarry Smith    Implements the higher-level options database querying methods. These are self-documenting and can attach at runtime to
43fc1eb6aSBarry Smith    GUI code to display the options and get values from the users.
553acd3b1SBarry Smith 
653acd3b1SBarry Smith */
753acd3b1SBarry Smith 
8afcb2eb5SJed Brown #include <petsc-private/petscimpl.h>        /*I  "petscsys.h"   I*/
9665c2dedSJed Brown #include <petscviewer.h>
1053acd3b1SBarry Smith 
112aa6d131SJed Brown #define ManSection(str) ((str) ? (str) : "None")
122aa6d131SJed Brown 
1353acd3b1SBarry Smith /*
1453acd3b1SBarry Smith     Keep a linked list of options that have been posted and we are waiting for
153fc1eb6aSBarry Smith    user selection. See the manual page for PetscOptionsBegin()
1653acd3b1SBarry Smith 
1753acd3b1SBarry Smith     Eventually we'll attach this beast to a MPI_Comm
1853acd3b1SBarry Smith */
19f8d0b74dSMatthew Knepley PetscOptionsObjectType PetscOptionsObject;
2053acd3b1SBarry Smith PetscInt               PetscOptionsPublishCount = 0;
2153acd3b1SBarry Smith 
2253acd3b1SBarry Smith #undef __FUNCT__
2353acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsBegin_Private"
2453acd3b1SBarry Smith /*
2553acd3b1SBarry Smith     Handles setting up the data structure in a call to PetscOptionsBegin()
2653acd3b1SBarry Smith */
2753acd3b1SBarry Smith PetscErrorCode PetscOptionsBegin_Private(MPI_Comm comm,const char prefix[],const char title[],const char mansec[])
2853acd3b1SBarry Smith {
2953acd3b1SBarry Smith   PetscErrorCode ierr;
3053acd3b1SBarry Smith 
3153acd3b1SBarry Smith   PetscFunctionBegin;
3253acd3b1SBarry Smith   PetscOptionsObject.next          = 0;
3353acd3b1SBarry Smith   PetscOptionsObject.comm          = comm;
346356e834SBarry Smith   PetscOptionsObject.changedmethod = PETSC_FALSE;
35a297a907SKarl Rupp 
36c31cb41cSBarry Smith   ierr = PetscFree(PetscOptionsObject.prefix);CHKERRQ(ierr);
3753acd3b1SBarry Smith   ierr = PetscStrallocpy(prefix,&PetscOptionsObject.prefix);CHKERRQ(ierr);
38c31cb41cSBarry Smith   ierr = PetscFree(PetscOptionsObject.title);CHKERRQ(ierr);
3953acd3b1SBarry Smith   ierr = PetscStrallocpy(title,&PetscOptionsObject.title);CHKERRQ(ierr);
4053acd3b1SBarry Smith 
410298fd71SBarry Smith   ierr = PetscOptionsHasName(NULL,"-help",&PetscOptionsObject.printhelp);CHKERRQ(ierr);
4253acd3b1SBarry Smith   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1) {
4361b37b28SSatish Balay     if (!PetscOptionsObject.alreadyprinted) {
4453acd3b1SBarry Smith       ierr = (*PetscHelpPrintf)(comm,"%s -------------------------------------------------\n",title);CHKERRQ(ierr);
4553acd3b1SBarry Smith     }
4661b37b28SSatish Balay   }
4753acd3b1SBarry Smith   PetscFunctionReturn(0);
4853acd3b1SBarry Smith }
4953acd3b1SBarry Smith 
503194b578SJed Brown #undef __FUNCT__
513194b578SJed Brown #define __FUNCT__ "PetscObjectOptionsBegin_Private"
523194b578SJed Brown /*
533194b578SJed Brown     Handles setting up the data structure in a call to PetscObjectOptionsBegin()
543194b578SJed Brown */
553194b578SJed Brown PetscErrorCode PetscObjectOptionsBegin_Private(PetscObject obj)
563194b578SJed Brown {
573194b578SJed Brown   PetscErrorCode ierr;
583194b578SJed Brown   char           title[256];
593194b578SJed Brown   PetscBool      flg;
603194b578SJed Brown 
613194b578SJed Brown   PetscFunctionBegin;
623194b578SJed Brown   PetscValidHeader(obj,1);
633194b578SJed Brown   PetscOptionsObject.object         = obj;
643194b578SJed Brown   PetscOptionsObject.alreadyprinted = obj->optionsprinted;
65a297a907SKarl Rupp 
663194b578SJed Brown   ierr = PetscStrcmp(obj->description,obj->class_name,&flg);CHKERRQ(ierr);
673194b578SJed Brown   if (flg) {
688caf3d72SBarry Smith     ierr = PetscSNPrintf(title,sizeof(title),"%s options",obj->class_name);CHKERRQ(ierr);
693194b578SJed Brown   } else {
708caf3d72SBarry Smith     ierr = PetscSNPrintf(title,sizeof(title),"%s (%s) options",obj->description,obj->class_name);CHKERRQ(ierr);
713194b578SJed Brown   }
723194b578SJed Brown   ierr = PetscOptionsBegin_Private(obj->comm,obj->prefix,title,obj->mansec);CHKERRQ(ierr);
733194b578SJed Brown   PetscFunctionReturn(0);
743194b578SJed Brown }
753194b578SJed Brown 
7653acd3b1SBarry Smith /*
7753acd3b1SBarry Smith      Handles adding another option to the list of options within this particular PetscOptionsBegin() PetscOptionsEnd()
7853acd3b1SBarry Smith */
7953acd3b1SBarry Smith #undef __FUNCT__
8053acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsCreate_Private"
81e3ed6ec8SBarry Smith static int PetscOptionsCreate_Private(const char opt[],const char text[],const char man[],PetscOptionType t,PetscOptions *amsopt)
8253acd3b1SBarry Smith {
8353acd3b1SBarry Smith   int          ierr;
8453acd3b1SBarry Smith   PetscOptions next;
853be6e4c3SJed Brown   PetscBool    valid;
8653acd3b1SBarry Smith 
8753acd3b1SBarry Smith   PetscFunctionBegin;
883be6e4c3SJed Brown   ierr = PetscOptionsValidKey(opt,&valid);CHKERRQ(ierr);
893be6e4c3SJed Brown   if (!valid) SETERRQ1(PETSC_COMM_WORLD,PETSC_ERR_ARG_INCOMP,"The option '%s' is not a valid key",opt);
903be6e4c3SJed Brown 
916e655a9bSJed Brown   ierr            = PetscNew(struct _n_PetscOptions,amsopt);CHKERRQ(ierr);
9253acd3b1SBarry Smith   (*amsopt)->next = 0;
9353acd3b1SBarry Smith   (*amsopt)->set  = PETSC_FALSE;
946356e834SBarry Smith   (*amsopt)->type = t;
9553acd3b1SBarry Smith   (*amsopt)->data = 0;
9661b37b28SSatish Balay 
9753acd3b1SBarry Smith   ierr = PetscStrallocpy(text,&(*amsopt)->text);CHKERRQ(ierr);
9853acd3b1SBarry Smith   ierr = PetscStrallocpy(opt,&(*amsopt)->option);CHKERRQ(ierr);
996356e834SBarry Smith   ierr = PetscStrallocpy(man,&(*amsopt)->man);CHKERRQ(ierr);
10053acd3b1SBarry Smith 
101a297a907SKarl Rupp   if (!PetscOptionsObject.next) PetscOptionsObject.next = *amsopt;
102a297a907SKarl Rupp   else {
10353acd3b1SBarry Smith     next = PetscOptionsObject.next;
10453acd3b1SBarry Smith     while (next->next) next = next->next;
10553acd3b1SBarry Smith     next->next = *amsopt;
10653acd3b1SBarry Smith   }
10753acd3b1SBarry Smith   PetscFunctionReturn(0);
10853acd3b1SBarry Smith }
10953acd3b1SBarry Smith 
11053acd3b1SBarry Smith #undef __FUNCT__
111aee2cecaSBarry Smith #define __FUNCT__ "PetscScanString"
112aee2cecaSBarry Smith /*
1133fc1eb6aSBarry Smith     PetscScanString -  Gets user input via stdin from process and broadcasts to all processes
1143fc1eb6aSBarry Smith 
1153fc1eb6aSBarry Smith     Collective on MPI_Comm
1163fc1eb6aSBarry Smith 
1173fc1eb6aSBarry Smith    Input Parameters:
1183fc1eb6aSBarry Smith +     commm - communicator for the broadcast, must be PETSC_COMM_WORLD
1193fc1eb6aSBarry Smith .     n - length of the string, must be the same on all processes
1203fc1eb6aSBarry Smith -     str - location to store input
121aee2cecaSBarry Smith 
122aee2cecaSBarry Smith     Bugs:
123aee2cecaSBarry Smith .   Assumes process 0 of the given communicator has access to stdin
124aee2cecaSBarry Smith 
125aee2cecaSBarry Smith */
1263fc1eb6aSBarry Smith static PetscErrorCode PetscScanString(MPI_Comm comm,size_t n,char str[])
127aee2cecaSBarry Smith {
128330cf3c9SBarry Smith   size_t         i;
129aee2cecaSBarry Smith   char           c;
1303fc1eb6aSBarry Smith   PetscMPIInt    rank,nm;
131aee2cecaSBarry Smith   PetscErrorCode ierr;
132aee2cecaSBarry Smith 
133aee2cecaSBarry Smith   PetscFunctionBegin;
134aee2cecaSBarry Smith   ierr = MPI_Comm_rank(comm,&rank);CHKERRQ(ierr);
135aee2cecaSBarry Smith   if (!rank) {
136aee2cecaSBarry Smith     c = (char) getchar();
137aee2cecaSBarry Smith     i = 0;
138aee2cecaSBarry Smith     while (c != '\n' && i < n-1) {
139aee2cecaSBarry Smith       str[i++] = c;
140aee2cecaSBarry Smith       c = (char)getchar();
141aee2cecaSBarry Smith     }
142aee2cecaSBarry Smith     str[i] = 0;
143aee2cecaSBarry Smith   }
1444dc2109aSBarry Smith   ierr = PetscMPIIntCast(n,&nm);CHKERRQ(ierr);
1453fc1eb6aSBarry Smith   ierr = MPI_Bcast(str,nm,MPI_CHAR,0,comm);CHKERRQ(ierr);
146aee2cecaSBarry Smith   PetscFunctionReturn(0);
147aee2cecaSBarry Smith }
148aee2cecaSBarry Smith 
149aee2cecaSBarry Smith #undef __FUNCT__
150aee2cecaSBarry Smith #define __FUNCT__ "PetscOptionsGetFromTextInput"
151aee2cecaSBarry Smith /*
1523cc1e11dSBarry Smith     PetscOptionsGetFromTextInput - Presents all the PETSc Options processed by the program so the user may change them at runtime
153aee2cecaSBarry Smith 
154aee2cecaSBarry Smith     Notes: this isn't really practical, it is just to demonstrate the principle
155aee2cecaSBarry Smith 
156aee2cecaSBarry Smith     Bugs:
157aee2cecaSBarry Smith +    All processes must traverse through the exact same set of option queries do to the call to PetscScanString()
1583cc1e11dSBarry Smith .    Internal strings have arbitrary length and string copies are not checked that they fit into string space
159aee2cecaSBarry Smith -    Only works for PetscInt == int, PetscReal == double etc
160aee2cecaSBarry Smith 
1613cc1e11dSBarry Smith     Developer Notes: Normally the GUI that presents the options the user and retrieves the values would be running in a different
1623cc1e11dSBarry Smith      address space and communicating with the PETSc program
1633cc1e11dSBarry Smith 
164aee2cecaSBarry Smith */
165aee2cecaSBarry Smith PetscErrorCode PetscOptionsGetFromTextInput()
1666356e834SBarry Smith {
1676356e834SBarry Smith   PetscErrorCode ierr;
1686356e834SBarry Smith   PetscOptions   next = PetscOptionsObject.next;
1696356e834SBarry Smith   char           str[512];
170a4404d99SBarry Smith   PetscInt       id;
171a4404d99SBarry Smith   PetscReal      ir,*valr;
172330cf3c9SBarry Smith   PetscInt       *vald;
173330cf3c9SBarry Smith   size_t         i;
1746356e834SBarry Smith 
175e26ddf31SBarry Smith   ierr = (*PetscPrintf)(PETSC_COMM_WORLD,"%s -------------------------------------------------\n",PetscOptionsObject.title);CHKERRQ(ierr);
1766356e834SBarry Smith   while (next) {
1776356e834SBarry Smith     switch (next->type) {
1786356e834SBarry Smith     case OPTION_HEAD:
1796356e834SBarry Smith       break;
180e26ddf31SBarry Smith     case OPTION_INT_ARRAY:
181e26ddf31SBarry Smith       ierr = PetscPrintf(PETSC_COMM_WORLD,"-%s%s <",PetscOptionsObject.prefix ? PetscOptionsObject.prefix : "",next->option+1);CHKERRQ(ierr);
182e26ddf31SBarry Smith       vald = (PetscInt*) next->data;
183e26ddf31SBarry Smith       for (i=0; i<next->arraylength; i++) {
184e26ddf31SBarry Smith         ierr = PetscPrintf(PETSC_COMM_WORLD,"%d",vald[i]);CHKERRQ(ierr);
185e26ddf31SBarry Smith         if (i < next->arraylength-1) {
186e26ddf31SBarry Smith           ierr = PetscPrintf(PETSC_COMM_WORLD,",");CHKERRQ(ierr);
187e26ddf31SBarry Smith         }
188e26ddf31SBarry Smith       }
189e26ddf31SBarry Smith       ierr = PetscPrintf(PETSC_COMM_WORLD,">: %s (%s)",next->text,next->man);CHKERRQ(ierr);
190e26ddf31SBarry Smith       ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr);
191e26ddf31SBarry Smith       if (str[0]) {
192e26ddf31SBarry Smith         PetscToken token;
193e26ddf31SBarry Smith         PetscInt   n=0,nmax = next->arraylength,*dvalue = (PetscInt*)next->data,start,end;
194e26ddf31SBarry Smith         size_t     len;
195e26ddf31SBarry Smith         char       *value;
196ace3abfcSBarry Smith         PetscBool  foundrange;
197e26ddf31SBarry Smith 
198e26ddf31SBarry Smith         next->set = PETSC_TRUE;
199e26ddf31SBarry Smith         value     = str;
200e26ddf31SBarry Smith         ierr      = PetscTokenCreate(value,',',&token);CHKERRQ(ierr);
201e26ddf31SBarry Smith         ierr      = PetscTokenFind(token,&value);CHKERRQ(ierr);
202e26ddf31SBarry Smith         while (n < nmax) {
203e26ddf31SBarry Smith           if (!value) break;
204e26ddf31SBarry Smith 
205e26ddf31SBarry Smith           /* look for form  d-D where d and D are integers */
206e26ddf31SBarry Smith           foundrange = PETSC_FALSE;
207e26ddf31SBarry Smith           ierr       = PetscStrlen(value,&len);CHKERRQ(ierr);
208e26ddf31SBarry Smith           if (value[0] == '-') i=2;
209e26ddf31SBarry Smith           else i=1;
210330cf3c9SBarry Smith           for (;i<len; i++) {
211e26ddf31SBarry Smith             if (value[i] == '-') {
212e32f2f54SBarry Smith               if (i == len-1) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_USER,"Error in %D-th array entry %s\n",n,value);
213e26ddf31SBarry Smith               value[i] = 0;
214cfbddea1SSatish Balay               ierr     = PetscOptionsStringToInt(value,&start);CHKERRQ(ierr);
215cfbddea1SSatish Balay               ierr     = PetscOptionsStringToInt(value+i+1,&end);CHKERRQ(ierr);
216e32f2f54SBarry Smith               if (end <= start) SETERRQ3(PETSC_COMM_SELF,PETSC_ERR_USER,"Error in %D-th array entry, %s-%s cannot have decreasing list",n,value,value+i+1);
217e32f2f54SBarry Smith               if (n + end - start - 1 >= nmax) SETERRQ4(PETSC_COMM_SELF,PETSC_ERR_USER,"Error in %D-th array entry, not enough space in left in array (%D) to contain entire range from %D to %D",n,nmax-n,start,end);
218e26ddf31SBarry Smith               for (; start<end; start++) {
219e26ddf31SBarry Smith                 *dvalue = start; dvalue++;n++;
220e26ddf31SBarry Smith               }
221e26ddf31SBarry Smith               foundrange = PETSC_TRUE;
222e26ddf31SBarry Smith               break;
223e26ddf31SBarry Smith             }
224e26ddf31SBarry Smith           }
225e26ddf31SBarry Smith           if (!foundrange) {
226cfbddea1SSatish Balay             ierr = PetscOptionsStringToInt(value,dvalue);CHKERRQ(ierr);
227e26ddf31SBarry Smith             dvalue++;
228e26ddf31SBarry Smith             n++;
229e26ddf31SBarry Smith           }
230e26ddf31SBarry Smith           ierr = PetscTokenFind(token,&value);CHKERRQ(ierr);
231e26ddf31SBarry Smith         }
2328c74ee41SBarry Smith         ierr = PetscTokenDestroy(&token);CHKERRQ(ierr);
233e26ddf31SBarry Smith       }
234e26ddf31SBarry Smith       break;
235e26ddf31SBarry Smith     case OPTION_REAL_ARRAY:
236e26ddf31SBarry Smith       ierr = PetscPrintf(PETSC_COMM_WORLD,"-%s%s <",PetscOptionsObject.prefix ? PetscOptionsObject.prefix : "",next->option+1);CHKERRQ(ierr);
237e26ddf31SBarry Smith       valr = (PetscReal*) next->data;
238e26ddf31SBarry Smith       for (i=0; i<next->arraylength; i++) {
239e26ddf31SBarry Smith         ierr = PetscPrintf(PETSC_COMM_WORLD,"%g",valr[i]);CHKERRQ(ierr);
240e26ddf31SBarry Smith         if (i < next->arraylength-1) {
241e26ddf31SBarry Smith           ierr = PetscPrintf(PETSC_COMM_WORLD,",");CHKERRQ(ierr);
242e26ddf31SBarry Smith         }
243e26ddf31SBarry Smith       }
244e26ddf31SBarry Smith       ierr = PetscPrintf(PETSC_COMM_WORLD,">: %s (%s)",next->text,next->man);CHKERRQ(ierr);
245e26ddf31SBarry Smith       ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr);
246e26ddf31SBarry Smith       if (str[0]) {
247e26ddf31SBarry Smith         PetscToken token;
248e26ddf31SBarry Smith         PetscInt   n = 0,nmax = next->arraylength;
249e26ddf31SBarry Smith         PetscReal  *dvalue = (PetscReal*)next->data;
250e26ddf31SBarry Smith         char       *value;
251e26ddf31SBarry Smith 
252e26ddf31SBarry Smith         next->set = PETSC_TRUE;
253e26ddf31SBarry Smith         value     = str;
254e26ddf31SBarry Smith         ierr      = PetscTokenCreate(value,',',&token);CHKERRQ(ierr);
255e26ddf31SBarry Smith         ierr      = PetscTokenFind(token,&value);CHKERRQ(ierr);
256e26ddf31SBarry Smith         while (n < nmax) {
257e26ddf31SBarry Smith           if (!value) break;
258cfbddea1SSatish Balay           ierr = PetscOptionsStringToReal(value,dvalue);CHKERRQ(ierr);
259e26ddf31SBarry Smith           dvalue++;
260e26ddf31SBarry Smith           n++;
261e26ddf31SBarry Smith           ierr = PetscTokenFind(token,&value);CHKERRQ(ierr);
262e26ddf31SBarry Smith         }
2638c74ee41SBarry Smith         ierr = PetscTokenDestroy(&token);CHKERRQ(ierr);
264e26ddf31SBarry Smith       }
265e26ddf31SBarry Smith       break;
2666356e834SBarry Smith     case OPTION_INT:
267e26ddf31SBarry Smith       ierr = PetscPrintf(PETSC_COMM_WORLD,"-%s%s <%d>: %s (%s)",PetscOptionsObject.prefix ? PetscOptionsObject.prefix : "",next->option+1,*(int*)next->data,next->text,next->man);CHKERRQ(ierr);
2683fc1eb6aSBarry Smith       ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr);
2693fc1eb6aSBarry Smith       if (str[0]) {
270c272547aSJed Brown #if defined(PETSC_USE_64BIT_INDICES)
271c272547aSJed Brown         sscanf(str,"%lld",&id);
272c272547aSJed Brown #else
273aee2cecaSBarry Smith         sscanf(str,"%d",&id);
274c272547aSJed Brown #endif
275aee2cecaSBarry Smith         next->set = PETSC_TRUE;
276a297a907SKarl Rupp 
277aee2cecaSBarry Smith         *((PetscInt*)next->data) = id;
278aee2cecaSBarry Smith       }
279aee2cecaSBarry Smith       break;
280aee2cecaSBarry Smith     case OPTION_REAL:
281e26ddf31SBarry Smith       ierr = PetscPrintf(PETSC_COMM_WORLD,"-%s%s <%g>: %s (%s)",PetscOptionsObject.prefix ? PetscOptionsObject.prefix : "",next->option+1,*(double*)next->data,next->text,next->man);CHKERRQ(ierr);
2823fc1eb6aSBarry Smith       ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr);
2833fc1eb6aSBarry Smith       if (str[0]) {
284ce63c4c1SBarry Smith #if defined(PETSC_USE_REAL_SINGLE)
285a4404d99SBarry Smith         sscanf(str,"%e",&ir);
286ce63c4c1SBarry Smith #elif defined(PETSC_USE_REAL_DOUBLE)
287aee2cecaSBarry Smith         sscanf(str,"%le",&ir);
288ce63c4c1SBarry Smith #elif defined(PETSC_USE_REAL___FLOAT128)
289d9822059SBarry Smith         ir = strtoflt128(str,0);
290d9822059SBarry Smith #else
291513dbe71SLisandro Dalcin         SETERRQ(PETSC_COMM_SELF,PETSC_ERR_LIB,"Unknown scalar type");
292a4404d99SBarry Smith #endif
293aee2cecaSBarry Smith         next->set                 = PETSC_TRUE;
294aee2cecaSBarry Smith         *((PetscReal*)next->data) = ir;
295aee2cecaSBarry Smith       }
296aee2cecaSBarry Smith       break;
297aee2cecaSBarry Smith     case OPTION_LOGICAL:
298aee2cecaSBarry Smith     case OPTION_STRING:
299e26ddf31SBarry Smith       ierr = PetscPrintf(PETSC_COMM_WORLD,"-%s%s <%s>: %s (%s)",PetscOptionsObject.prefix ? PetscOptionsObject.prefix : "",next->option+1,(char*)next->data,next->text,next->man);CHKERRQ(ierr);
3003fc1eb6aSBarry Smith       ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr);
3013fc1eb6aSBarry Smith       if (str[0]) {
302aee2cecaSBarry Smith         next->set = PETSC_TRUE;
303a297a907SKarl Rupp 
304*475446a1SBarry Smith         ierr = PetscStrallocpy(str,(char**)&next->data);CHKERRQ(ierr);
3056356e834SBarry Smith       }
3066356e834SBarry Smith       break;
3073cc1e11dSBarry Smith     case OPTION_LIST:
308140e18c1SBarry Smith       ierr = PetscFunctionListPrintTypes(PETSC_COMM_WORLD,stdout,PetscOptionsObject.prefix,next->option,next->text,next->man,next->flist,(char*)next->data);CHKERRQ(ierr);
3093cc1e11dSBarry Smith       ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr);
3103cc1e11dSBarry Smith       if (str[0]) {
3113cc1e11dSBarry Smith         PetscOptionsObject.changedmethod = PETSC_TRUE;
3123cc1e11dSBarry Smith         next->set = PETSC_TRUE;
313*475446a1SBarry Smith         ierr = PetscStrallocpy(str,(char**)&next->data);CHKERRQ(ierr);
3143cc1e11dSBarry Smith       }
3153cc1e11dSBarry Smith       break;
316b432afdaSMatthew Knepley     default:
317b432afdaSMatthew Knepley       break;
3186356e834SBarry Smith     }
3196356e834SBarry Smith     next = next->next;
3206356e834SBarry Smith   }
3216356e834SBarry Smith   PetscFunctionReturn(0);
3226356e834SBarry Smith }
3236356e834SBarry Smith 
324e04113cfSBarry Smith #if defined(PETSC_HAVE_SAWS)
325e04113cfSBarry Smith #include <petscviewersaws.h>
326d5649816SBarry Smith 
327d5649816SBarry Smith static int count = 0;
328d5649816SBarry Smith 
329b3506946SBarry Smith #undef __FUNCT__
330e04113cfSBarry Smith #define __FUNCT__ "PetscOptionsSAWsDestroy"
331e04113cfSBarry Smith PetscErrorCode PetscOptionsSAWsDestroy(void)
332d5649816SBarry Smith {
3332657e9d9SBarry Smith   PetscFunctionBegin;
334d5649816SBarry Smith   PetscFunctionReturn(0);
335d5649816SBarry Smith }
336d5649816SBarry Smith 
337d5649816SBarry Smith #undef __FUNCT__
338d5649816SBarry Smith #define __FUNCT__ "PetscOptionsAMSInput"
339b3506946SBarry Smith /*
340d5649816SBarry Smith     PetscOptionsAMSInput - Presents all the PETSc Options processed by the program so the user may change them at runtime using the AMS
341b3506946SBarry Smith 
342b3506946SBarry Smith     Bugs:
343b3506946SBarry Smith +    All processes must traverse through the exact same set of option queries do to the call to PetscScanString()
344b3506946SBarry Smith .    Internal strings have arbitrary length and string copies are not checked that they fit into string space
345b3506946SBarry Smith -    Only works for PetscInt == int, PetscReal == double etc
346b3506946SBarry Smith 
347b3506946SBarry Smith 
348b3506946SBarry Smith */
349*475446a1SBarry Smith PetscErrorCode PetscOptionsSAWsInput()
350b3506946SBarry Smith {
351b3506946SBarry Smith   PetscErrorCode ierr;
352b3506946SBarry Smith   PetscOptions   next     = PetscOptionsObject.next;
353d5649816SBarry Smith   static int     mancount = 0;
354b3506946SBarry Smith   char           options[16];
355ace3abfcSBarry Smith   PetscBool      changedmethod = PETSC_FALSE;
3569f32e415SBarry Smith   char           manname[16];
3572657e9d9SBarry Smith   char           dir[1024];
358b3506946SBarry Smith 
359b3506946SBarry Smith   /* the next line is a bug, this will only work if all processors are here, the comm passed in is ignored!!! */
360b3506946SBarry Smith   sprintf(options,"Options_%d",count++);
361a297a907SKarl Rupp 
362e04113cfSBarry Smith   PetscOptionsObject.pprefix = PetscOptionsObject.prefix; /* SAWs will change this, so cannot pass prefix directly */
3631bc75a8dSBarry Smith 
3642657e9d9SBarry Smith   ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",PetscOptionsObject.title);CHKERRQ(ierr);
3652657e9d9SBarry Smith   PetscStackCallSAWs(SAWs_Register,(dir,&PetscOptionsObject.pprefix,1,SAWs_READ,SAWs_STRING));
3662657e9d9SBarry Smith   PetscStackCallSAWs(SAWs_Register,("/PETSc/Options/ChangedMethod",&changedmethod,1,SAWs_WRITE,SAWs_BOOLEAN));
367b3506946SBarry Smith 
368b3506946SBarry Smith   while (next) {
3692657e9d9SBarry Smith     ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr);
3702657e9d9SBarry Smith     PetscStackCallSAWs(SAWs_Register,(dir,&next->set,1,SAWs_WRITE,SAWs_INT));
3711bc75a8dSBarry Smith     ierr =  PetscMalloc(sizeof(char*),&next->pman);CHKERRQ(ierr);
372a297a907SKarl Rupp 
3731bc75a8dSBarry Smith     *(char**)next->pman = next->man;
3749f32e415SBarry Smith     sprintf(manname,"man_%d",mancount++);
3752657e9d9SBarry Smith     ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",manname);CHKERRQ(ierr);
3762657e9d9SBarry Smith     PetscStackCallSAWs(SAWs_Register,(dir,next->pman,1,SAWs_READ,SAWs_STRING));
3779f32e415SBarry Smith 
378b3506946SBarry Smith     switch (next->type) {
379b3506946SBarry Smith     case OPTION_HEAD:
380b3506946SBarry Smith       break;
381b3506946SBarry Smith     case OPTION_INT_ARRAY:
3822657e9d9SBarry Smith     ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->text);CHKERRQ(ierr);
3832657e9d9SBarry Smith       PetscStackCallSAWs(SAWs_Register,(dir,next->data,next->arraylength,SAWs_WRITE,SAWs_INT));
384b3506946SBarry Smith       break;
385b3506946SBarry Smith     case OPTION_REAL_ARRAY:
3862657e9d9SBarry Smith     ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->text);CHKERRQ(ierr);
3872657e9d9SBarry Smith       PetscStackCallSAWs(SAWs_Register,(dir,next->data,next->arraylength,SAWs_WRITE,SAWs_DOUBLE));
388b3506946SBarry Smith       break;
389b3506946SBarry Smith     case OPTION_INT:
3902657e9d9SBarry Smith     ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->text);CHKERRQ(ierr);
3912657e9d9SBarry Smith       PetscStackCallSAWs(SAWs_Register,(dir,next->data,1,SAWs_WRITE,SAWs_INT));
392b3506946SBarry Smith       break;
393b3506946SBarry Smith     case OPTION_REAL:
3942657e9d9SBarry Smith     ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->text);CHKERRQ(ierr);
3952657e9d9SBarry Smith       PetscStackCallSAWs(SAWs_Register,(dir,next->data,1,SAWs_WRITE,SAWs_DOUBLE));
396b3506946SBarry Smith       break;
397b3506946SBarry Smith     case OPTION_LOGICAL:
3982657e9d9SBarry Smith     ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->text);CHKERRQ(ierr);
3992657e9d9SBarry Smith       PetscStackCallSAWs(SAWs_Register,(dir,next->data,1,SAWs_WRITE,SAWs_BOOLEAN));
4001ae3d29cSBarry Smith       break;
4011ae3d29cSBarry Smith     case OPTION_LOGICAL_ARRAY:
4022657e9d9SBarry Smith     ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->text);CHKERRQ(ierr);
4032657e9d9SBarry Smith       PetscStackCallSAWs(SAWs_Register,(dir,next->data,next->arraylength,SAWs_WRITE,SAWs_BOOLEAN));
40471f08665SBarry Smith       break;
405b3506946SBarry Smith     case OPTION_STRING:
4062657e9d9SBarry Smith     ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->text);CHKERRQ(ierr);
4072657e9d9SBarry Smith       PetscStackCallSAWs(SAWs_Register,(dir,next->data,1,SAWs_WRITE,SAWs_STRING));
4081ae3d29cSBarry Smith       break;
4091ae3d29cSBarry Smith     case OPTION_STRING_ARRAY:
4102657e9d9SBarry Smith     ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->text);CHKERRQ(ierr);
4112657e9d9SBarry Smith       PetscStackCallSAWs(SAWs_Register,(dir,next->data,next->arraylength,SAWs_WRITE,SAWs_STRING));
412b3506946SBarry Smith       break;
413b3506946SBarry Smith     case OPTION_LIST:
41471f08665SBarry Smith       {PetscInt ntext;
41571f08665SBarry Smith       char      ldefault[128];
41671f08665SBarry Smith       ierr = PetscStrcpy(ldefault,"DEFAULT:");CHKERRQ(ierr);
41771f08665SBarry Smith       ierr = PetscStrcat(ldefault,next->text);CHKERRQ(ierr);
4182657e9d9SBarry Smith       ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",ldefault);CHKERRQ(ierr);
4192657e9d9SBarry Smith       PetscStackCallSAWs(SAWs_Register,(dir,next->data,1,SAWs_WRITE,SAWs_STRING));
420140e18c1SBarry Smith       ierr = PetscFunctionListGet(next->flist,(const char***)&next->edata,&ntext);CHKERRQ(ierr);
4212657e9d9SBarry Smith       ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->text);CHKERRQ(ierr);
4222657e9d9SBarry Smith       PetscStackCallSAWs(SAWs_Register,(dir,next->edata,ntext-1,SAWs_WRITE,SAWs_STRING));
4231ae3d29cSBarry Smith       break;}
4241ae3d29cSBarry Smith     case OPTION_ELIST:
425d5649816SBarry Smith       {PetscInt ntext = next->nlist;
4261ae3d29cSBarry Smith       char      ldefault[128];
4271ae3d29cSBarry Smith       ierr = PetscStrcpy(ldefault,"DEFAULT:");CHKERRQ(ierr);
4281ae3d29cSBarry Smith       ierr = PetscStrcat(ldefault,next->text);CHKERRQ(ierr);
4292657e9d9SBarry Smith       ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",ldefault);CHKERRQ(ierr);
4302657e9d9SBarry Smith       PetscStackCallSAWs(SAWs_Register,(dir,next->data,1,SAWs_WRITE,SAWs_STRING));
4311ae3d29cSBarry Smith       ierr = PetscMalloc((ntext+1)*sizeof(char**),&next->edata);CHKERRQ(ierr);
4321ae3d29cSBarry Smith       ierr = PetscMemcpy(next->edata,next->list,ntext*sizeof(char*));CHKERRQ(ierr);
4332657e9d9SBarry Smith       ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->text);CHKERRQ(ierr);
4342657e9d9SBarry Smith       PetscStackCallSAWs(SAWs_Register,(dir,next->edata,ntext,SAWs_WRITE,SAWs_STRING));
43571f08665SBarry Smith       break;}
436b3506946SBarry Smith     default:
437b3506946SBarry Smith       break;
438b3506946SBarry Smith     }
439b3506946SBarry Smith     next = next->next;
440b3506946SBarry Smith   }
441b3506946SBarry Smith 
442b3506946SBarry Smith   /* wait until accessor has unlocked the memory */
4439a492a5cSBarry Smith   PetscStackCallSAWs(SAWs_Lock,());
444b3506946SBarry Smith 
445b3506946SBarry Smith   /* reset counter to -2; this updates the screen with the new options for the selected method */
446b3506946SBarry Smith   if (changedmethod) PetscOptionsPublishCount = -2;
447b3506946SBarry Smith 
4489a492a5cSBarry Smith   PetscStackCallSAWs(SAWs_Unlock,());
4499a492a5cSBarry Smith   PetscStackCallSAWs(SAWs_Delete,("/PETSc/Options"));
450b3506946SBarry Smith   PetscFunctionReturn(0);
451b3506946SBarry Smith }
452b3506946SBarry Smith #endif
453b3506946SBarry Smith 
4546356e834SBarry Smith #undef __FUNCT__
45553acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsEnd_Private"
45653acd3b1SBarry Smith PetscErrorCode PetscOptionsEnd_Private(void)
45753acd3b1SBarry Smith {
45853acd3b1SBarry Smith   PetscErrorCode ierr;
4596356e834SBarry Smith   PetscOptions   last;
4606356e834SBarry Smith   char           option[256],value[1024],tmp[32];
461330cf3c9SBarry Smith   size_t         j;
46253acd3b1SBarry Smith 
46353acd3b1SBarry Smith   PetscFunctionBegin;
464aee2cecaSBarry Smith   if (PetscOptionsObject.next) {
465b3506946SBarry Smith     if (!PetscOptionsPublishCount) {
466*475446a1SBarry Smith #if defined(PETSC_HAVE_SAWS) && defined(foo)
467*475446a1SBarry Smith       ierr = PetscOptionsSAWsInput();CHKERRQ(ierr);
468b3506946SBarry Smith #else
46971f08665SBarry Smith       ierr = PetscOptionsGetFromTextInput();CHKERRQ(ierr);
470b3506946SBarry Smith #endif
471aee2cecaSBarry Smith     }
472aee2cecaSBarry Smith   }
4736356e834SBarry Smith 
474c31cb41cSBarry Smith   ierr = PetscFree(PetscOptionsObject.title);CHKERRQ(ierr);
475c31cb41cSBarry Smith   ierr = PetscFree(PetscOptionsObject.prefix);CHKERRQ(ierr);
4766356e834SBarry Smith 
4776356e834SBarry Smith   /* reset counter to -2; this updates the screen with the new options for the selected method */
4786356e834SBarry Smith   if (PetscOptionsObject.changedmethod) PetscOptionsPublishCount = -2;
47961b37b28SSatish Balay   /* reset alreadyprinted flag */
48061b37b28SSatish Balay   PetscOptionsObject.alreadyprinted = PETSC_FALSE;
4813194b578SJed Brown   if (PetscOptionsObject.object) PetscOptionsObject.object->optionsprinted = PETSC_TRUE;
4820298fd71SBarry Smith   PetscOptionsObject.object = NULL;
4836356e834SBarry Smith 
4846356e834SBarry Smith   while (PetscOptionsObject.next) {
4856356e834SBarry Smith     if (PetscOptionsObject.next->set) {
4866356e834SBarry Smith       if (PetscOptionsObject.prefix) {
4876356e834SBarry Smith         ierr = PetscStrcpy(option,"-");CHKERRQ(ierr);
4886356e834SBarry Smith         ierr = PetscStrcat(option,PetscOptionsObject.prefix);CHKERRQ(ierr);
4896356e834SBarry Smith         ierr = PetscStrcat(option,PetscOptionsObject.next->option+1);CHKERRQ(ierr);
4906356e834SBarry Smith       } else {
4916356e834SBarry Smith         ierr = PetscStrcpy(option,PetscOptionsObject.next->option);CHKERRQ(ierr);
4926356e834SBarry Smith       }
4936356e834SBarry Smith 
4946356e834SBarry Smith       switch (PetscOptionsObject.next->type) {
4956356e834SBarry Smith       case OPTION_HEAD:
4966356e834SBarry Smith         break;
497e26ddf31SBarry Smith       case OPTION_INT_ARRAY:
498e26ddf31SBarry Smith         sprintf(value,"%d",(int)((PetscInt*)PetscOptionsObject.next->data)[0]);
499e26ddf31SBarry Smith         for (j=1; j<PetscOptionsObject.next->arraylength; j++) {
500e26ddf31SBarry Smith           sprintf(tmp,"%d",(int)((PetscInt*)PetscOptionsObject.next->data)[j]);
501e26ddf31SBarry Smith           ierr = PetscStrcat(value,",");CHKERRQ(ierr);
502e26ddf31SBarry Smith           ierr = PetscStrcat(value,tmp);CHKERRQ(ierr);
503e26ddf31SBarry Smith         }
504e26ddf31SBarry Smith         break;
5056356e834SBarry Smith       case OPTION_INT:
5067a72a596SBarry Smith         sprintf(value,"%d",(int) *(PetscInt*)PetscOptionsObject.next->data);
5076356e834SBarry Smith         break;
5086356e834SBarry Smith       case OPTION_REAL:
5097a72a596SBarry Smith         sprintf(value,"%g",(double) *(PetscReal*)PetscOptionsObject.next->data);
5106356e834SBarry Smith         break;
5116356e834SBarry Smith       case OPTION_REAL_ARRAY:
5127a72a596SBarry Smith         sprintf(value,"%g",(double)((PetscReal*)PetscOptionsObject.next->data)[0]);
5136356e834SBarry Smith         for (j=1; j<PetscOptionsObject.next->arraylength; j++) {
5147a72a596SBarry Smith           sprintf(tmp,"%g",(double)((PetscReal*)PetscOptionsObject.next->data)[j]);
5156356e834SBarry Smith           ierr = PetscStrcat(value,",");CHKERRQ(ierr);
5166356e834SBarry Smith           ierr = PetscStrcat(value,tmp);CHKERRQ(ierr);
5176356e834SBarry Smith         }
5186356e834SBarry Smith         break;
5196356e834SBarry Smith       case OPTION_LOGICAL:
52071f08665SBarry Smith         sprintf(value,"%d",*(int*)PetscOptionsObject.next->data);
5216356e834SBarry Smith         break;
5221ae3d29cSBarry Smith       case OPTION_LOGICAL_ARRAY:
523ace3abfcSBarry Smith         sprintf(value,"%d",(int)((PetscBool*)PetscOptionsObject.next->data)[0]);
5241ae3d29cSBarry Smith         for (j=1; j<PetscOptionsObject.next->arraylength; j++) {
525ace3abfcSBarry Smith           sprintf(tmp,"%d",(int)((PetscBool*)PetscOptionsObject.next->data)[j]);
5261ae3d29cSBarry Smith           ierr = PetscStrcat(value,",");CHKERRQ(ierr);
5271ae3d29cSBarry Smith           ierr = PetscStrcat(value,tmp);CHKERRQ(ierr);
5281ae3d29cSBarry Smith         }
5291ae3d29cSBarry Smith         break;
5306356e834SBarry Smith       case OPTION_LIST:
5311ae3d29cSBarry Smith       case OPTION_ELIST:
53271f08665SBarry Smith         ierr = PetscStrcpy(value,*(char**)PetscOptionsObject.next->data);CHKERRQ(ierr);
5336356e834SBarry Smith         break;
5341ae3d29cSBarry Smith       case OPTION_STRING:
535*475446a1SBarry Smith         ierr = PetscStrcpy(value,(char*)PetscOptionsObject.next->data);CHKERRQ(ierr);
5361ae3d29cSBarry Smith       case OPTION_STRING_ARRAY:
5371ae3d29cSBarry Smith         sprintf(value,"%s",((char**)PetscOptionsObject.next->data)[0]);
5381ae3d29cSBarry Smith         for (j=1; j<PetscOptionsObject.next->arraylength; j++) {
5391ae3d29cSBarry Smith           sprintf(tmp,"%s",((char**)PetscOptionsObject.next->data)[j]);
5401ae3d29cSBarry Smith           ierr = PetscStrcat(value,",");CHKERRQ(ierr);
5411ae3d29cSBarry Smith           ierr = PetscStrcat(value,tmp);CHKERRQ(ierr);
5421ae3d29cSBarry Smith         }
5436356e834SBarry Smith         break;
5446356e834SBarry Smith       }
5456356e834SBarry Smith       ierr = PetscOptionsSetValue(option,value);CHKERRQ(ierr);
5466356e834SBarry Smith     }
547503cfb0cSBarry Smith     ierr   = PetscFree(PetscOptionsObject.next->text);CHKERRQ(ierr);
548503cfb0cSBarry Smith     ierr   = PetscFree(PetscOptionsObject.next->option);CHKERRQ(ierr);
5496356e834SBarry Smith     ierr   = PetscFree(PetscOptionsObject.next->man);CHKERRQ(ierr);
55005b42c5fSBarry Smith     ierr   = PetscFree(PetscOptionsObject.next->data);CHKERRQ(ierr);
55171f08665SBarry Smith     ierr   = PetscFree(PetscOptionsObject.next->edata);CHKERRQ(ierr);
552a297a907SKarl Rupp 
5536356e834SBarry Smith     last                    = PetscOptionsObject.next;
5546356e834SBarry Smith     PetscOptionsObject.next = PetscOptionsObject.next->next;
5556356e834SBarry Smith     ierr                    = PetscFree(last);CHKERRQ(ierr);
5566356e834SBarry Smith   }
5576356e834SBarry Smith   PetscOptionsObject.next = 0;
55853acd3b1SBarry Smith   PetscFunctionReturn(0);
55953acd3b1SBarry Smith }
56053acd3b1SBarry Smith 
56153acd3b1SBarry Smith #undef __FUNCT__
56253acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsEnum"
56353acd3b1SBarry Smith /*@C
56453acd3b1SBarry Smith    PetscOptionsEnum - Gets the enum value for a particular option in the database.
56553acd3b1SBarry Smith 
5663f9fe445SBarry Smith    Logically Collective on the communicator passed in PetscOptionsBegin()
56753acd3b1SBarry Smith 
56853acd3b1SBarry Smith    Input Parameters:
56953acd3b1SBarry Smith +  opt - option name
57053acd3b1SBarry Smith .  text - short string that describes the option
57153acd3b1SBarry Smith .  man - manual page with additional information on option
57253acd3b1SBarry Smith .  list - array containing the list of choices, followed by the enum name, followed by the enum prefix, followed by a null
57353acd3b1SBarry Smith -  defaultv - the default (current) value
57453acd3b1SBarry Smith 
57553acd3b1SBarry Smith    Output Parameter:
57653acd3b1SBarry Smith +  value - the  value to return
577b32e0204SMatthew G Knepley -  set - PETSC_TRUE if found, else PETSC_FALSE
57853acd3b1SBarry Smith 
57953acd3b1SBarry Smith    Level: beginner
58053acd3b1SBarry Smith 
58153acd3b1SBarry Smith    Concepts: options database
58253acd3b1SBarry Smith 
58353acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
58453acd3b1SBarry Smith 
58553acd3b1SBarry Smith           list is usually something like PCASMTypes or some other predefined list of enum names
58653acd3b1SBarry Smith 
58753acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
588acfcf0e5SJed Brown           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool()
589acfcf0e5SJed Brown           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(),
59053acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
59153acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
592acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
59353acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
59453acd3b1SBarry Smith @*/
5957087cfbeSBarry Smith PetscErrorCode  PetscOptionsEnum(const char opt[],const char text[],const char man[],const char *const *list,PetscEnum defaultv,PetscEnum *value,PetscBool  *set)
59653acd3b1SBarry Smith {
59753acd3b1SBarry Smith   PetscErrorCode ierr;
59853acd3b1SBarry Smith   PetscInt       ntext = 0;
599aa5bb8c0SSatish Balay   PetscInt       tval;
600ace3abfcSBarry Smith   PetscBool      tflg;
60153acd3b1SBarry Smith 
60253acd3b1SBarry Smith   PetscFunctionBegin;
60353acd3b1SBarry Smith   while (list[ntext++]) {
604e32f2f54SBarry Smith     if (ntext > 50) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"List argument appears to be wrong or have more than 50 entries");
60553acd3b1SBarry Smith   }
606e32f2f54SBarry Smith   if (ntext < 3) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"List argument must have at least two entries: typename and type prefix");
60753acd3b1SBarry Smith   ntext -= 3;
608aa5bb8c0SSatish Balay   ierr   = PetscOptionsEList(opt,text,man,list,ntext,list[defaultv],&tval,&tflg);CHKERRQ(ierr);
609aa5bb8c0SSatish Balay   /* with PETSC_USE_64BIT_INDICES sizeof(PetscInt) != sizeof(PetscEnum) */
610aa5bb8c0SSatish Balay   if (tflg) *value = (PetscEnum)tval;
611aa5bb8c0SSatish Balay   if (set)  *set   = tflg;
61253acd3b1SBarry Smith   PetscFunctionReturn(0);
61353acd3b1SBarry Smith }
61453acd3b1SBarry Smith 
61553acd3b1SBarry Smith /* -------------------------------------------------------------------------------------------------------------*/
61653acd3b1SBarry Smith #undef __FUNCT__
61753acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsInt"
61853acd3b1SBarry Smith /*@C
61953acd3b1SBarry Smith    PetscOptionsInt - Gets the integer value for a particular option in the database.
62053acd3b1SBarry Smith 
6213f9fe445SBarry Smith    Logically 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 -  defaultv - the default (current) value
62853acd3b1SBarry Smith 
62953acd3b1SBarry Smith    Output Parameter:
63053acd3b1SBarry Smith +  value - the integer value to return
63153acd3b1SBarry Smith -  flg - PETSC_TRUE if found, else PETSC_FALSE
63253acd3b1SBarry Smith 
63353acd3b1SBarry Smith    Level: beginner
63453acd3b1SBarry Smith 
63553acd3b1SBarry Smith    Concepts: options database^has int
63653acd3b1SBarry Smith 
63753acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
63853acd3b1SBarry Smith 
63953acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
640acfcf0e5SJed Brown           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool()
641acfcf0e5SJed Brown           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(),
64253acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
64353acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
644acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
64553acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
64653acd3b1SBarry Smith @*/
6477087cfbeSBarry Smith PetscErrorCode  PetscOptionsInt(const char opt[],const char text[],const char man[],PetscInt defaultv,PetscInt *value,PetscBool  *set)
64853acd3b1SBarry Smith {
64953acd3b1SBarry Smith   PetscErrorCode ierr;
6506356e834SBarry Smith   PetscOptions   amsopt;
65153acd3b1SBarry Smith 
65253acd3b1SBarry Smith   PetscFunctionBegin;
653b3506946SBarry Smith   if (!PetscOptionsPublishCount) {
6546356e834SBarry Smith     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_INT,&amsopt);CHKERRQ(ierr);
6556356e834SBarry Smith     ierr = PetscMalloc(sizeof(PetscInt),&amsopt->data);CHKERRQ(ierr);
656a297a907SKarl Rupp 
6576356e834SBarry Smith     *(PetscInt*)amsopt->data = defaultv;
658af6d86caSBarry Smith   }
65953acd3b1SBarry Smith   ierr = PetscOptionsGetInt(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr);
66061b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
6612aa6d131SJed Brown     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%d>: %s (%s)\n",PetscOptionsObject.prefix ? PetscOptionsObject.prefix : "",opt+1,defaultv,text,ManSection(man));CHKERRQ(ierr);
66253acd3b1SBarry Smith   }
66353acd3b1SBarry Smith   PetscFunctionReturn(0);
66453acd3b1SBarry Smith }
66553acd3b1SBarry Smith 
66653acd3b1SBarry Smith #undef __FUNCT__
66753acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsString"
66853acd3b1SBarry Smith /*@C
66953acd3b1SBarry Smith    PetscOptionsString - Gets the string value for a particular option in the database.
67053acd3b1SBarry Smith 
6713f9fe445SBarry Smith    Logically Collective on the communicator passed in PetscOptionsBegin()
67253acd3b1SBarry Smith 
67353acd3b1SBarry Smith    Input Parameters:
67453acd3b1SBarry Smith +  opt - option name
67553acd3b1SBarry Smith .  text - short string that describes the option
67653acd3b1SBarry Smith .  man - manual page with additional information on option
677bcbf2dc5SJed Brown .  defaultv - the default (current) value
678bcbf2dc5SJed Brown -  len - length of the result string including null terminator
67953acd3b1SBarry Smith 
68053acd3b1SBarry Smith    Output Parameter:
68153acd3b1SBarry Smith +  value - the value to return
68253acd3b1SBarry Smith -  flg - PETSC_TRUE if found, else PETSC_FALSE
68353acd3b1SBarry Smith 
68453acd3b1SBarry Smith    Level: beginner
68553acd3b1SBarry Smith 
68653acd3b1SBarry Smith    Concepts: options database^has int
68753acd3b1SBarry Smith 
68853acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
68953acd3b1SBarry Smith 
6907fccdfe4SBarry Smith    Even if the user provided no string (for example -optionname -someotheroption) the flag is set to PETSC_TRUE (and the string is fulled with nulls).
6917fccdfe4SBarry Smith 
69253acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
693acfcf0e5SJed Brown           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool()
694acfcf0e5SJed Brown           PetscOptionsInt(), PetscOptionsReal(), PetscOptionsBool(),
69553acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
69653acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
697acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
69853acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
69953acd3b1SBarry Smith @*/
7007087cfbeSBarry Smith PetscErrorCode  PetscOptionsString(const char opt[],const char text[],const char man[],const char defaultv[],char value[],size_t len,PetscBool  *set)
70153acd3b1SBarry Smith {
70253acd3b1SBarry Smith   PetscErrorCode ierr;
703aee2cecaSBarry Smith   PetscOptions   amsopt;
70453acd3b1SBarry Smith 
70553acd3b1SBarry Smith   PetscFunctionBegin;
706b3506946SBarry Smith   if (!PetscOptionsPublishCount) {
707aee2cecaSBarry Smith     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_STRING,&amsopt);CHKERRQ(ierr);
708*475446a1SBarry Smith     ierr = PetscStrallocpy(defaultv,(char**)&amsopt->data);CHKERRQ(ierr);
709af6d86caSBarry Smith   }
71053acd3b1SBarry Smith   ierr = PetscOptionsGetString(PetscOptionsObject.prefix,opt,value,len,set);CHKERRQ(ierr);
71161b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
7122aa6d131SJed Brown     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%s>: %s (%s)\n",PetscOptionsObject.prefix ? PetscOptionsObject.prefix : "",opt+1,defaultv,text,ManSection(man));CHKERRQ(ierr);
71353acd3b1SBarry Smith   }
71453acd3b1SBarry Smith   PetscFunctionReturn(0);
71553acd3b1SBarry Smith }
71653acd3b1SBarry Smith 
71753acd3b1SBarry Smith #undef __FUNCT__
71853acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsReal"
71953acd3b1SBarry Smith /*@C
72053acd3b1SBarry Smith    PetscOptionsReal - Gets the PetscReal value for a particular option in the database.
72153acd3b1SBarry Smith 
7223f9fe445SBarry Smith    Logically Collective on the communicator passed in PetscOptionsBegin()
72353acd3b1SBarry Smith 
72453acd3b1SBarry Smith    Input Parameters:
72553acd3b1SBarry Smith +  opt - option name
72653acd3b1SBarry Smith .  text - short string that describes the option
72753acd3b1SBarry Smith .  man - manual page with additional information on option
72853acd3b1SBarry Smith -  defaultv - the default (current) value
72953acd3b1SBarry Smith 
73053acd3b1SBarry Smith    Output Parameter:
73153acd3b1SBarry Smith +  value - the value to return
73253acd3b1SBarry Smith -  flg - PETSC_TRUE if found, else PETSC_FALSE
73353acd3b1SBarry Smith 
73453acd3b1SBarry Smith    Level: beginner
73553acd3b1SBarry Smith 
73653acd3b1SBarry Smith    Concepts: options database^has int
73753acd3b1SBarry Smith 
73853acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
73953acd3b1SBarry Smith 
74053acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
741acfcf0e5SJed Brown           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool()
742acfcf0e5SJed Brown           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(),
74353acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
74453acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
745acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
74653acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
74753acd3b1SBarry Smith @*/
7487087cfbeSBarry Smith PetscErrorCode  PetscOptionsReal(const char opt[],const char text[],const char man[],PetscReal defaultv,PetscReal *value,PetscBool  *set)
74953acd3b1SBarry Smith {
75053acd3b1SBarry Smith   PetscErrorCode ierr;
751538aa990SBarry Smith   PetscOptions   amsopt;
75253acd3b1SBarry Smith 
75353acd3b1SBarry Smith   PetscFunctionBegin;
754b3506946SBarry Smith   if (!PetscOptionsPublishCount) {
755538aa990SBarry Smith     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_REAL,&amsopt);CHKERRQ(ierr);
756538aa990SBarry Smith     ierr = PetscMalloc(sizeof(PetscReal),&amsopt->data);CHKERRQ(ierr);
757a297a907SKarl Rupp 
758538aa990SBarry Smith     *(PetscReal*)amsopt->data = defaultv;
759538aa990SBarry Smith   }
76053acd3b1SBarry Smith   ierr = PetscOptionsGetReal(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr);
76161b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
7622aa6d131SJed Brown     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%G>: %s (%s)\n",PetscOptionsObject.prefix ? PetscOptionsObject.prefix : "",opt+1,defaultv,text,ManSection(man));CHKERRQ(ierr);
76353acd3b1SBarry Smith   }
76453acd3b1SBarry Smith   PetscFunctionReturn(0);
76553acd3b1SBarry Smith }
76653acd3b1SBarry Smith 
76753acd3b1SBarry Smith #undef __FUNCT__
76853acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsScalar"
76953acd3b1SBarry Smith /*@C
77053acd3b1SBarry Smith    PetscOptionsScalar - Gets the scalar value for a particular option in the database.
77153acd3b1SBarry Smith 
7723f9fe445SBarry Smith    Logically Collective on the communicator passed in PetscOptionsBegin()
77353acd3b1SBarry Smith 
77453acd3b1SBarry Smith    Input Parameters:
77553acd3b1SBarry Smith +  opt - option name
77653acd3b1SBarry Smith .  text - short string that describes the option
77753acd3b1SBarry Smith .  man - manual page with additional information on option
77853acd3b1SBarry Smith -  defaultv - the default (current) value
77953acd3b1SBarry Smith 
78053acd3b1SBarry Smith    Output Parameter:
78153acd3b1SBarry Smith +  value - the value to return
78253acd3b1SBarry Smith -  flg - PETSC_TRUE if found, else PETSC_FALSE
78353acd3b1SBarry Smith 
78453acd3b1SBarry Smith    Level: beginner
78553acd3b1SBarry Smith 
78653acd3b1SBarry Smith    Concepts: options database^has int
78753acd3b1SBarry Smith 
78853acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
78953acd3b1SBarry Smith 
79053acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
791acfcf0e5SJed Brown           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool()
792acfcf0e5SJed Brown           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(),
79353acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
79453acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
795acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
79653acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
79753acd3b1SBarry Smith @*/
7987087cfbeSBarry Smith PetscErrorCode  PetscOptionsScalar(const char opt[],const char text[],const char man[],PetscScalar defaultv,PetscScalar *value,PetscBool  *set)
79953acd3b1SBarry Smith {
80053acd3b1SBarry Smith   PetscErrorCode ierr;
80153acd3b1SBarry Smith 
80253acd3b1SBarry Smith   PetscFunctionBegin;
80353acd3b1SBarry Smith #if !defined(PETSC_USE_COMPLEX)
80453acd3b1SBarry Smith   ierr = PetscOptionsReal(opt,text,man,defaultv,value,set);CHKERRQ(ierr);
80553acd3b1SBarry Smith #else
80653acd3b1SBarry Smith   ierr = PetscOptionsGetScalar(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr);
80753acd3b1SBarry Smith #endif
80853acd3b1SBarry Smith   PetscFunctionReturn(0);
80953acd3b1SBarry Smith }
81053acd3b1SBarry Smith 
81153acd3b1SBarry Smith #undef __FUNCT__
81253acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsName"
81353acd3b1SBarry Smith /*@C
81490d69ab7SBarry 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
81590d69ab7SBarry Smith                       its value is set to false.
81653acd3b1SBarry Smith 
8173f9fe445SBarry Smith    Logically Collective on the communicator passed in PetscOptionsBegin()
81853acd3b1SBarry Smith 
81953acd3b1SBarry Smith    Input Parameters:
82053acd3b1SBarry Smith +  opt - option name
82153acd3b1SBarry Smith .  text - short string that describes the option
82253acd3b1SBarry Smith -  man - manual page with additional information on option
82353acd3b1SBarry Smith 
82453acd3b1SBarry Smith    Output Parameter:
82553acd3b1SBarry Smith .  flg - PETSC_TRUE if found, else PETSC_FALSE
82653acd3b1SBarry Smith 
82753acd3b1SBarry Smith    Level: beginner
82853acd3b1SBarry Smith 
82953acd3b1SBarry Smith    Concepts: options database^has int
83053acd3b1SBarry Smith 
83153acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
83253acd3b1SBarry Smith 
83353acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
834acfcf0e5SJed Brown           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool()
835acfcf0e5SJed Brown           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(),
83653acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
83753acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
838acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
83953acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
84053acd3b1SBarry Smith @*/
8417087cfbeSBarry Smith PetscErrorCode  PetscOptionsName(const char opt[],const char text[],const char man[],PetscBool  *flg)
84253acd3b1SBarry Smith {
84353acd3b1SBarry Smith   PetscErrorCode ierr;
8441ae3d29cSBarry Smith   PetscOptions   amsopt;
84553acd3b1SBarry Smith 
84653acd3b1SBarry Smith   PetscFunctionBegin;
8471ae3d29cSBarry Smith   if (!PetscOptionsPublishCount) {
8481ae3d29cSBarry Smith     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL,&amsopt);CHKERRQ(ierr);
849ace3abfcSBarry Smith     ierr = PetscMalloc(sizeof(PetscBool),&amsopt->data);CHKERRQ(ierr);
850a297a907SKarl Rupp 
851ace3abfcSBarry Smith     *(PetscBool*)amsopt->data = PETSC_FALSE;
8521ae3d29cSBarry Smith   }
85353acd3b1SBarry Smith   ierr = PetscOptionsHasName(PetscOptionsObject.prefix,opt,flg);CHKERRQ(ierr);
85461b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
8552aa6d131SJed Brown     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s: %s (%s)\n",PetscOptionsObject.prefix ? PetscOptionsObject.prefix : "",opt+1,text,ManSection(man));CHKERRQ(ierr);
85653acd3b1SBarry Smith   }
85753acd3b1SBarry Smith   PetscFunctionReturn(0);
85853acd3b1SBarry Smith }
85953acd3b1SBarry Smith 
86053acd3b1SBarry Smith #undef __FUNCT__
86153acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsList"
86253acd3b1SBarry Smith /*@C
86353acd3b1SBarry Smith      PetscOptionsList - Puts a list of option values that a single one may be selected from
86453acd3b1SBarry Smith 
8653f9fe445SBarry Smith    Logically Collective on the communicator passed in PetscOptionsBegin()
86653acd3b1SBarry Smith 
86753acd3b1SBarry Smith    Input Parameters:
86853acd3b1SBarry Smith +  opt - option name
86953acd3b1SBarry Smith .  text - short string that describes the option
87053acd3b1SBarry Smith .  man - manual page with additional information on option
87153acd3b1SBarry Smith .  list - the possible choices
8723cc1e11dSBarry Smith .  defaultv - the default (current) value
8733cc1e11dSBarry Smith -  len - the length of the character array value
87453acd3b1SBarry Smith 
87553acd3b1SBarry Smith    Output Parameter:
87653acd3b1SBarry Smith +  value - the value to return
87753acd3b1SBarry Smith -  set - PETSC_TRUE if found, else PETSC_FALSE
87853acd3b1SBarry Smith 
87953acd3b1SBarry Smith    Level: intermediate
88053acd3b1SBarry Smith 
88153acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
88253acd3b1SBarry Smith 
88353acd3b1SBarry Smith    See PetscOptionsEList() for when the choices are given in a string array
88453acd3b1SBarry Smith 
88553acd3b1SBarry Smith    To get a listing of all currently specified options,
88688c29154SBarry Smith     see PetscOptionsView() or PetscOptionsGetAll()
88753acd3b1SBarry Smith 
88853acd3b1SBarry Smith    Concepts: options database^list
88953acd3b1SBarry Smith 
89053acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
891acfcf0e5SJed Brown            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
89253acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
89353acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
894acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
895171400e9SBarry Smith           PetscOptionsList(), PetscOptionsEList(), PetscOptionsEnum()
89653acd3b1SBarry Smith @*/
897140e18c1SBarry Smith PetscErrorCode  PetscOptionsList(const char opt[],const char ltext[],const char man[],PetscFunctionList list,const char defaultv[],char value[],size_t len,PetscBool  *set)
89853acd3b1SBarry Smith {
89953acd3b1SBarry Smith   PetscErrorCode ierr;
9003cc1e11dSBarry Smith   PetscOptions   amsopt;
90153acd3b1SBarry Smith 
90253acd3b1SBarry Smith   PetscFunctionBegin;
903b3506946SBarry Smith   if (!PetscOptionsPublishCount) {
9043cc1e11dSBarry Smith     ierr = PetscOptionsCreate_Private(opt,ltext,man,OPTION_LIST,&amsopt);CHKERRQ(ierr);
905*475446a1SBarry Smith     ierr = PetscStrallocpy(defaultv,(char**)&amsopt->data);CHKERRQ(ierr);
9063cc1e11dSBarry Smith     amsopt->flist = list;
9073cc1e11dSBarry Smith   }
90853acd3b1SBarry Smith   ierr = PetscOptionsGetString(PetscOptionsObject.prefix,opt,value,len,set);CHKERRQ(ierr);
90961b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
910140e18c1SBarry Smith     ierr = PetscFunctionListPrintTypes(PetscOptionsObject.comm,stdout,PetscOptionsObject.prefix,opt,ltext,man,list,defaultv);CHKERRQ(ierr);CHKERRQ(ierr);
91153acd3b1SBarry Smith   }
91253acd3b1SBarry Smith   PetscFunctionReturn(0);
91353acd3b1SBarry Smith }
91453acd3b1SBarry Smith 
91553acd3b1SBarry Smith #undef __FUNCT__
91653acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsEList"
91753acd3b1SBarry Smith /*@C
91853acd3b1SBarry Smith      PetscOptionsEList - Puts a list of option values that a single one may be selected from
91953acd3b1SBarry Smith 
9203f9fe445SBarry Smith    Logically Collective on the communicator passed in PetscOptionsBegin()
92153acd3b1SBarry Smith 
92253acd3b1SBarry Smith    Input Parameters:
92353acd3b1SBarry Smith +  opt - option name
92453acd3b1SBarry Smith .  ltext - short string that describes the option
92553acd3b1SBarry Smith .  man - manual page with additional information on option
92653acd3b1SBarry Smith .  list - the possible choices
92753acd3b1SBarry Smith .  ntext - number of choices
92853acd3b1SBarry Smith -  defaultv - the default (current) value
92953acd3b1SBarry Smith 
93053acd3b1SBarry Smith    Output Parameter:
93153acd3b1SBarry Smith +  value - the index of the value to return
93253acd3b1SBarry Smith -  set - PETSC_TRUE if found, else PETSC_FALSE
93353acd3b1SBarry Smith 
93453acd3b1SBarry Smith    Level: intermediate
93553acd3b1SBarry Smith 
93653acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
93753acd3b1SBarry Smith 
938140e18c1SBarry Smith    See PetscOptionsList() for when the choices are given in a PetscFunctionList()
93953acd3b1SBarry Smith 
94053acd3b1SBarry Smith    Concepts: options database^list
94153acd3b1SBarry Smith 
94253acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
943acfcf0e5SJed Brown            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
94453acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
94553acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
946acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
947171400e9SBarry Smith           PetscOptionsList(), PetscOptionsEnum()
94853acd3b1SBarry Smith @*/
9497087cfbeSBarry Smith PetscErrorCode  PetscOptionsEList(const char opt[],const char ltext[],const char man[],const char *const *list,PetscInt ntext,const char defaultv[],PetscInt *value,PetscBool  *set)
95053acd3b1SBarry Smith {
95153acd3b1SBarry Smith   PetscErrorCode ierr;
95253acd3b1SBarry Smith   PetscInt       i;
9531ae3d29cSBarry Smith   PetscOptions   amsopt;
95453acd3b1SBarry Smith 
95553acd3b1SBarry Smith   PetscFunctionBegin;
9561ae3d29cSBarry Smith   if (!PetscOptionsPublishCount) {
957d5649816SBarry Smith     ierr = PetscOptionsCreate_Private(opt,ltext,man,OPTION_ELIST,&amsopt);CHKERRQ(ierr);
958*475446a1SBarry Smith     ierr = PetscStrallocpy(defaultv,(char**)&amsopt->data);CHKERRQ(ierr);
9591ae3d29cSBarry Smith     amsopt->list  = list;
9601ae3d29cSBarry Smith     amsopt->nlist = ntext;
9611ae3d29cSBarry Smith   }
96253acd3b1SBarry Smith   ierr = PetscOptionsGetEList(PetscOptionsObject.prefix,opt,list,ntext,value,set);CHKERRQ(ierr);
96361b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
96453acd3b1SBarry Smith     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%s> (choose one of)",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv);CHKERRQ(ierr);
96553acd3b1SBarry Smith     for (i=0; i<ntext; i++) {
96653acd3b1SBarry Smith       ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," %s",list[i]);CHKERRQ(ierr);
96753acd3b1SBarry Smith     }
9682aa6d131SJed Brown     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," (%s)\n",ManSection(man));CHKERRQ(ierr);
96953acd3b1SBarry Smith   }
97053acd3b1SBarry Smith   PetscFunctionReturn(0);
97153acd3b1SBarry Smith }
97253acd3b1SBarry Smith 
97353acd3b1SBarry Smith #undef __FUNCT__
974acfcf0e5SJed Brown #define __FUNCT__ "PetscOptionsBoolGroupBegin"
97553acd3b1SBarry Smith /*@C
976acfcf0e5SJed Brown      PetscOptionsBoolGroupBegin - First in a series of logical queries on the options database for
977d5649816SBarry Smith        which at most a single value can be true.
97853acd3b1SBarry Smith 
9793f9fe445SBarry Smith    Logically Collective on the communicator passed in PetscOptionsBegin()
98053acd3b1SBarry Smith 
98153acd3b1SBarry Smith    Input Parameters:
98253acd3b1SBarry Smith +  opt - option name
98353acd3b1SBarry Smith .  text - short string that describes the option
98453acd3b1SBarry Smith -  man - manual page with additional information on option
98553acd3b1SBarry Smith 
98653acd3b1SBarry Smith    Output Parameter:
98753acd3b1SBarry Smith .  flg - whether that option was set or not
98853acd3b1SBarry Smith 
98953acd3b1SBarry Smith    Level: intermediate
99053acd3b1SBarry Smith 
99153acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
99253acd3b1SBarry Smith 
993acfcf0e5SJed Brown    Must be followed by 0 or more PetscOptionsBoolGroup()s and PetscOptionsBoolGroupEnd()
99453acd3b1SBarry Smith 
99553acd3b1SBarry Smith     Concepts: options database^logical group
99653acd3b1SBarry Smith 
99753acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
998acfcf0e5SJed Brown            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
99953acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
100053acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1001acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
100253acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
100353acd3b1SBarry Smith @*/
10047087cfbeSBarry Smith PetscErrorCode  PetscOptionsBoolGroupBegin(const char opt[],const char text[],const char man[],PetscBool  *flg)
100553acd3b1SBarry Smith {
100653acd3b1SBarry Smith   PetscErrorCode ierr;
10071ae3d29cSBarry Smith   PetscOptions   amsopt;
100853acd3b1SBarry Smith 
100953acd3b1SBarry Smith   PetscFunctionBegin;
10101ae3d29cSBarry Smith   if (!PetscOptionsPublishCount) {
10111ae3d29cSBarry Smith     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL,&amsopt);CHKERRQ(ierr);
1012ace3abfcSBarry Smith     ierr = PetscMalloc(sizeof(PetscBool),&amsopt->data);CHKERRQ(ierr);
1013a297a907SKarl Rupp 
1014ace3abfcSBarry Smith     *(PetscBool*)amsopt->data = PETSC_FALSE;
10151ae3d29cSBarry Smith   }
101668b16fdaSBarry Smith   *flg = PETSC_FALSE;
10170298fd71SBarry Smith   ierr = PetscOptionsGetBool(PetscOptionsObject.prefix,opt,flg,NULL);CHKERRQ(ierr);
101861b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
101953acd3b1SBarry Smith     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  Pick at most one of -------------\n");CHKERRQ(ierr);
10202aa6d131SJed Brown     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"    -%s%s: %s (%s)\n",PetscOptionsObject.prefix ? PetscOptionsObject.prefix : "",opt+1,text,ManSection(man));CHKERRQ(ierr);
102153acd3b1SBarry Smith   }
102253acd3b1SBarry Smith   PetscFunctionReturn(0);
102353acd3b1SBarry Smith }
102453acd3b1SBarry Smith 
102553acd3b1SBarry Smith #undef __FUNCT__
1026acfcf0e5SJed Brown #define __FUNCT__ "PetscOptionsBoolGroup"
102753acd3b1SBarry Smith /*@C
1028acfcf0e5SJed Brown      PetscOptionsBoolGroup - One in a series of logical queries on the options database for
1029d5649816SBarry Smith        which at most a single value can be true.
103053acd3b1SBarry Smith 
10313f9fe445SBarry Smith    Logically Collective on the communicator passed in PetscOptionsBegin()
103253acd3b1SBarry Smith 
103353acd3b1SBarry Smith    Input Parameters:
103453acd3b1SBarry Smith +  opt - option name
103553acd3b1SBarry Smith .  text - short string that describes the option
103653acd3b1SBarry Smith -  man - manual page with additional information on option
103753acd3b1SBarry Smith 
103853acd3b1SBarry Smith    Output Parameter:
103953acd3b1SBarry Smith .  flg - PETSC_TRUE if found, else PETSC_FALSE
104053acd3b1SBarry Smith 
104153acd3b1SBarry Smith    Level: intermediate
104253acd3b1SBarry Smith 
104353acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
104453acd3b1SBarry Smith 
1045acfcf0e5SJed Brown    Must follow a PetscOptionsBoolGroupBegin() and preceded a PetscOptionsBoolGroupEnd()
104653acd3b1SBarry Smith 
104753acd3b1SBarry Smith     Concepts: options database^logical group
104853acd3b1SBarry Smith 
104953acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1050acfcf0e5SJed Brown            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
105153acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
105253acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1053acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
105453acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
105553acd3b1SBarry Smith @*/
10567087cfbeSBarry Smith PetscErrorCode  PetscOptionsBoolGroup(const char opt[],const char text[],const char man[],PetscBool  *flg)
105753acd3b1SBarry Smith {
105853acd3b1SBarry Smith   PetscErrorCode ierr;
10591ae3d29cSBarry Smith   PetscOptions   amsopt;
106053acd3b1SBarry Smith 
106153acd3b1SBarry Smith   PetscFunctionBegin;
10621ae3d29cSBarry Smith   if (!PetscOptionsPublishCount) {
10631ae3d29cSBarry Smith     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL,&amsopt);CHKERRQ(ierr);
1064ace3abfcSBarry Smith     ierr = PetscMalloc(sizeof(PetscBool),&amsopt->data);CHKERRQ(ierr);
1065a297a907SKarl Rupp 
1066ace3abfcSBarry Smith     *(PetscBool*)amsopt->data = PETSC_FALSE;
10671ae3d29cSBarry Smith   }
106817326d04SJed Brown   *flg = PETSC_FALSE;
10690298fd71SBarry Smith   ierr = PetscOptionsGetBool(PetscOptionsObject.prefix,opt,flg,NULL);CHKERRQ(ierr);
107061b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
10712aa6d131SJed Brown     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"    -%s%s: %s (%s)\n",PetscOptionsObject.prefix ? PetscOptionsObject.prefix : "",opt+1,text,ManSection(man));CHKERRQ(ierr);
107253acd3b1SBarry Smith   }
107353acd3b1SBarry Smith   PetscFunctionReturn(0);
107453acd3b1SBarry Smith }
107553acd3b1SBarry Smith 
107653acd3b1SBarry Smith #undef __FUNCT__
1077acfcf0e5SJed Brown #define __FUNCT__ "PetscOptionsBoolGroupEnd"
107853acd3b1SBarry Smith /*@C
1079acfcf0e5SJed Brown      PetscOptionsBoolGroupEnd - Last in a series of logical queries on the options database for
1080d5649816SBarry Smith        which at most a single value can be true.
108153acd3b1SBarry Smith 
10823f9fe445SBarry Smith    Logically Collective on the communicator passed in PetscOptionsBegin()
108353acd3b1SBarry Smith 
108453acd3b1SBarry Smith    Input Parameters:
108553acd3b1SBarry Smith +  opt - option name
108653acd3b1SBarry Smith .  text - short string that describes the option
108753acd3b1SBarry Smith -  man - manual page with additional information on option
108853acd3b1SBarry Smith 
108953acd3b1SBarry Smith    Output Parameter:
109053acd3b1SBarry Smith .  flg - PETSC_TRUE if found, else PETSC_FALSE
109153acd3b1SBarry Smith 
109253acd3b1SBarry Smith    Level: intermediate
109353acd3b1SBarry Smith 
109453acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
109553acd3b1SBarry Smith 
1096acfcf0e5SJed Brown    Must follow a PetscOptionsBoolGroupBegin()
109753acd3b1SBarry Smith 
109853acd3b1SBarry Smith     Concepts: options database^logical group
109953acd3b1SBarry Smith 
110053acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1101acfcf0e5SJed Brown            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
110253acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
110353acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1104acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
110553acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
110653acd3b1SBarry Smith @*/
11077087cfbeSBarry Smith PetscErrorCode  PetscOptionsBoolGroupEnd(const char opt[],const char text[],const char man[],PetscBool  *flg)
110853acd3b1SBarry Smith {
110953acd3b1SBarry Smith   PetscErrorCode ierr;
11101ae3d29cSBarry Smith   PetscOptions   amsopt;
111153acd3b1SBarry Smith 
111253acd3b1SBarry Smith   PetscFunctionBegin;
11131ae3d29cSBarry Smith   if (!PetscOptionsPublishCount) {
11141ae3d29cSBarry Smith     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL,&amsopt);CHKERRQ(ierr);
1115ace3abfcSBarry Smith     ierr = PetscMalloc(sizeof(PetscBool),&amsopt->data);CHKERRQ(ierr);
1116a297a907SKarl Rupp 
1117ace3abfcSBarry Smith     *(PetscBool*)amsopt->data = PETSC_FALSE;
11181ae3d29cSBarry Smith   }
111917326d04SJed Brown   *flg = PETSC_FALSE;
11200298fd71SBarry Smith   ierr = PetscOptionsGetBool(PetscOptionsObject.prefix,opt,flg,NULL);CHKERRQ(ierr);
112161b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
11222aa6d131SJed Brown     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"    -%s%s: %s (%s)\n",PetscOptionsObject.prefix ? PetscOptionsObject.prefix : "",opt+1,text,ManSection(man));CHKERRQ(ierr);
112353acd3b1SBarry Smith   }
112453acd3b1SBarry Smith   PetscFunctionReturn(0);
112553acd3b1SBarry Smith }
112653acd3b1SBarry Smith 
112753acd3b1SBarry Smith #undef __FUNCT__
1128acfcf0e5SJed Brown #define __FUNCT__ "PetscOptionsBool"
112953acd3b1SBarry Smith /*@C
1130acfcf0e5SJed Brown    PetscOptionsBool - Determines if a particular option is in the database with a true or false
113153acd3b1SBarry Smith 
11323f9fe445SBarry Smith    Logically Collective on the communicator passed in PetscOptionsBegin()
113353acd3b1SBarry Smith 
113453acd3b1SBarry Smith    Input Parameters:
113553acd3b1SBarry Smith +  opt - option name
113653acd3b1SBarry Smith .  text - short string that describes the option
113753acd3b1SBarry Smith -  man - manual page with additional information on option
113853acd3b1SBarry Smith 
113953acd3b1SBarry Smith    Output Parameter:
114053acd3b1SBarry Smith .  flg - PETSC_TRUE or PETSC_FALSE
114153acd3b1SBarry Smith .  set - PETSC_TRUE if found, else PETSC_FALSE
114253acd3b1SBarry Smith 
114353acd3b1SBarry Smith    Level: beginner
114453acd3b1SBarry Smith 
114553acd3b1SBarry Smith    Concepts: options database^logical
114653acd3b1SBarry Smith 
114753acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
114853acd3b1SBarry Smith 
114953acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
1150acfcf0e5SJed Brown           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool()
1151acfcf0e5SJed Brown           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(),
115253acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
115353acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1154acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
115553acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
115653acd3b1SBarry Smith @*/
11577087cfbeSBarry Smith PetscErrorCode  PetscOptionsBool(const char opt[],const char text[],const char man[],PetscBool deflt,PetscBool  *flg,PetscBool  *set)
115853acd3b1SBarry Smith {
115953acd3b1SBarry Smith   PetscErrorCode ierr;
1160ace3abfcSBarry Smith   PetscBool      iset;
1161aee2cecaSBarry Smith   PetscOptions   amsopt;
116253acd3b1SBarry Smith 
116353acd3b1SBarry Smith   PetscFunctionBegin;
1164b3506946SBarry Smith   if (!PetscOptionsPublishCount) {
1165aee2cecaSBarry Smith     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL,&amsopt);CHKERRQ(ierr);
1166ace3abfcSBarry Smith     ierr = PetscMalloc(sizeof(PetscBool),&amsopt->data);CHKERRQ(ierr);
1167a297a907SKarl Rupp 
1168ace3abfcSBarry Smith     *(PetscBool*)amsopt->data = deflt;
1169af6d86caSBarry Smith   }
1170acfcf0e5SJed Brown   ierr = PetscOptionsGetBool(PetscOptionsObject.prefix,opt,flg,&iset);CHKERRQ(ierr);
117153acd3b1SBarry Smith   if (!iset) {
117253acd3b1SBarry Smith     if (flg) *flg = deflt;
117353acd3b1SBarry Smith   }
117453acd3b1SBarry Smith   if (set) *set = iset;
117561b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
1176ace3abfcSBarry Smith     const char *v = PetscBools[deflt];
11772aa6d131SJed Brown     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s: <%s> %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,v,text,ManSection(man));CHKERRQ(ierr);
117853acd3b1SBarry Smith   }
117953acd3b1SBarry Smith   PetscFunctionReturn(0);
118053acd3b1SBarry Smith }
118153acd3b1SBarry Smith 
118253acd3b1SBarry Smith #undef __FUNCT__
118353acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsRealArray"
118453acd3b1SBarry Smith /*@C
118553acd3b1SBarry Smith    PetscOptionsRealArray - Gets an array of double values for a particular
118653acd3b1SBarry Smith    option in the database. The values must be separated with commas with
118753acd3b1SBarry Smith    no intervening spaces.
118853acd3b1SBarry Smith 
11893f9fe445SBarry Smith    Logically Collective on the communicator passed in PetscOptionsBegin()
119053acd3b1SBarry Smith 
119153acd3b1SBarry Smith    Input Parameters:
119253acd3b1SBarry Smith +  opt - the option one is seeking
119353acd3b1SBarry Smith .  text - short string describing option
119453acd3b1SBarry Smith .  man - manual page for option
119553acd3b1SBarry Smith -  nmax - maximum number of values
119653acd3b1SBarry Smith 
119753acd3b1SBarry Smith    Output Parameter:
119853acd3b1SBarry Smith +  value - location to copy values
119953acd3b1SBarry Smith .  nmax - actual number of values found
120053acd3b1SBarry Smith -  set - PETSC_TRUE if found, else PETSC_FALSE
120153acd3b1SBarry Smith 
120253acd3b1SBarry Smith    Level: beginner
120353acd3b1SBarry Smith 
120453acd3b1SBarry Smith    Notes:
120553acd3b1SBarry Smith    The user should pass in an array of doubles
120653acd3b1SBarry Smith 
120753acd3b1SBarry Smith    Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
120853acd3b1SBarry Smith 
120953acd3b1SBarry Smith    Concepts: options database^array of strings
121053acd3b1SBarry Smith 
121153acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1212acfcf0e5SJed Brown            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
121353acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
121453acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1215acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
121653acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
121753acd3b1SBarry Smith @*/
12187087cfbeSBarry Smith PetscErrorCode  PetscOptionsRealArray(const char opt[],const char text[],const char man[],PetscReal value[],PetscInt *n,PetscBool  *set)
121953acd3b1SBarry Smith {
122053acd3b1SBarry Smith   PetscErrorCode ierr;
122153acd3b1SBarry Smith   PetscInt       i;
1222e26ddf31SBarry Smith   PetscOptions   amsopt;
122353acd3b1SBarry Smith 
122453acd3b1SBarry Smith   PetscFunctionBegin;
1225b3506946SBarry Smith   if (!PetscOptionsPublishCount) {
1226e26ddf31SBarry Smith     PetscReal *vals;
1227e26ddf31SBarry Smith 
1228e26ddf31SBarry Smith     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_REAL_ARRAY,&amsopt);CHKERRQ(ierr);
1229e26ddf31SBarry Smith     ierr = PetscMalloc((*n)*sizeof(PetscReal),&amsopt->data);CHKERRQ(ierr);
1230e26ddf31SBarry Smith     vals = (PetscReal*)amsopt->data;
1231e26ddf31SBarry Smith     for (i=0; i<*n; i++) vals[i] = value[i];
1232e26ddf31SBarry Smith     amsopt->arraylength = *n;
1233e26ddf31SBarry Smith   }
123453acd3b1SBarry Smith   ierr = PetscOptionsGetRealArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr);
123561b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
1236a83599f4SBarry Smith     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%G",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr);
123753acd3b1SBarry Smith     for (i=1; i<*n; i++) {
1238a83599f4SBarry Smith       ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%G",value[i]);CHKERRQ(ierr);
123953acd3b1SBarry Smith     }
12402aa6d131SJed Brown     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,ManSection(man));CHKERRQ(ierr);
124153acd3b1SBarry Smith   }
124253acd3b1SBarry Smith   PetscFunctionReturn(0);
124353acd3b1SBarry Smith }
124453acd3b1SBarry Smith 
124553acd3b1SBarry Smith 
124653acd3b1SBarry Smith #undef __FUNCT__
124753acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsIntArray"
124853acd3b1SBarry Smith /*@C
124953acd3b1SBarry Smith    PetscOptionsIntArray - Gets an array of integers for a particular
1250b32a342fSShri Abhyankar    option in the database.
125153acd3b1SBarry Smith 
12523f9fe445SBarry Smith    Logically Collective on the communicator passed in PetscOptionsBegin()
125353acd3b1SBarry Smith 
125453acd3b1SBarry Smith    Input Parameters:
125553acd3b1SBarry Smith +  opt - the option one is seeking
125653acd3b1SBarry Smith .  text - short string describing option
125753acd3b1SBarry Smith .  man - manual page for option
1258f8a50e2bSBarry Smith -  n - maximum number of values
125953acd3b1SBarry Smith 
126053acd3b1SBarry Smith    Output Parameter:
126153acd3b1SBarry Smith +  value - location to copy values
1262f8a50e2bSBarry Smith .  n - actual number of values found
126353acd3b1SBarry Smith -  set - PETSC_TRUE if found, else PETSC_FALSE
126453acd3b1SBarry Smith 
126553acd3b1SBarry Smith    Level: beginner
126653acd3b1SBarry Smith 
126753acd3b1SBarry Smith    Notes:
1268b32a342fSShri Abhyankar    The array can be passed as
1269b32a342fSShri Abhyankar    a comma seperated list:                                 0,1,2,3,4,5,6,7
12700fd488f5SShri Abhyankar    a range (start-end+1):                                  0-8
12710fd488f5SShri Abhyankar    a range with given increment (start-end+1:inc):         0-7:2
12720fd488f5SShri Abhyankar    a combination of values and ranges seperated by commas: 0,1-8,8-15:2
1273b32a342fSShri Abhyankar 
1274b32a342fSShri Abhyankar    There must be no intervening spaces between the values.
127553acd3b1SBarry Smith 
127653acd3b1SBarry Smith    Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
127753acd3b1SBarry Smith 
1278b32a342fSShri Abhyankar    Concepts: options database^array of ints
127953acd3b1SBarry Smith 
128053acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1281acfcf0e5SJed Brown            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
128253acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
128353acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1284acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
128553acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList(), PetscOptionsRealArray()
128653acd3b1SBarry Smith @*/
12877087cfbeSBarry Smith PetscErrorCode  PetscOptionsIntArray(const char opt[],const char text[],const char man[],PetscInt value[],PetscInt *n,PetscBool  *set)
128853acd3b1SBarry Smith {
128953acd3b1SBarry Smith   PetscErrorCode ierr;
129053acd3b1SBarry Smith   PetscInt       i;
1291e26ddf31SBarry Smith   PetscOptions   amsopt;
129253acd3b1SBarry Smith 
129353acd3b1SBarry Smith   PetscFunctionBegin;
1294b3506946SBarry Smith   if (!PetscOptionsPublishCount) {
1295e26ddf31SBarry Smith     PetscInt *vals;
1296e26ddf31SBarry Smith 
1297e26ddf31SBarry Smith     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_INT_ARRAY,&amsopt);CHKERRQ(ierr);
1298e26ddf31SBarry Smith     ierr = PetscMalloc((*n)*sizeof(PetscInt),&amsopt->data);CHKERRQ(ierr);
1299e26ddf31SBarry Smith     vals = (PetscInt*)amsopt->data;
1300e26ddf31SBarry Smith     for (i=0; i<*n; i++) vals[i] = value[i];
1301e26ddf31SBarry Smith     amsopt->arraylength = *n;
1302e26ddf31SBarry Smith   }
130353acd3b1SBarry Smith   ierr = PetscOptionsGetIntArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr);
130461b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
130553acd3b1SBarry Smith     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%d",PetscOptionsObject.prefix ? PetscOptionsObject.prefix : "",opt+1,value[0]);CHKERRQ(ierr);
130653acd3b1SBarry Smith     for (i=1; i<*n; i++) {
130753acd3b1SBarry Smith       ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%d",value[i]);CHKERRQ(ierr);
130853acd3b1SBarry Smith     }
13092aa6d131SJed Brown     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,ManSection(man));CHKERRQ(ierr);
131053acd3b1SBarry Smith   }
131153acd3b1SBarry Smith   PetscFunctionReturn(0);
131253acd3b1SBarry Smith }
131353acd3b1SBarry Smith 
131453acd3b1SBarry Smith #undef __FUNCT__
131553acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsStringArray"
131653acd3b1SBarry Smith /*@C
131753acd3b1SBarry Smith    PetscOptionsStringArray - Gets an array of string values for a particular
131853acd3b1SBarry Smith    option in the database. The values must be separated with commas with
131953acd3b1SBarry Smith    no intervening spaces.
132053acd3b1SBarry Smith 
13213f9fe445SBarry Smith    Logically Collective on the communicator passed in PetscOptionsBegin()
132253acd3b1SBarry Smith 
132353acd3b1SBarry Smith    Input Parameters:
132453acd3b1SBarry Smith +  opt - the option one is seeking
132553acd3b1SBarry Smith .  text - short string describing option
132653acd3b1SBarry Smith .  man - manual page for option
132753acd3b1SBarry Smith -  nmax - maximum number of strings
132853acd3b1SBarry Smith 
132953acd3b1SBarry Smith    Output Parameter:
133053acd3b1SBarry Smith +  value - location to copy strings
133153acd3b1SBarry Smith .  nmax - actual number of strings found
133253acd3b1SBarry Smith -  set - PETSC_TRUE if found, else PETSC_FALSE
133353acd3b1SBarry Smith 
133453acd3b1SBarry Smith    Level: beginner
133553acd3b1SBarry Smith 
133653acd3b1SBarry Smith    Notes:
133753acd3b1SBarry Smith    The user should pass in an array of pointers to char, to hold all the
133853acd3b1SBarry Smith    strings returned by this function.
133953acd3b1SBarry Smith 
134053acd3b1SBarry Smith    The user is responsible for deallocating the strings that are
134153acd3b1SBarry Smith    returned. The Fortran interface for this routine is not supported.
134253acd3b1SBarry Smith 
134353acd3b1SBarry Smith    Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
134453acd3b1SBarry Smith 
134553acd3b1SBarry Smith    Concepts: options database^array of strings
134653acd3b1SBarry Smith 
134753acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1348acfcf0e5SJed Brown            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
134953acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
135053acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1351acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
135253acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
135353acd3b1SBarry Smith @*/
13547087cfbeSBarry Smith PetscErrorCode  PetscOptionsStringArray(const char opt[],const char text[],const char man[],char *value[],PetscInt *nmax,PetscBool  *set)
135553acd3b1SBarry Smith {
135653acd3b1SBarry Smith   PetscErrorCode ierr;
13571ae3d29cSBarry Smith   PetscOptions   amsopt;
135853acd3b1SBarry Smith 
135953acd3b1SBarry Smith   PetscFunctionBegin;
13601ae3d29cSBarry Smith   if (!PetscOptionsPublishCount) {
13611ae3d29cSBarry Smith     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_STRING_ARRAY,&amsopt);CHKERRQ(ierr);
13621ae3d29cSBarry Smith     ierr = PetscMalloc((*nmax)*sizeof(char*),&amsopt->data);CHKERRQ(ierr);
1363a297a907SKarl Rupp 
13641ae3d29cSBarry Smith     amsopt->arraylength = *nmax;
13651ae3d29cSBarry Smith   }
136653acd3b1SBarry Smith   ierr = PetscOptionsGetStringArray(PetscOptionsObject.prefix,opt,value,nmax,set);CHKERRQ(ierr);
136761b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
13682aa6d131SJed Brown     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <string1,string2,...>: %s (%s)\n",PetscOptionsObject.prefix ? PetscOptionsObject.prefix : "",opt+1,text,ManSection(man));CHKERRQ(ierr);
136953acd3b1SBarry Smith   }
137053acd3b1SBarry Smith   PetscFunctionReturn(0);
137153acd3b1SBarry Smith }
137253acd3b1SBarry Smith 
1373e2446a98SMatthew Knepley #undef __FUNCT__
1374acfcf0e5SJed Brown #define __FUNCT__ "PetscOptionsBoolArray"
1375e2446a98SMatthew Knepley /*@C
1376acfcf0e5SJed Brown    PetscOptionsBoolArray - Gets an array of logical values (true or false) for a particular
1377e2446a98SMatthew Knepley    option in the database. The values must be separated with commas with
1378e2446a98SMatthew Knepley    no intervening spaces.
1379e2446a98SMatthew Knepley 
13803f9fe445SBarry Smith    Logically Collective on the communicator passed in PetscOptionsBegin()
1381e2446a98SMatthew Knepley 
1382e2446a98SMatthew Knepley    Input Parameters:
1383e2446a98SMatthew Knepley +  opt - the option one is seeking
1384e2446a98SMatthew Knepley .  text - short string describing option
1385e2446a98SMatthew Knepley .  man - manual page for option
1386e2446a98SMatthew Knepley -  nmax - maximum number of values
1387e2446a98SMatthew Knepley 
1388e2446a98SMatthew Knepley    Output Parameter:
1389e2446a98SMatthew Knepley +  value - location to copy values
1390e2446a98SMatthew Knepley .  nmax - actual number of values found
1391e2446a98SMatthew Knepley -  set - PETSC_TRUE if found, else PETSC_FALSE
1392e2446a98SMatthew Knepley 
1393e2446a98SMatthew Knepley    Level: beginner
1394e2446a98SMatthew Knepley 
1395e2446a98SMatthew Knepley    Notes:
1396e2446a98SMatthew Knepley    The user should pass in an array of doubles
1397e2446a98SMatthew Knepley 
1398e2446a98SMatthew Knepley    Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1399e2446a98SMatthew Knepley 
1400e2446a98SMatthew Knepley    Concepts: options database^array of strings
1401e2446a98SMatthew Knepley 
1402e2446a98SMatthew Knepley .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1403acfcf0e5SJed Brown            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
1404e2446a98SMatthew Knepley           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1405e2446a98SMatthew Knepley           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1406acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
1407e2446a98SMatthew Knepley           PetscOptionsList(), PetscOptionsEList()
1408e2446a98SMatthew Knepley @*/
14097087cfbeSBarry Smith PetscErrorCode  PetscOptionsBoolArray(const char opt[],const char text[],const char man[],PetscBool value[],PetscInt *n,PetscBool *set)
1410e2446a98SMatthew Knepley {
1411e2446a98SMatthew Knepley   PetscErrorCode ierr;
1412e2446a98SMatthew Knepley   PetscInt       i;
14131ae3d29cSBarry Smith   PetscOptions   amsopt;
1414e2446a98SMatthew Knepley 
1415e2446a98SMatthew Knepley   PetscFunctionBegin;
14161ae3d29cSBarry Smith   if (!PetscOptionsPublishCount) {
1417ace3abfcSBarry Smith     PetscBool *vals;
14181ae3d29cSBarry Smith 
14191ae3d29cSBarry Smith     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL_ARRAY,&amsopt);CHKERRQ(ierr);
1420ace3abfcSBarry Smith     ierr = PetscMalloc((*n)*sizeof(PetscBool),&amsopt->data);CHKERRQ(ierr);
1421ace3abfcSBarry Smith     vals = (PetscBool*)amsopt->data;
14221ae3d29cSBarry Smith     for (i=0; i<*n; i++) vals[i] = value[i];
14231ae3d29cSBarry Smith     amsopt->arraylength = *n;
14241ae3d29cSBarry Smith   }
1425acfcf0e5SJed Brown   ierr = PetscOptionsGetBoolArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr);
1426e2446a98SMatthew Knepley   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
1427e2446a98SMatthew Knepley     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%d",PetscOptionsObject.prefix ? PetscOptionsObject.prefix : "",opt+1,value[0]);CHKERRQ(ierr);
1428e2446a98SMatthew Knepley     for (i=1; i<*n; i++) {
1429e2446a98SMatthew Knepley       ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%d",value[i]);CHKERRQ(ierr);
1430e2446a98SMatthew Knepley     }
14312aa6d131SJed Brown     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,ManSection(man));CHKERRQ(ierr);
1432e2446a98SMatthew Knepley   }
1433e2446a98SMatthew Knepley   PetscFunctionReturn(0);
1434e2446a98SMatthew Knepley }
1435e2446a98SMatthew Knepley 
14368cc676e6SMatthew G Knepley #undef __FUNCT__
14378cc676e6SMatthew G Knepley #define __FUNCT__ "PetscOptionsViewer"
14388cc676e6SMatthew G Knepley /*@C
14398cc676e6SMatthew G Knepley    PetscOptionsInt - Gets a viewer appropriate for the type indicated by the user
14408cc676e6SMatthew G Knepley 
14418cc676e6SMatthew G Knepley    Logically Collective on the communicator passed in PetscOptionsBegin()
14428cc676e6SMatthew G Knepley 
14438cc676e6SMatthew G Knepley    Input Parameters:
14448cc676e6SMatthew G Knepley +  opt - option name
14458cc676e6SMatthew G Knepley .  text - short string that describes the option
14468cc676e6SMatthew G Knepley -  man - manual page with additional information on option
14478cc676e6SMatthew G Knepley 
14488cc676e6SMatthew G Knepley    Output Parameter:
14498cc676e6SMatthew G Knepley +  viewer - the viewer
14508cc676e6SMatthew G Knepley -  set - PETSC_TRUE if found, else PETSC_FALSE
14518cc676e6SMatthew G Knepley 
14528cc676e6SMatthew G Knepley    Level: beginner
14538cc676e6SMatthew G Knepley 
14548cc676e6SMatthew G Knepley    Concepts: options database^has int
14558cc676e6SMatthew G Knepley 
14568cc676e6SMatthew G Knepley    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
14578cc676e6SMatthew G Knepley If no value is provided ascii:stdout is used
14588cc676e6SMatthew G Knepley $       ascii[:[filename][:format]]   defaults to stdout - format can be one of info, info_detailed, or matlab, for example ascii::info prints just the info
14598cc676e6SMatthew G Knepley $                                     about the object to standard out
14608cc676e6SMatthew G Knepley $       binary[:filename]   defaults to binaryoutput
14618cc676e6SMatthew G Knepley $       draw
14628cc676e6SMatthew G Knepley $       socket[:port]    defaults to the standard output port
14638cc676e6SMatthew G Knepley 
1464cffb1e40SBarry Smith    Use PetscRestoreViewerDestroy() after using the viewer, otherwise a memory leak will occur
14658cc676e6SMatthew G Knepley 
14668cc676e6SMatthew G Knepley .seealso: PetscOptionsGetViewer(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
14678cc676e6SMatthew G Knepley           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool()
14688cc676e6SMatthew G Knepley           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(),
14698cc676e6SMatthew G Knepley           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
14708cc676e6SMatthew G Knepley           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
14718cc676e6SMatthew G Knepley           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
14728cc676e6SMatthew G Knepley           PetscOptionsList(), PetscOptionsEList()
14738cc676e6SMatthew G Knepley @*/
1474cffb1e40SBarry Smith PetscErrorCode  PetscOptionsViewer(const char opt[],const char text[],const char man[],PetscViewer *viewer,PetscViewerFormat *format,PetscBool  *set)
14758cc676e6SMatthew G Knepley {
14768cc676e6SMatthew G Knepley   PetscErrorCode ierr;
14778cc676e6SMatthew G Knepley   PetscOptions   amsopt;
14788cc676e6SMatthew G Knepley 
14798cc676e6SMatthew G Knepley   PetscFunctionBegin;
14808cc676e6SMatthew G Knepley   if (!PetscOptionsPublishCount) {
14818cc676e6SMatthew G Knepley     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_STRING,&amsopt);CHKERRQ(ierr);
1482*475446a1SBarry Smith     ierr = PetscStrallocpy("",(char**)&amsopt->data);CHKERRQ(ierr);
14838cc676e6SMatthew G Knepley   }
1484cffb1e40SBarry Smith   ierr = PetscOptionsGetViewer(PetscOptionsObject.comm,PetscOptionsObject.prefix,opt,viewer,format,set);CHKERRQ(ierr);
14858cc676e6SMatthew G Knepley   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
14868cc676e6SMatthew G Knepley     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%s>: %s (%s)\n",PetscOptionsObject.prefix ? PetscOptionsObject.prefix : "",opt+1,"",text,ManSection(man));CHKERRQ(ierr);
14878cc676e6SMatthew G Knepley   }
14888cc676e6SMatthew G Knepley   PetscFunctionReturn(0);
14898cc676e6SMatthew G Knepley }
14908cc676e6SMatthew G Knepley 
149153acd3b1SBarry Smith 
149253acd3b1SBarry Smith #undef __FUNCT__
149353acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsHead"
149453acd3b1SBarry Smith /*@C
1495b52f573bSBarry Smith      PetscOptionsHead - Puts a heading before listing any more published options. Used, for example,
149653acd3b1SBarry Smith             in KSPSetFromOptions_GMRES().
149753acd3b1SBarry Smith 
14983f9fe445SBarry Smith    Logically Collective on the communicator passed in PetscOptionsBegin()
149953acd3b1SBarry Smith 
150053acd3b1SBarry Smith    Input Parameter:
150153acd3b1SBarry Smith .   head - the heading text
150253acd3b1SBarry Smith 
150353acd3b1SBarry Smith 
150453acd3b1SBarry Smith    Level: intermediate
150553acd3b1SBarry Smith 
150653acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
150753acd3b1SBarry Smith 
1508b52f573bSBarry Smith           Can be followed by a call to PetscOptionsTail() in the same function.
150953acd3b1SBarry Smith 
151053acd3b1SBarry Smith    Concepts: options database^subheading
151153acd3b1SBarry Smith 
151253acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1513acfcf0e5SJed Brown            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
151453acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
151553acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1516acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
151753acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
151853acd3b1SBarry Smith @*/
15197087cfbeSBarry Smith PetscErrorCode  PetscOptionsHead(const char head[])
152053acd3b1SBarry Smith {
152153acd3b1SBarry Smith   PetscErrorCode ierr;
152253acd3b1SBarry Smith 
152353acd3b1SBarry Smith   PetscFunctionBegin;
152461b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
152553acd3b1SBarry Smith     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  %s\n",head);CHKERRQ(ierr);
152653acd3b1SBarry Smith   }
152753acd3b1SBarry Smith   PetscFunctionReturn(0);
152853acd3b1SBarry Smith }
152953acd3b1SBarry Smith 
153053acd3b1SBarry Smith 
153153acd3b1SBarry Smith 
153253acd3b1SBarry Smith 
153353acd3b1SBarry Smith 
153453acd3b1SBarry Smith 
1535