xref: /petsc/include/petscoptions.h (revision 1ff8fb82e9f69978a6ddf457dc8492d10c815e2e)
1f26ada1bSBarry Smith /*
237f753daSBarry Smith    Routines to determine options set in the options database.
3f26ada1bSBarry Smith */
4a4963045SJacob Faibussowitsch #pragma once
5ac09b921SBarry Smith 
62c8e378dSBarry Smith #include <petscsys.h>
7c619b03eSJed Brown #include <petscviewertypes.h>
83a3b2205SBarry Smith 
9ac09b921SBarry Smith /* SUBMANSEC = Sys */
10ac09b921SBarry Smith 
119355ec05SMatthew G. Knepley typedef enum {
129355ec05SMatthew G. Knepley   PETSC_OPT_CODE,
139355ec05SMatthew G. Knepley   PETSC_OPT_COMMAND_LINE,
149355ec05SMatthew G. Knepley   PETSC_OPT_FILE,
159355ec05SMatthew G. Knepley   PETSC_OPT_ENVIRONMENT,
169355ec05SMatthew G. Knepley   NUM_PETSC_OPT_SOURCE
179355ec05SMatthew G. Knepley } PetscOptionSource;
189355ec05SMatthew G. Knepley 
19c5c1f447SLisandro Dalcin #define PETSC_MAX_OPTION_NAME 512
20c5929fdfSBarry Smith typedef struct _n_PetscOptions *PetscOptions;
21c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode     PetscOptionsCreate(PetscOptions *);
22b4205f0bSBarry Smith PETSC_EXTERN PetscErrorCode     PetscOptionsPush(PetscOptions);
23b4205f0bSBarry Smith PETSC_EXTERN PetscErrorCode     PetscOptionsPop(void);
24c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode     PetscOptionsDestroy(PetscOptions *);
252d747510SLisandro Dalcin PETSC_EXTERN PetscErrorCode     PetscOptionsCreateDefault(void);
262d747510SLisandro Dalcin PETSC_EXTERN PetscErrorCode     PetscOptionsDestroyDefault(void);
27c5929fdfSBarry Smith 
282d747510SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsHasHelp(PetscOptions, PetscBool *);
29c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsHasName(PetscOptions, const char[], const char[], PetscBool *);
30c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsGetBool(PetscOptions, const char[], const char[], PetscBool *, PetscBool *);
312d747510SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsGetInt(PetscOptions, const char[], const char[], PetscInt *, PetscBool *);
322d747510SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsGetEnum(PetscOptions, const char[], const char[], const char *const *, PetscEnum *, PetscBool *);
332d747510SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsGetEList(PetscOptions, const char[], const char[], const char *const *, PetscInt, PetscInt *, PetscBool *);
34c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsGetReal(PetscOptions, const char[], const char[], PetscReal *, PetscBool *);
35c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsGetScalar(PetscOptions, const char[], const char[], PetscScalar *, PetscBool *);
362d747510SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsGetString(PetscOptions, const char[], const char[], char[], size_t, PetscBool *);
372d747510SLisandro Dalcin 
382d747510SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsGetBoolArray(PetscOptions, const char[], const char[], PetscBool[], PetscInt *, PetscBool *);
392d747510SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsGetEnumArray(PetscOptions, const char[], const char[], const char *const *, PetscEnum *, PetscInt *, PetscBool *);
40c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsGetIntArray(PetscOptions, const char[], const char[], PetscInt[], PetscInt *, PetscBool *);
41c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsGetRealArray(PetscOptions, const char[], const char[], PetscReal[], PetscInt *, PetscBool *);
42c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsGetScalarArray(PetscOptions, const char[], const char[], PetscScalar[], PetscInt *, PetscBool *);
43c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsGetStringArray(PetscOptions, const char[], const char[], char *[], PetscInt *, PetscBool *);
443a3b2205SBarry Smith 
452d747510SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsValidKey(const char[], PetscBool *);
46c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsSetAlias(PetscOptions, const char[], const char[]);
47c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsSetValue(PetscOptions, const char[], const char[]);
48c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsClearValue(PetscOptions, const char[]);
492d747510SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsFindPair(PetscOptions, const char[], const char[], const char *[], PetscBool *);
503a3b2205SBarry Smith 
512d747510SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsGetAll(PetscOptions, char *[]);
52c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsAllUsed(PetscOptions, PetscInt *);
532d747510SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsUsed(PetscOptions, const char[], PetscBool *);
54c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsLeft(PetscOptions);
551ab23d95SFande Kong PETSC_EXTERN PetscErrorCode PetscOptionsLeftGet(PetscOptions, PetscInt *, char ***, char ***);
565b191818SFande Kong PETSC_EXTERN PetscErrorCode PetscOptionsLeftRestore(PetscOptions, PetscInt *, char ***, char ***);
57c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsView(PetscOptions, PetscViewer);
584b0e389bSBarry Smith 
592d747510SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsReject(PetscOptions, const char[], const char[], const char[]);
60c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsInsert(PetscOptions, int *, char ***, const char[]);
61c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsInsertFile(MPI_Comm, PetscOptions, const char[], PetscBool);
625c23ca1cSLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsInsertFileYAML(MPI_Comm, PetscOptions, const char[], PetscBool);
63c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsInsertString(PetscOptions, const char[]);
64080f0011SToby Isaac PETSC_EXTERN PetscErrorCode PetscOptionsInsertStringYAML(PetscOptions, const char[]);
65d06005cbSLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsInsertArgs(PetscOptions, int, char **);
66c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsClear(PetscOptions);
67c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsPrefixPush(PetscOptions, const char[]);
68c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsPrefixPop(PetscOptions);
695d0dffe5SBarry Smith 
70014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscOptionsGetenv(MPI_Comm, const char[], char[], size_t, PetscBool *);
712d747510SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsStringToBool(const char[], PetscBool *);
72014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscOptionsStringToInt(const char[], PetscInt *);
73014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscOptionsStringToReal(const char[], PetscReal *);
742d747510SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsStringToScalar(const char[], PetscScalar *);
752e8a6d31SBarry Smith 
769355ec05SMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscOptionsMonitorSet(PetscErrorCode (*)(const char[], const char[], PetscOptionSource, void *), void *, PetscErrorCode (*)(void **));
779355ec05SMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscOptionsMonitorDefault(const char[], const char[], PetscOptionSource, void *);
78081c24baSBoyana Norris 
7984761bfeSJed Brown PETSC_EXTERN PetscErrorCode PetscObjectSetOptions(PetscObject, PetscOptions);
8084761bfeSJed Brown PETSC_EXTERN PetscErrorCode PetscObjectGetOptions(PetscObject, PetscOptions *);
8184761bfeSJed Brown 
82014dd563SJed Brown PETSC_EXTERN PetscBool PetscOptionsPublish;
83e55864a3SBarry Smith 
84e55864a3SBarry Smith /*
85e55864a3SBarry Smith     See manual page for PetscOptionsBegin()
864416b707SBarry Smith 
874416b707SBarry Smith     PetscOptionsItem and PetscOptionsItems are a single option (such as ksp_type) and a collection of such single
884416b707SBarry Smith   options being handled with a PetscOptionsBegin/End()
894416b707SBarry Smith 
90e55864a3SBarry Smith */
919371c9d4SSatish Balay typedef enum {
929371c9d4SSatish Balay   OPTION_INT,
939371c9d4SSatish Balay   OPTION_BOOL,
949371c9d4SSatish Balay   OPTION_REAL,
959371c9d4SSatish Balay   OPTION_FLIST,
969371c9d4SSatish Balay   OPTION_STRING,
979371c9d4SSatish Balay   OPTION_REAL_ARRAY,
989371c9d4SSatish Balay   OPTION_SCALAR_ARRAY,
999371c9d4SSatish Balay   OPTION_HEAD,
1009371c9d4SSatish Balay   OPTION_INT_ARRAY,
1019371c9d4SSatish Balay   OPTION_ELIST,
1029371c9d4SSatish Balay   OPTION_BOOL_ARRAY,
1039371c9d4SSatish Balay   OPTION_STRING_ARRAY
1049371c9d4SSatish Balay } PetscOptionType;
1059355ec05SMatthew G. Knepley 
1064416b707SBarry Smith typedef struct _n_PetscOptionItem *PetscOptionItem;
1074416b707SBarry Smith struct _n_PetscOptionItem {
108e55864a3SBarry Smith   char              *option;
109e55864a3SBarry Smith   char              *text;
110e55864a3SBarry Smith   void              *data;  /* used to hold the default value and then any value it is changed to by GUI */
111e55864a3SBarry Smith   PetscFunctionList  flist; /* used for available values for PetscOptionsList() */
112e55864a3SBarry Smith   const char *const *list;  /* used for available values for PetscOptionsEList() */
113e55864a3SBarry Smith   char               nlist; /* number of entries in list */
114e55864a3SBarry Smith   char              *man;
115e55864a3SBarry Smith   size_t             arraylength; /* number of entries in data in the case that it is an array (of PetscInt etc) */
116e55864a3SBarry Smith   PetscBool          set;         /* the user has changed this value in the GUI */
117e55864a3SBarry Smith   PetscOptionType    type;
1184416b707SBarry Smith   PetscOptionItem    next;
119e55864a3SBarry Smith   char              *pman;
120e55864a3SBarry Smith   void              *edata;
121e55864a3SBarry Smith };
122e55864a3SBarry Smith 
1234416b707SBarry Smith typedef struct _p_PetscOptionItems {
124e55864a3SBarry Smith   PetscInt        count;
1254416b707SBarry Smith   PetscOptionItem next;
126e55864a3SBarry Smith   char           *prefix, *pprefix;
127e55864a3SBarry Smith   char           *title;
128e55864a3SBarry Smith   MPI_Comm        comm;
129e55864a3SBarry Smith   PetscBool       printhelp, changedmethod, alreadyprinted;
130e55864a3SBarry Smith   PetscObject     object;
131c5929fdfSBarry Smith   PetscOptions    options;
1324416b707SBarry Smith } PetscOptionItems;
13330de9b25SBarry Smith 
1345f80ce2aSJacob Faibussowitsch #if defined(PETSC_CLANG_STATIC_ANALYZER)
13594bad497SJacob Faibussowitsch extern PetscOptionItems *PetscOptionsObject; /* declare this so that the PetscOptions stubs work */
1365f80ce2aSJacob Faibussowitsch PetscErrorCode           PetscOptionsBegin(MPI_Comm, const char *, const char *, const char *);
1375f80ce2aSJacob Faibussowitsch PetscErrorCode           PetscObjectOptionsBegin(PetscObject);
1385f80ce2aSJacob Faibussowitsch PetscErrorCode           PetscOptionsEnd(void);
1395f80ce2aSJacob Faibussowitsch #else
14030de9b25SBarry Smith   /*MC
14130de9b25SBarry Smith     PetscOptionsBegin - Begins a set of queries on the options database that are related and should be
1421957e957SBarry Smith      displayed on the same window of a GUI that allows the user to set the options interactively. Often one should
14316a05f60SBarry Smith      use `PetscObjectOptionsBegin()` rather than this call.
14430de9b25SBarry Smith 
145f2ba6396SBarry Smith    Synopsis:
146aaa7dc30SBarry Smith     #include <petscoptions.h>
147f2ba6396SBarry Smith     PetscErrorCode PetscOptionsBegin(MPI_Comm comm,const char prefix[],const char title[],const char mansec[])
14830de9b25SBarry Smith 
149fb455bf4SPatrick Sanan     Collective
15030de9b25SBarry Smith 
15130de9b25SBarry Smith   Input Parameters:
15230de9b25SBarry Smith +   comm - communicator that shares GUI
15376280437SVaclav Hapla .   prefix - options prefix for all options displayed on window (optional)
15430de9b25SBarry Smith .   title - short descriptive text, for example "Krylov Solver Options"
15587497f52SBarry Smith -   mansec - section of manual pages for options, for example `KSP` (optional)
15630de9b25SBarry Smith 
15730de9b25SBarry Smith   Level: intermediate
15830de9b25SBarry Smith 
15995452b02SPatrick Sanan   Notes:
160d0609cedSBarry Smith     This is a macro that handles its own error checking, it does not return an error code.
161d0609cedSBarry Smith 
16287497f52SBarry Smith     The set of queries needs to be ended by a call to `PetscOptionsEnd()`.
163fb455bf4SPatrick Sanan 
16487497f52SBarry Smith     One can add subheadings with `PetscOptionsHeadBegin()`.
16530de9b25SBarry Smith 
16695452b02SPatrick Sanan   Developer Notes:
16716a05f60SBarry Smith       `PetscOptionsPublish` is set in `PetscOptionsCheckInitial_Private()` with `-saws_options`. When `PetscOptionsPublish` is set the
16816a05f60SBarry Smith       loop between `PetscOptionsBegin()` and `PetscOptionsEnd()` is run THREE times with `PetscOptionsPublishCount` of values -1,0,1.
16916a05f60SBarry Smith       Otherwise the loop is run ONCE with a `PetscOptionsPublishCount` of 1.
17016a05f60SBarry Smith +      \-1 - `PetscOptionsInt()` etc. just call `PetscOptionsGetInt()` etc.
17116a05f60SBarry Smith .      0  - The GUI objects are created in `PetscOptionsInt()` etc. and displayed in `PetscOptionsEnd()` and the options
17216a05f60SBarry Smith                database updated with user changes; `PetscOptionsGetInt()` etc. are also called.
17316a05f60SBarry Smith -      1 - `PetscOptionsInt()` etc. again call `PetscOptionsGetInt()` etc. (possibly getting new values), in addition the help message and
174fb455bf4SPatrick Sanan               default values are printed if -help was given.
17516a05f60SBarry Smith       When `PetscOptionsObject.changedmethod` is set this causes `PetscOptionsPublishCount` to be reset to -2 (so in the next loop iteration it is -1)
17616a05f60SBarry Smith       and the whole process is repeated. This is to handle when, for example, the `KSPType` is changed thus changing the list of
17716a05f60SBarry Smith       options available so they need to be redisplayed so the user can change the. Changing `PetscOptionsObjects.changedmethod` is never
178fb455bf4SPatrick Sanan       currently set.
179aee2cecaSBarry Smith 
1804bb2516aSBarry Smith    Fortran Note:
1814bb2516aSBarry Smith    Returns ierr error code per PETSc Fortran API
1824bb2516aSBarry Smith 
183db781477SPatrick Sanan .seealso: `PetscOptionsGetReal()`, `PetscOptionsHasName()`, `PetscOptionsGetString()`, `PetscOptionsGetInt()`,
184db781477SPatrick Sanan           `PetscOptionsGetIntArray()`, `PetscOptionsGetRealArray()`, `PetscOptionsBool()`
185db781477SPatrick Sanan           `PetscOptionsInt()`, `PetscOptionsString()`, `PetscOptionsReal()`, `PetscOptionsBool()`,
186db781477SPatrick Sanan           `PetscOptionsName()`, `PetscOptionsEnd()`, `PetscOptionsHeadBegin()`,
187c2e3fba1SPatrick Sanan           `PetscOptionsStringArray()`, `PetscOptionsRealArray()`, `PetscOptionsScalar()`,
188db781477SPatrick Sanan           `PetscOptionsBoolGroupBegin()`, `PetscOptionsBoolGroup()`, `PetscOptionsBoolGroupEnd()`,
189db781477SPatrick Sanan           `PetscOptionsFList()`, `PetscOptionsEList()`, `PetscObjectOptionsBegin()`
19030de9b25SBarry Smith M*/
1919371c9d4SSatish Balay   #define PetscOptionsBegin(comm, prefix, mess, sec) \
1929371c9d4SSatish Balay     do { \
1934416b707SBarry Smith       PetscOptionItems  PetscOptionsObjectBase; \
1944416b707SBarry Smith       PetscOptionItems *PetscOptionsObject = &PetscOptionsObjectBase; \
195d0609cedSBarry Smith       PetscCall(PetscMemzero(PetscOptionsObject, sizeof(*PetscOptionsObject))); \
196e55864a3SBarry Smith       for (PetscOptionsObject->count = (PetscOptionsPublish ? -1 : 1); PetscOptionsObject->count < 2; PetscOptionsObject->count++) { \
1979566063dSJacob Faibussowitsch         PetscCall(PetscOptionsBegin_Private(PetscOptionsObject, comm, prefix, mess, sec))
19830de9b25SBarry Smith 
1995fefd1ebSJed Brown   /*MC
2005fefd1ebSJed Brown     PetscObjectOptionsBegin - Begins a set of queries on the options database that are related and should be
2015fefd1ebSJed Brown      displayed on the same window of a GUI that allows the user to set the options interactively.
2025fefd1ebSJed Brown 
203f2ba6396SBarry Smith    Synopsis:
204aaa7dc30SBarry Smith     #include <petscoptions.h>
205f2ba6396SBarry Smith     PetscErrorCode PetscObjectOptionsBegin(PetscObject obj)
2065fefd1ebSJed Brown 
207c3339decSBarry Smith     Collective
2085fefd1ebSJed Brown 
2092fe279fdSBarry Smith   Input Parameter:
2105fefd1ebSJed Brown .   obj - object to set options for
2115fefd1ebSJed Brown 
2125fefd1ebSJed Brown   Level: intermediate
2135fefd1ebSJed Brown 
21495452b02SPatrick Sanan   Notes:
215d0609cedSBarry Smith     This is a macro that handles its own error checking, it does not return an error code.
216d0609cedSBarry Smith 
21787497f52SBarry Smith     Needs to be ended by a call the `PetscOptionsEnd()`
218d0609cedSBarry Smith 
21987497f52SBarry Smith     Can add subheadings with `PetscOptionsHeadBegin()`
2205fefd1ebSJed Brown 
221db781477SPatrick Sanan .seealso: `PetscOptionsGetReal()`, `PetscOptionsHasName()`, `PetscOptionsGetString()`, `PetscOptionsGetInt()`,
222db781477SPatrick Sanan           `PetscOptionsGetIntArray()`, `PetscOptionsGetRealArray()`, `PetscOptionsBool()`
223db781477SPatrick Sanan           `PetscOptionsInt()`, `PetscOptionsString()`, `PetscOptionsReal()`, `PetscOptionsBool()`,
224db781477SPatrick Sanan           `PetscOptionsName()`, `PetscOptionsBegin()`, `PetscOptionsEnd()`, `PetscOptionsHeadBegin()`,
225c2e3fba1SPatrick Sanan           `PetscOptionsStringArray()`, `PetscOptionsRealArray()`, `PetscOptionsScalar()`,
226db781477SPatrick Sanan           `PetscOptionsBoolGroupBegin()`, `PetscOptionsBoolGroup()`, `PetscOptionsBoolGroupEnd()`,
227db781477SPatrick Sanan           `PetscOptionsFList()`, `PetscOptionsEList()`
2285fefd1ebSJed Brown M*/
2299371c9d4SSatish Balay   #define PetscObjectOptionsBegin(obj) \
2309371c9d4SSatish Balay     do { \
2314416b707SBarry Smith       PetscOptionItems  PetscOptionsObjectBase; \
2324416b707SBarry Smith       PetscOptionItems *PetscOptionsObject = &PetscOptionsObjectBase; \
233c5929fdfSBarry Smith       PetscOptionsObject->options          = ((PetscObject)obj)->options; \
234e55864a3SBarry Smith       for (PetscOptionsObject->count = (PetscOptionsPublish ? -1 : 1); PetscOptionsObject->count < 2; PetscOptionsObject->count++) { \
235dbbe0bcdSBarry Smith         PetscCall(PetscObjectOptionsBegin_Private(obj, PetscOptionsObject))
2363194b578SJed Brown 
23730de9b25SBarry Smith   /*MC
23830de9b25SBarry Smith     PetscOptionsEnd - Ends a set of queries on the options database that are related and should be
23930de9b25SBarry Smith      displayed on the same window of a GUI that allows the user to set the options interactively.
24030de9b25SBarry Smith 
241f2ba6396SBarry Smith    Synopsis:
242aaa7dc30SBarry Smith      #include <petscoptions.h>
243f2ba6396SBarry Smith      PetscErrorCode PetscOptionsEnd(void)
24430de9b25SBarry Smith 
2457cdbe19fSJose E. Roman     Collective on the comm used in `PetscOptionsBegin()` or obj used in `PetscObjectOptionsBegin()`
2467cdbe19fSJose E. Roman 
24730de9b25SBarry Smith   Level: intermediate
24830de9b25SBarry Smith 
24995452b02SPatrick Sanan   Notes:
25087497f52SBarry Smith     Needs to be preceded by a call to `PetscOptionsBegin()` or `PetscObjectOptionsBegin()`
25130de9b25SBarry Smith 
252d0609cedSBarry Smith     This is a macro that handles its own error checking, it does not return an error code.
253d0609cedSBarry Smith 
2544bb2516aSBarry Smith   Fortran Note:
2554bb2516aSBarry Smith    Returns ierr error code per PETSc Fortran API
2564bb2516aSBarry Smith 
257db781477SPatrick Sanan .seealso: `PetscOptionsGetReal()`, `PetscOptionsHasName()`, `PetscOptionsGetString()`, `PetscOptionsGetInt()`,
258db781477SPatrick Sanan           `PetscOptionsGetIntArray()`, `PetscOptionsGetRealArray()`, `PetscOptionsBool()`
259db781477SPatrick Sanan           `PetscOptionsInt()`, `PetscOptionsString()`, `PetscOptionsReal()`, `PetscOptionsBool()`,
260db781477SPatrick Sanan           `PetscOptionsName()`, `PetscOptionsBegin()`, `PetscOptionsHeadBegin()`,
261c2e3fba1SPatrick Sanan           `PetscOptionsStringArray()`, `PetscOptionsRealArray()`, `PetscOptionsScalar()`,
262db781477SPatrick Sanan           `PetscOptionsBoolGroupBegin()`, `PetscOptionsBoolGroup()`, `PetscOptionsBoolGroupEnd()`,
263db781477SPatrick Sanan           `PetscOptionsFList()`, `PetscOptionsEList()`, `PetscObjectOptionsBegin()`
26430de9b25SBarry Smith M*/
2659371c9d4SSatish Balay   #define PetscOptionsEnd() \
2669371c9d4SSatish Balay     PetscCall(PetscOptionsEnd_Private(PetscOptionsObject)); \
2679371c9d4SSatish Balay     } \
2689371c9d4SSatish Balay     } \
2699371c9d4SSatish Balay     while (0)
2705f80ce2aSJacob Faibussowitsch #endif /* PETSC_CLANG_STATIC_ANALYZER */
27130de9b25SBarry Smith 
2724416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsBegin_Private(PetscOptionItems *, MPI_Comm, const char[], const char[], const char[]);
273dbbe0bcdSBarry Smith PETSC_EXTERN PetscErrorCode PetscObjectOptionsBegin_Private(PetscObject, PetscOptionItems *);
2744416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsEnd_Private(PetscOptionItems *);
275d0609cedSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsHeadBegin(PetscOptionItems *, const char[]);
27630de9b25SBarry Smith 
2775f80ce2aSJacob Faibussowitsch #if defined(PETSC_CLANG_STATIC_ANALYZER)
2789371c9d4SSatish Balay template <typename... T>
2799371c9d4SSatish Balay void PetscOptionsHeadBegin(T...);
280d0609cedSBarry Smith void PetscOptionsHeadEnd(void);
2819371c9d4SSatish Balay template <typename... T>
2829371c9d4SSatish Balay PetscErrorCode PetscOptionsEnum(T...);
2839371c9d4SSatish Balay template <typename... T>
2849371c9d4SSatish Balay PetscErrorCode PetscOptionsInt(T...);
2859371c9d4SSatish Balay template <typename... T>
2869371c9d4SSatish Balay PetscErrorCode PetscOptionsBoundedInt(T...);
2879371c9d4SSatish Balay template <typename... T>
2889371c9d4SSatish Balay PetscErrorCode PetscOptionsRangeInt(T...);
2899371c9d4SSatish Balay template <typename... T>
2909371c9d4SSatish Balay PetscErrorCode PetscOptionsReal(T...);
2919371c9d4SSatish Balay template <typename... T>
2929371c9d4SSatish Balay PetscErrorCode PetscOptionsScalar(T...);
2939371c9d4SSatish Balay template <typename... T>
2949371c9d4SSatish Balay PetscErrorCode PetscOptionsName(T...);
2959371c9d4SSatish Balay template <typename... T>
2969371c9d4SSatish Balay PetscErrorCode PetscOptionsString(T...);
2979371c9d4SSatish Balay template <typename... T>
2989371c9d4SSatish Balay PetscErrorCode PetscOptionsBool(T...);
2999371c9d4SSatish Balay template <typename... T>
3009371c9d4SSatish Balay PetscErrorCode PetscOptionsBoolGroupBegin(T...);
3019371c9d4SSatish Balay template <typename... T>
3029371c9d4SSatish Balay PetscErrorCode PetscOptionsBoolGroup(T...);
3039371c9d4SSatish Balay template <typename... T>
3049371c9d4SSatish Balay PetscErrorCode PetscOptionsBoolGroupEnd(T...);
3059371c9d4SSatish Balay template <typename... T>
3069371c9d4SSatish Balay PetscErrorCode PetscOptionsFList(T...);
3079371c9d4SSatish Balay template <typename... T>
3089371c9d4SSatish Balay PetscErrorCode PetscOptionsEList(T...);
3099371c9d4SSatish Balay template <typename... T>
3109371c9d4SSatish Balay PetscErrorCode PetscOptionsRealArray(T...);
3119371c9d4SSatish Balay template <typename... T>
3129371c9d4SSatish Balay PetscErrorCode PetscOptionsScalarArray(T...);
3139371c9d4SSatish Balay template <typename... T>
3149371c9d4SSatish Balay PetscErrorCode PetscOptionsIntArray(T...);
3159371c9d4SSatish Balay template <typename... T>
3169371c9d4SSatish Balay PetscErrorCode PetscOptionsStringArray(T...);
3179371c9d4SSatish Balay template <typename... T>
3189371c9d4SSatish Balay PetscErrorCode PetscOptionsBoolArray(T...);
3199371c9d4SSatish Balay template <typename... T>
3209371c9d4SSatish Balay PetscErrorCode PetscOptionsEnumArray(T...);
3219371c9d4SSatish Balay template <typename... T>
3229371c9d4SSatish Balay PetscErrorCode PetscOptionsDeprecated(T...);
3239371c9d4SSatish Balay template <typename... T>
3249371c9d4SSatish Balay PetscErrorCode PetscOptionsDeprecatedNoObject(T...);
3255f80ce2aSJacob Faibussowitsch #else
32630de9b25SBarry Smith   /*MC
327d0609cedSBarry Smith      PetscOptionsHeadBegin - Puts a heading before listing any more published options. Used, for example,
32816a05f60SBarry Smith             in `KSPSetFromOptions_GMRES()`.
329d0609cedSBarry Smith 
33016a05f60SBarry Smith    Logically Collective on the communicator passed in `PetscOptionsBegin()`
331d0609cedSBarry Smith 
332d0609cedSBarry Smith    Input Parameter:
333d0609cedSBarry Smith .   head - the heading text
334d0609cedSBarry Smith 
33587497f52SBarry Smith    Level: developer
336d0609cedSBarry Smith 
337d0609cedSBarry Smith    Notes:
338d0609cedSBarry Smith     Handles errors directly, hence does not return an error code
339d0609cedSBarry Smith 
34016a05f60SBarry Smith     Must be between a `PetscOptionsBegin()` and a `PetscOptionsEnd()`, and `PetscOptionsObject` created in `PetscOptionsBegin()` should be the first argument
341d0609cedSBarry Smith 
34287497f52SBarry Smith     Must be followed by a call to `PetscOptionsHeadEnd()` in the same function.
343d0609cedSBarry Smith 
344db781477SPatrick Sanan .seealso: `PetscOptionsGetInt()`, `PetscOptionsGetReal()`,
345db781477SPatrick Sanan           `PetscOptionsHasName()`, `PetscOptionsGetIntArray()`, `PetscOptionsGetRealArray()`, `PetscOptionsBool()`,
346db781477SPatrick Sanan           `PetscOptionsName()`, `PetscOptionsBegin()`, `PetscOptionsEnd()`, `PetscOptionsHeadBegin()`,
347c2e3fba1SPatrick Sanan           `PetscOptionsStringArray()`, `PetscOptionsRealArray()`, `PetscOptionsScalar()`,
348db781477SPatrick Sanan           `PetscOptionsBoolGroupBegin()`, `PetscOptionsBoolGroup()`, `PetscOptionsBoolGroupEnd()`,
349db781477SPatrick Sanan           `PetscOptionsFList()`, `PetscOptionsEList()`
350d0609cedSBarry Smith @*/
3519371c9d4SSatish Balay   #define PetscOptionsHeadBegin(PetscOptionsObject, head) \
3529371c9d4SSatish Balay     do { \
35348a46eb9SPierre Jolivet       if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) PetscCall((*PetscHelpPrintf)(PetscOptionsObject->comm, "  %s\n", head)); \
354d0609cedSBarry Smith     } while (0)
355d0609cedSBarry Smith 
356edd03b47SJacob Faibussowitsch   #define PetscOptionsHead(...) PETSC_DEPRECATED_MACRO(3, 18, 0, "PetscOptionsHeadBegin()", ) PetscOptionsHeadBegin(__VA_ARGS__)
357d0609cedSBarry Smith 
358d0609cedSBarry Smith   /*MC
35987497f52SBarry Smith      PetscOptionsHeadEnd - Ends a section of options begun with `PetscOptionsHeadBegin()`
36016a05f60SBarry Smith             See, for example, `KSPSetFromOptions_GMRES()`.
36130de9b25SBarry Smith 
362f2ba6396SBarry Smith    Synopsis:
363aaa7dc30SBarry Smith      #include <petscoptions.h>
364d0609cedSBarry Smith      PetscErrorCode PetscOptionsHeadEnd(void)
36530de9b25SBarry Smith 
3667cdbe19fSJose E. Roman     Collective on the comm used in `PetscOptionsBegin()` or obj used in `PetscObjectOptionsBegin()`
3677cdbe19fSJose E. Roman 
36830de9b25SBarry Smith   Level: intermediate
36930de9b25SBarry Smith 
37095452b02SPatrick Sanan    Notes:
37187497f52SBarry Smith     Must be between a `PetscOptionsBegin()` or `PetscObjectOptionsBegin()` and a `PetscOptionsEnd()`
37230de9b25SBarry Smith 
37387497f52SBarry Smith     Must be preceded by a call to `PetscOptionsHeadBegin()` in the same function.
37430de9b25SBarry Smith 
37587497f52SBarry Smith     This needs to be used only if the code below `PetscOptionsHeadEnd()` can be run ONLY once.
37616a05f60SBarry Smith     See, for example, `PCSetFromOptions_Composite()`. This is a `return(0)` in it for early exit
377b52f573bSBarry Smith     from the function.
378b52f573bSBarry Smith 
37956752e42SBarry Smith           This is only for use with the PETSc options GUI
380b52f573bSBarry Smith 
381db781477SPatrick Sanan .seealso: `PetscOptionsGetInt()`, `PetscOptionsGetReal()`,
382db781477SPatrick Sanan           `PetscOptionsHasName()`, `PetscOptionsGetIntArray()`, `PetscOptionsGetRealArray()`, `PetscOptionsBool()`,
383db781477SPatrick Sanan           `PetscOptionsName()`, `PetscOptionsBegin()`, `PetscOptionsEnd()`, `PetscOptionsHeadBegin()`,
384c2e3fba1SPatrick Sanan           `PetscOptionsStringArray()`, `PetscOptionsRealArray()`, `PetscOptionsScalar()`,
385db781477SPatrick Sanan           `PetscOptionsBoolGroupBegin()`, `PetscOptionsBoolGroup()`, `PetscOptionsBoolGroupEnd()`,
386db781477SPatrick Sanan           `PetscOptionsFList()`, `PetscOptionsEList()`, `PetscOptionsEnum()`
38730de9b25SBarry Smith M*/
3889371c9d4SSatish Balay   #define PetscOptionsHeadEnd() \
3899371c9d4SSatish Balay     do { \
3903ba16761SJacob Faibussowitsch       if (PetscOptionsObject->count != 1) PetscFunctionReturn(PETSC_SUCCESS); \
3919371c9d4SSatish Balay     } while (0)
392d0609cedSBarry Smith 
393edd03b47SJacob Faibussowitsch   #define PetscOptionsTail(...) PETSC_DEPRECATED_MACRO(3, 18, 0, "PetscOptionsHeadEnd()", ) PetscOptionsHeadEnd(__VA_ARGS__)
394186905e3SBarry Smith 
395*1ff8fb82SZach Atkins   #define PetscOptionsEnum(opt, text, man, list, currentvalue, value, set)          PetscOptionsEnum_Private(PetscOptionsObject, opt, text, man, list, currentvalue, value, set)
396*1ff8fb82SZach Atkins   #define PetscOptionsInt(opt, text, man, currentvalue, value, set)                 PetscOptionsInt_Private(PetscOptionsObject, opt, text, man, currentvalue, value, set, PETSC_MIN_INT, PETSC_MAX_INT)
397*1ff8fb82SZach Atkins   #define PetscOptionsBoundedInt(opt, text, man, currentvalue, value, set, lb)      PetscOptionsInt_Private(PetscOptionsObject, opt, text, man, currentvalue, value, set, lb, PETSC_MAX_INT)
398*1ff8fb82SZach Atkins   #define PetscOptionsRangeInt(opt, text, man, currentvalue, value, set, lb, ub)    PetscOptionsInt_Private(PetscOptionsObject, opt, text, man, currentvalue, value, set, lb, ub)
399*1ff8fb82SZach Atkins   #define PetscOptionsReal(opt, text, man, currentvalue, value, set)                PetscOptionsReal_Private(PetscOptionsObject, opt, text, man, currentvalue, value, set)
400*1ff8fb82SZach Atkins   #define PetscOptionsScalar(opt, text, man, currentvalue, value, set)              PetscOptionsScalar_Private(PetscOptionsObject, opt, text, man, currentvalue, value, set)
401*1ff8fb82SZach Atkins   #define PetscOptionsName(opt, text, man, flg)                                     PetscOptionsName_Private(PetscOptionsObject, opt, text, man, flg)
402*1ff8fb82SZach Atkins   #define PetscOptionsString(opt, text, man, currentvalue, value, len, set)         PetscOptionsString_Private(PetscOptionsObject, opt, text, man, currentvalue, value, len, set)
403*1ff8fb82SZach Atkins   #define PetscOptionsBool(opt, text, man, currentvalue, value, set)                PetscOptionsBool_Private(PetscOptionsObject, opt, text, man, currentvalue, value, set)
404*1ff8fb82SZach Atkins   #define PetscOptionsBoolGroupBegin(opt, text, man, flg)                           PetscOptionsBoolGroupBegin_Private(PetscOptionsObject, opt, text, man, flg)
405*1ff8fb82SZach Atkins   #define PetscOptionsBoolGroup(opt, text, man, flg)                                PetscOptionsBoolGroup_Private(PetscOptionsObject, opt, text, man, flg)
406*1ff8fb82SZach Atkins   #define PetscOptionsBoolGroupEnd(opt, text, man, flg)                             PetscOptionsBoolGroupEnd_Private(PetscOptionsObject, opt, text, man, flg)
407*1ff8fb82SZach Atkins   #define PetscOptionsFList(opt, ltext, man, list, currentvalue, value, len, set)   PetscOptionsFList_Private(PetscOptionsObject, opt, ltext, man, list, currentvalue, value, len, set)
408*1ff8fb82SZach Atkins   #define PetscOptionsEList(opt, ltext, man, list, ntext, currentvalue, value, set) PetscOptionsEList_Private(PetscOptionsObject, opt, ltext, man, list, ntext, currentvalue, value, set)
409*1ff8fb82SZach Atkins   #define PetscOptionsRealArray(opt, text, man, currentvalue, value, set)           PetscOptionsRealArray_Private(PetscOptionsObject, opt, text, man, currentvalue, value, set)
410*1ff8fb82SZach Atkins   #define PetscOptionsScalarArray(opt, text, man, currentvalue, value, set)         PetscOptionsScalarArray_Private(PetscOptionsObject, opt, text, man, currentvalue, value, set)
411*1ff8fb82SZach Atkins   #define PetscOptionsIntArray(opt, text, man, currentvalue, value, set)            PetscOptionsIntArray_Private(PetscOptionsObject, opt, text, man, currentvalue, value, set)
412*1ff8fb82SZach Atkins   #define PetscOptionsStringArray(opt, text, man, currentvalue, value, set)         PetscOptionsStringArray_Private(PetscOptionsObject, opt, text, man, currentvalue, value, set)
413*1ff8fb82SZach Atkins   #define PetscOptionsBoolArray(opt, text, man, currentvalue, value, set)           PetscOptionsBoolArray_Private(PetscOptionsObject, opt, text, man, currentvalue, value, set)
414*1ff8fb82SZach Atkins   #define PetscOptionsEnumArray(opt, text, man, list, value, n, set)                PetscOptionsEnumArray_Private(PetscOptionsObject, opt, text, man, list, value, n, set)
415*1ff8fb82SZach Atkins   #define PetscOptionsDeprecated(opt, text, man, info)                              PetscOptionsDeprecated_Private(PetscOptionsObject, opt, text, man, info)
416*1ff8fb82SZach Atkins   #define PetscOptionsDeprecatedNoObject(opt, text, man, info)                      PetscOptionsDeprecated_Private(NULL, opt, text, man, info)
4175f80ce2aSJacob Faibussowitsch #endif /* PETSC_CLANG_STATIC_ANALYZER */
418e55864a3SBarry Smith 
4194416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsEnum_Private(PetscOptionItems *, const char[], const char[], const char[], const char *const *, PetscEnum, PetscEnum *, PetscBool *);
4205a856986SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsInt_Private(PetscOptionItems *, const char[], const char[], const char[], PetscInt, PetscInt *, PetscBool *, PetscInt, PetscInt);
4214416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsReal_Private(PetscOptionItems *, const char[], const char[], const char[], PetscReal, PetscReal *, PetscBool *);
4224416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsScalar_Private(PetscOptionItems *, const char[], const char[], const char[], PetscScalar, PetscScalar *, PetscBool *);
4234416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsName_Private(PetscOptionItems *, const char[], const char[], const char[], PetscBool *);
4244416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsString_Private(PetscOptionItems *, const char[], const char[], const char[], const char[], char *, size_t, PetscBool *);
4254416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsBool_Private(PetscOptionItems *, const char[], const char[], const char[], PetscBool, PetscBool *, PetscBool *);
4264416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsBoolGroupBegin_Private(PetscOptionItems *, const char[], const char[], const char[], PetscBool *);
4274416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsBoolGroup_Private(PetscOptionItems *, const char[], const char[], const char[], PetscBool *);
4284416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsBoolGroupEnd_Private(PetscOptionItems *, const char[], const char[], const char[], PetscBool *);
4294416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsFList_Private(PetscOptionItems *, const char[], const char[], const char[], PetscFunctionList, const char[], char[], size_t, PetscBool *);
4304416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsEList_Private(PetscOptionItems *, const char[], const char[], const char[], const char *const *, PetscInt, const char[], PetscInt *, PetscBool *);
4314416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsRealArray_Private(PetscOptionItems *, const char[], const char[], const char[], PetscReal[], PetscInt *, PetscBool *);
4324416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsScalarArray_Private(PetscOptionItems *, const char[], const char[], const char[], PetscScalar[], PetscInt *, PetscBool *);
4334416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsIntArray_Private(PetscOptionItems *, const char[], const char[], const char[], PetscInt[], PetscInt *, PetscBool *);
4344416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsStringArray_Private(PetscOptionItems *, const char[], const char[], const char[], char *[], PetscInt *, PetscBool *);
4354416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsBoolArray_Private(PetscOptionItems *, const char[], const char[], const char[], PetscBool[], PetscInt *, PetscBool *);
4364416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsEnumArray_Private(PetscOptionItems *, const char[], const char[], const char[], const char *const *, PetscEnum[], PetscInt *, PetscBool *);
4379f3a6782SPatrick Sanan PETSC_EXTERN PetscErrorCode PetscOptionsDeprecated_Private(PetscOptionItems *, const char[], const char[], const char[], const char[]);
438cffb1e40SBarry Smith 
439e04113cfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsSAWsDestroy(void);
440f8d0b74dSMatthew Knepley 
441dbbe0bcdSBarry Smith PETSC_EXTERN PetscErrorCode PetscObjectAddOptionsHandler(PetscObject, PetscErrorCode (*)(PetscObject, PetscOptionItems *, void *), PetscErrorCode (*)(PetscObject, void *), void *);
442dbbe0bcdSBarry Smith PETSC_EXTERN PetscErrorCode PetscObjectProcessOptionsHandlers(PetscObject, PetscOptionItems *);
443447ac60bSBarry Smith PETSC_EXTERN PetscErrorCode PetscObjectDestroyOptionsHandlers(PetscObject);
444447ac60bSBarry Smith 
445f4bc716fSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsLeftError(void);
446