Skip to content

Commit

Permalink
revert examples
Browse files Browse the repository at this point in the history
  • Loading branch information
balos1 committed Jun 14, 2024
1 parent 6a47413 commit 8b915d4
Show file tree
Hide file tree
Showing 23 changed files with 103 additions and 107 deletions.
10 changes: 3 additions & 7 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,13 @@
# examples level CMakeLists.txt for SUNDIALS
# ---------------------------------------------------------------

# We need this to ensure the installed templates have MPI when ENABLE_MPI=TRUE,
# at least until we convert all of the templates to use the SUNDIALS CMake target.

# ===============================================================
# Configure compilers for installed examples
# ===============================================================

# unset the fortran module directory for the examples so that the
# example module names don't collide
set(CMAKE_Fortran_MODULE_DIRECTORY )

# We need this to ensure the installed templates have MPI when ENABLE_MPI=TRUE,
# at least until we convert all of the templates to use the SUNDIALS CMake target.

foreach(lang ${_SUNDIALS_ENABLED_LANGS})
if(ENABLE_MPI)
if(DEFINED MPI_${lang}_COMPILER)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module ode_mod

!======= Declarations =========
implicit none
integer(c_int64_t), parameter :: neq = 1
integer(c_long), parameter :: neq = 1
integer(c_int), parameter :: Nt = 10
complex(c_double_complex), parameter :: lambda = (-1d-2, 10.d0)
real(c_double), parameter :: T0 = 0.d0
Expand Down
36 changes: 18 additions & 18 deletions examples/arkode/F2003_custom/ark_brusselator1D_f2003.f90
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,21 @@ module ode_mod

!======= Declarations =========
implicit none
integer(c_int64_t), parameter :: N = 201 ! number of intervals
integer(c_int64_t), parameter :: Nt = 100 ! total number of output times
integer(c_int64_t), parameter :: Nvar = 3 ! number of solution fields
integer(c_int64_t), parameter :: neq = N*Nvar ! total size of solution vector
real(c_double), parameter :: dx = 1.d0/(N-1) ! mesh spacing
real(c_double), parameter :: a = 0.6d0 ! constant forcing on u
real(c_double), parameter :: b = 2.d0 ! steady-state value of w
real(c_double), parameter :: du = 0.001d0 ! diffusion coeff for u
real(c_double), parameter :: dv = 0.001d0 ! diffusion coeff for v
real(c_double), parameter :: dw = 0.001d0 ! diffusion coeff for w
real(c_double), parameter :: ep = 1.d-5 ! stiffness parameter
real(c_double), parameter :: T0 = 0.d0 ! initial time
real(c_double), parameter :: Tf = 10.d0 ! final time
real(c_double), parameter :: reltol = 1.d-6 ! solver tolerances
real(c_double), parameter :: abstol = 1.d-10
integer(c_long), parameter :: N = 201 ! number of intervals
integer(c_long), parameter :: Nt = 100 ! total number of output times
integer(c_long), parameter :: Nvar = 3 ! number of solution fields
integer(c_long), parameter :: neq = N*Nvar ! total size of solution vector
real(c_double), parameter :: dx = 1.d0/(N-1) ! mesh spacing
real(c_double), parameter :: a = 0.6d0 ! constant forcing on u
real(c_double), parameter :: b = 2.d0 ! steady-state value of w
real(c_double), parameter :: du = 0.001d0 ! diffusion coeff for u
real(c_double), parameter :: dv = 0.001d0 ! diffusion coeff for v
real(c_double), parameter :: dw = 0.001d0 ! diffusion coeff for w
real(c_double), parameter :: ep = 1.d-5 ! stiffness parameter
real(c_double), parameter :: T0 = 0.d0 ! initial time
real(c_double), parameter :: Tf = 10.d0 ! final time
real(c_double), parameter :: reltol = 1.d-6 ! solver tolerances
real(c_double), parameter :: abstol = 1.d-10

contains

Expand Down Expand Up @@ -97,7 +97,7 @@ integer(c_int) function RhsImplicit(tn, sunvec_y, sunvec_f, user_data) &
! local variables
type(FVec), pointer :: y, f ! ptrs to Fortran vector data
real(c_double) :: u, v, w
integer(C_INT64_T) :: i
integer(c_long) :: i

!======= Internals ============

Expand Down Expand Up @@ -161,7 +161,7 @@ integer(c_int) function RhsExplicit(tn, sunvec_y, sunvec_f, user_data) &
! local variables
type(FVec), pointer :: y, f ! ptrs to Fortran vector data
real(c_double) :: dconst(3)
integer(C_INT64_T) :: i, j
integer(c_long) :: i, j

!======= Internals ============

