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