On Mon, Nov 6, 2017 at 9:54 AM, Smith, Barry F. <bsm...@mcs.anl.gov> wrote:
> > Hmm, I think this perhaps an issue of documentation. > > It seems the various PetscOptionsGetXXX() DO NOT set the value unless > the options database indicates it should be set (and when the options > database does indicate it has been set the set flag is set). > > But this is only documented for PetscOptionsGetBool() > > The PetscOptionsXXX() also do not set the value unless the options > database indicates it should be set. > > So my conclusion is that the code is correct but the documentation > needs work. I will make a pull request where I "fix" the documentation. > This seems bad/wrong, if I have *flg = PETSC_TRUE PetscOptionsBool(...,PETSC_FALSE, flg, ..) and the option is NOT set then *flg == PETSC_TRUE, but my code and -help (I assume) say the default is false. Am I missing something? Not a big deal, I assume there was a good reason to split the default value into a new argument. > > Barry > > > > > > On Nov 6, 2017, at 8:25 AM, Mark Adams <mfad...@lbl.gov> wrote: > > > > This code looks wrong. I get a valgrind warning if the option is not > set. I think this code should be added. > > > > PetscErrorCode PetscOptionsBool_Private(PetscOptionItems > *PetscOptionsObject,const char opt[],const char text[],const char > man[],PetscBool currentvalue,PetscBool *flg,PetscBool *set) > > { > > PetscErrorCode ierr; > > PetscBool iset; > > PetscOptionItem amsopt; > > > > PetscFunctionBegin; > > if (!PetscOptionsObject->count) { > > ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,text,ma > n,OPTION_BOOL,&amsopt);CHKERRQ(ierr); > > ierr = PetscMalloc(sizeof(PetscBool),&amsopt->data);CHKERRQ(ierr); > > > > *(PetscBool*)amsopt->data = currentvalue; > > } > > flg = currentvalue; > > ierr = PetscOptionsGetBool(PetscOptionsObject->options,PetscOptions > Object->prefix,opt,flg,&iset);CHKERRQ(ierr); > > if (set) *set = iset; > > if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && > !PetscOptionsObject->alreadyprinted) { > > const char *v = PetscBools[currentvalue]; > > ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm," -%s%s: <%s> > %s (%s)\n",PetscOptionsObject->prefix?PetscOptionsObject->prefi > x:"",opt+1,v,text,ManSection(man));CHKERRQ(ierr); > > } > > PetscFunctionReturn(0); > > } > > > >