xref: /petsc/src/sys/objects/aoptions.c (revision 1ae3d29c0c4ff12b751c773c3532c58ab4c7ae04)
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 #undef __FUNCT__
296 #define __FUNCT__ "PetscOptionsGetFromAMSInput"
297 /*
298     PetscOptionsGetFromAMSInput - Presents all the PETSc Options processed by the program so the user may change them at runtime using the AMS
299 
300     Bugs:
301 +    All processes must traverse through the exact same set of option queries do to the call to PetscScanString()
302 .    Internal strings have arbitrary length and string copies are not checked that they fit into string space
303 -    Only works for PetscInt == int, PetscReal == double etc
304 
305 
306 */
307 PetscErrorCode PetscOptionsGetFromAMSInput()
308 {
309   PetscErrorCode ierr;
310   PetscOptions   next = PetscOptionsObject.next;
311   static int     count = 0,mancount = 0;
312   char           options[16];
313   AMS_Comm       acomm = -1;
314   AMS_Memory     amem = -1;
315   PetscTruth     changedmethod = PETSC_FALSE;
316   char           manname[16];
317 
318   /* the next line is a bug, this will only work if all processors are here, the comm passed in is ignored!!! */
319   ierr = PetscViewerAMSGetAMSComm(PETSC_VIEWER_AMS_(PETSC_COMM_WORLD),&acomm);CHKERRQ(ierr);
320   sprintf(options,"Options_%d",count++);
321   ierr = AMS_Memory_create(acomm,options,&amem);CHKERRAMS(ierr);
322   ierr = AMS_Memory_take_access(amem);CHKERRAMS(ierr);
323   PetscOptionsObject.pprefix = PetscOptionsObject.prefix; /* AMS will change this, so cannot pass prefix directly */
324 
325   ierr = AMS_Memory_add_field(amem,PetscOptionsObject.title,&PetscOptionsObject.pprefix,1,AMS_STRING,AMS_READ,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,PetscOptionsObject.title);
326   //  ierr = AMS_Memory_add_field(amem,"mansec",&PetscOptionsObject.pprefix,1,AMS_STRING,AMS_READ,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMS(ierr);
327   ierr = AMS_Memory_add_field(amem,"ChangedMethod",&changedmethod,1,AMS_BOOLEAN,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,"ChangedMethod");
328 
329   while (next) {
330     ierr = AMS_Memory_add_field(amem,next->option,&next->set,1,AMS_INT,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->option);
331     ierr =  PetscMalloc(sizeof(char*),&next->pman);CHKERRQ(ierr);
332     *(char **)next->pman = next->man;
333     sprintf(manname,"man_%d",mancount++);
334     ierr = AMS_Memory_add_field(amem,manname,next->pman,1,AMS_STRING,AMS_READ,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,manname);
335 
336     switch (next->type) {
337       case OPTION_HEAD:
338         break;
339       case OPTION_INT_ARRAY:
340         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);
341         break;
342       case OPTION_REAL_ARRAY:
343         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);
344         break;
345       case OPTION_INT:
346 	ierr = AMS_Memory_add_field(amem,next->text,next->data,1,AMS_INT,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->text);
347         break;
348       case OPTION_REAL:
349 	ierr = AMS_Memory_add_field(amem,next->text,next->data,1,AMS_DOUBLE,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->text);
350         break;
351       case OPTION_LOGICAL:
352 	ierr = AMS_Memory_add_field(amem,next->text,next->data,1,AMS_BOOLEAN,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->text);
353         break;
354       case OPTION_LOGICAL_ARRAY:
355 	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);
356         break;
357       case OPTION_STRING:
358 	ierr = AMS_Memory_add_field(amem,next->text,next->data,1,AMS_STRING,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->text);
359         break;
360       case OPTION_STRING_ARRAY:
361 	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);
362         break;
363       case OPTION_LIST:
364         {PetscInt  ntext;
365         char       ldefault[128];
366 	ierr = PetscStrcpy(ldefault,"DEFAULT:");CHKERRQ(ierr);
367 	ierr = PetscStrcat(ldefault,next->text);CHKERRQ(ierr);
368 	ierr = AMS_Memory_add_field(amem,ldefault,next->data,1,AMS_STRING,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,ldefault);
369 	ierr = PetscFListGet(next->flist,(char***)&next->edata,&ntext);CHKERRQ(ierr);
370 	ierr = AMS_Memory_add_field(amem,next->text,next->edata,ntext,AMS_STRING,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->text);
371         break;}
372       case OPTION_ELIST:
373         {PetscInt  ntext;
374         char       ldefault[128];
375 	ierr = PetscStrcpy(ldefault,"DEFAULT:");CHKERRQ(ierr);
376 	ierr = PetscStrcat(ldefault,next->text);CHKERRQ(ierr);
377 	ierr = AMS_Memory_add_field(amem,ldefault,next->data,1,AMS_STRING,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,ldefault);
378 	ierr = PetscMalloc((ntext+1)*sizeof(char**),&next->edata);CHKERRQ(ierr);
379         ierr = PetscMemcpy(next->edata,next->list,ntext*sizeof(char*));CHKERRQ(ierr);
380 	ierr = AMS_Memory_add_field(amem,next->text,next->edata,ntext,AMS_STRING,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRAMSFieldName(ierr,next->text);
381         break;}
382     default:
383       break;
384     }
385     next = next->next;
386   }
387 
388   ierr = AMS_Memory_publish(amem);CHKERRAMS(ierr);
389   ierr = AMS_Memory_grant_access(amem);CHKERRAMS(ierr);
390   /* wait until accessor has unlocked the memory */
391   ierr = AMS_Memory_lock(amem,0);CHKERRAMS(ierr);
392   ierr = AMS_Memory_take_access(amem);CHKERRAMS(ierr);
393 
394   /* reset counter to -2; this updates the screen with the new options for the selected method */
395   if (changedmethod) PetscOptionsPublishCount = -2;
396 
397   ierr = AMS_Memory_grant_access(amem);CHKERRAMS(ierr);
398   ierr = AMS_Memory_destroy(amem);CHKERRAMS(ierr);
399   PetscFunctionReturn(0);
400 }
401 #endif
402 
403 #undef __FUNCT__
404 #define __FUNCT__ "PetscOptionsEnd_Private"
405 PetscErrorCode PetscOptionsEnd_Private(void)
406 {
407   PetscErrorCode ierr;
408   PetscOptions   last;
409   char           option[256],value[1024],tmp[32];
410   size_t         j;
411 
412   PetscFunctionBegin;
413 
414   CHKMEMQ;
415   if (PetscOptionsObject.next) {
416     if (!PetscOptionsPublishCount) {
417 #if defined(PETSC_HAVE_AMS)
418       ierr = PetscOptionsGetFromAMSInput();CHKERRQ(ierr);
419 #else
420       ierr = PetscOptionsGetFromTextInput();CHKERRQ(ierr);
421 #endif
422     }
423   }
424 
425   ierr = PetscFree(PetscOptionsObject.title);CHKERRQ(ierr); PetscOptionsObject.title  = 0;
426   ierr = PetscFree(PetscOptionsObject.prefix);CHKERRQ(ierr); PetscOptionsObject.prefix = 0;
427 
428   /* reset counter to -2; this updates the screen with the new options for the selected method */
429   if (PetscOptionsObject.changedmethod) PetscOptionsPublishCount = -2;
430   /* reset alreadyprinted flag */
431   PetscOptionsObject.alreadyprinted = PETSC_FALSE;
432 
433   while (PetscOptionsObject.next) {
434     if (PetscOptionsObject.next->set) {
435       if (PetscOptionsObject.prefix) {
436         ierr = PetscStrcpy(option,"-");CHKERRQ(ierr);
437         ierr = PetscStrcat(option,PetscOptionsObject.prefix);CHKERRQ(ierr);
438         ierr = PetscStrcat(option,PetscOptionsObject.next->option+1);CHKERRQ(ierr);
439       } else {
440         ierr = PetscStrcpy(option,PetscOptionsObject.next->option);CHKERRQ(ierr);
441       }
442 
443       switch (PetscOptionsObject.next->type) {
444         case OPTION_HEAD:
445           break;
446         case OPTION_INT_ARRAY:
447           sprintf(value,"%d",(int)((PetscInt*)PetscOptionsObject.next->data)[0]);
448           for (j=1; j<PetscOptionsObject.next->arraylength; j++) {
449             sprintf(tmp,"%d",(int)((PetscInt*)PetscOptionsObject.next->data)[j]);
450             ierr = PetscStrcat(value,",");CHKERRQ(ierr);
451             ierr = PetscStrcat(value,tmp);CHKERRQ(ierr);
452           }
453           break;
454         case OPTION_INT:
455           sprintf(value,"%d",(int) *(PetscInt*)PetscOptionsObject.next->data);
456           break;
457         case OPTION_REAL:
458           sprintf(value,"%g",(double) *(PetscReal*)PetscOptionsObject.next->data);
459           break;
460         case OPTION_REAL_ARRAY:
461           sprintf(value,"%g",(double)((PetscReal*)PetscOptionsObject.next->data)[0]);
462           for (j=1; j<PetscOptionsObject.next->arraylength; j++) {
463             sprintf(tmp,"%g",(double)((PetscReal*)PetscOptionsObject.next->data)[j]);
464             ierr = PetscStrcat(value,",");CHKERRQ(ierr);
465             ierr = PetscStrcat(value,tmp);CHKERRQ(ierr);
466           }
467           break;
468         case OPTION_LOGICAL:
469           sprintf(value,"%d",*(int*)PetscOptionsObject.next->data);
470           break;
471       case OPTION_LOGICAL_ARRAY:
472           sprintf(value,"%d",(int)((PetscTruth*)PetscOptionsObject.next->data)[0]);
473           for (j=1; j<PetscOptionsObject.next->arraylength; j++) {
474             sprintf(tmp,"%d",(int)((PetscTruth*)PetscOptionsObject.next->data)[j]);
475             ierr = PetscStrcat(value,",");CHKERRQ(ierr);
476             ierr = PetscStrcat(value,tmp);CHKERRQ(ierr);
477           }
478           break;
479         case OPTION_LIST:
480         case OPTION_ELIST:
481           ierr = PetscStrcpy(value,*(char**)PetscOptionsObject.next->data);CHKERRQ(ierr);
482           break;
483         case OPTION_STRING:
484           ierr = PetscStrcpy(value,*(char**)PetscOptionsObject.next->data);CHKERRQ(ierr);
485         case OPTION_STRING_ARRAY:
486           sprintf(value,"%s",((char**)PetscOptionsObject.next->data)[0]);
487           for (j=1; j<PetscOptionsObject.next->arraylength; j++) {
488             sprintf(tmp,"%s",((char**)PetscOptionsObject.next->data)[j]);
489             ierr = PetscStrcat(value,",");CHKERRQ(ierr);
490             ierr = PetscStrcat(value,tmp);CHKERRQ(ierr);
491           }
492           break;
493       }
494       ierr = PetscOptionsSetValue(option,value);CHKERRQ(ierr);
495     }
496     ierr   = PetscFree(PetscOptionsObject.next->text);CHKERRQ(ierr);
497     ierr   = PetscFree(PetscOptionsObject.next->option);CHKERRQ(ierr);
498     ierr   = PetscFree(PetscOptionsObject.next->man);CHKERRQ(ierr);
499     ierr   = PetscFree(PetscOptionsObject.next->data);CHKERRQ(ierr);
500     ierr   = PetscFree(PetscOptionsObject.next->edata);CHKERRQ(ierr);
501     last                    = PetscOptionsObject.next;
502     PetscOptionsObject.next = PetscOptionsObject.next->next;
503     ierr                    = PetscFree(last);CHKERRQ(ierr);
504     CHKMEMQ;
505   }
506   CHKMEMQ;
507   PetscOptionsObject.next = 0;
508   PetscFunctionReturn(0);
509 }
510 
511 #undef __FUNCT__
512 #define __FUNCT__ "PetscOptionsEnum"
513 /*@C
514    PetscOptionsEnum - Gets the enum value for a particular option in the database.
515 
516    Collective on the communicator passed in PetscOptionsBegin()
517 
518    Input Parameters:
519 +  opt - option name
520 .  text - short string that describes the option
521 .  man - manual page with additional information on option
522 .  list - array containing the list of choices, followed by the enum name, followed by the enum prefix, followed by a null
523 -  defaultv - the default (current) value
524 
525    Output Parameter:
526 +  value - the  value to return
527 -  flg - PETSC_TRUE if found, else PETSC_FALSE
528 
529    Level: beginner
530 
531    Concepts: options database
532 
533    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
534 
535           list is usually something like PCASMTypes or some other predefined list of enum names
536 
537 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
538           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth()
539           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(),
540           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
541           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
542           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
543           PetscOptionsList(), PetscOptionsEList()
544 @*/
545 PetscErrorCode PETSC_DLLEXPORT PetscOptionsEnum(const char opt[],const char text[],const char man[],const char *const*list,PetscEnum defaultv,PetscEnum *value,PetscTruth *set)
546 {
547   PetscErrorCode ierr;
548   PetscInt       ntext = 0;
549   PetscInt       tval;
550   PetscTruth     tflg;
551 
552   PetscFunctionBegin;
553   while (list[ntext++]) {
554     if (ntext > 50) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"List argument appears to be wrong or have more than 50 entries");
555   }
556   if (ntext < 3) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"List argument must have at least two entries: typename and type prefix");
557   ntext -= 3;
558   ierr = PetscOptionsEList(opt,text,man,list,ntext,list[defaultv],&tval,&tflg);CHKERRQ(ierr);
559   /* with PETSC_USE_64BIT_INDICES sizeof(PetscInt) != sizeof(PetscEnum) */
560   if (tflg) *value = (PetscEnum)tval;
561   if (set)  *set   = tflg;
562   PetscFunctionReturn(0);
563 }
564 
565 /* -------------------------------------------------------------------------------------------------------------*/
566 #undef __FUNCT__
567 #define __FUNCT__ "PetscOptionsInt"
568 /*@C
569    PetscOptionsInt - Gets the integer value for a particular option in the database.
570 
571    Collective on the communicator passed in PetscOptionsBegin()
572 
573    Input Parameters:
574 +  opt - option name
575 .  text - short string that describes the option
576 .  man - manual page with additional information on option
577 -  defaultv - the default (current) value
578 
579    Output Parameter:
580 +  value - the integer value to return
581 -  flg - PETSC_TRUE if found, else PETSC_FALSE
582 
583    Level: beginner
584 
585    Concepts: options database^has int
586 
587    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
588 
589 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
590           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth()
591           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(),
592           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
593           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
594           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
595           PetscOptionsList(), PetscOptionsEList()
596 @*/
597 PetscErrorCode PETSC_DLLEXPORT PetscOptionsInt(const char opt[],const char text[],const char man[],PetscInt defaultv,PetscInt *value,PetscTruth *set)
598 {
599   PetscErrorCode ierr;
600   PetscOptions   amsopt;
601 
602   PetscFunctionBegin;
603   if (!PetscOptionsPublishCount) {
604     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_INT,&amsopt);CHKERRQ(ierr);
605     ierr = PetscMalloc(sizeof(PetscInt),&amsopt->data);CHKERRQ(ierr);
606     *(PetscInt*)amsopt->data = defaultv;
607   }
608   ierr = PetscOptionsGetInt(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr);
609   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
610     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%d>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,man);CHKERRQ(ierr);
611   }
612   PetscFunctionReturn(0);
613 }
614 
615 #undef __FUNCT__
616 #define __FUNCT__ "PetscOptionsString"
617 /*@C
618    PetscOptionsString - Gets the string value for a particular option in the database.
619 
620    Collective on the communicator passed in PetscOptionsBegin()
621 
622    Input Parameters:
623 +  opt - option name
624 .  text - short string that describes the option
625 .  man - manual page with additional information on option
626 -  defaultv - the default (current) value
627 
628    Output Parameter:
629 +  value - the value to return
630 -  flg - PETSC_TRUE if found, else PETSC_FALSE
631 
632    Level: beginner
633 
634    Concepts: options database^has int
635 
636    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
637 
638 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
639           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth()
640           PetscOptionsInt(), PetscOptionsReal(), PetscOptionsTruth(),
641           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
642           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
643           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
644           PetscOptionsList(), PetscOptionsEList()
645 @*/
646 PetscErrorCode PETSC_DLLEXPORT PetscOptionsString(const char opt[],const char text[],const char man[],const char defaultv[],char value[],size_t len,PetscTruth *set)
647 {
648   PetscErrorCode ierr;
649   PetscOptions   amsopt;
650 
651   PetscFunctionBegin;
652   if (!PetscOptionsPublishCount) {
653     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_STRING,&amsopt);CHKERRQ(ierr);
654     ierr = PetscMalloc(sizeof(char*),&amsopt->data);CHKERRQ(ierr);
655     *(const char**)amsopt->data = defaultv;
656   }
657   ierr = PetscOptionsGetString(PetscOptionsObject.prefix,opt,value,len,set);CHKERRQ(ierr);
658   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
659     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%s>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,man);CHKERRQ(ierr);
660   }
661   PetscFunctionReturn(0);
662 }
663 
664 #undef __FUNCT__
665 #define __FUNCT__ "PetscOptionsReal"
666 /*@C
667    PetscOptionsReal - Gets the PetscReal value for a particular option in the database.
668 
669    Collective on the communicator passed in PetscOptionsBegin()
670 
671    Input Parameters:
672 +  opt - option name
673 .  text - short string that describes the option
674 .  man - manual page with additional information on option
675 -  defaultv - the default (current) value
676 
677    Output Parameter:
678 +  value - the value to return
679 -  flg - PETSC_TRUE if found, else PETSC_FALSE
680 
681    Level: beginner
682 
683    Concepts: options database^has int
684 
685    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
686 
687 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
688           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth()
689           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(),
690           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
691           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
692           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
693           PetscOptionsList(), PetscOptionsEList()
694 @*/
695 PetscErrorCode PETSC_DLLEXPORT PetscOptionsReal(const char opt[],const char text[],const char man[],PetscReal defaultv,PetscReal *value,PetscTruth *set)
696 {
697   PetscErrorCode ierr;
698   PetscOptions   amsopt;
699 
700   PetscFunctionBegin;
701   if (!PetscOptionsPublishCount) {
702     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_REAL,&amsopt);CHKERRQ(ierr);
703     ierr = PetscMalloc(sizeof(PetscReal),&amsopt->data);CHKERRQ(ierr);
704     *(PetscReal*)amsopt->data = defaultv;
705   }
706   ierr = PetscOptionsGetReal(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr);
707   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
708     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%G>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,man);CHKERRQ(ierr);
709   }
710   PetscFunctionReturn(0);
711 }
712 
713 #undef __FUNCT__
714 #define __FUNCT__ "PetscOptionsScalar"
715 /*@C
716    PetscOptionsScalar - Gets the scalar value for a particular option in the database.
717 
718    Collective on the communicator passed in PetscOptionsBegin()
719 
720    Input Parameters:
721 +  opt - option name
722 .  text - short string that describes the option
723 .  man - manual page with additional information on option
724 -  defaultv - the default (current) value
725 
726    Output Parameter:
727 +  value - the value to return
728 -  flg - PETSC_TRUE if found, else PETSC_FALSE
729 
730    Level: beginner
731 
732    Concepts: options database^has int
733 
734    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
735 
736 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
737           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth()
738           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(),
739           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
740           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
741           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
742           PetscOptionsList(), PetscOptionsEList()
743 @*/
744 PetscErrorCode PETSC_DLLEXPORT PetscOptionsScalar(const char opt[],const char text[],const char man[],PetscScalar defaultv,PetscScalar *value,PetscTruth *set)
745 {
746   PetscErrorCode ierr;
747 
748   PetscFunctionBegin;
749 #if !defined(PETSC_USE_COMPLEX)
750   ierr = PetscOptionsReal(opt,text,man,defaultv,value,set);CHKERRQ(ierr);
751 #else
752   ierr = PetscOptionsGetScalar(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr);
753 #endif
754   PetscFunctionReturn(0);
755 }
756 
757 #undef __FUNCT__
758 #define __FUNCT__ "PetscOptionsName"
759 /*@C
760    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
761                       its value is set to false.
762 
763    Collective on the communicator passed in PetscOptionsBegin()
764 
765    Input Parameters:
766 +  opt - option name
767 .  text - short string that describes the option
768 -  man - manual page with additional information on option
769 
770    Output Parameter:
771 .  flg - PETSC_TRUE if found, else PETSC_FALSE
772 
773    Level: beginner
774 
775    Concepts: options database^has int
776 
777    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
778 
779 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
780           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth()
781           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(),
782           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
783           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
784           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
785           PetscOptionsList(), PetscOptionsEList()
786 @*/
787 PetscErrorCode PETSC_DLLEXPORT PetscOptionsName(const char opt[],const char text[],const char man[],PetscTruth *flg)
788 {
789   PetscErrorCode ierr;
790   PetscOptions   amsopt;
791 
792   PetscFunctionBegin;
793   if (!PetscOptionsPublishCount) {
794     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL,&amsopt);CHKERRQ(ierr);
795     ierr = PetscMalloc(sizeof(PetscTruth),&amsopt->data);CHKERRQ(ierr);
796     *(PetscTruth*)amsopt->data = PETSC_FALSE;
797   }
798   ierr = PetscOptionsHasName(PetscOptionsObject.prefix,opt,flg);CHKERRQ(ierr);
799   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
800     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr);
801   }
802   PetscFunctionReturn(0);
803 }
804 
805 #undef __FUNCT__
806 #define __FUNCT__ "PetscOptionsList"
807 /*@C
808      PetscOptionsList - Puts a list of option values that a single one may be selected from
809 
810    Collective on the communicator passed in PetscOptionsBegin()
811 
812    Input Parameters:
813 +  opt - option name
814 .  text - short string that describes the option
815 .  man - manual page with additional information on option
816 .  list - the possible choices
817 .  defaultv - the default (current) value
818 -  len - the length of the character array value
819 
820    Output Parameter:
821 +  value - the value to return
822 -  set - PETSC_TRUE if found, else PETSC_FALSE
823 
824    Level: intermediate
825 
826    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
827 
828    See PetscOptionsEList() for when the choices are given in a string array
829 
830    To get a listing of all currently specified options,
831     see PetscOptionsPrint() or PetscOptionsGetAll()
832 
833    Concepts: options database^list
834 
835 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
836            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
837           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
838           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
839           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
840           PetscOptionsList(), PetscOptionsEList()
841 @*/
842 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)
843 {
844   PetscErrorCode ierr;
845   PetscOptions   amsopt;
846 
847   PetscFunctionBegin;
848   if (!PetscOptionsPublishCount) {
849     ierr = PetscOptionsCreate_Private(opt,ltext,man,OPTION_LIST,&amsopt);CHKERRQ(ierr);
850     ierr = PetscMalloc(sizeof(char*),&amsopt->data);CHKERRQ(ierr);
851     *(const char**)amsopt->data = defaultv;
852     amsopt->flist = list;
853   }
854   ierr = PetscOptionsGetString(PetscOptionsObject.prefix,opt,value,len,set);CHKERRQ(ierr);
855   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
856     ierr = PetscFListPrintTypes(PetscOptionsObject.comm,stdout,PetscOptionsObject.prefix,opt,ltext,man,list,defaultv);CHKERRQ(ierr);CHKERRQ(ierr);
857   }
858   PetscFunctionReturn(0);
859 }
860 
861 #undef __FUNCT__
862 #define __FUNCT__ "PetscOptionsEList"
863 /*@C
864      PetscOptionsEList - Puts a list of option values that a single one may be selected from
865 
866    Collective on the communicator passed in PetscOptionsBegin()
867 
868    Input Parameters:
869 +  opt - option name
870 .  ltext - short string that describes the option
871 .  man - manual page with additional information on option
872 .  list - the possible choices
873 .  ntext - number of choices
874 -  defaultv - the default (current) value
875 
876    Output Parameter:
877 +  value - the index of the value to return
878 -  set - PETSC_TRUE if found, else PETSC_FALSE
879 
880    Level: intermediate
881 
882    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
883 
884    See PetscOptionsList() for when the choices are given in a PetscFList()
885 
886    Concepts: options database^list
887 
888 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
889            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
890           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
891           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
892           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
893           PetscOptionsList(), PetscOptionsEList()
894 @*/
895 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)
896 {
897   PetscErrorCode ierr;
898   PetscInt       i;
899   PetscOptions   amsopt;
900 
901   PetscFunctionBegin;
902   if (!PetscOptionsPublishCount) {
903     ierr = PetscOptionsCreate_Private(opt,ltext,man,OPTION_LIST,&amsopt);CHKERRQ(ierr);
904     ierr = PetscMalloc(sizeof(char*),&amsopt->data);CHKERRQ(ierr);
905     *(const char**)amsopt->data = defaultv;
906     amsopt->list  = list;
907     amsopt->nlist = ntext;
908   }
909   ierr = PetscOptionsGetEList(PetscOptionsObject.prefix,opt,list,ntext,value,set);CHKERRQ(ierr);
910   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
911     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%s> (choose one of)",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv);CHKERRQ(ierr);
912     for (i=0; i<ntext; i++){
913       ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," %s",list[i]);CHKERRQ(ierr);
914     }
915     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"\n");CHKERRQ(ierr);
916   }
917   PetscFunctionReturn(0);
918 }
919 
920 #undef __FUNCT__
921 #define __FUNCT__ "PetscOptionsTruthGroupBegin"
922 /*@C
923      PetscOptionsTruthGroupBegin - First in a series of logical queries on the options database for
924        which only a single value can be true.
925 
926    Collective on the communicator passed in PetscOptionsBegin()
927 
928    Input Parameters:
929 +  opt - option name
930 .  text - short string that describes the option
931 -  man - manual page with additional information on option
932 
933    Output Parameter:
934 .  flg - whether that option was set or not
935 
936    Level: intermediate
937 
938    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
939 
940    Must be followed by 0 or more PetscOptionsTruthGroup()s and PetscOptionsTruthGroupEnd()
941 
942     Concepts: options database^logical group
943 
944 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
945            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
946           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
947           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
948           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
949           PetscOptionsList(), PetscOptionsEList()
950 @*/
951 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroupBegin(const char opt[],const char text[],const char man[],PetscTruth *flg)
952 {
953   PetscErrorCode ierr;
954   PetscOptions   amsopt;
955 
956   PetscFunctionBegin;
957   if (!PetscOptionsPublishCount) {
958     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL,&amsopt);CHKERRQ(ierr);
959     ierr = PetscMalloc(sizeof(PetscTruth),&amsopt->data);CHKERRQ(ierr);
960     *(PetscTruth*)amsopt->data = PETSC_TRUE;
961   }
962   ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,PETSC_NULL);CHKERRQ(ierr);
963   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
964     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  Pick at most one of -------------\n");CHKERRQ(ierr);
965     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"    -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr);
966   }
967   PetscFunctionReturn(0);
968 }
969 
970 #undef __FUNCT__
971 #define __FUNCT__ "PetscOptionsTruthGroup"
972 /*@C
973      PetscOptionsTruthGroup - One in a series of logical queries on the options database for
974        which only a single value can be true.
975 
976    Collective on the communicator passed in PetscOptionsBegin()
977 
978    Input Parameters:
979 +  opt - option name
980 .  text - short string that describes the option
981 -  man - manual page with additional information on option
982 
983    Output Parameter:
984 .  flg - PETSC_TRUE if found, else PETSC_FALSE
985 
986    Level: intermediate
987 
988    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
989 
990    Must follow a PetscOptionsTruthGroupBegin() and preceded a PetscOptionsTruthGroupEnd()
991 
992     Concepts: options database^logical group
993 
994 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
995            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
996           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
997           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
998           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
999           PetscOptionsList(), PetscOptionsEList()
1000 @*/
1001 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroup(const char opt[],const char text[],const char man[],PetscTruth *flg)
1002 {
1003   PetscErrorCode ierr;
1004   PetscOptions   amsopt;
1005 
1006   PetscFunctionBegin;
1007   if (!PetscOptionsPublishCount) {
1008     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL,&amsopt);CHKERRQ(ierr);
1009     ierr = PetscMalloc(sizeof(PetscTruth),&amsopt->data);CHKERRQ(ierr);
1010     *(PetscTruth*)amsopt->data = PETSC_FALSE;
1011   }
1012   *flg = PETSC_FALSE;
1013   ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,PETSC_NULL);CHKERRQ(ierr);
1014   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
1015     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"    -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr);
1016   }
1017   PetscFunctionReturn(0);
1018 }
1019 
1020 #undef __FUNCT__
1021 #define __FUNCT__ "PetscOptionsTruthGroupEnd"
1022 /*@C
1023      PetscOptionsTruthGroupEnd - Last in a series of logical queries on the options database for
1024        which only a single value can be true.
1025 
1026    Collective on the communicator passed in PetscOptionsBegin()
1027 
1028    Input Parameters:
1029 +  opt - option name
1030 .  text - short string that describes the option
1031 -  man - manual page with additional information on option
1032 
1033    Output Parameter:
1034 .  flg - PETSC_TRUE if found, else PETSC_FALSE
1035 
1036    Level: intermediate
1037 
1038    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1039 
1040    Must follow a PetscOptionsTruthGroupBegin()
1041 
1042     Concepts: options database^logical group
1043 
1044 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1045            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
1046           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1047           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1048           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
1049           PetscOptionsList(), PetscOptionsEList()
1050 @*/
1051 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroupEnd(const char opt[],const char text[],const char man[],PetscTruth *flg)
1052 {
1053   PetscErrorCode ierr;
1054   PetscOptions   amsopt;
1055 
1056   PetscFunctionBegin;
1057   if (!PetscOptionsPublishCount) {
1058     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL,&amsopt);CHKERRQ(ierr);
1059     ierr = PetscMalloc(sizeof(PetscTruth),&amsopt->data);CHKERRQ(ierr);
1060     *(PetscTruth*)amsopt->data = PETSC_FALSE;
1061   }
1062   *flg = PETSC_FALSE;
1063   ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,PETSC_NULL);CHKERRQ(ierr);
1064   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
1065     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"    -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr);
1066   }
1067   PetscFunctionReturn(0);
1068 }
1069 
1070 #undef __FUNCT__
1071 #define __FUNCT__ "PetscOptionsTruth"
1072 /*@C
1073    PetscOptionsTruth - Determines if a particular option is in the database with a true or false
1074 
1075    Collective on the communicator passed in PetscOptionsBegin()
1076 
1077    Input Parameters:
1078 +  opt - option name
1079 .  text - short string that describes the option
1080 -  man - manual page with additional information on option
1081 
1082    Output Parameter:
1083 .  flg - PETSC_TRUE or PETSC_FALSE
1084 .  set - PETSC_TRUE if found, else PETSC_FALSE
1085 
1086    Level: beginner
1087 
1088    Concepts: options database^logical
1089 
1090    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1091 
1092 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
1093           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth()
1094           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(),
1095           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1096           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1097           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
1098           PetscOptionsList(), PetscOptionsEList()
1099 @*/
1100 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruth(const char opt[],const char text[],const char man[],PetscTruth deflt,PetscTruth *flg,PetscTruth *set)
1101 {
1102   PetscErrorCode ierr;
1103   PetscTruth     iset;
1104   PetscOptions   amsopt;
1105 
1106   PetscFunctionBegin;
1107   if (!PetscOptionsPublishCount) {
1108     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL,&amsopt);CHKERRQ(ierr);
1109     ierr = PetscMalloc(sizeof(PetscTruth),&amsopt->data);CHKERRQ(ierr);
1110     *(PetscTruth*)amsopt->data = deflt;
1111   }
1112   ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,&iset);CHKERRQ(ierr);
1113   if (!iset) {
1114     if (flg) *flg = deflt;
1115   }
1116   if (set) *set = iset;
1117   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
1118     const char *v = PetscTruths[deflt];
1119     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s: <%s> %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,v,text,man);CHKERRQ(ierr);
1120   }
1121   PetscFunctionReturn(0);
1122 }
1123 
1124 #undef __FUNCT__
1125 #define __FUNCT__ "PetscOptionsRealArray"
1126 /*@C
1127    PetscOptionsRealArray - Gets an array of double values for a particular
1128    option in the database. The values must be separated with commas with
1129    no intervening spaces.
1130 
1131    Collective on the communicator passed in PetscOptionsBegin()
1132 
1133    Input Parameters:
1134 +  opt - the option one is seeking
1135 .  text - short string describing option
1136 .  man - manual page for option
1137 -  nmax - maximum number of values
1138 
1139    Output Parameter:
1140 +  value - location to copy values
1141 .  nmax - actual number of values found
1142 -  set - PETSC_TRUE if found, else PETSC_FALSE
1143 
1144    Level: beginner
1145 
1146    Notes:
1147    The user should pass in an array of doubles
1148 
1149    Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1150 
1151    Concepts: options database^array of strings
1152 
1153 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1154            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
1155           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1156           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1157           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
1158           PetscOptionsList(), PetscOptionsEList()
1159 @*/
1160 PetscErrorCode PETSC_DLLEXPORT PetscOptionsRealArray(const char opt[],const char text[],const char man[],PetscReal value[],PetscInt *n,PetscTruth *set)
1161 {
1162   PetscErrorCode ierr;
1163   PetscInt       i;
1164   PetscOptions   amsopt;
1165 
1166   PetscFunctionBegin;
1167   if (!PetscOptionsPublishCount) {
1168     PetscReal *vals;
1169 
1170     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_REAL_ARRAY,&amsopt);CHKERRQ(ierr);
1171     ierr = PetscMalloc((*n)*sizeof(PetscReal),&amsopt->data);CHKERRQ(ierr);
1172     vals = (PetscReal*)amsopt->data;
1173     for (i=0; i<*n; i++) vals[i] = value[i];
1174     amsopt->arraylength = *n;
1175   }
1176   ierr = PetscOptionsGetRealArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr);
1177   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
1178     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%G",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr);
1179     for (i=1; i<*n; i++) {
1180       ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%G",value[i]);CHKERRQ(ierr);
1181     }
1182     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr);
1183   }
1184   PetscFunctionReturn(0);
1185 }
1186 
1187 
1188 #undef __FUNCT__
1189 #define __FUNCT__ "PetscOptionsIntArray"
1190 /*@C
1191    PetscOptionsIntArray - Gets an array of integers for a particular
1192    option in the database. The values must be separated with commas with
1193    no intervening spaces.
1194 
1195    Collective on the communicator passed in PetscOptionsBegin()
1196 
1197    Input Parameters:
1198 +  opt - the option one is seeking
1199 .  text - short string describing option
1200 .  man - manual page for option
1201 -  n - maximum number of values
1202 
1203    Output Parameter:
1204 +  value - location to copy values
1205 .  n - actual number of values found
1206 -  set - PETSC_TRUE if found, else PETSC_FALSE
1207 
1208    Level: beginner
1209 
1210    Notes:
1211    The user should pass in an array of integers
1212 
1213    Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1214 
1215    Concepts: options database^array of strings
1216 
1217 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1218            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
1219           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1220           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1221           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
1222           PetscOptionsList(), PetscOptionsEList(), PetscOptionsRealArray()
1223 @*/
1224 PetscErrorCode PETSC_DLLEXPORT PetscOptionsIntArray(const char opt[],const char text[],const char man[],PetscInt value[],PetscInt *n,PetscTruth *set)
1225 {
1226   PetscErrorCode ierr;
1227   PetscInt       i;
1228   PetscOptions   amsopt;
1229 
1230   PetscFunctionBegin;
1231   if (!PetscOptionsPublishCount) {
1232     PetscInt *vals;
1233 
1234     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_INT_ARRAY,&amsopt);CHKERRQ(ierr);
1235     ierr = PetscMalloc((*n)*sizeof(PetscInt),&amsopt->data);CHKERRQ(ierr);
1236     vals = (PetscInt*)amsopt->data;
1237     for (i=0; i<*n; i++) vals[i] = value[i];
1238     amsopt->arraylength = *n;
1239   }
1240   ierr = PetscOptionsGetIntArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr);
1241   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
1242     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%d",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr);
1243     for (i=1; i<*n; i++) {
1244       ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%d",value[i]);CHKERRQ(ierr);
1245     }
1246     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr);
1247   }
1248   PetscFunctionReturn(0);
1249 }
1250 
1251 #undef __FUNCT__
1252 #define __FUNCT__ "PetscOptionsStringArray"
1253 /*@C
1254    PetscOptionsStringArray - Gets an array of string values for a particular
1255    option in the database. The values must be separated with commas with
1256    no intervening spaces.
1257 
1258    Collective on the communicator passed in PetscOptionsBegin()
1259 
1260    Input Parameters:
1261 +  opt - the option one is seeking
1262 .  text - short string describing option
1263 .  man - manual page for option
1264 -  nmax - maximum number of strings
1265 
1266    Output Parameter:
1267 +  value - location to copy strings
1268 .  nmax - actual number of strings found
1269 -  set - PETSC_TRUE if found, else PETSC_FALSE
1270 
1271    Level: beginner
1272 
1273    Notes:
1274    The user should pass in an array of pointers to char, to hold all the
1275    strings returned by this function.
1276 
1277    The user is responsible for deallocating the strings that are
1278    returned. The Fortran interface for this routine is not supported.
1279 
1280    Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1281 
1282    Concepts: options database^array of strings
1283 
1284 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1285            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
1286           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1287           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1288           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
1289           PetscOptionsList(), PetscOptionsEList()
1290 @*/
1291 PetscErrorCode PETSC_DLLEXPORT PetscOptionsStringArray(const char opt[],const char text[],const char man[],char *value[],PetscInt *nmax,PetscTruth *set)
1292 {
1293   PetscErrorCode ierr;
1294   PetscOptions   amsopt;
1295 
1296   PetscFunctionBegin;
1297   if (!PetscOptionsPublishCount) {
1298     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_STRING_ARRAY,&amsopt);CHKERRQ(ierr);
1299     ierr = PetscMalloc((*nmax)*sizeof(char*),&amsopt->data);CHKERRQ(ierr);
1300     amsopt->arraylength = *nmax;
1301   }
1302   ierr = PetscOptionsGetStringArray(PetscOptionsObject.prefix,opt,value,nmax,set);CHKERRQ(ierr);
1303   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
1304     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <string1,string2,...>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr);
1305   }
1306   PetscFunctionReturn(0);
1307 }
1308 
1309 #undef __FUNCT__
1310 #define __FUNCT__ "PetscOptionsTruthArray"
1311 /*@C
1312    PetscOptionsTruthArray - Gets an array of logical values (true or false) for a particular
1313    option in the database. The values must be separated with commas with
1314    no intervening spaces.
1315 
1316    Collective on the communicator passed in PetscOptionsBegin()
1317 
1318    Input Parameters:
1319 +  opt - the option one is seeking
1320 .  text - short string describing option
1321 .  man - manual page for option
1322 -  nmax - maximum number of values
1323 
1324    Output Parameter:
1325 +  value - location to copy values
1326 .  nmax - actual number of values found
1327 -  set - PETSC_TRUE if found, else PETSC_FALSE
1328 
1329    Level: beginner
1330 
1331    Notes:
1332    The user should pass in an array of doubles
1333 
1334    Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1335 
1336    Concepts: options database^array of strings
1337 
1338 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1339            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
1340           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1341           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1342           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
1343           PetscOptionsList(), PetscOptionsEList()
1344 @*/
1345 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthArray(const char opt[],const char text[],const char man[],PetscTruth value[],PetscInt *n,PetscTruth *set)
1346 {
1347   PetscErrorCode ierr;
1348   PetscInt       i;
1349   PetscOptions   amsopt;
1350 
1351   PetscFunctionBegin;
1352   if (!PetscOptionsPublishCount) {
1353     PetscTruth *vals;
1354 
1355     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_LOGICAL_ARRAY,&amsopt);CHKERRQ(ierr);
1356     ierr = PetscMalloc((*n)*sizeof(PetscTruth),&amsopt->data);CHKERRQ(ierr);
1357     vals = (PetscTruth*)amsopt->data;
1358     for (i=0; i<*n; i++) vals[i] = value[i];
1359     amsopt->arraylength = *n;
1360   }
1361   ierr = PetscOptionsGetTruthArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr);
1362   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
1363     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%d",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr);
1364     for (i=1; i<*n; i++) {
1365       ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%d",value[i]);CHKERRQ(ierr);
1366     }
1367     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr);
1368   }
1369   PetscFunctionReturn(0);
1370 }
1371 
1372 
1373 #undef __FUNCT__
1374 #define __FUNCT__ "PetscOptionsHead"
1375 /*@C
1376      PetscOptionsHead - Puts a heading before listing any more published options. Used, for example,
1377             in KSPSetFromOptions_GMRES().
1378 
1379    Collective on the communicator passed in PetscOptionsBegin()
1380 
1381    Input Parameter:
1382 .   head - the heading text
1383 
1384 
1385    Level: intermediate
1386 
1387    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1388 
1389           Can be followed by a call to PetscOptionsTail() in the same function.
1390 
1391    Concepts: options database^subheading
1392 
1393 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1394            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
1395           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1396           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1397           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
1398           PetscOptionsList(), PetscOptionsEList()
1399 @*/
1400 PetscErrorCode PETSC_DLLEXPORT PetscOptionsHead(const char head[])
1401 {
1402   PetscErrorCode ierr;
1403 
1404   PetscFunctionBegin;
1405   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
1406     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  %s\n",head);CHKERRQ(ierr);
1407   }
1408   PetscFunctionReturn(0);
1409 }
1410 
1411 
1412 
1413 
1414 
1415 
1416