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