Skip to content

Commit

Permalink
Added *.out files, fixed a CMakeList.txt file, and added function hea…
Browse files Browse the repository at this point in the history
…ders where necessary.
  • Loading branch information
danmm16 committed Jul 18, 2023
1 parent 15417b7 commit 8104715
Show file tree
Hide file tree
Showing 13 changed files with 197 additions and 18 deletions.
2 changes: 1 addition & 1 deletion examples/arkode/F2003_serial/ark_roberts_dnsL_f2003.out
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Linear solver: LAPACK DENSE, with user-supplied Jacobian.
Tolerance parameters: rtol = 0.0001 atol = 1.E-08 1.E-11 1.E-08
Initial conditions y0 = ( 1.00 0.00 0.00 )
Constraints and id not used.
Constraints not used.

----------------------------------------------------------------------
t y1 y2 y3 | nst h
Expand Down
2 changes: 1 addition & 1 deletion examples/arkode/F2003_serial/ark_roberts_dns_f2003.out
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Linear solver: DENSE, with user-supplied Jacobian.
Tolerance parameters: rtol = 0.0001 atol = 1.E-08 1.E-11 1.E-08
Initial conditions y0 = ( 1.00 0.00 0.00 )
Constraints and id not used.
Constraints not used.

----------------------------------------------------------------------
t y1 y2 y3 | nst h
Expand Down
50 changes: 48 additions & 2 deletions examples/cvode/F2003_serial/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@ set(FCVODE_examples
)

# Examples using LAPACK linear solvers
set(FCVODE_examples_BL
"cv_roberts_dnsL_f2003\;develop")
if(SUNDIALS_INDEX_SIZE MATCHES "64")

set(FCVODE_examples_LAPACK
"cv_roberts_dnsL_f2003\;develop"
)

endif()

# Add sparse solvers examples for 64-bit indextype configurations only,
# not compatible with 32-bit indextype
Expand Down Expand Up @@ -124,6 +129,47 @@ if(BUILD_SUNLINSOL_KLU)

endif()

# Add the build and install targets for each LAPACK example (if needed)
if(BUILD_SUNLINSOL_LAPACKBAND AND BUILD_SUNLINSOL_LAPACKDENSE)

# Sundials LAPACK linear solver modules
set(SUNLINSOLLAPACK_LIBS
sundials_sunlinsollapackdense
sundials_fsunlinsollapackdense_mod)

# LAPACK libraries
list(APPEND SUNLINSOLLAPACK_LIBS ${LAPACK_LIBRARIES})

foreach(example_tuple ${FCVODE_examples_LAPACK})

# parse the example tuple
list(GET example_tuple 0 example)
list(GET example_tuple 1 example_type)

# example source files
add_executable(${example} ${example}.f90)

set_target_properties(${example} PROPERTIES FOLDER "Examples")

# add example to regression tests
sundials_add_test(${example} ${example}
ANSWER_DIR ${CMAKE_CURRENT_SOURCE_DIR}
ANSWER_FILE ${example}.out
EXAMPLE_TYPE ${example_type})

# libraries to link against
target_link_libraries(${example} ${SUNDIALS_LIBS} ${SUNLINSOLLAPACK_LIBS})

# install example source and out files
if(EXAMPLES_INSTALL)
install(FILES ${example}.f ${example}.out
DESTINATION ${EXAMPLES_INSTALL_PATH}/cvode/F2003_serial)
endif()

endforeach(example_tuple ${FCVODE_examples_LAPACK})

endif()

# create Makefile and CMakeLists.txt for examples
if(EXAMPLES_INSTALL)

Expand Down
14 changes: 10 additions & 4 deletions examples/cvode/F2003_serial/cv_advdiff_bnd_f2003.f90
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ module advdiff_mod
contains

! ----------------------------------------------------------------
! RhsFn provides the right hand side implicit function for the
! ODE: dy1/dt = f1(t,y1,y2,y3)
! dy2/dt = f2(t,y1,y2,y3)
! dy3/dt = f3(t,y1,y2,y3)
! RhsFn provides the right hand side implicit function for the ODE.
!
! Return values:
! 0 = success,
Expand Down Expand Up @@ -140,6 +137,15 @@ integer(c_int) function RhsFn(tn, sunvec_u, sunvec_f, user_data) &

