<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div><div><div>On Apr 2, 2012, at 3:43 PM, Peter Brune wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Does PCGAMGSetType() call PetscOptionsHead() from KSP/PCSetFromOptions on some subsolver?  I had a similar issue recently with FAS.  The fix is to move other function calls that might do this out of your PetscOptionsHead/Tail() pair.<br></blockquote><div><br></div><div>I don't think so ... I think this is the code stack that is invoked with PCGAMGSetType:</div><div><br></div><div><div>PetscErrorCode PCGAMGSetType( PC pc, const PCGAMGType type )</div><div>{</div><div>  PetscErrorCode ierr;</div><div>  </div><div>  PetscFunctionBegin;</div><div>  PetscValidHeaderSpecific(pc,PC_CLASSID,1);</div><div>  ierr = PetscTryMethod(pc,"PCGAMGSetType_C",(PC,const PCGAMGType),(pc,type));</div><div>  CHKERRQ(ierr);</div><div>  PetscFunctionReturn(0);</div><div>}</div><div>  </div><div>EXTERN_C_BEGIN</div><div>#undef __FUNCT__  </div><div>#define __FUNCT__ "PCGAMGSetType_GAMG"</div><div>PetscErrorCode PCGAMGSetType_GAMG( PC pc, const PCGAMGType type )</div><div>{</div><div>  PetscErrorCode ierr,(*r)(PC);</div><div>  </div><div>  PetscFunctionBegin;</div><div>  ierr = PetscFListFind(GAMGList,((PetscObject)pc)->comm,type,PETSC_FALSE,(PetscVoidStarFunction)&r); </div><div>  CHKERRQ(ierr);</div><div><br></div><div>  if (!r) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_UNKNOWN_TYPE,"Unknown GAMG type %s given",type);</div><div><br></div><div>  /* call sub create method */</div><div>  ierr = (*r)(pc); CHKERRQ(ierr);</div><div><br></div><div>  PetscFunctionReturn(0);</div><div>}</div><div>EXTERN_C_END</div></div><div><br></div><div><div>PetscErrorCode  PCCreateGAMG_AGG( PC pc )</div><div>{</div><div>  PetscErrorCode  ierr;</div><div>  PC_MG           *mg = (PC_MG*)pc->data;</div><div>  PC_GAMG         *pc_gamg = (PC_GAMG*)mg->innerctx;</div><div>  PC_GAMG_AGG      *pc_gamg_agg;</div><div><br></div></div><div><div>  PetscFunctionBegin;</div><div>  /* create sub context for SA */</div><div>  ierr = PetscNewLog( pc, PC_GAMG_AGG, &pc_gamg_agg ); CHKERRQ(ierr);</div><div>  assert(!pc_gamg->subctx);</div><div>  pc_gamg->subctx = pc_gamg_agg;</div><div>  </div><div>  pc->ops->setfromoptions = PCSetFromOptions_GAMG_AGG;</div><div>  pc->ops->destroy        = PCDestroy_AGG;</div><div>  /* reset does not do anything; setup not virtual */</div><div><br></div><div>  /* set internal function pointers */</div><div>  pc_gamg->graph = PCGAMGgraph_AGG;</div><div>  pc_gamg->coarsen = PCGAMGCoarsen_AGG;</div><div>  pc_gamg->prolongator = PCGAMGProlongator_AGG;</div><div>  pc_gamg->optprol = PCGAMGOptprol_AGG;</div><div> </div><div>  pc_gamg->createdefaultdata = PCSetData_AGG;</div><div><br></div><div>  ierr = PetscObjectComposeFunctionDynamic( (PetscObject)pc,</div><div>                                            "PCSetCoordinates_C",</div><div>                                            "PCSetCoordinates_AGG",</div><div>                                            PCSetCoordinates_AGG);</div><div>  PetscFunctionReturn(0);</div><div>}</div></div><div><br></div><div>Mark</div><br><blockquote type="cite">
<br>- Peter<br><br><div class="gmail_quote">On Mon, Apr 2, 2012 at 2:40 PM, Mark F. Adams <span dir="ltr"><<a href="mailto:mark.adams@columbia.edu">mark.adams@columbia.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I am getting strange behavior with PetscOptionsTail.  I have this code:<br>
<br>
 /* instantiate derived type */<br>
  ierr = PetscOptionsHead("GAMG options"); CHKERRQ(ierr);<br>
  {<br>
    char tname[256] = GAMGAGG;<br>
    ierr = PetscOptionsList("-pc_gamg_type","Type of GAMG method","PCGAMGSetType",<br>
                            GAMGList, tname, tname, sizeof(tname), PETSC_NULL );<br>
    CHKERRQ(ierr);<br>
    ierr = PCGAMGSetType( pc, tname ); CHKERRQ(ierr);<br>
  }<br>
PetscPrintf(wcomm,"******* [%d]%s 5555\n",0,__FUNCT__);<br>
  ierr = PetscOptionsTail();   CHKERRQ(ierr);<br>
PetscPrintf(wcomm,"******* [%d]%s 6666\n",0,__FUNCT__);<br>
<br>
and this last line does not get executed.  It is as if CHKERRQ is silently returning.  I see the usage in KSPSetFromOptions_GMRES has this code (PetscOptionsTail) at the very end and so this behavior  would not be noticed.<br>

<span class="HOEnZb"><font color="#888888"><br>
Mark</font></span></blockquote></div><br>
</blockquote></div><br></body></html>