<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. </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"><<a href="mailto:rlmackie862@gmail.com">rlmackie862@gmail.com</a>></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 </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>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><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><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>