end function RhsFn

! ----------------------------------------------------------------
! JacFn provides the user-supplied banded Jacobian
! function for the ODE.
!
! Return values:
! 0 = success,
! 1 = recoverable error,
! -1 = non-recoverable error
! ----------------------------------------------------------------
integer(c_int) function JacFn(t, sunvec_u, sunvec_f, sunmat_J, &
user_data, sunvec_t1, sunvec_t2, sunvec_t3) result(ierr) &
bind(C,name='JacFn')
Expand Down
61 changes: 57 additions & 4 deletions examples/cvode/F2003_serial/cv_diurnal_kry_f2003.f90
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,8 @@ module diurnal_mod

! ----------------------------------------------------------------
! RhsFn provides the right hand side implicit function for the
! ODE: dy1/dt = f1(t,y1,y2,y3)
! dy2/dt = f2(t,y1,y2,y3)
! dy3/dt = f3(t,y1,y2,y3)
! ODE: dc1/dt = f1(t,c1,c2)
! dc2/dt = f2(t,c1,c2)
!
! Return values:
! 0 = success,
Expand Down Expand Up @@ -204,7 +203,17 @@ integer(c_int) function RhsFn(tn, sunvec_u, sunvec_f, user_data) &
return

end function RhsFn


! ----------------------------------------------------------------
! PreSet provides the setup function for the Preconditioner of the
! ODE: dc1/dt = f1(t,c1,c2)
! dc2/dt = f2(t,c1,c2)
!
! Return values:
! 0 = success,
! 1 = recoverable error,
! -1 = non-recoverable error
! ----------------------------------------------------------------
integer(c_int) function PreSet(t, sunvec_u, sunvec_f, jok, jcur, gamma, user_data) &
result(ierr) bind(C,name='PreSet')

