1
$\begingroup$

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?

$\endgroup$

1 Answer 1

2
$\begingroup$

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].

$\endgroup$
2
  • $\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() and PetscOptionsSometype() to tell the difference from the source. $\endgroup$
    – Dan
    Commented 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$
    – Jed Brown
    Commented Mar 13, 2012 at 2:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.