xref: /petsc/src/sys/objects/aoptions.c (revision 5a586d828132823a7f656d0d7f79985f923612fa)
1 #define PETSC_DLL
2 /*
3    Implements the higher-level options database querying methods. These are self-documenting and can attach at runtime to
4    GUI code to display the options and get values from the users.
5 
6 */
7 
8 #include "petscsys.h"        /*I  "petscsys.h"   I*/
9 #if defined(PETSC_HAVE_STDLIB_H)
10 #include <stdlib.h>
11 #endif
12 
13 /*
14     Keep a linked list of options that have been posted and we are waiting for
15    user selection. See the manual page for PetscOptionsBegin()
16 
17     Eventually we'll attach this beast to a MPI_Comm
18 */
19 PetscOptionsObjectType PetscOptionsObject;
20 PetscInt               PetscOptionsPublishCount = 0;
21 
22 #undef __FUNCT__
23 #define __FUNCT__ "PetscOptionsBegin_Private"
24 /*
25     Handles setting up the data structure in a call to PetscOptionsBegin()
26 */
27 PetscErrorCode PetscOptionsBegin_Private(MPI_Comm comm,const char prefix[],const char title[],const char mansec[])
28 {
29   PetscErrorCode ierr;
30 
31   PetscFunctionBegin;
32   PetscOptionsObject.next          = 0;
33   PetscOptionsObject.comm          = comm;
34   PetscOptionsObject.changedmethod = PETSC_FALSE;
35   if (PetscOptionsObject.prefix) {
36     ierr = PetscFree(PetscOptionsObject.prefix);CHKERRQ(ierr); PetscOptionsObject.prefix = 0;
37   }
38   ierr = PetscStrallocpy(prefix,&PetscOptionsObject.prefix);CHKERRQ(ierr);
39   if (PetscOptionsObject.title) {
40     ierr = PetscFree(PetscOptionsObject.title);CHKERRQ(ierr); PetscOptionsObject.title  = 0;
41   }
42   ierr = PetscStrallocpy(title,&PetscOptionsObject.title);CHKERRQ(ierr);
43 
44   ierr = PetscOptionsHasName(PETSC_NULL,"-help",&PetscOptionsObject.printhelp);CHKERRQ(ierr);
45   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1) {
46     if (!PetscOptionsObject.alreadyprinted) {
47       ierr = (*PetscHelpPrintf)(comm,"%s -------------------------------------------------\n",title);CHKERRQ(ierr);
48     }
49   }
50   PetscFunctionReturn(0);
51 }
52 
53 /*
54      Handles adding another option to the list of options within this particular PetscOptionsBegin() PetscOptionsEnd()
55 */
56 #undef __FUNCT__
57 #define __FUNCT__ "PetscOptionsCreate_Private"
58 static int PetscOptionsCreate_Private(const char opt[],const char text[],const char man[],PetscOptionType t,PetscOptions *amsopt)
59 {
60   int          ierr;
61   PetscOptions next;
62 
63   PetscFunctionBegin;
64   ierr             = PetscNew(struct _p_PetscOptions,amsopt);CHKERRQ(ierr);
65   (*amsopt)->next  = 0;
66   (*amsopt)->set   = PETSC_FALSE;
67   (*amsopt)->type  = t;
68   (*amsopt)->data  = 0;
69 
70   ierr             = PetscStrallocpy(text,&(*amsopt)->text);CHKERRQ(ierr);
71   ierr             = PetscStrallocpy(opt,&(*amsopt)->option);CHKERRQ(ierr);
72   ierr             = PetscStrallocpy(man,&(*amsopt)->man);CHKERRQ(ierr);
73 
74   if (!PetscOptionsObject.next) {
75     PetscOptionsObject.next = *amsopt;
76   } else {
77     next = PetscOptionsObject.next;
78     while (next->next) next = next->next;
79     next->next = *amsopt;
80   }
81   PetscFunctionReturn(0);
82 }
83 
84 #undef __FUNCT__
85 #define __FUNCT__ "PetscScanString"
86 /*
87     PetscScanString -  Gets user input via stdin from process and broadcasts to all processes
88 
89     Collective on MPI_Comm
90 
91    Input Parameters:
92 +     commm - communicator for the broadcast, must be PETSC_COMM_WORLD
93 .     n - length of the string, must be the same on all processes
94 -     str - location to store input
95 
96     Bugs:
97 .   Assumes process 0 of the given communicator has access to stdin
98 
99 */
100 static PetscErrorCode PetscScanString(MPI_Comm comm,size_t n,char str[])
101 {
102   size_t         i;
103   char           c;
104   PetscMPIInt    rank,nm;
105   PetscErrorCode ierr;
106 
107   PetscFunctionBegin;
108   ierr = MPI_Comm_rank(comm,&rank);CHKERRQ(ierr);
109   if (!rank) {
110     c = (char) getchar();
111     i = 0;
112     while ( c != '\n' && i < n-1) {
113       str[i++] = c;
114       c = (char) getchar();
115     }
116     str[i] = 0;
117   }
118   nm   = PetscMPIIntCast(n);
119   ierr = MPI_Bcast(str,nm,MPI_CHAR,0,comm);CHKERRQ(ierr);
120   PetscFunctionReturn(0);
121 }
122 
123 #undef __FUNCT__
124 #define __FUNCT__ "PetscOptionsGetFromTextInput"
125 /*
126     PetscOptionsGetFromTextInput - Presents all the PETSc Options processed by the program so the user may change them at runtime
127 
128     Notes: this isn't really practical, it is just to demonstrate the principle
129 
130     Bugs:
131 +    All processes must traverse through the exact same set of option queries do to the call to PetscScanString()
132 .    Internal strings have arbitrary length and string copies are not checked that they fit into string space
133 -    Only works for PetscInt == int, PetscReal == double etc
134 
135     Developer Notes: Normally the GUI that presents the options the user and retrieves the values would be running in a different
136      address space and communicating with the PETSc program
137 
138 */
139 PetscErrorCode PetscOptionsGetFromTextInput()
140 {
141   PetscErrorCode ierr;
142   PetscOptions   next = PetscOptionsObject.next;
143   char           str[512];
144   PetscInt       id;
145   PetscReal      ir,*valr;
146   PetscInt       *vald;
147   size_t         i;
148 
149   ierr = (*PetscPrintf)(PETSC_COMM_WORLD,"%s -------------------------------------------------\n",PetscOptionsObject.title);CHKERRQ(ierr);
150   while (next) {
151     switch (next->type) {
152       case OPTION_HEAD:
153         break;
154       case OPTION_INT_ARRAY:
155         ierr = PetscPrintf(PETSC_COMM_WORLD,"-%s%s <",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",next->option+1);CHKERRQ(ierr);
156         vald = (PetscInt*) next->data;
157         for (i=0; i<next->arraylength; i++) {
158           ierr = PetscPrintf(PETSC_COMM_WORLD,"%d",vald[i]);CHKERRQ(ierr);
159           if (i < next->arraylength-1) {
160             ierr = PetscPrintf(PETSC_COMM_WORLD,",");CHKERRQ(ierr);
161           }
162         }
163         ierr = PetscPrintf(PETSC_COMM_WORLD,">: %s (%s)",next->text,next->man);CHKERRQ(ierr);
164         ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr);
165         if (str[0]) {
166           PetscToken token;
167           PetscInt   n=0,nmax = next->arraylength,*dvalue = (PetscInt*)next->data,start,end;
168           size_t     len;
169           char*      value;
170           PetscTruth foundrange;
171 
172           next->set = PETSC_TRUE;
173           value = str;
174 	  ierr = PetscTokenCreate(value,',',&token);CHKERRQ(ierr);
175 	  ierr = PetscTokenFind(token,&value);CHKERRQ(ierr);
176 	  while (n < nmax) {
177 	    if (!value) break;
178 
179 	    /* look for form  d-D where d and D are integers */
180 	    foundrange = PETSC_FALSE;
181 	    ierr      = PetscStrlen(value,&len);CHKERRQ(ierr);
182 	    if (value[0] == '-') i=2;
183 	    else i=1;
184 	    for (;i<len; i++) {
185 	      if (value[i] == '-') {
186 		if (i == len-1) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_USER,"Error in %D-th array entry %s\n",n,value);
187 		value[i] = 0;
188 		ierr     = PetscOptionsAtoi(value,&start);CHKERRQ(ierr);
189 		ierr     = PetscOptionsAtoi(value+i+1,&end);CHKERRQ(ierr);
190 		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);
191 		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);
192 		for (;start<end; start++) {
193 		  *dvalue = start; dvalue++;n++;
194 		}
195 		foundrange = PETSC_TRUE;
196 		break;
197 	      }
198 	    }
199 	    if (!foundrange) {
200 	      ierr      = PetscOptionsAtoi(value,dvalue);CHKERRQ(ierr);
201 	      dvalue++;
202 	      n++;
203 	    }
204 	    ierr = PetscTokenFind(token,&value);CHKERRQ(ierr);
205 	  }
206 	  ierr = PetscTokenDestroy(token);CHKERRQ(ierr);
207         }
208         break;
209       case OPTION_REAL_ARRAY:
210         ierr = PetscPrintf(PETSC_COMM_WORLD,"-%s%s <",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",next->option+1);CHKERRQ(ierr);
211         valr = (PetscReal*) next->data;
212         for (i=0; i<next->arraylength; i++) {
213           ierr = PetscPrintf(PETSC_COMM_WORLD,"%g",valr[i]);CHKERRQ(ierr);
214           if (i < next->arraylength-1) {
215             ierr = PetscPrintf(PETSC_COMM_WORLD,",");CHKERRQ(ierr);
216           }
217         }
218         ierr = PetscPrintf(PETSC_COMM_WORLD,">: %s (%s)",next->text,next->man);CHKERRQ(ierr);
219         ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr);
220         if (str[0]) {
221           PetscToken token;
222           PetscInt   n=0,nmax = next->arraylength;
223           PetscReal   *dvalue = (PetscReal*)next->data;
224           char*      value;
225 
226           next->set = PETSC_TRUE;
227           value = str;
228 	  ierr = PetscTokenCreate(value,',',&token);CHKERRQ(ierr);
229 	  ierr = PetscTokenFind(token,&value);CHKERRQ(ierr);
230 	  while (n < nmax) {
231 	    if (!value) break;
232             ierr      = PetscOptionsAtod(value,dvalue);CHKERRQ(ierr);
233 	    dvalue++;
234 	    n++;
235 	    ierr = PetscTokenFind(token,&value);CHKERRQ(ierr);
236 	  }
237 	  ierr = PetscTokenDestroy(token);CHKERRQ(ierr);
238         }
239         break;
240       case OPTION_INT:
241         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);
242         ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr);
243         if (str[0]) {
244 #if defined(PETSC_USE_64BIT_INDICES)
245           sscanf(str,"%lld",&id);
246 #else
247           sscanf(str,"%d",&id);
248 #endif
249           next->set = PETSC_TRUE;
250           *((PetscInt*)next->data) = id;
251         }
252         break;
253       case OPTION_REAL:
254         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);
255         ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr);
256         if (str[0]) {
257 #if defined(PETSC_USE_SCALAR_SINGLE)
258           sscanf(str,"%e",&ir);
259 #else
260           sscanf(str,"%le",&ir);
261 #endif
262           next->set = PETSC_TRUE;
263           *((PetscReal*)next->data) = ir;
264         }
265         break;
266       case OPTION_LOGICAL:
267       case OPTION_STRING:
268         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);
269         ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr);
270         if (str[0]) {
271           next->set = PETSC_TRUE;
272           ierr = PetscStrcpy((char*)next->data,str);CHKERRQ(ierr);
273         }
274         break;
275       case OPTION_LIST:
276         ierr = PetscFListPrintTypes(PETSC_COMM_WORLD,stdout,PetscOptionsObject.prefix,next->option,next->text,next->man,next->flist,(char*)next->data);CHKERRQ(ierr);
277         ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr);
278         if (str[0]) {
279 	  PetscOptionsObject.changedmethod = PETSC_TRUE;
280           next->set = PETSC_TRUE;
281           ierr = PetscStrcpy((char*)next->data,str);CHKERRQ(ierr);
282         }
283         break;
284     default:
285       break;
286     }
287     next = next->next;
288   }
289   PetscFunctionReturn(0);
290 }
291 
292 #if defined(PETSC_HAVE_AMS)
293 #define CHKERRAMS(err)  if (err) {char *msg; AMS_Explain_error((err), &(msg)); SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"AMS Error: %s",msg);}
294 #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);}
295 
296 static int  count = 0;
297 
298 #undef __FUNCT__
299 #define __FUNCT__ "PetscOptionsAMSDestroy"
300 PetscErrorCode PetscOptionsAMSDestroy(void)
301 {
302   PetscErrorCode ierr;
303   AMS_Comm       acomm = -1;
304   AMS_Memory     amem = -1;
305   char           options[16];
306   const char     *string = "Exit";
307 
308   /* the next line is a bug, this will only work if all processors are here, the comm passed in is ignored!!! */
309   ierr = PetscViewerAMSGetAMSComm(PETSC_VIEWER_AMS_(PETSC_COMM_WORLD),&acomm);CHKERRQ(ierr);
310   sprintf(options,"Options_%d",count++);
311   ierr = AMS_Memory_create(acomm,options,&amem);CHKERRAMS(ierr);
312   ierr = AMS_Memory_add_field(amem,"Exit",&string,1,AMS_STRING,AMS_READ,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,"Exit");
313 
314   ierr = AMS_Memory_take_access(amem);CHKERRAMS(ierr);
315   ierr = AMS_Memory_publish(amem);CHKERRAMS(ierr);
316   ierr = AMS_Memory_grant_access(amem);CHKERRAMS(ierr);
317   /* wait until accessor has unlocked the memory */
318   ierr = AMS_Memory_lock(amem,0);CHKERRAMS(ierr);
319   ierr = AMS_Memory_take_access(amem);CHKERRAMS(ierr);
320   ierr = AMS_Memory_grant_access(amem);CHKERRAMS(ierr);
321   ierr = AMS_Memory_destroy(amem);CHKERRAMS(ierr);
322   PetscFunctionReturn(0);
323 }
324 
325 #undef __FUNCT__
326 #define __FUNCT__ "PetscOptionsAMSInput"
327 /*
328     PetscOptionsAMSInput - Presents all the PETSc Options processed by the program so the user may change them at runtime using the AMS
329 
330     Bugs:
331 +    All processes must traverse through the exact same set of option queries do to the call to PetscScanString()
332 .    Internal strings have arbitrary length and string copies are not checked that they fit into string space
333 -    Only works for PetscInt == int, PetscReal == double etc
334 
335 
336 */
337 PetscErrorCode PetscOptionsAMSInput()
338 {
339   PetscErrorCode ierr;
340   PetscOptions   next = PetscOptionsObject.next;
341   static int     mancount = 0;
342   char           options[16];
343   AMS_Comm       acomm = -1;
344   AMS_Memory     amem = -1;
345   PetscTruth     changedmethod = PETSC_FALSE;
346   char           manname[16];
347 
348   /* the next line is a bug, this will only work if all processors are here, the comm passed in is ignored!!! */
349   ierr = PetscViewerAMSGetAMSComm(PETSC_VIEWER_AMS_(PETSC_COMM_WORLD),&acomm);CHKERRQ(ierr);
350   sprintf(options,"Options_%d",count++);
351   ierr = AMS_Memory_create(acomm,options,&amem);CHKERRAMS(ierr);
352   ierr = AMS_Memory_take_access(amem);CHKERRAMS(ierr);
353   PetscOptionsObject.pprefix = PetscOptionsObject.prefix; /* AMS will change this, so cannot pass prefix directly */
354 
355   ierr = AMS_Memory_add_field(amem,PetscOptionsObject.title,&PetscOptionsObject.pprefix,1,AMS_STRING,AMS_READ,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,PetscOptionsObject.title);
356   //  ierr = AMS_Memory_add_field(amem,"mansec",&PetscOptionsObject.pprefix,1,AMS_STRING,AMS_READ,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMS(ierr);
357   ierr = AMS_Memory_add_field(amem,"ChangedMethod",&changedmethod,1,AMS_BOOLEAN,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,"ChangedMethod");
358 
359   while (next) {
360     ierr = AMS_Memory_add_field(amem,next->option,&next->set,1,AMS_INT,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->option);
361     ierr =  PetscMalloc(sizeof(char*),&next->pman);CHKERRQ(ierr);
362     *(char **)next->pman = next->man;
363     sprintf(manname,"man_%d",mancount++);
364     ierr = AMS_Memory_add_field(amem,manname,next->pman,1,AMS_STRING,AMS_READ,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,manname);
365 
366     switch (next->type) {
367       case OPTION_HEAD:
368         break;
369       case OPTION_INT_ARRAY:
370         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);
371         break;
372       case OPTION_REAL_ARRAY:
373         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);
374         break;
375       case OPTION_INT:
376 	ierr = AMS_Memory_add_field(amem,next->text,next->data,1,AMS_INT,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->text);
377         break;
378       case OPTION_REAL:
379 	ierr = AMS_Memory_add_field(amem,next->text,next->data,1,AMS_DOUBLE,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->text);
380         break;
381       case OPTION_LOGICAL:
382 	ierr = AMS_Memory_add_field(amem,next->text,next->data,1,AMS_BOOLEAN,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->text);
383         break;
384       case OPTION_LOGICAL_ARRAY:
385 	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);
386         break;
387       case OPTION_STRING:
388 	ierr = AMS_Memory_add_field(amem,next->text,next->data,1,AMS_STRING,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->text);
389         break;
390       case OPTION_STRING_ARRAY:
391 	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);
392         break;
393       case OPTION_LIST:
394         {PetscInt  ntext;
395         char       ldefault[128];
396 	ierr = PetscStrcpy(ldefault,"DEFAULT:");CHKERRQ(ierr);
397 	ierr = PetscStrcat(ldefault,next->text);CHKERRQ(ierr);
398 	ierr = AMS_Memory_add_field(amem,ldefault,next->data,1,AMS_STRING,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,ldefault);
399 	ierr = PetscFListGet(next->flist,(char***)&next->edata,&ntext);CHKERRQ(ierr);
400 	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);
401         break;}
402       case OPTION_ELIST:
403         {PetscInt  ntext = next->nlist;
404         char       ldefault[128];
405 	ierr = PetscStrcpy(ldefault,"DEFAULT:");CHKERRQ(ierr);
406 	ierr = PetscStrcat(ldefault,next->text);CHKERRQ(ierr);
407 	ierr = AMS_Memory_add_field(amem,ldefault,next->data,1,AMS_STRING,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,ldefault);
408 	ierr = PetscMalloc((ntext+1)*sizeof(char**),&next->edata);CHKERRQ(ierr);
409         ierr = PetscMemcpy(next->edata,next->list,ntext*sizeof(char*));CHKERRQ(ierr);
410 	ierr = AMS_Memory_add_field(amem,next->text,next->edata,ntext,AMS_STRING,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->text);
411         break;}
412     default:
413       break;
414     }
415     next = next->next;
416   }
417 
418   ierr = AMS_Memory_publish(amem);CHKERRAMS(ierr);
419   ierr = AMS_Memory_grant_access(amem);CHKERRAMS(ierr);
420   /* wait until accessor has unlocked the memory */
421   ierr = AMS_Memory_lock(amem,0);CHKERRAMS(ierr);
422   ierr = AMS_Memory_take_access(amem);CHKERRAMS(ierr);
423 
424   /* reset counter to -2; this updates the screen with the new options for the selected method */
425   if (changedmethod) PetscOptionsPublishCount = -2;
426 
427   ierr = AMS_Memory_grant_access(amem);CHKERRAMS(ierr);
428   ierr = AMS_Memory_destroy(amem);CHKERRAMS(ierr);
429   PetscFunctionReturn(0);
430 }
431 #endif
432 
433 #undef __FUNCT__
434 #define __FUNCT__ "PetscOptionsEnd_Private"
435 PetscErrorCode PetscOptionsEnd_Private(void)
436 {
437   PetscErrorCode ierr;
438   PetscOptions   last;
439   char           option[256],value[1024],tmp[32];
440   size_t         j;
441 
442   PetscFunctionBegin;
443 
444   CHKMEMQ;
445   if (PetscOptionsObject.next) {
446     if (!PetscOptionsPublishCount) {
447 #if defined(PETSC_HAVE_AMS)
448       ierr = PetscOptionsAMSInput();CHKERRQ(ierr);
449 #else
450       ierr = PetscOptionsGetFromTextInput();CHKERRQ(ierr);
451 #endif
452     }
453   }
454 
455   ierr = PetscFree(PetscOptionsObject.title);CHKERRQ(ierr); PetscOptionsObject.title  = 0;
456   ierr = PetscFree(PetscOptionsObject.prefix);CHKERRQ(ierr); PetscOptionsObject.prefix = 0;
457 
458   /* reset counter to -2; this updates the screen with the new options for the selected method */
459   if (PetscOptionsObject.changedmethod) PetscOptionsPublishCount = -2;
460   /* reset alreadyprinted flag */
461   PetscOptionsObject.alreadyprinted = PETSC_FALSE;
462 
463   while (PetscOptionsObject.next) {
464     if (PetscOptionsObject.next->set) {
465       if (PetscOptionsObject.prefix) {
466         ierr = PetscStrcpy(option,"-");CHKERRQ(ierr);
467         ierr = PetscStrcat(option,PetscOptionsObject.prefix);CHKERRQ(ierr);
468         ierr = PetscStrcat(option,PetscOptionsObject.next->option+1);CHKERRQ(ierr);
469       } else {
470         ierr = PetscStrcpy(option,PetscOptionsObject.next->option);CHKERRQ(ierr);
471       }
472 
473       switch (PetscOptionsObject.next->type) {
474         case OPTION_HEAD:
475           break;
476         case OPTION_INT_ARRAY:
477           sprintf(value,"%d",(int)((PetscInt*)PetscOptionsObject.next->data)[0]);
478           for (j=1; j<PetscOptionsObject.next->arraylength; j++) {
479             sprintf(tmp,"%d",(int)((PetscInt*)PetscOptionsObject.next->data)[j]);
480             ierr = PetscStrcat(value,",");CHKERRQ(ierr);
481             ierr = PetscStrcat(value,tmp);CHKERRQ(ierr);
482           }
483           break;
484         case OPTION_INT:
485           sprintf(value,"%d",(int) *(PetscInt*)PetscOptionsObject.next->data);
486           break;
487         case OPTION_REAL:
488           sprintf(value,"%g",(double) *(PetscReal*)PetscOptionsObject.next->data);
489           break;
490         case OPTION_REAL_ARRAY:
491           sprintf(value,"%g",(double)((PetscReal*)PetscOptionsObject.next->data)[0]);
492           for (j=1; j<PetscOptionsObject.next->arraylength; j++) {
493             sprintf(tmp,"%g",(double)((PetscReal*)PetscOptionsObject.next->data)[j]);
494             ierr = PetscStrcat(value,",");CHKERRQ(ierr);
495             ierr = PetscStrcat(value,tmp);CHKERRQ(ierr);
496           }
497           break;
498         case OPTION_LOGICAL:
499           sprintf(value,"%d",*(int*)PetscOptionsObject.next->data);
500           break;
501       case OPTION_LOGICAL_ARRAY:
502           sprintf(value,"%d",(int)((PetscTruth*)PetscOptionsObject.next->data)[0]);
503           for (j=1; j<PetscOptionsObject.next->arraylength; j++) {
504             sprintf(tmp,"%d",(int)((PetscTruth*)PetscOptionsObject.next->data)[j]);
505             ierr = PetscStrcat(value,",");CHKERRQ(ierr);
506             ierr = PetscStrcat(value,tmp);CHKERRQ(ierr);
507           }
508           break;
509         case OPTION_LIST:
510         case OPTION_ELIST:
511           ierr = PetscStrcpy(value,*(char**)PetscOptionsObject.next->data);CHKERRQ(ierr);
512           break;
513         case OPTION_STRING:
514           ierr = PetscStrcpy(value,*(char**)PetscOptionsObject.next->data);CHKERRQ(ierr);
515         case OPTION_STRING_ARRAY:
516           sprintf(value,"%s",((char**)PetscOptionsObject.next->data)[0]);
517           for (j=1; j<PetscOptionsObject.next->arraylength; j++) {
518             sprintf(tmp,"%s",((char**)PetscOptionsObject.next->data)[j]);
519             ierr = PetscStrcat(value,",");CHKERRQ(ierr);
520             ierr = PetscStrcat(value,tmp);CHKERRQ(ierr);
521           }
522           break;
523       }
524       ierr = PetscOptionsSetValue(option,value);CHKERRQ(ierr);
525     }
526     ierr   = PetscFree(PetscOptionsObject.next->text);CHKERRQ(ierr);
527     ierr   = PetscFree(PetscOptionsObject.next->option);CHKERRQ(ierr);
528     ierr   = PetscFree(PetscOptionsObject.next->man);CHKERRQ(ierr);
529     ierr   = PetscFree(PetscOptionsObject.next->data);CHKERRQ(ierr);
530     ierr   = PetscFree(PetscOptionsObject.next->edata);CHKERRQ(ierr);
531     last                    = PetscOptionsObject.next;
532     PetscOptionsObject.next = PetscOptionsObject.next->next;
533     ierr                    = PetscFree(last);CHKERRQ(ierr);
534     CHKMEMQ;
535   }
536   CHKMEMQ;
537   PetscOptionsObject.next = 0;
538   PetscFunctionReturn(0);
539 }
540 
541 #undef __FUNCT__
542 #define __FUNCT__ "PetscOptionsEnum"
543 /*@C
544    PetscOptionsEnum - Gets the enum value for a particular option in the database.
545 
546    Collective on the communicator passed in PetscOptionsBegin()
547 
548    Input Parameters:
549 +  opt - option name
550 .  text - short string that describes the option
551 .  man - manual page with additional information on option
552 .  list - array containing the list of choices, followed by the enum name, followed by the enum prefix, followed by a null
553 -  defaultv - the default (current) value
554 
555    Output Parameter:
556 +  value - the  value to return
557 -  flg - PETSC_TRUE if found, else PETSC_FALSE
558 
559    Level: beginner
560 
561    Concepts: options database
562 
563    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
564 
565           list is usually something like PCASMTypes or some other predefined list of enum names
566 
567 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
568           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth()
569           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(),
570           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
571           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
572           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
573           PetscOptionsList(), PetscOptionsEList()
574 @*/
575 PetscErrorCode PETSC_DLLEXPORT PetscOptionsEnum(const char opt[],const char text[],const char man[],const char *const*list,PetscEnum defaultv,PetscEnum *value,PetscTruth *set)
576 {
577   PetscErrorCode ierr;
578   PetscInt       ntext = 0;
579   PetscInt       tval;
580   PetscTruth     tflg;
581 
582   PetscFunctionBegin;
583   while (list[ntext++]) {
584     if (ntext > 50) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"List argument appears to be wrong or have more than 50 entries");
585   }
586   if (ntext < 3) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"List argument must have at least two entries: typename and type prefix");
587   ntext -= 3;
588   ierr = PetscOptionsEList(opt,text,man,list,ntext,list[defaultv],&tval,&tflg);CHKERRQ(ierr);
589   /* with PETSC_USE_64BIT_INDICES sizeof(PetscInt) != sizeof(PetscEnum) */
590   if (tflg) *value = (PetscEnum)tval;
591   if (set)  *set   = tflg;
592   PetscFunctionReturn(0);
593 }
594 
595 /* -------------------------------------------------------------------------------------------------------------*/
596 #undef __FUNCT__
597 #define __FUNCT__ "PetscOptionsInt"
598 /*@C
599    PetscOptionsInt - Gets the integer value for a particular option in the database.
600 
601    Collective on the communicator passed in PetscOptionsBegin()
602 
603    Input Parameters:
604 +  opt - option name
605 .  text - short string that describes the option
606 .  man - manual page with additional information on option
607 -  defaultv - the default (current) value
608 
609    Output Parameter:
610 +  value - the integer value to return
611 -  flg - PETSC_TRUE if found, else PETSC_FALSE
612 
613    Level: beginner
614 
615    Concepts: options database^has int
616 
617    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
618 
619 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
620           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth()
621           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(),
622           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
623           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
624           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
625           PetscOptionsList(), PetscOptionsEList()
626 @*/
627 PetscErrorCode PETSC_DLLEXPORT PetscOptionsInt(const char opt[],const char text[],const char man[],PetscInt defaultv,PetscInt *value,PetscTruth *set)
628 {
629   PetscErrorCode ierr;
630   PetscOptions   amsopt;
631 
632   PetscFunctionBegin;
633   if (!PetscOptionsPublishCount) {
634     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_INT,&amsopt);CHKERRQ(ierr);
635     ierr = PetscMalloc(sizeof(PetscInt),&amsopt->data);CHKERRQ(ierr);
636     *(PetscInt*)amsopt->data = defaultv;
637   }
638   ierr = PetscOptionsGetInt(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr);
639   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
640     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%d>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,man);CHKERRQ(ierr);
641   }
642   PetscFunctionReturn(0);
643 }
644 
645 #undef __FUNCT__
646 #define __FUNCT__ "PetscOptionsString"
647 /*@C
648    PetscOptionsString - Gets the string value for a particular option in the database.
649 
650    Collective on the communicator passed in PetscOptionsBegin()
651 
652    Input Parameters:
653 +  opt - option name
654 .  text - short string that describes the option
655 .  man - manual page with additional information on option
656 -  defaultv - the default (current) value
657 
658    Output Parameter:
659 +  value - the value to return
660 -  flg - PETSC_TRUE if found, else PETSC_FALSE
661 
662    Level: beginner
663 
664    Concepts: options database^has int
665 
666    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
667 
668 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
669           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth()
670           PetscOptionsInt(), PetscOptionsReal(), PetscOptionsTruth(),
671           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
672           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
673           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
674           PetscOptionsList(), PetscOptionsEList()
675 @*/
676 PetscErrorCode PETSC_DLLEXPORT PetscOptionsString(const char opt[],const char text[],const char man[],const char defaultv[],char value[],size_t len,PetscTruth *set)
677 {
678   PetscErrorCode ierr;
679   PetscOptions   amsopt;
680 
681   PetscFunctionBegin;
682   if (!PetscOptionsPublishCount) {
683     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_STRING,&amsopt);CHKERRQ(ierr);
684     ierr = PetscMalloc(sizeof(char*),&amsopt->data);CHKERRQ(ierr);
685     *(const char**)amsopt->data = defaultv;
686   }
687   ierr = PetscOptionsGetString(PetscOptionsObject.prefix,opt,value,len,set);CHKERRQ(ierr);
688   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
689     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%s>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,man);CHKERRQ(ierr);
690   }
691   PetscFunctionReturn(0);
692 }
693 
694 #undef __FUNCT__
695 #define __FUNCT__ "PetscOptionsReal"
696 /*@C
697    PetscOptionsReal - Gets the PetscReal value for a particular option in the database.
698 
699    Collective on the communicator passed in PetscOptionsBegin()
700 
701    Input Parameters:
702 +  opt - option name
703 .  text - short string that describes the option
704 .  man - manual page with additional information on option
705 -  defaultv - the default (current) value
706 
707    Output Parameter:
708 +  value - the value to return
709 -  flg - PETSC_TRUE if found, else PETSC_FALSE
710 
711    Level: beginner
712 
713    Concepts: options database^has int
714 
715    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
716 
717 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
718           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth()
719           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(),
720           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
721           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
722           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
723           PetscOptionsList(), PetscOptionsEList()
724 @*/
725 PetscErrorCode PETSC_DLLEXPORT PetscOptionsReal(const char opt[],const char text[],const char man[],PetscReal defaultv,PetscReal *value,PetscTruth *set)
726 {
727   PetscErrorCode ierr;
728   PetscOptions   amsopt;
729 
730   PetscFunctionBegin;
731   if (!PetscOptionsPublishCount) {
732     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_REAL,&amsopt);CHKERRQ(ierr);
733     ierr = PetscMalloc(sizeof(PetscReal),&amsopt->data);CHKERRQ(ierr);
734     *(PetscReal*)amsopt->data = defaultv;
735   }
736   ierr = PetscOptionsGetReal(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr);
737   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
738     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%G>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,man);CHKERRQ(ierr);
739   }
740   PetscFunctionReturn(0);
741 }
742 
743 #undef __FUNCT__
744 #define __FUNCT__ "PetscOptionsScalar"
745 /*@C
746    PetscOptionsScalar - Gets the scalar value for a particular option in the database.
747 
748    Collective on the communicator passed in PetscOptionsBegin()
749 
750    Input Parameters:
751 +  opt - option name
752 .  text - short string that describes the option
753 .  man - manual page with additional information on option
754 -  defaultv - the default (current) value
755 
756    Output Parameter:
757 +  value - the value to return
758 -  flg - PETSC_TRUE if found, else PETSC_FALSE
759 
760    Level: beginner
761 
762    Concepts: options database^has int
763 
764    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
765 
766 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
767           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth()
768           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(),
769           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
770           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
771           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
772           PetscOptionsList(), PetscOptionsEList()
773 @*/
774 PetscErrorCode PETSC_DLLEXPORT PetscOptionsScalar(const char opt[],const char text[],const char man[],PetscScalar defaultv,PetscScalar *value,PetscTruth *set)
775 {
776   PetscErrorCode ierr;
777 
778   PetscFunctionBegin;
779 #if !defined(PETSC_USE_COMPLEX)
780   ierr = PetscOptionsReal(opt,text,man,defaultv,value,set);CHKERRQ(ierr);
781 #else
782   ierr = PetscOptionsGetScalar(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr);
783 #endif
784   PetscFunctionReturn(0);
785 }
786 
787 #undef __FUNCT__
788 #define __FUNCT__ "PetscOptionsName"
789 /*@C
790    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
791                       its value is set to false.
792 
793    Collective on the communicator passed in PetscOptionsBegin()
794 
795    Input Parameters:
796 +  opt - option name
797 .  text - short string that describes the option
798 -  man - manual page with additional information on option
799 
800    Output Parameter:
801 .  flg - PETSC_TRUE if found, else PETSC_FALSE
802 
803    Level: beginner
804 
805    Concepts: options database^has int
806 
807    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
808 
809 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
810           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth()
811           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(),
812           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
813           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
814           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
815           PetscOptionsList(), PetscOptionsEList()
816 @*/
817 PetscErrorCode PETSC_DLLEXPORT PetscOptionsName(const char opt[],const char text[],const char man[],PetscTruth *flg)
818 {
819   PetscErrorCode ierr;
820   PetscOptions   amsopt;
821 
822   PetscFunctionBegin;
823   if (!PetscOptionsPublishCount) {
824     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL,&amsopt);CHKERRQ(ierr);
825     ierr = PetscMalloc(sizeof(PetscTruth),&amsopt->data);CHKERRQ(ierr);
826     *(PetscTruth*)amsopt->data = PETSC_FALSE;
827   }
828   ierr = PetscOptionsHasName(PetscOptionsObject.prefix,opt,flg);CHKERRQ(ierr);
829   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
830     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr);
831   }
832   PetscFunctionReturn(0);
833 }
834 
835 #undef __FUNCT__
836 #define __FUNCT__ "PetscOptionsList"
837 /*@C
838      PetscOptionsList - Puts a list of option values that a single one may be selected from
839 
840    Collective on the communicator passed in PetscOptionsBegin()
841 
842    Input Parameters:
843 +  opt - option name
844 .  text - short string that describes the option
845 .  man - manual page with additional information on option
846 .  list - the possible choices
847 .  defaultv - the default (current) value
848 -  len - the length of the character array value
849 
850    Output Parameter:
851 +  value - the value to return
852 -  set - PETSC_TRUE if found, else PETSC_FALSE
853 
854    Level: intermediate
855 
856    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
857 
858    See PetscOptionsEList() for when the choices are given in a string array
859 
860    To get a listing of all currently specified options,
861     see PetscOptionsPrint() or PetscOptionsGetAll()
862 
863    Concepts: options database^list
864 
865 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
866            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
867           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
868           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
869           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
870           PetscOptionsList(), PetscOptionsEList()
871 @*/
872 PetscErrorCode PETSC_DLLEXPORT PetscOptionsList(const char opt[],const char ltext[],const char man[],PetscFList list,const char defaultv[],char value[],size_t len,PetscTruth *set)
873 {
874   PetscErrorCode ierr;
875   PetscOptions   amsopt;
876 
877   PetscFunctionBegin;
878   if (!PetscOptionsPublishCount) {
879     ierr = PetscOptionsCreate_Private(opt,ltext,man,OPTION_LIST,&amsopt);CHKERRQ(ierr);
880     ierr = PetscMalloc(sizeof(char*),&amsopt->data);CHKERRQ(ierr);
881     *(const char**)amsopt->data = defaultv;
882     amsopt->flist = list;
883   }
884   ierr = PetscOptionsGetString(PetscOptionsObject.prefix,opt,value,len,set);CHKERRQ(ierr);
885   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
886     ierr = PetscFListPrintTypes(PetscOptionsObject.comm,stdout,PetscOptionsObject.prefix,opt,ltext,man,list,defaultv);CHKERRQ(ierr);CHKERRQ(ierr);
887   }
888   PetscFunctionReturn(0);
889 }
890 
891 #undef __FUNCT__
892 #define __FUNCT__ "PetscOptionsEList"
893 /*@C
894      PetscOptionsEList - Puts a list of option values that a single one may be selected from
895 
896    Collective on the communicator passed in PetscOptionsBegin()
897 
898    Input Parameters:
899 +  opt - option name
900 .  ltext - short string that describes the option
901 .  man - manual page with additional information on option
902 .  list - the possible choices
903 .  ntext - number of choices
904 -  defaultv - the default (current) value
905 
906    Output Parameter:
907 +  value - the index of the value to return
908 -  set - PETSC_TRUE if found, else PETSC_FALSE
909 
910    Level: intermediate
911 
912    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
913 
914    See PetscOptionsList() for when the choices are given in a PetscFList()
915 
916    Concepts: options database^list
917 
918 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
919            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
920           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
921           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
922           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
923           PetscOptionsList(), PetscOptionsEList()
924 @*/
925 PetscErrorCode PETSC_DLLEXPORT PetscOptionsEList(const char opt[],const char ltext[],const char man[],const char *const*list,PetscInt ntext,const char defaultv[],PetscInt *value,PetscTruth *set)
926 {
927   PetscErrorCode ierr;
928   PetscInt       i;
929   PetscOptions   amsopt;
930 
931   PetscFunctionBegin;
932   if (!PetscOptionsPublishCount) {
933     ierr = PetscOptionsCreate_Private(opt,ltext,man,OPTION_ELIST,&amsopt);CHKERRQ(ierr);
934     ierr = PetscMalloc(sizeof(char*),&amsopt->data);CHKERRQ(ierr);
935     *(const char**)amsopt->data = defaultv;
936     amsopt->list  = list;
937     amsopt->nlist = ntext;
938   }
939   ierr = PetscOptionsGetEList(PetscOptionsObject.prefix,opt,list,ntext,value,set);CHKERRQ(ierr);
940   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
941     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%s> (choose one of)",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv);CHKERRQ(ierr);
942     for (i=0; i<ntext; i++){
943       ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," %s",list[i]);CHKERRQ(ierr);
944     }
945     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"\n");CHKERRQ(ierr);
946   }
947   PetscFunctionReturn(0);
948 }
949 
950 #undef __FUNCT__
951 #define __FUNCT__ "PetscOptionsTruthGroupBegin"
952 /*@C
953      PetscOptionsTruthGroupBegin - First in a series of logical queries on the options database for
954        which at most a single value can be true.
955 
956    Collective on the communicator passed in PetscOptionsBegin()
957 
958    Input Parameters:
959 +  opt - option name
960 .  text - short string that describes the option
961 -  man - manual page with additional information on option
962 
963    Output Parameter:
964 .  flg - whether that option was set or not
965 
966    Level: intermediate
967 
968    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
969 
970    Must be followed by 0 or more PetscOptionsTruthGroup()s and PetscOptionsTruthGroupEnd()
971 
972     Concepts: options database^logical group
973 
974 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
975            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
976           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
977           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
978           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
979           PetscOptionsList(), PetscOptionsEList()
980 @*/
981 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroupBegin(const char opt[],const char text[],const char man[],PetscTruth *flg)
982 {
983   PetscErrorCode ierr;
984   PetscOptions   amsopt;
985 
986   PetscFunctionBegin;
987   if (!PetscOptionsPublishCount) {
988     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL,&amsopt);CHKERRQ(ierr);
989     ierr = PetscMalloc(sizeof(PetscTruth),&amsopt->data);CHKERRQ(ierr);
990     *(PetscTruth*)amsopt->data = PETSC_FALSE;
991   }
992   *flg = PETSC_FALSE;
993   ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,PETSC_NULL);CHKERRQ(ierr);
994   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
995     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  Pick at most one of -------------\n");CHKERRQ(ierr);
996     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"    -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr);
997   }
998   PetscFunctionReturn(0);
999 }
1000 
1001 #undef __FUNCT__
1002 #define __FUNCT__ "PetscOptionsTruthGroup"
1003 /*@C
1004      PetscOptionsTruthGroup - One in a series of logical queries on the options database for
1005        which at most a single value can be true.
1006 
1007    Collective on the communicator passed in PetscOptionsBegin()
1008 
1009    Input Parameters:
1010 +  opt - option name
1011 .  text - short string that describes the option
1012 -  man - manual page with additional information on option
1013 
1014    Output Parameter:
1015 .  flg - PETSC_TRUE if found, else PETSC_FALSE
1016 
1017    Level: intermediate
1018 
1019    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1020 
1021    Must follow a PetscOptionsTruthGroupBegin() and preceded a PetscOptionsTruthGroupEnd()
1022 
1023     Concepts: options database^logical group
1024 
1025 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1026            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
1027           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1028           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1029           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
1030           PetscOptionsList(), PetscOptionsEList()
1031 @*/
1032 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroup(const char opt[],const char text[],const char man[],PetscTruth *flg)
1033 {
1034   PetscErrorCode ierr;
1035   PetscOptions   amsopt;
1036 
1037   PetscFunctionBegin;
1038   if (!PetscOptionsPublishCount) {
1039     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL,&amsopt);CHKERRQ(ierr);
1040     ierr = PetscMalloc(sizeof(PetscTruth),&amsopt->data);CHKERRQ(ierr);
1041     *(PetscTruth*)amsopt->data = PETSC_FALSE;
1042   }
1043   *flg = PETSC_FALSE;
1044   ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,PETSC_NULL);CHKERRQ(ierr);
1045   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
1046     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"    -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr);
1047   }
1048   PetscFunctionReturn(0);
1049 }
1050 
1051 #undef __FUNCT__
1052 #define __FUNCT__ "PetscOptionsTruthGroupEnd"
1053 /*@C
1054      PetscOptionsTruthGroupEnd - Last in a series of logical queries on the options database for
1055        which at most a single value can be true.
1056 
1057    Collective on the communicator passed in PetscOptionsBegin()
1058 
1059    Input Parameters:
1060 +  opt - option name
1061 .  text - short string that describes the option
1062 -  man - manual page with additional information on option
1063 
1064    Output Parameter:
1065 .  flg - PETSC_TRUE if found, else PETSC_FALSE
1066 
1067    Level: intermediate
1068 
1069    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1070 
1071    Must follow a PetscOptionsTruthGroupBegin()
1072 
1073     Concepts: options database^logical group
1074 
1075 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1076            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
1077           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1078           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1079           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
1080           PetscOptionsList(), PetscOptionsEList()
1081 @*/
1082 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroupEnd(const char opt[],const char text[],const char man[],PetscTruth *flg)
1083 {
1084   PetscErrorCode ierr;
1085   PetscOptions   amsopt;
1086 
1087   PetscFunctionBegin;
1088   if (!PetscOptionsPublishCount) {
1089     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL,&amsopt);CHKERRQ(ierr);
1090     ierr = PetscMalloc(sizeof(PetscTruth),&amsopt->data);CHKERRQ(ierr);
1091     *(PetscTruth*)amsopt->data = PETSC_FALSE;
1092   }
1093   *flg = PETSC_FALSE;
1094   ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,PETSC_NULL);CHKERRQ(ierr);
1095   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
1096     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"    -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr);
1097   }
1098   PetscFunctionReturn(0);
1099 }
1100 
1101 #undef __FUNCT__
1102 #define __FUNCT__ "PetscOptionsTruth"
1103 /*@C
1104    PetscOptionsTruth - Determines if a particular option is in the database with a true or false
1105 
1106    Collective on the communicator passed in PetscOptionsBegin()
1107 
1108    Input Parameters:
1109 +  opt - option name
1110 .  text - short string that describes the option
1111 -  man - manual page with additional information on option
1112 
1113    Output Parameter:
1114 .  flg - PETSC_TRUE or PETSC_FALSE
1115 .  set - PETSC_TRUE if found, else PETSC_FALSE
1116 
1117    Level: beginner
1118 
1119    Concepts: options database^logical
1120 
1121    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1122 
1123 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
1124           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth()
1125           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(),
1126           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1127           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1128           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
1129           PetscOptionsList(), PetscOptionsEList()
1130 @*/
1131 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruth(const char opt[],const char text[],const char man[],PetscTruth deflt,PetscTruth *flg,PetscTruth *set)
1132 {
1133   PetscErrorCode ierr;
1134   PetscTruth     iset;
1135   PetscOptions   amsopt;
1136 
1137   PetscFunctionBegin;
1138   if (!PetscOptionsPublishCount) {
1139     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL,&amsopt);CHKERRQ(ierr);
1140     ierr = PetscMalloc(sizeof(PetscTruth),&amsopt->data);CHKERRQ(ierr);
1141     *(PetscTruth*)amsopt->data = deflt;
1142   }
1143   ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,&iset);CHKERRQ(ierr);
1144   if (!iset) {
1145     if (flg) *flg = deflt;
1146   }
1147   if (set) *set = iset;
1148   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
1149     const char *v = PetscTruths[deflt];
1150     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s: <%s> %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,v,text,man);CHKERRQ(ierr);
1151   }
1152   PetscFunctionReturn(0);
1153 }
1154 
1155 #undef __FUNCT__
1156 #define __FUNCT__ "PetscOptionsRealArray"
1157 /*@C
1158    PetscOptionsRealArray - Gets an array of double values for a particular
1159    option in the database. The values must be separated with commas with
1160    no intervening spaces.
1161 
1162    Collective on the communicator passed in PetscOptionsBegin()
1163 
1164    Input Parameters:
1165 +  opt - the option one is seeking
1166 .  text - short string describing option
1167 .  man - manual page for option
1168 -  nmax - maximum number of values
1169 
1170    Output Parameter:
1171 +  value - location to copy values
1172 .  nmax - actual number of values found
1173 -  set - PETSC_TRUE if found, else PETSC_FALSE
1174 
1175    Level: beginner
1176 
1177    Notes:
1178    The user should pass in an array of doubles
1179 
1180    Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1181 
1182    Concepts: options database^array of strings
1183 
1184 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1185            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
1186           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1187           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1188           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
1189           PetscOptionsList(), PetscOptionsEList()
1190 @*/
1191 PetscErrorCode PETSC_DLLEXPORT PetscOptionsRealArray(const char opt[],const char text[],const char man[],PetscReal value[],PetscInt *n,PetscTruth *set)
1192 {
1193   PetscErrorCode ierr;
1194   PetscInt       i;
1195   PetscOptions   amsopt;
1196 
1197   PetscFunctionBegin;
1198   if (!PetscOptionsPublishCount) {
1199     PetscReal *vals;
1200 
1201     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_REAL_ARRAY,&amsopt);CHKERRQ(ierr);
1202     ierr = PetscMalloc((*n)*sizeof(PetscReal),&amsopt->data);CHKERRQ(ierr);
1203     vals = (PetscReal*)amsopt->data;
1204     for (i=0; i<*n; i++) vals[i] = value[i];
1205     amsopt->arraylength = *n;
1206   }
1207   ierr = PetscOptionsGetRealArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr);
1208   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
1209     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%G",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr);
1210     for (i=1; i<*n; i++) {
1211       ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%G",value[i]);CHKERRQ(ierr);
1212     }
1213     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr);
1214   }
1215   PetscFunctionReturn(0);
1216 }
1217 
1218 
1219 #undef __FUNCT__
1220 #define __FUNCT__ "PetscOptionsIntArray"
1221 /*@C
1222    PetscOptionsIntArray - Gets an array of integers for a particular
1223    option in the database. The values must be separated with commas with
1224    no intervening spaces.
1225 
1226    Collective on the communicator passed in PetscOptionsBegin()
1227 
1228    Input Parameters:
1229 +  opt - the option one is seeking
1230 .  text - short string describing option
1231 .  man - manual page for option
1232 -  n - maximum number of values
1233 
1234    Output Parameter:
1235 +  value - location to copy values
1236 .  n - actual number of values found
1237 -  set - PETSC_TRUE if found, else PETSC_FALSE
1238 
1239    Level: beginner
1240 
1241    Notes:
1242    The user should pass in an array of integers
1243 
1244    Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1245 
1246    Concepts: options database^array of strings
1247 
1248 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1249            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
1250           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1251           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1252           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
1253           PetscOptionsList(), PetscOptionsEList(), PetscOptionsRealArray()
1254 @*/
1255 PetscErrorCode PETSC_DLLEXPORT PetscOptionsIntArray(const char opt[],const char text[],const char man[],PetscInt value[],PetscInt *n,PetscTruth *set)
1256 {
1257   PetscErrorCode ierr;
1258   PetscInt       i;
1259   PetscOptions   amsopt;
1260 
1261   PetscFunctionBegin;
1262   if (!PetscOptionsPublishCount) {
1263     PetscInt *vals;
1264 
1265     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_INT_ARRAY,&amsopt);CHKERRQ(ierr);
1266     ierr = PetscMalloc((*n)*sizeof(PetscInt),&amsopt->data);CHKERRQ(ierr);
1267     vals = (PetscInt*)amsopt->data;
1268     for (i=0; i<*n; i++) vals[i] = value[i];
1269     amsopt->arraylength = *n;
1270   }
1271   ierr = PetscOptionsGetIntArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr);
1272   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
1273     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%d",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr);
1274     for (i=1; i<*n; i++) {
1275       ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%d",value[i]);CHKERRQ(ierr);
1276     }
1277     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr);
1278   }
1279   PetscFunctionReturn(0);
1280 }
1281 
1282 #undef __FUNCT__
1283 #define __FUNCT__ "PetscOptionsStringArray"
1284 /*@C
1285    PetscOptionsStringArray - Gets an array of string values for a particular
1286    option in the database. The values must be separated with commas with
1287    no intervening spaces.
1288 
1289    Collective on the communicator passed in PetscOptionsBegin()
1290 
1291    Input Parameters:
1292 +  opt - the option one is seeking
1293 .  text - short string describing option
1294 .  man - manual page for option
1295 -  nmax - maximum number of strings
1296 
1297    Output Parameter:
1298 +  value - location to copy strings
1299 .  nmax - actual number of strings found
1300 -  set - PETSC_TRUE if found, else PETSC_FALSE
1301 
1302    Level: beginner
1303 
1304    Notes:
1305    The user should pass in an array of pointers to char, to hold all the
1306    strings returned by this function.
1307 
1308    The user is responsible for deallocating the strings that are
1309    returned. The Fortran interface for this routine is not supported.
1310 
1311    Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1312 
1313    Concepts: options database^array of strings
1314 
1315 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1316            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
1317           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1318           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1319           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
1320           PetscOptionsList(), PetscOptionsEList()
1321 @*/
1322 PetscErrorCode PETSC_DLLEXPORT PetscOptionsStringArray(const char opt[],const char text[],const char man[],char *value[],PetscInt *nmax,PetscTruth *set)
1323 {
1324   PetscErrorCode ierr;
1325   PetscOptions   amsopt;
1326 
1327   PetscFunctionBegin;
1328   if (!PetscOptionsPublishCount) {
1329     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_STRING_ARRAY,&amsopt);CHKERRQ(ierr);
1330     ierr = PetscMalloc((*nmax)*sizeof(char*),&amsopt->data);CHKERRQ(ierr);
1331     amsopt->arraylength = *nmax;
1332   }
1333   ierr = PetscOptionsGetStringArray(PetscOptionsObject.prefix,opt,value,nmax,set);CHKERRQ(ierr);
1334   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
1335     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <string1,string2,...>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr);
1336   }
1337   PetscFunctionReturn(0);
1338 }
1339 
1340 #undef __FUNCT__
1341 #define __FUNCT__ "PetscOptionsTruthArray"
1342 /*@C
1343    PetscOptionsTruthArray - Gets an array of logical values (true or false) for a particular
1344    option in the database. The values must be separated with commas with
1345    no intervening spaces.
1346 
1347    Collective on the communicator passed in PetscOptionsBegin()
1348 
1349    Input Parameters:
1350 +  opt - the option one is seeking
1351 .  text - short string describing option
1352 .  man - manual page for option
1353 -  nmax - maximum number of values
1354 
1355    Output Parameter:
1356 +  value - location to copy values
1357 .  nmax - actual number of values found
1358 -  set - PETSC_TRUE if found, else PETSC_FALSE
1359 
1360    Level: beginner
1361 
1362    Notes:
1363    The user should pass in an array of doubles
1364 
1365    Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1366 
1367    Concepts: options database^array of strings
1368 
1369 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1370            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
1371           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1372           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1373           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
1374           PetscOptionsList(), PetscOptionsEList()
1375 @*/
1376 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthArray(const char opt[],const char text[],const char man[],PetscTruth value[],PetscInt *n,PetscTruth *set)
1377 {
1378   PetscErrorCode ierr;
1379   PetscInt       i;
1380   PetscOptions   amsopt;
1381 
1382   PetscFunctionBegin;
1383   if (!PetscOptionsPublishCount) {
1384     PetscTruth *vals;
1385 
1386     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL_ARRAY,&amsopt);CHKERRQ(ierr);
1387     ierr = PetscMalloc((*n)*sizeof(PetscTruth),&amsopt->data);CHKERRQ(ierr);
1388     vals = (PetscTruth*)amsopt->data;
1389     for (i=0; i<*n; i++) vals[i] = value[i];
1390     amsopt->arraylength = *n;
1391   }
1392   ierr = PetscOptionsGetTruthArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr);
1393   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
1394     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%d",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr);
1395     for (i=1; i<*n; i++) {
1396       ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%d",value[i]);CHKERRQ(ierr);
1397     }
1398     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr);
1399   }
1400   PetscFunctionReturn(0);
1401 }
1402 
1403 
1404 #undef __FUNCT__
1405 #define __FUNCT__ "PetscOptionsHead"
1406 /*@C
1407      PetscOptionsHead - Puts a heading before listing any more published options. Used, for example,
1408             in KSPSetFromOptions_GMRES().
1409 
1410    Collective on the communicator passed in PetscOptionsBegin()
1411 
1412    Input Parameter:
1413 .   head - the heading text
1414 
1415 
1416    Level: intermediate
1417 
1418    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1419 
1420           Can be followed by a call to PetscOptionsTail() in the same function.
1421 
1422    Concepts: options database^subheading
1423 
1424 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1425            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
1426           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1427           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1428           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
1429           PetscOptionsList(), PetscOptionsEList()
1430 @*/
1431 PetscErrorCode PETSC_DLLEXPORT PetscOptionsHead(const char head[])
1432 {
1433   PetscErrorCode ierr;
1434 
1435   PetscFunctionBegin;
1436   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
1437     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  %s\n",head);CHKERRQ(ierr);
1438   }
1439   PetscFunctionReturn(0);
1440 }
1441 
1442 
1443 
1444 
1445 
1446 
1447