diff --git a/.github/workflows/Fortran.yml b/.github/workflows/Fortran.yml index 92116a1a0..2df5ecb1a 100644 --- a/.github/workflows/Fortran.yml +++ b/.github/workflows/Fortran.yml @@ -2,7 +2,7 @@ name: Grid and Mesh Solver on: [push] env: - PETSC_VERSION: '3.21.4' + PETSC_VERSION: '3.22.0' HOMEBREW_NO_ANALYTICS: 'ON' # Make Homebrew installation a little quicker HOMEBREW_NO_AUTO_UPDATE: 'ON' HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK: 'ON' diff --git a/CMakeLists.txt b/CMakeLists.txt index 676a7f2f6..227c78138 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ endif() project(Prerequisites LANGUAGES) set(ENV{PKG_CONFIG_PATH} "$ENV{PETSC_DIR}/$ENV{PETSC_ARCH}/lib/pkgconfig:$ENV{PKG_CONFIG_PATH}") pkg_check_modules(PETSC_MIN REQUIRED PETSc>=3.12.0 QUIET) #CMake does not support version range -pkg_check_modules(PETSC REQUIRED PETSc<3.22.0) +pkg_check_modules(PETSC REQUIRED PETSc<3.23.0) pkg_get_variable(CMAKE_Fortran_COMPILER PETSc fcompiler) pkg_get_variable(CMAKE_C_COMPILER PETSc ccompiler) diff --git a/src/CLI.f90 b/src/CLI.f90 index 3525336c4..4334c29af 100644 --- a/src/CLI.f90 +++ b/src/CLI.f90 @@ -6,7 +6,7 @@ !> @brief Parse command line interface for PETSc-based solvers !-------------------------------------------------------------------------------------------------- #define PETSC_MINOR_MIN 12 -#define PETSC_MINOR_MAX 21 +#define PETSC_MINOR_MAX 22 module CLI use, intrinsic :: ISO_fortran_env diff --git a/src/grid/grid_mech_spectral_Galerkin.f90 b/src/grid/grid_mech_spectral_Galerkin.f90 index ea5a570c4..296fe6665 100644 --- a/src/grid/grid_mech_spectral_Galerkin.f90 +++ b/src/grid/grid_mech_spectral_Galerkin.f90 @@ -135,6 +135,7 @@ subroutine MatShellSetOperation(mat,op_num,op_callback,ierr) end subroutine MatShellSetOperation end interface MatShellSetOperation +#if (PETSC_VERSION_MAJOR==3 && PETSC_VERSION_MINOR<22) interface SNESSetJacobian subroutine SNESSetJacobian(snes_mech,A,P,jac_callback,ctx,ierr) use petscsnes @@ -145,6 +146,7 @@ subroutine SNESSetJacobian(snes_mech,A,P,jac_callback,ctx,ierr) PetscErrorCode :: ierr end subroutine SNESSetJacobian end interface SNESSetJacobian +#endif interface SNESSetUpdate subroutine SNESSetUpdate(snes_mech,upd_callback,ierr) @@ -678,7 +680,8 @@ end subroutine GK_op subroutine set_F_aim(snes, step, ierr) SNES :: snes PetscInt :: step ! curr completed petsc iter - PetscErrorCode :: ierr + PetscErrorCode, intent(out) :: ierr + real(pREAL), dimension(3,3) :: & deltaF_aim @@ -686,6 +689,8 @@ subroutine set_F_aim(snes, step, ierr) deltaF_aim = math_mul3333xx33(S, P_av - P_aim) F_aim = F_aim - deltaF_aim + ierr = 0_pPETSCERRORCODE + end subroutine set_F_aim end module grid_mechanical_spectral_Galerkin diff --git a/src/mesh/discretization_mesh.f90 b/src/mesh/discretization_mesh.f90 index ed48e6f76..b3295da23 100644 --- a/src/mesh/discretization_mesh.f90 +++ b/src/mesh/discretization_mesh.f90 @@ -179,15 +179,25 @@ subroutine discretization_mesh_init() #else call PetscDTSimplexQuadrature(dimplex, p_i, -1, quadrature, err_PETSc) CHKERRQ(err_PETSc) +#if (PETSC_VERSION_MAJOR==3 && PETSC_VERSION_MINOR>=22) + call PetscQuadratureGetData(quadrature,PETSC_NULL_INTEGER,PETSC_NULL_INTEGER, & + mesh_maxNips,qPointsP,PETSC_NULL_REAL_PTR,err_PETSc) +#else call PetscQuadratureGetData(quadrature,PETSC_NULL_INTEGER(1),PETSC_NULL_INTEGER(1), & mesh_maxNips,qPointsP,PETSC_NULL_REAL_PTR,err_PETSc) +#endif CHKERRQ(err_PETSc) call mesh_FEM_build_ipCoordinates(dimPlex,qPointsP) call mesh_FEM_build_ipVolumes(dimPlex) +#if (PETSC_VERSION_MAJOR==3 && PETSC_VERSION_MINOR>=22) + call PetscQuadratureRestoreData(quadrature,PETSC_NULL_INTEGER,PETSC_NULL_INTEGER, & + PETSC_NULL_INTEGER,qPointsP,PETSC_NULL_REAL_PTR,err_PETSc) +#else call PetscQuadratureRestoreData(quadrature,PETSC_NULL_INTEGER(1),PETSC_NULL_INTEGER(1), & PETSC_NULL_INTEGER(1),qPointsP,PETSC_NULL_REAL_PTR,err_PETSc) +#endif CHKERRQ(err_PETSc) call PetscQuadratureDestroy(quadrature, err_PETSc) CHKERRQ(err_PETSc) diff --git a/src/mesh/mesh_mech_FEM.f90 b/src/mesh/mesh_mech_FEM.f90 index aee11d1e5..1395ffbde 100644 --- a/src/mesh/mesh_mech_FEM.f90 +++ b/src/mesh/mesh_mech_FEM.f90 @@ -179,6 +179,15 @@ subroutine FEM_mechanical_init(mechBC,num_mesh) #else call PetscDTSimplexQuadrature(dimplex,num%p_i,-1,mechQuad,err_PETSc) CHKERRQ(err_PETSc) +#if (PETSC_VERSION_MAJOR==3 && PETSC_VERSION_MINOR>=22) + call PetscQuadratureGetData(mechQuad,PETSC_NULL_INTEGER,PETSC_NULL_INTEGER, & + nQuadrature,PETSC_NULL_REAL_PTR,qWeightsP,err_PETSc) + CHKERRQ(err_PETSc) + qWeights = qWeightsP + call PetscQuadratureRestoreData(mechQuad,PETSC_NULL_INTEGER,PETSC_NULL_INTEGER, & + PETSC_NULL_INTEGER,PETSC_NULL_REAL_PTR,qWeightsP, & + err_PETSc) +#else call PetscQuadratureGetData(mechQuad,PETSC_NULL_INTEGER(1),PETSC_NULL_INTEGER(1), & nQuadrature,PETSC_NULL_REAL_PTR,qWeightsP,err_PETSc) CHKERRQ(err_PETSc) @@ -186,6 +195,7 @@ subroutine FEM_mechanical_init(mechBC,num_mesh) call PetscQuadratureRestoreData(mechQuad,PETSC_NULL_INTEGER(1),PETSC_NULL_INTEGER(1), & PETSC_NULL_INTEGER(1),PETSC_NULL_REAL_PTR,qWeightsP, & err_PETSc) +#endif CHKERRQ(err_PETSc) nc = dimPlex #endif diff --git a/src/prec.f90 b/src/prec.f90 index 4f475a5aa..f9cb6052d 100644 --- a/src/prec.f90 +++ b/src/prec.f90 @@ -23,10 +23,10 @@ module prec integer, parameter :: pI32 = selected_int_kind(9) !< number with at least up to +-1e9 (typically 32 bit) integer, parameter :: pI64 = selected_int_kind(18) !< number with at least up to +-1e18 (typically 64 bit) #ifdef PETSC - PetscInt, private :: dummy_int - integer, parameter :: pPETSCINT = kind(dummy_int) - PetscScalar, private :: dummy_scalar - real(pREAL), parameter, private :: pPETSCSCALAR = kind(dummy_scalar) + PetscInt, private :: dummy_int + PetscErrorCode, private :: dummy_error_code + integer, parameter :: pPETSCINT = kind(dummy_int) + integer, parameter :: pPETSCERRORCODE = kind(dummy_error_code) #endif integer, parameter :: pSTRLEN = 256 !< default string length integer, parameter :: pPATHLEN = 4096 !< maximum length of a path name on linux @@ -251,10 +251,11 @@ subroutine prec_selfTest() real(pREAL), dimension(1) :: f integer(pI64), dimension(1) :: i real(pREAL), dimension(2) :: r +#ifdef PETSC + PetscScalar :: dummy_scalar -#ifdef PETSC - if (pREAL /= pPETSCSCALAR) error stop 'PETSc and DAMASK scalar datatypes do not match' + if (pREAL /= kind(dummy_scalar)) error stop 'PETSc and DAMASK scalar datatypes do not match' #endif realloc_lhs_test = [1,2] if (any(realloc_lhs_test/=[1,2])) error stop 'LHS allocation'