<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I still get the same error message. Can you try /src/ksp/ksp/examples/tutorials/ex2f.F, but replace the<div>call to KSPBuildSolution line 348 to</div><div><br></div><div> call KSPMonitorTrueResidualNorm(ksp,n,rnorm,dummy,ierr)</div><div><div><br></div><div>That will reproduce the error.</div><div><br></div><div>Thanks, Randy M</div><div><br></div><br><div><div>On Apr 19, 2012, at 10:40 AM, Jed Brown wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">It looks like this null object check was missing from the Fortran bindings. Can you try with this patch included?<div><br></div><div><a href="http://petsc.cs.iit.edu/petsc/petsc-dev/rev/05b5b9325f55">http://petsc.cs.iit.edu/petsc/petsc-dev/rev/05b5b9325f55</a><br>
<div><div><br><div class="gmail_quote">On Thu, Apr 19, 2012 at 10:12, Randall Mackie <span dir="ltr"><<a href="mailto:rlmackie862@gmail.com">rlmackie862@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Matt and Barry,<div><br></div><div>I tried this again, but this time I used a c subroutine like Barry suggested, which is this:</div><div><br></div><div><div>#include "petsc.h"</div><div><br></div><div>PetscErrorCode shellkspmonitor_(KSP ksp,PetscInt n,PetscReal rnorm,void *dummy)</div>
<div>{</div><div><span style="white-space:pre-wrap">        </span>PetscErrorCode ierr=0;</div><div class="im"><div> if (n % 10) {</div><div> ierr = KSPMonitorTrueResidualNorm(ksp,n,rnorm,dummy);CHKERRQ(ierr);</div><div>
}</div><div> </div></div><div><span style="white-space:pre-wrap">        </span>return ierr;</div><div>}</div><div><br></div><div><br></div><div>In my Fortran code, I declared shellkspmonitor as external, then I called KSPSetMonitor as follows:</div>
<div><br></div><div><div> call KSPMonitorSet(ksp,shellkspmonitor,PETSC_NULL_OBJECT, PETSC_NULL_FUNCTION, ierr)</div></div><div><br></div><div><br></div><div>But I am still getting the same error as before:</div><div><br>
</div><div><div>[0]PETSC ERROR: [1]PETSC ERROR: [2]PETSC ERROR: [3]PETSC ERROR: --------------------- Error Message ------------------------------------</div><div>--------------------- Error Message ------------------------------------</div>
<div>[3]PETSC ERROR: [2]PETSC ERROR: Invalid argument!</div><div>Invalid argument!</div><div>[3]PETSC ERROR: Wrong type of object: Parameter # 1!</div><div>[3]PETSC ERROR: [2]PETSC ERROR: ------------------------------------------------------------------------</div>
<div>[3]PETSC ERROR: Petsc Release Version 3.2.0, Patch 5, Sat Oct 29 13:45:54 CDT 2011 </div><div>[3]PETSC ERROR: --------------------- Error Message ------------------------------------</div><div class="im"><div>[0]PETSC ERROR: Invalid argument!</div>
<div>[0]PETSC ERROR: Wrong type of object: Parameter # 1!</div><div>[0]PETSC ERROR: ------------------------------------------------------------------------</div><div>[0]PETSC ERROR: Petsc Release Version 3.2.0, Patch 5, Sat Oct 29 13:45:54 CDT 2011 </div>
</div><div>[0]PETSC ERROR: See docs/changes/index.html for recent updates.</div><div>[0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.</div><div>[0]PETSC ERROR: See docs/index.html for manual pages.</div>
<div>
[0]PETSC ERROR: ------------------------------------------------------------------------</div><div>[0]PETSC ERROR: PetscViewerASCIIAddTab() line 277 in src/sys/viewer/impls/ascii/filev.c</div><div>[0]PETSC ERROR: KSPMonitorTrueResidualNorm() line 233 in src/ksp/ksp/interface/iterativ.c</div>
<div>[0]PETSC ERROR: shellkspmonitor_() line 7 in custom_monitor.c</div><div>[3]PETSC ERROR: See docs/faq.html for hints about trouble shooting.</div><div>[3]PETSC ERROR: See docs/index.html for manual pages.</div></div>
<div>
<br></div>So, there is either a problem in one of the PETSc routines, or the call from Fortran to KSPMonitorSet </div><div>is wrong, although I have copied the calling sequence from the example in /src/ksp/ksp/examples/tutorials/ex2f.F</div>
<div><br></div><div>In fact, you can reproduce this error using ex2f.F, simply swapping in the custom monitor above for</div><div>the MyKSPMonitor of that example. I can send you the modified code and c subroutine to test if you want.</div>
<div><br></div><div>Thanks, Randy </div><div class="HOEnZb"><div class="h5"><div><br></div><div><br><div class="gmail_quote">On Tue, Apr 17, 2012 at 10:39 AM, Matthew Knepley <span dir="ltr"><<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto; "><div><div>On Tue, Apr 17, 2012 at 1:27 PM, Randall Mackie <span dir="ltr"><<a href="mailto:rlmackie862@gmail.com" target="_blank">rlmackie862@gmail.com</a>></span> wrote:<br>
</div></div><div class="gmail_quote"><div><div><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto; ">
Hi Barry,<div><br></div><div>I've tried implementing this in Fortran, following ex2f.F in /src/ksp/ksp/examples/tutorials, but</div><div>it is bombing out with the following message:</div><div><br></div><div><div><div>
---------------------- Error Message ------------------------------------</div><div>[0]PETSC ERROR: Invalid argument!</div><div>[0]PETSC ERROR: Wrong type of object: Parameter # 1!</div><div>[0]PETSC ERROR: ------------------------------------------------------------------------</div>
<div>[0]PETSC ERROR: Petsc Release Version 3.2.0, Patch 5, Sat Oct 29 13:45:54 CDT 2011 </div><div>-------------------- Error Message ------------------------------------</div><div>[0]PETSC ERROR: Invalid argument!</div>
<div>
[0]PETSC ERROR: Wrong type of object: Parameter # 1!</div><div>[0]PETSC ERROR: ------------------------------------------------------------------------</div><div>[0]PETSC ERROR: Petsc Release Version 3.2.0, Patch 5, Sat Oct 29 13:45:54 CDT 2011 </div>
</div><div><br></div><div><br></div><div><div>[1]PETSC ERROR: PetscViewerASCIIAddTab() line 277 in src/sys/viewer/impls/ascii/filev.c</div><div>[1]PETSC ERROR: KSPMonitorTrueResidualNorm() line 233 in src/ksp/ksp/interface/iterativ.c</div>
<div>[1]PETSC ERROR: ourmonitor() line 103 in src/ksp/ksp/interface/ftn-custom/zitfuncf.c</div><div>[1]PETSC ERROR: KSPMonitor() line 1429 in src/ksp/ksp/interface/itfunc.c</div><div>[1]PETSC ERROR: KSPSolve_CG() line 255 in src/ksp/ksp/impls/cg/cg.c</div>
<div>[1]PETSC ERROR: KSPSolve() line 423 in src/ksp/ksp/interface/itfunc.c</div></div><div><br></div><div><br></div><div>I am running PETSC 3.2-p5.</div><div><br></div>I have set my monitor routine as follows:</div><div>
<br>
</div><div><div> subroutine ShellKSPMonitor(ksp, n, rnorm, dummy, ierr)</div><div><br></div><div> implicit none</div><div><br></div><div>#include "finclude/petsc.h"</div><div><br></div><div> KSP :: ksp</div>
<div>
PetscErrorCode :: ierr</div><div> PetscInt :: n, dummy</div><div> PetscReal :: rnorm</div><div><br></div><div> if (n == 200) then</div><div> call KSPMonitorTrueResidualNorm(ksp,n,rnorm,dummy,ierr)</div></div></blockquote>
<div><br></div></div></div><div>I think it should work if dummy is 0, but we should really do NULL conversion</div><div>here and you should pass PETSC_NULL.</div><div><br></div><div> Matt</div><div><div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div> end if</div>
<div><br></div><div> return</div><div> end subroutine ShellKSPMonitor</div><div><br></div><div>And then in the main program I call:</div><div><br></div><div><div> call KSPMonitorSet(ksp,ShellKSPMonitor,PETSC_NULL_OBJECT, PETSC_NULL_FUNCTION, ierr)</div>
</div><div><br></div><div>As I have followed the example in the PETSc documentation, I am unsure where I have made a mistake.</div><div><br></div><div>Thanks, </div><div><br></div><div>Randy M</div><div><br></div><div><br>
</div><div class="gmail_quote">On Fri, Apr 13, 2012 at 5:01 PM, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@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">
<br>
Write a one line monitor that calls the true residual monitor when desired:<br>
<br>
PetscErrorCode myKSPMonitorTrueResidualNorm(KSP ksp,PetscInt n,PetscReal rnorm,void *dummy)<br>
{<br>
if (n % 10) {<br>
ierr = KSPMonitorTrueResidualNorm(ksp,n,rnorm,dummy);CHKERRQ(ierr);<br>
}<br>
}<br>
<br>
then call this on the KPS<br>
<br>
ierr = KSPMonitorSet(ksp,myKSPMonitorTrueResidualNorm,PETSC_VIEWER_STDOUT,0);CHKERRQ(ierr);<br>
<div><div><br>
<br>
On Apr 13, 2012, at 6:52 PM, Randall Mackie wrote:<br>
<br>
> In using ksp_monitor_true_residual_norm, is it possible to change how often this information is printed out?<br>
> That is, instead of every iteration, say I only want to see it every 10 or 20 iterations. Is there an easy way<br>
> to do this, other than creating my own monitor and doing it myself?<br>
><br>
> Thanks, Randy M.<br>
<br>
</div></div></blockquote></div><br></div>
</blockquote></div></div><span><font color="#888888"><br><br clear="all"><div><br></div>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener<br>
</font></span></blockquote></div><br></div>
</div></div></blockquote></div><br></div></div></div>
</blockquote></div><br></div></body></html>