<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">As the error message says, use valgrind <a href="https://www.valgrind.org/" class="">https://www.valgrind.org/</a> to catch these kind of issues<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Apr 9, 2021, at 10:43 AM, dazza simplythebest <<a href="mailto:sayosale@hotmail.com" class="">sayosale@hotmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class="">Dear All,</div><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class=""> I am getting a puzzling 'Segmentation Violation' error when I try to</div><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class="">write out an integer array using PetscIntView in a Fortran code. I have written the small<span class="Apple-converted-space"> </span><br class=""></div><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class="">code below which reproduces the problem. All this code does is create</div><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class=""> a PetscInt array, initialise this array, then try to write it out to screen.</div><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class="">Interestingly PetscIntView<span class="Apple-converted-space"> </span><i class="">does</i><span class="Apple-converted-space"> </span>seem to correctly write out all the values to</div><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class="">the screen (which agree with a direct write), but then fails before it can return to</div><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class="">the main program (see output pasted in below).</div><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class=""><br class=""></div><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class="">I think I must be doing something quite silly, but just<span class="Apple-converted-space"> </span><br class=""></div><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class="">can't quite see what it is! Any suggestions will be very welcome.</div><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class=""> Many thanks,</div><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class=""> Dan<br class=""></div><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class=""> <span class="Apple-converted-space"> </span><br class=""></div><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class="">Code:</div><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class=""><br class=""></div><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class=""> <span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""><span class="Apple-converted-space"> </span> MODULE ALL_STAB_ROUTINES</span><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> IMPLICIT NONE</span></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> CONTAINS</span></div><div class=""><br class=""></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> SUBROUTINE WRITE_ROWS_TO_PETSC_MATRIX( ISIZE, JALOC)</span></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class="">#include <slepc/finclude/slepceps.h></span></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> use slepceps</span></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> IMPLICIT NONE</span></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> PetscInt, INTENT (IN) :: ISIZE</span></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> PetscInt, INTENT(INOUT), DIMENSION(0:ISIZE-1) :: JALOC</span></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> PetscErrorCode :: ierr</span></div><div class=""><br class=""></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> write(*,*)'check 02: ',shape(jaloc),lbound(jaloc),ubound(jaloc)</span></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> write(*,*)jaloc</span></div><div class=""><br class=""></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> write(*,*)'now for PetscIntView ...'</span></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> call PetscIntView(ISIZE,JALOC, PETSC_VIEWER_STDOUT_WORLD)</span></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> CHKERRA(ierr)</span></div><div class=""><br class=""></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> END SUBROUTINE WRITE_ROWS_TO_PETSC_MATRIX</span></div><div class=""><br class=""></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> END MODULE ALL_STAB_ROUTINES </span></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> </span></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> program stabbo</span></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> USE MPI</span></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class="">#include <slepc/finclude/slepceps.h></span></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> use slepceps</span></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> USE ALL_STAB_ROUTINES</span></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> IMPLICIT NONE</span><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> </span></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> PetscInt, ALLOCATABLE, DIMENSION(:) :: JALOC</span></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> PetscInt, PARAMETER :: ISIZE = 10</span></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> PetscInt, parameter :: FOUR=4</span></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> PetscErrorCode :: ierr_pets</span></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> call SlepcInitialize(PETSC_NULL_CHARACTER,ierr_pets)</span></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> </span></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> ALLOCATE(JALOC(0:ISIZE-1))</span></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> JALOC = FOUR</span></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> write(*,*)'check 01: ',shape(jaloc),lbound(jaloc),ubound(jaloc)</span></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> CALL WRITE_ROWS_TO_PETSC_MATRIX(ISIZE, JALOC)</span></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> CALL SlepcFinalize(ierr_pets)</span></div><div class=""><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);" class=""> END PROGRAM STABBO <span class="Apple-converted-space"> </span></span><br class=""></div><div class=""><br class=""></div></div><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class=""><span style="color: rgb(6, 64, 12);" class="">Output:</span></div><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class=""><br class=""></div><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class=""><span style="color: rgb(6, 64, 12);" class="">dan@super01 /data/work/rotplane/omega_to_zero/stability/test/tmp10/tmp3 $ mpiexec.hydra -n 1 ./trashy.exe</span><div class=""><span style="color: rgb(6, 64, 12);" class=""> check 01: 10 0 9</span></div><div class=""><span style="color: rgb(6, 64, 12);" class=""> check 02: 10 0 9</span></div><div class=""><span style="color: rgb(6, 64, 12);" class=""> 4 4 4</span></div><div class=""><span style="color: rgb(6, 64, 12);" class=""> 4 4 4</span></div><div class=""><span style="color: rgb(6, 64, 12);" class=""> 4 4 4</span></div><div class=""><span style="color: rgb(6, 64, 12);" class=""> 4</span></div><div class=""><span style="color: rgb(6, 64, 12);" class=""> now for PetscIntView ...</span></div><div class=""><span style="color: rgb(6, 64, 12);" class="">0: 4 4 4 4 4 4 4 4 4 4</span></div><div class=""><span style="color: rgb(6, 64, 12);" class="">[0]PETSC ERROR: ------------------------------------------------------------------------</span></div><div class=""><span style="color: rgb(6, 64, 12);" class="">[0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range</span></div><div class=""><span style="color: rgb(6, 64, 12);" class="">[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger</span></div><div class=""><span style="color: rgb(6, 64, 12);" class="">[0]PETSC ERROR: or see<span class="Apple-converted-space"> </span><a href="https://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind" class="">https://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind</a></span></div><div class=""><span style="color: rgb(6, 64, 12);" class="">[0]PETSC ERROR: or try<span class="Apple-converted-space"> </span><a href="http://valgrind.org/" class="">http://valgrind.org</a><span class="Apple-converted-space"> </span>on GNU/linux and Apple Mac OS X to find memory corruption errors</span></div><div class=""><span style="color: rgb(6, 64, 12);" class="">[0]PETSC ERROR: likely location of problem given in stack below</span></div><div class=""><span style="color: rgb(6, 64, 12);" class="">[0]PETSC ERROR: --------------------- Stack Frames ------------------------------------</span></div><div class=""><span style="color: rgb(6, 64, 12);" class="">[0]PETSC ERROR: Note: The EXACT line numbers in the stack are not available,</span></div><div class=""><span style="color: rgb(6, 64, 12);" class="">[0]PETSC ERROR: INSTEAD the line number of the start of the function</span></div><div class=""><span style="color: rgb(6, 64, 12);" class="">[0]PETSC ERROR: is given.</span></div><div class=""><span style="color: rgb(6, 64, 12);" class="">[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------</span></div><div class=""><span style="color: rgb(6, 64, 12);" class="">[0]PETSC ERROR: Signal received</span></div><div class=""><span style="color: rgb(6, 64, 12);" class="">[0]PETSC ERROR: See<span class="Apple-converted-space"> </span><a href="https://www.mcs.anl.gov/petsc/documentation/faq.html" class="">https://www.mcs.anl.gov/petsc/documentation/faq.html</a><span class="Apple-converted-space"> </span>for trouble shooting.</span></div><div class=""><span style="color: rgb(6, 64, 12);" class="">[0]PETSC ERROR: Petsc Release Version 3.14.5, Mar 03, 2021</span></div><div class=""><span style="color: rgb(6, 64, 12);" class="">[0]PETSC ERROR: ./trashy.exe on a named super01 by darren Fri Apr 9 16:28:25 2021</span></div><div class=""><span style="color: rgb(6, 64, 12);" class="">[0]PETSC ERROR: Configure options --package-prefix-hash=/home/darren/petsc-hash-pkgs --with-cc=mpiicc --with-cxx=mpiicpc --with-fc=mpiifort --with-mpiexec=mpiexec.hydra COPTFLAGS="-g -O" FOPTFLAGS="-g -O" CXXOPTFLAGS="-g -O" --with-64-bit-indices=1 --with-scalar-type=complex --with-precision=double --with-debugging=1 --with-blaslapack-dir=/opt/intel/compilers_and_libraries_2020.0.166/linux/mkl --with-mkl_pardiso-dir=/opt/intel/compilers_and_libraries_2020.0.166/linux/mkl --with-mkl_cpardiso-dir=/opt/intel/compilers_and_libraries_2020.0.166/linux/mkl --download-mumps --download-scalapack --download-cmake PETSC_ARCH=arch-ci-linux-intel-mkl-cmplx-ilp64-dbg-ftn-with-external</span></div><div class=""><span style="color: rgb(6, 64, 12);" class="">[0]PETSC ERROR: #1 User provided function() line 0 in unknown file</span></div><div class=""><span style="color: rgb(6, 64, 12);" class="">[0]PETSC ERROR: Checking the memory for corruption.</span></div><div class=""><span style="color: rgb(6, 64, 12);" class="">Abort(50176059) on node 0 (rank 0 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, 50176059) - process 0</span></div></div></div></blockquote></div><br class=""></body></html>