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