xref: /petsc/src/sys/objects/aoptions.c (revision f963788bda91a1d728e4d3144eba9dd2a8083b3a) !
1 #define PETSC_DLL
2 /*
3    These routines simplify the use of command line, file options, etc.,
4    and are used to manipulate the options database.
5 
6   This file uses regular malloc and free because it cannot know
7   what malloc is being used until it has already processed the input.
8 */
9 
10 #include "petsc.h"        /*I  "petsc.h"   I*/
11 #include "petscsys.h"
12 #if defined(PETSC_HAVE_STDLIB_H)
13 #include <stdlib.h>
14 #endif
15 
16 /*
17     Keep a linked list of options that have been posted and we are waiting for
18    user selection
19 
20     Eventually we'll attach this beast to a MPI_Comm
21 */
22 PetscOptionsObjectType PetscOptionsObject;
23 PetscInt               PetscOptionsPublishCount = 0;
24 
25 
26 #undef __FUNCT__
27 #define __FUNCT__ "PetscOptionsHelpAddList"
28 PetscErrorCode PetscOptionsHelpAddList(const char prefix[],const char title[],const char mansec[])
29 {
30   int               ierr;
31   PetscOptionsHelp  newhelp;
32   PetscFunctionBegin;
33   ierr = PetscNew(struct _p_PetscOptionsHelp,&newhelp);CHKERRQ(ierr);
34   ierr = PetscStrallocpy(prefix,&newhelp->prefix);CHKERRQ(ierr);
35   ierr = PetscStrallocpy(title,&newhelp->title);CHKERRQ(ierr);
36   ierr = PetscStrallocpy(mansec,&newhelp->mansec);CHKERRQ(ierr);
37   newhelp->next = 0;
38 
39   if (!PetscOptionsObject.help) {
40     PetscOptionsObject.help = newhelp;
41   } else {
42     newhelp->next = PetscOptionsObject.help;
43     PetscOptionsObject.help = newhelp;
44   }
45   PetscFunctionReturn(0);
46 }
47 
48 #undef __FUNCT__
49 #define __FUNCT__ "PetscOptionsHelpDestroyList"
50 PetscErrorCode PetscOptionsHelpDestroyList(void)
51 {
52   PetscErrorCode   ierr;
53   PetscOptionsHelp help = PetscOptionsObject.help, next;
54 
55   PetscFunctionBegin;
56   while (help) {
57     next = help->next;
58     ierr = PetscStrfree(help->prefix);CHKERRQ(ierr);
59     ierr = PetscStrfree(help->title);CHKERRQ(ierr);
60     ierr = PetscStrfree(help->mansec);CHKERRQ(ierr);
61     ierr = PetscFree(help);CHKERRQ(ierr);
62     help = next;
63   }
64   PetscFunctionReturn(0);
65 }
66 
67 
68 #undef __FUNCT__
69 #define __FUNCT__ "PetscOptionsHelpFindList"
70 PetscErrorCode PetscOptionsHelpFindList(const char prefix[],const char title[],const char mansec[],PetscTruth *flg)
71 {
72   PetscErrorCode   ierr;
73   PetscTruth       flg1,flg2,flg3;
74   PetscOptionsHelp help = PetscOptionsObject.help;
75   PetscFunctionBegin;
76   while (help) {
77     ierr = PetscStrcmp(help->prefix,prefix,&flg1);CHKERRQ(ierr);
78     ierr = PetscStrcmp(help->title,title,&flg2);CHKERRQ(ierr);
79     ierr = PetscStrcmp(help->mansec,mansec,&flg3);CHKERRQ(ierr);
80     if (flg1 && flg2 && flg3) {
81       *flg = PETSC_TRUE;
82       break;
83     }
84     help = help->next;
85   }
86   PetscFunctionReturn(0);
87 
88 }
89 
90 #undef __FUNCT__
91 #define __FUNCT__ "PetscOptionsHelpCheckAddList"
92 PetscErrorCode PetscOptionsHelpCheckAddList(const char prefix[],const char title[],const char mansec[],PetscTruth *flg)
93 {
94   PetscFunctionBegin;
95   PetscOptionsHelpFindList(prefix,title,mansec,flg);
96   if (!(*flg)) PetscOptionsHelpAddList(prefix,title,mansec);
97   PetscFunctionReturn(0);
98 }
99 
100 #undef __FUNCT__
101 #define __FUNCT__ "PetscOptionsBegin_Private"
102 /*
103     Handles setting up the data structure in a call to PetscOptionsBegin()
104 */
105 PetscErrorCode PetscOptionsBegin_Private(MPI_Comm comm,const char prefix[],const char title[],const char mansec[])
106 {
107   PetscErrorCode ierr;
108 
109   PetscFunctionBegin;
110   PetscOptionsObject.next          = 0;
111   PetscOptionsObject.comm          = comm;
112   PetscOptionsObject.changedmethod = PETSC_FALSE;
113   if (PetscOptionsObject.prefix) {
114     ierr = PetscStrfree(PetscOptionsObject.prefix);CHKERRQ(ierr); PetscOptionsObject.prefix = 0;
115   }
116   ierr = PetscStrallocpy(prefix,&PetscOptionsObject.prefix);CHKERRQ(ierr);
117   if (PetscOptionsObject.title) {
118     ierr = PetscStrfree(PetscOptionsObject.title);CHKERRQ(ierr); PetscOptionsObject.title  = 0;
119   }
120   ierr = PetscStrallocpy(title,&PetscOptionsObject.title);CHKERRQ(ierr);
121 
122   ierr = PetscOptionsHasName(PETSC_NULL,"-help",&PetscOptionsObject.printhelp);CHKERRQ(ierr);
123   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1) {
124     ierr = PetscOptionsHelpCheckAddList(prefix,title,mansec,&PetscOptionsObject.alreadyprinted);
125     if (!PetscOptionsObject.alreadyprinted) {
126       ierr = (*PetscHelpPrintf)(comm,"%s -------------------------------------------------\n",title);CHKERRQ(ierr);
127     }
128   }
129   PetscFunctionReturn(0);
130 }
131 
132 /*
133      Handles adding another option to the list of options within this particular PetscOptionsBegin() PetscOptionsEnd()
134 */
135 #undef __FUNCT__
136 #define __FUNCT__ "PetscOptionsCreate_Private"
137 static int PetscOptionsCreate_Private(const char opt[],const char text[],const char man[],PetscOptionType t,PetscOptions *amsopt)
138 {
139   int          ierr;
140   PetscOptions next;
141 
142   PetscFunctionBegin;
143   ierr             = PetscNew(struct _p_PetscOptions,amsopt);CHKERRQ(ierr);
144   (*amsopt)->next  = 0;
145   (*amsopt)->set   = PETSC_FALSE;
146   (*amsopt)->type  = t;
147   (*amsopt)->data  = 0;
148   (*amsopt)->edata = 0;
149 
150   ierr             = PetscStrallocpy(text,&(*amsopt)->text);CHKERRQ(ierr);
151   ierr             = PetscStrallocpy(opt,&(*amsopt)->option);CHKERRQ(ierr);
152   ierr             = PetscStrallocpy(man,&(*amsopt)->man);CHKERRQ(ierr);
153 
154   if (!PetscOptionsObject.next) {
155     PetscOptionsObject.next = *amsopt;
156   } else {
157     next = PetscOptionsObject.next;
158     while (next->next) next = next->next;
159     next->next = *amsopt;
160   }
161   PetscFunctionReturn(0);
162 }
163 
164 #undef __FUNCT__
165 #define __FUNCT__ "PetscOptionsGetFromGui"
166 PetscErrorCode PetscOptionsGetFromGUI()
167 {
168   PetscErrorCode ierr;
169   PetscOptions   next = PetscOptionsObject.next;
170   char           str[512];
171 
172   ierr = (*PetscPrintf)(PetscOptionsObject.comm,"%s -------------------------------------------------\n",PetscOptionsObject.title);CHKERRQ(ierr);
173   while (next) {
174     switch (next->type) {
175       case OPTION_HEAD:
176         break;
177       case OPTION_INT:
178         ierr = PetscPrintf(PetscOptionsObject.comm,"-%s%s <%d>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",next->option,*(int*)next->data,next->text,next->man);CHKERRQ(ierr);
179         scanf("%s\n",str);
180         if (str[0] != '\n') {
181           printf("changing value\n");
182         }
183         break;
184     default:
185       break;
186     }
187     next = next->next;
188   }
189   PetscFunctionReturn(0);
190 }
191 
192 #undef __FUNCT__
193 #define __FUNCT__ "PetscOptionsEnd_Private"
194 PetscErrorCode PetscOptionsEnd_Private(void)
195 {
196   PetscErrorCode ierr;
197   PetscOptions   last;
198   char           option[256],value[1024],tmp[32];
199   PetscInt       j;
200 
201   PetscFunctionBegin;
202 
203   /*  if (PetscOptionsObject.next) {
204     ierr = PetscOptionsGetFromGUI();
205     }*/
206 
207   ierr = PetscStrfree(PetscOptionsObject.title);CHKERRQ(ierr); PetscOptionsObject.title  = 0;
208   ierr = PetscStrfree(PetscOptionsObject.prefix);CHKERRQ(ierr); PetscOptionsObject.prefix = 0;
209 
210   /* reset counter to -2; this updates the screen with the new options for the selected method */
211   if (PetscOptionsObject.changedmethod) PetscOptionsPublishCount = -2;
212   /* reset alreadyprinted flag */
213   PetscOptionsObject.alreadyprinted = PETSC_FALSE;
214 
215   while (PetscOptionsObject.next) {
216     if (PetscOptionsObject.next->set) {
217       if (PetscOptionsObject.prefix) {
218         ierr = PetscStrcpy(option,"-");CHKERRQ(ierr);
219         ierr = PetscStrcat(option,PetscOptionsObject.prefix);CHKERRQ(ierr);
220         ierr = PetscStrcat(option,PetscOptionsObject.next->option+1);CHKERRQ(ierr);
221       } else {
222         ierr = PetscStrcpy(option,PetscOptionsObject.next->option);CHKERRQ(ierr);
223       }
224 
225       switch (PetscOptionsObject.next->type) {
226         case OPTION_HEAD:
227           break;
228         case OPTION_INT:
229           sprintf(value,"%d",(int) *(PetscInt*)PetscOptionsObject.next->data);
230           break;
231         case OPTION_REAL:
232           sprintf(value,"%g",(double) *(PetscReal*)PetscOptionsObject.next->data);
233           break;
234         case OPTION_REAL_ARRAY:
235           sprintf(value,"%g",(double)((PetscReal*)PetscOptionsObject.next->data)[0]);
236           for (j=1; j<PetscOptionsObject.next->arraylength; j++) {
237             sprintf(tmp,"%g",(double)((PetscReal*)PetscOptionsObject.next->data)[j]);
238             ierr = PetscStrcat(value,",");CHKERRQ(ierr);
239             ierr = PetscStrcat(value,tmp);CHKERRQ(ierr);
240           }
241           break;
242         case OPTION_LOGICAL:
243           sprintf(value,"%d",(int)*(PetscInt*)PetscOptionsObject.next->data);
244           break;
245         case OPTION_LIST:
246           ierr = PetscStrcpy(value,*(char**)PetscOptionsObject.next->data);CHKERRQ(ierr);
247           break;
248         case OPTION_STRING: /* also handles string arrays */
249           ierr = PetscStrcpy(value,*(char**)PetscOptionsObject.next->data);CHKERRQ(ierr);
250           break;
251       }
252       ierr = PetscOptionsSetValue(option,value);CHKERRQ(ierr);
253     }
254     ierr   = PetscStrfree(PetscOptionsObject.next->text);CHKERRQ(ierr);
255     ierr   = PetscStrfree(PetscOptionsObject.next->option);CHKERRQ(ierr);
256     ierr   = PetscFree(PetscOptionsObject.next->man);CHKERRQ(ierr);
257     ierr   = PetscFree(PetscOptionsObject.next->data);CHKERRQ(ierr);
258     ierr   = PetscFree(PetscOptionsObject.next->edata);CHKERRQ(ierr);
259     last                    = PetscOptionsObject.next;
260     PetscOptionsObject.next = PetscOptionsObject.next->next;
261     ierr                    = PetscFree(last);CHKERRQ(ierr);
262   }
263   PetscOptionsObject.next = 0;
264   PetscFunctionReturn(0);
265 }
266 
267 #undef __FUNCT__
268 #define __FUNCT__ "PetscOptionsEnum"
269 /*@C
270    PetscOptionsEnum - Gets the enum value for a particular option in the database.
271 
272    Collective on the communicator passed in PetscOptionsBegin()
273 
274    Input Parameters:
275 +  opt - option name
276 .  text - short string that describes the option
277 .  man - manual page with additional information on option
278 .  list - array containing the list of choices, followed by the enum name, followed by the enum prefix, followed by a null
279 -  defaultv - the default (current) value
280 
281    Output Parameter:
282 +  value - the  value to return
283 -  flg - PETSC_TRUE if found, else PETSC_FALSE
284 
285    Level: beginner
286 
287    Concepts: options database
288 
289    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
290 
291           list is usually something like PCASMTypes or some other predefined list of enum names
292 
293 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
294           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth()
295           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(),
296           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
297           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
298           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
299           PetscOptionsList(), PetscOptionsEList()
300 @*/
301 PetscErrorCode PETSC_DLLEXPORT PetscOptionsEnum(const char opt[],const char text[],const char man[],const char **list,PetscEnum defaultv,PetscEnum *value,PetscTruth *set)
302 {
303   PetscErrorCode ierr;
304   PetscInt       ntext = 0;
305   PetscInt       tval;
306   PetscTruth     tflg;
307 
308   PetscFunctionBegin;
309   while (list[ntext++]) {
310     if (ntext > 50) SETERRQ(PETSC_ERR_ARG_WRONG,"List argument appears to be wrong or have more than 50 entries");
311   }
312   if (ntext < 3) SETERRQ(PETSC_ERR_ARG_WRONG,"List argument must have at least two entries: typename and type prefix");
313   ntext -= 3;
314   ierr = PetscOptionsEList(opt,text,man,list,ntext,list[defaultv],&tval,&tflg);CHKERRQ(ierr);
315   /* with PETSC_USE_64BIT_INDICES sizeof(PetscInt) != sizeof(PetscEnum) */
316   if (tflg) *value = (PetscEnum)tval;
317   if (set)  *set   = tflg;
318   PetscFunctionReturn(0);
319 }
320 
321 /* -------------------------------------------------------------------------------------------------------------*/
322 #undef __FUNCT__
323 #define __FUNCT__ "PetscOptionsInt"
324 /*@C
325    PetscOptionsInt - Gets the integer value for a particular option in the database.
326 
327    Collective on the communicator passed in PetscOptionsBegin()
328 
329    Input Parameters:
330 +  opt - option name
331 .  text - short string that describes the option
332 .  man - manual page with additional information on option
333 -  defaultv - the default (current) value
334 
335    Output Parameter:
336 +  value - the integer value to return
337 -  flg - PETSC_TRUE if found, else PETSC_FALSE
338 
339    Level: beginner
340 
341    Concepts: options database^has int
342 
343    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
344 
345 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
346           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth()
347           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(),
348           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
349           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
350           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
351           PetscOptionsList(), PetscOptionsEList()
352 @*/
353 PetscErrorCode PETSC_DLLEXPORT PetscOptionsInt(const char opt[],const char text[],const char man[],PetscInt defaultv,PetscInt *value,PetscTruth *set)
354 {
355   PetscErrorCode ierr;
356   PetscOptions   amsopt;
357 
358   PetscFunctionBegin;
359   if (PetscOptionsPublishCount == 1) {
360     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_INT,&amsopt);CHKERRQ(ierr);
361     ierr = PetscMalloc(sizeof(PetscInt),&amsopt->data);CHKERRQ(ierr);
362     *(PetscInt*)amsopt->data = defaultv;
363   }
364   ierr = PetscOptionsGetInt(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr);
365   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
366     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%d>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,man);CHKERRQ(ierr);
367   }
368   PetscFunctionReturn(0);
369 }
370 
371 #undef __FUNCT__
372 #define __FUNCT__ "PetscOptionsString"
373 /*@C
374    PetscOptionsString - Gets the string value for a particular option in the database.
375 
376    Collective on the communicator passed in PetscOptionsBegin()
377 
378    Input Parameters:
379 +  opt - option name
380 .  text - short string that describes the option
381 .  man - manual page with additional information on option
382 -  defaultv - the default (current) value
383 
384    Output Parameter:
385 +  value - the value to return
386 -  flg - PETSC_TRUE if found, else PETSC_FALSE
387 
388    Level: beginner
389 
390    Concepts: options database^has int
391 
392    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
393 
394 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
395           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth()
396           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(),
397           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
398           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
399           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
400           PetscOptionsList(), PetscOptionsEList()
401 @*/
402 PetscErrorCode PETSC_DLLEXPORT PetscOptionsString(const char opt[],const char text[],const char man[],const char defaultv[],char value[],size_t len,PetscTruth *set)
403 {
404   PetscErrorCode ierr;
405 
406   PetscFunctionBegin;
407   ierr = PetscOptionsGetString(PetscOptionsObject.prefix,opt,value,len,set);CHKERRQ(ierr);
408   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
409     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%s>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,man);CHKERRQ(ierr);
410   }
411   PetscFunctionReturn(0);
412 }
413 
414 /*
415      Publishes an AMS double field (with the default value in it) and with a name
416    given by the text string
417 */
418 #undef __FUNCT__
419 #define __FUNCT__ "PetscOptionsReal"
420 /*@C
421    PetscOptionsReal - Gets the PetscReal value for a particular option in the database.
422 
423    Collective on the communicator passed in PetscOptionsBegin()
424 
425    Input Parameters:
426 +  opt - option name
427 .  text - short string that describes the option
428 .  man - manual page with additional information on option
429 -  defaultv - the default (current) value
430 
431    Output Parameter:
432 +  value - the value to return
433 -  flg - PETSC_TRUE if found, else PETSC_FALSE
434 
435    Level: beginner
436 
437    Concepts: options database^has int
438 
439    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
440 
441 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
442           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth()
443           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(),
444           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
445           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
446           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
447           PetscOptionsList(), PetscOptionsEList()
448 @*/
449 PetscErrorCode PETSC_DLLEXPORT PetscOptionsReal(const char opt[],const char text[],const char man[],PetscReal defaultv,PetscReal *value,PetscTruth *set)
450 {
451   PetscErrorCode ierr;
452 
453   PetscFunctionBegin;
454   ierr = PetscOptionsGetReal(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr);
455   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
456     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%G>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv,text,man);CHKERRQ(ierr);
457   }
458   PetscFunctionReturn(0);
459 }
460 
461 #undef __FUNCT__
462 #define __FUNCT__ "PetscOptionsScalar"
463 /*@C
464    PetscOptionsScalar - Gets the scalar value for a particular option in the database.
465 
466    Collective on the communicator passed in PetscOptionsBegin()
467 
468    Input Parameters:
469 +  opt - option name
470 .  text - short string that describes the option
471 .  man - manual page with additional information on option
472 -  defaultv - the default (current) value
473 
474    Output Parameter:
475 +  value - the value to return
476 -  flg - PETSC_TRUE if found, else PETSC_FALSE
477 
478    Level: beginner
479 
480    Concepts: options database^has int
481 
482    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
483 
484 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
485           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth()
486           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(),
487           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
488           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
489           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
490           PetscOptionsList(), PetscOptionsEList()
491 @*/
492 PetscErrorCode PETSC_DLLEXPORT PetscOptionsScalar(const char opt[],const char text[],const char man[],PetscScalar defaultv,PetscScalar *value,PetscTruth *set)
493 {
494   PetscErrorCode ierr;
495 
496   PetscFunctionBegin;
497 #if !defined(PETSC_USE_COMPLEX)
498   ierr = PetscOptionsReal(opt,text,man,defaultv,value,set);CHKERRQ(ierr);
499 #else
500   ierr = PetscOptionsGetScalar(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr);
501 #endif
502   PetscFunctionReturn(0);
503 }
504 
505 /*
506      Publishes an AMS logical field (with the default value in it) and with a name
507    given by the text string
508 */
509 #undef __FUNCT__
510 #define __FUNCT__ "PetscOptionsName"
511 /*@C
512    PetscOptionsName - Determines if a particular option is in the database
513 
514    Collective on the communicator passed in PetscOptionsBegin()
515 
516    Input Parameters:
517 +  opt - option name
518 .  text - short string that describes the option
519 -  man - manual page with additional information on option
520 
521    Output Parameter:
522 .  flg - PETSC_TRUE if found, else PETSC_FALSE
523 
524    Level: beginner
525 
526    Concepts: options database^has int
527 
528    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
529 
530 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
531           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth()
532           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(),
533           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
534           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
535           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
536           PetscOptionsList(), PetscOptionsEList()
537 @*/
538 PetscErrorCode PETSC_DLLEXPORT PetscOptionsName(const char opt[],const char text[],const char man[],PetscTruth *flg)
539 {
540   PetscErrorCode ierr;
541 
542   PetscFunctionBegin;
543   ierr = PetscOptionsHasName(PetscOptionsObject.prefix,opt,flg);CHKERRQ(ierr);
544   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
545     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr);
546   }
547   PetscFunctionReturn(0);
548 }
549 
550 #undef __FUNCT__
551 #define __FUNCT__ "PetscOptionsList"
552 /*@C
553      PetscOptionsList - Puts a list of option values that a single one may be selected from
554 
555    Collective on the communicator passed in PetscOptionsBegin()
556 
557    Input Parameters:
558 +  opt - option name
559 .  text - short string that describes the option
560 .  man - manual page with additional information on option
561 .  list - the possible choices
562 -  defaultv - the default (current) value
563 
564    Output Parameter:
565 +  value - the value to return
566 -  set - PETSC_TRUE if found, else PETSC_FALSE
567 
568    Level: intermediate
569 
570    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
571 
572    See PetscOptionsEList() for when the choices are given in a string array
573 
574    To get a listing of all currently specified options,
575     see PetscOptionsPrint() or PetscOptionsGetAll()
576 
577    Concepts: options database^list
578 
579 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
580            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
581           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
582           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
583           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
584           PetscOptionsList(), PetscOptionsEList()
585 @*/
586 PetscErrorCode PETSC_DLLEXPORT PetscOptionsList(const char opt[],const char ltext[],const char man[],PetscFList list,const char defaultv[],char value[],PetscInt len,PetscTruth *set)
587 {
588   PetscErrorCode ierr;
589 
590   PetscFunctionBegin;
591   ierr = PetscOptionsGetString(PetscOptionsObject.prefix,opt,value,len,set);CHKERRQ(ierr);
592   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
593     ierr = PetscFListPrintTypes(list,PetscOptionsObject.comm,stdout,PetscOptionsObject.prefix,opt,ltext,man);CHKERRQ(ierr);CHKERRQ(ierr);
594   }
595   PetscFunctionReturn(0);
596 }
597 
598 #undef __FUNCT__
599 #define __FUNCT__ "PetscOptionsEList"
600 /*@C
601      PetscOptionsEList - Puts a list of option values that a single one may be selected from
602 
603    Collective on the communicator passed in PetscOptionsBegin()
604 
605    Input Parameters:
606 +  opt - option name
607 .  ltext - short string that describes the option
608 .  man - manual page with additional information on option
609 .  list - the possible choices
610 .  ntext - number of choices
611 -  defaultv - the default (current) value
612 
613    Output Parameter:
614 +  value - the index of the value to return
615 -  set - PETSC_TRUE if found, else PETSC_FALSE
616 
617    Level: intermediate
618 
619    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
620 
621    See PetscOptionsList() for when the choices are given in a PetscFList()
622 
623    Concepts: options database^list
624 
625 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
626            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
627           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
628           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
629           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
630           PetscOptionsList(), PetscOptionsEList()
631 @*/
632 PetscErrorCode PETSC_DLLEXPORT PetscOptionsEList(const char opt[],const char ltext[],const char man[],const char **list,PetscInt ntext,const char defaultv[],PetscInt *value,PetscTruth *set)
633 {
634   PetscErrorCode ierr;
635   PetscInt       i;
636 
637   PetscFunctionBegin;
638   ierr = PetscOptionsGetEList(PetscOptionsObject.prefix,opt,list,ntext,value,set);CHKERRQ(ierr);
639   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
640     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%s> (choose one of)",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv);CHKERRQ(ierr);
641     for (i=0; i<ntext; i++){
642       ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," %s",list[i]);CHKERRQ(ierr);
643     }
644     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"\n");CHKERRQ(ierr);
645   }
646   PetscFunctionReturn(0);
647 }
648 
649 #undef __FUNCT__
650 #define __FUNCT__ "PetscOptionsTruthGroupBegin"
651 /*@C
652      PetscOptionsTruthGroupBegin - First in a series of logical queries on the options database for
653        which only a single value can be true.
654 
655    Collective on the communicator passed in PetscOptionsBegin()
656 
657    Input Parameters:
658 +  opt - option name
659 .  text - short string that describes the option
660 -  man - manual page with additional information on option
661 
662    Output Parameter:
663 .  flg - whether that option was set or not
664 
665    Level: intermediate
666 
667    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
668 
669    Must be followed by 0 or more PetscOptionsTruthGroup()s and PetscOptionsTruthGroupEnd()
670 
671     Concepts: options database^logical group
672 
673 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
674            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
675           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
676           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
677           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
678           PetscOptionsList(), PetscOptionsEList()
679 @*/
680 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroupBegin(const char opt[],const char text[],const char man[],PetscTruth *flg)
681 {
682   PetscErrorCode ierr;
683 
684   PetscFunctionBegin;
685   ierr = PetscOptionsHasName(PetscOptionsObject.prefix,opt,flg);CHKERRQ(ierr);
686   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
687     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  Pick at most one of -------------\n");CHKERRQ(ierr);
688     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"    -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr);
689   }
690   PetscFunctionReturn(0);
691 }
692 
693 #undef __FUNCT__
694 #define __FUNCT__ "PetscOptionsTruthGroup"
695 /*@C
696      PetscOptionsTruthGroup - One in a series of logical queries on the options database for
697        which only a single value can be true.
698 
699    Collective on the communicator passed in PetscOptionsBegin()
700 
701    Input Parameters:
702 +  opt - option name
703 .  text - short string that describes the option
704 -  man - manual page with additional information on option
705 
706    Output Parameter:
707 .  flg - PETSC_TRUE if found, else PETSC_FALSE
708 
709    Level: intermediate
710 
711    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
712 
713    Must follow a PetscOptionsTruthGroupBegin() and preceded a PetscOptionsTruthGroupEnd()
714 
715     Concepts: options database^logical group
716 
717 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
718            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
719           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
720           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
721           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
722           PetscOptionsList(), PetscOptionsEList()
723 @*/
724 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroup(const char opt[],const char text[],const char man[],PetscTruth *flg)
725 {
726   PetscErrorCode ierr;
727 
728   PetscFunctionBegin;
729   ierr = PetscOptionsHasName(PetscOptionsObject.prefix,opt,flg);CHKERRQ(ierr);
730   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
731     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"    -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr);
732   }
733   PetscFunctionReturn(0);
734 }
735 
736 #undef __FUNCT__
737 #define __FUNCT__ "PetscOptionsTruthGroupEnd"
738 /*@C
739      PetscOptionsTruthGroupEnd - Last in a series of logical queries on the options database for
740        which only a single value can be true.
741 
742    Collective on the communicator passed in PetscOptionsBegin()
743 
744    Input Parameters:
745 +  opt - option name
746 .  text - short string that describes the option
747 -  man - manual page with additional information on option
748 
749    Output Parameter:
750 .  flg - PETSC_TRUE if found, else PETSC_FALSE
751 
752    Level: intermediate
753 
754    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
755 
756    Must follow a PetscOptionsTruthGroupBegin()
757 
758     Concepts: options database^logical group
759 
760 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
761            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
762           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
763           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
764           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
765           PetscOptionsList(), PetscOptionsEList()
766 @*/
767 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroupEnd(const char opt[],const char text[],const char man[],PetscTruth *flg)
768 {
769   PetscErrorCode ierr;
770 
771   PetscFunctionBegin;
772   ierr = PetscOptionsHasName(PetscOptionsObject.prefix,opt,flg);CHKERRQ(ierr);
773   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
774     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"    -%s%s: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr);
775   }
776   PetscFunctionReturn(0);
777 }
778 
779 #undef __FUNCT__
780 #define __FUNCT__ "PetscOptionsTruth"
781 /*@C
782    PetscOptionsTruth - Determines if a particular option is in the database with a true or false
783 
784    Collective on the communicator passed in PetscOptionsBegin()
785 
786    Input Parameters:
787 +  opt - option name
788 .  text - short string that describes the option
789 -  man - manual page with additional information on option
790 
791    Output Parameter:
792 .  flg - PETSC_TRUE or PETSC_FALSE
793 .  set - PETSC_TRUE if found, else PETSC_FALSE
794 
795    Level: beginner
796 
797    Concepts: options database^logical
798 
799    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
800 
801 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
802           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth()
803           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(),
804           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
805           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
806           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
807           PetscOptionsList(), PetscOptionsEList()
808 @*/
809 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruth(const char opt[],const char text[],const char man[],PetscTruth deflt,PetscTruth *flg,PetscTruth *set)
810 {
811   PetscErrorCode ierr;
812   PetscTruth     iset;
813 
814   PetscFunctionBegin;
815   ierr = PetscOptionsGetTruth(PetscOptionsObject.prefix,opt,flg,&iset);CHKERRQ(ierr);
816   if (!iset) {
817     if (flg) *flg = deflt;
818   }
819   if (set) *set = iset;
820   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
821     const char *v = PetscTruths[deflt];
822     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s: <%s> %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,v,text,man);CHKERRQ(ierr);
823   }
824   PetscFunctionReturn(0);
825 }
826 
827 #undef __FUNCT__
828 #define __FUNCT__ "PetscOptionsRealArray"
829 /*@C
830    PetscOptionsRealArray - Gets an array of double values for a particular
831    option in the database. The values must be separated with commas with
832    no intervening spaces.
833 
834    Collective on the communicator passed in PetscOptionsBegin()
835 
836    Input Parameters:
837 +  opt - the option one is seeking
838 .  text - short string describing option
839 .  man - manual page for option
840 -  nmax - maximum number of values
841 
842    Output Parameter:
843 +  value - location to copy values
844 .  nmax - actual number of values found
845 -  set - PETSC_TRUE if found, else PETSC_FALSE
846 
847    Level: beginner
848 
849    Notes:
850    The user should pass in an array of doubles
851 
852    Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
853 
854    Concepts: options database^array of strings
855 
856 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
857            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
858           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
859           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
860           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
861           PetscOptionsList(), PetscOptionsEList()
862 @*/
863 PetscErrorCode PETSC_DLLEXPORT PetscOptionsRealArray(const char opt[],const char text[],const char man[],PetscReal value[],PetscInt *n,PetscTruth *set)
864 {
865   PetscErrorCode ierr;
866   PetscInt       i;
867 
868   PetscFunctionBegin;
869   ierr = PetscOptionsGetRealArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr);
870   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
871     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%G",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr);
872     for (i=1; i<*n; i++) {
873       ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%G",value[i]);CHKERRQ(ierr);
874     }
875     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr);
876   }
877   PetscFunctionReturn(0);
878 }
879 
880 
881 #undef __FUNCT__
882 #define __FUNCT__ "PetscOptionsIntArray"
883 /*@C
884    PetscOptionsIntArray - Gets an array of integers for a particular
885    option in the database. The values must be separated with commas with
886    no intervening spaces.
887 
888    Collective on the communicator passed in PetscOptionsBegin()
889 
890    Input Parameters:
891 +  opt - the option one is seeking
892 .  text - short string describing option
893 .  man - manual page for option
894 -  n - maximum number of values
895 
896    Output Parameter:
897 +  value - location to copy values
898 .  n - actual number of values found
899 -  set - PETSC_TRUE if found, else PETSC_FALSE
900 
901    Level: beginner
902 
903    Notes:
904    The user should pass in an array of integers
905 
906    Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
907 
908    Concepts: options database^array of strings
909 
910 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
911            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
912           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
913           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
914           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
915           PetscOptionsList(), PetscOptionsEList(), PetscOptionsRealArray()
916 @*/
917 PetscErrorCode PETSC_DLLEXPORT PetscOptionsIntArray(const char opt[],const char text[],const char man[],PetscInt value[],PetscInt *n,PetscTruth *set)
918 {
919   PetscErrorCode ierr;
920   PetscInt       i;
921 
922   PetscFunctionBegin;
923   ierr = PetscOptionsGetIntArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr);
924   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
925     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%d",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr);
926     for (i=1; i<*n; i++) {
927       ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%d",value[i]);CHKERRQ(ierr);
928     }
929     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr);
930   }
931   PetscFunctionReturn(0);
932 }
933 
934 #undef __FUNCT__
935 #define __FUNCT__ "PetscOptionsStringArray"
936 /*@C
937    PetscOptionsStringArray - Gets an array of string values for a particular
938    option in the database. The values must be separated with commas with
939    no intervening spaces.
940 
941    Collective on the communicator passed in PetscOptionsBegin()
942 
943    Input Parameters:
944 +  opt - the option one is seeking
945 .  text - short string describing option
946 .  man - manual page for option
947 -  nmax - maximum number of strings
948 
949    Output Parameter:
950 +  value - location to copy strings
951 .  nmax - actual number of strings found
952 -  set - PETSC_TRUE if found, else PETSC_FALSE
953 
954    Level: beginner
955 
956    Notes:
957    The user should pass in an array of pointers to char, to hold all the
958    strings returned by this function.
959 
960    The user is responsible for deallocating the strings that are
961    returned. The Fortran interface for this routine is not supported.
962 
963    Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
964 
965    Concepts: options database^array of strings
966 
967 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
968            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
969           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
970           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
971           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
972           PetscOptionsList(), PetscOptionsEList()
973 @*/
974 PetscErrorCode PETSC_DLLEXPORT PetscOptionsStringArray(const char opt[],const char text[],const char man[],char *value[],PetscInt *nmax,PetscTruth *set)
975 {
976   PetscErrorCode ierr;
977 
978   PetscFunctionBegin;
979   ierr = PetscOptionsGetStringArray(PetscOptionsObject.prefix,opt,value,nmax,set);CHKERRQ(ierr);
980   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
981     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <string1,string2,...>: %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,text,man);CHKERRQ(ierr);
982   }
983   PetscFunctionReturn(0);
984 }
985 
986 #undef __FUNCT__
987 #define __FUNCT__ "PetscOptionsTruthArray"
988 /*@C
989    PetscOptionsTruthArray - Gets an array of logical values (true or false) for a particular
990    option in the database. The values must be separated with commas with
991    no intervening spaces.
992 
993    Collective on the communicator passed in PetscOptionsBegin()
994 
995    Input Parameters:
996 +  opt - the option one is seeking
997 .  text - short string describing option
998 .  man - manual page for option
999 -  nmax - maximum number of values
1000 
1001    Output Parameter:
1002 +  value - location to copy values
1003 .  nmax - actual number of values found
1004 -  set - PETSC_TRUE if found, else PETSC_FALSE
1005 
1006    Level: beginner
1007 
1008    Notes:
1009    The user should pass in an array of doubles
1010 
1011    Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1012 
1013    Concepts: options database^array of strings
1014 
1015 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1016            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
1017           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1018           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1019           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
1020           PetscOptionsList(), PetscOptionsEList()
1021 @*/
1022 PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthArray(const char opt[],const char text[],const char man[],PetscTruth value[],PetscInt *n,PetscTruth *set)
1023 {
1024   PetscErrorCode ierr;
1025   PetscInt       i;
1026 
1027   PetscFunctionBegin;
1028   ierr = PetscOptionsGetTruthArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr);
1029   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
1030     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  -%s%s <%d",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr);
1031     for (i=1; i<*n; i++) {
1032       ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%d",value[i]);CHKERRQ(ierr);
1033     }
1034     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,man);CHKERRQ(ierr);
1035   }
1036   PetscFunctionReturn(0);
1037 }
1038 
1039 
1040 #undef __FUNCT__
1041 #define __FUNCT__ "PetscOptionsHead"
1042 /*@C
1043      PetscOptionsHead - Puts a heading before listing any more published options. Used, for example,
1044             in KSPSetFromOptions_GMRES().
1045 
1046    Collective on the communicator passed in PetscOptionsBegin()
1047 
1048    Input Parameter:
1049 .   head - the heading text
1050 
1051 
1052    Level: intermediate
1053 
1054    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
1055 
1056           Can be followed by a call to PetscOptionsTail() in the same function.
1057 
1058    Concepts: options database^subheading
1059 
1060 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
1061            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
1062           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
1063           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
1064           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
1065           PetscOptionsList(), PetscOptionsEList()
1066 @*/
1067 PetscErrorCode PETSC_DLLEXPORT PetscOptionsHead(const char head[])
1068 {
1069   PetscErrorCode ierr;
1070 
1071   PetscFunctionBegin;
1072   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
1073     ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,"  %s\n",head);CHKERRQ(ierr);
1074   }
1075   PetscFunctionReturn(0);
1076 }
1077 
1078 
1079 
1080 
1081 
1082 
1083