Expand Down Expand Up @@ -253,6 +262,16 @@ integer(c_int) function PreSet(t, sunvec_u, sunvec_f, jok, jcur, gamma, user_dat

end function PreSet

! ----------------------------------------------------------------
! PreSolve provides the solver function for the Preconditioner of
! the ODE: dc1/dt = f1(t,c1,c2)
! dc2/dt = f2(t,c1,c2)
!
! Return values:
! 0 = success,
! 1 = recoverable error,
! -1 = non-recoverable error
! ----------------------------------------------------------------
integer(c_int) function PreSolve(t, sunvec_u, sunvec_f, sunvec_r, sunvec_z, &
gamma, delta, lr, user_data) result(ierr) bind(C,name='PreSolve')

Expand Down Expand Up @@ -291,6 +310,17 @@ integer(c_int) function PreSolve(t, sunvec_u, sunvec_f, sunvec_r, sunvec_z, &

end function PreSolve

! ----------------------------------------------------------------
! Prec_Jac provides the Jacobian routine for the Preconditioner of
! the ODE, specifically the PreSet function, where the ODE is:
! dc1/dt = f1(t,c1,c2)
! dc2/dt = f2(t,c1,c2)
!
! Return values:
! 0 = success,
! 1 = recoverable error,
! -1 = non-recoverable error
! ----------------------------------------------------------------
subroutine Prec_Jac(mmx, mmy, u, bd, qq1, qq2, qq3, qq4, cc3, &
ddy, hhdco, vvdco, ierr)

Expand Down Expand Up @@ -330,6 +360,17 @@ subroutine Prec_Jac(mmx, mmy, u, bd, qq1, qq2, qq3, qq4, cc3, &

end subroutine Prec_Jac

! ----------------------------------------------------------------
! Prec_LU provides the LU Decomposition (2 x 2 inverse) routine
! for the Preconditioner of the ODE, specifically the PreSet
! function, where the ODE is: dc1/dt = f1(t,c1,c2)
! dc2/dt = f2(t,c1,c2)
!
! Return values:
! 0 = success,
! 1 = recoverable error,
! -1 = non-recoverable error
! ----------------------------------------------------------------
subroutine Prec_LU(mmm, p, ierr)

implicit none
Expand Down Expand Up @@ -361,6 +402,18 @@ subroutine Prec_LU(mmm, p, ierr)

end subroutine Prec_LU

! ----------------------------------------------------------------
! Prec_Sol provides the Solver routine for the Preconditioner of
! the ODE (functionally matrix-vector multiplication of our 2 x 2
! matrix), specifically the PreSolve function, where the ODE is:
! dc1/dt = f1(t,c1,c2)
! dc2/dt = f2(t,c1,c2)
!
! Return values:
! 0 = success,
! 1 = recoverable error,
! -1 = non-recoverable error
! ----------------------------------------------------------------
subroutine Prec_Sol(mmm, p, z)

implicit none
Expand Down
43 changes: 43 additions & 0 deletions examples/cvode/F2003_serial/cv_roberts_dnsL_f2003.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

cv_roberts_dns_constraints_f2003.f90: Robertson CV ODE serial example problem for CVODE
Three equation chemical kinetics problem.

Linear solver: LAPACK DENSE, with user-supplied Jacobian.
Tolerance parameters: rtol = 0.0001 atol = 1.E-06 1.E-11 1.E-05
Initial conditions y0 = ( 1.00 0.00 0.00 )

---------------------------------------------------
t y1 y2 y3
---------------------------------------------------
2.6391E-01 9.8997E-01 3.4706E-05 1.0000E-02
rootsfound[] = 0 1
4.0000E-01 9.8517E-01 3.3863E-05 1.4801E-02
4.0000E+00 9.0553E-01 2.2406E-05 9.4449E-02
4.0000E+01 7.1587E-01 9.1872E-06 2.8412E-01
4.0000E+02 4.5055E-01 3.2230E-06 5.4945E-01
4.0000E+03 1.8323E-01 8.9439E-07 8.1677E-01
4.0000E+04 3.8986E-02 1.6219E-07 9.6101E-01
4.0000E+05 4.9340E-03 1.9833E-08 9.9507E-01
4.0000E+06 5.1659E-04 2.0675E-09 9.9948E-01
1.9607E+07 1.0000E-04 4.0004E-10 9.9990E-01
rootsfound[] = -1 0
4.0000E+07 5.1479E-05 2.0593E-10 9.9995E-01
4.0000E+08 6.0238E-06 2.4095E-11 9.9999E-01
4.0000E+09 4.6711E-07 1.8685E-12 1.0000E+00
4.0000E+10 7.1415E-07 2.8566E-12 1.0000E+00

------------------------------------------------------
Final y1' y2' y3'
------------------------------------------------------
5.6187E-17 2.2475E-22 -5.6187E-17

General Solver Stats:
Total internal steps taken = 387
Total rhs function calls = 567
Total Jacobian function calls = 13
Total root function calls = 425
Total LU function calls = 95
Num error test failures = 15
Num nonlinear solver iters = 564
Num nonlinear solver fails = 8

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
Tolerance parameters: rtol = 0.0001 atol = 1.E-06 1.E-11 1.E-05
Initial conditions y0 = ( 1.00 0.00 0.00 )
Constraints cval = ( 1.00 1.00 1.00 )
ID not used.

---------------------------------------------------
t y1 y2 y3
Expand Down
2 changes: 1 addition & 1 deletion examples/cvode/F2003_serial/cv_roberts_dns_f2003.out
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Linear solver: DENSE, with user-supplied Jacobian.
Tolerance parameters: rtol = 0.0001 atol = 1.E-08 1.E-14 1.E-06
Initial conditions y0 = ( 1.00 0.00 0.00 )
Constraints and ID not used.
Constraints not used.

---------------------------------------------------
t y1 y2 y3
Expand Down
2 changes: 1 addition & 1 deletion examples/cvode/F2003_serial/cv_roberts_klu_f2003.out
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Linear solver: DENSE, with user-supplied Jacobian.
Tolerance parameters: rtol = 0.0001 atol = 1.E-06 1.E-12 1.E-04
Initial conditions y0 = ( 1.00 0.00 0.00 )
Constraints and ID not used.
Constraints not used.

---------------------------------------------------
t y1 y2 y3
Expand Down
4 changes: 2 additions & 2 deletions examples/ida/F2003_parallel/ida_heat2D_kry_bbd_f2003.f90
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ end function Exchange


!-----------------------------------------------------------------
! Preconditioner solve routine
! Processor-local portion of the DAE residual function.
!-----------------------------------------------------------------
integer(c_int) function LocalFn(Nloc, t, sunvec_y, sunvec_ydot, sunvec_g, &
user_data) result(ierr) bind(C)
Expand Down Expand Up @@ -768,7 +768,7 @@ program driver
real(c_double), pointer :: f(:,:) ! vector data
type(SUNLinearSolver), pointer :: sun_LS ! linear solver
type(SUNMatrix), pointer :: sunmat_A ! sundials matrix
type(c_ptr) :: ida_mem ! IDAODE memory
type(c_ptr) :: ida_mem ! IDA memory
integer(c_int) :: retval
integer :: ierr, case
logical :: outproc
Expand Down
16 changes: 16 additions & 0 deletions examples/kinsol/F2003_parallel/kin_diagon_kry_f2003.f90
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,14 @@ integer(c_int) function func(sunvec_u, sunvec_f, user_data) &

end function func

! ----------------------------------------------------------------
! kpsetup: The KINSOL Preconditioner setup function
!
! Return values:
! 0 = success,
! 1 = recoverable error,
! -1 = non-recoverable error
! ----------------------------------------------------------------
integer(c_int) function kpsetup(sunvec_u, sunvec_s, sunvec_f, &
sunvec_fs, user_data) result(ierr) bind(C)

Expand Down Expand Up @@ -180,6 +188,14 @@ integer(c_int) function kpsetup(sunvec_u, sunvec_s, sunvec_f, &

end function kpsetup

! ----------------------------------------------------------------
! kpsolve: The KINSOL Preconditioner solve function
!
! Return values:
! 0 = success,
! 1 = recoverable error,
! -1 = non-recoverable error
! ----------------------------------------------------------------
integer(c_int) function kpsolve(sunvec_u, sunvec_s, sunvec_f, &
sunvec_fs, sunvec_v, user_data) result(ierr) bind(C)

Expand Down
2 changes: 1 addition & 1 deletion examples/kinsol/F2003_serial/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

# Examples using SUNDIALS linear solvers
set(FKINSOL_examples
"kinDiagon_kry_f2003\;-ffpe-trap=invalid\;develop"
"kinDiagon_kry_f2003\;\;develop"
"kinRoboKin_dns_f2003\;\;develop"
"kinLaplace_bnd_f2003\;\;develop"
"kinLaplace_picard_kry_f2003\;\;develop"
Expand Down
16 changes: 16 additions & 0 deletions examples/kinsol/F2003_serial/kinDiagon_kry_f2003.f90
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ integer(c_int) function func(sunvec_u, sunvec_f, user_data) &

end function func

! ----------------------------------------------------------------
! kpsetup: The KINSOL Preconditioner setup function
!
! Return values:
! 0 = success,
! 1 = recoverable error,
! -1 = non-recoverable error
! ----------------------------------------------------------------
integer(c_int) function kpsetup(sunvec_u, sunvec_s, sunvec_f, &
sunvec_fs, user_data) result(ierr) bind(C)

Expand Down Expand Up @@ -162,6 +170,14 @@ integer(c_int) function kpsetup(sunvec_u, sunvec_s, sunvec_f, &

end function kpsetup

! ----------------------------------------------------------------
! kpsolve: The KINSOL Preconditioner solve function
!
! Return values:
! 0 = success,
! 1 = recoverable error,
! -1 = non-recoverable error
! ----------------------------------------------------------------
integer(c_int) function kpsolve(sunvec_u, sunvec_s, sunvec_f, &
sunvec_fs, sunvec_v, user_data) result(ierr) bind(C)

Expand Down

0 comments on commit 8104715

Please sign in to comment.