<div>Thank you for your replies.<br /><br />Tried to configure commited version of PETSc from Satish Balay branch (<span style="background-color:#ffffff;color:#000000;float:none;font-family:'arial' , sans-serif;font-size:15px;font-style:normal;font-weight:400;text-decoration-style:initial;text-indent:0px;text-transform:none;white-space:pre-wrap;word-spacing:0px">balay/fix-ftn-i8/maint</span>) and faced to the same error when running test example ex5f<div> </div><div><br /><em>call SNESCreate(PETSC_COMM_WORLD,snes,ierr)</em></div><div> </div><div><em>Error: Type mismatch in argument «z» at (1); passed INTEGER(4) to INTEGER(8)</em></div><div> </div><div><br />At the moment, some subroutines (such as <em>PetscInitialize, PetscFinalize, MatSetValue, VecSetValue</em>) work with the correct size of the variable <em>ierr </em>defined as <em>PetscErrorCode</em>, and some do not.</div><div>The following subroutines still require <em>ierr </em>to be of type <em>INTEGER(8):</em><div> </div><div><br /><em>VecGetSubVector, VecAssemblyBegin, VecAssemblyEnd, VecScatterBegin, VecScatterEnd, VecScatterDestroy, VecCreateMPI, VecDuplicate, VecZeroEntries, VecAYPX, VecWAXPY, VecWAXPY</em></div><div><em>MatMult, MatDestroy, MatAssemblyBegin, MatAssemblyEnd, MatZeroEntries, MatCreateSubMatrix, MatScale, MatDiagonalSet, MatGetDiagonal, MatDuplicat, MatSetSizes, MatSetFromOptions</em></div></div><div><br />Unfortunately, I'm not sure if this is the only issue that occurs when switching to the 64-bit version of PETSc.<br />I can set the size of the variables <em>ierr </em>so that the solver compilation process completes successfully, but I get the following error when solving linear algebra system by use of <em>KSPSolve </em>subroutine:<br /> </div><div> </div><p style="margin:0px;text-indent:0px"><em>[0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range</em></p></div><div> </div><div>Because the solver with the 32-bit version of PETSc works properly, I suppose that the cause of the errors (for 64-bit version of PETSc) is the inappropriate size of the variables.<br />I compiled PETSc with flags: <em>with-64-bit-indices </em>and <em>-fdefault-integer-8. </em><br />Also changed the size of <em>MPI_Integer to MPI_Integer8:</em></div><div><em>MPI_Bcast(npart,nnds,MPI_Integer8,0,MPI_Comm_World,ierr).</em></div><div> </div><div>I am probably missing something else.<br /><br /><em>​​​​​​​</em><br />Kind regards,<br />Dmitry Melnichuk</div><div> </div><div>16.01.2020, 01:26, "Balay, Satish" <balay@mcs.anl.gov>:</div><blockquote><p>I have some changes (incomplete) here -<br /><br />my hack to bfort.<br /><br />diff --git a/src/bfort/bfort.c b/src/bfort/bfort.c<br />index 0efe900..31ff154 100644<br />--- a/src/bfort/bfort.c<br />+++ b/src/bfort/bfort.c<br />@@ -1654,7 +1654,7 @@ void PrintDefinition( FILE *fout, int is_function, char *name, int nstrings,<br /><br />     /* Add a "decl/result(name) for functions */<br />     if (useFerr) {<!-- --><br />- OutputFortranToken( fout, 7, "integer" );<br />+ OutputFortranToken( fout, 7, "PetscErrorCode" );<br />        OutputFortranToken( fout, 1, errArgNameParm);<br />     } else if (is_function) {<!-- --><br />        OutputFortranToken( fout, 7, ArgToFortran( rt->name ) );<br /><br /><br />And my changes to petsc are on branch balay/fix-ftn-i8/maint<br /><br />Satish<br /><br />On Wed, 15 Jan 2020, Smith, Barry F. via petsc-users wrote:<br /> </p><blockquote><br />   Working on it now; may be doable<br /><br /><br /><br /> > On Jan 15, 2020, at 11:55 AM, Matthew Knepley <<a href="mailto:knepley@gmail.com">knepley@gmail.com</a>> wrote:<br /> ><br /> > On Wed, Jan 15, 2020 at 10:26 AM Дмитрий Мельничук <<a href="mailto:dmitry.melnichuk@geosteertech.com">dmitry.melnichuk@geosteertech.com</a>> wrote:<br /> > > And I'm not sure why you are having to use PetscInt for ierr. All PETSc routines should be suing 'PetscErrorCode for ierr'<br /> ><br /> > If I define ierr as PetscErrorCode for all subroutines given below<br /> ><br /> > call VecDuplicate(Vec_U,Vec_Um,ierr)<br /> > call VecCopy(Vec_U,Vec_Um,ierr)<br /> > call VecGetLocalSize(Vec_U,j,ierr)<br /> > call VecGetOwnershipRange(Vec_U,j1,j2,ierr)<br /> ><br /> > then errors occur with first three subroutines:<br /> > Error: Type mismatch in argument «z» at (1); passed INTEGER(4) to INTEGER(8).<br /> ><br /> > Barry,<br /> ><br /> > It looks like the ftn-auto interfaces are using 'integer' for the error code, whereas the ftn-custom is using PetscErrorCode.<br /> > Could we make the generated ones use integer?<br /> ><br /> > Thanks,<br /> ><br /> > Matt<br /> ><br /> > Therefore I was forced to define ierr as PetscInt for VecDuplicate, VecCopy, VecGetLocalSize subroutines to fix these errors.<br /> > Why some subroutines sue 8-bytes integer type of ierr (PetscInt), while others - 4-bytes integer type of ierr (PetscErrorCode) remains a mystery for me.<br /> ><br /> > > What version of PETSc are you using?<br /> ><br /> > version 3.12.2<br /> ><br /> > > Are you seeing this issue with a PETSc example?<br /> ><br /> > I will check it tomorrow and let you know.<br /> ><br /> > Kind regards,<br /> > Dmitry Melnichuk<br /> ><br /> ><br /> ><br /> > 15.01.2020, 17:14, "Balay, Satish" <<a href="mailto:balay@mcs.anl.gov">balay@mcs.anl.gov</a>>:<br /> > -fdefault-integer-8 is likely to break things [esp with MPI - where 'integer' is used everywhere for ex - MPI_Comm etc - so MPI includes become incompatible with the MPI library with -fdefault-integer-8.]<br /> ><br /> > And I'm not sure why you are having to use PetscInt for ierr. All PETSc routines should be suing 'PetscErrorCode for ierr'<br /> ><br /> > What version of PETSc are you using? Are you seeing this issue with a PETSc example?<br /> ><br /> > Satish<br /> ><br /> > On Wed, 15 Jan 2020, Дмитрий Мельничук wrote:<br /> ><br /> ><br /> > Hello all!<br /> > At present time I need to compile solver called Defmod (<a href="https://bitbucket.org/stali/defmod/wiki/Home">https://bitbucket.org/stali/defmod/wiki/Home</a>), which is written in Fortran 95.<br /> > Defmod uses PETSc for solving linear algebra system.<br /> > Solver compilation with 32-bit version of PETSc does not cause any problem.<br /> > But solver compilation with 64-bit version of PETSc produces an error with size of ierr PETSc variable.<br /> ><br /> > 1. For example, consider the following statements written in Fortran:<br /> ><br /> ><br /> > PetscErrorCode :: ierr_m<br /> > PetscInt :: ierr<br /> > ...<br /> > ...<br /> > call VecDuplicate(Vec_U,Vec_Um,ierr)<br /> > call VecCopy(Vec_U,Vec_Um,ierr)<br /> > call VecGetLocalSize(Vec_U,j,ierr)<br /> > call VecGetOwnershipRange(Vec_U,j1,j2,ierr_m)<br /> ><br /> ><br /> > As can be seen first three subroutunes require ierr to be size of INTEGER(8), while the last subroutine (VecGetOwnershipRange) requires ierr to be size of INTEGER(4).<br /> > Using the same integer format gives an error:<br /> ><br /> > There is no specific subroutine for the generic ‘vecgetownershiprange’ at (1)<br /> ><br /> > 2. Another example is:<br /> ><br /> ><br /> > call MatAssemblyBegin(Mat_K,Mat_Final_Assembly,ierr)<br /> > CHKERRA(ierr)<br /> > call MatAssemblyEnd(Mat_K,Mat_Final_Assembly,ierr)<br /> ><br /> ><br /> > I am not able to define an appropriate size if ierr in CHKERRA(ierr). If I choose INTEGER(8), the error "Type mismatch in argument ‘ierr’ at (1); passed INTEGER(8) to<br /> > INTEGER(4)" occurs.<br /> > If I define ierr as INTEGER(4), the error "Type mismatch in argument ‘ierr’ at (1); passed INTEGER(4) to INTEGER(8)" appears.<br /> ><br /> > 3. If I change the sizes of ierr vaiables as error messages require, the compilation completed successfully, but an error occurs when calculating the RHS vector with<br /> > following message:<br /> > [0]PETSC ERROR: Out of range index value -4 cannot be negative<br /> ><br /> ><br /> > Command to configure 32-bit version of PETSc under Windows 10 using Cygwin:<br /> > ./configure --with-cc=x86_64-w64-mingw32-gcc --with-cxx=x86_64-w64-mingw32-g++ --with-fc=x86_64-w64-mingw32-gfortran --download-fblaslapack<br /> > --with-mpi-include=/cygdrive/c/MPISDK/Include --with-mpi-lib=/cygdrive/c/MPISDK/Lib/libmsmpi.a --with-mpi-mpiexec=/cygdrive/c/MPI/Bin/mpiexec.exe --with-debugging=yes<br /> > -CFLAGS='-O2' -CXXFLAGS='-O2' -FFLAGS='-O2 -static-libgfortran -static -lpthread -fno-range-check' --with-shared-libraries=no<br /> > Command to configure 64-bit version of PETSc under Windows 10 using Cygwin:./configure --with-cc=x86_64-w64-mingw32-gcc --with-cxx=x86_64-w64-mingw32-g++<br /> > --with-fc=x86_64-w64-mingw32-gfortran --download-fblaslapack --with-mpi-include=/cygdrive/c/MPISDK/Include --with-mpi-lib=/cygdrive/c/MPISDK/Lib/libmsmpi.a<br /> > --with-mpi-mpiexec=/cygdrive/c/MPI/Bin/mpiexec.exe --with-debugging=yes -CFLAGS='-O2' -CXXFLAGS='-O2' -FFLAGS='-O2 -static-libgfortran -static -lpthread -fno-range-check<br /> > -fdefault-integer-8' --with-shared-libraries=no --with-64-bit-indices --known-64-bit-blas-indices<br /> ><br /> ><br /> > Kind regards,<br /> > Dmitry Melnichuk<br /> ><br /> ><br /> ><br /> ><br /> > --<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 /> ><br /> > <a href="https://www.cse.buffalo.edu/~knepley/">https://www.cse.buffalo.edu/~knepley/</a><br /><br /> </blockquote></blockquote>