Expand Down Expand Up @@ -221,7 +221,7 @@ integer(c_int) function JacFn(tn, sunvec_y, sunvec_f, sunmat_J, &
type(FVec), pointer :: y, f ! ptrs to Fortran vector data
type(FMat), pointer :: J ! ptr to Fortran matrix data
real(c_double) :: u, v, w
integer(C_INT64_T) :: i
integer(c_long) :: i

!======= Internals ============

Expand Down
12 changes: 6 additions & 6 deletions examples/arkode/F2003_custom/fnvector_complex_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module fnvector_complex_mod
! ----------------------------------------------------------------
type, public :: FVec
logical :: own_data
integer(C_INT64_T) :: len
integer(c_long) :: len
complex(c_double_complex), pointer :: data(:)
end type FVec
! ----------------------------------------------------------------
Expand All @@ -35,7 +35,7 @@ module fnvector_complex_mod
function FN_VNew_Complex(n, sunctx) result(sunvec_y)

implicit none
integer(C_INT64_T), value :: n
integer(c_long), value :: n
type(c_ptr), value :: sunctx
type(N_Vector), pointer :: sunvec_y
type(N_Vector_Ops), pointer :: ops
Expand Down Expand Up @@ -88,7 +88,7 @@ end function FN_VNew_Complex
function FN_VMake_Complex(n, data, sunctx) result(sunvec_y)

implicit none
integer(C_INT64_T), value :: n
integer(c_long), value :: n
type(c_ptr), value :: sunctx
type(N_Vector), pointer :: sunvec_y
type(N_Vector_Ops), pointer :: ops
Expand Down Expand Up @@ -191,7 +191,7 @@ subroutine FN_VDestroy_Complex(sunvec_y) bind(C)
end subroutine FN_VDestroy_Complex

! ----------------------------------------------------------------
integer(C_INT64_T) function FN_VGetLength_Complex(sunvec_y) &
integer(c_long) function FN_VGetLength_Complex(sunvec_y) &
bind(C) result(length)

implicit none
Expand Down Expand Up @@ -456,7 +456,7 @@ real(c_double) function FN_VWSqrSumMask_Complex(sunvec_x, sunvec_w, sunvec_id) &
type(N_Vector) :: sunvec_w
type(N_Vector) :: sunvec_id
type(FVec), pointer :: x, w, id
integer(C_INT64_T) :: i
integer(c_long) :: i

! extract Fortran vector structures to work with
x => FN_VGetFVec(sunvec_x)
Expand Down Expand Up @@ -571,7 +571,7 @@ integer(c_int) function FN_VInvTest_Complex(sunvec_x, sunvec_z) &
type(N_Vector) :: sunvec_x
type(N_Vector) :: sunvec_z
type(FVec), pointer :: x, z
integer(C_INT64_T) :: i
integer(c_long) :: i

! extract Fortran vector structures to work with
x => FN_VGetFVec(sunvec_x)
Expand Down
24 changes: 12 additions & 12 deletions examples/arkode/F2003_custom/fnvector_fortran_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ module fnvector_fortran_mod
! ----------------------------------------------------------------
type, public :: FVec
logical :: own_data
integer(C_INT64_T) :: length1
integer(C_INT64_T) :: length2
integer(c_long) :: length1
integer(c_long) :: length2
real(c_double), pointer :: data(:,:)
end type FVec
! ----------------------------------------------------------------
Expand All @@ -36,8 +36,8 @@ module fnvector_fortran_mod
! ----------------------------------------------------------------
function FN_VNew_Fortran(n1, n2, sunctx) result(sunvec_y)
implicit none
integer(C_INT64_T), value :: n1
integer(C_INT64_T), value :: n2
integer(c_long), value :: n1
integer(c_long), value :: n2
type(c_ptr), value :: sunctx
type(N_Vector), pointer :: sunvec_y
type(N_Vector_Ops), pointer :: ops
Expand Down Expand Up @@ -97,8 +97,8 @@ end function FN_VNew_Fortran
! ----------------------------------------------------------------
function FN_VMake_Fortran(n1, n2, data, sunctx) result(sunvec_y)
implicit none
integer(C_INT64_T), value :: n1
integer(C_INT64_T), value :: n2
integer(c_long), value :: n1
integer(c_long), value :: n2
type(c_ptr), value :: sunctx
type(N_Vector), pointer :: sunvec_y
type(N_Vector_Ops), pointer :: ops
Expand Down Expand Up @@ -206,7 +206,7 @@ subroutine FN_VDestroy_Fortran(sunvec_y) bind(C)
end subroutine FN_VDestroy_Fortran

! ----------------------------------------------------------------
integer(C_INT64_T) function FN_VGetLength_Fortran(sunvec_y) &
integer(c_long) function FN_VGetLength_Fortran(sunvec_y) &
bind(C) result(length)

implicit none
Expand Down Expand Up @@ -480,7 +480,7 @@ real(c_double) function FN_VWSqrSumMask_Fortran(sunvec_x, sunvec_w, sunvec_id) &
type(N_Vector) :: sunvec_w
type(N_Vector) :: sunvec_id
type(FVec), pointer :: x, w, id
integer(C_INT64_T) :: i, j
integer(c_long) :: i, j

! extract Fortran vector structures to work with
x => FN_VGetFVec(sunvec_x)
Expand Down Expand Up @@ -596,7 +596,7 @@ subroutine FN_VCompare_Fortran(c, sunvec_x, sunvec_z) bind(C)
type(N_Vector) :: sunvec_x
type(N_Vector) :: sunvec_z
type(FVec), pointer :: x, z
integer(C_INT64_T) :: i, j
integer(c_long) :: i, j

! extract Fortran vector structures to work with
x => FN_VGetFVec(sunvec_x)
Expand Down Expand Up @@ -624,7 +624,7 @@ integer(c_int) function FN_VInvTest_Fortran(sunvec_x, sunvec_z) &
type(N_Vector) :: sunvec_x
type(N_Vector) :: sunvec_z
type(FVec), pointer :: x, z
integer(C_INT64_T) :: i, j
integer(c_long) :: i, j

! extract Fortran vector structures to work with
x => FN_VGetFVec(sunvec_x)
Expand Down Expand Up @@ -654,7 +654,7 @@ integer(c_int) function FN_VConstrMask_Fortran(sunvec_c, sunvec_x, sunvec_m) &
type(N_Vector) :: sunvec_x
type(N_Vector) :: sunvec_m
type(FVec), pointer :: c, x, m
integer(C_INT64_T) :: i, j
integer(c_long) :: i, j
logical :: test

! extract Fortran vector structures to work with
Expand Down Expand Up @@ -692,7 +692,7 @@ real(c_double) function FN_VMinQuotient_Fortran(sunvec_n, sunvec_d) &
type(N_Vector) :: sunvec_n
type(N_Vector) :: sunvec_d
type(FVec), pointer :: n, d
integer(C_INT64_T) :: i, j
integer(c_long) :: i, j
logical :: notEvenOnce

! extract Fortran vector structures to work with
Expand Down
14 changes: 7 additions & 7 deletions examples/arkode/F2003_custom/fsunlinsol_fortran_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ module fsunlinsol_fortran_mod

! ----------------------------------------------------------------
type, public :: FLinSol
integer(C_INT64_T) :: Nvar
integer(C_INT64_T) :: N
integer(C_INT64_T), allocatable :: pivots(:,:)
integer(c_long) :: Nvar
integer(c_long) :: N
integer(c_long), allocatable :: pivots(:,:)
end type FLinSol
! ----------------------------------------------------------------

Expand All @@ -42,8 +42,8 @@ module fsunlinsol_fortran_mod
function FSUNLinSolNew_Fortran(Nvar, N, sunctx) result(sunls_S)

implicit none
integer(C_INT64_T), value :: Nvar
integer(C_INT64_T), value :: N
integer(c_long), value :: Nvar
integer(c_long), value :: N
type(c_ptr), value :: sunctx
type(SUNLinearSolver), pointer :: sunls_S
type(SUNLinearSolver_Ops), pointer :: ops
Expand Down Expand Up @@ -135,7 +135,7 @@ integer(c_int) function FSUNLinSolSetup_Fortran(sunls_S, sunmat_A) &
type(SUNMatrix) :: sunmat_A
type(FLinSol), pointer :: S
type(FMat), pointer :: AMat
integer(C_INT64_T) :: i, j, k, l
integer(c_long) :: i, j, k, l
real(c_double) :: temp
real(c_double), pointer :: A(:,:)

Expand Down Expand Up @@ -214,7 +214,7 @@ integer(c_int) function FSUNLinSolSolve_Fortran(sunls_S, sunmat_A, &
type(FLinSol), pointer :: S
type(FMat), pointer :: AMat
type(FVec), pointer :: xvec, bvec
integer(C_INT64_T) :: i, k, pk
integer(c_long) :: i, k, pk
real(c_double) :: temp
real(c_double), pointer :: A(:,:), x(:)

Expand Down
12 changes: 6 additions & 6 deletions examples/arkode/F2003_custom/fsunmatrix_fortran_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ module fsunmatrix_fortran_mod
! ----------------------------------------------------------------
type, public :: FMat
logical :: own_data
integer(C_INT64_T) :: Nvar
integer(C_INT64_T) :: N
integer(c_long) :: Nvar
integer(c_long) :: N
real(c_double), pointer :: data(:,:,:)
end type FMat
! ----------------------------------------------------------------
Expand All @@ -42,8 +42,8 @@ module fsunmatrix_fortran_mod
function FSUNMatNew_Fortran(Nvar, N, sunctx) result(sunmat_A)

implicit none
integer(C_INT64_T), value :: Nvar
integer(C_INT64_T), value :: N
integer(c_long), value :: Nvar
integer(c_long), value :: N
type(c_ptr), value :: sunctx
type(SUNMatrix), pointer :: sunmat_A
type(SUNMatrix_Ops), pointer :: ops
Expand Down Expand Up @@ -236,7 +236,7 @@ integer(c_int) function FSUNMatScaleAddI_Fortran(c, sunmat_A) &
real(c_double), value :: c
type(SUNMatrix) :: sunmat_A
type(FMat), pointer :: A
integer(C_INT64_T) :: i, j, k
integer(c_long) :: i, j, k

! extract Fortran matrix structure to work with
A => FSUNMatGetFMat(sunmat_A)
Expand Down Expand Up @@ -267,7 +267,7 @@ integer(c_int) function FSUNMatMatvec_Fortran(sunmat_A, sunvec_x, sunvec_y) &
type(N_Vector) :: sunvec_y
type(FMat), pointer :: A
type(FVec), pointer :: x, y
integer(C_INT64_T) :: i
integer(c_long) :: i

! extract Fortran matrix and vector structures to work with
A => FSUNMatGetFMat(sunmat_A)
Expand Down
6 changes: 3 additions & 3 deletions examples/arkode/F2003_custom/test_fnvector_complex_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ integer(c_int) function check_ans(val, tol, N, sunvec_x) result(failure)
implicit none
complex(c_double_complex), value :: val
real(c_double), value :: tol
integer(c_int64_t), value :: N
integer(c_long), value :: N
Type(N_Vector) :: sunvec_x
Type(FVec), pointer :: x
integer(c_int64_t) :: i
integer(c_long) :: i

x => FN_VGetFVec(sunvec_x)
failure = 0
Expand All @@ -58,7 +58,7 @@ program main
! local variables
type(c_ptr) :: sunctx
integer(c_int) :: fails, i, loc
integer(c_int64_t), parameter :: N = 1000
integer(c_long), parameter :: N = 1000
type(N_Vector), pointer :: sU, sV, sW, sX, sY, sZ
type(FVec), pointer :: U, V, W, X, Y, Z
complex(c_double_complex) :: Udata(N)
Expand Down
10 changes: 5 additions & 5 deletions examples/arkode/F2003_custom/test_fnvector_fortran_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ integer(c_int) function check_ans(val, tol, Nvar, N, sunvec_x) result(failure)

implicit none
real(c_double), value :: val, tol
integer(c_int64_t), value :: Nvar, N
integer(c_long), value :: Nvar, N
Type(N_Vector) :: sunvec_x
Type(FVec), pointer :: x
integer(c_int64_t) :: i, j
integer(c_long) :: i, j

x => FN_VGetFVec(sunvec_x)
failure = 0
Expand Down Expand Up @@ -59,9 +59,9 @@ program main
! local variables
type(c_ptr) :: sunctx
integer(c_int) :: fails
integer(c_int64_t) :: i, j, loc
integer(c_int64_t), parameter :: N = 1000
integer(c_int64_t), parameter :: Nvar = 10
integer(c_long) :: i, j, loc
integer(c_long), parameter :: N = 1000
integer(c_long), parameter :: Nvar = 10
type(N_Vector), pointer :: sU, sV, sW, sX, sY, sZ
type(FVec), pointer :: U, V, W, X, Y, Z
real(c_double), allocatable :: Udata(:,:)
Expand Down
8 changes: 4 additions & 4 deletions examples/arkode/F2003_custom/test_fsunlinsol_fortran_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ integer(c_int) function check_vector(sunvec_x, sunvec_y, tol, Nvar, N) result(fa

implicit none
real(c_double), value :: tol
integer(c_int64_t), value :: Nvar, N
integer(c_long), value :: Nvar, N
Type(N_Vector) :: sunvec_x, sunvec_y
Type(FVec), pointer :: x, y
integer(c_int64_t) :: i, j
integer(c_long) :: i, j

x => FN_VGetFVec(sunvec_x)
y => FN_VGetFVec(sunvec_y)
Expand Down Expand Up @@ -82,8 +82,8 @@ program main
! local variables
type(c_ptr) :: sunctx
integer(c_int) :: fails, retval, j, k
integer(c_int64_t), parameter :: N = 1000
integer(c_int64_t), parameter :: Nvar = 50
integer(c_long), parameter :: N = 1000
integer(c_long), parameter :: Nvar = 50
type(SUNMatrix), pointer :: sA
type(FMat), pointer :: A
type(SUNLinearSolver), pointer :: LS
Expand Down
Loading

0 comments on commit 8b915d4

Please sign in to comment.