<div dir="ltr"><div style="font-size:12.8px">Thanks for the quick response. </div><div style="font-size:12.8px"><br></div><span style="font-size:12.8px">I tried Valgrind. Apart from a couple of other warnings in other parts of my code, now fixed, it shows the same stack I described:</span><div style="font-size:12.8px"><div>==22498== Invalid read of size 4</div><div>==22498==    at 0x55A5BFF: MatDestroy_MPIBAIJ_<wbr>MatGetSubmatrices (baijov.c:609)</div><div>==22498==    by 0x538A206: MatDestroy (matrix.c:1168)</div><div>==22498==    by 0x5F21F2F: PCSetUp_ILU (ilu.c:162)</div><div>==22498==    by 0x604898A: PCSetUp (precon.c:924)</div><div>==22498==    by 0x6189005: KSPSetUp (itfunc.c:379)</div><div>==22498==    by 0x618AB57: KSPSolve (itfunc.c:599)</div><div>==22498==    by 0x5FD4816: PCApply_ASM (asm.c:485)</div><div>==22498==    by 0x604204C: PCApply (precon.c:458)</div><div>==22498==    by 0x6055C76: pcapply_ (preconf.c:223)</div><div>==22498==    by 0x42F500: __cpr_linsolver_MOD_cprapply (cpr_linsolver.F90:419)</div><div>==22498==    by 0x5F42431: ourshellapply (zshellpcf.c:41)</div><div>==22498==    by 0x5F3697A: PCApply_Shell (shellpc.c:115)</div><div>==22498==    by 0x604204C: PCApply (precon.c:458)</div><div>==22498==    by 0x61B74E7: KSP_PCApply (kspimpl.h:251)</div><div>==22498==    by 0x61B83C3: KSPInitialResidual (itres.c:67)</div><div>==22498==    by 0x6104EF9: KSPSolve_BCGS (bcgs.c:44)</div><div>==22498==    by 0x618B77E: KSPSolve (itfunc.c:656)</div><div>==22498==    by 0x62BB02D: SNESSolve_NEWTONLS (ls.c:224)</div><div>==22498==    by 0x6245706: SNESSolve (snes.c:3967)</div><div>==22498==    by 0x6265A58: snessolve_ (zsnesf.c:167)</div><div>==22498==  Address 0x0 is not stack'd, malloc'd or (recently) free'd</div><div>==22498== </div></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">PETSc version: this is from include/petscversion.h:</div><div style="font-size:12.8px"><div>#define PETSC_VERSION_RELEASE    0</div><div>#define PETSC_VERSION_MAJOR      3</div><div>#define PETSC_VERSION_MINOR      7</div><div>#define PETSC_VERSION_SUBMINOR   5</div><div>#define PETSC_VERSION_PATCH      0</div><div>#define PETSC_RELEASE_DATE       "Apr, 25, 2016"</div><div>#define PETSC_VERSION_DATE       "unknown"</div></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">This is the recommended version of PETSc for using with PFLOTRAN:</div><div><span style="font-size:12.8px"><a href="http://documentation.pflotran.org/user_guide/how_to/installation/linux.html#linux-install">http://documentation.pflotran.org/user_guide/how_to/installation/linux.html#linux-install</a></span><br></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Exact debugger output:</span></div><div><span style="font-size:12.8px">It's a graphical debugger so there isn't much to copy/paste.</span></div><div><span style="font-size:12.8px">The exact message is:</span></div><div><span style="font-size:12.8px"><br></span></div><div><div><span style="font-size:12.8px">Memory error detected in MatDestroy​_MPIBAIJ​_MatGetSubmatrices ​(baijov.c:609)​:</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">null pointer dereference or unaligned memory access.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">I can provide screenshots if that would help. </span></div><div><span style="font-size:12.8px"><br></span></div><div style="font-size:12.8px">-ksp_view_pre:</div></div><div style="font-size:12.8px">I tried this, it doesn't seem to give information about the KSPs in question. To be clear, this is</div><div style="font-size:12.8px">part of an attempt to implement the two stage CPR-AMG preconditioner in PFLOTRAN, so the</div><div style="font-size:12.8px">KSP and PC objects involved are:</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">KSP: linear solver inside a SNES, inside PFLOTRAN (BCGS),</div><div style="font-size:12.8px">which has a PC:</div><div style="font-size:12.8px">   PC: shell, the CPR implementation, which calls two more preconditioners, T1 and T2, in sequence:</div><div style="font-size:12.8px">      T1: another shell, which calls a KSP (GMRES), which has a PC which is HYPRE BOOMERAMG</div><div style="font-size:12.8px">      T2: ASM, this is the problematic one.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">-ksp_view_pre doesn't seem to give us any information about the ASM preconditioner object</div><div style="font-size:12.8px">or it's ILU sub-KSPs; presumably it crashes before getting there. We do get a lot of output about</div><div style="font-size:12.8px">T1, for example:</div><div style="font-size:12.8px"><br></div><div><div><span style="font-size:12.8px">KSP Object: T1 24 MPI processes</span></div><div><span style="font-size:12.8px">  type: gmres</span></div><div><span style="font-size:12.8px">    GMRES: restart=30, using Classical (unmodified) Gram-Schmidt Orthogonalization with no iterative refinement</span></div><div><span style="font-size:12.8px">    GMRES: happy breakdown tolerance 1e-30</span></div><div><span style="font-size:12.8px">  maximum iterations=10000, initial guess is zero</span></div><div><span style="font-size:12.8px">  tolerances:  relative=1e-05, absolute=1e-50, divergence=10000.</span></div><div><span style="font-size:12.8px">  left preconditioning</span></div><div><span style="font-size:12.8px">  using DEFAULT norm type for convergence test</span></div><div><span style="font-size:12.8px">PC Object: 24 MPI processes</span></div><div><span style="font-size:12.8px">  type: hypre</span></div><div><span style="font-size:12.8px">  PC has not been set up so information may be incomplete</span></div><div><span style="font-size:12.8px">    HYPRE BoomerAMG preconditioning</span></div><div><span style="font-size:12.8px">    HYPRE BoomerAMG: Cycle type V</span></div><div><span style="font-size:12.8px">    HYPRE BoomerAMG: Maximum number of levels 25</span></div><div><span style="font-size:12.8px">    HYPRE BoomerAMG: Maximum number of iterations PER hypre call 1</span></div><div><span style="font-size:12.8px">    HYPRE BoomerAMG: Convergence tolerance PER hypre call 0.</span></div><div><span style="font-size:12.8px">    HYPRE BoomerAMG: Threshold for strong coupling 0.25</span></div><div><span style="font-size:12.8px">    HYPRE BoomerAMG: Interpolation truncation factor 0.</span></div><div><span style="font-size:12.8px">    HYPRE BoomerAMG: Interpolation: max elements per row 0</span></div><div><span style="font-size:12.8px">    HYPRE BoomerAMG: Number of levels of aggressive coarsening 0</span></div><div><span style="font-size:12.8px">    HYPRE BoomerAMG: Number of paths for aggressive coarsening 1</span></div><div><span style="font-size:12.8px">    HYPRE BoomerAMG: Maximum row sums 0.9</span></div><div><span style="font-size:12.8px">    HYPRE BoomerAMG: Sweeps down         1</span></div><div><span style="font-size:12.8px">    HYPRE BoomerAMG: Sweeps up           1</span></div><div><span style="font-size:12.8px">    HYPRE BoomerAMG: Sweeps on coarse    1</span></div><div><span style="font-size:12.8px">    HYPRE BoomerAMG: Relax down          symmetric-SOR/Jacobi</span></div><div><span style="font-size:12.8px">    HYPRE BoomerAMG: Relax up            symmetric-SOR/Jacobi</span></div><div><span style="font-size:12.8px">    HYPRE BoomerAMG: Relax on coarse     Gaussian-elimination</span></div><div><span style="font-size:12.8px">    HYPRE BoomerAMG: Relax weight  (all)      1.</span></div><div><span style="font-size:12.8px">    HYPRE BoomerAMG: Outer relax weight (all) 1.</span></div><div><span style="font-size:12.8px">    HYPRE BoomerAMG: Using CF-relaxation</span></div><div><span style="font-size:12.8px">    HYPRE BoomerAMG: Not using more complex smoothers.</span></div><div><span style="font-size:12.8px">    HYPRE BoomerAMG: Measure type        local</span></div><div><span style="font-size:12.8px">    HYPRE BoomerAMG: Coarsen type        Falgout</span></div><div><span style="font-size:12.8px">    HYPRE BoomerAMG: Interpolation type  classical</span></div><div><span style="font-size:12.8px">  linear system matrix = precond matrix:</span></div><div><span style="font-size:12.8px">  Mat Object: 24 MPI processes</span></div><div><span style="font-size:12.8px">    type: mpiaij</span></div><div><span style="font-size:12.8px">    rows=1122000, cols=1122000</span></div><div><span style="font-size:12.8px">    total: nonzeros=7780000, allocated nonzeros=7780000</span></div><div><span style="font-size:12.8px">    total number of mallocs used during MatSetValues calls =0</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Thanks,</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Daniel Stone</span></div><div style="font-size:12.8px"><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Nov 24, 2017 at 4:08 PM, Smith, Barry F. <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>
  First run under valgrind.   <a href="https://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind" rel="noreferrer" target="_blank">https://www.mcs.anl.gov/petsc/<wbr>documentation/faq.html#<wbr>valgrind</a><br>
