Skip to content

Commit 55dd0cd

Browse files
committed
grid solver adjustments for PETSc 3.22.x
and a few smaller adjustments
1 parent 4e070e5 commit 55dd0cd

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ endif()
1111
project(Prerequisites LANGUAGES)
1212
set(ENV{PKG_CONFIG_PATH} "$ENV{PETSC_DIR}/$ENV{PETSC_ARCH}/lib/pkgconfig:$ENV{PKG_CONFIG_PATH}")
1313
pkg_check_modules(PETSC_MIN REQUIRED PETSc>=3.12.0 QUIET) #CMake does not support version range
14-
pkg_check_modules(PETSC REQUIRED PETSc<3.22.0)
14+
pkg_check_modules(PETSC REQUIRED PETSc<3.23.0)
1515

1616
pkg_get_variable(CMAKE_Fortran_COMPILER PETSc fcompiler)
1717
pkg_get_variable(CMAKE_C_COMPILER PETSc ccompiler)

src/CLI.f90

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
!> @brief Parse command line interface for PETSc-based solvers
77
!--------------------------------------------------------------------------------------------------
88
#define PETSC_MINOR_MIN 12
9-
#define PETSC_MINOR_MAX 21
9+
#define PETSC_MINOR_MAX 22
1010

1111
module CLI
1212
use, intrinsic :: ISO_fortran_env

src/grid/grid_mech_spectral_Galerkin.f90

+6-1
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ subroutine MatShellSetOperation(mat,op_num,op_callback,ierr)
135135
end subroutine MatShellSetOperation
136136
end interface MatShellSetOperation
137137

138+
#if (PETSC_VERSION_MAJOR==3 && PETSC_VERSION_MINOR<22)
138139
interface SNESSetJacobian
139140
subroutine SNESSetJacobian(snes_mech,A,P,jac_callback,ctx,ierr)
140141
use petscsnes
@@ -145,6 +146,7 @@ subroutine SNESSetJacobian(snes_mech,A,P,jac_callback,ctx,ierr)
145146
PetscErrorCode :: ierr
146147
end subroutine SNESSetJacobian
147148
end interface SNESSetJacobian
149+
#endif
148150

149151
interface SNESSetUpdate
150152
subroutine SNESSetUpdate(snes_mech,upd_callback,ierr)
@@ -678,14 +680,17 @@ end subroutine GK_op
678680
subroutine set_F_aim(snes, step, ierr)
679681
SNES :: snes
680682
PetscInt :: step ! curr completed petsc iter
681-
PetscErrorCode :: ierr
683+
PetscErrorCode, intent(out) :: ierr
684+
682685

683686
real(pREAL), dimension(3,3) :: &
684687
deltaF_aim
685688

686689
deltaF_aim = math_mul3333xx33(S, P_av - P_aim)
687690
F_aim = F_aim - deltaF_aim
688691

692+
ierr = 0_pPETSCERRORCODE
693+
689694
end subroutine set_F_aim
690695

691696
end module grid_mechanical_spectral_Galerkin

src/prec.f90

+7-6
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ module prec
2323
integer, parameter :: pI32 = selected_int_kind(9) !< number with at least up to +-1e9 (typically 32 bit)
2424
integer, parameter :: pI64 = selected_int_kind(18) !< number with at least up to +-1e18 (typically 64 bit)
2525
#ifdef PETSC
26-
PetscInt, private :: dummy_int
27-
integer, parameter :: pPETSCINT = kind(dummy_int)
28-
PetscScalar, private :: dummy_scalar
29-
real(pREAL), parameter, private :: pPETSCSCALAR = kind(dummy_scalar)
26+
PetscInt, private :: dummy_int
27+
PetscErrorCode, private :: dummy_error_code
28+
integer, parameter :: pPETSCINT = kind(dummy_int)
29+
integer, parameter :: pPETSCERRORCODE = kind(dummy_error_code)
3030
#endif
3131
integer, parameter :: pSTRLEN = 256 !< default string length
3232
integer, parameter :: pPATHLEN = 4096 !< maximum length of a path name on linux
@@ -251,10 +251,11 @@ subroutine prec_selfTest()
251251
real(pREAL), dimension(1) :: f
252252
integer(pI64), dimension(1) :: i
253253
real(pREAL), dimension(2) :: r
254+
#ifdef PETSC
255+
PetscScalar :: dummy_scalar
254256

255257

256-
#ifdef PETSC
257-
if (pREAL /= pPETSCSCALAR) error stop 'PETSc and DAMASK scalar datatypes do not match'
258+
if (pREAL /= kind(dummy_scalar)) error stop 'PETSc and DAMASK scalar datatypes do not match'
258259
#endif
259260
realloc_lhs_test = [1,2]
260261
if (any(realloc_lhs_test/=[1,2])) error stop 'LHS allocation'

0 commit comments

Comments
 (0)