From 4194f58023666f71de00fbcc6228a7c337a43d22 Mon Sep 17 00:00:00 2001 From: Tobias Ott Date: Mon, 23 Jan 2023 12:35:35 +0100 Subject: [PATCH 1/2] Changed PETSc error handling to work with v3.18 --- src/hdg/elem_mat.f90 | 28 ++++++------ src/hdg/hdg.f90 | 84 +++++++++++++++++------------------ src/restart/restart_field.f90 | 12 ++--- 3 files changed, 62 insertions(+), 62 deletions(-) diff --git a/src/hdg/elem_mat.f90 b/src/hdg/elem_mat.f90 index 90412b5d7..959a36042 100644 --- a/src/hdg/elem_mat.f90 +++ b/src/hdg/elem_mat.f90 @@ -375,13 +375,13 @@ SUBROUTINE Elem_Mat(td_iter) iPETScGlobal=PETScGlobal(iSideID) jPETScGlobal=PETScGlobal(jSideID) IF (iPETScGlobal.GT.jPETScGlobal) CYCLE - CALL MatSetValuesBlocked(Smat_petsc,1,iPETScGlobal,1,jPETScGlobal, & - Smat(:,:,jLocSide,iLocSide,iElem),ADD_VALUES,ierr);PetscCall(ierr) + PetscCallA(MatSetValuesBlocked(Smat_petsc,1,iPETScGlobal,1,jPETScGlobal,\ + Smat(:,:,jLocSide,iLocSide,iElem),ADD_VALUES,ierr)) END DO END DO END DO -CALL MatAssemblyBegin(Smat_petsc,MAT_FINAL_ASSEMBLY,ierr);PetscCall(ierr) -CALL MatAssemblyEnd(Smat_petsc,MAT_FINAL_ASSEMBLY,ierr);PetscCall(ierr) +PetscCallA(MatAssemblyBegin(Smat_petsc,MAT_FINAL_ASSEMBLY,ierr)) +PetscCallA(MatAssemblyEnd(Smat_petsc,MAT_FINAL_ASSEMBLY,ierr)) #endif @@ -462,25 +462,25 @@ SUBROUTINE BuildPrecond() !=================================================================================================================================== #if USE_PETSC -CALL KSPGetPC(ksp,pc,ierr);PetscCall(ierr) +PetscCallA(KSPGetPC(ksp,pc,ierr)) SELECT CASE(PrecondType) CASE(0) - CALL PCSetType(pc,PCNONE,ierr);PetscCall(ierr) + PetscCallA(PCSetType(pc,PCNONE,ierr)) CASE(1) - CALL PCSetType(pc,PCJACOBI,ierr);PetscCall(ierr) + PetscCallA(PCSetType(pc,PCJACOBI,ierr)) CASE(2) - CALL PCHYPRESetType(pc,PCILU,ierr);PetscCall(ierr) + PetscCallA(PCHYPRESetType(pc,PCILU,ierr)) CASE(3) - CALL PCHYPRESetType(pc,PCSPAI,ierr);PetscCall(ierr) + PetscCallA(PCHYPRESetType(pc,PCSPAI,ierr)) CASE(4) lens=nGP_Face - CALL PCSetType(pc,PCBJACOBI,ierr);PetscCall(ierr) - CALL PCBJacobiSetLocalBlocks(pc,nPETScUniqueSides,lens,ierr);PetscCall(ierr) - CALL KSPSetUp(ksp,ierr) + PetscCallA(PCSetType(pc,PCBJACOBI,ierr)) + PetscCallA(PCBJacobiSetLocalBlocks(pc,nPETScUniqueSides,lens,ierr)) + PetscCallA(KSPSetUp(ksp,ierr)) case(10) - CALL PCSetType(pc,PCCHOLESKY,ierr);PetscCall(ierr) + PetscCallA(PCSetType(pc,PCCHOLESKY,ierr)) case(11) - CALL PCSetType(pc,PCLU,ierr);PetscCall(ierr) + PetscCallA(PCSetType(pc,PCLU,ierr)) END SELECT #else SELECT CASE(PrecondType) diff --git a/src/hdg/hdg.f90 b/src/hdg/hdg.f90 index a55bb790b..d82a749fc 100644 --- a/src/hdg/hdg.f90 +++ b/src/hdg/hdg.f90 @@ -176,7 +176,7 @@ SUBROUTINE InitHDG() #if USE_PETSC ! initialize PETSc stuff! -CALL PetscInitialize(PETSC_NULL_CHARACTER,ierr);!PetscCall(ierr) +PetscCallA(PetscInitialize(PETSC_NULL_CHARACTER,ierr)) #endif #if defined(PARTICLES) @@ -404,14 +404,14 @@ SUBROUTINE InitHDG() Smat_zeroPotential = 0. END IF -CALL MatCreate(PETSC_COMM_WORLD,Smat_petsc,ierr);PetscCall(ierr) -CALL MatSetBlockSize(Smat_petsc,nGP_face,ierr);PetscCall(ierr) -CALL MatSetSizes(Smat_petsc,PETSC_DECIDE,PETSC_DECIDE,nPETScUniqueSidesGlobal*nGP_Face,nPETScUniqueSidesGlobal*nGP_Face,ierr);PetscCall(ierr) -CALL MatSetType(Smat_petsc,MATSBAIJ,ierr);PetscCall(ierr) ! Symmetric sparse (mpi) matrix +PetscCallA(MatCreate(PETSC_COMM_WORLD,Smat_petsc,ierr)) +PetscCallA(MatSetBlockSize(Smat_petsc,nGP_face,ierr)) +PetscCallA(MatSetSizes(Smat_petsc,PETSC_DECIDE,PETSC_DECIDE,nPETScUniqueSidesGlobal*nGP_Face,nPETScUniqueSidesGlobal*nGP_Face,ierr)) +PetscCallA(MatSetType(Smat_petsc,MATSBAIJ,ierr)) ! Symmetric sparse (mpi) matrix ! 1 Big mortar side is affected by 6 + 4*4 = 22 other sides... -CALL MatSEQSBAIJSetPreallocation(Smat_petsc,nGP_face,22,PETSC_NULL_INTEGER,ierr);PetscCall(ierr) -CALL MatMPISBAIJSetPreallocation(Smat_petsc,nGP_face,22,PETSC_NULL_INTEGER,21,PETSC_NULL_INTEGER,ierr);PetscCall(ierr) -CALL MatZeroEntries(Smat_petsc,ierr);PetscCall(ierr) +PetscCallA(MatSEQSBAIJSetPreallocation(Smat_petsc,nGP_face,22,PETSC_NULL_INTEGER,ierr)) +PetscCallA(MatMPISBAIJSetPreallocation(Smat_petsc,nGP_face,22,PETSC_NULL_INTEGER,21,PETSC_NULL_INTEGER,ierr)) +PetscCallA(MatZeroEntries(Smat_petsc,ierr)) #endif !stabilization parameter @@ -425,18 +425,18 @@ SUBROUTINE InitHDG() END IF #if USE_PETSC -CALL KSPCreate(PETSC_COMM_WORLD,ksp,ierr);PetscCall(ierr) -CALL KSPSetOperators(ksp,Smat_petsc,Smat_petsc,ierr);PetscCall(ierr) +PetscCallA(KSPCreate(PETSC_COMM_WORLD,ksp,ierr)) +PetscCallA(KSPSetOperators(ksp,Smat_petsc,Smat_petsc,ierr)) IF(PrecondType.GE.10) THEN - CALL KSPSetType(ksp,KSPPREONLY,ierr);PetscCall(ierr) ! Exact solver + PetscCallA(KSPSetType(ksp,KSPPREONLY,ierr)) ! Exact solver ELSE - CALL KSPSetType(ksp,KSPCG,ierr);PetscCall(ierr) ! CG solver for sparse symmetric positive definite matrix + PetscCallA(KSPSetType(ksp,KSPCG,ierr)) ! CG solver for sparse symmetric positive definite matrix - CALL KSPSetInitialGuessNonzero(ksp,PETSC_TRUE, ierr);PetscCall(ierr) + PetscCallA(KSPSetInitialGuessNonzero(ksp,PETSC_TRUE, ierr)) - CALL KSPSetNormType(ksp, KSP_NORM_UNPRECONDITIONED, ierr);PetscCall(ierr) - CALL KSPSetTolerances(ksp,1.E-20,epsCG,PETSC_DEFAULT_REAL,MaxIterCG,ierr);PetscCall(ierr) + PetscCallA(KSPSetNormType(ksp, KSP_NORM_UNPRECONDITIONED, ierr)) + PetscCallA(KSPSetTolerances(ksp,1.E-20,epsCG,PETSC_DEFAULT_REAL,MaxIterCG,ierr)) END IF #endif @@ -449,18 +449,18 @@ SUBROUTINE InitHDG() #if USE_PETSC ! allocate RHS & lambda vectors -CALL VecCreate(PETSC_COMM_WORLD,lambda_petsc,ierr);PetscCall(ierr) -CALL VecSetBlockSize(lambda_petsc,nGP_face,ierr);PetscCall(ierr) -CALL VecSetSizes(lambda_petsc,PETSC_DECIDE,nPETScUniqueSidesGlobal*nGP_Face,ierr);PetscCall(ierr) -CALL VecSetType(lambda_petsc,VECSTANDARD,ierr);PetscCall(ierr) -CALL VecSetUp(lambda_petsc,ierr);PetscCall(ierr) -CALL VecDuplicate(lambda_petsc,RHS_petsc,ierr) +PetscCallA(VecCreate(PETSC_COMM_WORLD,lambda_petsc,ierr)) +PetscCallA(VecSetBlockSize(lambda_petsc,nGP_face,ierr)) +PetscCallA(VecSetSizes(lambda_petsc,PETSC_DECIDE,nPETScUniqueSidesGlobal*nGP_Face,ierr)) +PetscCallA(VecSetType(lambda_petsc,VECSTANDARD,ierr)) +PetscCallA(VecSetUp(lambda_petsc,ierr)) +PetscCallA(VecDuplicate(lambda_petsc,RHS_petsc,ierr)) ! Create scatter context to access local values from global petsc vector -CALL VecCreateSeq(PETSC_COMM_SELF,nPETScUniqueSides*nGP_face,lambda_local_petsc,ierr);PetscCall(ierr) -CALL ISCreateStride(PETSC_COMM_SELF,nPETScUniqueSides*nGP_face,0,1,idx_local_petsc,ierr);PetscCall(ierr) -CALL ISCreateBlock(PETSC_COMM_WORLD,nGP_face,nPETScUniqueSides,PETScGlobal(PETScLocalToSideID(1:nPETScUniqueSides)),PETSC_COPY_VALUES,idx_global_petsc,ierr);PetscCall(ierr) -CALL VecScatterCreate(lambda_petsc,idx_global_petsc,lambda_local_petsc,idx_local_petsc,scatter_petsc,ierr);PetscCall(ierr) +PetscCallA(VecCreateSeq(PETSC_COMM_SELF,nPETScUniqueSides*nGP_face,lambda_local_petsc,ierr)) +PetscCallA(ISCreateStride(PETSC_COMM_SELF,nPETScUniqueSides*nGP_face,0,1,idx_local_petsc,ierr)) +PetscCallA(ISCreateBlock(PETSC_COMM_WORLD,nGP_face,nPETScUniqueSides,PETScGlobal(PETScLocalToSideID(1:nPETScUniqueSides)),PETSC_COPY_VALUES,idx_global_petsc,ierr)) +PetscCallA(VecScatterCreate(lambda_petsc,idx_global_petsc,lambda_local_petsc,idx_local_petsc,scatter_petsc,ierr)) #endif HDGInitIsDone = .TRUE. @@ -943,38 +943,38 @@ SUBROUTINE HDGLinear(time,U_out) #if USE_PETSC ! Fill right hand side - !CALL VecZeroEntries(RHS_petsc,ierr);PetscCall(ierr) + !PetscCallA(VecZeroEntries(RHS_petsc,ierr)) TimeStartPiclas=PICLASTIME() DO PETScLocalID=1,nPETScUniqueSides SideID=PETScLocalToSideID(PETScLocalID) !VecSetValuesBlockedLocal somehow not working... - CALL VecSetValuesBlocked(RHS_petsc,1,PETScGlobal(SideID),RHS_face(1,:,SideID),INSERT_VALUES,ierr);PetscCall(ierr) + PetscCallA(VecSetValuesBlocked(RHS_petsc,1,PETScGlobal(SideID),RHS_face(1,:,SideID),INSERT_VALUES,ierr)) END DO - CALL VecAssemblyBegin(RHS_petsc,ierr);PetscCall(ierr) - CALL VecAssemblyEnd(RHS_petsc,ierr);PetscCall(ierr) + PetscCallA(VecAssemblyBegin(RHS_petsc,ierr)) + PetscCallA(VecAssemblyEnd(RHS_petsc,ierr)) ! Calculate lambda - CALL KSPSolve(ksp,RHS_petsc,lambda_petsc,ierr);PetscCall(ierr) + PetscCallA(KSPSolve(ksp,RHS_petsc,lambda_petsc,ierr)) TimeEndPiclas=PICLASTIME() - CALL KSPGetIterationNumber(ksp,iterations,ierr);PetscCall(ierr) - CALL KSPGetConvergedReason(ksp,reason,ierr);PetscCall(ierr) - CALL KSPGetResidualNorm(ksp,petscnorm,ierr);PetscCall(ierr) + PetscCallA(KSPGetIterationNumber(ksp,iterations,ierr)) + PetscCallA(KSPGetConvergedReason(ksp,reason,ierr)) + PetscCallA(KSPGetResidualNorm(ksp,petscnorm,ierr)) IF(reason.LT.0)THEN SWRITE(*,*) 'Attention: PETSc not converged! Reason: ', reason END IF IF(MPIroot) CALL DisplayConvergence(TimeEndPiclas-TimeStartPiclas, iterations, petscnorm) ! Fill element local lambda for post processing - CALL VecScatterBegin(scatter_petsc, lambda_petsc, lambda_local_petsc, INSERT_VALUES, SCATTER_FORWARD,ierr);PetscCall(ierr) - CALL VecScatterEnd(scatter_petsc, lambda_petsc, lambda_local_petsc, INSERT_VALUES, SCATTER_FORWARD,ierr);PetscCall(ierr) - CALL VecGetArrayReadF90(lambda_local_petsc,lambda_pointer,ierr);PetscCall(ierr) + PetscCallA(VecScatterBegin(scatter_petsc, lambda_petsc, lambda_local_petsc, INSERT_VALUES, SCATTER_FORWARD,ierr)) + PetscCallA(VecScatterEnd(scatter_petsc, lambda_petsc, lambda_local_petsc, INSERT_VALUES, SCATTER_FORWARD,ierr)) + PetscCallA(VecGetArrayReadF90(lambda_local_petsc,lambda_pointer,ierr)) DO PETScLocalID=1,nPETScUniqueSides SideID=PETScLocalToSideID(PETScLocalID) PETScID_start=1+(PETScLocalID-1)*nGP_face PETScID_stop=PETScLocalID*nGP_face lambda(1,:,SideID) = lambda_pointer(PETScID_start:PETScID_stop) END DO - CALL VecRestoreArrayReadF90(lambda_local_petsc,lambda_pointer,ierr);PetscCall(ierr) + PetscCallA(VecRestoreArrayReadF90(lambda_local_petsc,lambda_pointer,ierr)) ! PETSc Calculate lambda at small mortars from big mortars CALL BigToSmallMortar_HDG(1,lambda) #if USE_MPI @@ -2151,11 +2151,11 @@ SUBROUTINE FinalizeHDG() !=================================================================================================================================== HDGInitIsDone = .FALSE. #if USE_PETSC -CALL KSPDestroy(ksp,ierr); PetscCall(ierr) -CALL MatDestroy(Smat_petsc,ierr); PetscCall(ierr) -CALL VecDestroy(lambda_petsc,ierr); PetscCall(ierr) -CALL VecDestroy(RHS_petsc,ierr); PetscCall(ierr) -CALL PetscFinalize(ierr) +PetscCallA(KSPDestroy(ksp,ierr)) +PetscCallA(MatDestroy(Smat_petsc,ierr)) +PetscCallA(VecDestroy(lambda_petsc,ierr)) +PetscCallA(VecDestroy(RHS_petsc,ierr)) +PetscCallA(PetscFinalize(ierr)) SDEALLOCATE(PETScGlobal) SDEALLOCATE(PETScLocalToSideID) SDEALLOCATE(Smat_BC) diff --git a/src/restart/restart_field.f90 b/src/restart/restart_field.f90 index 86d92f19f..5bed7e0e3 100644 --- a/src/restart/restart_field.f90 +++ b/src/restart/restart_field.f90 @@ -231,10 +231,10 @@ SUBROUTINE FieldRestart() #if USE_PETSC DO PETScLocalID=1,nPETScUniqueSides SideID=PETScLocalToSideID(PETScLocalID) - CALL VecSetValuesBlocked(lambda_petsc,1,PETScGlobal(SideID),lambda(1,:,SideID),INSERT_VALUES,ierr);PetscCall(ierr) + PetscCallA(VecSetValuesBlocked(lambda_petsc,1,PETScGlobal(SideID),lambda(1,:,SideID),INSERT_VALUES,ierr)) END DO - CALL VecAssemblyBegin(lambda_petsc,ierr);PetscCall(ierr) - CALL VecAssemblyEnd(lambda_petsc,ierr);PetscCall(ierr) + PetscCallA(VecAssemblyBegin(lambda_petsc,ierr)) + PetscCallA(VecAssemblyEnd(lambda_petsc,ierr)) #endif CALL RestartHDG(U) ! calls PostProcessGradient for calculate the derivative, e.g., the electric field E @@ -387,10 +387,10 @@ SUBROUTINE FieldRestart() #if USE_PETSC DO PETScLocalID=1,nPETScUniqueSides SideID=PETScLocalToSideID(PETScLocalID) - CALL VecSetValuesBlocked(lambda_petsc,1,PETScGlobal(SideID),lambda(1,:,SideID),INSERT_VALUES,ierr);PetscCall(ierr) + PetscCallA(VecSetValuesBlocked(lambda_petsc,1,PETScGlobal(SideID),lambda(1,:,SideID),INSERT_VALUES,ierr)) END DO - CALL VecAssemblyBegin(lambda_petsc,ierr);PetscCall(ierr) - CALL VecAssemblyEnd(lambda_petsc,ierr);PetscCall(ierr) + PetscCallA(VecAssemblyBegin(lambda_petsc,ierr)) + PetscCallA(VecAssemblyEnd(lambda_petsc,ierr)) #endif CALL RestartHDG(U) ! calls PostProcessGradient for calculate the derivative, e.g., the electric field E From 1bbd81d5de7467aaf059ac1eeeeb5ff3c6649bf8 Mon Sep 17 00:00:00 2001 From: Stephen Copplestone Date: Sun, 5 Feb 2023 22:38:42 +0100 Subject: [PATCH 2/2] Fixed compilation for petsc version 3.17 and 3.18 using preproc macro when the version is less than 3.18, which is read from petscversion.h in the petsc include directory. If this is the case, then -DUSE_PETSC_FIX317=1 is set, which defines the preproc macro #define PetscCallA(a) CALL a; PetscCall(ierr). --- CMakeListsLib.txt | 73 ++++++++++++++++----------- src/hdg/elem_mat.f90 | 3 +- src/piclas.h | 5 ++ tools/Setup_ModuleEnv/InstallPETSc.sh | 1 + 4 files changed, 51 insertions(+), 31 deletions(-) diff --git a/CMakeListsLib.txt b/CMakeListsLib.txt index 7dab06082..47a20ae59 100644 --- a/CMakeListsLib.txt +++ b/CMakeListsLib.txt @@ -525,37 +525,52 @@ ENDIF() OPTION(PICLAS_PETSC "Use the PETSc library" OFF) IF(PICLAS_PETSC) ADD_DEFINITIONS(-DUSE_PETSC=1) - if(NOT DEFINED PETSC_DIR) - set(PETSC_DIR $ENV{PETSC_DIR}) - endif() - if(NOT DEFINED PETSC_ARCH) - set(PETSC_ARCH $ENV{PETSC_ARCH}) - endif() - - if(EXISTS "${PETSC_DIR}/include" AND - EXISTS "${PETSC_DIR}/${PETSC_ARCH}/include") - set(PETSC_INC "${PETSC_DIR}/include" "${PETSC_DIR}/${PETSC_ARCH}/include") - else() - message(SEND_ERROR "PETSc includes not found") - endif() - - if(EXISTS "${PETSC_DIR}/${PETSC_ARCH}/lib/libpetsc.so") - set(PETSC_LIB "${PETSC_DIR}/${PETSC_ARCH}/lib/libpetsc.so") - elseif(EXISTS "${PETSC_DIR}/${PETSC_ARCH}/lib/libpetsc.a") - set(PETSC_LIB "${PETSC_DIR}/${PETSC_ARCH}/lib/libpetsc.a") - else() - message(SEND_ERROR "PETSc library not found") - endif() - - if(EXISTS ${PETSC_DIR}/${PETSC_ARCH}/conf/petscvariables) - file(STRINGS ${PETSC_DIR}/${PETSC_ARCH}/conf/petscvariables + IF(NOT DEFINED PETSC_DIR) + SET(PETSC_DIR $ENV{PETSC_DIR}) + ENDIF() + IF(NOT DEFINED PETSC_ARCH) + SET(PETSC_ARCH $ENV{PETSC_ARCH}) + ENDIF() + + IF(EXISTS "${PETSC_DIR}/include" AND EXISTS "${PETSC_DIR}/${PETSC_ARCH}/include") + SET(PETSC_INCLUDE_DIR "${PETSC_DIR}/include") + SET(PETSC_INC "${PETSC_DIR}/include" "${PETSC_DIR}/${PETSC_ARCH}/include") + ELSE() + MESSAGE(SEND_ERROR "PETSc includes not found") + ENDIF() + + IF(EXISTS "${PETSC_DIR}/${PETSC_ARCH}/lib/libpetsc.so") + SET(PETSC_LIB "${PETSC_DIR}/${PETSC_ARCH}/lib/libpetsc.so") + ELSEIf(EXISTS "${PETSC_DIR}/${PETSC_ARCH}/lib/libpetsc.a") + SET(PETSC_LIB "${PETSC_DIR}/${PETSC_ARCH}/lib/libpetsc.a") + ELSE() + MESSAGE(SEND_ERROR "PETSc library not found") + ENDIF() + + IF(EXISTS ${PETSC_DIR}/${PETSC_ARCH}/conf/petscvariables) + FILE(STRINGS ${PETSC_DIR}/${PETSC_ARCH}/conf/petscvariables PETSC_VARIABLES NEWLINE_CONSUME) - elseif(EXISTS ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/petscvariables) - file(STRINGS ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/petscvariables + ELSEIf(EXISTS ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/petscvariables) + FILE(STRINGS ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/petscvariables PETSC_VARIABLES NEWLINE_CONSUME) - else() - message(SEND_ERROR "PETSc variables not found") - endif() + ELSE() + MESSAGE(SEND_ERROR "PETSc variables not found") + ENDIF() + + # Find "^#define PETSC_VERSION_MAJOR" and get only the numbers and remove trailing line breaks + SET(PETSC_VERSION_FILE "${PETSC_INCLUDE_DIR}/petscversion.h") + IF(EXISTS "${PETSC_VERSION_FILE}") + EXECUTE_PROCESS(COMMAND cat "${PETSC_VERSION_FILE}" COMMAND grep "^#define PETSC_VERSION_MAJOR" COMMAND grep -o "[[:digit:]]*" COMMAND tr -d '\n' OUTPUT_VARIABLE PICLAS_PETSC_VERSION_MAJOR) + EXECUTE_PROCESS(COMMAND cat "${PETSC_VERSION_FILE}" COMMAND grep "^#define PETSC_VERSION_MINOR" COMMAND grep -o "[[:digit:]]*" COMMAND tr -d '\n' OUTPUT_VARIABLE PICLAS_PETSC_VERSION_MINOR) + MESSAGE(STATUS "Found PETSC version [${PICLAS_PETSC_VERSION_MAJOR}.${PICLAS_PETSC_VERSION_MINOR}] in ${PETSC_VERSION_FILE}") + IF(${PICLAS_PETSC_VERSION_MAJOR}.${PICLAS_PETSC_VERSION_MINOR} VERSION_LESS 3.18) + ADD_DEFINITIONS(-DUSE_PETSC_FIX317=1) + ELSE() + ADD_DEFINITIONS(-DUSE_PETSC_FIX317=0) + ENDIF() + ELSE() + ADD_DEFINITIONS(-DUSE_PETSC_FIX317=1) + ENDIF() INCLUDE_DIRECTORIES(${PETSC_INC}) LIST(APPEND linkedlibs ${PETSC_LIB}) diff --git a/src/hdg/elem_mat.f90 b/src/hdg/elem_mat.f90 index 959a36042..af90a61f1 100644 --- a/src/hdg/elem_mat.f90 +++ b/src/hdg/elem_mat.f90 @@ -375,8 +375,7 @@ SUBROUTINE Elem_Mat(td_iter) iPETScGlobal=PETScGlobal(iSideID) jPETScGlobal=PETScGlobal(jSideID) IF (iPETScGlobal.GT.jPETScGlobal) CYCLE - PetscCallA(MatSetValuesBlocked(Smat_petsc,1,iPETScGlobal,1,jPETScGlobal,\ - Smat(:,:,jLocSide,iLocSide,iElem),ADD_VALUES,ierr)) + PetscCallA(MatSetValuesBlocked(Smat_petsc,1,iPETScGlobal,1,jPETScGlobal,Smat(:,:,jLocSide,iLocSide,iElem),ADD_VALUES,ierr)) END DO END DO END DO diff --git a/src/piclas.h b/src/piclas.h index 234d1a08f..7a00aee04 100644 --- a/src/piclas.h +++ b/src/piclas.h @@ -2,6 +2,11 @@ ! Here, preprocessor variables for different equation systems and abbreviations for specific expressions are defined !=================================================================================================================================== +! From include/petsc/finclude/petscsys.h: #define PetscCallA(func) call func; CHKERRA(ierr) +#if USE_PETSC_FIX317 +#define PetscCallA(a) CALL a; PetscCall(ierr) +#endif + ! Abbrevations #ifndef __FILENAME__ #define __FILENAME__ __FILE__ diff --git a/tools/Setup_ModuleEnv/InstallPETSc.sh b/tools/Setup_ModuleEnv/InstallPETSc.sh index 37819386d..fc5fd7137 100755 --- a/tools/Setup_ModuleEnv/InstallPETSc.sh +++ b/tools/Setup_ModuleEnv/InstallPETSc.sh @@ -121,6 +121,7 @@ WHICHMPI=openmpi # DOWNLOAD and INSTALL PETSc (example PETSc-3.17.0) PETSCVERSION=3.17.0 +PETSCVERSION=3.18.4 # -------------------------------------------------------------------------------------------------- # Check pre-requisites