Hi Again<div><br></div><div>I've pulled the most recent 3.3 branch code, compiled and tried running with the shell solver. When I run just the snessolve() on the shell solver everything works just fine. However, when I try to combine it with NGMRES I get issues. Here's how I setup the solvers:</div>
<div><br></div><div><div>     ! ----------- Create Shell snes context -----------------                                                                                                                                                 </div>
<div>     call SNESCreate(SUMB_COMM_WORLD, psnes, ierr)</div><div>     call EChk(ierr, __FILE__, __LINE__)</div><div><br></div><div>     ! Set the type to "shell"                                                                                                                                                                                 </div>
<div>     call SNESSetType(psnes, SNESSHELL, ierr)</div><div>     call EChk(ierr, __FILE__, __LINE__)</div><div><br></div><div>     ! Set the user-defined function for psnes to our funtion                                                                                                                                                  </div>
<div>     call SNESShellSetSolve(psnes, psnes_func, ierr)</div><div>     call EChk(ierr, __FILE__, __LINE__)</div><div><br></div><div>     ! ----------- Create main snes solver object ------------                                                                                                                                                 </div>
<div>     call SNESCreate(SUMB_COMM_WORLD, outer_snes, ierr)</div><div>     call EChk(ierr, __FILE__, __LINE__)</div><div><br></div><div>     ! Set the type to the nonlinear ngmres                                                                                                                                                                    </div>
<div>     call SNESSetType(outer_snes, SNESNGMRES, ierr)</div><div>     call EChk(ierr, __FILE__, __LINE__)</div><div><br></div><div>     call SNESSetFunction(outer_snes, rVec, formFunction_snes, ctx2, ierr)</div><div>     call EChk(ierr, __FILE__, __LINE__)</div>
<div><br></div><div>     ! Set the above create psnes context to the 'pc' of the one just created                                                                                                                                  </div>
<div>     call SNESSetPC(outer_snes, psnes, ierr)</div><div>     call EChk(ierr, __FILE__, __LINE__)</div><div><br></div><div>     call snessetfromoptions(outer_snes, ierr)</div><div>     call EChk(ierr, __FILE__, __LINE__)</div>
<div><br></div><div><div><br class="Apple-interchange-newline">The actual commands I'm running are:</div><div><div>  call SNESSolve(outer_snes, rhs, wVec, ierr) ! this works when 'outer_snes' is replaced with 'psnes'</div>
<div>  call EChk(ierr,__FILE__,__LINE__) ! </div></div></div><div><br></div><div><br></div><div>I'm pretty sure the function is correct since it runs through when just the shell solver is called. the "formFunction_snes" also seems to work ok by itself. The traceback I get is below:</div>
<div><br></div><div><div>[0]PETSC ERROR: ------------------------------------------------------------------------</div><div>[0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range</div>
<div>[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger</div><div>[0]PETSC ERROR: or see <a href="http://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind[0]PETSC">http://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind[0]PETSC</a> ERROR: or try <a href="http://valgrind.org">http://valgrind.org</a> on GNU/linux and Apple Mac OS X to find memory corruption errors</div>
<div>[0]PETSC ERROR: likely location of problem given in stack below</div><div>[0]PETSC ERROR: ---------------------  Stack Frames ------------------------------------</div><div>[0]PETSC ERROR: Note: The EXACT line numbers in the stack are not available,</div>
<div>[0]PETSC ERROR:       INSTEAD the line number of the start of the function</div><div>[0]PETSC ERROR:       is given.</div><div>[0]PETSC ERROR: [0] SNESSolve_Shell line 166 /nfs/mica/home/kenway/Downloads/petsc-3.3/src/snes/impls/shell/snesshell.c</div>
<div>[0]PETSC ERROR: [0] SNESSolve line 3491 /nfs/mica/home/kenway/Downloads/petsc-3.3/src/snes/interface/snes.c</div><div>[0]PETSC ERROR: [0] SNESSolve_NGMRES line 189 /nfs/mica/home/kenway/Downloads/petsc-3.3/src/snes/impls/ngmres/snesngmres.c</div>
<div>[0]PETSC ERROR: [0] SNESSolve line 3491 /nfs/mica/home/kenway/Downloads/petsc-3.3/src/snes/interface/snes.c</div><div>[0]PETSC ERROR: [0] VecCreateMPIWithArray line 313 /nfs/mica/home/kenway/Downloads/petsc-3.3/src/vec/vec/impls/mpi/pbvec.c</div>
<div>[0]PETSC ERROR: [0] VecCreateMPIWithArray line 313 /nfs/mica/home/kenway/Downloads/petsc-3.3/src/vec/vec/impls/mpi/pbvec.c</div><div>[0]PETSC ERROR: [0] VecCreateMPIWithArray line 313 /nfs/mica/home/kenway/Downloads/petsc-3.3/src/vec/vec/impls/mpi/pbvec.c</div>
<div>[0]PETSC ERROR: [0] VecCreateMPIWithArray line 313 /nfs/mica/home/kenway/Downloads/petsc-3.3/src/vec/vec/impls/mpi/pbvec.c</div></div><div><br></div><div>I can tell from the output it first calls the supplied 'formFunction' correctly and then has made its way to the SNESSolve_Shell command as expected. However, my guess is it actually dies at the following line:</div>
<div><br></div><div><div> ierr = (*shell->solve)(snes,snes->vec_sol);CHKERRQ(ierr);</div></div><div><br></div><div>I'm not quite sure what's going on.  Something fishy with the vec_sol pointer or the solve command pointer?</div>
<div><br></div><div>Do you have any examples of using NGMRES? </div><div><br></div><div>Thanks, </div><div><br></div><div>Gaetan</div><br><div class="gmail_quote">On Mon, Aug 27, 2012 at 5:06 PM, Gaetan Kenway <span dir="ltr"><<a href="mailto:kenway@utias.utoronto.ca" target="_blank">kenway@utias.utoronto.ca</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks very much for the very quick response. <div><br></div><div>I will pull the change from the mercurial repository and give it a try in the next couple of days. </div>
<span class="HOEnZb"><font color="#888888"><div><br></div></font></span><div><span class="HOEnZb"><font color="#888888">Gaetan</font></span><div><div class="h5"><br><br><div class="gmail_quote">
On Mon, Aug 27, 2012 at 3:59 PM, Peter Brune <span dir="ltr"><<a href="mailto:brune@mcs.anl.gov" target="_blank">brune@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

I've tested and pushed a fix to petsc-3.3.  If there are any problems, let me know.<br><br><div class="gmail_quote"><div>On Mon, Aug 27, 2012 at 12:24 PM, Gaetan Kenway <span dir="ltr"><<a href="mailto:kenway@utias.utoronto.ca" target="_blank">kenway@utias.utoronto.ca</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Excellent. Thanks.<div><br></div><div>The reason for using the snes shell solver is I would like to try out the ngmres snes. solver. The code I'm working with already has a has a non-linear multi-grid method, coded directly in the fortran source. My plan was to setup the the ngmres snes solver, then create a snes shell as the preconditioner that wraps the nonlienear multigrid solver already in place. </div>



<div><br></div><div>Does this make sense? Is this the sort of usage you had in mind? </div><div><br></div></blockquote></div><div><br>This is very much the usage we were intending for this.<span><font color="#888888"><br>

<br>- Peter<br> </font></span></div><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div></div><div>Thanks,</div><div><br></div><div>Gaetan<div><div><br><br><div class="gmail_quote">On Mon, Aug 27, 2012 at 1:10 PM, Jed Brown <span dir="ltr"><<a href="mailto:jedbrown@mcs.anl.gov" target="_blank">jedbrown@mcs.anl.gov</a>></span> wrote:<br>



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="gmail_quote">On Mon, Aug 27, 2012 at 12:09 PM, Gaetan Kenway <span dir="ltr"><<a href="mailto:kenway@utias.utoronto.ca" target="_blank">kenway@utias.utoronto.ca</a>></span> wrote:<br>



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
That's what I had deduced. I tried modifying the source code taking out the 'C', but it still didn't seem to generate the required wrapper. Does the functions that get passed function pointer handle's require special handling? </blockquote>




</div><div><br></div></div>It needs custom handling. Peter is working on it.<br><div><br></div>
</blockquote></div><br></div></div></div>
</blockquote></div></div><br>
</blockquote></div><br></div></div></div>
</blockquote></div><br></div>