Take the 2-minute tour ×
Computational Science Stack Exchange is a question and answer site for scientists using computers to solve scientific problems. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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 petsc-users@mcs.anl.gov.

share|improve this answer
    
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. –  Dan Mar 13 '12 at 0:04
    
It uses the values if they are set in the options database (via the command line, environment variable, configuration file, etc). –  Jed Brown Mar 13 '12 at 2:51
    
@Jed Brown: Thanks! –  Dan Mar 13 '12 at 4:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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