<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi Matt,<div><br></div><div>I'm afraid it didn't work by passing in dummy=0.&nbsp;</div><div><br></div><div>Randy</div><div><br></div><div><br><div><div>On Apr 17, 2012, at 10:39 AM, Matthew Knepley wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">On Tue, Apr 17, 2012 at 1:27 PM, Randall Mackie <span dir="ltr">&lt;<a href="mailto:rlmackie862@gmail.com">rlmackie862@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
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&nbsp;</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&nbsp;</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>&nbsp; subroutine ShellKSPMonitor(ksp, n, rnorm, dummy, ierr)</div><div><br></div><div>&nbsp; implicit none</div><div><br></div><div>#include "finclude/petsc.h"</div><div><br></div><div>&nbsp; KSP :: ksp</div>
<div>
&nbsp; PetscErrorCode :: ierr</div><div>&nbsp; PetscInt :: n, dummy</div><div>&nbsp; PetscReal :: rnorm</div><div><br></div><div>&nbsp; if (n == 200) then</div><div>&nbsp; &nbsp; call KSPMonitorTrueResidualNorm(ksp,n,rnorm,dummy,ierr)</div></div></blockquote>
<div><br></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>&nbsp; &nbsp;Matt</div><div>&nbsp;</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div>&nbsp; end if</div>
<div><br></div><div>&nbsp; return</div><div>&nbsp; end subroutine ShellKSPMonitor</div><div><br></div><div>And then in the main program I call:</div><div><br></div><div><div>&nbsp; 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,&nbsp;</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">&lt;<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
 &nbsp; Write a one line monitor that calls the true residual monitor when desired:<br>
<br>
 &nbsp; &nbsp;PetscErrorCode &nbsp;myKSPMonitorTrueResidualNorm(KSP ksp,PetscInt n,PetscReal rnorm,void *dummy)<br>
 &nbsp; &nbsp;{<br>
 &nbsp; &nbsp; &nbsp; &nbsp;if (n % 10) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ierr = KSPMonitorTrueResidualNorm(ksp,n,rnorm,dummy);CHKERRQ(ierr);<br>
 &nbsp; &nbsp; &nbsp; &nbsp;}<br>
 &nbsp; &nbsp;}<br>
<br>
 &nbsp; &nbsp;then call this on the KPS<br>
<br>
 &nbsp; 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>
&gt; In using ksp_monitor_true_residual_norm, is it possible to change how often this information is printed out?<br>
&gt; That is, instead of every iteration, say I only want to see it every 10 or 20 iterations. Is there an easy way<br>
&gt; to do this, other than creating my own monitor and doing it myself?<br>
&gt;<br>
&gt; Thanks, Randy M.<br>
<br>
</div></div></blockquote></div><br></div>
</blockquote></div><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>
</blockquote></div><br></div></body></html>