I'm writing a program that uses PETSc and SLEPc, and I was looking for a convienient way to read in options from the command line. The description of PetscBagSetFromOptions()
in the official documentation says it "allows setting options from a bag". Does this mean that if I create a bag with a variety of PetscFoo
elements I can read in my program's parameters from the command line without having to use PetscOptionsGetInt()
and other functions like it?
1 Answer
It appears from the code, linked on the very page you have described, that PetscBagSetFromOptions literally just goes through the bag's item names and checks to see if they are in the options database (by appending - in front and using PetscOptionsInt, PetscOptionsReal, etc.).
It's silly that the linked examples, however, use this redundantly with the PetscOptionsXXX routines, so I can see why this might be confusing.
Requests like this may be sent to [email protected].
-
$\begingroup$ Do you mean it sets the items in the bag by their names, or just checks to see if they are in the options database? I don't know enough about
PetscOptionsBegin()
andPetscOptionsSometype()
to tell the difference from the source. $\endgroup$– DanCommented Mar 13, 2012 at 0:04 -
$\begingroup$ It uses the values if they are set in the options database (via the command line, environment variable, configuration file, etc). $\endgroup$ Commented Mar 13, 2012 at 2:51