xref: /petsc/src/sys/objects/aoptions.c (revision 89583661dbdda284bc23265230c2f308532cda40)
1 
2 
3 /*
4    Implements the higher-level options database querying methods. These are self-documenting and can attach at runtime to
5    GUI code to display the options and get values from the users.
6 
7 */
8 
9 #include <petsc/private/petscimpl.h>        /*I  "petscsys.h"   I*/
10 #include <petscviewer.h>
11 
12 #define ManSection(str) ((str) ? (str) : "None")
13 
14 /*
15     Keep a linked list of options that have been posted and we are waiting for
16    user selection. See the manual page for PetscOptionsBegin()
17 
18     Eventually we'll attach this beast to a MPI_Comm
19 */
20 
21 
22 /*
23     Handles setting up the data structure in a call to PetscOptionsBegin()
24 */
25 PetscErrorCode PetscOptionsBegin_Private(PetscOptionItems *PetscOptionsObject,MPI_Comm comm,const char prefix[],const char title[],const char mansec[])
26 {
27   PetscErrorCode ierr;
28 
29   PetscFunctionBegin;
30   if (!PetscOptionsObject->alreadyprinted) {
31     if (!PetscOptionsHelpPrintedSingleton) {
32       ierr = PetscOptionsHelpPrintedCreate(&PetscOptionsHelpPrintedSingleton);CHKERRQ(ierr);
33     }
34     ierr = PetscOptionsHelpPrintedCheck(PetscOptionsHelpPrintedSingleton,prefix,title,&PetscOptionsObject->alreadyprinted);CHKERRQ(ierr);
35   }
36   PetscOptionsObject->next          = 0;
37   PetscOptionsObject->comm          = comm;
38   PetscOptionsObject->changedmethod = PETSC_FALSE;
39 
40   ierr = PetscStrallocpy(prefix,&PetscOptionsObject->prefix);CHKERRQ(ierr);
41   ierr = PetscStrallocpy(title,&PetscOptionsObject->title);CHKERRQ(ierr);
42 
43   ierr = PetscOptionsHasHelp(PetscOptionsObject->options,&PetscOptionsObject->printhelp);CHKERRQ(ierr);
44   if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1) {
45     if (!PetscOptionsObject->alreadyprinted) {
46       ierr = (*PetscHelpPrintf)(comm,"%s -------------------------------------------------\n",title);CHKERRQ(ierr);
47     }
48   }
49   PetscFunctionReturn(0);
50 }
51 
52 /*
53     Handles setting up the data structure in a call to PetscObjectOptionsBegin()
54 */
55 PetscErrorCode PetscObjectOptionsBegin_Private(PetscOptionItems *PetscOptionsObject,PetscObject obj)
56 {
57   PetscErrorCode ierr;
58   char           title[256];
59   PetscBool      flg;
60 
61   PetscFunctionBegin;
62   PetscValidHeader(obj,1);
63   PetscOptionsObject->object         = obj;
64   PetscOptionsObject->alreadyprinted = obj->optionsprinted;
65 
66   ierr = PetscStrcmp(obj->description,obj->class_name,&flg);CHKERRQ(ierr);
67   if (flg) {
68     ierr = PetscSNPrintf(title,sizeof(title),"%s options",obj->class_name);CHKERRQ(ierr);
69   } else {
70     ierr = PetscSNPrintf(title,sizeof(title),"%s (%s) options",obj->description,obj->class_name);CHKERRQ(ierr);
71   }
72   ierr = PetscOptionsBegin_Private(PetscOptionsObject,obj->comm,obj->prefix,title,obj->mansec);CHKERRQ(ierr);
73   PetscFunctionReturn(0);
74 }
75 
76 /*
77      Handles adding another option to the list of options within this particular PetscOptionsBegin() PetscOptionsEnd()
78 */
79 static int PetscOptionItemCreate_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],PetscOptionType t,PetscOptionItem *amsopt)
80 {
81   int             ierr;
82   PetscOptionItem next;
83   PetscBool       valid;
84 
85   PetscFunctionBegin;
86   ierr = PetscOptionsValidKey(opt,&valid);CHKERRQ(ierr);
87   if (!valid) SETERRQ1(PETSC_COMM_WORLD,PETSC_ERR_ARG_INCOMP,"The option '%s' is not a valid key",opt);
88 
89   ierr            = PetscNew(amsopt);CHKERRQ(ierr);
90   (*amsopt)->next = 0;
91   (*amsopt)->set  = PETSC_FALSE;
92   (*amsopt)->type = t;
93   (*amsopt)->data = 0;
94 
95   ierr = PetscStrallocpy(text,&(*amsopt)->text);CHKERRQ(ierr);
96   ierr = PetscStrallocpy(opt,&(*amsopt)->option);CHKERRQ(ierr);
97   ierr = PetscStrallocpy(man,&(*amsopt)->man);CHKERRQ(ierr);
98 
99   if (!PetscOptionsObject->next) PetscOptionsObject->next = *amsopt;
100   else {
101     next = PetscOptionsObject->next;
102     while (next->next) next = next->next;
103     next->next = *amsopt;
104   }
105   PetscFunctionReturn(0);
106 }
107 
108 /*
109     PetscScanString -  Gets user input via stdin from process and broadcasts to all processes
110 
111     Collective
112 
113    Input Parameters:
114 +     commm - communicator for the broadcast, must be PETSC_COMM_WORLD
115 .     n - length of the string, must be the same on all processes
116 -     str - location to store input
117 
118     Bugs:
119 .   Assumes process 0 of the given communicator has access to stdin
120 
121 */
122 static PetscErrorCode PetscScanString(MPI_Comm comm,size_t n,char str[])
123 {
124   size_t         i;
125   char           c;
126   PetscMPIInt    rank,nm;
127   PetscErrorCode ierr;
128 
129   PetscFunctionBegin;
130   ierr = MPI_Comm_rank(comm,&rank);CHKERRQ(ierr);
131   if (!rank) {
132     c = (char) getchar();
133     i = 0;
134     while (c != '\n' && i < n-1) {
135       str[i++] = c;
136       c = (char)getchar();
137     }
138     str[i] = 0;
139   }
140   ierr = PetscMPIIntCast(n,&nm);CHKERRQ(ierr);
141   ierr = MPI_Bcast(str,nm,MPI_CHAR,0,comm);CHKERRQ(ierr);
142   PetscFunctionReturn(0);
143 }
144 
145 /*
146     This is needed because certain strings may be freed by SAWs, hence we cannot use PetscStrallocpy()
147 */
148 static PetscErrorCode  PetscStrdup(const char s[],char *t[])
149 {
150   PetscErrorCode ierr;
151   size_t         len;
152   char           *tmp = 0;
153 
154   PetscFunctionBegin;
155   if (s) {
156     ierr = PetscStrlen(s,&len);CHKERRQ(ierr);
157     tmp = (char*) malloc((len+1)*sizeof(char));
158     if (!tmp) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_MEM,"No memory to duplicate string");
159     ierr = PetscStrcpy(tmp,s);CHKERRQ(ierr);
160   }
161   *t = tmp;
162   PetscFunctionReturn(0);
163 }
164 
165 
166 /*
167     PetscOptionsGetFromTextInput - Presents all the PETSc Options processed by the program so the user may change them at runtime
168 
169     Notes:
170     this isn't really practical, it is just to demonstrate the principle
171 
172     A carriage return indicates no change from the default; but this like -ksp_monitor <stdout>  the default is actually not stdout the default
173     is to do nothing so to get it to use stdout you need to type stdout. This is kind of bug?
174 
175     Bugs:
176 +    All processes must traverse through the exact same set of option queries due to the call to PetscScanString()
177 .    Internal strings have arbitrary length and string copies are not checked that they fit into string space
178 -    Only works for PetscInt == int, PetscReal == double etc
179 
180     Developer Notes:
181     Normally the GUI that presents the options the user and retrieves the values would be running in a different
182      address space and communicating with the PETSc program
183 
184 */
185 PetscErrorCode PetscOptionsGetFromTextInput(PetscOptionItems *PetscOptionsObject)
186 {
187   PetscErrorCode  ierr;
188   PetscOptionItem next = PetscOptionsObject->next;
189   char            str[512];
190   PetscBool       bid;
191   PetscReal       ir,*valr;
192   PetscInt        *vald;
193   size_t          i;
194 
195   PetscFunctionBegin;
196   ierr = (*PetscPrintf)(PETSC_COMM_WORLD,"%s -------------------------------------------------\n",PetscOptionsObject->title);CHKERRQ(ierr);
197   while (next) {
198     switch (next->type) {
199     case OPTION_HEAD:
200       break;
201     case OPTION_INT_ARRAY:
202       ierr = PetscPrintf(PETSC_COMM_WORLD,"-%s%s <",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",next->option+1);CHKERRQ(ierr);
203       vald = (PetscInt*) next->data;
204       for (i=0; i<next->arraylength; i++) {
205         ierr = PetscPrintf(PETSC_COMM_WORLD,"%d",vald[i]);CHKERRQ(ierr);
206         if (i < next->arraylength-1) {
207           ierr = PetscPrintf(PETSC_COMM_WORLD,",");CHKERRQ(ierr);
208         }
209       }
210       ierr = PetscPrintf(PETSC_COMM_WORLD,">: %s (%s) ",next->text,next->man);CHKERRQ(ierr);
211       ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr);
212       if (str[0]) {
213         PetscToken token;
214         PetscInt   n=0,nmax = next->arraylength,*dvalue = (PetscInt*)next->data,start,end;
215         size_t     len;
216         char       *value;
217         PetscBool  foundrange;
218 
219         next->set = PETSC_TRUE;
220         value     = str;
221         ierr      = PetscTokenCreate(value,',',&token);CHKERRQ(ierr);
222         ierr      = PetscTokenFind(token,&value);CHKERRQ(ierr);
223         while (n < nmax) {
224           if (!value) break;
225 
226           /* look for form  d-D where d and D are integers */
227           foundrange = PETSC_FALSE;
228           ierr       = PetscStrlen(value,&len);CHKERRQ(ierr);
229           if (value[0] == '-') i=2;
230           else i=1;
231           for (;i<len; i++) {
232             if (value[i] == '-') {
233               if (i == len-1) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_USER,"Error in %D-th array entry %s\n",n,value);
234               value[i] = 0;
235               ierr     = PetscOptionsStringToInt(value,&start);CHKERRQ(ierr);
236               ierr     = PetscOptionsStringToInt(value+i+1,&end);CHKERRQ(ierr);
237               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);
238               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);
239               for (; start<end; start++) {
240                 *dvalue = start; dvalue++;n++;
241               }
242               foundrange = PETSC_TRUE;
243               break;
244             }
245           }
246           if (!foundrange) {
247             ierr = PetscOptionsStringToInt(value,dvalue);CHKERRQ(ierr);
248             dvalue++;
249             n++;
250           }
251           ierr = PetscTokenFind(token,&value);CHKERRQ(ierr);
252         }
253         ierr = PetscTokenDestroy(&token);CHKERRQ(ierr);
254       }
255       break;
256     case OPTION_REAL_ARRAY:
257       ierr = PetscPrintf(PETSC_COMM_WORLD,"-%s%s <",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",next->option+1);CHKERRQ(ierr);
258       valr = (PetscReal*) next->data;
259       for (i=0; i<next->arraylength; i++) {
260         ierr = PetscPrintf(PETSC_COMM_WORLD,"%g",valr[i]);CHKERRQ(ierr);
261         if (i < next->arraylength-1) {
262           ierr = PetscPrintf(PETSC_COMM_WORLD,",");CHKERRQ(ierr);
263         }
264       }
265       ierr = PetscPrintf(PETSC_COMM_WORLD,">: %s (%s) ",next->text,next->man);CHKERRQ(ierr);
266       ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr);
267       if (str[0]) {
268         PetscToken token;
269         PetscInt   n = 0,nmax = next->arraylength;
270         PetscReal  *dvalue = (PetscReal*)next->data;
271         char       *value;
272 
273         next->set = PETSC_TRUE;
274         value     = str;
275         ierr      = PetscTokenCreate(value,',',&token);CHKERRQ(ierr);
276         ierr      = PetscTokenFind(token,&value);CHKERRQ(ierr);
277         while (n < nmax) {
278           if (!value) break;
279           ierr = PetscOptionsStringToReal(value,dvalue);CHKERRQ(ierr);
280           dvalue++;
281           n++;
282           ierr = PetscTokenFind(token,&value);CHKERRQ(ierr);
283         }
284         ierr = PetscTokenDestroy(&token);CHKERRQ(ierr);
285       }
286       break;
287     case OPTION_INT:
288       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);
289       ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr);
290       if (str[0]) {
291 #if defined(PETSC_SIZEOF_LONG_LONG)
292         long long lid;
293         sscanf(str,"%lld",&lid);
294         if (lid > PETSC_MAX_INT || lid < PETSC_MIN_INT) SETERRQ3(PETSC_COMM_WORLD,PETSC_ERR_ARG_OUTOFRANGE,"Argument: -%s%s %lld",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",next->option+1,lid);
295 #else
296         long  lid;
297         sscanf(str,"%ld",&lid);
298         if (lid > PETSC_MAX_INT || lid < PETSC_MIN_INT) SETERRQ3(PETSC_COMM_WORLD,PETSC_ERR_ARG_OUTOFRANGE,"Argument: -%s%s %ld",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",next->option+1,lid);
299 #endif
300 
301         next->set = PETSC_TRUE;
302         *((PetscInt*)next->data) = (PetscInt)lid;
303       }
304       break;
305     case OPTION_REAL:
306       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);
307       ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr);
308       if (str[0]) {
309 #if defined(PETSC_USE_REAL_SINGLE)
310         sscanf(str,"%e",&ir);
311 #elif defined(PETSC_USE_REAL___FP16)
312         float irtemp;
313         sscanf(str,"%e",&irtemp);
314         ir = irtemp;
315 #elif defined(PETSC_USE_REAL_DOUBLE)
316         sscanf(str,"%le",&ir);
317 #elif defined(PETSC_USE_REAL___FLOAT128)
318         ir = strtoflt128(str,0);
319 #else
320         SETERRQ(PETSC_COMM_SELF,PETSC_ERR_LIB,"Unknown scalar type");
321 #endif
322         next->set                 = PETSC_TRUE;
323         *((PetscReal*)next->data) = ir;
324       }
325       break;
326     case OPTION_BOOL:
327       ierr = PetscPrintf(PETSC_COMM_WORLD,"-%s%s <%s>: %s (%s) ",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",next->option+1,*(PetscBool*)next->data ? "true": "false",next->text,next->man);CHKERRQ(ierr);
328       ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr);
329       if (str[0]) {
330         ierr = PetscOptionsStringToBool(str,&bid);CHKERRQ(ierr);
331         next->set = PETSC_TRUE;
332         *((PetscBool*)next->data) = bid;
333       }
334       break;
335     case OPTION_STRING:
336       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);
337       ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr);
338       if (str[0]) {
339         next->set = PETSC_TRUE;
340         /* must use system malloc since SAWs may free this */
341         ierr = PetscStrdup(str,(char**)&next->data);CHKERRQ(ierr);
342       }
343       break;
344     case OPTION_FLIST:
345       ierr = PetscFunctionListPrintTypes(PETSC_COMM_WORLD,stdout,PetscOptionsObject->prefix,next->option,next->text,next->man,next->flist,(char*)next->data,(char*)next->data);CHKERRQ(ierr);
346       ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr);
347       if (str[0]) {
348         PetscOptionsObject->changedmethod = PETSC_TRUE;
349         next->set = PETSC_TRUE;
350         /* must use system malloc since SAWs may free this */
351         ierr = PetscStrdup(str,(char**)&next->data);CHKERRQ(ierr);
352       }
353       break;
354     default:
355       break;
356     }
357     next = next->next;
358   }
359   PetscFunctionReturn(0);
360 }
361 
362 #if defined(PETSC_HAVE_SAWS)
363 #include <petscviewersaws.h>
364 
365 static int count = 0;
366 
367 PetscErrorCode PetscOptionsSAWsDestroy(void)
368 {
369   PetscFunctionBegin;
370   PetscFunctionReturn(0);
371 }
372 
373 static const char *OptionsHeader = "<head>\n"
374                                    "<script type=\"text/javascript\" src=\"https://www.mcs.anl.gov/research/projects/saws/js/jquery-1.9.1.js\"></script>\n"
375                                    "<script type=\"text/javascript\" src=\"https://www.mcs.anl.gov/research/projects/saws/js/SAWs.js\"></script>\n"
376                                    "<script type=\"text/javascript\" src=\"js/PETSc.js\"></script>\n"
377                                    "<script>\n"
378                                       "jQuery(document).ready(function() {\n"
379                                          "PETSc.getAndDisplayDirectory(null,\"#variablesInfo\")\n"
380                                       "})\n"
381                                   "</script>\n"
382                                   "</head>\n";
383 
384 /*  Determines the size and style of the scroll region where PETSc options selectable from users are displayed */
385 static const char *OptionsBodyBottom = "<div id=\"variablesInfo\" style=\"background-color:lightblue;height:auto;max-height:500px;overflow:scroll;\"></div>\n<br>\n</body>";
386 
387 /*
388     PetscOptionsSAWsInput - Presents all the PETSc Options processed by the program so the user may change them at runtime using the SAWs
389 
390     Bugs:
391 +    All processes must traverse through the exact same set of option queries do to the call to PetscScanString()
392 .    Internal strings have arbitrary length and string copies are not checked that they fit into string space
393 -    Only works for PetscInt == int, PetscReal == double etc
394 
395 
396 */
397 PetscErrorCode PetscOptionsSAWsInput(PetscOptionItems *PetscOptionsObject)
398 {
399   PetscErrorCode  ierr;
400   PetscOptionItem next     = PetscOptionsObject->next;
401   static int      mancount = 0;
402   char            options[16];
403   PetscBool       changedmethod = PETSC_FALSE;
404   PetscBool       stopasking    = PETSC_FALSE;
405   char            manname[16],textname[16];
406   char            dir[1024];
407 
408   PetscFunctionBegin;
409   /* the next line is a bug, this will only work if all processors are here, the comm passed in is ignored!!! */
410   sprintf(options,"Options_%d",count++);
411 
412   PetscOptionsObject->pprefix = PetscOptionsObject->prefix; /* SAWs will change this, so cannot pass prefix directly */
413 
414   ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s","_title");CHKERRQ(ierr);
415   PetscStackCallSAWs(SAWs_Register,(dir,&PetscOptionsObject->title,1,SAWs_READ,SAWs_STRING));
416   ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s","prefix");CHKERRQ(ierr);
417   PetscStackCallSAWs(SAWs_Register,(dir,&PetscOptionsObject->pprefix,1,SAWs_READ,SAWs_STRING));
418   PetscStackCallSAWs(SAWs_Register,("/PETSc/Options/ChangedMethod",&changedmethod,1,SAWs_WRITE,SAWs_BOOLEAN));
419   PetscStackCallSAWs(SAWs_Register,("/PETSc/Options/StopAsking",&stopasking,1,SAWs_WRITE,SAWs_BOOLEAN));
420 
421   while (next) {
422     sprintf(manname,"_man_%d",mancount);
423     ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",manname);CHKERRQ(ierr);
424     PetscStackCallSAWs(SAWs_Register,(dir,&next->man,1,SAWs_READ,SAWs_STRING));
425     sprintf(textname,"_text_%d",mancount++);
426     ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",textname);CHKERRQ(ierr);
427     PetscStackCallSAWs(SAWs_Register,(dir,&next->text,1,SAWs_READ,SAWs_STRING));
428 
429     switch (next->type) {
430     case OPTION_HEAD:
431       break;
432     case OPTION_INT_ARRAY:
433     ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr);
434       PetscStackCallSAWs(SAWs_Register,(dir,next->data,next->arraylength,SAWs_WRITE,SAWs_INT));
435       break;
436     case OPTION_REAL_ARRAY:
437     ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr);
438       PetscStackCallSAWs(SAWs_Register,(dir,next->data,next->arraylength,SAWs_WRITE,SAWs_DOUBLE));
439       break;
440     case OPTION_INT:
441     ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr);
442       PetscStackCallSAWs(SAWs_Register,(dir,next->data,1,SAWs_WRITE,SAWs_INT));
443       break;
444     case OPTION_REAL:
445     ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr);
446       PetscStackCallSAWs(SAWs_Register,(dir,next->data,1,SAWs_WRITE,SAWs_DOUBLE));
447       break;
448     case OPTION_BOOL:
449     ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr);
450       PetscStackCallSAWs(SAWs_Register,(dir,next->data,1,SAWs_WRITE,SAWs_BOOLEAN));
451       break;
452     case OPTION_BOOL_ARRAY:
453     ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr);
454       PetscStackCallSAWs(SAWs_Register,(dir,next->data,next->arraylength,SAWs_WRITE,SAWs_BOOLEAN));
455       break;
456     case OPTION_STRING:
457     ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr);
458       PetscStackCallSAWs(SAWs_Register,(dir,&next->data,1,SAWs_WRITE,SAWs_STRING));
459       break;
460     case OPTION_STRING_ARRAY:
461     ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr);
462       PetscStackCallSAWs(SAWs_Register,(dir,next->data,next->arraylength,SAWs_WRITE,SAWs_STRING));
463       break;
464     case OPTION_FLIST:
465       {
466       PetscInt ntext;
467       ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr);
468       PetscStackCallSAWs(SAWs_Register,(dir,&next->data,1,SAWs_WRITE,SAWs_STRING));
469       ierr = PetscFunctionListGet(next->flist,(const char***)&next->edata,&ntext);CHKERRQ(ierr);
470       PetscStackCallSAWs(SAWs_Set_Legal_Variable_Values,(dir,ntext,next->edata));
471       }
472       break;
473     case OPTION_ELIST:
474       {
475       PetscInt ntext = next->nlist;
476       ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr);
477       PetscStackCallSAWs(SAWs_Register,(dir,&next->data,1,SAWs_WRITE,SAWs_STRING));
478       ierr = PetscMalloc1((ntext+1),(char***)&next->edata);CHKERRQ(ierr);
479       ierr = PetscMemcpy(next->edata,next->list,ntext*sizeof(char*));CHKERRQ(ierr);
480       PetscStackCallSAWs(SAWs_Set_Legal_Variable_Values,(dir,ntext,next->edata));
481       }
482       break;
483     default:
484       break;
485     }
486     next = next->next;
487   }
488 
489   /* wait until accessor has unlocked the memory */
490   PetscStackCallSAWs(SAWs_Push_Header,("index.html",OptionsHeader));
491   PetscStackCallSAWs(SAWs_Push_Body,("index.html",2,OptionsBodyBottom));
492   ierr = PetscSAWsBlock();CHKERRQ(ierr);
493   PetscStackCallSAWs(SAWs_Pop_Header,("index.html"));
494   PetscStackCallSAWs(SAWs_Pop_Body,("index.html",2));
495 
496   /* determine if any values have been set in GUI */
497   next = PetscOptionsObject->next;
498   while (next) {
499     ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr);
500     PetscStackCallSAWs(SAWs_Selected,(dir,(int*)&next->set));
501     next = next->next;
502   }
503 
504   /* reset counter to -2; this updates the screen with the new options for the selected method */
505   if (changedmethod) PetscOptionsObject->count = -2;
506 
507   if (stopasking) {
508     PetscOptionsPublish      = PETSC_FALSE;
509     PetscOptionsObject->count = 0;//do not ask for same thing again
510   }
511 
512   PetscStackCallSAWs(SAWs_Delete,("/PETSc/Options"));
513   PetscFunctionReturn(0);
514 }
515 #endif
516 
517 PetscErrorCode PetscOptionsEnd_Private(PetscOptionItems *PetscOptionsObject)
518 {
519   PetscErrorCode  ierr;
520   PetscOptionItem last;
521   char            option[256],value[1024],tmp[32];
522   size_t          j;
523 
524   PetscFunctionBegin;
525   if (PetscOptionsObject->next) {
526     if (!PetscOptionsObject->count) {
527 #if defined(PETSC_HAVE_SAWS)
528       ierr = PetscOptionsSAWsInput(PetscOptionsObject);CHKERRQ(ierr);
529 #else
530       ierr = PetscOptionsGetFromTextInput(PetscOptionsObject);CHKERRQ(ierr);
531 #endif
532     }
533   }
534 
535   ierr = PetscFree(PetscOptionsObject->title);CHKERRQ(ierr);
536 
537   /* reset counter to -2; this updates the screen with the new options for the selected method */
538   if (PetscOptionsObject->changedmethod) PetscOptionsObject->count = -2;
539   /* reset alreadyprinted flag */
540   PetscOptionsObject->alreadyprinted = PETSC_FALSE;
541   if (PetscOptionsObject->object) PetscOptionsObject->object->optionsprinted = PETSC_TRUE;
542   PetscOptionsObject->object = NULL;
543 
544   while (PetscOptionsObject->next) {
545     if (PetscOptionsObject->next->set) {
546       if (PetscOptionsObject->prefix) {
547         ierr = PetscStrcpy(option,"-");CHKERRQ(ierr);
548         ierr = PetscStrcat(option,PetscOptionsObject->prefix);CHKERRQ(ierr);
549         ierr = PetscStrcat(option,PetscOptionsObject->next->option+1);CHKERRQ(ierr);
550       } else {
551         ierr = PetscStrcpy(option,PetscOptionsObject->next->option);CHKERRQ(ierr);
552       }
553 
554       switch (PetscOptionsObject->next->type) {
555       case OPTION_HEAD:
556         break;
557       case OPTION_INT_ARRAY:
558         sprintf(value,"%d",(int)((PetscInt*)PetscOptionsObject->next->data)[0]);
559         for (j=1; j<PetscOptionsObject->next->arraylength; j++) {
560           sprintf(tmp,"%d",(int)((PetscInt*)PetscOptionsObject->next->data)[j]);
561           ierr = PetscStrcat(value,",");CHKERRQ(ierr);
562           ierr = PetscStrcat(value,tmp);CHKERRQ(ierr);
563         }
564         break;
565       case OPTION_INT:
566         sprintf(value,"%d",(int) *(PetscInt*)PetscOptionsObject->next->data);
567         break;
568       case OPTION_REAL:
569         sprintf(value,"%g",(double) *(PetscReal*)PetscOptionsObject->next->data);
570         break;
571       case OPTION_REAL_ARRAY:
572         sprintf(value,"%g",(double)((PetscReal*)PetscOptionsObject->next->data)[0]);
573         for (j=1; j<PetscOptionsObject->next->arraylength; j++) {
574           sprintf(tmp,"%g",(double)((PetscReal*)PetscOptionsObject->next->data)[j]);
575           ierr = PetscStrcat(value,",");CHKERRQ(ierr);
576           ierr = PetscStrcat(value,tmp);CHKERRQ(ierr);
577         }
578         break;
579       case OPTION_SCALAR_ARRAY:
580         sprintf(value,"%g+%gi",(double)PetscRealPart(((PetscScalar*)PetscOptionsObject->next->data)[0]),(double)PetscImaginaryPart(((PetscScalar*)PetscOptionsObject->next->data)[0]));
581         for (j=1; j<PetscOptionsObject->next->arraylength; j++) {
582           sprintf(tmp,"%g+%gi",(double)PetscRealPart(((PetscScalar*)PetscOptionsObject->next->data)[j]),(double)PetscImaginaryPart(((PetscScalar*)PetscOptionsObject->next->data)[j]));
583           ierr = PetscStrcat(value,",");CHKERRQ(ierr);
584           ierr = PetscStrcat(value,tmp);CHKERRQ(ierr);
585         }
586         break;
587       case OPTION_BOOL:
588         sprintf(value,"%d",*(int*)PetscOptionsObject->next->data);
589         break;
590       case OPTION_BOOL_ARRAY:
591         sprintf(value,"%d",(int)((PetscBool*)PetscOptionsObject->next->data)[0]);
592         for (j=1; j<PetscOptionsObject->next->arraylength; j++) {
593           sprintf(tmp,"%d",(int)((PetscBool*)PetscOptionsObject->next->data)[j]);
594           ierr = PetscStrcat(value,",");CHKERRQ(ierr);
595           ierr = PetscStrcat(value,tmp);CHKERRQ(ierr);
596         }
597         break;
598       case OPTION_FLIST:
599         ierr = PetscStrcpy(value,(char*)PetscOptionsObject->next->data);CHKERRQ(ierr);
600         break;
601       case OPTION_ELIST:
602         ierr = PetscStrcpy(value,(char*)PetscOptionsObject->next->data);CHKERRQ(ierr);
603         break;
604       case OPTION_STRING:
605         ierr = PetscStrcpy(value,(char*)PetscOptionsObject->next->data);CHKERRQ(ierr);
606         break;
607       case OPTION_STRING_ARRAY:
608         sprintf(value,"%s",((char**)PetscOptionsObject->next->data)[0]);
609         for (j=1; j<PetscOptionsObject->next->arraylength; j++) {
610           sprintf(tmp,"%s",((char**)PetscOptionsObject->next->data)[j]);
611           ierr = PetscStrcat(value,",");CHKERRQ(ierr);
612           ierr = PetscStrcat(value,tmp);CHKERRQ(ierr);
613         }
614         break;
615       }
616       ierr = PetscOptionsSetValue(PetscOptionsObject->options,option,value);CHKERRQ(ierr);
617     }
618     if (PetscOptionsObject->next->type == OPTION_ELIST) {
619       ierr = PetscStrNArrayDestroy(PetscOptionsObject->next->nlist,(char ***)&PetscOptionsObject->next->list);CHKERRQ(ierr);
620     }
621     ierr   = PetscFree(PetscOptionsObject->next->text);CHKERRQ(ierr);
622     ierr   = PetscFree(PetscOptionsObject->next->option);CHKERRQ(ierr);
623     ierr   = PetscFree(PetscOptionsObject->next->man);CHKERRQ(ierr);
624     ierr   = PetscFree(PetscOptionsObject->next->edata);CHKERRQ(ierr);
625 
626     if ((PetscOptionsObject->next->type == OPTION_STRING) || (PetscOptionsObject->next->type == OPTION_FLIST) || (PetscOptionsObject->next->type == OPTION_ELIST)){
627       free(PetscOptionsObject->next->data);
628     } else {
629       ierr   = PetscFree(PetscOptionsObject->next->data);CHKERRQ(ierr);
630     }
631 
632     last                    = PetscOptionsObject->next;
633     PetscOptionsObject->next = PetscOptionsObject->next->next;
634     ierr                    = PetscFree(last);CHKERRQ(ierr);
635   }
636   ierr = PetscFree(PetscOptionsObject->prefix);CHKERRQ(ierr);
637   PetscOptionsObject->next = 0;
638   PetscFunctionReturn(0);
639 }
640 
641 /*@C
642    PetscOptionsEnum - Gets the enum value for a particular option in the database.
643 
644    Logically Collective on the communicator passed in PetscOptionsBegin()
645 
646    Input Parameters:
647 +  opt - option name
648 .  text - short string that describes the option
649 .  man - manual page with additional information on option
650 .  list - array containing the list of choices, followed by the enum name, followed by the enum prefix, followed by a null
651 -  currentvalue - the current value; caller is responsible for setting this value correctly. Normally this is done with either
652 $                 PetscOptionsEnum(..., obj->value,&object->value,...) or
653 $                 value = defaultvalue
654 $                 PetscOptionsEnum(..., value,&value,&flg);
655 $                 if (flg) {
656 
657    Output Parameter:
658 +  value - the  value to return
659 -  set - PETSC_TRUE if found, else PETSC_FALSE
660 
661    Level: beginner
662 
663    Notes:
664     Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
665 
666           list is usually something like PCASMTypes or some other predefined list of enum names
667 
668           If the user does not supply the option at all value is NOT changed. Thus
669           you should ALWAYS initialize value if you access it without first checking if the set flag is true.
670 
671           The default/currentvalue passed into this routine does not get transferred to the output value variable automatically.
672 
673 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
674           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool()
675           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(),
676           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
677           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
678           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
679           PetscOptionsFList(), PetscOptionsEList()
680 @*/
681 PetscErrorCode  PetscOptionsEnum_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],const char *const *list,PetscEnum currentvalue,PetscEnum *value,PetscBool  *set)
682 {
683   PetscErrorCode ierr;
684   PetscInt       ntext = 0;
685   PetscInt       tval;
686   PetscBool      tflg;
687 
688   PetscFunctionBegin;
689   while (list[ntext++]) {
690     if (ntext > 50) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"List argument appears to be wrong or have more than 50 entries");
691   }
692   if (ntext < 3) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"List argument must have at least two entries: typename and type prefix");
693   ntext -= 3;
694   ierr   = PetscOptionsEList_Private(PetscOptionsObject,opt,text,man,list,ntext,list[currentvalue],&tval,&tflg);CHKERRQ(ierr);
695   /* with PETSC_USE_64BIT_INDICES sizeof(PetscInt) != sizeof(PetscEnum) */
696   if (tflg) *value = (PetscEnum)tval;
697   if (set)  *set   = tflg;
698   PetscFunctionReturn(0);
699 }
700 
701 /*@C
702    PetscOptionsEnumArray - Gets an array of enum values for a particular
703    option in the database.
704 
705    Logically Collective on the communicator passed in PetscOptionsBegin()
706 
707    Input Parameters:
708 +  opt - the option one is seeking
709 .  text - short string describing option
710 .  man - manual page for option
711 .  list - array containing the list of choices, followed by the enum name, followed by the enum prefix, followed by a null
712 -  n - maximum number of values
713 
714    Output Parameter:
715 +  value - location to copy values
716 .  n - actual number of values found
717 -  set - PETSC_TRUE if found, else PETSC_FALSE
718 
719    Level: beginner
720 
721    Notes:
722    The array must be passed as a comma separated list.
723 
724    There must be no intervening spaces between the values.
725 
726    Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
727 
728 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
729           PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
730           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
731           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
732           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
733           PetscOptionsFList(), PetscOptionsEList(), PetscOptionsRealArray()
734 @*/
735 PetscErrorCode  PetscOptionsEnumArray_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],const char *const *list,PetscEnum value[],PetscInt *n,PetscBool  *set)
736 {
737   PetscInt        i,nlist = 0;
738   PetscOptionItem amsopt;
739   PetscErrorCode  ierr;
740 
741   PetscFunctionBegin;
742   while (list[nlist++]) if (nlist > 50) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"List argument appears to be wrong or have more than 50 entries");
743   if (nlist < 3) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"List argument must have at least two entries: typename and type prefix");
744   nlist -= 3; /* drop enum name, prefix, and null termination */
745   if (0 && !PetscOptionsObject->count) { /* XXX Requires additional support */
746     PetscEnum *vals;
747     ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,text,man,OPTION_INT_ARRAY/*XXX OPTION_ENUM_ARRAY*/,&amsopt);CHKERRQ(ierr);
748     ierr = PetscStrNArrayallocpy(nlist,list,(char***)&amsopt->list);CHKERRQ(ierr);
749     amsopt->nlist = nlist;
750     ierr = PetscMalloc1(*n,(PetscEnum**)&amsopt->data);CHKERRQ(ierr);
751     amsopt->arraylength = *n;
752     vals = (PetscEnum*)amsopt->data;
753     for (i=0; i<*n; i++) vals[i] = value[i];
754   }
755   ierr = PetscOptionsGetEnumArray(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,list,value,n,set);CHKERRQ(ierr);
756   if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) {
757     ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,"  -%s%s <%s",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",opt+1,list[value[0]]);CHKERRQ(ierr);
758     for (i=1; i<*n; i++) {ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,",%s",list[value[i]]);CHKERRQ(ierr);}
759     ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,">: %s (choose from)",text);CHKERRQ(ierr);
760     for (i=0; i<nlist; i++) {ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm," %s",list[i]);CHKERRQ(ierr);}
761     ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm," (%s)\n",ManSection(man));CHKERRQ(ierr);
762   }
763   PetscFunctionReturn(0);
764 }
765 
766 /* -------------------------------------------------------------------------------------------------------------*/
767 /*@C
768    PetscOptionsInt - Gets the integer value for a particular option in the database.
769 
770    Logically Collective on the communicator passed in PetscOptionsBegin()
771 
772    Input Parameters:
773 +  opt - option name
774 .  text - short string that describes the option
775 .  man - manual page with additional information on option
776 -  currentvalue - the current value; caller is responsible for setting this value correctly. Normally this is done with either
777 $                 PetscOptionsInt(..., obj->value,&object->value,...) or
778 $                 value = defaultvalue
779 $                 PetscOptionsInt(..., value,&value,&flg);
780 $                 if (flg) {
781 
782    Output Parameter:
783 +  value - the integer value to return
784 -  flg - PETSC_TRUE if found, else PETSC_FALSE
785 
786    Notes:
787     If the user does not supply the option at all value is NOT changed. Thus
788           you should ALWAYS initialize value if you access it without first checking if the set flag is true.
789 
790           The default/currentvalue passed into this routine does not get transferred to the output value variable automatically.
791 
792    Level: beginner
793 
794    Notes:
795     Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
796 
797 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
798           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool()
799           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(),
800           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
801           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
802           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
803           PetscOptionsFList(), PetscOptionsEList()
804 @*/
805 PetscErrorCode  PetscOptionsInt_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],PetscInt currentvalue,PetscInt *value,PetscBool  *set)
806 {
807   PetscErrorCode  ierr;
808   PetscOptionItem amsopt;
809   PetscBool       wasset;
810 
811   PetscFunctionBegin;
812   if (!PetscOptionsObject->count) {
813     ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,text,man,OPTION_INT,&amsopt);CHKERRQ(ierr);
814     ierr = PetscMalloc(sizeof(PetscInt),&amsopt->data);CHKERRQ(ierr);
815     *(PetscInt*)amsopt->data = currentvalue;
816 
817     ierr = PetscOptionsGetInt(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,&currentvalue,&wasset);CHKERRQ(ierr);
818     if (wasset) {
819       *(PetscInt*)amsopt->data = currentvalue;
820     }
821   }
822   ierr = PetscOptionsGetInt(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,value,&wasset);CHKERRQ(ierr);
823   if (set) *set = wasset;
824   if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) {
825     ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,"  -%s%s <now %D : formerly %D>: %s (%s)\n",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",opt+1,wasset && value ? *value : currentvalue,currentvalue,text,ManSection(man));CHKERRQ(ierr);
826   }
827   PetscFunctionReturn(0);
828 }
829 
830 /*@C
831    PetscOptionsString - Gets the string value for a particular option in the database.
832 
833    Logically Collective on the communicator passed in PetscOptionsBegin()
834 
835    Input Parameters:
836 +  opt - option name
837 .  text - short string that describes the option
838 .  man - manual page with additional information on option
839 .  currentvalue - the current value; caller is responsible for setting this value correctly. This is not used to set value
840 -  len - length of the result string including null terminator
841 
842    Output Parameter:
843 +  value - the value to return
844 -  flg - PETSC_TRUE if found, else PETSC_FALSE
845 
846    Level: beginner
847 
848    Notes:
849     Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
850 
851    Even if the user provided no string (for example -optionname -someotheroption) the flag is set to PETSC_TRUE (and the string is fulled with nulls).
852 
853           If the user does not supply the option at all value is NOT changed. Thus
854           you should ALWAYS initialize value if you access it without first checking if the set flag is true.
855 
856           The default/currentvalue passed into this routine does not get transferred to the output value variable automatically.
857 
858 
859 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
860           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool()
861           PetscOptionsInt(), PetscOptionsReal(), PetscOptionsBool(),
862           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
863           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
864           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
865           PetscOptionsFList(), PetscOptionsEList()
866 @*/
867 PetscErrorCode  PetscOptionsString_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],const char currentvalue[],char value[],size_t len,PetscBool  *set)
868 {
869   PetscErrorCode  ierr;
870   PetscOptionItem amsopt;
871   PetscBool       lset;
872 
873   PetscFunctionBegin;
874   if (!PetscOptionsObject->count) {
875     ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,text,man,OPTION_STRING,&amsopt);CHKERRQ(ierr);
876     /* must use system malloc since SAWs may free this */
877     ierr = PetscStrdup(currentvalue ? currentvalue : "",(char**)&amsopt->data);CHKERRQ(ierr);
878   }
879   ierr = PetscOptionsGetString(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,value,len,&lset);CHKERRQ(ierr);
880   if (set) *set = lset;
881   if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) {
882     ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,"  -%s%s <now %s : formerly %s>: %s (%s)\n",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",opt+1,lset && value ? value : currentvalue,currentvalue,text,ManSection(man));CHKERRQ(ierr);
883   }
884   PetscFunctionReturn(0);
885 }
886 
887 /*@C
888    PetscOptionsReal - Gets the PetscReal value for a particular option in the database.
889 
890    Logically Collective on the communicator passed in PetscOptionsBegin()
891 
892    Input Parameters:
893 +  opt - option name
894 .  text - short string that describes the option
895 .  man - manual page with additional information on option
896 -  currentvalue - the current value; caller is responsible for setting this value correctly. Normally this is done with either
897 $                 PetscOptionsReal(..., obj->value,&object->value,...) or
898 $                 value = defaultvalue
899 $                 PetscOptionsReal(..., value,&value,&flg);
900 $                 if (flg) {
901 
902    Output Parameter:
903 +  value - the value to return
904 -  flg - PETSC_TRUE if found, else PETSC_FALSE
905 
906    Notes:
907     If the user does not supply the option at all value is NOT changed. Thus
908           you should ALWAYS initialize value if you access it without first checking if the set flag is true.
909 
910           The default/currentvalue passed into this routine does not get transferred to the output value variable automatically.
911 
912    Level: beginner
913 
914    Notes:
915     Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
916 
917 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
918           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool()
919           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(),
920           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
921           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
922           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
923           PetscOptionsFList(), PetscOptionsEList()
924 @*/
925 PetscErrorCode  PetscOptionsReal_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],PetscReal currentvalue,PetscReal *value,PetscBool  *set)
926 {
927   PetscErrorCode  ierr;
928   PetscOptionItem amsopt;
929   PetscBool       lset;
930 
931   PetscFunctionBegin;
932   if (!PetscOptionsObject->count) {
933     ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,text,man,OPTION_REAL,&amsopt);CHKERRQ(ierr);
934     ierr = PetscMalloc(sizeof(PetscReal),&amsopt->data);CHKERRQ(ierr);
935 
936     *(PetscReal*)amsopt->data = currentvalue;
937   }
938   ierr = PetscOptionsGetReal(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,value,&lset);CHKERRQ(ierr);
939   if (set) *set = lset;
940   if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) {
941     ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,"  -%s%s <%g : %g>: %s (%s)\n",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",opt+1,lset && value ? (double)*value : (double) currentvalue,(double)currentvalue,text,ManSection(man));CHKERRQ(ierr);
942   }
943   PetscFunctionReturn(0);
944 }
945 
946 /*@C
947    PetscOptionsScalar - Gets the scalar value for a particular option in the database.
948 
949    Logically Collective on the communicator passed in PetscOptionsBegin()
950 
951    Input Parameters:
952 +  opt - option name
953 .  text - short string that describes the option
954 .  man - manual page with additional information on option
955 -  currentvalue - the current value; caller is responsible for setting this value correctly. Normally this is done with either
956 $                 PetscOptionsScalar(..., obj->value,&object->value,...) or
957 $                 value = defaultvalue
958 $                 PetscOptionsScalar(..., value,&value,&flg);
959 $                 if (flg) {
960 
961 
962    Output Parameter:
963 +  value - the value to return
964 -  flg - PETSC_TRUE if found, else PETSC_FALSE
965 
966    Notes:
967     If the user does not supply the option at all value is NOT changed. Thus
968           you should ALWAYS initialize value if you access it without first checking if the set flag is true.
969 
970           The default/currentvalue passed into this routine does not get transferred to the output value variable automatically.
971 
972    Level: beginner
973 
974    Notes:
975     Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
976 
977 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
978           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool()
979           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(),
980           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
981           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
982           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
983           PetscOptionsFList(), PetscOptionsEList()
984 @*/
985 PetscErrorCode  PetscOptionsScalar_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],PetscScalar currentvalue,PetscScalar *value,PetscBool  *set)
986 {
987   PetscErrorCode ierr;
988 
989   PetscFunctionBegin;
990 #if !defined(PETSC_USE_COMPLEX)
991   ierr = PetscOptionsReal(opt,text,man,currentvalue,value,set);CHKERRQ(ierr);
992 #else
993   ierr = PetscOptionsGetScalar(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,value,set);CHKERRQ(ierr);
994 #endif
995   PetscFunctionReturn(0);
996 }
997 
998 /*@C
999    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
1000                       its value is set to false.
1001 
1002    Logically Collective on the communicator passed in PetscOptionsBegin()
1003 
1004    Input Parameters:
1005 +  opt - option name
1006 .  text - short string that describes the option
1007 -  man - manual page with additional information on option
1008 
1009    Output Parameter:
1010 .  flg - PETSC_TRUE if found, else PETSC_FALSE
1011 
1012    Level: beginner
1013 
1014    Notes:
1015     Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1016 
1017 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
1018           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool()
1019           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(),
1020           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1021           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1022           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
1023           PetscOptionsFList(), PetscOptionsEList()
1024 @*/
1025 PetscErrorCode  PetscOptionsName_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],PetscBool  *flg)
1026 {
1027   PetscErrorCode  ierr;
1028   PetscOptionItem amsopt;
1029 
1030   PetscFunctionBegin;
1031   if (!PetscOptionsObject->count) {
1032     ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,text,man,OPTION_BOOL,&amsopt);CHKERRQ(ierr);
1033     ierr = PetscMalloc(sizeof(PetscBool),&amsopt->data);CHKERRQ(ierr);
1034 
1035     *(PetscBool*)amsopt->data = PETSC_FALSE;
1036   }
1037   ierr = PetscOptionsHasName(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,flg);CHKERRQ(ierr);
1038   if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) {
1039     ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,"  -%s%s: %s (%s)\n",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",opt+1,text,ManSection(man));CHKERRQ(ierr);
1040   }
1041   PetscFunctionReturn(0);
1042 }
1043 
1044 /*@C
1045      PetscOptionsFList - Puts a list of option values that a single one may be selected from
1046 
1047    Logically Collective on the communicator passed in PetscOptionsBegin()
1048 
1049    Input Parameters:
1050 +  opt - option name
1051 .  text - short string that describes the option
1052 .  man - manual page with additional information on option
1053 .  list - the possible choices
1054 .  currentvalue - the current value; caller is responsible for setting this value correctly. Normally this is done with
1055 $                 PetscOptionsFlist(..., obj->value,value,len,&flg);
1056 $                 if (flg) {
1057 -  len - the length of the character array value
1058 
1059    Output Parameter:
1060 +  value - the value to return
1061 -  set - PETSC_TRUE if found, else PETSC_FALSE
1062 
1063    Level: intermediate
1064 
1065    Notes:
1066     Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1067 
1068           If the user does not supply the option at all value is NOT changed. Thus
1069           you should ALWAYS initialize value if you access it without first checking if the set flag is true.
1070 
1071           The default/currentvalue passed into this routine does not get transferred to the output value variable automatically.
1072 
1073    See PetscOptionsEList() for when the choices are given in a string array
1074 
1075    To get a listing of all currently specified options,
1076     see PetscOptionsView() or PetscOptionsGetAll()
1077 
1078    Developer Note: This cannot check for invalid selection because of things like MATAIJ that are not included in the list
1079 
1080 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1081            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
1082           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1083           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1084           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
1085           PetscOptionsFList(), PetscOptionsEList(), PetscOptionsEnum()
1086 @*/
1087 PetscErrorCode  PetscOptionsFList_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char ltext[],const char man[],PetscFunctionList list,const char currentvalue[],char value[],size_t len,PetscBool  *set)
1088 {
1089   PetscErrorCode  ierr;
1090   PetscOptionItem amsopt;
1091   PetscBool       lset;
1092 
1093   PetscFunctionBegin;
1094   if (!PetscOptionsObject->count) {
1095     ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,ltext,man,OPTION_FLIST,&amsopt);CHKERRQ(ierr);
1096     /* must use system malloc since SAWs may free this */
1097     ierr = PetscStrdup(currentvalue ? currentvalue : "",(char**)&amsopt->data);CHKERRQ(ierr);
1098     amsopt->flist = list;
1099   }
1100   ierr = PetscOptionsGetString(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,value,len,&lset);CHKERRQ(ierr);
1101   if (set) *set = lset;
1102   if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) {
1103     ierr = PetscFunctionListPrintTypes(PetscOptionsObject->comm,stdout,PetscOptionsObject->prefix,opt,ltext,man,list,currentvalue,lset && value ? value : currentvalue);CHKERRQ(ierr);CHKERRQ(ierr);
1104   }
1105   PetscFunctionReturn(0);
1106 }
1107 
1108 /*@C
1109      PetscOptionsEList - Puts a list of option values that a single one may be selected from
1110 
1111    Logically Collective on the communicator passed in PetscOptionsBegin()
1112 
1113    Input Parameters:
1114 +  opt - option name
1115 .  ltext - short string that describes the option
1116 .  man - manual page with additional information on option
1117 .  list - the possible choices (one of these must be selected, anything else is invalid)
1118 .  ntext - number of choices
1119 -  currentvalue - the current value; caller is responsible for setting this value correctly. Normally this is done with
1120 $                 PetscOptionsElist(..., obj->value,&value,&flg);
1121 $                 if (flg) {
1122 
1123 
1124    Output Parameter:
1125 +  value - the index of the value to return
1126 -  set - PETSC_TRUE if found, else PETSC_FALSE
1127 
1128    Level: intermediate
1129 
1130    Notes:
1131     Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1132 
1133          If the user does not supply the option at all value is NOT changed. Thus
1134           you should ALWAYS initialize value if you access it without first checking if the set flag is true.
1135 
1136    See PetscOptionsFList() for when the choices are given in a PetscFunctionList()
1137 
1138 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1139            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
1140           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1141           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1142           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
1143           PetscOptionsFList(), PetscOptionsEnum()
1144 @*/
1145 PetscErrorCode  PetscOptionsEList_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char ltext[],const char man[],const char *const *list,PetscInt ntext,const char currentvalue[],PetscInt *value,PetscBool  *set)
1146 {
1147   PetscErrorCode  ierr;
1148   PetscInt        i;
1149   PetscOptionItem amsopt;
1150   PetscBool       lset;
1151 
1152   PetscFunctionBegin;
1153   if (!PetscOptionsObject->count) {
1154     ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,ltext,man,OPTION_ELIST,&amsopt);CHKERRQ(ierr);
1155     /* must use system malloc since SAWs may free this */
1156     ierr = PetscStrdup(currentvalue ? currentvalue : "",(char**)&amsopt->data);CHKERRQ(ierr);
1157     ierr = PetscStrNArrayallocpy(ntext,list,(char***)&amsopt->list);CHKERRQ(ierr);
1158     amsopt->nlist = ntext;
1159   }
1160   ierr = PetscOptionsGetEList(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,list,ntext,value,&lset);CHKERRQ(ierr);
1161   if (set) *set = lset;
1162   if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) {
1163     ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,"  -%s%s <now %s : formerly %s> %s (choose one of)",PetscOptionsObject->prefix?PetscOptionsObject->prefix:"",opt+1,lset && value ? list[*value] : currentvalue,currentvalue,ltext);CHKERRQ(ierr);
1164     for (i=0; i<ntext; i++) {
1165       ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm," %s",list[i]);CHKERRQ(ierr);
1166     }
1167     ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm," (%s)\n",ManSection(man));CHKERRQ(ierr);
1168   }
1169   PetscFunctionReturn(0);
1170 }
1171 
1172 /*@C
1173      PetscOptionsBoolGroupBegin - First in a series of logical queries on the options database for
1174        which at most a single value can be true.
1175 
1176    Logically Collective on the communicator passed in PetscOptionsBegin()
1177 
1178    Input Parameters:
1179 +  opt - option name
1180 .  text - short string that describes the option
1181 -  man - manual page with additional information on option
1182 
1183    Output Parameter:
1184 .  flg - whether that option was set or not
1185 
1186    Level: intermediate
1187 
1188    Notes:
1189     Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1190 
1191    Must be followed by 0 or more PetscOptionsBoolGroup()s and PetscOptionsBoolGroupEnd()
1192 
1193 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1194            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
1195           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1196           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1197           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
1198           PetscOptionsFList(), PetscOptionsEList()
1199 @*/
1200 PetscErrorCode  PetscOptionsBoolGroupBegin_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],PetscBool  *flg)
1201 {
1202   PetscErrorCode  ierr;
1203   PetscOptionItem amsopt;
1204 
1205   PetscFunctionBegin;
1206   if (!PetscOptionsObject->count) {
1207     ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,text,man,OPTION_BOOL,&amsopt);CHKERRQ(ierr);
1208     ierr = PetscMalloc(sizeof(PetscBool),&amsopt->data);CHKERRQ(ierr);
1209 
1210     *(PetscBool*)amsopt->data = PETSC_FALSE;
1211   }
1212   *flg = PETSC_FALSE;
1213   ierr = PetscOptionsGetBool(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,flg,NULL);CHKERRQ(ierr);
1214   if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) {
1215     ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,"  Pick at most one of -------------\n");CHKERRQ(ierr);
1216     ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,"    -%s%s: %s (%s)\n",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",opt+1,text,ManSection(man));CHKERRQ(ierr);
1217   }
1218   PetscFunctionReturn(0);
1219 }
1220 
1221 /*@C
1222      PetscOptionsBoolGroup - One in a series of logical queries on the options database for
1223        which at most a single value can be true.
1224 
1225    Logically Collective on the communicator passed in PetscOptionsBegin()
1226 
1227    Input Parameters:
1228 +  opt - option name
1229 .  text - short string that describes the option
1230 -  man - manual page with additional information on option
1231 
1232    Output Parameter:
1233 .  flg - PETSC_TRUE if found, else PETSC_FALSE
1234 
1235    Level: intermediate
1236 
1237    Notes:
1238     Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1239 
1240    Must follow a PetscOptionsBoolGroupBegin() and preceded a PetscOptionsBoolGroupEnd()
1241 
1242 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1243            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
1244           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1245           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1246           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
1247           PetscOptionsFList(), PetscOptionsEList()
1248 @*/
1249 PetscErrorCode  PetscOptionsBoolGroup_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],PetscBool  *flg)
1250 {
1251   PetscErrorCode  ierr;
1252   PetscOptionItem amsopt;
1253 
1254   PetscFunctionBegin;
1255   if (!PetscOptionsObject->count) {
1256     ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,text,man,OPTION_BOOL,&amsopt);CHKERRQ(ierr);
1257     ierr = PetscMalloc(sizeof(PetscBool),&amsopt->data);CHKERRQ(ierr);
1258 
1259     *(PetscBool*)amsopt->data = PETSC_FALSE;
1260   }
1261   *flg = PETSC_FALSE;
1262   ierr = PetscOptionsGetBool(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,flg,NULL);CHKERRQ(ierr);
1263   if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) {
1264     ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,"    -%s%s: %s (%s)\n",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",opt+1,text,ManSection(man));CHKERRQ(ierr);
1265   }
1266   PetscFunctionReturn(0);
1267 }
1268 
1269 /*@C
1270      PetscOptionsBoolGroupEnd - Last in a series of logical queries on the options database for
1271        which at most a single value can be true.
1272 
1273    Logically Collective on the communicator passed in PetscOptionsBegin()
1274 
1275    Input Parameters:
1276 +  opt - option name
1277 .  text - short string that describes the option
1278 -  man - manual page with additional information on option
1279 
1280    Output Parameter:
1281 .  flg - PETSC_TRUE if found, else PETSC_FALSE
1282 
1283    Level: intermediate
1284 
1285    Notes:
1286     Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1287 
1288    Must follow a PetscOptionsBoolGroupBegin()
1289 
1290 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1291            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
1292           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1293           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1294           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
1295           PetscOptionsFList(), PetscOptionsEList()
1296 @*/
1297 PetscErrorCode  PetscOptionsBoolGroupEnd_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],PetscBool  *flg)
1298 {
1299   PetscErrorCode  ierr;
1300   PetscOptionItem amsopt;
1301 
1302   PetscFunctionBegin;
1303   if (!PetscOptionsObject->count) {
1304     ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,text,man,OPTION_BOOL,&amsopt);CHKERRQ(ierr);
1305     ierr = PetscMalloc(sizeof(PetscBool),&amsopt->data);CHKERRQ(ierr);
1306 
1307     *(PetscBool*)amsopt->data = PETSC_FALSE;
1308   }
1309   *flg = PETSC_FALSE;
1310   ierr = PetscOptionsGetBool(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,flg,NULL);CHKERRQ(ierr);
1311   if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) {
1312     ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,"    -%s%s: %s (%s)\n",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",opt+1,text,ManSection(man));CHKERRQ(ierr);
1313   }
1314   PetscFunctionReturn(0);
1315 }
1316 
1317 /*@C
1318    PetscOptionsBool - Determines if a particular option is in the database with a true or false
1319 
1320    Logically Collective on the communicator passed in PetscOptionsBegin()
1321 
1322    Input Parameters:
1323 +  opt - option name
1324 .  text - short string that describes the option
1325 .  man - manual page with additional information on option
1326 -  currentvalue - the current value
1327 
1328    Output Parameter:
1329 .  flg - PETSC_TRUE or PETSC_FALSE
1330 .  set - PETSC_TRUE if found, else PETSC_FALSE
1331 
1332    Notes:
1333        TRUE, true, YES, yes, nostring, and 1 all translate to PETSC_TRUE
1334        FALSE, false, NO, no, and 0 all translate to PETSC_FALSE
1335 
1336       If the option is given, but no value is provided, then flg and set are both given the value PETSC_TRUE. That is -requested_bool
1337      is equivalent to -requested_bool true
1338 
1339        If the user does not supply the option at all flg is NOT changed. Thus
1340      you should ALWAYS initialize the flg if you access it without first checking if the set flag is true.
1341 
1342    Level: beginner
1343 
1344    Notes:
1345     Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1346 
1347 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
1348           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool()
1349           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(),
1350           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1351           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1352           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
1353           PetscOptionsFList(), PetscOptionsEList()
1354 @*/
1355 PetscErrorCode  PetscOptionsBool_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],PetscBool currentvalue,PetscBool  *flg,PetscBool  *set)
1356 {
1357   PetscErrorCode  ierr;
1358   PetscBool       iset;
1359   PetscOptionItem amsopt;
1360 
1361   PetscFunctionBegin;
1362   if (!PetscOptionsObject->count) {
1363     ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,text,man,OPTION_BOOL,&amsopt);CHKERRQ(ierr);
1364     ierr = PetscMalloc(sizeof(PetscBool),&amsopt->data);CHKERRQ(ierr);
1365 
1366     *(PetscBool*)amsopt->data = currentvalue;
1367   }
1368   ierr = PetscOptionsGetBool(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,flg,&iset);CHKERRQ(ierr);
1369   if (set) *set = iset;
1370   if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) {
1371     const char *v = PetscBools[currentvalue], *vn = PetscBools[iset && flg ? *flg : currentvalue];
1372     ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,"  -%s%s: <%s : %s> %s (%s)\n",PetscOptionsObject->prefix?PetscOptionsObject->prefix:"",opt+1,v,vn,text,ManSection(man));CHKERRQ(ierr);
1373   }
1374   PetscFunctionReturn(0);
1375 }
1376 
1377 /*@C
1378    PetscOptionsRealArray - Gets an array of double values for a particular
1379    option in the database. The values must be separated with commas with
1380    no intervening spaces.
1381 
1382    Logically Collective on the communicator passed in PetscOptionsBegin()
1383 
1384    Input Parameters:
1385 +  opt - the option one is seeking
1386 .  text - short string describing option
1387 .  man - manual page for option
1388 -  nmax - maximum number of values
1389 
1390    Output Parameter:
1391 +  value - location to copy values
1392 .  nmax - actual number of values found
1393 -  set - PETSC_TRUE if found, else PETSC_FALSE
1394 
1395    Level: beginner
1396 
1397    Notes:
1398    The user should pass in an array of doubles
1399 
1400    Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1401 
1402 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1403            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
1404           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1405           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1406           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
1407           PetscOptionsFList(), PetscOptionsEList()
1408 @*/
1409 PetscErrorCode PetscOptionsRealArray_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],PetscReal value[],PetscInt *n,PetscBool  *set)
1410 {
1411   PetscErrorCode  ierr;
1412   PetscInt        i;
1413   PetscOptionItem amsopt;
1414 
1415   PetscFunctionBegin;
1416   if (!PetscOptionsObject->count) {
1417     PetscReal *vals;
1418 
1419     ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,text,man,OPTION_REAL_ARRAY,&amsopt);CHKERRQ(ierr);
1420     ierr = PetscMalloc((*n)*sizeof(PetscReal),&amsopt->data);CHKERRQ(ierr);
1421     vals = (PetscReal*)amsopt->data;
1422     for (i=0; i<*n; i++) vals[i] = value[i];
1423     amsopt->arraylength = *n;
1424   }
1425   ierr = PetscOptionsGetRealArray(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,value,n,set);CHKERRQ(ierr);
1426   if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) {
1427     ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,"  -%s%s <%g",PetscOptionsObject->prefix?PetscOptionsObject->prefix:"",opt+1,(double)value[0]);CHKERRQ(ierr);
1428     for (i=1; i<*n; i++) {
1429       ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,",%g",(double)value[i]);CHKERRQ(ierr);
1430     }
1431     ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,">: %s (%s)\n",text,ManSection(man));CHKERRQ(ierr);
1432   }
1433   PetscFunctionReturn(0);
1434 }
1435 
1436 /*@C
1437    PetscOptionsScalarArray - Gets an array of Scalar values for a particular
1438    option in the database. The values must be separated with commas with
1439    no intervening spaces.
1440 
1441    Logically Collective on the communicator passed in PetscOptionsBegin()
1442 
1443    Input Parameters:
1444 +  opt - the option one is seeking
1445 .  text - short string describing option
1446 .  man - manual page for option
1447 -  nmax - maximum number of values
1448 
1449    Output Parameter:
1450 +  value - location to copy values
1451 .  nmax - actual number of values found
1452 -  set - PETSC_TRUE if found, else PETSC_FALSE
1453 
1454    Level: beginner
1455 
1456    Notes:
1457    The user should pass in an array of doubles
1458 
1459    Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1460 
1461 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1462           PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
1463           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1464           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1465           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
1466           PetscOptionsFList(), PetscOptionsEList()
1467 @*/
1468 PetscErrorCode PetscOptionsScalarArray_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],PetscScalar value[],PetscInt *n,PetscBool  *set)
1469 {
1470   PetscErrorCode  ierr;
1471   PetscInt        i;
1472   PetscOptionItem amsopt;
1473 
1474   PetscFunctionBegin;
1475   if (!PetscOptionsObject->count) {
1476     PetscScalar *vals;
1477 
1478     ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,text,man,OPTION_SCALAR_ARRAY,&amsopt);CHKERRQ(ierr);
1479     ierr = PetscMalloc((*n)*sizeof(PetscScalar),&amsopt->data);CHKERRQ(ierr);
1480     vals = (PetscScalar*)amsopt->data;
1481     for (i=0; i<*n; i++) vals[i] = value[i];
1482     amsopt->arraylength = *n;
1483   }
1484   ierr = PetscOptionsGetScalarArray(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,value,n,set);CHKERRQ(ierr);
1485   if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) {
1486     ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,"  -%s%s <%g+%gi",PetscOptionsObject->prefix?PetscOptionsObject->prefix:"",opt+1,(double)PetscRealPart(value[0]),(double)PetscImaginaryPart(value[0]));CHKERRQ(ierr);
1487     for (i=1; i<*n; i++) {
1488       ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,",%g+%gi",(double)PetscRealPart(value[i]),(double)PetscImaginaryPart(value[i]));CHKERRQ(ierr);
1489     }
1490     ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,">: %s (%s)\n",text,ManSection(man));CHKERRQ(ierr);
1491   }
1492   PetscFunctionReturn(0);
1493 }
1494 
1495 /*@C
1496    PetscOptionsIntArray - Gets an array of integers for a particular
1497    option in the database.
1498 
1499    Logically Collective on the communicator passed in PetscOptionsBegin()
1500 
1501    Input Parameters:
1502 +  opt - the option one is seeking
1503 .  text - short string describing option
1504 .  man - manual page for option
1505 -  n - maximum number of values
1506 
1507    Output Parameter:
1508 +  value - location to copy values
1509 .  n - actual number of values found
1510 -  set - PETSC_TRUE if found, else PETSC_FALSE
1511 
1512    Level: beginner
1513 
1514    Notes:
1515    The array can be passed as
1516    a comma separated list:                                 0,1,2,3,4,5,6,7
1517    a range (start-end+1):                                  0-8
1518    a range with given increment (start-end+1:inc):         0-7:2
1519    a combination of values and ranges separated by commas: 0,1-8,8-15:2
1520 
1521    There must be no intervening spaces between the values.
1522 
1523    Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1524 
1525 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1526            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
1527           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1528           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1529           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
1530           PetscOptionsFList(), PetscOptionsEList(), PetscOptionsRealArray()
1531 @*/
1532 PetscErrorCode  PetscOptionsIntArray_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],PetscInt value[],PetscInt *n,PetscBool  *set)
1533 {
1534   PetscErrorCode ierr;
1535   PetscInt        i;
1536   PetscOptionItem amsopt;
1537 
1538   PetscFunctionBegin;
1539   if (!PetscOptionsObject->count) {
1540     PetscInt *vals;
1541 
1542     ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,text,man,OPTION_INT_ARRAY,&amsopt);CHKERRQ(ierr);
1543     ierr = PetscMalloc1(*n,(PetscInt**)&amsopt->data);CHKERRQ(ierr);
1544     vals = (PetscInt*)amsopt->data;
1545     for (i=0; i<*n; i++) vals[i] = value[i];
1546     amsopt->arraylength = *n;
1547   }
1548   ierr = PetscOptionsGetIntArray(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,value,n,set);CHKERRQ(ierr);
1549   if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) {
1550     ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,"  -%s%s <%d",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",opt+1,value[0]);CHKERRQ(ierr);
1551     for (i=1; i<*n; i++) {
1552       ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,",%d",value[i]);CHKERRQ(ierr);
1553     }
1554     ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,">: %s (%s)\n",text,ManSection(man));CHKERRQ(ierr);
1555   }
1556   PetscFunctionReturn(0);
1557 }
1558 
1559 /*@C
1560    PetscOptionsStringArray - Gets an array of string values for a particular
1561    option in the database. The values must be separated with commas with
1562    no intervening spaces.
1563 
1564    Logically Collective on the communicator passed in PetscOptionsBegin()
1565 
1566    Input Parameters:
1567 +  opt - the option one is seeking
1568 .  text - short string describing option
1569 .  man - manual page for option
1570 -  nmax - maximum number of strings
1571 
1572    Output Parameter:
1573 +  value - location to copy strings
1574 .  nmax - actual number of strings found
1575 -  set - PETSC_TRUE if found, else PETSC_FALSE
1576 
1577    Level: beginner
1578 
1579    Notes:
1580    The user should pass in an array of pointers to char, to hold all the
1581    strings returned by this function.
1582 
1583    The user is responsible for deallocating the strings that are
1584    returned. The Fortran interface for this routine is not supported.
1585 
1586    Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1587 
1588 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1589            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
1590           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1591           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1592           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
1593           PetscOptionsFList(), PetscOptionsEList()
1594 @*/
1595 PetscErrorCode  PetscOptionsStringArray_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],char *value[],PetscInt *nmax,PetscBool  *set)
1596 {
1597   PetscErrorCode  ierr;
1598   PetscOptionItem amsopt;
1599 
1600   PetscFunctionBegin;
1601   if (!PetscOptionsObject->count) {
1602     ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,text,man,OPTION_STRING_ARRAY,&amsopt);CHKERRQ(ierr);
1603     ierr = PetscMalloc1(*nmax,(char**)&amsopt->data);CHKERRQ(ierr);
1604 
1605     amsopt->arraylength = *nmax;
1606   }
1607   ierr = PetscOptionsGetStringArray(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,value,nmax,set);CHKERRQ(ierr);
1608   if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) {
1609     ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,"  -%s%s <string1,string2,...>: %s (%s)\n",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",opt+1,text,ManSection(man));CHKERRQ(ierr);
1610   }
1611   PetscFunctionReturn(0);
1612 }
1613 
1614 /*@C
1615    PetscOptionsBoolArray - Gets an array of logical values (true or false) for a particular
1616    option in the database. The values must be separated with commas with
1617    no intervening spaces.
1618 
1619    Logically Collective on the communicator passed in PetscOptionsBegin()
1620 
1621    Input Parameters:
1622 +  opt - the option one is seeking
1623 .  text - short string describing option
1624 .  man - manual page for option
1625 -  nmax - maximum number of values
1626 
1627    Output Parameter:
1628 +  value - location to copy values
1629 .  nmax - actual number of values found
1630 -  set - PETSC_TRUE if found, else PETSC_FALSE
1631 
1632    Level: beginner
1633 
1634    Notes:
1635    The user should pass in an array of doubles
1636 
1637    Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1638 
1639 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1640            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
1641           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1642           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1643           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
1644           PetscOptionsFList(), PetscOptionsEList()
1645 @*/
1646 PetscErrorCode  PetscOptionsBoolArray_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],PetscBool value[],PetscInt *n,PetscBool *set)
1647 {
1648   PetscErrorCode   ierr;
1649   PetscInt         i;
1650   PetscOptionItem  amsopt;
1651 
1652   PetscFunctionBegin;
1653   if (!PetscOptionsObject->count) {
1654     PetscBool *vals;
1655 
1656     ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,text,man,OPTION_BOOL_ARRAY,&amsopt);CHKERRQ(ierr);
1657     ierr = PetscMalloc1(*n,(PetscBool**)&amsopt->data);CHKERRQ(ierr);
1658     vals = (PetscBool*)amsopt->data;
1659     for (i=0; i<*n; i++) vals[i] = value[i];
1660     amsopt->arraylength = *n;
1661   }
1662   ierr = PetscOptionsGetBoolArray(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,value,n,set);CHKERRQ(ierr);
1663   if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) {
1664     ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,"  -%s%s <%d",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",opt+1,value[0]);CHKERRQ(ierr);
1665     for (i=1; i<*n; i++) {
1666       ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,",%d",value[i]);CHKERRQ(ierr);
1667     }
1668     ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,">: %s (%s)\n",text,ManSection(man));CHKERRQ(ierr);
1669   }
1670   PetscFunctionReturn(0);
1671 }
1672 
1673 /*@C
1674    PetscOptionsViewer - Gets a viewer appropriate for the type indicated by the user
1675 
1676    Logically Collective on the communicator passed in PetscOptionsBegin()
1677 
1678    Input Parameters:
1679 +  opt - option name
1680 .  text - short string that describes the option
1681 -  man - manual page with additional information on option
1682 
1683    Output Parameter:
1684 +  viewer - the viewer
1685 -  set - PETSC_TRUE if found, else PETSC_FALSE
1686 
1687    Level: beginner
1688 
1689    Notes:
1690     Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1691 
1692    See PetscOptionsGetViewer() for the format of the supplied viewer and its options
1693 
1694 .seealso: PetscOptionsGetViewer(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
1695           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool()
1696           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(),
1697           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1698           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1699           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
1700           PetscOptionsFList(), PetscOptionsEList()
1701 @*/
1702 PetscErrorCode  PetscOptionsViewer_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],PetscViewer *viewer,PetscViewerFormat *format,PetscBool  *set)
1703 {
1704   PetscErrorCode  ierr;
1705   PetscOptionItem amsopt;
1706 
1707   PetscFunctionBegin;
1708   if (!PetscOptionsObject->count) {
1709     ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,text,man,OPTION_STRING,&amsopt);CHKERRQ(ierr);
1710     /* must use system malloc since SAWs may free this */
1711     ierr = PetscStrdup("",(char**)&amsopt->data);CHKERRQ(ierr);
1712   }
1713   ierr = PetscOptionsGetViewer(PetscOptionsObject->comm,PetscOptionsObject->options,PetscOptionsObject->prefix,opt,viewer,format,set);CHKERRQ(ierr);
1714   if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) {
1715     ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,"  -%s%s <%s>: %s (%s)\n",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",opt+1,"",text,ManSection(man));CHKERRQ(ierr);
1716   }
1717   PetscFunctionReturn(0);
1718 }
1719 
1720 
1721 /*@C
1722      PetscOptionsHead - Puts a heading before listing any more published options. Used, for example,
1723             in KSPSetFromOptions_GMRES().
1724 
1725    Logically Collective on the communicator passed in PetscOptionsBegin()
1726 
1727    Input Parameter:
1728 .   head - the heading text
1729 
1730 
1731    Level: intermediate
1732 
1733    Notes:
1734     Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1735 
1736           Can be followed by a call to PetscOptionsTail() in the same function.
1737 
1738 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1739            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
1740           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1741           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1742           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
1743           PetscOptionsFList(), PetscOptionsEList()
1744 @*/
1745 PetscErrorCode  PetscOptionsHead(PetscOptionItems *PetscOptionsObject,const char head[])
1746 {
1747   PetscErrorCode ierr;
1748 
1749   PetscFunctionBegin;
1750   if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) {
1751     ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,"  %s\n",head);CHKERRQ(ierr);
1752   }
1753   PetscFunctionReturn(0);
1754 }
1755 
1756 
1757 
1758 
1759 
1760 
1761