From 81047155bfd643bdcaae8defe8870be21e68c2ce Mon Sep 17 00:00:00 2001 From: Daniel Margolis Date: Tue, 18 Jul 2023 12:38:22 -0500 Subject: [PATCH] Added *.out files, fixed a CMakeList.txt file, and added function headers where necessary. --- .../F2003_serial/ark_roberts_dnsL_f2003.out | 2 +- .../F2003_serial/ark_roberts_dns_f2003.out | 2 +- examples/cvode/F2003_serial/CMakeLists.txt | 50 ++++++++++++++- .../F2003_serial/cv_advdiff_bnd_f2003.f90 | 14 +++-- .../F2003_serial/cv_diurnal_kry_f2003.f90 | 61 +++++++++++++++++-- .../F2003_serial/cv_roberts_dnsL_f2003.out | 43 +++++++++++++ .../cv_roberts_dns_constraints_f2003.out | 1 - .../F2003_serial/cv_roberts_dns_f2003.out | 2 +- .../F2003_serial/cv_roberts_klu_f2003.out | 2 +- .../ida_heat2D_kry_bbd_f2003.f90 | 4 +- .../F2003_parallel/kin_diagon_kry_f2003.f90 | 16 +++++ examples/kinsol/F2003_serial/CMakeLists.txt | 2 +- .../F2003_serial/kinDiagon_kry_f2003.f90 | 16 +++++ 13 files changed, 197 insertions(+), 18 deletions(-) create mode 100644 examples/cvode/F2003_serial/cv_roberts_dnsL_f2003.out diff --git a/examples/arkode/F2003_serial/ark_roberts_dnsL_f2003.out b/examples/arkode/F2003_serial/ark_roberts_dnsL_f2003.out index cdacc9d96c..aa2ddcf652 100644 --- a/examples/arkode/F2003_serial/ark_roberts_dnsL_f2003.out +++ b/examples/arkode/F2003_serial/ark_roberts_dnsL_f2003.out @@ -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 diff --git a/examples/arkode/F2003_serial/ark_roberts_dns_f2003.out b/examples/arkode/F2003_serial/ark_roberts_dns_f2003.out index dcf3e1b603..c3c996bfd3 100644 --- a/examples/arkode/F2003_serial/ark_roberts_dns_f2003.out +++ b/examples/arkode/F2003_serial/ark_roberts_dns_f2003.out @@ -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 diff --git a/examples/cvode/F2003_serial/CMakeLists.txt b/examples/cvode/F2003_serial/CMakeLists.txt index 6c6a4e9f69..c5046700db 100644 --- a/examples/cvode/F2003_serial/CMakeLists.txt +++ b/examples/cvode/F2003_serial/CMakeLists.txt @@ -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 @@ -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) diff --git a/examples/cvode/F2003_serial/cv_advdiff_bnd_f2003.f90 b/examples/cvode/F2003_serial/cv_advdiff_bnd_f2003.f90 index 62058d949d..c876c63fb7 100644 --- a/examples/cvode/F2003_serial/cv_advdiff_bnd_f2003.f90 +++ b/examples/cvode/F2003_serial/cv_advdiff_bnd_f2003.f90 @@ -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, @@ -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') diff --git a/examples/cvode/F2003_serial/cv_diurnal_kry_f2003.f90 b/examples/cvode/F2003_serial/cv_diurnal_kry_f2003.f90 index 623766c17c..68b71064fe 100644 --- a/examples/cvode/F2003_serial/cv_diurnal_kry_f2003.f90 +++ b/examples/cvode/F2003_serial/cv_diurnal_kry_f2003.f90 @@ -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, @@ -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') @@ -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') @@ -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) @@ -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 @@ -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 diff --git a/examples/cvode/F2003_serial/cv_roberts_dnsL_f2003.out b/examples/cvode/F2003_serial/cv_roberts_dnsL_f2003.out new file mode 100644 index 0000000000..69609420a5 --- /dev/null +++ b/examples/cvode/F2003_serial/cv_roberts_dnsL_f2003.out @@ -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 + diff --git a/examples/cvode/F2003_serial/cv_roberts_dns_constraints_f2003.out b/examples/cvode/F2003_serial/cv_roberts_dns_constraints_f2003.out index 2dd8cce0fc..36da8d04ff 100644 --- a/examples/cvode/F2003_serial/cv_roberts_dns_constraints_f2003.out +++ b/examples/cvode/F2003_serial/cv_roberts_dns_constraints_f2003.out @@ -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 diff --git a/examples/cvode/F2003_serial/cv_roberts_dns_f2003.out b/examples/cvode/F2003_serial/cv_roberts_dns_f2003.out index 12df6ed4ce..5d72f8e9fd 100644 --- a/examples/cvode/F2003_serial/cv_roberts_dns_f2003.out +++ b/examples/cvode/F2003_serial/cv_roberts_dns_f2003.out @@ -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 diff --git a/examples/cvode/F2003_serial/cv_roberts_klu_f2003.out b/examples/cvode/F2003_serial/cv_roberts_klu_f2003.out index f0da52b325..d4182f00ae 100644 --- a/examples/cvode/F2003_serial/cv_roberts_klu_f2003.out +++ b/examples/cvode/F2003_serial/cv_roberts_klu_f2003.out @@ -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 diff --git a/examples/ida/F2003_parallel/ida_heat2D_kry_bbd_f2003.f90 b/examples/ida/F2003_parallel/ida_heat2D_kry_bbd_f2003.f90 index 1135510588..944d7c5b01 100644 --- a/examples/ida/F2003_parallel/ida_heat2D_kry_bbd_f2003.f90 +++ b/examples/ida/F2003_parallel/ida_heat2D_kry_bbd_f2003.f90 @@ -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) @@ -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 diff --git a/examples/kinsol/F2003_parallel/kin_diagon_kry_f2003.f90 b/examples/kinsol/F2003_parallel/kin_diagon_kry_f2003.f90 index a509a07404..bcbb6b3118 100644 --- a/examples/kinsol/F2003_parallel/kin_diagon_kry_f2003.f90 +++ b/examples/kinsol/F2003_parallel/kin_diagon_kry_f2003.f90 @@ -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) @@ -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) diff --git a/examples/kinsol/F2003_serial/CMakeLists.txt b/examples/kinsol/F2003_serial/CMakeLists.txt index 41c6ff0798..7f1b5a963c 100644 --- a/examples/kinsol/F2003_serial/CMakeLists.txt +++ b/examples/kinsol/F2003_serial/CMakeLists.txt @@ -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" diff --git a/examples/kinsol/F2003_serial/kinDiagon_kry_f2003.f90 b/examples/kinsol/F2003_serial/kinDiagon_kry_f2003.f90 index 9f4e8e3bbe..651828aab0 100644 --- a/examples/kinsol/F2003_serial/kinDiagon_kry_f2003.f90 +++ b/examples/kinsol/F2003_serial/kinDiagon_kry_f2003.f90 @@ -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) @@ -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)