<html><head><meta http-equiv="content-type" content="text/html; charset=us-ascii"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">In previous versions of PETSc we use to be able to call KSPMonitorTrueResidual from within our custom KSPMonitor, using an approach that is now commented out in the example found at <a href="https://urldefense.us/v3/__https://petsc.org/release/src/ksp/ksp/tutorials/ex2f.F90.html:__;!!G_uCfscf7eWS!ft8A0uxwHvTcBa5FwETVQYcImMgoOOueBeZT-7zP9jlaLFCDZ6ApRkBFUgoUzMRWCLbyU1FcxTgFoYMm8twVYS6KDQ$">https://petsc.org/release/src/ksp/ksp/tutorials/ex2f.F90.html:</a><div><br></div><div><pre width="80"><a name="line213"></a>!
<a name="line214">214: </a>! Cannot also use the <font color="#4169E1">default</font> <a href="https://urldefense.us/v3/__https://petsc.org/release/manualpages/KSP/KSP/__;!!G_uCfscf7eWS!ft8A0uxwHvTcBa5FwETVQYcImMgoOOueBeZT-7zP9jlaLFCDZ6ApRkBFUgoUzMRWCLbyU1FcxTgFoYMm8tx3EWnatA$">KSP</a> monitor routine showing how it may be used from Fortran
<a name="line215">215: </a>! since the Fortran compiler thinks the calling arguments are different in the two cases
<a name="line216">216: </a>!
<a name="line217">217: </a>! <a href="https://urldefense.us/v3/__https://petsc.org/release/manualpages/Sys/PetscCallA/__;!!G_uCfscf7eWS!ft8A0uxwHvTcBa5FwETVQYcImMgoOOueBeZT-7zP9jlaLFCDZ6ApRkBFUgoUzMRWCLbyU1FcxTgFoYMm8tzA4vLgOQ$">PetscCallA</a>(<a href="https://urldefense.us/v3/__https://petsc.org/release/manualpages/Viewer/PetscViewerAndFormatCreate/__;!!G_uCfscf7eWS!ft8A0uxwHvTcBa5FwETVQYcImMgoOOueBeZT-7zP9jlaLFCDZ6ApRkBFUgoUzMRWCLbyU1FcxTgFoYMm8tykmBKBfg$">PetscViewerAndFormatCreate</a>(<a href="https://urldefense.us/v3/__https://petsc.org/release/manualpages/Viewer/PETSC_VIEWER_STDOUT_WORLD/__;!!G_uCfscf7eWS!ft8A0uxwHvTcBa5FwETVQYcImMgoOOueBeZT-7zP9jlaLFCDZ6ApRkBFUgoUzMRWCLbyU1FcxTgFoYMm8tw_EZkgfA$">PETSC_VIEWER_STDOUT_WORLD</a>,<a href="https://urldefense.us/v3/__https://petsc.org/release/manualpages/Viewer/PetscViewerFormat/__;!!G_uCfscf7eWS!ft8A0uxwHvTcBa5FwETVQYcImMgoOOueBeZT-7zP9jlaLFCDZ6ApRkBFUgoUzMRWCLbyU1FcxTgFoYMm8tyZ_k-1Uw$">PETSC_VIEWER_DEFAULT</a>,vf,ierr))
<a name="line218">218: </a>! <a href="https://urldefense.us/v3/__https://petsc.org/release/manualpages/Sys/PetscCallA/__;!!G_uCfscf7eWS!ft8A0uxwHvTcBa5FwETVQYcImMgoOOueBeZT-7zP9jlaLFCDZ6ApRkBFUgoUzMRWCLbyU1FcxTgFoYMm8tzA4vLgOQ$">PetscCallA</a>(<a href="https://urldefense.us/v3/__https://petsc.org/release/manualpages/KSP/KSPMonitorSet/__;!!G_uCfscf7eWS!ft8A0uxwHvTcBa5FwETVQYcImMgoOOueBeZT-7zP9jlaLFCDZ6ApRkBFUgoUzMRWCLbyU1FcxTgFoYMm8tx6T8FJsA$">KSPMonitorSet</a>(ksp,<a href="https://urldefense.us/v3/__https://petsc.org/release/manualpages/KSP/KSPMonitorResidual/__;!!G_uCfscf7eWS!ft8A0uxwHvTcBa5FwETVQYcImMgoOOueBeZT-7zP9jlaLFCDZ6ApRkBFUgoUzMRWCLbyU1FcxTgFoYMm8txdiRZPSg$">KSPMonitorResidual</a>,vf,<a href="https://urldefense.us/v3/__https://petsc.org/release/manualpages/Viewer/PetscViewerAndFormatDestroy/__;!!G_uCfscf7eWS!ft8A0uxwHvTcBa5FwETVQYcImMgoOOueBeZT-7zP9jlaLFCDZ6ApRkBFUgoUzMRWCLbyU1FcxTgFoYMm8tzN4PpBPA$">PetscViewerAndFormatDestroy</a>,ierr))</pre><pre width="80"><br></pre><pre width="80">Instead, that example uses:</pre><pre width="80"><br></pre><pre width="80"><a name="line210">210: </a> <font color="#4169E1">if</font> (flg) then
<a name="line211">211: </a> vzero = 0
<a name="line212">212: </a> <a href="https://urldefense.us/v3/__https://petsc.org/release/manualpages/Sys/PetscCallA/__;!!G_uCfscf7eWS!ft8A0uxwHvTcBa5FwETVQYcImMgoOOueBeZT-7zP9jlaLFCDZ6ApRkBFUgoUzMRWCLbyU1FcxTgFoYMm8tzA4vLgOQ$">PetscCallA</a>(<a href="https://urldefense.us/v3/__https://petsc.org/release/manualpages/KSP/KSPMonitorSet/__;!!G_uCfscf7eWS!ft8A0uxwHvTcBa5FwETVQYcImMgoOOueBeZT-7zP9jlaLFCDZ6ApRkBFUgoUzMRWCLbyU1FcxTgFoYMm8tx6T8FJsA$">KSPMonitorSet</a>(ksp,MyKSPMonitor,vzero,PETSC_NULL_FUNCTION,ierr))
<a name="line213">213: </a>!</pre><pre width="80">Regardless of which of these approaches I try, I cannot use KSPMonitorTrueResidual in the MyKSPMonitor routine.</pre><pre width="80">I get the following error:</pre><pre width="80"><br></pre><pre width="80"><p class="MsoNormal" style="font-size: 12pt; white-space: normal; margin: 0in; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------<o:p></o:p></span></p><p class="MsoNormal" style="font-size: 12pt; white-space: normal; margin: 0in; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">[0]PETSC ERROR: Null argument, when expecting valid pointer<o:p></o:p></span></p><p class="MsoNormal" style="font-size: 12pt; white-space: normal; margin: 0in; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">[0]PETSC ERROR: Null Pointer: Parameter # 4<o:p></o:p></span></p><p class="MsoNormal" style="font-size: 12pt; white-space: normal; margin: 0in; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">[0]PETSC ERROR: See <a href="https://urldefense.us/v3/__https://petsc.org/release/faq/__;!!G_uCfscf7eWS!ft8A0uxwHvTcBa5FwETVQYcImMgoOOueBeZT-7zP9jlaLFCDZ6ApRkBFUgoUzMRWCLbyU1FcxTgFoYMm8tzxt44McA$" style="color: rgb(70, 120, 134);">https://petsc.org/release/faq/</a> for trouble shooting.<o:p></o:p></span></p><p class="MsoNormal" style="font-size: 12pt; white-space: normal; margin: 0in; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">[0]PETSC ERROR: PETSc Release Version 3.23.3, May 30, 2025<o:p></o:p></span></p><p class="MsoNormal" style="font-size: 12pt; white-space: normal; margin: 0in; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">[0]PETSC ERROR: ./test with 2 MPI process(es) and PETSC_ARCH linux-gfortran-complex-debug on rmackie-VirtualBox-2024 by rmackie Mon Jun 23 11:34:04 2025<o:p></o:p></span></p><p class="MsoNormal" style="font-size: 12pt; white-space: normal; margin: 0in; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">[0]PETSC ERROR: Configure options: --with-clean=1 --with-scalar-type=complex --with-debugging=1 --with-fortran=1 --download-mpich=1<o:p></o:p></span></p><p class="MsoNormal" style="font-size: 12pt; white-space: normal; margin: 0in; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">[0]PETSC ERROR: #1 KSPMonitorTrueResidual() at /home/rmackie/PETSc/petsc-3.23.3/src/ksp/ksp/interface/iterativ.c:400<o:p></o:p></span></p><p class="MsoNormal" style="font-size: 12pt; white-space: normal; margin: 0in; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">[0]PETSC ERROR: #2 test.F90:303<o:p></o:p></span></p><p class="MsoNormal" style="font-size: 12pt; white-space: normal; margin: 0in; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;"><br></span></p><p class="MsoNormal" style="font-size: 12pt; white-space: normal; margin: 0in; font-family: Aptos, sans-serif;"><br></p><p class="MsoNormal" style="margin: 0in;"><font face="Aptos, sans-serif"><span style="font-size: 14.666667px; white-space: normal;">I attach a slightly modified version of the example that demonstrates this behavior.</span></font></p><p class="MsoNormal" style="margin: 0in;"><font face="Aptos, sans-serif"><span style="font-size: 14.666667px; white-space: normal;"><br></span></font></p><p class="MsoNormal" style="margin: 0in;"><font face="Aptos, sans-serif"><span style="font-size: 14.666667px; white-space: normal;"><br></span></font></p><p class="MsoNormal" style="margin: 0in;"><span style="font-size: 11pt; font-family: Aptos, sans-serif; white-space: normal;">Thanks for the help,</span></p><p class="MsoNormal" style="margin: 0in;"><span style="font-size: 11pt; font-family: Aptos, sans-serif; white-space: normal;"><br></span></p><p class="MsoNormal" style="margin: 0in;"><span style="font-size: 11pt; font-family: Aptos, sans-serif; white-space: normal;">Randy</span></p><p class="MsoNormal" style="margin: 0in;"><font face="Aptos, sans-serif"><span style="font-size: 14.666667px; white-space: normal;"><br></span></font></p><p class="MsoNormal" style="margin: 0in;"><font face="Aptos, sans-serif"><span style="font-size: 14.666667px; white-space: normal;"></span></font></p></pre></div></body></html>