xref: /petsc/src/sys/objects/aoptions.c (revision 3194b578e315f5cda09358e793b5717ffe550174)
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 
8c6db04a5SJed Brown #include <petscsys.h>        /*I  "petscsys.h"   I*/
953acd3b1SBarry Smith #if defined(PETSC_HAVE_STDLIB_H)
1053acd3b1SBarry Smith #include <stdlib.h>
1153acd3b1SBarry Smith #endif
1253acd3b1SBarry Smith 
132aa6d131SJed Brown #define ManSection(str) ((str)?(str):"None")
142aa6d131SJed Brown 
1553acd3b1SBarry Smith /*
1653acd3b1SBarry Smith     Keep a linked list of options that have been posted and we are waiting for
173fc1eb6aSBarry Smith    user selection. See the manual page for PetscOptionsBegin()
1853acd3b1SBarry Smith 
1953acd3b1SBarry Smith     Eventually we'll attach this beast to a MPI_Comm
2053acd3b1SBarry Smith */
21f8d0b74dSMatthew Knepley PetscOptionsObjectType PetscOptionsObject;
2253acd3b1SBarry Smith PetscInt               PetscOptionsPublishCount = 0;
2353acd3b1SBarry Smith 
2453acd3b1SBarry Smith #undef __FUNCT__
2553acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsBegin_Private"
2653acd3b1SBarry Smith /*
2753acd3b1SBarry Smith     Handles setting up the data structure in a call to PetscOptionsBegin()
2853acd3b1SBarry Smith */
2953acd3b1SBarry Smith PetscErrorCode PetscOptionsBegin_Private(MPI_Comm comm,const char prefix[],const char title[],const char mansec[])
3053acd3b1SBarry Smith {
3153acd3b1SBarry Smith   PetscErrorCode ierr;
3253acd3b1SBarry Smith 
3353acd3b1SBarry Smith   PetscFunctionBegin;
3453acd3b1SBarry Smith   PetscOptionsObject.next          = 0;
3553acd3b1SBarry Smith   PetscOptionsObject.comm          = comm;
366356e834SBarry Smith   PetscOptionsObject.changedmethod = PETSC_FALSE;
37c31cb41cSBarry Smith   ierr = PetscFree(PetscOptionsObject.prefix);CHKERRQ(ierr);
3853acd3b1SBarry Smith   ierr = PetscStrallocpy(prefix,&PetscOptionsObject.prefix);CHKERRQ(ierr);
39c31cb41cSBarry Smith   ierr = PetscFree(PetscOptionsObject.title);CHKERRQ(ierr);
4053acd3b1SBarry Smith   ierr = PetscStrallocpy(title,&PetscOptionsObject.title);CHKERRQ(ierr);
4153acd3b1SBarry Smith 
4253acd3b1SBarry Smith   ierr = PetscOptionsHasName(PETSC_NULL,"-help",&PetscOptionsObject.printhelp);CHKERRQ(ierr);
4353acd3b1SBarry Smith   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1) {
4461b37b28SSatish Balay     if (!PetscOptionsObject.alreadyprinted) {
4553acd3b1SBarry Smith       ierr = (*PetscHelpPrintf)(comm,"%s -------------------------------------------------\n",title);CHKERRQ(ierr);
4653acd3b1SBarry Smith     }
4761b37b28SSatish Balay   }
4853acd3b1SBarry Smith   PetscFunctionReturn(0);
4953acd3b1SBarry Smith }
5053acd3b1SBarry Smith 
51*3194b578SJed Brown #undef __FUNCT__
52*3194b578SJed Brown #define __FUNCT__ "PetscObjectOptionsBegin_Private"
53*3194b578SJed Brown /*
54*3194b578SJed Brown     Handles setting up the data structure in a call to PetscObjectOptionsBegin()
55*3194b578SJed Brown */
56*3194b578SJed Brown PetscErrorCode PetscObjectOptionsBegin_Private(PetscObject obj)
57*3194b578SJed Brown {
58*3194b578SJed Brown   PetscErrorCode ierr;
59*3194b578SJed Brown   char title[256];
60*3194b578SJed Brown   PetscBool flg;
61*3194b578SJed Brown 
62*3194b578SJed Brown   PetscFunctionBegin;
63*3194b578SJed Brown   PetscValidHeader(obj,1);
64*3194b578SJed Brown   PetscOptionsObject.object = obj;
65*3194b578SJed Brown   PetscOptionsObject.alreadyprinted = obj->optionsprinted;
66*3194b578SJed Brown   ierr = PetscStrcmp(obj->description,obj->class_name,&flg);CHKERRQ(ierr);
67*3194b578SJed Brown   if (flg) {
68*3194b578SJed Brown     ierr = PetscSNPrintf(title,sizeof title,"%s options",obj->class_name);CHKERRQ(ierr);
69*3194b578SJed Brown   } else {
70*3194b578SJed Brown     ierr = PetscSNPrintf(title,sizeof title,"%s (%s) options",obj->description,obj->class_name);CHKERRQ(ierr);
71*3194b578SJed Brown   }
72*3194b578SJed Brown   ierr = PetscOptionsBegin_Private(obj->comm,obj->prefix,title,obj->mansec);CHKERRQ(ierr);
73*3194b578SJed Brown   PetscFunctionReturn(0);
74*3194b578SJed Brown }
75*3194b578SJed 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 
10153acd3b1SBarry Smith   if (!PetscOptionsObject.next) {
10253acd3b1SBarry Smith     PetscOptionsObject.next = *amsopt;
10353acd3b1SBarry Smith   } else {
10453acd3b1SBarry Smith     next = PetscOptionsObject.next;
10553acd3b1SBarry Smith     while (next->next) next = next->next;
10653acd3b1SBarry Smith     next->next = *amsopt;
10753acd3b1SBarry Smith   }
10853acd3b1SBarry Smith   PetscFunctionReturn(0);
10953acd3b1SBarry Smith }
11053acd3b1SBarry Smith 
11153acd3b1SBarry Smith #undef __FUNCT__
112aee2cecaSBarry Smith #define __FUNCT__ "PetscScanString"
113aee2cecaSBarry Smith /*
1143fc1eb6aSBarry Smith     PetscScanString -  Gets user input via stdin from process and broadcasts to all processes
1153fc1eb6aSBarry Smith 
1163fc1eb6aSBarry Smith     Collective on MPI_Comm
1173fc1eb6aSBarry Smith 
1183fc1eb6aSBarry Smith    Input Parameters:
1193fc1eb6aSBarry Smith +     commm - communicator for the broadcast, must be PETSC_COMM_WORLD
1203fc1eb6aSBarry Smith .     n - length of the string, must be the same on all processes
1213fc1eb6aSBarry Smith -     str - location to store input
122aee2cecaSBarry Smith 
123aee2cecaSBarry Smith     Bugs:
124aee2cecaSBarry Smith .   Assumes process 0 of the given communicator has access to stdin
125aee2cecaSBarry Smith 
126aee2cecaSBarry Smith */
1273fc1eb6aSBarry Smith static PetscErrorCode PetscScanString(MPI_Comm comm,size_t n,char str[])
128aee2cecaSBarry Smith {
129330cf3c9SBarry Smith   size_t         i;
130aee2cecaSBarry Smith   char           c;
1313fc1eb6aSBarry Smith   PetscMPIInt    rank,nm;
132aee2cecaSBarry Smith   PetscErrorCode ierr;
133aee2cecaSBarry Smith 
134aee2cecaSBarry Smith   PetscFunctionBegin;
135aee2cecaSBarry Smith   ierr = MPI_Comm_rank(comm,&rank);CHKERRQ(ierr);
136aee2cecaSBarry Smith   if (!rank) {
137aee2cecaSBarry Smith     c = (char) getchar();
138aee2cecaSBarry Smith     i = 0;
139aee2cecaSBarry Smith     while ( c != '\n' && i < n-1) {
140aee2cecaSBarry Smith       str[i++] = c;
141aee2cecaSBarry Smith       c = (char) getchar();
142aee2cecaSBarry Smith     }
143aee2cecaSBarry Smith     str[i] = 0;
144aee2cecaSBarry Smith   }
1453fc1eb6aSBarry Smith   nm   = PetscMPIIntCast(n);
1463fc1eb6aSBarry Smith   ierr = MPI_Bcast(str,nm,MPI_CHAR,0,comm);CHKERRQ(ierr);
147aee2cecaSBarry Smith   PetscFunctionReturn(0);
148aee2cecaSBarry Smith }
149aee2cecaSBarry Smith 
150aee2cecaSBarry Smith #undef __FUNCT__
151aee2cecaSBarry Smith #define __FUNCT__ "PetscOptionsGetFromTextInput"
152aee2cecaSBarry Smith /*
1533cc1e11dSBarry Smith     PetscOptionsGetFromTextInput - Presents all the PETSc Options processed by the program so the user may change them at runtime
154aee2cecaSBarry Smith 
155aee2cecaSBarry Smith     Notes: this isn't really practical, it is just to demonstrate the principle
156aee2cecaSBarry Smith 
157aee2cecaSBarry Smith     Bugs:
158aee2cecaSBarry Smith +    All processes must traverse through the exact same set of option queries do to the call to PetscScanString()
1593cc1e11dSBarry Smith .    Internal strings have arbitrary length and string copies are not checked that they fit into string space
160aee2cecaSBarry Smith -    Only works for PetscInt == int, PetscReal == double etc
161aee2cecaSBarry Smith 
1623cc1e11dSBarry Smith     Developer Notes: Normally the GUI that presents the options the user and retrieves the values would be running in a different
1633cc1e11dSBarry Smith      address space and communicating with the PETSc program
1643cc1e11dSBarry Smith 
165aee2cecaSBarry Smith */
166aee2cecaSBarry Smith PetscErrorCode PetscOptionsGetFromTextInput()
1676356e834SBarry Smith {
1686356e834SBarry Smith   PetscErrorCode ierr;
1696356e834SBarry Smith   PetscOptions   next = PetscOptionsObject.next;
1706356e834SBarry Smith   char           str[512];
171a4404d99SBarry Smith   PetscInt       id;
172a4404d99SBarry Smith   PetscReal      ir,*valr;
173330cf3c9SBarry Smith   PetscInt       *vald;
174330cf3c9SBarry Smith   size_t         i;
1756356e834SBarry Smith 
176e26ddf31SBarry Smith   ierr = (*PetscPrintf)(PETSC_COMM_WORLD,"%s -------------------------------------------------\n",PetscOptionsObject.title);CHKERRQ(ierr);
1776356e834SBarry Smith   while (next) {
1786356e834SBarry Smith     switch (next->type) {
1796356e834SBarry Smith       case OPTION_HEAD:
1806356e834SBarry Smith         break;
181e26ddf31SBarry Smith       case OPTION_INT_ARRAY:
182e26ddf31SBarry Smith         ierr = PetscPrintf(PETSC_COMM_WORLD,"-%s%s <",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",next->option+1);CHKERRQ(ierr);
183e26ddf31SBarry Smith         vald = (PetscInt*) next->data;
184e26ddf31SBarry Smith         for (i=0; i<next->arraylength; i++) {
185e26ddf31SBarry Smith           ierr = PetscPrintf(PETSC_COMM_WORLD,"%d",vald[i]);CHKERRQ(ierr);
186e26ddf31SBarry Smith           if (i < next->arraylength-1) {
187e26ddf31SBarry Smith             ierr = PetscPrintf(PETSC_COMM_WORLD,",");CHKERRQ(ierr);
188e26ddf31SBarry Smith           }
189e26ddf31SBarry Smith         }
190e26ddf31SBarry Smith         ierr = PetscPrintf(PETSC_COMM_WORLD,">: %s (%s)",next->text,next->man);CHKERRQ(ierr);
191e26ddf31SBarry Smith         ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr);
192e26ddf31SBarry Smith         if (str[0]) {
193e26ddf31SBarry Smith           PetscToken token;
194e26ddf31SBarry Smith           PetscInt   n=0,nmax = next->arraylength,*dvalue = (PetscInt*)next->data,start,end;
195e26ddf31SBarry Smith           size_t     len;
196e26ddf31SBarry Smith           char*      value;
197ace3abfcSBarry Smith           PetscBool  foundrange;
198e26ddf31SBarry Smith 
199e26ddf31SBarry Smith           next->set = PETSC_TRUE;
200e26ddf31SBarry Smith           value = str;
201e26ddf31SBarry Smith 	  ierr = PetscTokenCreate(value,',',&token);CHKERRQ(ierr);
202e26ddf31SBarry Smith 	  ierr = PetscTokenFind(token,&value);CHKERRQ(ierr);
203e26ddf31SBarry Smith 	  while (n < nmax) {
204e26ddf31SBarry Smith 	    if (!value) break;
205e26ddf31SBarry Smith 
206e26ddf31SBarry Smith 	    /* look for form  d-D where d and D are integers */
207e26ddf31SBarry Smith 	    foundrange = PETSC_FALSE;
208e26ddf31SBarry Smith 	    ierr      = PetscStrlen(value,&len);CHKERRQ(ierr);
209e26ddf31SBarry Smith 	    if (value[0] == '-') i=2;
210e26ddf31SBarry Smith 	    else i=1;
211330cf3c9SBarry Smith 	    for (;i<len; i++) {
212e26ddf31SBarry Smith 	      if (value[i] == '-') {
213e32f2f54SBarry Smith 		if (i == len-1) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_USER,"Error in %D-th array entry %s\n",n,value);
214e26ddf31SBarry Smith 		value[i] = 0;
215cfbddea1SSatish Balay 		ierr     = PetscOptionsStringToInt(value,&start);CHKERRQ(ierr);
216cfbddea1SSatish Balay 		ierr     = PetscOptionsStringToInt(value+i+1,&end);CHKERRQ(ierr);
217e32f2f54SBarry 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);
218e32f2f54SBarry 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);
219e26ddf31SBarry Smith 		for (;start<end; start++) {
220e26ddf31SBarry Smith 		  *dvalue = start; dvalue++;n++;
221e26ddf31SBarry Smith 		}
222e26ddf31SBarry Smith 		foundrange = PETSC_TRUE;
223e26ddf31SBarry Smith 		break;
224e26ddf31SBarry Smith 	      }
225e26ddf31SBarry Smith 	    }
226e26ddf31SBarry Smith 	    if (!foundrange) {
227cfbddea1SSatish Balay 	      ierr      = PetscOptionsStringToInt(value,dvalue);CHKERRQ(ierr);
228e26ddf31SBarry Smith 	      dvalue++;
229e26ddf31SBarry Smith 	      n++;
230e26ddf31SBarry Smith 	    }
231e26ddf31SBarry Smith 	    ierr = PetscTokenFind(token,&value);CHKERRQ(ierr);
232e26ddf31SBarry Smith 	  }
233e26ddf31SBarry Smith 	  ierr = PetscTokenDestroy(token);CHKERRQ(ierr);
234e26ddf31SBarry Smith         }
235e26ddf31SBarry Smith         break;
236e26ddf31SBarry Smith       case OPTION_REAL_ARRAY:
237e26ddf31SBarry Smith         ierr = PetscPrintf(PETSC_COMM_WORLD,"-%s%s <",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",next->option+1);CHKERRQ(ierr);
238e26ddf31SBarry Smith         valr = (PetscReal*) next->data;
239e26ddf31SBarry Smith         for (i=0; i<next->arraylength; i++) {
240e26ddf31SBarry Smith           ierr = PetscPrintf(PETSC_COMM_WORLD,"%g",valr[i]);CHKERRQ(ierr);
241e26ddf31SBarry Smith           if (i < next->arraylength-1) {
242e26ddf31SBarry Smith             ierr = PetscPrintf(PETSC_COMM_WORLD,",");CHKERRQ(ierr);
243e26ddf31SBarry Smith           }
244e26ddf31SBarry Smith         }
245e26ddf31SBarry Smith         ierr = PetscPrintf(PETSC_COMM_WORLD,">: %s (%s)",next->text,next->man);CHKERRQ(ierr);
246e26ddf31SBarry Smith         ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr);
247e26ddf31SBarry Smith         if (str[0]) {
248e26ddf31SBarry Smith           PetscToken token;
249e26ddf31SBarry Smith           PetscInt   n=0,nmax = next->arraylength;
250e26ddf31SBarry Smith           PetscReal   *dvalue = (PetscReal*)next->data;
251e26ddf31SBarry Smith           char*      value;
252e26ddf31SBarry Smith 
253e26ddf31SBarry Smith           next->set = PETSC_TRUE;
254e26ddf31SBarry Smith           value = str;
255e26ddf31SBarry Smith 	  ierr = PetscTokenCreate(value,',',&token);CHKERRQ(ierr);
256e26ddf31SBarry Smith 	  ierr = PetscTokenFind(token,&value);CHKERRQ(ierr);
257e26ddf31SBarry Smith 	  while (n < nmax) {
258e26ddf31SBarry Smith 	    if (!value) break;
259cfbddea1SSatish Balay             ierr      = PetscOptionsStringToReal(value,dvalue);CHKERRQ(ierr);
260e26ddf31SBarry Smith 	    dvalue++;
261e26ddf31SBarry Smith 	    n++;
262e26ddf31SBarry Smith 	    ierr = PetscTokenFind(token,&value);CHKERRQ(ierr);
263e26ddf31SBarry Smith 	  }
264e26ddf31SBarry Smith 	  ierr = PetscTokenDestroy(token);CHKERRQ(ierr);
265e26ddf31SBarry Smith         }
266e26ddf31SBarry Smith         break;
2676356e834SBarry Smith       case OPTION_INT:
268e26ddf31SBarry 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);
2693fc1eb6aSBarry Smith         ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr);
2703fc1eb6aSBarry Smith         if (str[0]) {
271c272547aSJed Brown #if defined(PETSC_USE_64BIT_INDICES)
272c272547aSJed Brown           sscanf(str,"%lld",&id);
273c272547aSJed Brown #else
274aee2cecaSBarry Smith           sscanf(str,"%d",&id);
275c272547aSJed Brown #endif
276aee2cecaSBarry Smith           next->set = PETSC_TRUE;
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);
288513dbe71SLisandro Dalcin #elif defined(PETSC_USE_REAL_LONG_DOUBLE)
289513dbe71SLisandro Dalcin           sscanf(str,"%Le",&ir);
290ce63c4c1SBarry Smith #elif defined(PETSC_USE_REAL___FLOAT128)
291d9822059SBarry Smith           ir = strtoflt128(str,0);
292d9822059SBarry Smith #else
293513dbe71SLisandro Dalcin           SETERRQ(PETSC_COMM_SELF,PETSC_ERR_LIB,"Unknown scalar type");
294a4404d99SBarry Smith #endif
295aee2cecaSBarry Smith           next->set = PETSC_TRUE;
296aee2cecaSBarry Smith           *((PetscReal*)next->data) = ir;
297aee2cecaSBarry Smith         }
298aee2cecaSBarry Smith         break;
299aee2cecaSBarry Smith       case OPTION_LOGICAL:
300aee2cecaSBarry Smith       case OPTION_STRING:
301e26ddf31SBarry 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);
3023fc1eb6aSBarry Smith         ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr);
3033fc1eb6aSBarry Smith         if (str[0]) {
304aee2cecaSBarry Smith           next->set = PETSC_TRUE;
305330cf3c9SBarry Smith           ierr = PetscStrcpy((char*)next->data,str);CHKERRQ(ierr);
3066356e834SBarry Smith         }
3076356e834SBarry Smith         break;
3083cc1e11dSBarry Smith       case OPTION_LIST:
3093cc1e11dSBarry Smith         ierr = PetscFListPrintTypes(PETSC_COMM_WORLD,stdout,PetscOptionsObject.prefix,next->option,next->text,next->man,next->flist,(char*)next->data);CHKERRQ(ierr);
3103cc1e11dSBarry Smith         ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr);
3113cc1e11dSBarry Smith         if (str[0]) {
3123cc1e11dSBarry Smith 	  PetscOptionsObject.changedmethod = PETSC_TRUE;
3133cc1e11dSBarry Smith           next->set = PETSC_TRUE;
314330cf3c9SBarry Smith           ierr = PetscStrcpy((char*)next->data,str);CHKERRQ(ierr);
3153cc1e11dSBarry Smith         }
3163cc1e11dSBarry Smith         break;
317b432afdaSMatthew Knepley     default:
318b432afdaSMatthew Knepley       break;
3196356e834SBarry Smith     }
3206356e834SBarry Smith     next = next->next;
3216356e834SBarry Smith   }
3226356e834SBarry Smith   PetscFunctionReturn(0);
3236356e834SBarry Smith }
3246356e834SBarry Smith 
325b3506946SBarry Smith #if defined(PETSC_HAVE_AMS)
3261ae3d29cSBarry Smith #define CHKERRAMS(err)  if (err) {char *msg; AMS_Explain_error((err), &(msg)); SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"AMS Error: %s",msg);}
3271ae3d29cSBarry Smith #define CHKERRAMSFieldName(err,fn)  if (err) {char *msg; AMS_Explain_error((err), &(msg)); SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_LIB,"Fieldname %s, AMS Error: %s",fn,msg);}
328d5649816SBarry Smith 
329d5649816SBarry Smith static int  count = 0;
330d5649816SBarry Smith 
331b3506946SBarry Smith #undef __FUNCT__
332d5649816SBarry Smith #define __FUNCT__ "PetscOptionsAMSDestroy"
333d5649816SBarry Smith PetscErrorCode PetscOptionsAMSDestroy(void)
334d5649816SBarry Smith {
335d5649816SBarry Smith   PetscErrorCode ierr;
336d5649816SBarry Smith   AMS_Comm       acomm = -1;
337d5649816SBarry Smith   AMS_Memory     amem = -1;
338d5649816SBarry Smith   char           options[16];
339d5649816SBarry Smith   const char     *string = "Exit";
340d5649816SBarry Smith 
341d5649816SBarry Smith   /* the next line is a bug, this will only work if all processors are here, the comm passed in is ignored!!! */
342d5649816SBarry Smith   ierr = PetscViewerAMSGetAMSComm(PETSC_VIEWER_AMS_(PETSC_COMM_WORLD),&acomm);CHKERRQ(ierr);
343d5649816SBarry Smith   sprintf(options,"Options_%d",count++);
344d5649816SBarry Smith   ierr = AMS_Memory_create(acomm,options,&amem);CHKERRAMS(ierr);
345d5649816SBarry Smith   ierr = AMS_Memory_add_field(amem,"Exit",&string,1,AMS_STRING,AMS_READ,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,"Exit");
346d5649816SBarry Smith 
347d5649816SBarry Smith   ierr = AMS_Memory_take_access(amem);CHKERRAMS(ierr);
348d5649816SBarry Smith   ierr = AMS_Memory_publish(amem);CHKERRAMS(ierr);
349d5649816SBarry Smith   ierr = AMS_Memory_grant_access(amem);CHKERRAMS(ierr);
350d5649816SBarry Smith   /* wait until accessor has unlocked the memory */
351d5649816SBarry Smith   ierr = AMS_Memory_lock(amem,0);CHKERRAMS(ierr);
352d5649816SBarry Smith   ierr = AMS_Memory_take_access(amem);CHKERRAMS(ierr);
353d5649816SBarry Smith   ierr = AMS_Memory_grant_access(amem);CHKERRAMS(ierr);
354d5649816SBarry Smith   ierr = AMS_Memory_destroy(amem);CHKERRAMS(ierr);
355d5649816SBarry Smith   PetscFunctionReturn(0);
356d5649816SBarry Smith }
357d5649816SBarry Smith 
358d5649816SBarry Smith #undef __FUNCT__
359d5649816SBarry Smith #define __FUNCT__ "PetscOptionsAMSInput"
360b3506946SBarry Smith /*
361d5649816SBarry Smith     PetscOptionsAMSInput - Presents all the PETSc Options processed by the program so the user may change them at runtime using the AMS
362b3506946SBarry Smith 
363b3506946SBarry Smith     Bugs:
364b3506946SBarry Smith +    All processes must traverse through the exact same set of option queries do to the call to PetscScanString()
365b3506946SBarry Smith .    Internal strings have arbitrary length and string copies are not checked that they fit into string space
366b3506946SBarry Smith -    Only works for PetscInt == int, PetscReal == double etc
367b3506946SBarry Smith 
368b3506946SBarry Smith 
369b3506946SBarry Smith */
370d5649816SBarry Smith PetscErrorCode PetscOptionsAMSInput()
371b3506946SBarry Smith {
372b3506946SBarry Smith   PetscErrorCode ierr;
373b3506946SBarry Smith   PetscOptions   next = PetscOptionsObject.next;
374d5649816SBarry Smith   static int     mancount = 0;
375b3506946SBarry Smith   char           options[16];
376b3506946SBarry Smith   AMS_Comm       acomm = -1;
377b3506946SBarry Smith   AMS_Memory     amem = -1;
378ace3abfcSBarry Smith   PetscBool      changedmethod = PETSC_FALSE;
3799f32e415SBarry Smith   char           manname[16];
380b3506946SBarry Smith 
381b3506946SBarry Smith   /* the next line is a bug, this will only work if all processors are here, the comm passed in is ignored!!! */
382b3506946SBarry Smith   ierr = PetscViewerAMSGetAMSComm(PETSC_VIEWER_AMS_(PETSC_COMM_WORLD),&acomm);CHKERRQ(ierr);
383b3506946SBarry Smith   sprintf(options,"Options_%d",count++);
3841ae3d29cSBarry Smith   ierr = AMS_Memory_create(acomm,options,&amem);CHKERRAMS(ierr);
3851ae3d29cSBarry Smith   ierr = AMS_Memory_take_access(amem);CHKERRAMS(ierr);
3861bc75a8dSBarry Smith   PetscOptionsObject.pprefix = PetscOptionsObject.prefix; /* AMS will change this, so cannot pass prefix directly */
3871bc75a8dSBarry Smith 
3881ae3d29cSBarry Smith   ierr = AMS_Memory_add_field(amem,PetscOptionsObject.title,&PetscOptionsObject.pprefix,1,AMS_STRING,AMS_READ,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,PetscOptionsObject.title);
3891ae3d29cSBarry Smith   //  ierr = AMS_Memory_add_field(amem,"mansec",&PetscOptionsObject.pprefix,1,AMS_STRING,AMS_READ,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMS(ierr);
3901ae3d29cSBarry Smith   ierr = AMS_Memory_add_field(amem,"ChangedMethod",&changedmethod,1,AMS_BOOLEAN,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,"ChangedMethod");
391b3506946SBarry Smith 
392b3506946SBarry Smith   while (next) {
3931ae3d29cSBarry Smith     ierr = AMS_Memory_add_field(amem,next->option,&next->set,1,AMS_INT,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->option);
3941bc75a8dSBarry Smith     ierr =  PetscMalloc(sizeof(char*),&next->pman);CHKERRQ(ierr);
3951bc75a8dSBarry Smith     *(char **)next->pman = next->man;
3969f32e415SBarry Smith     sprintf(manname,"man_%d",mancount++);
3971ae3d29cSBarry Smith     ierr = AMS_Memory_add_field(amem,manname,next->pman,1,AMS_STRING,AMS_READ,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,manname);
3989f32e415SBarry Smith 
399b3506946SBarry Smith     switch (next->type) {
400b3506946SBarry Smith       case OPTION_HEAD:
401b3506946SBarry Smith         break;
402b3506946SBarry Smith       case OPTION_INT_ARRAY:
4031ae3d29cSBarry Smith         ierr = AMS_Memory_add_field(amem,next->text,next->data,next->arraylength,AMS_INT,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->text);
404b3506946SBarry Smith         break;
405b3506946SBarry Smith       case OPTION_REAL_ARRAY:
4061ae3d29cSBarry Smith         ierr = AMS_Memory_add_field(amem,next->text,next->data,next->arraylength,AMS_DOUBLE,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->text);
407b3506946SBarry Smith         break;
408b3506946SBarry Smith       case OPTION_INT:
4091ae3d29cSBarry Smith 	ierr = AMS_Memory_add_field(amem,next->text,next->data,1,AMS_INT,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->text);
410b3506946SBarry Smith         break;
411b3506946SBarry Smith       case OPTION_REAL:
4121ae3d29cSBarry Smith 	ierr = AMS_Memory_add_field(amem,next->text,next->data,1,AMS_DOUBLE,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->text);
413b3506946SBarry Smith         break;
414b3506946SBarry Smith       case OPTION_LOGICAL:
4151ae3d29cSBarry Smith 	ierr = AMS_Memory_add_field(amem,next->text,next->data,1,AMS_BOOLEAN,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->text);
4161ae3d29cSBarry Smith         break;
4171ae3d29cSBarry Smith       case OPTION_LOGICAL_ARRAY:
4181ae3d29cSBarry Smith 	ierr = AMS_Memory_add_field(amem,next->text,next->data,next->arraylength,AMS_BOOLEAN,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->text);
41971f08665SBarry Smith         break;
420b3506946SBarry Smith       case OPTION_STRING:
4211ae3d29cSBarry Smith 	ierr = AMS_Memory_add_field(amem,next->text,next->data,1,AMS_STRING,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->text);
4221ae3d29cSBarry Smith         break;
4231ae3d29cSBarry Smith       case OPTION_STRING_ARRAY:
4241ae3d29cSBarry Smith 	ierr = AMS_Memory_add_field(amem,next->text,next->data,next->arraylength,AMS_STRING,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->text);
425b3506946SBarry Smith         break;
426b3506946SBarry Smith       case OPTION_LIST:
42771f08665SBarry Smith         {PetscInt  ntext;
42871f08665SBarry Smith         char       ldefault[128];
42971f08665SBarry Smith 	ierr = PetscStrcpy(ldefault,"DEFAULT:");CHKERRQ(ierr);
43071f08665SBarry Smith 	ierr = PetscStrcat(ldefault,next->text);CHKERRQ(ierr);
4311ae3d29cSBarry Smith 	ierr = AMS_Memory_add_field(amem,ldefault,next->data,1,AMS_STRING,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,ldefault);
43271f08665SBarry Smith 	ierr = PetscFListGet(next->flist,(char***)&next->edata,&ntext);CHKERRQ(ierr);
433d5649816SBarry Smith 	ierr = AMS_Memory_add_field(amem,next->text,next->edata,ntext-1,AMS_STRING,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->text);
4341ae3d29cSBarry Smith         break;}
4351ae3d29cSBarry Smith       case OPTION_ELIST:
436d5649816SBarry Smith         {PetscInt  ntext = next->nlist;
4371ae3d29cSBarry Smith         char       ldefault[128];
4381ae3d29cSBarry Smith 	ierr = PetscStrcpy(ldefault,"DEFAULT:");CHKERRQ(ierr);
4391ae3d29cSBarry Smith 	ierr = PetscStrcat(ldefault,next->text);CHKERRQ(ierr);
4401ae3d29cSBarry Smith 	ierr = AMS_Memory_add_field(amem,ldefault,next->data,1,AMS_STRING,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,ldefault);
4411ae3d29cSBarry Smith 	ierr = PetscMalloc((ntext+1)*sizeof(char**),&next->edata);CHKERRQ(ierr);
4421ae3d29cSBarry Smith         ierr = PetscMemcpy(next->edata,next->list,ntext*sizeof(char*));CHKERRQ(ierr);
4431ae3d29cSBarry Smith 	ierr = AMS_Memory_add_field(amem,next->text,next->edata,ntext,AMS_STRING,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->text);
44471f08665SBarry Smith         break;}
445b3506946SBarry Smith     default:
446b3506946SBarry Smith       break;
447b3506946SBarry Smith     }
448b3506946SBarry Smith     next = next->next;
449b3506946SBarry Smith   }
450b3506946SBarry Smith 
4511ae3d29cSBarry Smith   ierr = AMS_Memory_publish(amem);CHKERRAMS(ierr);
4521ae3d29cSBarry Smith   ierr = AMS_Memory_grant_access(amem);CHKERRAMS(ierr);
453b3506946SBarry Smith   /* wait until accessor has unlocked the memory */
4541ae3d29cSBarry Smith   ierr = AMS_Memory_lock(amem,0);CHKERRAMS(ierr);
4551ae3d29cSBarry Smith   ierr = AMS_Memory_take_access(amem);CHKERRAMS(ierr);
456b3506946SBarry Smith 
457b3506946SBarry Smith   /* reset counter to -2; this updates the screen with the new options for the selected method */
458b3506946SBarry Smith   if (changedmethod) PetscOptionsPublishCount = -2;
459b3506946SBarry Smith 
4601ae3d29cSBarry Smith   ierr = AMS_Memory_grant_access(amem);CHKERRAMS(ierr);
4611ae3d29cSBarry Smith   ierr = AMS_Memory_destroy(amem);CHKERRAMS(ierr);
462b3506946SBarry Smith   PetscFunctionReturn(0);
463b3506946SBarry Smith }
464b3506946SBarry Smith #endif
465b3506946SBarry Smith 
4666356e834SBarry Smith #undef __FUNCT__
46753acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsEnd_Private"
46853acd3b1SBarry Smith PetscErrorCode PetscOptionsEnd_Private(void)
46953acd3b1SBarry Smith {
47053acd3b1SBarry Smith   PetscErrorCode ierr;
4716356e834SBarry Smith   PetscOptions   last;
4726356e834SBarry Smith   char           option[256],value[1024],tmp[32];
473330cf3c9SBarry Smith   size_t         j;
47453acd3b1SBarry Smith 
47553acd3b1SBarry Smith   PetscFunctionBegin;
4766356e834SBarry Smith 
4771bc75a8dSBarry Smith   CHKMEMQ;
478aee2cecaSBarry Smith   if (PetscOptionsObject.next) {
479b3506946SBarry Smith     if (!PetscOptionsPublishCount) {
480b3506946SBarry Smith #if defined(PETSC_HAVE_AMS)
481d5649816SBarry Smith       ierr = PetscOptionsAMSInput();CHKERRQ(ierr);
482b3506946SBarry Smith #else
48371f08665SBarry Smith       ierr = PetscOptionsGetFromTextInput();CHKERRQ(ierr);
484b3506946SBarry Smith #endif
485aee2cecaSBarry Smith     }
486aee2cecaSBarry Smith   }
4876356e834SBarry Smith 
488c31cb41cSBarry Smith   ierr = PetscFree(PetscOptionsObject.title);CHKERRQ(ierr);
489c31cb41cSBarry Smith   ierr = PetscFree(PetscOptionsObject.prefix);CHKERRQ(ierr);
4906356e834SBarry Smith 
4916356e834SBarry Smith   /* reset counter to -2; this updates the screen with the new options for the selected method */
4926356e834SBarry Smith   if (PetscOptionsObject.changedmethod) PetscOptionsPublishCount = -2;
49361b37b28SSatish Balay   /* reset alreadyprinted flag */
49461b37b28SSatish Balay   PetscOptionsObject.alreadyprinted = PETSC_FALSE;
495*3194b578SJed Brown   if (PetscOptionsObject.object) PetscOptionsObject.object->optionsprinted = PETSC_TRUE;
496*3194b578SJed Brown   PetscOptionsObject.object = PETSC_NULL;
4976356e834SBarry Smith 
4986356e834SBarry Smith   while (PetscOptionsObject.next) {
4996356e834SBarry Smith     if (PetscOptionsObject.next->set) {
5006356e834SBarry Smith       if (PetscOptionsObject.prefix) {
5016356e834SBarry Smith         ierr = PetscStrcpy(option,"-");CHKERRQ(ierr);
5026356e834SBarry Smith         ierr = PetscStrcat(option,PetscOptionsObject.prefix);CHKERRQ(ierr);
5036356e834SBarry Smith         ierr = PetscStrcat(option,PetscOptionsObject.next->option+1);CHKERRQ(ierr);
5046356e834SBarry Smith       } else {
5056356e834SBarry Smith         ierr = PetscStrcpy(option,PetscOptionsObject.next->option);CHKERRQ(ierr);
5066356e834SBarry Smith       }
5076356e834SBarry Smith 
5086356e834SBarry Smith       switch (PetscOptionsObject.next->type) {
5096356e834SBarry Smith         case OPTION_HEAD:
5106356e834SBarry Smith           break;
511e26ddf31SBarry Smith         case OPTION_INT_ARRAY:
512e26ddf31SBarry Smith           sprintf(value,"%d",(int)((PetscInt*)PetscOptionsObject.next->data)[0]);
513e26ddf31SBarry Smith           for (j=1; j<PetscOptionsObject.next->arraylength; j++) {
514e26ddf31SBarry Smith             sprintf(tmp,"%d",(int)((PetscInt*)PetscOptionsObject.next->data)[j]);
515e26ddf31SBarry Smith             ierr = PetscStrcat(value,",");CHKERRQ(ierr);
516e26ddf31SBarry Smith             ierr = PetscStrcat(value,tmp);CHKERRQ(ierr);
517e26ddf31SBarry Smith           }
518e26ddf31SBarry Smith           break;
5196356e834SBarry Smith         case OPTION_INT:
5207a72a596SBarry Smith           sprintf(value,"%d",(int) *(PetscInt*)PetscOptionsObject.next->data);
5216356e834SBarry Smith           break;
5226356e834SBarry Smith         case OPTION_REAL:
5237a72a596SBarry Smith           sprintf(value,"%g",(double) *(PetscReal*)PetscOptionsObject.next->data);
5246356e834SBarry Smith           break;
5256356e834SBarry Smith         case OPTION_REAL_ARRAY:
5267a72a596SBarry Smith           sprintf(value,"%g",(double)((PetscReal*)PetscOptionsObject.next->data)[0]);
5276356e834SBarry Smith           for (j=1; j<PetscOptionsObject.next->arraylength; j++) {
5287a72a596SBarry Smith             sprintf(tmp,"%g",(double)((PetscReal*)PetscOptionsObject.next->data)[j]);
5296356e834SBarry Smith             ierr = PetscStrcat(value,",");CHKERRQ(ierr);
5306356e834SBarry Smith             ierr = PetscStrcat(value,tmp);CHKERRQ(ierr);
5316356e834SBarry Smith           }
5326356e834SBarry Smith           break;
5336356e834SBarry Smith         case OPTION_LOGICAL:
53471f08665SBarry Smith           sprintf(value,"%d",*(int*)PetscOptionsObject.next->data);
5356356e834SBarry Smith           break;
5361ae3d29cSBarry Smith       case OPTION_LOGICAL_ARRAY:
537ace3abfcSBarry Smith           sprintf(value,"%d",(int)((PetscBool*)PetscOptionsObject.next->data)[0]);
5381ae3d29cSBarry Smith           for (j=1; j<PetscOptionsObject.next->arraylength; j++) {
539ace3abfcSBarry Smith             sprintf(tmp,"%d",(int)((PetscBool*)PetscOptionsObject.next->data)[j]);
5401ae3d29cSBarry Smith             ierr = PetscStrcat(value,",");CHKERRQ(ierr);
5411ae3d29cSBarry Smith             ierr = PetscStrcat(value,tmp);CHKERRQ(ierr);
5421ae3d29cSBarry Smith           }
5431ae3d29cSBarry Smith           break;
5446356e834SBarry Smith         case OPTION_LIST:
5451ae3d29cSBarry Smith         case OPTION_ELIST:
54671f08665SBarry Smith           ierr = PetscStrcpy(value,*(char**)PetscOptionsObject.next->data);CHKERRQ(ierr);
5476356e834SBarry Smith           break;
5481ae3d29cSBarry Smith         case OPTION_STRING:
54971f08665SBarry Smith           ierr = PetscStrcpy(value,*(char**)PetscOptionsObject.next->data);CHKERRQ(ierr);
5501ae3d29cSBarry Smith         case OPTION_STRING_ARRAY:
5511ae3d29cSBarry Smith           sprintf(value,"%s",((char**)PetscOptionsObject.next->data)[0]);
5521ae3d29cSBarry Smith           for (j=1; j<PetscOptionsObject.next->arraylength; j++) {
5531ae3d29cSBarry Smith             sprintf(tmp,"%s",((char**)PetscOptionsObject.next->data)[j]);
5541ae3d29cSBarry Smith             ierr = PetscStrcat(value,",");CHKERRQ(ierr);
5551ae3d29cSBarry Smith             ierr = PetscStrcat(value,tmp);CHKERRQ(ierr);
5561ae3d29cSBarry Smith           }
5576356e834SBarry Smith           break;
5586356e834SBarry Smith       }
5596356e834SBarry Smith       ierr = PetscOptionsSetValue(option,value);CHKERRQ(ierr);
5606356e834SBarry Smith     }
561503cfb0cSBarry Smith     ierr   = PetscFree(PetscOptionsObject.next->text);CHKERRQ(ierr);
562503cfb0cSBarry Smith     ierr   = PetscFree(PetscOptionsObject.next->option);CHKERRQ(ierr);
5636356e834SBarry Smith     ierr   = PetscFree(PetscOptionsObject.next->man);CHKERRQ(ierr);
56405b42c5fSBarry Smith     ierr   = PetscFree(PetscOptionsObject.next->data);CHKERRQ(ierr);
56571f08665SBarry Smith     ierr   = PetscFree(PetscOptionsObject.next->edata);CHKERRQ(ierr);
5666356e834SBarry Smith     last                    = PetscOptionsObject.next;
5676356e834SBarry Smith     PetscOptionsObject.next = PetscOptionsObject.next->next;
5686356e834SBarry Smith     ierr                    = PetscFree(last);CHKERRQ(ierr);
5691bc75a8dSBarry Smith     CHKMEMQ;
5706356e834SBarry Smith   }
5711bc75a8dSBarry Smith   CHKMEMQ;
5726356e834SBarry Smith   PetscOptionsObject.next = 0;
57353acd3b1SBarry Smith   PetscFunctionReturn(0);
57453acd3b1SBarry Smith }
57553acd3b1SBarry Smith 
57653acd3b1SBarry Smith #undef __FUNCT__
57753acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsEnum"
57853acd3b1SBarry Smith /*@C
57953acd3b1SBarry Smith    PetscOptionsEnum - Gets the enum value for a particular option in the database.
58053acd3b1SBarry Smith 
5813f9fe445SBarry Smith    Logically Collective on the communicator passed in PetscOptionsBegin()
58253acd3b1SBarry Smith 
58353acd3b1SBarry Smith    Input Parameters:
58453acd3b1SBarry Smith +  opt - option name
58553acd3b1SBarry Smith .  text - short string that describes the option
58653acd3b1SBarry Smith .  man - manual page with additional information on option
58753acd3b1SBarry Smith .  list - array containing the list of choices, followed by the enum name, followed by the enum prefix, followed by a null
58853acd3b1SBarry Smith -  defaultv - the default (current) value
58953acd3b1SBarry Smith 
59053acd3b1SBarry Smith    Output Parameter:
59153acd3b1SBarry Smith +  value - the  value to return
59253acd3b1SBarry Smith -  flg - PETSC_TRUE if found, else PETSC_FALSE
59353acd3b1SBarry Smith 
59453acd3b1SBarry Smith    Level: beginner
59553acd3b1SBarry Smith 
59653acd3b1SBarry Smith    Concepts: options database
59753acd3b1SBarry Smith 
59853acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
59953acd3b1SBarry Smith 
60053acd3b1SBarry Smith           list is usually something like PCASMTypes or some other predefined list of enum names
60153acd3b1SBarry Smith 
60253acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
603acfcf0e5SJed Brown           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool()
604acfcf0e5SJed Brown           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(),
60553acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
60653acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
607acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
60853acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
60953acd3b1SBarry Smith @*/
6107087cfbeSBarry Smith PetscErrorCode  PetscOptionsEnum(const char opt[],const char text[],const char man[],const char *const*list,PetscEnum defaultv,PetscEnum *value,PetscBool  *set)
61153acd3b1SBarry Smith {
61253acd3b1SBarry Smith   PetscErrorCode ierr;
61353acd3b1SBarry Smith   PetscInt       ntext = 0;
614aa5bb8c0SSatish Balay   PetscInt       tval;
615ace3abfcSBarry Smith   PetscBool      tflg;
61653acd3b1SBarry Smith 
61753acd3b1SBarry Smith   PetscFunctionBegin;
61853acd3b1SBarry Smith   while (list[ntext++]) {
619e32f2f54SBarry Smith     if (ntext > 50) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"List argument appears to be wrong or have more than 50 entries");
62053acd3b1SBarry Smith   }
621e32f2f54SBarry Smith   if (ntext < 3) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"List argument must have at least two entries: typename and type prefix");
62253acd3b1SBarry Smith   ntext -= 3;
623aa5bb8c0SSatish Balay   ierr = PetscOptionsEList(opt,text,man,list,ntext,list[defaultv],&tval,&tflg);CHKERRQ(ierr);
624aa5bb8c0SSatish Balay   /* with PETSC_USE_64BIT_INDICES sizeof(PetscInt) != sizeof(PetscEnum) */
625aa5bb8c0SSatish Balay   if (tflg) *value = (PetscEnum)tval;
626aa5bb8c0SSatish Balay   if (set)  *set   = tflg;
62753acd3b1SBarry Smith   PetscFunctionReturn(0);
62853acd3b1SBarry Smith }
62953acd3b1SBarry Smith 
63053acd3b1SBarry Smith /* -------------------------------------------------------------------------------------------------------------*/
63153acd3b1SBarry Smith #undef __FUNCT__
63253acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsInt"
63353acd3b1SBarry Smith /*@C
63453acd3b1SBarry Smith    PetscOptionsInt - Gets the integer value for a particular option in the database.
63553acd3b1SBarry Smith 
6363f9fe445SBarry Smith    Logically Collective on the communicator passed in PetscOptionsBegin()
63753acd3b1SBarry Smith 
63853acd3b1SBarry Smith    Input Parameters:
63953acd3b1SBarry Smith +  opt - option name
64053acd3b1SBarry Smith .  text - short string that describes the option
64153acd3b1SBarry Smith .  man - manual page with additional information on option
64253acd3b1SBarry Smith -  defaultv - the default (current) value
64353acd3b1SBarry Smith 
64453acd3b1SBarry Smith    Output Parameter:
64553acd3b1SBarry Smith +  value - the integer value to return
64653acd3b1SBarry Smith -  flg - PETSC_TRUE if found, else PETSC_FALSE
64753acd3b1SBarry Smith 
64853acd3b1SBarry Smith    Level: beginner
64953acd3b1SBarry Smith 
65053acd3b1SBarry Smith    Concepts: options database^has int
65153acd3b1SBarry Smith 
65253acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
65353acd3b1SBarry Smith 
65453acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
655acfcf0e5SJed Brown           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool()
656acfcf0e5SJed Brown           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(),
65753acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
65853acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
659acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
66053acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
66153acd3b1SBarry Smith @*/
6627087cfbeSBarry Smith PetscErrorCode  PetscOptionsInt(const char opt[],const char text[],const char man[],PetscInt defaultv,PetscInt *value,PetscBool  *set)
66353acd3b1SBarry Smith {
66453acd3b1SBarry Smith   PetscErrorCode ierr;
6656356e834SBarry Smith   PetscOptions   amsopt;
66653acd3b1SBarry Smith 
66753acd3b1SBarry Smith   PetscFunctionBegin;
668b3506946SBarry Smith   if (!PetscOptionsPublishCount) {
6696356e834SBarry Smith     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_INT,&amsopt);CHKERRQ(ierr);
6706356e834SBarry Smith     ierr = PetscMalloc(sizeof(PetscInt),&amsopt->data);CHKERRQ(ierr);
6716356e834SBarry Smith     *(PetscInt*)amsopt->data = defaultv;
672af6d86caSBarry Smith   }
67353acd3b1SBarry Smith   ierr = PetscOptionsGetInt(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr);
67461b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
6752aa6d131SJed Brown     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%d>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,ManSection(man));CHKERRQ(ierr);
67653acd3b1SBarry Smith   }
67753acd3b1SBarry Smith   PetscFunctionReturn(0);
67853acd3b1SBarry Smith }
67953acd3b1SBarry Smith 
68053acd3b1SBarry Smith #undef __FUNCT__
68153acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsString"
68253acd3b1SBarry Smith /*@C
68353acd3b1SBarry Smith    PetscOptionsString - Gets the string value for a particular option in the database.
68453acd3b1SBarry Smith 
6853f9fe445SBarry Smith    Logically Collective on the communicator passed in PetscOptionsBegin()
68653acd3b1SBarry Smith 
68753acd3b1SBarry Smith    Input Parameters:
68853acd3b1SBarry Smith +  opt - option name
68953acd3b1SBarry Smith .  text - short string that describes the option
69053acd3b1SBarry Smith .  man - manual page with additional information on option
691bcbf2dc5SJed Brown .  defaultv - the default (current) value
692bcbf2dc5SJed Brown -  len - length of the result string including null terminator
69353acd3b1SBarry Smith 
69453acd3b1SBarry Smith    Output Parameter:
69553acd3b1SBarry Smith +  value - the value to return
69653acd3b1SBarry Smith -  flg - PETSC_TRUE if found, else PETSC_FALSE
69753acd3b1SBarry Smith 
69853acd3b1SBarry Smith    Level: beginner
69953acd3b1SBarry Smith 
70053acd3b1SBarry Smith    Concepts: options database^has int
70153acd3b1SBarry Smith 
70253acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
70353acd3b1SBarry Smith 
7047fccdfe4SBarry 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).
7057fccdfe4SBarry Smith 
70653acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
707acfcf0e5SJed Brown           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool()
708acfcf0e5SJed Brown           PetscOptionsInt(), PetscOptionsReal(), PetscOptionsBool(),
70953acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
71053acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
711acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
71253acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
71353acd3b1SBarry Smith @*/
7147087cfbeSBarry Smith PetscErrorCode  PetscOptionsString(const char opt[],const char text[],const char man[],const char defaultv[],char value[],size_t len,PetscBool  *set)
71553acd3b1SBarry Smith {
71653acd3b1SBarry Smith   PetscErrorCode ierr;
717aee2cecaSBarry Smith   PetscOptions   amsopt;
71853acd3b1SBarry Smith 
71953acd3b1SBarry Smith   PetscFunctionBegin;
720b3506946SBarry Smith   if (!PetscOptionsPublishCount) {
721aee2cecaSBarry Smith     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_STRING,&amsopt);CHKERRQ(ierr);
72271f08665SBarry Smith     ierr = PetscMalloc(sizeof(char*),&amsopt->data);CHKERRQ(ierr);
72371f08665SBarry Smith     *(const char**)amsopt->data = defaultv;
724af6d86caSBarry Smith   }
72553acd3b1SBarry Smith   ierr = PetscOptionsGetString(PetscOptionsObject.prefix,opt,value,len,set);CHKERRQ(ierr);
72661b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
7272aa6d131SJed Brown     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%s>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,ManSection(man));CHKERRQ(ierr);
72853acd3b1SBarry Smith   }
72953acd3b1SBarry Smith   PetscFunctionReturn(0);
73053acd3b1SBarry Smith }
73153acd3b1SBarry Smith 
73253acd3b1SBarry Smith #undef __FUNCT__
73353acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsReal"
73453acd3b1SBarry Smith /*@C
73553acd3b1SBarry Smith    PetscOptionsReal - Gets the PetscReal value for a particular option in the database.
73653acd3b1SBarry Smith 
7373f9fe445SBarry Smith    Logically Collective on the communicator passed in PetscOptionsBegin()
73853acd3b1SBarry Smith 
73953acd3b1SBarry Smith    Input Parameters:
74053acd3b1SBarry Smith +  opt - option name
74153acd3b1SBarry Smith .  text - short string that describes the option
74253acd3b1SBarry Smith .  man - manual page with additional information on option
74353acd3b1SBarry Smith -  defaultv - the default (current) value
74453acd3b1SBarry Smith 
74553acd3b1SBarry Smith    Output Parameter:
74653acd3b1SBarry Smith +  value - the value to return
74753acd3b1SBarry Smith -  flg - PETSC_TRUE if found, else PETSC_FALSE
74853acd3b1SBarry Smith 
74953acd3b1SBarry Smith    Level: beginner
75053acd3b1SBarry Smith 
75153acd3b1SBarry Smith    Concepts: options database^has int
75253acd3b1SBarry Smith 
75353acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
75453acd3b1SBarry Smith 
75553acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
756acfcf0e5SJed Brown           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool()
757acfcf0e5SJed Brown           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(),
75853acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
75953acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
760acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
76153acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
76253acd3b1SBarry Smith @*/
7637087cfbeSBarry Smith PetscErrorCode  PetscOptionsReal(const char opt[],const char text[],const char man[],PetscReal defaultv,PetscReal *value,PetscBool  *set)
76453acd3b1SBarry Smith {
76553acd3b1SBarry Smith   PetscErrorCode ierr;
766538aa990SBarry Smith   PetscOptions   amsopt;
76753acd3b1SBarry Smith 
76853acd3b1SBarry Smith   PetscFunctionBegin;
769b3506946SBarry Smith   if (!PetscOptionsPublishCount) {
770538aa990SBarry Smith     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_REAL,&amsopt);CHKERRQ(ierr);
771538aa990SBarry Smith     ierr = PetscMalloc(sizeof(PetscReal),&amsopt->data);CHKERRQ(ierr);
772538aa990SBarry Smith     *(PetscReal*)amsopt->data = defaultv;
773538aa990SBarry Smith   }
77453acd3b1SBarry Smith   ierr = PetscOptionsGetReal(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr);
77561b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
7762aa6d131SJed Brown     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%G>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,ManSection(man));CHKERRQ(ierr);
77753acd3b1SBarry Smith   }
77853acd3b1SBarry Smith   PetscFunctionReturn(0);
77953acd3b1SBarry Smith }
78053acd3b1SBarry Smith 
78153acd3b1SBarry Smith #undef __FUNCT__
78253acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsScalar"
78353acd3b1SBarry Smith /*@C
78453acd3b1SBarry Smith    PetscOptionsScalar - Gets the scalar value for a particular option in the database.
78553acd3b1SBarry Smith 
7863f9fe445SBarry Smith    Logically Collective on the communicator passed in PetscOptionsBegin()
78753acd3b1SBarry Smith 
78853acd3b1SBarry Smith    Input Parameters:
78953acd3b1SBarry Smith +  opt - option name
79053acd3b1SBarry Smith .  text - short string that describes the option
79153acd3b1SBarry Smith .  man - manual page with additional information on option
79253acd3b1SBarry Smith -  defaultv - the default (current) value
79353acd3b1SBarry Smith 
79453acd3b1SBarry Smith    Output Parameter:
79553acd3b1SBarry Smith +  value - the value to return
79653acd3b1SBarry Smith -  flg - PETSC_TRUE if found, else PETSC_FALSE
79753acd3b1SBarry Smith 
79853acd3b1SBarry Smith    Level: beginner
79953acd3b1SBarry Smith 
80053acd3b1SBarry Smith    Concepts: options database^has int
80153acd3b1SBarry Smith 
80253acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
80353acd3b1SBarry Smith 
80453acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
805acfcf0e5SJed Brown           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool()
806acfcf0e5SJed Brown           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(),
80753acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
80853acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
809acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
81053acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
81153acd3b1SBarry Smith @*/
8127087cfbeSBarry Smith PetscErrorCode  PetscOptionsScalar(const char opt[],const char text[],const char man[],PetscScalar defaultv,PetscScalar *value,PetscBool  *set)
81353acd3b1SBarry Smith {
81453acd3b1SBarry Smith   PetscErrorCode ierr;
81553acd3b1SBarry Smith 
81653acd3b1SBarry Smith   PetscFunctionBegin;
81753acd3b1SBarry Smith #if !defined(PETSC_USE_COMPLEX)
81853acd3b1SBarry Smith   ierr = PetscOptionsReal(opt,text,man,defaultv,value,set);CHKERRQ(ierr);
81953acd3b1SBarry Smith #else
82053acd3b1SBarry Smith   ierr = PetscOptionsGetScalar(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr);
82153acd3b1SBarry Smith #endif
82253acd3b1SBarry Smith   PetscFunctionReturn(0);
82353acd3b1SBarry Smith }
82453acd3b1SBarry Smith 
82553acd3b1SBarry Smith #undef __FUNCT__
82653acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsName"
82753acd3b1SBarry Smith /*@C
82890d69ab7SBarry 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
82990d69ab7SBarry Smith                       its value is set to false.
83053acd3b1SBarry Smith 
8313f9fe445SBarry Smith    Logically Collective on the communicator passed in PetscOptionsBegin()
83253acd3b1SBarry Smith 
83353acd3b1SBarry Smith    Input Parameters:
83453acd3b1SBarry Smith +  opt - option name
83553acd3b1SBarry Smith .  text - short string that describes the option
83653acd3b1SBarry Smith -  man - manual page with additional information on option
83753acd3b1SBarry Smith 
83853acd3b1SBarry Smith    Output Parameter:
83953acd3b1SBarry Smith .  flg - PETSC_TRUE if found, else PETSC_FALSE
84053acd3b1SBarry Smith 
84153acd3b1SBarry Smith    Level: beginner
84253acd3b1SBarry Smith 
84353acd3b1SBarry Smith    Concepts: options database^has int
84453acd3b1SBarry Smith 
84553acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
84653acd3b1SBarry Smith 
84753acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
848acfcf0e5SJed Brown           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool()
849acfcf0e5SJed Brown           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(),
85053acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
85153acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
852acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
85353acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
85453acd3b1SBarry Smith @*/
8557087cfbeSBarry Smith PetscErrorCode  PetscOptionsName(const char opt[],const char text[],const char man[],PetscBool  *flg)
85653acd3b1SBarry Smith {
85753acd3b1SBarry Smith   PetscErrorCode ierr;
8581ae3d29cSBarry Smith   PetscOptions   amsopt;
85953acd3b1SBarry Smith 
86053acd3b1SBarry Smith   PetscFunctionBegin;
8611ae3d29cSBarry Smith   if (!PetscOptionsPublishCount) {
8621ae3d29cSBarry Smith     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL,&amsopt);CHKERRQ(ierr);
863ace3abfcSBarry Smith     ierr = PetscMalloc(sizeof(PetscBool),&amsopt->data);CHKERRQ(ierr);
864ace3abfcSBarry Smith     *(PetscBool*)amsopt->data = PETSC_FALSE;
8651ae3d29cSBarry Smith   }
86653acd3b1SBarry Smith   ierr = PetscOptionsHasName(PetscOptionsObject.prefix,opt,flg);CHKERRQ(ierr);
86761b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
8682aa6d131SJed Brown     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,ManSection(man));CHKERRQ(ierr);
86953acd3b1SBarry Smith   }
87053acd3b1SBarry Smith   PetscFunctionReturn(0);
87153acd3b1SBarry Smith }
87253acd3b1SBarry Smith 
87353acd3b1SBarry Smith #undef __FUNCT__
87453acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsList"
87553acd3b1SBarry Smith /*@C
87653acd3b1SBarry Smith      PetscOptionsList - Puts a list of option values that a single one may be selected from
87753acd3b1SBarry Smith 
8783f9fe445SBarry Smith    Logically Collective on the communicator passed in PetscOptionsBegin()
87953acd3b1SBarry Smith 
88053acd3b1SBarry Smith    Input Parameters:
88153acd3b1SBarry Smith +  opt - option name
88253acd3b1SBarry Smith .  text - short string that describes the option
88353acd3b1SBarry Smith .  man - manual page with additional information on option
88453acd3b1SBarry Smith .  list - the possible choices
8853cc1e11dSBarry Smith .  defaultv - the default (current) value
8863cc1e11dSBarry Smith -  len - the length of the character array value
88753acd3b1SBarry Smith 
88853acd3b1SBarry Smith    Output Parameter:
88953acd3b1SBarry Smith +  value - the value to return
89053acd3b1SBarry Smith -  set - PETSC_TRUE if found, else PETSC_FALSE
89153acd3b1SBarry Smith 
89253acd3b1SBarry Smith    Level: intermediate
89353acd3b1SBarry Smith 
89453acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
89553acd3b1SBarry Smith 
89653acd3b1SBarry Smith    See PetscOptionsEList() for when the choices are given in a string array
89753acd3b1SBarry Smith 
89853acd3b1SBarry Smith    To get a listing of all currently specified options,
89988c29154SBarry Smith     see PetscOptionsView() or PetscOptionsGetAll()
90053acd3b1SBarry Smith 
90153acd3b1SBarry Smith    Concepts: options database^list
90253acd3b1SBarry Smith 
90353acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
904acfcf0e5SJed Brown            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
90553acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
90653acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
907acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
90853acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
90953acd3b1SBarry Smith @*/
9107087cfbeSBarry Smith PetscErrorCode  PetscOptionsList(const char opt[],const char ltext[],const char man[],PetscFList list,const char defaultv[],char value[],size_t len,PetscBool  *set)
91153acd3b1SBarry Smith {
91253acd3b1SBarry Smith   PetscErrorCode ierr;
9133cc1e11dSBarry Smith   PetscOptions   amsopt;
91453acd3b1SBarry Smith 
91553acd3b1SBarry Smith   PetscFunctionBegin;
916b3506946SBarry Smith   if (!PetscOptionsPublishCount) {
9173cc1e11dSBarry Smith     ierr = PetscOptionsCreate_Private(opt,ltext,man,OPTION_LIST,&amsopt);CHKERRQ(ierr);
91871f08665SBarry Smith     ierr = PetscMalloc(sizeof(char*),&amsopt->data);CHKERRQ(ierr);
91971f08665SBarry Smith     *(const char**)amsopt->data = defaultv;
9203cc1e11dSBarry Smith     amsopt->flist = list;
9213cc1e11dSBarry Smith   }
92253acd3b1SBarry Smith   ierr = PetscOptionsGetString(PetscOptionsObject.prefix,opt,value,len,set);CHKERRQ(ierr);
92361b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
9243cc1e11dSBarry Smith     ierr = PetscFListPrintTypes(PetscOptionsObject.comm,stdout,PetscOptionsObject.prefix,opt,ltext,man,list,defaultv);CHKERRQ(ierr);CHKERRQ(ierr);
92553acd3b1SBarry Smith   }
92653acd3b1SBarry Smith   PetscFunctionReturn(0);
92753acd3b1SBarry Smith }
92853acd3b1SBarry Smith 
92953acd3b1SBarry Smith #undef __FUNCT__
93053acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsEList"
93153acd3b1SBarry Smith /*@C
93253acd3b1SBarry Smith      PetscOptionsEList - Puts a list of option values that a single one may be selected from
93353acd3b1SBarry Smith 
9343f9fe445SBarry Smith    Logically Collective on the communicator passed in PetscOptionsBegin()
93553acd3b1SBarry Smith 
93653acd3b1SBarry Smith    Input Parameters:
93753acd3b1SBarry Smith +  opt - option name
93853acd3b1SBarry Smith .  ltext - short string that describes the option
93953acd3b1SBarry Smith .  man - manual page with additional information on option
94053acd3b1SBarry Smith .  list - the possible choices
94153acd3b1SBarry Smith .  ntext - number of choices
94253acd3b1SBarry Smith -  defaultv - the default (current) value
94353acd3b1SBarry Smith 
94453acd3b1SBarry Smith    Output Parameter:
94553acd3b1SBarry Smith +  value - the index of the value to return
94653acd3b1SBarry Smith -  set - PETSC_TRUE if found, else PETSC_FALSE
94753acd3b1SBarry Smith 
94853acd3b1SBarry Smith    Level: intermediate
94953acd3b1SBarry Smith 
95053acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
95153acd3b1SBarry Smith 
95253acd3b1SBarry Smith    See PetscOptionsList() for when the choices are given in a PetscFList()
95353acd3b1SBarry Smith 
95453acd3b1SBarry Smith    Concepts: options database^list
95553acd3b1SBarry Smith 
95653acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
957acfcf0e5SJed Brown            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
95853acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
95953acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
960acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
96153acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
96253acd3b1SBarry Smith @*/
9637087cfbeSBarry 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)
96453acd3b1SBarry Smith {
96553acd3b1SBarry Smith   PetscErrorCode ierr;
96653acd3b1SBarry Smith   PetscInt       i;
9671ae3d29cSBarry Smith   PetscOptions   amsopt;
96853acd3b1SBarry Smith 
96953acd3b1SBarry Smith   PetscFunctionBegin;
9701ae3d29cSBarry Smith   if (!PetscOptionsPublishCount) {
971d5649816SBarry Smith     ierr = PetscOptionsCreate_Private(opt,ltext,man,OPTION_ELIST,&amsopt);CHKERRQ(ierr);
9721ae3d29cSBarry Smith     ierr = PetscMalloc(sizeof(char*),&amsopt->data);CHKERRQ(ierr);
9731ae3d29cSBarry Smith     *(const char**)amsopt->data = defaultv;
9741ae3d29cSBarry Smith     amsopt->list  = list;
9751ae3d29cSBarry Smith     amsopt->nlist = ntext;
9761ae3d29cSBarry Smith   }
97753acd3b1SBarry Smith   ierr = PetscOptionsGetEList(PetscOptionsObject.prefix,opt,list,ntext,value,set);CHKERRQ(ierr);
97861b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
97953acd3b1SBarry Smith     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%s> (choose one of)",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv);CHKERRQ(ierr);
98053acd3b1SBarry Smith     for (i=0; i<ntext; i++){
98153acd3b1SBarry Smith       ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," %s",list[i]);CHKERRQ(ierr);
98253acd3b1SBarry Smith     }
9832aa6d131SJed Brown     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," (%s)\n",ManSection(man));CHKERRQ(ierr);
98453acd3b1SBarry Smith   }
98553acd3b1SBarry Smith   PetscFunctionReturn(0);
98653acd3b1SBarry Smith }
98753acd3b1SBarry Smith 
98853acd3b1SBarry Smith #undef __FUNCT__
989acfcf0e5SJed Brown #define __FUNCT__ "PetscOptionsBoolGroupBegin"
99053acd3b1SBarry Smith /*@C
991acfcf0e5SJed Brown      PetscOptionsBoolGroupBegin - First in a series of logical queries on the options database for
992d5649816SBarry Smith        which at most a single value can be true.
99353acd3b1SBarry Smith 
9943f9fe445SBarry Smith    Logically Collective on the communicator passed in PetscOptionsBegin()
99553acd3b1SBarry Smith 
99653acd3b1SBarry Smith    Input Parameters:
99753acd3b1SBarry Smith +  opt - option name
99853acd3b1SBarry Smith .  text - short string that describes the option
99953acd3b1SBarry Smith -  man - manual page with additional information on option
100053acd3b1SBarry Smith 
100153acd3b1SBarry Smith    Output Parameter:
100253acd3b1SBarry Smith .  flg - whether that option was set or not
100353acd3b1SBarry Smith 
100453acd3b1SBarry Smith    Level: intermediate
100553acd3b1SBarry Smith 
100653acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
100753acd3b1SBarry Smith 
1008acfcf0e5SJed Brown    Must be followed by 0 or more PetscOptionsBoolGroup()s and PetscOptionsBoolGroupEnd()
100953acd3b1SBarry Smith 
101053acd3b1SBarry Smith     Concepts: options database^logical group
101153acd3b1SBarry Smith 
101253acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1013acfcf0e5SJed Brown            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
101453acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
101553acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1016acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
101753acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
101853acd3b1SBarry Smith @*/
10197087cfbeSBarry Smith PetscErrorCode  PetscOptionsBoolGroupBegin(const char opt[],const char text[],const char man[],PetscBool  *flg)
102053acd3b1SBarry Smith {
102153acd3b1SBarry Smith   PetscErrorCode ierr;
10221ae3d29cSBarry Smith   PetscOptions   amsopt;
102353acd3b1SBarry Smith 
102453acd3b1SBarry Smith   PetscFunctionBegin;
10251ae3d29cSBarry Smith   if (!PetscOptionsPublishCount) {
10261ae3d29cSBarry Smith     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL,&amsopt);CHKERRQ(ierr);
1027ace3abfcSBarry Smith     ierr = PetscMalloc(sizeof(PetscBool),&amsopt->data);CHKERRQ(ierr);
1028ace3abfcSBarry Smith     *(PetscBool*)amsopt->data = PETSC_FALSE;
10291ae3d29cSBarry Smith   }
103068b16fdaSBarry Smith   *flg = PETSC_FALSE;
1031acfcf0e5SJed Brown   ierr = PetscOptionsGetBool(PetscOptionsObject.prefix,opt,flg,PETSC_NULL);CHKERRQ(ierr);
103261b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
103353acd3b1SBarry Smith     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  Pick at most one of -------------\n");CHKERRQ(ierr);
10342aa6d131SJed Brown     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"    -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,ManSection(man));CHKERRQ(ierr);
103553acd3b1SBarry Smith   }
103653acd3b1SBarry Smith   PetscFunctionReturn(0);
103753acd3b1SBarry Smith }
103853acd3b1SBarry Smith 
103953acd3b1SBarry Smith #undef __FUNCT__
1040acfcf0e5SJed Brown #define __FUNCT__ "PetscOptionsBoolGroup"
104153acd3b1SBarry Smith /*@C
1042acfcf0e5SJed Brown      PetscOptionsBoolGroup - One in a series of logical queries on the options database for
1043d5649816SBarry Smith        which at most a single value can be true.
104453acd3b1SBarry Smith 
10453f9fe445SBarry Smith    Logically Collective on the communicator passed in PetscOptionsBegin()
104653acd3b1SBarry Smith 
104753acd3b1SBarry Smith    Input Parameters:
104853acd3b1SBarry Smith +  opt - option name
104953acd3b1SBarry Smith .  text - short string that describes the option
105053acd3b1SBarry Smith -  man - manual page with additional information on option
105153acd3b1SBarry Smith 
105253acd3b1SBarry Smith    Output Parameter:
105353acd3b1SBarry Smith .  flg - PETSC_TRUE if found, else PETSC_FALSE
105453acd3b1SBarry Smith 
105553acd3b1SBarry Smith    Level: intermediate
105653acd3b1SBarry Smith 
105753acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
105853acd3b1SBarry Smith 
1059acfcf0e5SJed Brown    Must follow a PetscOptionsBoolGroupBegin() and preceded a PetscOptionsBoolGroupEnd()
106053acd3b1SBarry Smith 
106153acd3b1SBarry Smith     Concepts: options database^logical group
106253acd3b1SBarry Smith 
106353acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1064acfcf0e5SJed Brown            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
106553acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
106653acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1067acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
106853acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
106953acd3b1SBarry Smith @*/
10707087cfbeSBarry Smith PetscErrorCode  PetscOptionsBoolGroup(const char opt[],const char text[],const char man[],PetscBool  *flg)
107153acd3b1SBarry Smith {
107253acd3b1SBarry Smith   PetscErrorCode ierr;
10731ae3d29cSBarry Smith   PetscOptions   amsopt;
107453acd3b1SBarry Smith 
107553acd3b1SBarry Smith   PetscFunctionBegin;
10761ae3d29cSBarry Smith   if (!PetscOptionsPublishCount) {
10771ae3d29cSBarry Smith     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL,&amsopt);CHKERRQ(ierr);
1078ace3abfcSBarry Smith     ierr = PetscMalloc(sizeof(PetscBool),&amsopt->data);CHKERRQ(ierr);
1079ace3abfcSBarry Smith     *(PetscBool*)amsopt->data = PETSC_FALSE;
10801ae3d29cSBarry Smith   }
108117326d04SJed Brown   *flg = PETSC_FALSE;
1082acfcf0e5SJed Brown   ierr = PetscOptionsGetBool(PetscOptionsObject.prefix,opt,flg,PETSC_NULL);CHKERRQ(ierr);
108361b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
10842aa6d131SJed Brown     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"    -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,ManSection(man));CHKERRQ(ierr);
108553acd3b1SBarry Smith   }
108653acd3b1SBarry Smith   PetscFunctionReturn(0);
108753acd3b1SBarry Smith }
108853acd3b1SBarry Smith 
108953acd3b1SBarry Smith #undef __FUNCT__
1090acfcf0e5SJed Brown #define __FUNCT__ "PetscOptionsBoolGroupEnd"
109153acd3b1SBarry Smith /*@C
1092acfcf0e5SJed Brown      PetscOptionsBoolGroupEnd - Last in a series of logical queries on the options database for
1093d5649816SBarry Smith        which at most a single value can be true.
109453acd3b1SBarry Smith 
10953f9fe445SBarry Smith    Logically Collective on the communicator passed in PetscOptionsBegin()
109653acd3b1SBarry Smith 
109753acd3b1SBarry Smith    Input Parameters:
109853acd3b1SBarry Smith +  opt - option name
109953acd3b1SBarry Smith .  text - short string that describes the option
110053acd3b1SBarry Smith -  man - manual page with additional information on option
110153acd3b1SBarry Smith 
110253acd3b1SBarry Smith    Output Parameter:
110353acd3b1SBarry Smith .  flg - PETSC_TRUE if found, else PETSC_FALSE
110453acd3b1SBarry Smith 
110553acd3b1SBarry Smith    Level: intermediate
110653acd3b1SBarry Smith 
110753acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
110853acd3b1SBarry Smith 
1109acfcf0e5SJed Brown    Must follow a PetscOptionsBoolGroupBegin()
111053acd3b1SBarry Smith 
111153acd3b1SBarry Smith     Concepts: options database^logical group
111253acd3b1SBarry Smith 
111353acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1114acfcf0e5SJed Brown            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
111553acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
111653acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1117acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
111853acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
111953acd3b1SBarry Smith @*/
11207087cfbeSBarry Smith PetscErrorCode  PetscOptionsBoolGroupEnd(const char opt[],const char text[],const char man[],PetscBool  *flg)
112153acd3b1SBarry Smith {
112253acd3b1SBarry Smith   PetscErrorCode ierr;
11231ae3d29cSBarry Smith   PetscOptions   amsopt;
112453acd3b1SBarry Smith 
112553acd3b1SBarry Smith   PetscFunctionBegin;
11261ae3d29cSBarry Smith   if (!PetscOptionsPublishCount) {
11271ae3d29cSBarry Smith     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL,&amsopt);CHKERRQ(ierr);
1128ace3abfcSBarry Smith     ierr = PetscMalloc(sizeof(PetscBool),&amsopt->data);CHKERRQ(ierr);
1129ace3abfcSBarry Smith     *(PetscBool*)amsopt->data = PETSC_FALSE;
11301ae3d29cSBarry Smith   }
113117326d04SJed Brown   *flg = PETSC_FALSE;
1132acfcf0e5SJed Brown   ierr = PetscOptionsGetBool(PetscOptionsObject.prefix,opt,flg,PETSC_NULL);CHKERRQ(ierr);
113361b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
11342aa6d131SJed Brown     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"    -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,ManSection(man));CHKERRQ(ierr);
113553acd3b1SBarry Smith   }
113653acd3b1SBarry Smith   PetscFunctionReturn(0);
113753acd3b1SBarry Smith }
113853acd3b1SBarry Smith 
113953acd3b1SBarry Smith #undef __FUNCT__
1140acfcf0e5SJed Brown #define __FUNCT__ "PetscOptionsBool"
114153acd3b1SBarry Smith /*@C
1142acfcf0e5SJed Brown    PetscOptionsBool - Determines if a particular option is in the database with a true or false
114353acd3b1SBarry Smith 
11443f9fe445SBarry Smith    Logically Collective on the communicator passed in PetscOptionsBegin()
114553acd3b1SBarry Smith 
114653acd3b1SBarry Smith    Input Parameters:
114753acd3b1SBarry Smith +  opt - option name
114853acd3b1SBarry Smith .  text - short string that describes the option
114953acd3b1SBarry Smith -  man - manual page with additional information on option
115053acd3b1SBarry Smith 
115153acd3b1SBarry Smith    Output Parameter:
115253acd3b1SBarry Smith .  flg - PETSC_TRUE or PETSC_FALSE
115353acd3b1SBarry Smith .  set - PETSC_TRUE if found, else PETSC_FALSE
115453acd3b1SBarry Smith 
115553acd3b1SBarry Smith    Level: beginner
115653acd3b1SBarry Smith 
115753acd3b1SBarry Smith    Concepts: options database^logical
115853acd3b1SBarry Smith 
115953acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
116053acd3b1SBarry Smith 
116153acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
1162acfcf0e5SJed Brown           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool()
1163acfcf0e5SJed Brown           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(),
116453acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
116553acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1166acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
116753acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
116853acd3b1SBarry Smith @*/
11697087cfbeSBarry Smith PetscErrorCode  PetscOptionsBool(const char opt[],const char text[],const char man[],PetscBool  deflt,PetscBool  *flg,PetscBool  *set)
117053acd3b1SBarry Smith {
117153acd3b1SBarry Smith   PetscErrorCode ierr;
1172ace3abfcSBarry Smith   PetscBool      iset;
1173aee2cecaSBarry Smith   PetscOptions   amsopt;
117453acd3b1SBarry Smith 
117553acd3b1SBarry Smith   PetscFunctionBegin;
1176b3506946SBarry Smith   if (!PetscOptionsPublishCount) {
1177aee2cecaSBarry Smith     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL,&amsopt);CHKERRQ(ierr);
1178ace3abfcSBarry Smith     ierr = PetscMalloc(sizeof(PetscBool),&amsopt->data);CHKERRQ(ierr);
1179ace3abfcSBarry Smith     *(PetscBool*)amsopt->data = deflt;
1180af6d86caSBarry Smith   }
1181acfcf0e5SJed Brown   ierr = PetscOptionsGetBool(PetscOptionsObject.prefix,opt,flg,&iset);CHKERRQ(ierr);
118253acd3b1SBarry Smith   if (!iset) {
118353acd3b1SBarry Smith     if (flg) *flg = deflt;
118453acd3b1SBarry Smith   }
118553acd3b1SBarry Smith   if (set) *set = iset;
118661b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
1187ace3abfcSBarry Smith     const char *v = PetscBools[deflt];
11882aa6d131SJed Brown     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s: <%s> %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,v,text,ManSection(man));CHKERRQ(ierr);
118953acd3b1SBarry Smith   }
119053acd3b1SBarry Smith   PetscFunctionReturn(0);
119153acd3b1SBarry Smith }
119253acd3b1SBarry Smith 
119353acd3b1SBarry Smith #undef __FUNCT__
119453acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsRealArray"
119553acd3b1SBarry Smith /*@C
119653acd3b1SBarry Smith    PetscOptionsRealArray - Gets an array of double values for a particular
119753acd3b1SBarry Smith    option in the database. The values must be separated with commas with
119853acd3b1SBarry Smith    no intervening spaces.
119953acd3b1SBarry Smith 
12003f9fe445SBarry Smith    Logically Collective on the communicator passed in PetscOptionsBegin()
120153acd3b1SBarry Smith 
120253acd3b1SBarry Smith    Input Parameters:
120353acd3b1SBarry Smith +  opt - the option one is seeking
120453acd3b1SBarry Smith .  text - short string describing option
120553acd3b1SBarry Smith .  man - manual page for option
120653acd3b1SBarry Smith -  nmax - maximum number of values
120753acd3b1SBarry Smith 
120853acd3b1SBarry Smith    Output Parameter:
120953acd3b1SBarry Smith +  value - location to copy values
121053acd3b1SBarry Smith .  nmax - actual number of values found
121153acd3b1SBarry Smith -  set - PETSC_TRUE if found, else PETSC_FALSE
121253acd3b1SBarry Smith 
121353acd3b1SBarry Smith    Level: beginner
121453acd3b1SBarry Smith 
121553acd3b1SBarry Smith    Notes:
121653acd3b1SBarry Smith    The user should pass in an array of doubles
121753acd3b1SBarry Smith 
121853acd3b1SBarry Smith    Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
121953acd3b1SBarry Smith 
122053acd3b1SBarry Smith    Concepts: options database^array of strings
122153acd3b1SBarry Smith 
122253acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1223acfcf0e5SJed Brown            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
122453acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
122553acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1226acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
122753acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
122853acd3b1SBarry Smith @*/
12297087cfbeSBarry Smith PetscErrorCode  PetscOptionsRealArray(const char opt[],const char text[],const char man[],PetscReal value[],PetscInt *n,PetscBool  *set)
123053acd3b1SBarry Smith {
123153acd3b1SBarry Smith   PetscErrorCode ierr;
123253acd3b1SBarry Smith   PetscInt       i;
1233e26ddf31SBarry Smith   PetscOptions   amsopt;
123453acd3b1SBarry Smith 
123553acd3b1SBarry Smith   PetscFunctionBegin;
1236b3506946SBarry Smith   if (!PetscOptionsPublishCount) {
1237e26ddf31SBarry Smith     PetscReal *vals;
1238e26ddf31SBarry Smith 
1239e26ddf31SBarry Smith     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_REAL_ARRAY,&amsopt);CHKERRQ(ierr);
1240e26ddf31SBarry Smith     ierr = PetscMalloc((*n)*sizeof(PetscReal),&amsopt->data);CHKERRQ(ierr);
1241e26ddf31SBarry Smith     vals = (PetscReal*)amsopt->data;
1242e26ddf31SBarry Smith     for (i=0; i<*n; i++) vals[i] = value[i];
1243e26ddf31SBarry Smith     amsopt->arraylength = *n;
1244e26ddf31SBarry Smith   }
124553acd3b1SBarry Smith   ierr = PetscOptionsGetRealArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr);
124661b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
1247a83599f4SBarry Smith     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%G",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr);
124853acd3b1SBarry Smith     for (i=1; i<*n; i++) {
1249a83599f4SBarry Smith       ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%G",value[i]);CHKERRQ(ierr);
125053acd3b1SBarry Smith     }
12512aa6d131SJed Brown     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,ManSection(man));CHKERRQ(ierr);
125253acd3b1SBarry Smith   }
125353acd3b1SBarry Smith   PetscFunctionReturn(0);
125453acd3b1SBarry Smith }
125553acd3b1SBarry Smith 
125653acd3b1SBarry Smith 
125753acd3b1SBarry Smith #undef __FUNCT__
125853acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsIntArray"
125953acd3b1SBarry Smith /*@C
126053acd3b1SBarry Smith    PetscOptionsIntArray - Gets an array of integers for a particular
126153acd3b1SBarry Smith    option in the database. The values must be separated with commas with
126253acd3b1SBarry Smith    no intervening spaces.
126353acd3b1SBarry Smith 
12643f9fe445SBarry Smith    Logically Collective on the communicator passed in PetscOptionsBegin()
126553acd3b1SBarry Smith 
126653acd3b1SBarry Smith    Input Parameters:
126753acd3b1SBarry Smith +  opt - the option one is seeking
126853acd3b1SBarry Smith .  text - short string describing option
126953acd3b1SBarry Smith .  man - manual page for option
1270f8a50e2bSBarry Smith -  n - maximum number of values
127153acd3b1SBarry Smith 
127253acd3b1SBarry Smith    Output Parameter:
127353acd3b1SBarry Smith +  value - location to copy values
1274f8a50e2bSBarry Smith .  n - actual number of values found
127553acd3b1SBarry Smith -  set - PETSC_TRUE if found, else PETSC_FALSE
127653acd3b1SBarry Smith 
127753acd3b1SBarry Smith    Level: beginner
127853acd3b1SBarry Smith 
127953acd3b1SBarry Smith    Notes:
128053acd3b1SBarry Smith    The user should pass in an array of integers
128153acd3b1SBarry Smith 
128253acd3b1SBarry Smith    Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
128353acd3b1SBarry Smith 
128453acd3b1SBarry Smith    Concepts: options database^array of strings
128553acd3b1SBarry Smith 
128653acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1287acfcf0e5SJed Brown            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
128853acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
128953acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1290acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
129153acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList(), PetscOptionsRealArray()
129253acd3b1SBarry Smith @*/
12937087cfbeSBarry Smith PetscErrorCode  PetscOptionsIntArray(const char opt[],const char text[],const char man[],PetscInt value[],PetscInt *n,PetscBool  *set)
129453acd3b1SBarry Smith {
129553acd3b1SBarry Smith   PetscErrorCode ierr;
129653acd3b1SBarry Smith   PetscInt       i;
1297e26ddf31SBarry Smith   PetscOptions   amsopt;
129853acd3b1SBarry Smith 
129953acd3b1SBarry Smith   PetscFunctionBegin;
1300b3506946SBarry Smith   if (!PetscOptionsPublishCount) {
1301e26ddf31SBarry Smith     PetscInt *vals;
1302e26ddf31SBarry Smith 
1303e26ddf31SBarry Smith     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_INT_ARRAY,&amsopt);CHKERRQ(ierr);
1304e26ddf31SBarry Smith     ierr = PetscMalloc((*n)*sizeof(PetscInt),&amsopt->data);CHKERRQ(ierr);
1305e26ddf31SBarry Smith     vals = (PetscInt*)amsopt->data;
1306e26ddf31SBarry Smith     for (i=0; i<*n; i++) vals[i] = value[i];
1307e26ddf31SBarry Smith     amsopt->arraylength = *n;
1308e26ddf31SBarry Smith   }
130953acd3b1SBarry Smith   ierr = PetscOptionsGetIntArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr);
131061b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
131153acd3b1SBarry Smith     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%d",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr);
131253acd3b1SBarry Smith     for (i=1; i<*n; i++) {
131353acd3b1SBarry Smith       ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%d",value[i]);CHKERRQ(ierr);
131453acd3b1SBarry Smith     }
13152aa6d131SJed Brown     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,ManSection(man));CHKERRQ(ierr);
131653acd3b1SBarry Smith   }
131753acd3b1SBarry Smith   PetscFunctionReturn(0);
131853acd3b1SBarry Smith }
131953acd3b1SBarry Smith 
132053acd3b1SBarry Smith #undef __FUNCT__
132153acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsStringArray"
132253acd3b1SBarry Smith /*@C
132353acd3b1SBarry Smith    PetscOptionsStringArray - Gets an array of string values for a particular
132453acd3b1SBarry Smith    option in the database. The values must be separated with commas with
132553acd3b1SBarry Smith    no intervening spaces.
132653acd3b1SBarry Smith 
13273f9fe445SBarry Smith    Logically Collective on the communicator passed in PetscOptionsBegin()
132853acd3b1SBarry Smith 
132953acd3b1SBarry Smith    Input Parameters:
133053acd3b1SBarry Smith +  opt - the option one is seeking
133153acd3b1SBarry Smith .  text - short string describing option
133253acd3b1SBarry Smith .  man - manual page for option
133353acd3b1SBarry Smith -  nmax - maximum number of strings
133453acd3b1SBarry Smith 
133553acd3b1SBarry Smith    Output Parameter:
133653acd3b1SBarry Smith +  value - location to copy strings
133753acd3b1SBarry Smith .  nmax - actual number of strings found
133853acd3b1SBarry Smith -  set - PETSC_TRUE if found, else PETSC_FALSE
133953acd3b1SBarry Smith 
134053acd3b1SBarry Smith    Level: beginner
134153acd3b1SBarry Smith 
134253acd3b1SBarry Smith    Notes:
134353acd3b1SBarry Smith    The user should pass in an array of pointers to char, to hold all the
134453acd3b1SBarry Smith    strings returned by this function.
134553acd3b1SBarry Smith 
134653acd3b1SBarry Smith    The user is responsible for deallocating the strings that are
134753acd3b1SBarry Smith    returned. The Fortran interface for this routine is not supported.
134853acd3b1SBarry Smith 
134953acd3b1SBarry Smith    Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
135053acd3b1SBarry Smith 
135153acd3b1SBarry Smith    Concepts: options database^array of strings
135253acd3b1SBarry Smith 
135353acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1354acfcf0e5SJed Brown            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
135553acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
135653acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1357acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
135853acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
135953acd3b1SBarry Smith @*/
13607087cfbeSBarry Smith PetscErrorCode  PetscOptionsStringArray(const char opt[],const char text[],const char man[],char *value[],PetscInt *nmax,PetscBool  *set)
136153acd3b1SBarry Smith {
136253acd3b1SBarry Smith   PetscErrorCode ierr;
13631ae3d29cSBarry Smith   PetscOptions   amsopt;
136453acd3b1SBarry Smith 
136553acd3b1SBarry Smith   PetscFunctionBegin;
13661ae3d29cSBarry Smith   if (!PetscOptionsPublishCount) {
13671ae3d29cSBarry Smith     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_STRING_ARRAY,&amsopt);CHKERRQ(ierr);
13681ae3d29cSBarry Smith     ierr = PetscMalloc((*nmax)*sizeof(char*),&amsopt->data);CHKERRQ(ierr);
13691ae3d29cSBarry Smith     amsopt->arraylength = *nmax;
13701ae3d29cSBarry Smith   }
137153acd3b1SBarry Smith   ierr = PetscOptionsGetStringArray(PetscOptionsObject.prefix,opt,value,nmax,set);CHKERRQ(ierr);
137261b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
13732aa6d131SJed Brown     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <string1,string2,...>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,ManSection(man));CHKERRQ(ierr);
137453acd3b1SBarry Smith   }
137553acd3b1SBarry Smith   PetscFunctionReturn(0);
137653acd3b1SBarry Smith }
137753acd3b1SBarry Smith 
1378e2446a98SMatthew Knepley #undef __FUNCT__
1379acfcf0e5SJed Brown #define __FUNCT__ "PetscOptionsBoolArray"
1380e2446a98SMatthew Knepley /*@C
1381acfcf0e5SJed Brown    PetscOptionsBoolArray - Gets an array of logical values (true or false) for a particular
1382e2446a98SMatthew Knepley    option in the database. The values must be separated with commas with
1383e2446a98SMatthew Knepley    no intervening spaces.
1384e2446a98SMatthew Knepley 
13853f9fe445SBarry Smith    Logically Collective on the communicator passed in PetscOptionsBegin()
1386e2446a98SMatthew Knepley 
1387e2446a98SMatthew Knepley    Input Parameters:
1388e2446a98SMatthew Knepley +  opt - the option one is seeking
1389e2446a98SMatthew Knepley .  text - short string describing option
1390e2446a98SMatthew Knepley .  man - manual page for option
1391e2446a98SMatthew Knepley -  nmax - maximum number of values
1392e2446a98SMatthew Knepley 
1393e2446a98SMatthew Knepley    Output Parameter:
1394e2446a98SMatthew Knepley +  value - location to copy values
1395e2446a98SMatthew Knepley .  nmax - actual number of values found
1396e2446a98SMatthew Knepley -  set - PETSC_TRUE if found, else PETSC_FALSE
1397e2446a98SMatthew Knepley 
1398e2446a98SMatthew Knepley    Level: beginner
1399e2446a98SMatthew Knepley 
1400e2446a98SMatthew Knepley    Notes:
1401e2446a98SMatthew Knepley    The user should pass in an array of doubles
1402e2446a98SMatthew Knepley 
1403e2446a98SMatthew Knepley    Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1404e2446a98SMatthew Knepley 
1405e2446a98SMatthew Knepley    Concepts: options database^array of strings
1406e2446a98SMatthew Knepley 
1407e2446a98SMatthew Knepley .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1408acfcf0e5SJed Brown            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
1409e2446a98SMatthew Knepley           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1410e2446a98SMatthew Knepley           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1411acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
1412e2446a98SMatthew Knepley           PetscOptionsList(), PetscOptionsEList()
1413e2446a98SMatthew Knepley @*/
14147087cfbeSBarry Smith PetscErrorCode  PetscOptionsBoolArray(const char opt[],const char text[],const char man[],PetscBool  value[],PetscInt *n,PetscBool  *set)
1415e2446a98SMatthew Knepley {
1416e2446a98SMatthew Knepley   PetscErrorCode ierr;
1417e2446a98SMatthew Knepley   PetscInt       i;
14181ae3d29cSBarry Smith   PetscOptions   amsopt;
1419e2446a98SMatthew Knepley 
1420e2446a98SMatthew Knepley   PetscFunctionBegin;
14211ae3d29cSBarry Smith   if (!PetscOptionsPublishCount) {
1422ace3abfcSBarry Smith     PetscBool  *vals;
14231ae3d29cSBarry Smith 
14241ae3d29cSBarry Smith     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL_ARRAY,&amsopt);CHKERRQ(ierr);
1425ace3abfcSBarry Smith     ierr = PetscMalloc((*n)*sizeof(PetscBool),&amsopt->data);CHKERRQ(ierr);
1426ace3abfcSBarry Smith     vals = (PetscBool*)amsopt->data;
14271ae3d29cSBarry Smith     for (i=0; i<*n; i++) vals[i] = value[i];
14281ae3d29cSBarry Smith     amsopt->arraylength = *n;
14291ae3d29cSBarry Smith   }
1430acfcf0e5SJed Brown   ierr = PetscOptionsGetBoolArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr);
1431e2446a98SMatthew Knepley   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
1432e2446a98SMatthew Knepley     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%d",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr);
1433e2446a98SMatthew Knepley     for (i=1; i<*n; i++) {
1434e2446a98SMatthew Knepley       ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%d",value[i]);CHKERRQ(ierr);
1435e2446a98SMatthew Knepley     }
14362aa6d131SJed Brown     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,ManSection(man));CHKERRQ(ierr);
1437e2446a98SMatthew Knepley   }
1438e2446a98SMatthew Knepley   PetscFunctionReturn(0);
1439e2446a98SMatthew Knepley }
1440e2446a98SMatthew Knepley 
144153acd3b1SBarry Smith 
144253acd3b1SBarry Smith #undef __FUNCT__
144353acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsHead"
144453acd3b1SBarry Smith /*@C
1445b52f573bSBarry Smith      PetscOptionsHead - Puts a heading before listing any more published options. Used, for example,
144653acd3b1SBarry Smith             in KSPSetFromOptions_GMRES().
144753acd3b1SBarry Smith 
14483f9fe445SBarry Smith    Logically Collective on the communicator passed in PetscOptionsBegin()
144953acd3b1SBarry Smith 
145053acd3b1SBarry Smith    Input Parameter:
145153acd3b1SBarry Smith .   head - the heading text
145253acd3b1SBarry Smith 
145353acd3b1SBarry Smith 
145453acd3b1SBarry Smith    Level: intermediate
145553acd3b1SBarry Smith 
145653acd3b1SBarry Smith    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
145753acd3b1SBarry Smith 
1458b52f573bSBarry Smith           Can be followed by a call to PetscOptionsTail() in the same function.
145953acd3b1SBarry Smith 
146053acd3b1SBarry Smith    Concepts: options database^subheading
146153acd3b1SBarry Smith 
146253acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1463acfcf0e5SJed Brown            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
146453acd3b1SBarry Smith           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
146553acd3b1SBarry Smith           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1466acfcf0e5SJed Brown           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
146753acd3b1SBarry Smith           PetscOptionsList(), PetscOptionsEList()
146853acd3b1SBarry Smith @*/
14697087cfbeSBarry Smith PetscErrorCode  PetscOptionsHead(const char head[])
147053acd3b1SBarry Smith {
147153acd3b1SBarry Smith   PetscErrorCode ierr;
147253acd3b1SBarry Smith 
147353acd3b1SBarry Smith   PetscFunctionBegin;
147461b37b28SSatish Balay   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
147553acd3b1SBarry Smith     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  %s\n",head);CHKERRQ(ierr);
147653acd3b1SBarry Smith   }
147753acd3b1SBarry Smith   PetscFunctionReturn(0);
147853acd3b1SBarry Smith }
147953acd3b1SBarry Smith 
148053acd3b1SBarry Smith 
148153acd3b1SBarry Smith 
148253acd3b1SBarry Smith 
148353acd3b1SBarry Smith 
148453acd3b1SBarry Smith 
1485