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