<br>
   If that doesn't help send the exact output from the debugger (cut and paste) and the exact version of PETSc you are using.<br>
Also out put from -ksp_view_pre<br>
<span class="HOEnZb"><font color="#888888"><br>
  Barry<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
> On Nov 24, 2017, at 8:03 AM, Daniel Stone <<a href="mailto:daniel.stone@opengosim.com">daniel.stone@opengosim.com</a>> wrote:<br>
><br>
> Hello,<br>
><br>
> I'm getting a memory exception crash every time I try to run the ASM preconditioner in parallel, can anyone help?<br>
><br>
> I'm using a debugger so I can give most of the stack:<br>
><br>
> PCApply_ASM (asm.c:line 485)<br>
>   KSPSolve (itfunc.c:line 599)<br>
>     KSPSetUp (itfunc.c:line 379)<br>
>        PCSetUp (precon.c: 924)<br>
>           PCSetUp_ILU (ilu.c:line 162)<br>
>             MatDestroy  (matrix.c:line 1168)<br>
>               MatDestroy_MPIBAIJ_<wbr>MatGetSubMatrices (baijov.c:line 609)<br>
><br>
><br>
> The problem line is then in  MatDestroy_MPIBAIJ_<wbr>MatGetSubMatrices,<br>
> in the file baijov.c, line 609:<br>
><br>
> if (!submatj->id) {<br>
><br>
> At this point submatj has no value, address 0x0, and so the attempt to access submatj->id<br>
> causes the memory error. We can see in the lines just above 609 where submatj is supposed to<br>
> come from, it should basically be an attribute of C->data, where C is the input matrix.<br>
><br>
> Does anyone have any ideas where to start with getting this to work? I can provide a lot more information<br>
> from the debugger if need.<br>
><br>
> Many thanks in advance,<br>
><br>
> Daniel Stone<br>
><br>
<br>
</div></div></blockquote></div><br></div>