<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Dear All,</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I am getting a puzzling 'Segmentation Violation' error when I try to</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
write out an integer array using PetscIntView in a Fortran code. I have written the small
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
code below which reproduces the problem. All this code does is create</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
a PetscInt array, initialise this array, then try to write it out to screen.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Interestingly PetscIntView <i>does</i> seem to correctly write out all the values to</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
the screen (which agree with a direct write), but then fails before it can return to</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
the main program (see output pasted in below).</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I think I must be doing something quite silly, but just <br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
can't quite see what it is! Any suggestions will be very welcome.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Many thanks,</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Dan<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Code:</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);"> MODULE ALL_STAB_ROUTINES</span>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);"> IMPLICIT NONE</span></div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);"> CONTAINS</span></div>
<div><br>
</div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);"> SUBROUTINE WRITE_ROWS_TO_PETSC_MATRIX( ISIZE, JALOC)</span></div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);">#include <slepc/finclude/slepceps.h>
</span></div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);"> use slepceps</span></div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);"> IMPLICIT NONE</span></div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);"> PetscInt, INTENT (IN) :: ISIZE</span></div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);"> PetscInt, INTENT(INOUT), DIMENSION(0:ISIZE-1) :: JALOC
</span></div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);"> PetscErrorCode :: ierr</span></div>
<div><br>
</div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);"> write(*,*)'check 02: ',shape(jaloc),lbound(jaloc),ubound(jaloc)</span></div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);"> write(*,*)jaloc</span></div>
<div><br>
</div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);"> write(*,*)'now for PetscIntView ...'</span></div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);"> call PetscIntView(ISIZE,JALOC, PETSC_VIEWER_STDOUT_WORLD)</span></div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);"> CHKERRA(ierr)</span></div>
<div><br>
</div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);"> END SUBROUTINE WRITE_ROWS_TO_PETSC_MATRIX</span></div>
<div><br>
</div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);"> END MODULE ALL_STAB_ROUTINES
</span></div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);">
</span></div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);"> program stabbo
</span></div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);"> USE MPI</span></div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);">#include <slepc/finclude/slepceps.h></span></div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);"> use slepceps</span></div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);"> USE ALL_STAB_ROUTINES</span></div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);"> IMPLICIT NONE</span><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);">
</span></div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);"> PetscInt, ALLOCATABLE, DIMENSION(:) :: JALOC</span></div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);"> PetscInt, PARAMETER :: ISIZE = 10</span></div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);"> PetscInt, parameter :: FOUR=4
</span></div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);"> PetscErrorCode :: ierr_pets</span></div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);"> call SlepcInitialize(PETSC_NULL_CHARACTER,ierr_pets)</span></div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);"> </span></div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);"> ALLOCATE(JALOC(0:ISIZE-1))</span></div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);"> JALOC = FOUR</span></div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);"> write(*,*)'check 01: ',shape(jaloc),lbound(jaloc),ubound(jaloc)</span></div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);"> CALL WRITE_ROWS_TO_PETSC_MATRIX(ISIZE, JALOC)</span></div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);"> CALL SlepcFinalize(ierr_pets)</span></div>
<div><span style="font-family: Cambria, Georgia, serif; color: rgb(23, 78, 134);"> END PROGRAM STABBO
</span><br>
</div>
<div><br>
</div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(6, 64, 12);">Output:</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(6, 64, 12);">dan@super01 /data/work/rotplane/omega_to_zero/stability/test/tmp10/tmp3 $ mpiexec.hydra -n 1 ./trashy.exe
</span>
<div><span style="color: rgb(6, 64, 12);"> check 01: 10 0 9</span></div>
<div><span style="color: rgb(6, 64, 12);"> check 02: 10 0 9</span></div>
<div><span style="color: rgb(6, 64, 12);"> 4 4 4</span></div>
<div><span style="color: rgb(6, 64, 12);"> 4 4 4</span></div>
<div><span style="color: rgb(6, 64, 12);"> 4 4 4</span></div>
<div><span style="color: rgb(6, 64, 12);"> 4</span></div>
<div><span style="color: rgb(6, 64, 12);"> now for PetscIntView ...</span></div>
<div><span style="color: rgb(6, 64, 12);">0: 4 4 4 4 4 4 4 4 4 4</span></div>
<div><span style="color: rgb(6, 64, 12);">[0]PETSC ERROR: ------------------------------------------------------------------------</span></div>
<div><span style="color: rgb(6, 64, 12);">[0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range</span></div>
<div><span style="color: rgb(6, 64, 12);">[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger</span></div>
<div><span style="color: rgb(6, 64, 12);">[0]PETSC ERROR: or see https://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind</span></div>
<div><span style="color: rgb(6, 64, 12);">[0]PETSC ERROR: or try http://valgrind.org on GNU/linux and Apple Mac OS X to find memory corruption errors</span></div>
<div><span style="color: rgb(6, 64, 12);">[0]PETSC ERROR: likely location of problem given in stack below</span></div>
<div><span style="color: rgb(6, 64, 12);">[0]PETSC ERROR: --------------------- Stack Frames ------------------------------------</span></div>
<div><span style="color: rgb(6, 64, 12);">[0]PETSC ERROR: Note: The EXACT line numbers in the stack are not available,</span></div>
<div><span style="color: rgb(6, 64, 12);">[0]PETSC ERROR: INSTEAD the line number of the start of the function</span></div>
<div><span style="color: rgb(6, 64, 12);">[0]PETSC ERROR: is given.</span></div>
<div><span style="color: rgb(6, 64, 12);">[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------</span></div>
<div><span style="color: rgb(6, 64, 12);">[0]PETSC ERROR: Signal received</span></div>
<div><span style="color: rgb(6, 64, 12);">[0]PETSC ERROR: See https://www.mcs.anl.gov/petsc/documentation/faq.html for trouble shooting.</span></div>
<div><span style="color: rgb(6, 64, 12);">[0]PETSC ERROR: Petsc Release Version 3.14.5, Mar 03, 2021
</span></div>
<div><span style="color: rgb(6, 64, 12);">[0]PETSC ERROR: ./trashy.exe on a named super01 by darren Fri Apr 9 16:28:25 2021</span></div>
<div><span style="color: rgb(6, 64, 12);">[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><span style="color: rgb(6, 64, 12);">[0]PETSC ERROR: #1 User provided function() line 0 in unknown file</span></div>
<div><span style="color: rgb(6, 64, 12);">[0]PETSC ERROR: Checking the memory for corruption.</span></div>
<div><span style="color: rgb(6, 64, 12);">Abort(50176059) on node 0 (rank 0 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, 50176059) - process 0</span></div>
<br>
</div>
</body>
</html>