diff --git a/.github/workflows/build-ci-containers-e4s.yml b/.github/workflows/build-ci-containers-e4s.yml index 46374a4195..16561f8346 100644 --- a/.github/workflows/build-ci-containers-e4s.yml +++ b/.github/workflows/build-ci-containers-e4s.yml @@ -40,7 +40,7 @@ jobs: strategy: matrix: indexsize: [32, 64] - precision: ['single', 'double', 'extended'] + precision: ['single', 'double', 'extended', 'float128'] runs-on: ubuntu-latest needs: build_e4s_base steps: diff --git a/.github/workflows/ubuntu-latest.yml b/.github/workflows/ubuntu-latest.yml index 2326d6454d..ada7d5c8ec 100644 --- a/.github/workflows/ubuntu-latest.yml +++ b/.github/workflows/ubuntu-latest.yml @@ -26,7 +26,7 @@ jobs: max-parallel: 2 matrix: indexsize: [32, 64] - precision: ['single', 'double', 'extended'] + precision: ['single', 'double', 'extended', 'float128'] buildtype: ['Debug', 'Release', 'RelWithDebInfo'] tpls: ['ON'] exclude: @@ -34,10 +34,14 @@ jobs: precision: single - buildtype: Debug precision: extended + - buildtype: Debug + precision: float128 - buildtype: Release precision: single - buildtype: Release precision: extended + - buildtype: Release + precision: float128 - buildtype: RelWithDebInfo precision: double diff --git a/.gitignore b/.gitignore index 86211661fd..19c702ed69 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ /.project /builddir /build* +/cmake-build* /instdir /install* /TPLs @@ -18,9 +19,12 @@ *.directory /.pydevproject .vscode +.vs +/out compile_commands.json .venv .clangd +.idea # custom test environment setup script /test/env/env.sh diff --git a/.gitmodules b/.gitmodules index 91609780fd..a2c9527d9d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,7 +6,7 @@ url = https://github.com/sundials-codes/uberenv.git [submodule "test/answers"] path = test/answers - url = https://github.com/sundials-codes/answers.git + url = https://github.com/wuzhiqiao-ninecube/answers.git [submodule "external/sundials-addon-example"] path = external/sundials-addon-example url = https://github.com/sundials-codes/sundials-addon-example.git diff --git a/benchmarks/diffusion_2D/diffusion_2D.cpp b/benchmarks/diffusion_2D/diffusion_2D.cpp index 270f730bb9..38094e105f 100644 --- a/benchmarks/diffusion_2D/diffusion_2D.cpp +++ b/benchmarks/diffusion_2D/diffusion_2D.cpp @@ -691,23 +691,25 @@ int UserOutput::open(UserData* udata) if (outproc) { cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << endl; if (error) { - cout << " t "; - cout << " ||u||_rms "; - cout << " max error " << endl; - cout << " ---------------------"; - cout << "-------------------------"; - cout << "-------------------------" << endl; + cout << setw(SUN_DIGITS10 / 2 + 3) << " " + << "t" << setw(SUN_DIGITS10 / 2 + 4) << " "; + cout << setw(SUN_DIGITS10 / 2 + 1) << " " + << "||u||_rms" << setw(SUN_DIGITS10 / 2 + 1) << " "; + cout << setw(SUN_DIGITS10 / 2 + 1) << " " + << "max error" << setw(SUN_DIGITS10 / 2 + 1) << " " << endl; + cout << setfill('_') << setw(SUN_DIGITS10 * 3 + 28) << setfill(' ') << endl; } else { - cout << " t "; - cout << " ||u||_rms " << endl; - cout << " ---------------------"; - cout << "-------------------------" << endl; + cout << setw(SUN_DIGITS10 / 2 + 3) << " " + << "t" << setw(SUN_DIGITS10 / 2 + 4) << " "; + cout << setw(SUN_DIGITS10 / 2 + 1) << " " + << "||u||_rms" << setw(SUN_DIGITS10 / 2 + 1) << " " << endl; + cout << setfill('_') << setw(SUN_DIGITS10 * 2 + 18) << " " << endl; } } @@ -739,7 +741,7 @@ int UserOutput::open(UserData* udata) uoutstream << "# je " << udata->je << endl; uoutstream << scientific; - uoutstream << setprecision(numeric_limits::digits10); + uoutstream << setprecision(SUN_DIGITS10); if (error) { @@ -768,7 +770,7 @@ int UserOutput::open(UserData* udata) eoutstream << "# je " << udata->je << endl; eoutstream << scientific; - eoutstream << setprecision(numeric_limits::digits10); + eoutstream << setprecision(SUN_DIGITS10); } } @@ -794,16 +796,21 @@ int UserOutput::write(sunrealtype t, N_Vector u, UserData* udata) } // Compute rms norm of the state - sunrealtype urms = sqrt(N_VDotProd(u, u) / udata->nx / udata->ny); + sunrealtype urms = SUNRsqrt(N_VDotProd(u, u) / udata->nx / udata->ny); // Output current status if (outproc) { if (error) { - cout << setw(22) << t << setw(25) << urms << setw(25) << max << endl; + cout << setw(SUN_DIGITS10 + 7) << t << setw(SUN_DIGITS10 + 10) << urms + << setw(SUN_DIGITS10 + 10) << max << endl; + } + else + { + cout << setw(SUN_DIGITS10 + 7) << t << setw(SUN_DIGITS10 + 10) << urms + << endl; } - else { cout << setw(22) << t << setw(25) << urms << endl; } } // Write solution and error to disk diff --git a/benchmarks/diffusion_2D/diffusion_2D.hpp b/benchmarks/diffusion_2D/diffusion_2D.hpp index f16acb0365..d597ae659c 100644 --- a/benchmarks/diffusion_2D/diffusion_2D.hpp +++ b/benchmarks/diffusion_2D/diffusion_2D.hpp @@ -29,6 +29,8 @@ #include #include #include +#include +#include #include #include "mpi.h" diff --git a/benchmarks/diffusion_2D/mpi_serial/CMakeLists.txt b/benchmarks/diffusion_2D/mpi_serial/CMakeLists.txt index 2d366d1f85..8063c5134d 100644 --- a/benchmarks/diffusion_2D/mpi_serial/CMakeLists.txt +++ b/benchmarks/diffusion_2D/mpi_serial/CMakeLists.txt @@ -54,8 +54,9 @@ foreach(test_tuple ${tests}) target_include_directories(${target} PRIVATE ${benchmark_prefix}) - target_link_libraries(${target} PRIVATE sundials_${package} - sundials_nvecparallel MPI::MPI_CXX) + target_link_libraries( + ${target} PRIVATE sundials_${package} sundials_nvecparallel MPI::MPI_CXX + ${SUNDIALS_MATH_LIBRARY}) if(SUNDIALS_ENABLE_SUNLINSOL_SUPERLUDIST) target_compile_definitions(${target} PRIVATE USE_SUPERLU_DIST) diff --git a/benchmarks/diffusion_2D/mpi_serial/diffusion.cpp b/benchmarks/diffusion_2D/mpi_serial/diffusion.cpp index 5d4ebeef32..589e93ee4c 100644 --- a/benchmarks/diffusion_2D/mpi_serial/diffusion.cpp +++ b/benchmarks/diffusion_2D/mpi_serial/diffusion.cpp @@ -66,8 +66,8 @@ int laplacian(sunrealtype t, N_Vector u, N_Vector f, UserData* udata) sunrealtype bx = (udata->kx) * TWO * PI * PI; sunrealtype by = (udata->ky) * TWO * PI * PI; - sunrealtype sin_t_cos_t = sin(PI * t) * cos(PI * t); - sunrealtype cos_sqr_t = cos(PI * t) * cos(PI * t); + sunrealtype sin_t_cos_t = SUNRsin(PI * t) * SUNRcos(PI * t); + sunrealtype cos_sqr_t = SUNRcos(PI * t) * SUNRcos(PI * t); for (j = jstart; j < jend; j++) { @@ -76,11 +76,11 @@ int laplacian(sunrealtype t, N_Vector u, N_Vector f, UserData* udata) x = (udata->is + i) * udata->dx; y = (udata->js + j) * udata->dy; - sin_sqr_x = sin(PI * x) * sin(PI * x); - sin_sqr_y = sin(PI * y) * sin(PI * y); + sin_sqr_x = SUNRsin(PI * x) * SUNRsin(PI * x); + sin_sqr_y = SUNRsin(PI * y) * SUNRsin(PI * y); - cos_sqr_x = cos(PI * x) * cos(PI * x); - cos_sqr_y = cos(PI * y) * cos(PI * y); + cos_sqr_x = SUNRcos(PI * x) * SUNRcos(PI * x); + cos_sqr_y = SUNRcos(PI * y) * SUNRcos(PI * y); farray[IDX(i, j, nx_loc)] = -TWO * PI * sin_sqr_x * sin_sqr_y * sin_t_cos_t - diff --git a/benchmarks/diffusion_2D/mpi_serial/solution.cpp b/benchmarks/diffusion_2D/mpi_serial/solution.cpp index 85971e8c6d..d4c681862a 100644 --- a/benchmarks/diffusion_2D/mpi_serial/solution.cpp +++ b/benchmarks/diffusion_2D/mpi_serial/solution.cpp @@ -29,7 +29,7 @@ int Solution(sunrealtype t, N_Vector u, UserData* udata) sunrealtype sin_sqr_x, sin_sqr_y; // Constants for computing solution - sunrealtype cos_sqr_t = cos(PI * t) * cos(PI * t); + sunrealtype cos_sqr_t = SUNRcos(PI * t) * SUNRcos(PI * t); // Iterative over domain interior sunindextype istart = (udata->HaveNbrW) ? 0 : 1; @@ -48,8 +48,8 @@ int Solution(sunrealtype t, N_Vector u, UserData* udata) x = (udata->is + i) * udata->dx; y = (udata->js + j) * udata->dy; - sin_sqr_x = sin(PI * x) * sin(PI * x); - sin_sqr_y = sin(PI * y) * sin(PI * y); + sin_sqr_x = SUNRsin(PI * x) * SUNRsin(PI * x); + sin_sqr_y = SUNRsin(PI * y) * SUNRsin(PI * y); uarray[IDX(i, j, udata->nx_loc)] = sin_sqr_x * sin_sqr_y * cos_sqr_t; } @@ -68,7 +68,7 @@ int SolutionDerivative(sunrealtype t, N_Vector up, UserData* udata) sunrealtype sin_sqr_x, sin_sqr_y; // Constants for computing solution - sunrealtype cos_sin_t = -TWO * PI * cos(PI * t) * sin(PI * t); + sunrealtype cos_sin_t = -TWO * PI * SUNRcos(PI * t) * SUNRsin(PI * t); // Iterative over domain interior sunindextype istart = (udata->HaveNbrW) ? 0 : 1; @@ -87,8 +87,8 @@ int SolutionDerivative(sunrealtype t, N_Vector up, UserData* udata) x = (udata->is + i) * udata->dx; y = (udata->js + j) * udata->dy; - sin_sqr_x = sin(PI * x) * sin(PI * x); - sin_sqr_y = sin(PI * y) * sin(PI * y); + sin_sqr_x = SUNRsin(PI * x) * SUNRsin(PI * x); + sin_sqr_y = SUNRsin(PI * y) * SUNRsin(PI * y); uparray[IDX(i, j, udata->nx_loc)] = sin_sqr_x * sin_sqr_y * cos_sin_t; } diff --git a/benchmarks/nvector/openmpdev/test_nvector_performance_openmpdev.c b/benchmarks/nvector/openmpdev/test_nvector_performance_openmpdev.c index 54899986aa..d3dddbca50 100644 --- a/benchmarks/nvector/openmpdev/test_nvector_performance_openmpdev.c +++ b/benchmarks/nvector/openmpdev/test_nvector_performance_openmpdev.c @@ -36,8 +36,9 @@ static int FinalizeClearCache(); * --------------------------------------------------------------------*/ int main(int argc, char* argv[]) { - N_Vector X; /* test vector */ - sunindextype veclen; /* vector length */ + SUNContext ctx = NULL; /* SUNDIALS context */ + N_Vector X = NULL; /* test vector */ + sunindextype veclen; /* vector length */ int print_timing; /* output timings */ int ntests; /* number of tests */ @@ -59,27 +60,27 @@ int main(int argc, char* argv[]) return (-1); } - veclen = atol(argv[1]); + veclen = (sunindextype)atol(argv[1]); if (veclen <= 0) { printf("ERROR: length of vector must be a positive integer \n"); return (-1); } - nvecs = atol(argv[2]); + nvecs = (int)atol(argv[2]); if (nvecs < 1) { printf("WARNING: Fused operation tests disabled\n"); } - nsums = atol(argv[3]); + nsums = (int)atol(argv[3]); if (nsums < 1) { printf("WARNING: Some fused operation tests disabled\n"); } - ntests = atol(argv[4]); + ntests = (int)atol(argv[4]); if (ntests <= 0) { printf("ERROR: number of tests must be a positive integer \n"); return (-1); } - cachesize = atol(argv[5]); + cachesize = (int)atol(argv[5]); if (cachesize < 0) { printf("ERROR: cache size (MB) must be a non-negative integer \n"); @@ -98,7 +99,7 @@ int main(int argc, char* argv[]) printf(" timing on/off %d \n", print_timing); /* Create vectors */ - X = N_VNew_OpenMPDEV(veclen); + X = N_VNew_OpenMPDEV(veclen, ctx); /* run tests */ if (print_timing) { printf("\n\n standard operations:\n"); } @@ -154,6 +155,9 @@ int main(int argc, char* argv[]) FinalizeClearCache(); + flag = SUNContext_Free(&ctx); + if (flag) { return flag; } + printf("\nFinished Tests\n"); return (flag); diff --git a/benchmarks/nvector/test_nvector_performance.c b/benchmarks/nvector/test_nvector_performance.c index d12c062c63..3c46f5043a 100644 --- a/benchmarks/nvector/test_nvector_performance.c +++ b/benchmarks/nvector/test_nvector_performance.c @@ -2860,6 +2860,6 @@ static void time_stats(N_Vector X, double* times, int num_warmups, int ntests, { *sdev += (times[i] - *avg) * (times[i] - *avg); } - *sdev = sqrt(*sdev / (ntests - 1)); + *sdev = SUNRsqrt(*sdev / (ntests - 1)); } } diff --git a/bindings/sundials4py/sundials/sundials_core.cpp b/bindings/sundials4py/sundials/sundials_core.cpp index f68795970f..c5d7fbd2d7 100644 --- a/bindings/sundials4py/sundials/sundials_core.cpp +++ b/bindings/sundials4py/sundials/sundials_core.cpp @@ -89,6 +89,8 @@ void bind_core(nb::module_& m) m.attr("sunrealtype") = np.attr("float64"); #elif defined(SUNDIALS_EXTENDED_PRECISION) m.attr("sunrealtype") = np.attr("longdouble"); +#elif defined(SUNDIALS_FLOAT128_PRECISION) + m.attr("sunrealtype") = np.attr("float128"); #else #error Unknown sunrealtype, email sundials-users@llnl.gov #endif diff --git a/bindings/sundials4py/sundials4py-generate b/bindings/sundials4py/sundials4py-generate index e0aca449e3..64ed8ff737 160000 --- a/bindings/sundials4py/sundials4py-generate +++ b/bindings/sundials4py/sundials4py-generate @@ -1 +1 @@ -Subproject commit e0aca449e3dbb9d3b09b40724e4cc57e8dd1ded1 +Subproject commit 64ed8ff737360daae1fa1ddc401c035b7f62a4d0 diff --git a/cmake/SundialsBuildOptionsPre.cmake b/cmake/SundialsBuildOptionsPre.cmake index 2d6e0a79c3..1402bd701d 100644 --- a/cmake/SundialsBuildOptionsPre.cmake +++ b/cmake/SundialsBuildOptionsPre.cmake @@ -33,7 +33,7 @@ endif() # Option to specify precision (sunrealtype) # --------------------------------------------------------------- -set(DOCSTR "single, double, or extended") +set(DOCSTR "single, double, extended or float128") sundials_option(SUNDIALS_PRECISION STRING "${DOCSTR}" "DOUBLE") string(TOUPPER ${SUNDIALS_PRECISION} _upper_SUNDIALS_PRECISION) set(SUNDIALS_PRECISION @@ -132,7 +132,11 @@ endif() # Option to set the math library # --------------------------------------------------------------- -if(UNIX) +if(CMAKE_C_COMPILER_ID STREQUAL "GNU") + sundials_option( + SUNDIALS_MATH_LIBRARY PATH "Which math library (e.g., libm) to link to" + "-lm -lquadmath" ADVANCED) +elseif(CMAKE_C_COMPILER_ID MATCHES "AppleClang|Clang|Intel|IntelLLVM") sundials_option(SUNDIALS_MATH_LIBRARY PATH "Which math library (e.g., libm) to link to" "-lm" ADVANCED) else() diff --git a/cmake/SundialsSetupCompilers.cmake b/cmake/SundialsSetupCompilers.cmake index 3a82d9b841..5638fd2890 100644 --- a/cmake/SundialsSetupCompilers.cmake +++ b/cmake/SundialsSetupCompilers.cmake @@ -86,15 +86,22 @@ if(SUNDIALS_ENABLE_ALL_WARNINGS) # flags with -Wno-unknown-warning-option. Ironically, this is not supported by # some compilers. set(WARNING_FLAGS - "-Wno-unknown-warning-option -Wall -Wpedantic -Wextra -Wshadow \ + "-Wno-unknown-warning-option -Wall -Wextra -Wshadow \ -Wwrite-strings -Wcast-align -Wdisabled-optimization -Wvla -Walloca \ -Wduplicated-cond -Wduplicated-branches -Wunused-macros \ -Wunused-local-typedefs -Wundef") # TODO(SBR): Try to add -Wredundant-decls once SuperLU version is updated in - # CI tests + # CI tests Avoid numerous warnings from printf + if(SUNDIALS_PRECISION MATCHES "SINGLE|DOUBLE|EXTENDED") + set(WARNING_FLAGS "-Wpedantic ${WARNING_FLAGS}") + endif() + + if(SUNDIALS_PRECISION MATCHES "FLOAT128") + set(WARNING_FLAGS "-Wno-format ${WARNING_FLAGS}") + endif() # Avoid numerous warnings from printf - if(SUNDIALS_PRECISION MATCHES "EXTENDED") + if(SUNDIALS_PRECISION MATCHES "EXTENDED|FLOAT128") set(WARNING_FLAGS "-Wdouble-promotion ${WARNING_FLAGS}") endif() diff --git a/cmake/SundialsSetupCuda.cmake b/cmake/SundialsSetupCuda.cmake index e3b84853d7..30cc749947 100644 --- a/cmake/SundialsSetupCuda.cmake +++ b/cmake/SundialsSetupCuda.cmake @@ -57,12 +57,13 @@ if((CMAKE_CXX_COMPILER_ID MATCHES GNU) endif() # =============================================================== -# Prohibit CUDA interface when using extended precision. +# Prohibit CUDA interface when using extended or float128 precision. # =============================================================== -if(SUNDIALS_PRECISION MATCHES "EXTENDED") +if(SUNDIALS_PRECISION MATCHES "EXTENDED|FLOAT128") message( - FATAL_ERROR "CUDA interfaces are incompatible with extended precision.") + FATAL_ERROR + "CUDA interfaces are incompatible with ${SUNDIALS_PRECISION} precision.") endif() # =============================================================== diff --git a/cmake/macros/SundialsAddNvectorBenchmark.cmake b/cmake/macros/SundialsAddNvectorBenchmark.cmake index 6e27a224ed..16e9ca7545 100644 --- a/cmake/macros/SundialsAddNvectorBenchmark.cmake +++ b/cmake/macros/SundialsAddNvectorBenchmark.cmake @@ -35,8 +35,9 @@ function(sundials_add_nvector_benchmark NAME) target_include_directories(${NAME} PRIVATE ${BENCHMARKS_DIR}/nvector) - target_link_libraries(${NAME} PRIVATE ${arg_SUNDIALS_TARGETS} - ${arg_LINK_LIBRARIES} -lm) + target_link_libraries( + ${NAME} PRIVATE ${arg_SUNDIALS_TARGETS} ${arg_LINK_LIBRARIES} + ${SUNDIALS_MATH_LIBRARY}) install( TARGETS ${NAME} diff --git a/cmake/tpl/SundialsGinkgo.cmake b/cmake/tpl/SundialsGinkgo.cmake index 8ee5df83bd..be1290f0ab 100644 --- a/cmake/tpl/SundialsGinkgo.cmake +++ b/cmake/tpl/SundialsGinkgo.cmake @@ -91,11 +91,12 @@ if(SUNDIALS_ENABLE_GINKGO_CHECKS) message(CHECK_START "Testing Ginkgo") - if(SUNDIALS_PRECISION MATCHES "extended|EXTENDED") + if(SUNDIALS_PRECISION MATCHES "extended|EXTENDED|float128|FLOAT128") message(CHECK_FAIL "failed") message( FATAL_ERROR - "SUNDIALS GINKGO interface is not compatible with extended precision") + "SUNDIALS GINKGO interface is not compatible with extended or float128 precision" + ) endif() if(SUNDIALS_GINKGO_BACKENDS MATCHES "CUDA" AND NOT SUNDIALS_ENABLE_CUDA) diff --git a/cmake/tpl/SundialsKLU.cmake b/cmake/tpl/SundialsKLU.cmake index b7abfe26b9..c54e4917b3 100644 --- a/cmake/tpl/SundialsKLU.cmake +++ b/cmake/tpl/SundialsKLU.cmake @@ -27,8 +27,8 @@ include_guard(GLOBAL) # Section 2: Check to make sure options are compatible # ----------------------------------------------------------------------------- -# KLU does not support single or extended precision -if(SUNDIALS_PRECISION MATCHES "SINGLE" OR SUNDIALS_PRECISION MATCHES "EXTENDED") +# KLU does not support single, extended or float128 precision +if(SUNDIALS_PRECISION MATCHES "SINGLE|EXTENDED|FLOAT128") message( FATAL_ERROR "KLU is not compatible with ${SUNDIALS_PRECISION} precision") endif() diff --git a/cmake/tpl/SundialsLapack.cmake b/cmake/tpl/SundialsLapack.cmake index 3840b547d5..b18c7d6ba3 100644 --- a/cmake/tpl/SundialsLapack.cmake +++ b/cmake/tpl/SundialsLapack.cmake @@ -27,8 +27,8 @@ include_guard(GLOBAL) # Section 2: Check to make sure options are compatible # ----------------------------------------------------------------------------- -# LAPACK does not support extended precision -if(SUNDIALS_ENABLE_LAPACK AND SUNDIALS_PRECISION MATCHES "EXTENDED") +# LAPACK does not support extended or float128 precision +if(ENABLE_LAPACK AND SUNDIALS_PRECISION MATCHES "EXTENDED|FLOAT128") message( FATAL_ERROR "LAPACK is not compatible with ${SUNDIALS_PRECISION} precision") endif() diff --git a/cmake/tpl/SundialsMAGMA.cmake b/cmake/tpl/SundialsMAGMA.cmake index ffc97e167c..662f0972ae 100644 --- a/cmake/tpl/SundialsMAGMA.cmake +++ b/cmake/tpl/SundialsMAGMA.cmake @@ -27,10 +27,11 @@ include_guard(GLOBAL) # Section 2: Check to make sure options are compatible # ----------------------------------------------------------------------------- -if(SUNDIALS_PRECISION MATCHES "extended") +if(SUNDIALS_PRECISION MATCHES "extended|float128") message( FATAL_ERROR - "SUNDIALS MAGMA interface is not compatible with extended precision") + "SUNDIALS MAGMA interface is not compatible with ${SUNDIALS_PRECISION} precision" + ) endif() # ----------------------------------------------------------------------------- diff --git a/cmake/tpl/SundialsONEMKL.cmake b/cmake/tpl/SundialsONEMKL.cmake index 6baaed015f..5461b2af7f 100644 --- a/cmake/tpl/SundialsONEMKL.cmake +++ b/cmake/tpl/SundialsONEMKL.cmake @@ -27,8 +27,8 @@ include_guard(GLOBAL) # Section 2: Check to make sure options are compatible # ----------------------------------------------------------------------------- -# oneMKL does not support extended precision -if(SUNDIALS_PRECISION MATCHES "EXTENDED") +# oneMKL does not support extended or float128 precision +if(SUNDIALS_PRECISION MATCHES "EXTENDED|FLOAT128") message( FATAL_ERROR "oneMKL is not compatible with ${SUNDIALS_PRECISION} precision") endif() diff --git a/cmake/tpl/SundialsPETSC.cmake b/cmake/tpl/SundialsPETSC.cmake index 131fab28a8..4fb3bbe230 100644 --- a/cmake/tpl/SundialsPETSC.cmake +++ b/cmake/tpl/SundialsPETSC.cmake @@ -34,7 +34,7 @@ if(SUNDIALS_ENABLE_PETSC AND NOT SUNDIALS_ENABLE_MPI) "MPI is required for PETSc support. Set SUNDIALS_ENABLE_MPI to ON.") endif() -if(SUNDIALS_PRECISION MATCHES "EXTENDED") +if(SUNDIALS_PRECISION MATCHES "EXTENDED|FLOAT128") message( FATAL_ERROR "SUNDIALS is not compatible with PETSc when using ${SUNDIALS_PRECISION} precision" diff --git a/cmake/tpl/SundialsSuperLUDIST.cmake b/cmake/tpl/SundialsSuperLUDIST.cmake index e7411034aa..c6c8fd70a4 100644 --- a/cmake/tpl/SundialsSuperLUDIST.cmake +++ b/cmake/tpl/SundialsSuperLUDIST.cmake @@ -28,7 +28,7 @@ include_guard(GLOBAL) # ----------------------------------------------------------------------------- # SuperLU_DIST only supports double precision -if(SUNDIALS_PRECISION MATCHES "SINGLE" OR SUNDIALS_PRECISION MATCHES "EXTENDED") +if(SUNDIALS_PRECISION MATCHES "SINGLE|EXTENDED|FLOAT128") message( FATAL_ERROR "SuperLU_DIST is not compatible with ${SUNDIALS_PRECISION} precision") diff --git a/cmake/tpl/SundialsSuperLUMT.cmake b/cmake/tpl/SundialsSuperLUMT.cmake index e7dbb40fed..9cfe2f4776 100644 --- a/cmake/tpl/SundialsSuperLUMT.cmake +++ b/cmake/tpl/SundialsSuperLUMT.cmake @@ -27,8 +27,8 @@ include_guard(GLOBAL) # Section 2: Check to make sure options are compatible # ----------------------------------------------------------------------------- -# SUPERLUMT does not support extended precision -if(SUNDIALS_PRECISION MATCHES "EXTENDED") +# SUPERLUMT does not support extended or float128 precision +if(SUNDIALS_PRECISION MATCHES "EXTENDED|FLOAT128") message( FATAL_ERROR "SUPERLUMT is not compatible with ${SUNDIALS_PRECISION} precision") diff --git a/cmake/tpl/SundialsXBRAID.cmake b/cmake/tpl/SundialsXBRAID.cmake index 4366dac09b..a40b83bdc1 100644 --- a/cmake/tpl/SundialsXBRAID.cmake +++ b/cmake/tpl/SundialsXBRAID.cmake @@ -34,8 +34,8 @@ if(NOT SUNDIALS_ENABLE_MPI) "MPI is required for XBraid support. Set SUNDIALS_ENABLE_MPI to ON.") endif() -# XBraid does not support single or extended precision -if(SUNDIALS_PRECISION MATCHES "SINGLE" OR SUNDIALS_PRECISION MATCHES "EXTENDED") +# XBraid does not support single, extended or precision +if(SUNDIALS_PRECISION MATCHES "SINGLE|EXTENDED|FLOAT128") message( FATAL_ERROR "XBraid is not compatible with ${SUNDIALS_PRECISION} precision") endif() diff --git a/doc/cvode/cv_ex_intro.tex b/doc/cvode/cv_ex_intro.tex index 714043f4fe..07afbd02f1 100644 --- a/doc/cvode/cv_ex_intro.tex +++ b/doc/cvode/cv_ex_intro.tex @@ -308,6 +308,7 @@ \section{Introduction}\label{s:ex_intro} the installation of {\sundials} (see Appendix \ref{c:install} in the User Guide). As a consequence, they contain portions of code that will not be typically present in a user program. For example, all {\CC} example programs make use of the -variables \id{SUNDIALS\_EXTENDED\_PRECISION} and \id{SUNDIALS\_DOUBLE\_PRECISION} -to test if the solver libraries were built in extended or double precision, -and use the appropriate conversion specifiers in \id{printf} functions. +variables \id{SUNDIALS\_FLAOT128\_PRECISION}, \id{SUNDIALS\_EXTENDED\_PRECISION} +and \id{SUNDIALS\_DOUBLE\_PRECISION} to test if the solver libraries were built +in float128, extended or double precision,and use the appropriate conversion +specifiers in \id{printf} functions. diff --git a/doc/cvodes/cvs_ex_intro.tex b/doc/cvodes/cvs_ex_intro.tex index 6fab5f73c7..6811b65468 100644 --- a/doc/cvodes/cvs_ex_intro.tex +++ b/doc/cvodes/cvs_ex_intro.tex @@ -393,9 +393,9 @@ \section{Introduction}\label{s:ex_intro} the installation of {\sundials} (see Appendix \ref{c:install} in the User Guide). As a consequence, they contain portions of code that will not typically be present in a user program. For example, all example programs make use of the -variables \id{SUNDIALS\_EXTENDED\_PRECISION} and \id{SUNDIALS\_DOUBLE\_PRECISION} -to test if the solver libraries -were built in extended or double precision, and use the appropriate conversion +variables \id{SUNDIALS\_FLAOT128\_PRECISION}, \id{SUNDIALS\_EXTENDED\_PRECISION} and +\id{SUNDIALS\_DOUBLE\_PRECISION} to test if the solver libraries +were built in float128, extended or double precision, and use the appropriate conversion specifiers in \id{printf} functions. Similarly, all forward sensitivity examples can be run with or without sensitivity computations enabled and, in the former case, with various combinations of methods and error control diff --git a/doc/ida/ida_ex_intro.tex b/doc/ida/ida_ex_intro.tex index 29f17dd299..e4c1005be9 100644 --- a/doc/ida/ida_ex_intro.tex +++ b/doc/ida/ida_ex_intro.tex @@ -203,6 +203,7 @@ \section{Introduction}\label{s:ex_intro} installation of {\sundials} (see Appendix \ref{c:install} in the User Guide). As a consequence, they contain portions of code that will not be typically present in a user program. For example, all example programs make use of the -variables \id{SUNDIALS\_EXTENDED\_PRECISION} and \id{SUNDIALS\_DOUBLE\_PRECISION} -to test if the solver libraries were built in extended or double precision, -and use the appropriate conversion specifiers in \id{printf} functions. +variables \id{SUNDIALS\_FLAOT128\_PRECISION}, \id{SUNDIALS\_EXTENDED\_PRECISION} +and \id{SUNDIALS\_DOUBLE\_PRECISION} to test if the solver libraries were built +in float128, extended or double precision,and use the appropriate conversion +specifiers in \id{printf} functions. diff --git a/doc/idas/idas_ex_intro.tex b/doc/idas/idas_ex_intro.tex index a7d34d25df..2c566d388d 100644 --- a/doc/idas/idas_ex_intro.tex +++ b/doc/idas/idas_ex_intro.tex @@ -341,9 +341,9 @@ \section{Introduction}\label{s:ex_intro} the installation of {\sundials} (see Appendix \ref{c:install} in the User Guide). As a consequence, they contain portions of code that will not typically be present in a user program. For example, all example programs make use of the -variables \id{SUNDIALS\_EXTENDED\_PRECISION} and \id{SUNDIALS\_DOUBLE\_PRECISION} -to test if the solver libraries -were built in extended or double precision, and use the appropriate conversion +variables \id{SUNDIALS\_FLAOT128\_PRECISION}, \id{SUNDIALS\_EXTENDED\_PRECISION} +and \id{SUNDIALS\_DOUBLE\_PRECISION} to test if the solver libraries +were built in float128, extended or double precision, and use the appropriate conversion specifiers in \id{printf} functions. Similarly, all forward sensitivity examples can be run with or without sensitivity computations enabled and, in the former case, with various combinations of methods and error control diff --git a/doc/kinsol/examples/source/introduction.rst b/doc/kinsol/examples/source/introduction.rst index 0ff35d75cc..403b7ccf80 100644 --- a/doc/kinsol/examples/source/introduction.rst +++ b/doc/kinsol/examples/source/introduction.rst @@ -48,10 +48,10 @@ differ from one machine environment to another by as much as 10% to 20%. compile and run for any combination of configuration options used during the installation of SUNDIALS. As a consequence, they contain portions of code that will not be typically present in a user program. For example, programs - may make use of the variables ``SUNDIALS_EXTENDED_PRECISION`` and - ``SUNDIALS_DOUBLE_PRECISION`` to test if the solver libraries were built in - extended or double precision, and use the appropriate conversion specifiers - in ``printf`` functions. + may make use of the variables ``SUNDIALS_FLOAT128_PRECISION``, + ``SUNDIALS_EXTENDED_PRECISION`` and ``SUNDIALS_DOUBLE_PRECISION`` to test if + the solver libraries were built in float128, extended or double precision, + and use the appropriate conversion specifiers in ``printf`` functions. Serial examples --------------- diff --git a/doc/kinsol/kin_ex_intro.tex b/doc/kinsol/kin_ex_intro.tex index b889cef018..7bb1560ef3 100644 --- a/doc/kinsol/kin_ex_intro.tex +++ b/doc/kinsol/kin_ex_intro.tex @@ -168,6 +168,7 @@ \section{Introduction}\label{s:ex_intro} the installation of {\sundials} (see Appendix \ref{c:install} in the User Guide). As a consequence, they contain portions of code that will not be typically present in a user program. For example, all {\CC} example programs make use of the -variables \id{SUNDIALS\_EXTENDED\_PRECISION} and \id{SUNDIALS\_DOUBLE\_PRECISION} -to test if the solver libraries were built in extended or double precision, -and use the appropriate conversion specifiers in \id{printf} functions. +variables \id{SUNDIALS\_FLAOT128\_PRECISION}, \id{SUNDIALS\_EXTENDED\_PRECISION} and +\id{SUNDIALS\_DOUBLE\_PRECISION} to test if the solver libraries were built in +float128, extended or double precision,and use the appropriate conversion specifiers +in \id{printf} functions. diff --git a/doc/shared/RecentChanges.rst b/doc/shared/RecentChanges.rst index ba72979476..ac7aae0769 100644 --- a/doc/shared/RecentChanges.rst +++ b/doc/shared/RecentChanges.rst @@ -5,6 +5,8 @@ **New Features and Enhancements** +Add `__float128` support with quadmath dependency and ostream integration. + Updated the Kokkos N_Vector to support Kokkos 5.x versions. **Bug Fixes** diff --git a/doc/shared/sundials/Install.rst b/doc/shared/sundials/Install.rst index 2dddd75b45..daa95d57af 100644 --- a/doc/shared/sundials/Install.rst +++ b/doc/shared/sundials/Install.rst @@ -612,7 +612,8 @@ Precision .. cmakeoption:: SUNDIALS_PRECISION The floating-point precision used in SUNDIALS packages and class - implementations, options are: ``single``, ``double``, or ``extended`` + implementations, options are: ``single``, ``double``, ``extended`` + or ``float128`` Default: ``double`` @@ -623,9 +624,18 @@ Math Library .. cmakeoption:: SUNDIALS_MATH_LIBRARY - The standard C math library (e.g., ``libm``) to link with. + The standard C math library (e.g., ``libm``; ``libquadmath`` for float128) to link with. - Default: ``-lm`` on Unix systems, none otherwise + Default: ``-lm -lquadmath`` on Unix systems, none otherwise. For example: + + .. code-block:: bash + + cmake \ + -S SOLVER_DIR \ + -B BUILD_DIR \ + -D CMAKE_INSTALL_PREFIX=INSTALL_DIR \ + -D SUNDIALS_PRECISION=float128 \ + -D SUNDIALS_MATH_LIBRARY=/usr/lib/x86_64-linux-gnu/libm.so;/usr/lib/gcc/x86_64-linux-gnu/13/libquadmath.so \ .. _Installation.Options.Packages: @@ -1114,8 +1124,8 @@ configure SUNDIALS with Ginkgo support using the reference, OpenMP, and CUDA .. note:: - The SUNDIALS interfaces to Ginkgo are not compatible with extended precision - (i.e., when :cmakeop:`SUNDIALS_PRECISION` is set to ``extended``). + The SUNDIALS interfaces to Ginkgo are not compatible with extended or float128 precision + (i.e., when :cmakeop:`SUNDIALS_PRECISION` is set to ``extended`` or ``float128``). .. cmakeoption:: SUNDIALS_ENABLE_GINKGO diff --git a/doc/shared/sundials/Types.rst b/doc/shared/sundials/Types.rst index b2c807a690..c9981a2630 100644 --- a/doc/shared/sundials/Types.rst +++ b/doc/shared/sundials/Types.rst @@ -42,52 +42,60 @@ Floating point types .. c:type:: sunrealtype - The type ``sunrealtype`` can be ``float``, ``double``, or ``long double``, with - the default being ``double``. The user can change the precision of the - arithmetic used in the SUNDIALS solvers at the configuration stage (see - :cmakeop:`SUNDIALS_PRECISION`). + The type ``sunrealtype`` can be ``float``, ``double``, ``long double``, or + ``__float128`` with the default being ``double``. The user can change the + precision of the arithmetic used in the SUNDIALS solvers at the configuration + stage (see: cmakeop:`SUNDIALS_PRECISION`). Additionally, based on the current precision, ``sundials_types.h`` defines ``SUN_BIG_REAL`` to be the largest value representable as a ``sunrealtype``, -``SUN_SMALL_REAL`` to be the smallest value representable as a ``sunrealtype``, and +``SUN_SMALL_REAL`` to be the smallest value representable as a ``sunrealtype``, ``SUN_UNIT_ROUNDOFF`` to be the difference between :math:`1.0` and the minimum -``sunrealtype`` greater than :math:`1.0`. +``sunrealtype`` greater than :math:`1.0`, and ``SUN_DIGITS10`` to be the number + of decimal digits, ``q``, such that any floating-point number as a ``sunrealtype`` + with ``q`` digits and back again without change to the ``q`` decimal digits, + same as ``std::numeric_limits::digits10``. + Within SUNDIALS, real constants are set by way of a macro called ``SUN_RCONST``. It is this macro that needs the ability to branch on the definition of ``sunrealtype``. In ANSI C, a floating-point constant with no suffix is stored as a ``double``. Placing the suffix "``F``" at the end of a floating point constant -makes it a ``float``, whereas using the suffix "``L``" makes it a ``long -double``. For example, +makes it a ``float``, whereas using the suffix "``L``" makes it a ``long double``, +whereas using the suffix "``Q``" makes it a ``__float128``. For example, .. code-block:: c #define A 1.0 #define B 1.0F #define C 1.0L + #define D 1.0Q defines ``A`` to be a ``double`` constant equal to :math:`1.0`, ``B`` to be a -``float`` constant equal to :math:`1.0`, and ``C`` to be a ``long double`` +``float`` constant equal to :math:`1.0`, ``C`` to be a ``long double`` +constant equal to :math:`1.0`, and ``D`` to be a ``__float128`` constant equal to :math:`1.0`. The macro call ``SUN_RCONST(1.0)`` automatically expands to ``1.0`` if ``sunrealtype`` is ``double``, to ``1.0F`` if ``sunrealtype`` is -``float``, or to ``1.0L`` if ``sunrealtype`` is ``long double``. SUNDIALS uses the +``float``, to ``1.0L`` if ``sunrealtype`` is ``long double``, or to ``1.0Q`` if +``sunrealtype`` is ``__float128``. SUNDIALS uses the ``SUN_RCONST`` macro internally to declare all of its floating-point constants. Additionally, SUNDIALS defines several macros for common mathematical functions -*e.g.*, ``fabs``, ``sqrt``, ``exp``, etc. in ``sundials_math.h``. The macros are -prefixed with ``SUNR`` and expand to the appropriate ``C`` function based on the -``sunrealtype``. For example, the macro ``SUNRabs`` expands to the ``C`` function -``fabs`` when ``sunrealtype`` is ``double``, ``fabsf`` when ``sunrealtype`` is -``float``, and ``fabsl`` when ``sunrealtype`` is ``long double``. +*e.g.*, ``fabs``, ``sqrt``, ``exp``, ``sin``, ``sinh``, etc. in ``sundials_math.h``. +The macros are prefixed with ``SUNR`` and expand to the appropriate ``C`` function +based on the ``sunrealtype``. For example, the macro ``SUNRabs`` expands to the +``C`` function ``fabs`` when ``sunrealtype`` is ``double``, ``fabsf`` when +``sunrealtype`` is ``float``, ``fabsl`` when ``sunrealtype`` is ``long double``, +and ``fabsq`` when ``sunrealtype`` is ``__float128``. A user program which uses the type ``sunrealtype``, the ``SUN_RCONST`` macro, and the ``SUNR`` mathematical function macros is precision-independent except for any calls to precision-specific library functions. Our example programs use ``sunrealtype``, ``SUN_RCONST``, and the ``SUNR`` macros. Users can, however, use the -type ``double``, ``float``, or ``long double`` in their code (assuming that this -usage is consistent with the typedef for ``sunrealtype``) and call the appropriate -math library functions directly. Thus, a previously existing piece of C or C++ -code can use SUNDIALS without modifying the code to use ``sunrealtype``, +type ``double``, ``float``, ``long double`` or ``__float128`` in their code (assuming +that this usage is consistent with the typedef for ``sunrealtype``) and call the +appropriate math library functions directly. Thus, a previously existing piece of C +or C++ code can use SUNDIALS without modifying the code to use ``sunrealtype``, ``SUN_RCONST``, or the ``SUNR`` macros so long as the SUNDIALS libraries are built to use the corresponding precision (see :numref:`Installation.Options`). diff --git a/doc/shared/sunlinsol/SUNLinSol_KLU.rst b/doc/shared/sunlinsol/SUNLinSol_KLU.rst index f66b0d9dc0..8e109cc598 100644 --- a/doc/shared/sunlinsol/SUNLinSol_KLU.rst +++ b/doc/shared/sunlinsol/SUNLinSol_KLU.rst @@ -231,8 +231,8 @@ that SUNDIALS has been configured appropriately to link with KLU (see :numref:`Installation.Options.KLU` for details). Additionally, this wrapper only supports double-precision calculations, and therefore cannot be compiled if SUNDIALS is -configured to have :c:type:`sunrealtype` set to either ``extended`` or -``single`` (see :numref:`SUNDIALS.DataTypes` for +configured to have :c:type:`sunrealtype` set to either ``float128``, +``extended`` or ``single`` (see :numref:`SUNDIALS.DataTypes` for details). Since the KLU library supports both 32-bit and 64-bit integers, this interface will be compiled for either of the available :c:type:`sunindextype` options. diff --git a/doc/shared/sunlinsol/SUNLinSol_LapackBand.rst b/doc/shared/sunlinsol/SUNLinSol_LapackBand.rst index f2efd1dd12..76217711c0 100644 --- a/doc/shared/sunlinsol/SUNLinSol_LapackBand.rst +++ b/doc/shared/sunlinsol/SUNLinSol_LapackBand.rst @@ -111,8 +111,8 @@ link with LAPACK (see :numref:`Installation.Options.LAPACK` for details). We note that since there do not exist 128-bit floating-point factorization and solve routines in LAPACK, this interface cannot be compiled when -using ``extended`` precision for :c:type:`sunrealtype`. Similarly, since -there do not exist 64-bit integer LAPACK routines, the +using ``float128`` or ``extended`` precision for :c:type:`sunrealtype`. +Similarly, since there do not exist 64-bit integer LAPACK routines, the SUNLinSol_LapackBand module also cannot be compiled when using ``int64_t`` for the :c:type:`sunindextype`. diff --git a/doc/shared/sunlinsol/SUNLinSol_LapackDense.rst b/doc/shared/sunlinsol/SUNLinSol_LapackDense.rst index e9643cddb4..33a2be256c 100644 --- a/doc/shared/sunlinsol/SUNLinSol_LapackDense.rst +++ b/doc/shared/sunlinsol/SUNLinSol_LapackDense.rst @@ -108,10 +108,10 @@ link with LAPACK (see :numref:`Installation.Options.LAPACK` for details). We note that since there do not exist 128-bit floating-point factorization and solve routines in LAPACK, this interface cannot be -compiled when using ``extended`` precision for :c:type:`sunrealtype`. -Similarly, since there do not exist 64-bit integer LAPACK routines, -the SUNLinSol_LapackDense module also cannot be compiled when using -``int64_t`` for the :c:type:`sunindextype`. +compiled when using ``float128`` or ``extended`` precision for +:c:type:`sunrealtype`. Similarly, since there do not exist 64-bit +integer LAPACK routines, the SUNLinSol_LapackDense module also cannot +be compiled when using ``int64_t`` for the :c:type:`sunindextype`. This solver is constructed to perform the following operations: diff --git a/doc/shared/sunlinsol/SUNLinSol_SuperLUDIST.rst b/doc/shared/sunlinsol/SUNLinSol_SuperLUDIST.rst index 74c6113192..59e241acdf 100644 --- a/doc/shared/sunlinsol/SUNLinSol_SuperLUDIST.rst +++ b/doc/shared/sunlinsol/SUNLinSol_SuperLUDIST.rst @@ -199,8 +199,8 @@ that SUNDIALS has been configured appropriately to link with SuperLU_DIST (see :numref:`Installation.Options.SuperLU_DIST` for details). Additionally, the wrapper only supports double-precision calculations, and therefore cannot be compiled if SUNDIALS -is configured to use single or extended precision. Moreover, since the SuperLU_DIST -library may be installed to support either 32-bit or 64-bit integers, +is configured to use single, extended or float128 precision. Moreover, since the +SuperLU_DIST library may be installed to support either 32-bit or 64-bit integers, it is assumed that the SuperLU_DIST library is installed using the same integer size as SUNDIALS. diff --git a/doc/shared/sunlinsol/SUNLinSol_SuperLUMT.rst b/doc/shared/sunlinsol/SUNLinSol_SuperLUMT.rst index 344ce9ed63..0fc152ef86 100644 --- a/doc/shared/sunlinsol/SUNLinSol_SuperLUMT.rst +++ b/doc/shared/sunlinsol/SUNLinSol_SuperLUMT.rst @@ -167,7 +167,7 @@ appropriately to link with SuperLU_MT (see Additionally, this wrapper only supports single- and double-precision calculations, and therefore cannot be compiled if SUNDIALS is configured to have :c:type:`sunrealtype` set to ``extended`` -(see :numref:`SUNDIALS.DataTypes` for details). Moreover, +or ``float128`` (see :numref:`SUNDIALS.DataTypes` for details). Moreover, since the SuperLU_MT library may be installed to support either 32-bit or 64-bit integers, it is assumed that the SuperLU_MT library is installed using the same integer precision as the SUNDIALS diff --git a/doc/superbuild/source/developers/testing/Answers.rst b/doc/superbuild/source/developers/testing/Answers.rst index e0bb22d82d..44beaae3b5 100644 --- a/doc/superbuild/source/developers/testing/Answers.rst +++ b/doc/superbuild/source/developers/testing/Answers.rst @@ -63,7 +63,7 @@ is expected/desired. Changing output files requires careful verification that th the branch that you are developing in sundials on: ``git checkout -b ``. #. Update the relevant ``.out`` files in - ``test/answers/linux-ubuntu20.04-x86_64/gcc-9.4.0/`` (this is the files + ``test/answers/linux-ubuntu20.04-x86_64/gcc-9.4.0/`` (this is the files used for the GitHub Actions CI). Like with the embedded ``.out`` files, you can try and use the output generated on your machine, but it may be different enough from what is produced on the GitHub actions to trigger a failure. You can download the output files generated on the GitHub @@ -79,7 +79,7 @@ is expected/desired. Changing output files requires careful verification that th When updating files in the answers repo the source path is the path to the build directory downloaded from GitHub and the destination path is ``/linux-ubuntu20.04-x86_64/gcc-9.4.0/``. When updating with output + repo>/linux-ubuntu20.04-x86_64/gcc-9.4.0/``. When updating with output from Jenkins the source path is the build directory for the Jenkins run and the destination path is the top level of the sundials repo (i.e., ../. if running from scripts). The script will automatically traverse the examples and test/unit_test directories to update output files diff --git a/doc/superbuild/source/developers/testing/GitHub.rst b/doc/superbuild/source/developers/testing/GitHub.rst index 752392483a..2434ae9765 100644 --- a/doc/superbuild/source/developers/testing/GitHub.rst +++ b/doc/superbuild/source/developers/testing/GitHub.rst @@ -91,7 +91,7 @@ Automated building of new containers ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ We currently have six different containers, one for each combination of {int32, int64} and {single, -double, extended} precision. These containers are pinned to an E4S release. When E4S does a release, +double, extended, float128} precision. These containers are pinned to an E4S release. When E4S does a release, we can rebuild these containers to use the packages from it. We add E4S as a mirror in the Spack environment so that its buildcache can be leveraged. diff --git a/doc/superbuild/source/developers/testing/Scripts.rst b/doc/superbuild/source/developers/testing/Scripts.rst index 2677985380..0fbfaf149c 100644 --- a/doc/superbuild/source/developers/testing/Scripts.rst +++ b/doc/superbuild/source/developers/testing/Scripts.rst @@ -61,7 +61,7 @@ machine script to change the compiler used when testing. The setup script will set the following environment variables (among others): -* ``SUNDIALS_PRECISION`` the real type: ``single``, ``double``, or ``extended`` +* ``SUNDIALS_PRECISION`` the real type: ``single``, ``double``, ``extended`` or ``float128`` * ``SUNDIALS_INDEX_SIZE`` the index size: ``32`` or ``64`` diff --git a/docker/sundials-ci/build-all-containers.sh b/docker/sundials-ci/build-all-containers.sh index 5a2a176ba8..986fdf6dc1 100644 --- a/docker/sundials-ci/build-all-containers.sh +++ b/docker/sundials-ci/build-all-containers.sh @@ -2,7 +2,7 @@ export DOCKER_BUILDKIT=1 export BUILDKIT_PROGRESS=plain -images=('int32-double' 'int32-extended' 'int32-single' 'int64-double' 'int64-extended' 'int64-single') +images=('int32-double' 'int32-extended' 'int32-float128' 'int32-single' 'int64-double' 'int64-extended' 'int64-float128' 'int64-single') set -x docker build -t ghcr.io/llnl/sundials-ci-e4s-base:latest e4s-base/ docker build -t ghcr.io/llnl/sundials-ci-e4s-base:e4s-22.05 e4s-base/ diff --git a/docker/sundials-ci/e4s-quarterly/int32-float128/spack.yaml b/docker/sundials-ci/e4s-quarterly/int32-float128/spack.yaml new file mode 100644 index 0000000000..17637840fe --- /dev/null +++ b/docker/sundials-ci/e4s-quarterly/int32-float128/spack.yaml @@ -0,0 +1,21 @@ +spack: + packages: + all: + providers: + target: [x86_64] + mpi: + - openmpi + compiler: + - gcc@9.4.0 + specs: + - cmake arch=x86_64 %gcc@9.4.0 + - openmpi arch=x86_64 %gcc@9.4.0 + config: + install_tree: /opt/software + mirrors: + local: /var/cache/spack-mirror + E4S: https://cache.e4s.io + repos: [] + upstreams: {} + concretization: together + view: /opt/view diff --git a/docker/sundials-ci/e4s-quarterly/int64-float128/spack.yaml b/docker/sundials-ci/e4s-quarterly/int64-float128/spack.yaml new file mode 100644 index 0000000000..17637840fe --- /dev/null +++ b/docker/sundials-ci/e4s-quarterly/int64-float128/spack.yaml @@ -0,0 +1,21 @@ +spack: + packages: + all: + providers: + target: [x86_64] + mpi: + - openmpi + compiler: + - gcc@9.4.0 + specs: + - cmake arch=x86_64 %gcc@9.4.0 + - openmpi arch=x86_64 %gcc@9.4.0 + config: + install_tree: /opt/software + mirrors: + local: /var/cache/spack-mirror + E4S: https://cache.e4s.io + repos: [] + upstreams: {} + concretization: together + view: /opt/view diff --git a/docker/sundials-ci/pull-all-containers.sh b/docker/sundials-ci/pull-all-containers.sh index 214e127ded..86614de59e 100644 --- a/docker/sundials-ci/pull-all-containers.sh +++ b/docker/sundials-ci/pull-all-containers.sh @@ -1,6 +1,6 @@ #!/usr/bin/bash -images=('int32-double' 'int32-extended' 'int32-single' 'int64-double' 'int64-extended' 'int64-single') +images=('int32-double' 'int32-extended' 'int32-float128' 'int32-single' 'int64-double' 'int64-extended' 'int64-float128' 'int64-single') set -x docker pull ghcr.io/llnl/sundials-ci-e4s-base:latest docker pull ghcr.io/llnl/sundials-ci-e4s-base:e4s-22.05 diff --git a/docker/sundials-ci/push-all-containers.sh b/docker/sundials-ci/push-all-containers.sh index 47b3a2eb02..caff3957f5 100644 --- a/docker/sundials-ci/push-all-containers.sh +++ b/docker/sundials-ci/push-all-containers.sh @@ -1,6 +1,6 @@ #!/usr/bin/bash -images=('int32-double' 'int32-extended' 'int32-single' 'int64-double' 'int64-extended' 'int64-single') +images=('int32-double' 'int32-extended' 'int32-float128' 'int32-single' 'int64-double' 'int64-extended' 'int64-float128' 'int64-single') set -x docker push ghcr.io/llnl/sundials-ci-e4s-base:latest docker push ghcr.io/llnl/sundials-ci-e4s-base:e4s-22.05 diff --git a/examples/arkode/CXX_lapack/ark_heat2D_lsrk_domeigest.cpp b/examples/arkode/CXX_lapack/ark_heat2D_lsrk_domeigest.cpp index c0eeeac36f..10579a2191 100644 --- a/examples/arkode/CXX_lapack/ark_heat2D_lsrk_domeigest.cpp +++ b/examples/arkode/CXX_lapack/ark_heat2D_lsrk_domeigest.cpp @@ -433,7 +433,7 @@ int main(int argc, char* argv[]) sunrealtype maxerr = N_VMaxNorm(udata->e); cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << " Max error = " << maxerr << endl; } @@ -882,7 +882,7 @@ static int OpenOutput(UserData* udata) if (udata->output > 0) { cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); if (udata->forcing) { cout << " t "; @@ -917,13 +917,13 @@ static int OpenOutput(UserData* udata) // Open output streams for solution and error udata->uout.open("heat2d_solution.txt"); udata->uout << scientific; - udata->uout << setprecision(numeric_limits::digits10); + udata->uout << setprecision(SUN_DIGITS10); if (udata->forcing) { udata->eout.open("heat2d_error.txt"); udata->eout << scientific; - udata->eout << setprecision(numeric_limits::digits10); + udata->eout << setprecision(SUN_DIGITS10); } } diff --git a/examples/arkode/CXX_manyvector/ark_sod_lsrk.cpp b/examples/arkode/CXX_manyvector/ark_sod_lsrk.cpp index 111309af79..c9630f81b5 100644 --- a/examples/arkode/CXX_manyvector/ark_sod_lsrk.cpp +++ b/examples/arkode/CXX_manyvector/ark_sod_lsrk.cpp @@ -336,8 +336,8 @@ void face_flux(sunrealtype (&w1d)[STSIZE][NSPECIES], sunrealtype* f_face, // v = wbar_3 / wbar_1 // w = wbar_4 / wbar_1 // H = wbar_5 / wbar_1 - rhosqrL = sqrt(w1d[2][0]); - rhosqrR = sqrt(w1d[3][0]); + rhosqrL = SUNRsqrt(w1d[2][0]); + rhosqrR = SUNRsqrt(w1d[3][0]); rhosqrbar = HALF * (rhosqrL + rhosqrR); u = HALF * (w1d[2][1] / rhosqrL + w1d[3][1] / rhosqrR) / rhosqrbar; v = HALF * (w1d[2][2] / rhosqrL + w1d[3][2] / rhosqrR) / rhosqrbar; @@ -417,8 +417,8 @@ void face_flux(sunrealtype (&w1d)[STSIZE][NSPECIES], sunrealtype* f_face, flux[j][2] = u * w1d[j][2]; // f_my = rho*v*u = my*u flux[j][3] = u * w1d[j][3]; // f_mz = rho*w*u = mz*u flux[j][4] = u * (w1d[j][4] + p[j]); // f_et = u*(et + p) - csnd = sqrt(udata.gamma * p[j] / w1d[j][0]); // csnd = sqrt(gamma*p/rho) - alpha = max(alpha, abs(u) + csnd); + csnd = SUNRsqrt(udata.gamma * p[j] / w1d[j][0]); // csnd = sqrt(gamma*p/rho) + alpha = SUNMAX(alpha, SUNRabs(u) + csnd); } // compute flux from right side of face at x_{i+1/2}: @@ -447,19 +447,22 @@ void face_flux(sunrealtype (&w1d)[STSIZE][NSPECIES], sunrealtype* f_face, for (i = 0; i < NSPECIES; i++) { // smoothness indicators - beta1 = bc * pow(fproj[2][i] - SUN_RCONST(2.0) * fproj[3][i] + fproj[4][i], - 2) + - FOURTH * pow(SUN_RCONST(3.0) * fproj[2][i] - - SUN_RCONST(4.0) * fproj[3][i] + fproj[4][i], - 2); - beta2 = bc * pow(fproj[1][i] - SUN_RCONST(2.0) * fproj[2][i] + fproj[3][i], - 2) + - FOURTH * pow(fproj[1][i] - fproj[3][i], 2); - beta3 = bc * pow(fproj[0][i] - SUN_RCONST(2.0) * fproj[1][i] + fproj[2][i], - 2) + - FOURTH * pow(fproj[0][i] - SUN_RCONST(4.0) * fproj[1][i] + - SUN_RCONST(3.0) * fproj[2][i], - 2); + beta1 = + bc * SUNRpowerI(fproj[2][i] - SUN_RCONST(2.0) * fproj[3][i] + fproj[4][i], + 2) + + FOURTH * SUNRpowerI(SUN_RCONST(3.0) * fproj[2][i] - + SUN_RCONST(4.0) * fproj[3][i] + fproj[4][i], + 2); + beta2 = + bc * SUNRpowerI(fproj[1][i] - SUN_RCONST(2.0) * fproj[2][i] + fproj[3][i], + 2) + + FOURTH * SUNRpowerI(fproj[1][i] - fproj[3][i], 2); + beta3 = + bc * SUNRpowerI(fproj[0][i] - SUN_RCONST(2.0) * fproj[1][i] + fproj[2][i], + 2) + + FOURTH * SUNRpowerI(fproj[0][i] - SUN_RCONST(4.0) * fproj[1][i] + + SUN_RCONST(3.0) * fproj[2][i], + 2); // nonlinear weights w1 = SUN_RCONST(0.3) / ((epsilon + beta1) * (epsilon + beta1)); w2 = SUN_RCONST(0.6) / ((epsilon + beta2) * (epsilon + beta2)); @@ -504,19 +507,22 @@ void face_flux(sunrealtype (&w1d)[STSIZE][NSPECIES], sunrealtype* f_face, for (i = 0; i < NSPECIES; i++) { // smoothness indicators - beta1 = bc * pow(fproj[2][i] - SUN_RCONST(2.0) * fproj[3][i] + fproj[4][i], - 2) + - FOURTH * pow(SUN_RCONST(3.0) * fproj[2][i] - - SUN_RCONST(4.0) * fproj[3][i] + fproj[4][i], - 2); - beta2 = bc * pow(fproj[1][i] - SUN_RCONST(2.0) * fproj[2][i] + fproj[3][i], - 2) + - FOURTH * pow(fproj[1][i] - fproj[3][i], 2); - beta3 = bc * pow(fproj[0][i] - SUN_RCONST(2.0) * fproj[1][i] + fproj[2][i], - 2) + - FOURTH * pow(fproj[0][i] - SUN_RCONST(4.0) * fproj[1][i] + - SUN_RCONST(3.0) * fproj[2][i], - 2); + beta1 = + bc * SUNRpowerI(fproj[2][i] - SUN_RCONST(2.0) * fproj[3][i] + fproj[4][i], + 2) + + FOURTH * SUNRpowerI(SUN_RCONST(3.0) * fproj[2][i] - + SUN_RCONST(4.0) * fproj[3][i] + fproj[4][i], + 2); + beta2 = + bc * SUNRpowerI(fproj[1][i] - SUN_RCONST(2.0) * fproj[2][i] + fproj[3][i], + 2) + + FOURTH * SUNRpowerI(fproj[1][i] - fproj[3][i], 2); + beta3 = + bc * SUNRpowerI(fproj[0][i] - SUN_RCONST(2.0) * fproj[1][i] + fproj[2][i], + 2) + + FOURTH * SUNRpowerI(fproj[0][i] - SUN_RCONST(4.0) * fproj[1][i] + + SUN_RCONST(3.0) * fproj[2][i], + 2); // nonlinear weights w1 = SUN_RCONST(0.1) / ((epsilon + beta1) * (epsilon + beta1)); w2 = SUN_RCONST(0.6) / ((epsilon + beta2) * (epsilon + beta2)); diff --git a/examples/arkode/CXX_manyvector/ark_sod_lsrk.hpp b/examples/arkode/CXX_manyvector/ark_sod_lsrk.hpp index 4f3afb7257..0ac9202e9d 100644 --- a/examples/arkode/CXX_manyvector/ark_sod_lsrk.hpp +++ b/examples/arkode/CXX_manyvector/ark_sod_lsrk.hpp @@ -52,7 +52,7 @@ #define NSPECIES 5 #define STSIZE 6 -#define WIDTH (10 + std::numeric_limits::digits10) +#define WIDTH (10 + SUN_DIGITS10) // ----------------------------------------------------------------------------- // Problem options @@ -307,6 +307,8 @@ inline void find_arg(std::vector& args, const std::string key, dest = stod(*(it + 1)); #elif defined(SUNDIALS_EXTENDED_PRECISION) dest = stold(*(it + 1)); +#elif defined(SUNDIALS_FLOAT128_PRECISION) + dest = sunrealtype(stold(*(it + 1))); #endif args.erase(it, it + 2); } @@ -433,7 +435,7 @@ static int OpenOutput(EulerData& udata, ARKODEParameters& uopts) if (uopts.output) { std::cout << std::scientific; - std::cout << std::setprecision(std::numeric_limits::digits10); + std::cout << std::setprecision(SUN_DIGITS10); std::cout << " t " << " ||rho|| " << " ||mx|| " @@ -455,7 +457,7 @@ static int OpenOutput(EulerData& udata, ARKODEParameters& uopts) uopts.uout.open(fname.str()); uopts.uout << std::scientific; - uopts.uout << std::setprecision(std::numeric_limits::digits10); + uopts.uout << std::setprecision(SUN_DIGITS10); uopts.uout << "# title Sod Shock Tube" << std::endl; uopts.uout << "# nvar 5" << std::endl; uopts.uout << "# vars rho mx my mz et" << std::endl; @@ -480,11 +482,11 @@ static int WriteOutput(sunrealtype t, N_Vector y, EulerData& udata, N_Vector my = N_VGetSubvector_ManyVector(y, 2); N_Vector mz = N_VGetSubvector_ManyVector(y, 3); N_Vector et = N_VGetSubvector_ManyVector(y, 4); - sunrealtype rhorms = sqrt(N_VDotProd(rho, rho) / (sunrealtype)udata.nx); - sunrealtype mxrms = sqrt(N_VDotProd(mx, mx) / (sunrealtype)udata.nx); - sunrealtype myrms = sqrt(N_VDotProd(my, my) / (sunrealtype)udata.nx); - sunrealtype mzrms = sqrt(N_VDotProd(mz, mz) / (sunrealtype)udata.nx); - sunrealtype etrms = sqrt(N_VDotProd(et, et) / (sunrealtype)udata.nx); + sunrealtype rhorms = SUNRsqrt(N_VDotProd(rho, rho) / (sunrealtype)udata.nx); + sunrealtype mxrms = SUNRsqrt(N_VDotProd(mx, mx) / (sunrealtype)udata.nx); + sunrealtype myrms = SUNRsqrt(N_VDotProd(my, my) / (sunrealtype)udata.nx); + sunrealtype mzrms = SUNRsqrt(N_VDotProd(mz, mz) / (sunrealtype)udata.nx); + sunrealtype etrms = SUNRsqrt(N_VDotProd(et, et) / (sunrealtype)udata.nx); std::cout << std::setprecision(2) << " " << t << std::setprecision(5) << " " << rhorms << " " << mxrms << " " << myrms << " " << mzrms << " " << etrms << std::endl; diff --git a/examples/arkode/CXX_parallel/ark_brusselator1D_task_local_nls.cpp b/examples/arkode/CXX_parallel/ark_brusselator1D_task_local_nls.cpp index 0de80dd619..09c2e5dc66 100644 --- a/examples/arkode/CXX_parallel/ark_brusselator1D_task_local_nls.cpp +++ b/examples/arkode/CXX_parallel/ark_brusselator1D_task_local_nls.cpp @@ -1469,30 +1469,30 @@ int SetupProblem(int argc, char* argv[], UserData* udata, UserOptions* uopt, } else if (strcmp(argv[i], "--xmax") == 0) { - udata->xmax = strtod(argv[i + 1], NULL); + udata->xmax = SUNStrToReal(argv[i + 1]); i++; } else if (strcmp(argv[i], "--A") == 0) { - udata->A = strtod(argv[i + 1], NULL); + udata->A = SUNStrToReal(argv[i + 1]); i++; } else if (strcmp(argv[i], "--B") == 0) { - udata->B = strtod(argv[i + 1], NULL); + udata->B = SUNStrToReal(argv[i + 1]); i++; } else if (strcmp(argv[i], "--k") == 0) { - udata->k1 = strtod(argv[i + 1], NULL); - udata->k2 = strtod(argv[i + 1], NULL); - udata->k3 = strtod(argv[i + 1], NULL); - udata->k4 = strtod(argv[i + 1], NULL); + udata->k1 = SUNStrToReal(argv[i + 1]); + udata->k2 = SUNStrToReal(argv[i + 1]); + udata->k3 = SUNStrToReal(argv[i + 1]); + udata->k4 = SUNStrToReal(argv[i + 1]); i += 4; } else if (strcmp(argv[i], "--c") == 0) { - udata->c = strtod(argv[i + 1], NULL); + udata->c = SUNStrToReal(argv[i + 1]); i++; } else if (strcmp(argv[i], "--order") == 0) @@ -1510,12 +1510,12 @@ int SetupProblem(int argc, char* argv[], UserData* udata, UserOptions* uopt, } else if (strcmp(argv[i], "--rtol") == 0) { - uopt->rtol = strtod(argv[i + 1], NULL); + uopt->rtol = SUNStrToReal(argv[i + 1]); i++; } else if (strcmp(argv[i], "--atol") == 0) { - uopt->atol = strtod(argv[i + 1], NULL); + uopt->atol = SUNStrToReal(argv[i + 1]); i++; } else diff --git a/examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp b/examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp index 3cacf6aaae..0f6d234f74 100644 --- a/examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp +++ b/examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp @@ -77,6 +77,8 @@ #include "cvode/cvode.h" #include "nvector/nvector_mpiplusx.h" #include "nvector/nvector_serial.h" +#include "sundials/sundials_math.h" +#include "sundials/sundials_types.hpp" #include "sunlinsol/sunlinsol_pcg.h" #include "sunlinsol/sunlinsol_spgmr.h" #include "sunnonlinsol/sunnonlinsol_fixedpoint.h" @@ -89,7 +91,7 @@ #define NSPECIES 2 -#define WIDTH (10 + numeric_limits::digits10) +#define WIDTH (10 + SUN_DIGITS10) // Macro to access each species at an (x,y) location in a 1D array #define UIDX(x, y, nx) (NSPECIES * ((nx) * (y) + (x))) @@ -2299,7 +2301,8 @@ static int SetIC(N_Vector u, UserData* udata) a = TWO * PI * (x - udata->xl) / (udata->xu - udata->xl); b = TWO * PI * (y - udata->yl) / (udata->yu - udata->yl); - data[UIDX(i, j, nx_loc)] = udata->A + SUN_RCONST(0.5) * sin(a) * sin(b); + data[UIDX(i, j, nx_loc)] = udata->A + + SUN_RCONST(0.5) * SUNRsin(a) * SUNRsin(b); data[VIDX(i, j, nx_loc)] = udata->B / udata->A; } } @@ -2430,7 +2433,7 @@ static int OpenOutput(UserData* udata) if (udata->output > 0 && udata->outproc) { cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << " t "; cout << " ||u||_rms " << endl; cout << " ---------------------"; @@ -2447,7 +2450,7 @@ static int OpenOutput(UserData* udata) udata->uout.open(fname.str()); udata->uout << scientific; - udata->uout << setprecision(numeric_limits::digits10); + udata->uout << setprecision(SUN_DIGITS10); // Add 1 to the total number of nodes in the x and y directions and to the // end indices in the x and y direction at the North and East boundary to @@ -2490,7 +2493,7 @@ static int WriteOutput(sunrealtype t, N_Vector y, UserData* udata) if (udata->output > 0) { // Compute rms norm of the state - sunrealtype urms = sqrt(N_VDotProd(y, y) / udata->nx / udata->ny); + sunrealtype urms = SUNRsqrt(N_VDotProd(y, y) / udata->nx / udata->ny); // Output current status if (udata->outproc) { cout << setw(22) << t << setw(25) << urms << endl; } diff --git a/examples/arkode/CXX_parallel/ark_heat2D_lsrk_p.cpp b/examples/arkode/CXX_parallel/ark_heat2D_lsrk_p.cpp index 63b41b118a..a8f6e4dce8 100644 --- a/examples/arkode/CXX_parallel/ark_heat2D_lsrk_p.cpp +++ b/examples/arkode/CXX_parallel/ark_heat2D_lsrk_p.cpp @@ -56,6 +56,7 @@ #include #include +#include #include "arkode/arkode_lsrkstep.h" // access to LSRKStep #include "mpi.h" // MPI header file #include "nvector/nvector_parallel.h" // access to the MPI N_Vector @@ -463,7 +464,7 @@ int main(int argc, char* argv[]) if (outproc) { cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << " Max error = " << maxerr << endl; } } @@ -736,8 +737,8 @@ static int f(sunrealtype t, N_Vector u, N_Vector f, void* user_data) sunrealtype bx = (udata->kx) * TWO * PI * PI; sunrealtype by = (udata->ky) * TWO * PI * PI; - sunrealtype sin_t_cos_t = sin(PI * t) * cos(PI * t); - sunrealtype cos_sqr_t = cos(PI * t) * cos(PI * t); + sunrealtype sin_t_cos_t = SUNRsin(PI * t) * SUNRcos(PI * t); + sunrealtype cos_sqr_t = SUNRcos(PI * t) * SUNRcos(PI * t); for (j = jstart; j < jend; j++) { @@ -746,11 +747,11 @@ static int f(sunrealtype t, N_Vector u, N_Vector f, void* user_data) x = (udata->is + i) * udata->dx; y = (udata->js + j) * udata->dy; - sin_sqr_x = sin(PI * x) * sin(PI * x); - sin_sqr_y = sin(PI * y) * sin(PI * y); + sin_sqr_x = SUNRsin(PI * x) * SUNRsin(PI * x); + sin_sqr_y = SUNRsin(PI * y) * SUNRsin(PI * y); - cos_sqr_x = cos(PI * x) * cos(PI * x); - cos_sqr_y = cos(PI * y) * cos(PI * y); + cos_sqr_x = SUNRcos(PI * x) * SUNRcos(PI * x); + cos_sqr_y = SUNRcos(PI * y) * SUNRcos(PI * y); farray[IDX(i, j, nx_loc)] = -TWO * PI * sin_sqr_x * sin_sqr_y * sin_t_cos_t - @@ -1367,7 +1368,7 @@ static int Solution(sunrealtype t, N_Vector u, UserData* udata) sunrealtype sin_sqr_x, sin_sqr_y; // Constants for computing solution - cos_sqr_t = cos(PI * t) * cos(PI * t); + cos_sqr_t = SUNRcos(PI * t) * SUNRcos(PI * t); // Initialize u to zero (handles boundary conditions) N_VConst(ZERO, u); @@ -1389,8 +1390,8 @@ static int Solution(sunrealtype t, N_Vector u, UserData* udata) x = (udata->is + i) * udata->dx; y = (udata->js + j) * udata->dy; - sin_sqr_x = sin(PI * x) * sin(PI * x); - sin_sqr_y = sin(PI * y) * sin(PI * y); + sin_sqr_x = SUNRsin(PI * x) * SUNRsin(PI * x); + sin_sqr_y = SUNRsin(PI * y) * SUNRsin(PI * y); uarray[IDX(i, j, udata->nx_loc)] = sin_sqr_x * sin_sqr_y * cos_sqr_t; } @@ -1496,7 +1497,7 @@ static int OpenOutput(UserData* udata) if (udata->output > 0 && outproc) { cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); if (udata->forcing) { cout << " t "; @@ -1546,7 +1547,7 @@ static int OpenOutput(UserData* udata) udata->uout.open(fname.str()); udata->uout << scientific; - udata->uout << setprecision(numeric_limits::digits10); + udata->uout << setprecision(SUN_DIGITS10); if (udata->forcing) { @@ -1557,7 +1558,7 @@ static int OpenOutput(UserData* udata) udata->eout.open(fname.str()); udata->eout << scientific; - udata->eout << setprecision(numeric_limits::digits10); + udata->eout << setprecision(SUN_DIGITS10); } } @@ -1584,7 +1585,7 @@ static int WriteOutput(sunrealtype t, N_Vector u, UserData* udata) } // Compute rms norm of the state - sunrealtype urms = sqrt(N_VDotProd(u, u) / udata->nx / udata->ny); + sunrealtype urms = SUNRsqrt(N_VDotProd(u, u) / udata->nx / udata->ny); // Output current status if (outproc) diff --git a/examples/arkode/CXX_parallel/ark_heat2D_p.cpp b/examples/arkode/CXX_parallel/ark_heat2D_p.cpp index 6b401008ec..ee8cbde001 100644 --- a/examples/arkode/CXX_parallel/ark_heat2D_p.cpp +++ b/examples/arkode/CXX_parallel/ark_heat2D_p.cpp @@ -56,6 +56,7 @@ #include #include +#include #include "arkode/arkode_arkstep.h" // access to ARKStep #include "mpi.h" // MPI header file #include "nvector/nvector_parallel.h" // access to the MPI N_Vector @@ -537,7 +538,7 @@ int main(int argc, char* argv[]) if (outproc) { cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << " Max error = " << maxerr << endl; } } @@ -811,8 +812,8 @@ static int f(sunrealtype t, N_Vector u, N_Vector f, void* user_data) sunrealtype bx = (udata->kx) * TWO * PI * PI; sunrealtype by = (udata->ky) * TWO * PI * PI; - sunrealtype sin_t_cos_t = sin(PI * t) * cos(PI * t); - sunrealtype cos_sqr_t = cos(PI * t) * cos(PI * t); + sunrealtype sin_t_cos_t = SUNRsin(PI * t) * SUNRcos(PI * t); + sunrealtype cos_sqr_t = SUNRcos(PI * t) * SUNRcos(PI * t); for (j = jstart; j < jend; j++) { @@ -821,11 +822,11 @@ static int f(sunrealtype t, N_Vector u, N_Vector f, void* user_data) x = (udata->is + i) * udata->dx; y = (udata->js + j) * udata->dy; - sin_sqr_x = sin(PI * x) * sin(PI * x); - sin_sqr_y = sin(PI * y) * sin(PI * y); + sin_sqr_x = SUNRsin(PI * x) * SUNRsin(PI * x); + sin_sqr_y = SUNRsin(PI * y) * SUNRsin(PI * y); - cos_sqr_x = cos(PI * x) * cos(PI * x); - cos_sqr_y = cos(PI * y) * cos(PI * y); + cos_sqr_x = SUNRcos(PI * x) * SUNRcos(PI * x); + cos_sqr_y = SUNRcos(PI * y) * SUNRcos(PI * y); farray[IDX(i, j, nx_loc)] = -TWO * PI * sin_sqr_x * sin_sqr_y * sin_t_cos_t - @@ -1502,7 +1503,7 @@ static int Solution(sunrealtype t, N_Vector u, UserData* udata) sunrealtype sin_sqr_x, sin_sqr_y; // Constants for computing solution - cos_sqr_t = cos(PI * t) * cos(PI * t); + cos_sqr_t = SUNRcos(PI * t) * SUNRcos(PI * t); // Initialize u to zero (handles boundary conditions) N_VConst(ZERO, u); @@ -1524,8 +1525,8 @@ static int Solution(sunrealtype t, N_Vector u, UserData* udata) x = (udata->is + i) * udata->dx; y = (udata->js + j) * udata->dy; - sin_sqr_x = sin(PI * x) * sin(PI * x); - sin_sqr_y = sin(PI * y) * sin(PI * y); + sin_sqr_x = SUNRsin(PI * x) * SUNRsin(PI * x); + sin_sqr_y = SUNRsin(PI * y) * SUNRsin(PI * y); uarray[IDX(i, j, udata->nx_loc)] = sin_sqr_x * sin_sqr_y * cos_sqr_t; } @@ -1637,7 +1638,7 @@ static int OpenOutput(UserData* udata) if (udata->output > 0 && outproc) { cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); if (udata->forcing) { cout << " t "; @@ -1687,7 +1688,7 @@ static int OpenOutput(UserData* udata) udata->uout.open(fname.str()); udata->uout << scientific; - udata->uout << setprecision(numeric_limits::digits10); + udata->uout << setprecision(SUN_DIGITS10); if (udata->forcing) { @@ -1698,7 +1699,7 @@ static int OpenOutput(UserData* udata) udata->eout.open(fname.str()); udata->eout << scientific; - udata->eout << setprecision(numeric_limits::digits10); + udata->eout << setprecision(SUN_DIGITS10); } } @@ -1725,7 +1726,7 @@ static int WriteOutput(sunrealtype t, N_Vector u, UserData* udata) } // Compute rms norm of the state - sunrealtype urms = sqrt(N_VDotProd(u, u) / udata->nx / udata->ny); + sunrealtype urms = SUNRsqrt(N_VDotProd(u, u) / udata->nx / udata->ny); // Output current status if (outproc) diff --git a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_ls.cpp b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_ls.cpp index 35127fb812..d1f31541e6 100644 --- a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_ls.cpp +++ b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_ls.cpp @@ -576,7 +576,7 @@ int main(int argc, char* argv[]) if (outproc) { cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << " Max error = " << maxerr << endl; } } @@ -1929,7 +1929,7 @@ static int OpenOutput(UserData* udata) if (udata->output > 0 && outproc) { cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); if (udata->forcing) { cout << " t "; @@ -1979,7 +1979,7 @@ static int OpenOutput(UserData* udata) udata->uout.open(fname.str()); udata->uout << scientific; - udata->uout << setprecision(numeric_limits::digits10); + udata->uout << setprecision(SUN_DIGITS10); if (udata->forcing) { @@ -1990,7 +1990,7 @@ static int OpenOutput(UserData* udata) udata->eout.open(fname.str()); udata->eout << scientific; - udata->eout << setprecision(numeric_limits::digits10); + udata->eout << setprecision(SUN_DIGITS10); } } diff --git a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg.cpp b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg.cpp index 931d9a58bb..0194d9b4fa 100644 --- a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg.cpp +++ b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg.cpp @@ -581,7 +581,7 @@ int main(int argc, char* argv[]) if (outproc) { cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << " Max error = " << maxerr << endl; } } @@ -2546,7 +2546,7 @@ static int OpenOutput(UserData* udata) if (udata->output > 0 && outproc) { cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); if (udata->forcing) { cout << " t "; @@ -2596,7 +2596,7 @@ static int OpenOutput(UserData* udata) udata->uout.open(fname.str()); udata->uout << scientific; - udata->uout << setprecision(numeric_limits::digits10); + udata->uout << setprecision(SUN_DIGITS10); if (udata->forcing) { @@ -2607,7 +2607,7 @@ static int OpenOutput(UserData* udata) udata->eout.open(fname.str()); udata->eout << scientific; - udata->eout << setprecision(numeric_limits::digits10); + udata->eout << setprecision(SUN_DIGITS10); } } diff --git a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_imex.cpp b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_imex.cpp index 65eaa45bfb..4e071c7e22 100644 --- a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_imex.cpp +++ b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_imex.cpp @@ -2619,7 +2619,7 @@ static int OpenOutput(UserData* udata) if (udata->output > 0 && outproc) { cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << " t "; cout << " ||u||_rms " << endl; cout << " ---------------------"; @@ -2657,7 +2657,7 @@ static int OpenOutput(UserData* udata) udata->uout.open(fname.str()); udata->uout << scientific; - udata->uout << setprecision(numeric_limits::digits10); + udata->uout << setprecision(SUN_DIGITS10); } return 0; diff --git a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_mri.cpp b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_mri.cpp index a1d88f477a..b6c54f61d0 100644 --- a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_mri.cpp +++ b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_mri.cpp @@ -2592,7 +2592,7 @@ static int OpenOutput(UserData* udata) if (udata->output > 0 && outproc) { cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << " t "; cout << " ||u||_rms " << endl; cout << " ---------------------"; @@ -2630,7 +2630,7 @@ static int OpenOutput(UserData* udata) udata->uout.open(fname.str()); udata->uout << scientific; - udata->uout << setprecision(numeric_limits::digits10); + udata->uout << setprecision(SUN_DIGITS10); } return 0; diff --git a/examples/arkode/CXX_serial/ark_advection_diffusion_reaction.cpp b/examples/arkode/CXX_serial/ark_advection_diffusion_reaction.cpp index f028b68313..052c5d9cbe 100644 --- a/examples/arkode/CXX_serial/ark_advection_diffusion_reaction.cpp +++ b/examples/arkode/CXX_serial/ark_advection_diffusion_reaction.cpp @@ -1547,7 +1547,7 @@ int SetIC(N_Vector y, UserData& udata) for (sunindextype i = 0; i < udata.nx; i++) { x = udata.xl + i * udata.dx; - p = SUN_RCONST(0.1) * sin(PI * x); + p = SUN_RCONST(0.1) * SUNRsin(PI * x); ydata[UIDX(i)] = udata.A + p; ydata[VIDX(i)] = udata.B / udata.A + p; ydata[WIDX(i)] = udata.B + p; diff --git a/examples/arkode/CXX_serial/ark_advection_diffusion_reaction.hpp b/examples/arkode/CXX_serial/ark_advection_diffusion_reaction.hpp index 72d4500da8..4ec0ee26cc 100644 --- a/examples/arkode/CXX_serial/ark_advection_diffusion_reaction.hpp +++ b/examples/arkode/CXX_serial/ark_advection_diffusion_reaction.hpp @@ -47,7 +47,7 @@ #define NSPECIES 3 -#define WIDTH (10 + numeric_limits::digits10) +#define WIDTH (10 + SUN_DIGITS10) // Macro to access each species at an x location #define UIDX(i) (NSPECIES * (i)) @@ -635,6 +635,8 @@ inline void find_arg(vector& args, const string key, sunrealtype& dest) dest = stod(*(it + 1)); #elif defined(SUNDIALS_EXTENDED_PRECISION) dest = stold(*(it + 1)); +#elif defined(SUNDIALS_FLOAT128_PRECISION) + dest = sunrealtype(stold(*(it + 1))); #endif args.erase(it, it + 2); } @@ -1135,7 +1137,7 @@ static int OpenOutput(UserData& udata, UserOptions& uopts) if (uopts.output) { cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << " t "; cout << " ||y||_rms " << endl; cout << " ---------------------"; @@ -1151,7 +1153,7 @@ static int OpenOutput(UserData& udata, UserOptions& uopts) uopts.uout.open(fname.str()); uopts.uout << scientific; - uopts.uout << setprecision(numeric_limits::digits10); + uopts.uout << setprecision(SUN_DIGITS10); uopts.uout << "# title Advection-Diffusion-Reaction (Brusselator)" << endl; uopts.uout << "# nvar 3" << endl; uopts.uout << "# vars u v w" << endl; @@ -1171,7 +1173,12 @@ static int WriteOutput(sunrealtype t, N_Vector y, UserData& udata, if (uopts.output) { // Compute rms norm of the state - sunrealtype urms = sqrt(N_VDotProd(y, y) / udata.nx); + sunrealtype urms = SUNRsqrt(N_VDotProd(y, y) / udata.nx); +#if defined(SUNDIALS_FLOAT128_PRECISION) + uopts.uout << setprecision(SUN_DIGITS10 / 2); +#else + uopts.uout << setprecision(SUN_DIGITS10); +#endif cout << setw(22) << t << setw(25) << urms << endl; // Write solution to disk diff --git a/examples/arkode/CXX_serial/ark_analytic_sys.cpp b/examples/arkode/CXX_serial/ark_analytic_sys.cpp index a68f88d809..0361c0aac0 100644 --- a/examples/arkode/CXX_serial/ark_analytic_sys.cpp +++ b/examples/arkode/CXX_serial/ark_analytic_sys.cpp @@ -59,6 +59,9 @@ #if defined(SUNDIALS_EXTENDED_PRECISION) #define ESYM "Le" #define FSYM "Lf" +#elif defined(SUNDIALS_FLOAT128_PRECISION) +#define ESYM "Qe" +#define FSYM "Qf" #else #define ESYM "e" #define FSYM "f" @@ -211,7 +214,7 @@ int main() sunrealtype tout = T0 + dTout; cout << " t y0 y1 y2\n"; cout << " --------------------------------------\n"; - while (Tf - t > 1.0e-15) + while (Tf - t > SUN_RCONST(1.0e-15)) { flag = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); // call integrator if (check_flag(&flag, "ARKodeEvolve", 1)) { break; } diff --git a/examples/arkode/CXX_serial/ark_heat2D.cpp b/examples/arkode/CXX_serial/ark_heat2D.cpp index 6cf558e1db..63af832884 100644 --- a/examples/arkode/CXX_serial/ark_heat2D.cpp +++ b/examples/arkode/CXX_serial/ark_heat2D.cpp @@ -56,6 +56,7 @@ #include #include +#include // definition of output stream operator for`__float128` #include "arkode/arkode_arkstep.h" // access to ARKStep #include "nvector/nvector_serial.h" // access to the serial N_Vector #include "sunlinsol/sunlinsol_pcg.h" // access to PCG SUNLinearSolver @@ -458,7 +459,7 @@ int main(int argc, char* argv[]) sunrealtype maxerr = N_VMaxNorm(udata->e); cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << " Max error = " << maxerr << endl; } @@ -530,8 +531,8 @@ static int f(sunrealtype t, N_Vector u, N_Vector f, void* user_data) sunrealtype bx = (udata->kx) * TWO * PI * PI; sunrealtype by = (udata->ky) * TWO * PI * PI; - sunrealtype sin_t_cos_t = sin(PI * t) * cos(PI * t); - sunrealtype cos_sqr_t = cos(PI * t) * cos(PI * t); + sunrealtype sin_t_cos_t = SUNRsin(PI * t) * SUNRcos(PI * t); + sunrealtype cos_sqr_t = SUNRcos(PI * t) * SUNRcos(PI * t); for (sunindextype j = 1; j < ny - 1; j++) { @@ -540,11 +541,11 @@ static int f(sunrealtype t, N_Vector u, N_Vector f, void* user_data) x = i * udata->dx; y = j * udata->dy; - sin_sqr_x = sin(PI * x) * sin(PI * x); - sin_sqr_y = sin(PI * y) * sin(PI * y); + sin_sqr_x = SUNRsin(PI * x) * SUNRsin(PI * x); + sin_sqr_y = SUNRsin(PI * y) * SUNRsin(PI * y); - cos_sqr_x = cos(PI * x) * cos(PI * x); - cos_sqr_y = cos(PI * y) * cos(PI * y); + cos_sqr_x = SUNRcos(PI * x) * SUNRcos(PI * x); + cos_sqr_y = SUNRcos(PI * y) * SUNRcos(PI * y); farray[IDX(i, j, nx)] = -TWO * PI * sin_sqr_x * sin_sqr_y * sin_t_cos_t - @@ -836,7 +837,7 @@ static int Solution(sunrealtype t, N_Vector u, UserData* udata) sunrealtype sin_sqr_x, sin_sqr_y; // Constants for computing solution - cos_sqr_t = cos(PI * t) * cos(PI * t); + cos_sqr_t = SUNRcos(PI * t) * SUNRcos(PI * t); // Initialize u to zero (handles boundary conditions) N_VConst(ZERO, u); @@ -851,8 +852,8 @@ static int Solution(sunrealtype t, N_Vector u, UserData* udata) x = i * udata->dx; y = j * udata->dy; - sin_sqr_x = sin(PI * x) * sin(PI * x); - sin_sqr_y = sin(PI * y) * sin(PI * y); + sin_sqr_x = SUNRsin(PI * x) * SUNRsin(PI * x); + sin_sqr_y = SUNRsin(PI * y) * SUNRsin(PI * y); uarray[IDX(i, j, udata->nx)] = sin_sqr_x * sin_sqr_y * cos_sqr_t; } @@ -953,7 +954,7 @@ static int OpenOutput(UserData* udata) if (udata->output > 0) { cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); if (udata->forcing) { cout << " t "; @@ -988,13 +989,13 @@ static int OpenOutput(UserData* udata) // Open output streams for solution and error udata->uout.open("heat2d_solution.txt"); udata->uout << scientific; - udata->uout << setprecision(numeric_limits::digits10); + udata->uout << setprecision(SUN_DIGITS10); if (udata->forcing) { udata->eout.open("heat2d_error.txt"); udata->eout << scientific; - udata->eout << setprecision(numeric_limits::digits10); + udata->eout << setprecision(SUN_DIGITS10); } } @@ -1009,7 +1010,7 @@ static int WriteOutput(sunrealtype t, N_Vector u, UserData* udata) if (udata->output > 0) { // Compute rms norm of the state - sunrealtype urms = sqrt(N_VDotProd(u, u) / udata->nx / udata->ny); + sunrealtype urms = SUNRsqrt(N_VDotProd(u, u) / udata->nx / udata->ny); // Output current status if (udata->forcing) diff --git a/examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp b/examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp index 604bb3b336..59aa682024 100644 --- a/examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp +++ b/examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp @@ -62,6 +62,7 @@ #include "sunadaptcontroller/sunadaptcontroller_imexgus.h" #include "sunadaptcontroller/sunadaptcontroller_soderlind.h" #include "sundials/sundials_adaptcontroller.h" +#include "sundials/sundials_context.hpp" // Macros for problem constants #define PI SUN_RCONST(3.141592653589793238462643383279502884197169) @@ -370,7 +371,7 @@ int main(int argc, char* argv[]) sunrealtype maxerr = N_VMaxNorm(udata->e); cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << " Max error = " << maxerr << endl; } @@ -440,8 +441,8 @@ static int f(sunrealtype t, N_Vector u, N_Vector f, void* user_data) sunrealtype bx = (udata->kx) * TWO * PI * PI; sunrealtype by = (udata->ky) * TWO * PI * PI; - sunrealtype sin_t_cos_t = sin(PI * t) * cos(PI * t); - sunrealtype cos_sqr_t = cos(PI * t) * cos(PI * t); + sunrealtype sin_t_cos_t = SUNRsin(PI * t) * SUNRcos(PI * t); + sunrealtype cos_sqr_t = SUNRcos(PI * t) * SUNRcos(PI * t); for (sunindextype j = 1; j < ny - 1; j++) { @@ -450,11 +451,11 @@ static int f(sunrealtype t, N_Vector u, N_Vector f, void* user_data) x = i * udata->dx; y = j * udata->dy; - sin_sqr_x = sin(PI * x) * sin(PI * x); - sin_sqr_y = sin(PI * y) * sin(PI * y); + sin_sqr_x = SUNRsin(PI * x) * SUNRsin(PI * x); + sin_sqr_y = SUNRsin(PI * y) * SUNRsin(PI * y); - cos_sqr_x = cos(PI * x) * cos(PI * x); - cos_sqr_y = cos(PI * y) * cos(PI * y); + cos_sqr_x = SUNRcos(PI * x) * SUNRcos(PI * x); + cos_sqr_y = SUNRcos(PI * y) * SUNRcos(PI * y); farray[IDX(i, j, nx)] = -TWO * PI * sin_sqr_x * sin_sqr_y * sin_t_cos_t - @@ -668,7 +669,7 @@ static int Solution(sunrealtype t, N_Vector u, UserData* udata) sunrealtype sin_sqr_x, sin_sqr_y; // Constants for computing solution - cos_sqr_t = cos(PI * t) * cos(PI * t); + cos_sqr_t = SUNRcos(PI * t) * SUNRcos(PI * t); // Initialize u to zero (handles boundary conditions) N_VConst(ZERO, u); @@ -683,8 +684,8 @@ static int Solution(sunrealtype t, N_Vector u, UserData* udata) x = i * udata->dx; y = j * udata->dy; - sin_sqr_x = sin(PI * x) * sin(PI * x); - sin_sqr_y = sin(PI * y) * sin(PI * y); + sin_sqr_x = SUNRsin(PI * x) * SUNRsin(PI * x); + sin_sqr_y = SUNRsin(PI * y) * SUNRsin(PI * y); uarray[IDX(i, j, udata->nx)] = sin_sqr_x * sin_sqr_y * cos_sqr_t; } @@ -779,7 +780,7 @@ static int OpenOutput(UserData* udata) if (udata->output > 0) { cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); if (udata->forcing) { cout << " t "; @@ -814,13 +815,13 @@ static int OpenOutput(UserData* udata) // Open output streams for solution and error udata->uout.open("heat2d_solution.txt"); udata->uout << scientific; - udata->uout << setprecision(numeric_limits::digits10); + udata->uout << setprecision(SUN_DIGITS10); if (udata->forcing) { udata->eout.open("heat2d_error.txt"); udata->eout << scientific; - udata->eout << setprecision(numeric_limits::digits10); + udata->eout << setprecision(SUN_DIGITS10); } } @@ -835,7 +836,7 @@ static int WriteOutput(sunrealtype t, N_Vector u, UserData* udata) if (udata->output > 0) { // Compute rms norm of the state - sunrealtype urms = sqrt(N_VDotProd(u, u) / udata->nx / udata->ny); + sunrealtype urms = SUNRsqrt(N_VDotProd(u, u) / udata->nx / udata->ny); // Output current status if (udata->forcing) diff --git a/examples/arkode/CXX_serial/ark_kpr_Mt.cpp b/examples/arkode/CXX_serial/ark_kpr_Mt.cpp index d592db2a7c..336f837786 100644 --- a/examples/arkode/CXX_serial/ark_kpr_Mt.cpp +++ b/examples/arkode/CXX_serial/ark_kpr_Mt.cpp @@ -77,6 +77,7 @@ // Header files #include // prototypes for ARKStep fcts., consts #include +#include //for setw #include #include // serial N_Vector type, fcts., macros #include @@ -88,7 +89,10 @@ #include // Newton nonlinear solver #include -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define ESYM "Qe" +#define FSYM "Qf" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define ESYM "Le" #define FSYM "Lf" #else @@ -228,9 +232,9 @@ int main(int argc, char* argv[]) << ", abstol = " << abstol << endl; } else { cout << " Order-of-convergence run\n"; } - cout << " G = " << udata.G << endl; - cout << " g = " << udata.g << endl; - cout << " e = " << udata.e << endl; + cout << " G = " << setw(8) << udata.G << endl; + cout << " g = " << setw(8) << udata.g << endl; + cout << " e = " << setw(8) << udata.e << endl; // // Problem Setup @@ -360,8 +364,8 @@ static int fe(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // fill in the RHS function: // g*[ cos(t) sin(t)] * [rdot(t)/(2u)] // [-sin(t) cos(t)] [sdot(t)/(2v)] - gcos = (udata->M_timedep) ? udata->g * cos(t) : udata->g * cos(PI4); - gsin = (udata->M_timedep) ? udata->g * sin(t) : udata->g * sin(PI4); + gcos = (udata->M_timedep) ? udata->g * SUNRcos(t) : udata->g * SUNRcos(PI4); + gsin = (udata->M_timedep) ? udata->g * SUNRsin(t) : udata->g * SUNRsin(PI4); tmp1 = rdot(t) / (TWO * u); tmp2 = sdot(t) / (TWO * v); NV_Ith_S(ydot, 0) = gcos * tmp1 + gsin * tmp2; @@ -382,8 +386,8 @@ static int fi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // fill in the RHS function: // g*[ cos(t) sin(t)]*[G e]*[(-1+u^2-r(t))/(2*u)] // [-sin(t) cos(t)] [e -1] [(-2+v^2-s(t))/(2*v)] - gcos = (udata->M_timedep) ? udata->g * cos(t) : udata->g * cos(PI4); - gsin = (udata->M_timedep) ? udata->g * sin(t) : udata->g * sin(PI4); + gcos = (udata->M_timedep) ? udata->g * SUNRcos(t) : udata->g * SUNRcos(PI4); + gsin = (udata->M_timedep) ? udata->g * SUNRsin(t) : udata->g * SUNRsin(PI4); tmp1 = (-ONE + u * u - r(t)) / (TWO * u); tmp2 = (-TWO + v * v - s(t)) / (TWO * v); tmp3 = udata->G * tmp1 + udata->e * tmp2; @@ -405,8 +409,8 @@ static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // fill in the RHS function: // g*[ cos(t) sin(t)]*( [G e]*[(-1+u^2-r(t))/(2*u)] + [rdot(t)/(2u)] // [-sin(t) cos(t)] ( [e -1] [(-2+v^2-s(t))/(2*v)] [sdot(t)/(2v)] - gcos = (udata->M_timedep) ? udata->g * cos(t) : udata->g * cos(PI4); - gsin = (udata->M_timedep) ? udata->g * sin(t) : udata->g * sin(PI4); + gcos = (udata->M_timedep) ? udata->g * SUNRcos(t) : udata->g * SUNRcos(PI4); + gsin = (udata->M_timedep) ? udata->g * SUNRsin(t) : udata->g * SUNRsin(PI4); tmp1 = (-ONE + u * u - r(t)) / (TWO * u); tmp2 = (-TWO + v * v - s(t)) / (TWO * v); tmp3 = udata->G * tmp1 + udata->e * tmp2 + rdot(t) / (TWO * u); @@ -429,8 +433,8 @@ static int Ji(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, // fill in the Jacobian: // g*[ cos(t) sin(t)]*[G e]*[1-(u^2-r(t)-1)/(2*u^2), 0] // [-sin(t) cos(t)] [e -1] [0, 1-(v^2-s(t)-2)/(2*v^2)] - gcos = (udata->M_timedep) ? udata->g * cos(t) : udata->g * cos(PI4); - gsin = (udata->M_timedep) ? udata->g * sin(t) : udata->g * sin(PI4); + gcos = (udata->M_timedep) ? udata->g * SUNRcos(t) : udata->g * SUNRcos(PI4); + gsin = (udata->M_timedep) ? udata->g * SUNRsin(t) : udata->g * SUNRsin(PI4); t11 = ONE - (u * u - r(t) - ONE) / (TWO * u * u); t12 = ZERO; t22 = ONE - (v * v - s(t) - TWO) / (TWO * v * v); @@ -459,8 +463,8 @@ static int Jn(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, // fill in the Jacobian: // g*[ cos(t) sin(t)]*( [G e]*[1-(u^2-r(t)-1)/(2*u^2), 0] + [-r'(t)/(2*u^2), 0]) // [-sin(t) cos(t)] ( [e -1] [0, 1-(v^2-s(t)-2)/(2*v^2)] [0, -s'(t)/(2*v^2)]) - gcos = (udata->M_timedep) ? udata->g * cos(t) : udata->g * cos(PI4); - gsin = (udata->M_timedep) ? udata->g * sin(t) : udata->g * sin(PI4); + gcos = (udata->M_timedep) ? udata->g * SUNRcos(t) : udata->g * SUNRcos(PI4); + gsin = (udata->M_timedep) ? udata->g * SUNRsin(t) : udata->g * SUNRsin(PI4); t11 = ONE - (u * u - r(t) - ONE) / (TWO * u * u); t12 = ZERO; t21 = ZERO; @@ -485,14 +489,14 @@ static int MassMatrix(sunrealtype t, SUNMatrix M, void* user_data, UserData* udata = (UserData*)user_data; // fill in the mass matrix: g*[ cos(t) sin(t); -sin(t) cos(t)] - SM_ELEMENT_D(M, 0, 0) = (udata->M_timedep) ? udata->g * cos(t) - : udata->g * cos(PI4); - SM_ELEMENT_D(M, 0, 1) = (udata->M_timedep) ? udata->g * sin(t) - : udata->g * sin(PI4); - SM_ELEMENT_D(M, 1, 0) = (udata->M_timedep) ? -udata->g * sin(t) - : -udata->g * sin(PI4); - SM_ELEMENT_D(M, 1, 1) = (udata->M_timedep) ? udata->g * cos(t) - : udata->g * cos(PI4); + SM_ELEMENT_D(M, 0, 0) = (udata->M_timedep) ? udata->g * SUNRcos(t) + : udata->g * SUNRcos(PI4); + SM_ELEMENT_D(M, 0, 1) = (udata->M_timedep) ? udata->g * SUNRsin(t) + : udata->g * SUNRsin(PI4); + SM_ELEMENT_D(M, 1, 0) = (udata->M_timedep) ? -udata->g * SUNRsin(t) + : -udata->g * SUNRsin(PI4); + SM_ELEMENT_D(M, 1, 1) = (udata->M_timedep) ? udata->g * SUNRcos(t) + : udata->g * SUNRcos(PI4); return 0; } @@ -527,7 +531,7 @@ static int adaptive_run(void* arkode_mem, N_Vector y, sunrealtype T0, // Main time-stepping loop: calls ARKodeEvolve to perform integration, // then prints results. Stops when the final time has been reached - int Nt = (int)ceil((Tf - T0) / dTout); + int Nt = (int)SUNRceil((Tf - T0) / dTout); sunrealtype t = T0; sunrealtype tout = T0 + dTout; sunrealtype uerr = ZERO; @@ -657,7 +661,7 @@ static int check_order(void* arkode_mem, N_Vector y, sunrealtype T0, sunrealtype hmax = Tf - T0; if (rk_type == 2) { hmax = ONE / SUNRabs(udata.G); } sunrealtype Nmin = SUNMAX((sunrealtype)Nout, - (sunrealtype)ceil((Tf - T0) / hmax)); + (sunrealtype)SUNRceil((Tf - T0) / hmax)); vector hvals = {(Tf - T0) / Nmin, (Tf - T0) / 2 / Nmin, (Tf - T0) / 4 / Nmin, (Tf - T0) / 8 / Nmin, (Tf - T0) / 16 / Nmin, (Tf - T0) / 32 / Nmin, @@ -700,15 +704,15 @@ static int check_order(void* arkode_mem, N_Vector y, sunrealtype T0, } errs[ih] = SUNMIN(ONE, SUNRsqrt(errs[ih] / ((sunrealtype)Nout * 2))); a11 += 1; - a12 += log(hvals[ih]); - a21 += log(hvals[ih]); - a22 += (log(hvals[ih]) * log(hvals[ih])); - b1 += log(errs[ih]); - b2 += (log(errs[ih]) * log(hvals[ih])); + a12 += SUNRlog(hvals[ih]); + a21 += SUNRlog(hvals[ih]); + a22 += (SUNRlog(hvals[ih]) * SUNRlog(hvals[ih])); + b1 += SUNRlog(errs[ih]); + b2 += (SUNRlog(errs[ih]) * SUNRlog(hvals[ih])); if (ih > 0) { - orders[ih - 1] = log(errs[ih] / errs[ih - 1]) / - log(hvals[ih] / hvals[ih - 1]); + orders[ih - 1] = SUNRlog(errs[ih] / errs[ih - 1]) / + SUNRlog(hvals[ih] / hvals[ih - 1]); printf(" h = %.3" ESYM ", error = %.3" ESYM ", order = %.2" FSYM "\n", hvals[ih], errs[ih], orders[ih - 1]); } @@ -746,13 +750,16 @@ static int check_order(void* arkode_mem, N_Vector y, sunrealtype T0, } } -static sunrealtype r(sunrealtype t) { return (SUN_RCONST(0.5) * cos(t)); } +static sunrealtype r(sunrealtype t) { return (SUN_RCONST(0.5) * SUNRcos(t)); } -static sunrealtype s(sunrealtype t) { return (sin(t)); } +static sunrealtype s(sunrealtype t) { return (SUNRsin(t)); } -static sunrealtype rdot(sunrealtype t) { return (-SUN_RCONST(0.5) * sin(t)); } +static sunrealtype rdot(sunrealtype t) +{ + return (-SUN_RCONST(0.5) * SUNRsin(t)); +} -static sunrealtype sdot(sunrealtype t) { return (cos(t)); } +static sunrealtype sdot(sunrealtype t) { return (SUNRcos(t)); } static sunrealtype utrue(sunrealtype t) { return (SUNRsqrt(ONE + r(t))); } diff --git a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp index c574f5814f..0bd37f3d7e 100644 --- a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp +++ b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp @@ -145,7 +145,10 @@ #include // common utility functions -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define ESYM "Qe" +#define FSYM "Qf" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define ESYM "Le" #define FSYM "Lf" #else @@ -360,7 +363,7 @@ int main(int argc, char* argv[]) case (1): fcontrol = SUNAdaptController_I(sunctx); if (check_ptr((void*)fcontrol, "SUNAdaptController_I")) return 1; - if (!std::isnan(opts.k1f)) + if (!SUNRisnan(opts.k1f)) { retval = SUNAdaptController_SetParams_I(fcontrol, opts.k1f); if (check_flag(retval, "SUNAdaptController_SetParams_I")) return 1; @@ -369,7 +372,7 @@ int main(int argc, char* argv[]) case (2): fcontrol = SUNAdaptController_PI(sunctx); if (check_ptr((void*)fcontrol, "SUNAdaptController_PI")) return 1; - if (!(std::isnan(opts.k1f) || std::isnan(opts.k2f))) + if (!(SUNRisnan(opts.k1f) || SUNRisnan(opts.k2f))) { retval = SUNAdaptController_SetParams_PI(fcontrol, opts.k1f, opts.k2f); if (check_flag(retval, "SUNAdaptController_SetParams_PI")) return 1; @@ -378,7 +381,7 @@ int main(int argc, char* argv[]) case (3): fcontrol = SUNAdaptController_PID(sunctx); if (check_ptr((void*)fcontrol, "SUNAdaptController_PID")) return 1; - if (!(std::isnan(opts.k1f) || std::isnan(opts.k2f) || std::isnan(opts.k3f))) + if (!(SUNRisnan(opts.k1f) || SUNRisnan(opts.k2f) || SUNRisnan(opts.k3f))) { retval = SUNAdaptController_SetParams_PID(fcontrol, opts.k1f, opts.k2f, opts.k3f); @@ -388,7 +391,7 @@ int main(int argc, char* argv[]) case (4): fcontrol = SUNAdaptController_ExpGus(sunctx); if (check_ptr((void*)fcontrol, "SUNAdaptController_ExpGus")) return 1; - if (!(std::isnan(opts.k1f) || std::isnan(opts.k2f))) + if (!(SUNRisnan(opts.k1f) || SUNRisnan(opts.k2f))) { retval = SUNAdaptController_SetParams_ExpGus(fcontrol, opts.k1f, opts.k2f); if (check_flag(retval, "SUNAdaptController_SetParams_ExpGus")) return 1; @@ -397,7 +400,7 @@ int main(int argc, char* argv[]) case (5): fcontrol = SUNAdaptController_ImpGus(sunctx); if (check_ptr((void*)fcontrol, "SUNAdaptController_ImpGus")) return 1; - if (!(std::isnan(opts.k1f) || std::isnan(opts.k2f))) + if (!(SUNRisnan(opts.k1f) || SUNRisnan(opts.k2f))) { retval = SUNAdaptController_SetParams_ImpGus(fcontrol, opts.k1f, opts.k2f); if (check_flag(retval, "SUNAdaptController_SetParams_ImpGus")) return 1; @@ -408,7 +411,7 @@ int main(int argc, char* argv[]) if (check_ptr((void*)fcontrol, "SUNAdaptController_ImExGus")) return 1; break; } - if (!std::isnan(opts.bias) && (opts.fcontrol > 0)) + if (!SUNRisnan(opts.bias) && (opts.fcontrol > 0)) { retval = SUNAdaptController_SetErrorBias(fcontrol, opts.bias); if (check_flag(retval, "SUNAdaptController_SetErrorBias")) return 1; @@ -478,7 +481,7 @@ int main(int argc, char* argv[]) mcontrol_Tol = SUNAdaptController_I(sunctx); if (check_ptr((void*)mcontrol_Tol, "SUNAdaptController_I (mid Tol)")) return 1; - if (!std::isnan(opts.k1s)) + if (!SUNRisnan(opts.k1s)) { retval = SUNAdaptController_SetParams_I(scontrol_H, opts.k1s); if (check_flag(retval, "SUNAdaptController_SetParams_I")) return 1; @@ -493,8 +496,8 @@ int main(int argc, char* argv[]) if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; mcontrol = SUNAdaptController_MRIHTol(mcontrol_H, mcontrol_Tol, sunctx); if (check_ptr((void*)mcontrol, "SUNAdaptController_MRIHTol")) return 1; - if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || - std::isnan(opts.htol_maxfac))) + if (!(SUNRisnan(opts.htol_relch) || SUNRisnan(opts.htol_minfac) || + SUNRisnan(opts.htol_maxfac))) { retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, opts.htol_minfac, @@ -520,7 +523,7 @@ int main(int argc, char* argv[]) mcontrol_Tol = SUNAdaptController_PI(sunctx); if (check_ptr((void*)mcontrol_Tol, "SUNAdaptController_PI (mid Tol)")) return 1; - if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) + if (!(SUNRisnan(opts.k1s) || SUNRisnan(opts.k2s))) { retval = SUNAdaptController_SetParams_PI(scontrol_H, opts.k1s, opts.k2s); if (check_flag(retval, "SUNAdaptController_SetParams_PI")) return 1; @@ -535,8 +538,8 @@ int main(int argc, char* argv[]) if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; mcontrol = SUNAdaptController_MRIHTol(mcontrol_H, mcontrol_Tol, sunctx); if (check_ptr((void*)mcontrol, "SUNAdaptController_MRIHTol")) return 1; - if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || - std::isnan(opts.htol_maxfac))) + if (!(SUNRisnan(opts.htol_relch) || SUNRisnan(opts.htol_minfac) || + SUNRisnan(opts.htol_maxfac))) { retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, opts.htol_minfac, @@ -563,7 +566,7 @@ int main(int argc, char* argv[]) mcontrol_Tol = SUNAdaptController_PID(sunctx); if (check_ptr((void*)mcontrol_Tol, "SUNAdaptController_PID (mid Tol)")) return 1; - if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s) || std::isnan(opts.k3s))) + if (!(SUNRisnan(opts.k1s) || SUNRisnan(opts.k2s) || SUNRisnan(opts.k3s))) { retval = SUNAdaptController_SetParams_PID(scontrol_H, opts.k1s, opts.k2s, opts.k3s); @@ -582,8 +585,8 @@ int main(int argc, char* argv[]) if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; mcontrol = SUNAdaptController_MRIHTol(mcontrol_H, mcontrol_Tol, sunctx); if (check_ptr((void*)mcontrol, "SUNAdaptController_MRIHTol")) return 1; - if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || - std::isnan(opts.htol_maxfac))) + if (!(SUNRisnan(opts.htol_relch) || SUNRisnan(opts.htol_minfac) || + SUNRisnan(opts.htol_maxfac))) { retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, opts.htol_minfac, @@ -610,7 +613,7 @@ int main(int argc, char* argv[]) mcontrol_Tol = SUNAdaptController_ExpGus(sunctx); if (check_ptr((void*)mcontrol_Tol, "SUNAdaptController_ExpGus (mid Tol)")) return 1; - if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) + if (!(SUNRisnan(opts.k1s) || SUNRisnan(opts.k2s))) { retval = SUNAdaptController_SetParams_ExpGus(scontrol_H, opts.k1s, opts.k2s); @@ -629,8 +632,8 @@ int main(int argc, char* argv[]) if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; mcontrol = SUNAdaptController_MRIHTol(mcontrol_H, mcontrol_Tol, sunctx); if (check_ptr((void*)mcontrol, "SUNAdaptController_MRIHTol")) return 1; - if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || - std::isnan(opts.htol_maxfac))) + if (!(SUNRisnan(opts.htol_relch) || SUNRisnan(opts.htol_minfac) || + SUNRisnan(opts.htol_maxfac))) { retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, opts.htol_minfac, @@ -657,7 +660,7 @@ int main(int argc, char* argv[]) mcontrol_Tol = SUNAdaptController_ImpGus(sunctx); if (check_ptr((void*)mcontrol_Tol, "SUNAdaptController_ImpGus (mid Tol)")) return 1; - if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) + if (!(SUNRisnan(opts.k1s) || SUNRisnan(opts.k2s))) { retval = SUNAdaptController_SetParams_ImpGus(scontrol_H, opts.k1s, opts.k2s); @@ -676,8 +679,8 @@ int main(int argc, char* argv[]) if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; mcontrol = SUNAdaptController_MRIHTol(mcontrol_H, mcontrol_Tol, sunctx); if (check_ptr((void*)mcontrol, "SUNAdaptController_MRIHTol")) return 1; - if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || - std::isnan(opts.htol_maxfac))) + if (!(SUNRisnan(opts.htol_relch) || SUNRisnan(opts.htol_minfac) || + SUNRisnan(opts.htol_maxfac))) { retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, opts.htol_minfac, @@ -708,8 +711,8 @@ int main(int argc, char* argv[]) if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; mcontrol = SUNAdaptController_MRIHTol(scontrol_H, scontrol_Tol, sunctx); if (check_ptr((void*)mcontrol, "SUNAdaptController_MRIHTol")) return 1; - if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || - std::isnan(opts.htol_maxfac))) + if (!(SUNRisnan(opts.htol_relch) || SUNRisnan(opts.htol_minfac) || + SUNRisnan(opts.htol_maxfac))) { retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, opts.htol_minfac, @@ -728,7 +731,7 @@ int main(int argc, char* argv[]) if (check_ptr((void*)scontrol, "SUNAdaptControllerI (slow)")) return 1; mcontrol = SUNAdaptController_I(sunctx); if (check_ptr((void*)mcontrol, "SUNAdaptControllerI (mid)")) return 1; - if (!std::isnan(opts.k1s)) + if (!SUNRisnan(opts.k1s)) { retval = SUNAdaptController_SetParams_I(scontrol, opts.k1s); if (check_flag(retval, "SUNAdaptController_SetParams_I")) return 1; @@ -743,7 +746,7 @@ int main(int argc, char* argv[]) if (check_ptr((void*)scontrol, "SUNAdaptController_PI (slow)")) return 1; mcontrol = SUNAdaptController_PI(sunctx); if (check_ptr((void*)mcontrol, "SUNAdaptController_PI (mid)")) return 1; - if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) + if (!(SUNRisnan(opts.k1s) || SUNRisnan(opts.k2s))) { retval = SUNAdaptController_SetParams_PI(scontrol, opts.k1s, opts.k2s); if (check_flag(retval, "SUNAdaptController_SetParams_PI")) return 1; @@ -758,7 +761,7 @@ int main(int argc, char* argv[]) if (check_ptr((void*)scontrol, "SUNAdaptController_PID (slow)")) return 1; mcontrol = SUNAdaptController_PID(sunctx); if (check_ptr((void*)mcontrol, "SUNAdaptController_PID (mid)")) return 1; - if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s) || std::isnan(opts.k3s))) + if (!(SUNRisnan(opts.k1s) || SUNRisnan(opts.k2s) || SUNRisnan(opts.k3s))) { retval = SUNAdaptController_SetParams_PID(scontrol, opts.k1s, opts.k2s, opts.k3s); @@ -776,7 +779,7 @@ int main(int argc, char* argv[]) return 1; mcontrol = SUNAdaptController_ExpGus(sunctx); if (check_ptr((void*)mcontrol, "SUNAdaptController_ExpGus (mid)")) return 1; - if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) + if (!(SUNRisnan(opts.k1s) || SUNRisnan(opts.k2s))) { retval = SUNAdaptController_SetParams_ExpGus(scontrol, opts.k1s, opts.k2s); if (check_flag(retval, "SUNAdaptController_SetParams_ExpGus")) return 1; @@ -792,7 +795,7 @@ int main(int argc, char* argv[]) return 1; mcontrol = SUNAdaptController_ImpGus(sunctx); if (check_ptr((void*)mcontrol, "SUNAdaptController_ImpGus (mid)")) return 1; - if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) + if (!(SUNRisnan(opts.k1s) || SUNRisnan(opts.k2s))) { retval = SUNAdaptController_SetParams_ImpGus(scontrol, opts.k1s, opts.k2s); if (check_flag(retval, "SUNAdaptController_SetParams_ImpGus")) return 1; @@ -812,7 +815,7 @@ int main(int argc, char* argv[]) break; } } - if (!std::isnan(opts.bias) && (opts.scontrol > 0)) + if (!SUNRisnan(opts.bias) && (opts.scontrol > 0)) { retval = SUNAdaptController_SetErrorBias(scontrol, opts.bias); if (check_flag(retval, "SUNAdaptController_SetErrorBias")) return 1; @@ -862,7 +865,7 @@ int main(int argc, char* argv[]) retval = ARKodeSetAdaptivityAdjustment(mid_arkode_mem, 0); if (check_flag(retval, "ARKodeSetAdaptivityAdjustment")) return 1; } - if (!std::isnan(opts.slow_safety)) + if (!SUNRisnan(opts.slow_safety)) { retval = ARKodeSetSafetyFactor(mid_arkode_mem, opts.slow_safety); if (check_flag(retval, "ARKodeSetSafetyFactor")) return 1; @@ -920,7 +923,7 @@ int main(int argc, char* argv[]) retval = ARKodeSetAdaptivityAdjustment(arkode_mem, 0); if (check_flag(retval, "ARKodeSetAdaptivityAdjustment")) return 1; } - if (!std::isnan(opts.slow_safety)) + if (!SUNRisnan(opts.slow_safety)) { retval = ARKodeSetSafetyFactor(arkode_mem, opts.slow_safety); if (check_flag(retval, "ARKodeSetSafetyFactor")) return 1; @@ -985,19 +988,19 @@ int main(int argc, char* argv[]) u = ydata[0]; v = ydata[1]; w = ydata[2]; - uerr = std::abs(yrefdata[0] - u); - verr = std::abs(yrefdata[1] - v); - werr = std::abs(yrefdata[2] - w); + uerr = SUNRabs(yrefdata[0] - u); + verr = SUNRabs(yrefdata[1] - v); + werr = SUNRabs(yrefdata[2] - w); uerrtot += uerr * uerr; verrtot += verr * verr; werrtot += werr * werr; errtot += uerr * uerr + verr * verr + werr * werr; - accuracy = std::max(accuracy, - uerr / std::abs(opts.atol + opts.rtol * yrefdata[0])); - accuracy = std::max(accuracy, - verr / std::abs(opts.atol + opts.rtol * yrefdata[1])); - accuracy = std::max(accuracy, - werr / std::abs(opts.atol + opts.rtol * yrefdata[2])); + accuracy = SUNMAX(accuracy, + uerr / SUNRabs(opts.atol + opts.rtol * yrefdata[0])); + accuracy = SUNMAX(accuracy, + verr / SUNRabs(opts.atol + opts.rtol * yrefdata[1])); + accuracy = SUNMAX(accuracy, + werr / SUNRabs(opts.atol + opts.rtol * yrefdata[2])); // Periodically output current results to screen if (t >= tout) @@ -1059,10 +1062,10 @@ int main(int argc, char* argv[]) check_flag(retval, "ARKodeGetNumRhsEvals"); // Print some final statistics - uerrtot = std::sqrt(uerrtot / (sunrealtype)nsts); - verrtot = std::sqrt(verrtot / (sunrealtype)nsts); - werrtot = std::sqrt(werrtot / (sunrealtype)nsts); - errtot = std::sqrt(errtot / SUN_RCONST(3.0) / (sunrealtype)nsts); + uerrtot = SUNRsqrt(uerrtot / (sunrealtype)nsts); + verrtot = SUNRsqrt(verrtot / (sunrealtype)nsts); + werrtot = SUNRsqrt(werrtot / (sunrealtype)nsts); + errtot = SUNRsqrt(errtot / SUN_RCONST(3.0) / (sunrealtype)nsts); std::cout << "\nFinal Solver Statistics:\n"; std::cout << " Slow steps = " << nsts << " (attempts = " << natts << ", fails = " << netfs << ", innerfails = " << nifs << ")\n"; @@ -1484,53 +1487,54 @@ static int Jsi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, static sunrealtype p(sunrealtype t, const Options& opts) { - return HALF * cos(t); + return HALF * SUNRcos(t); } static sunrealtype q(sunrealtype t, const Options& opts) { - return (cos(opts.om * t * (ONE + exp(-(t - TWO) * (t - TWO))))); + return (SUNRcos(opts.om * t * (ONE + SUNRexp(-(t - TWO) * (t - TWO))))); } static sunrealtype r(sunrealtype t, const Options& opts) { - return (cos(opts.om * opts.om * t * (ONE + exp(-(t - THREE) * (t - THREE))))); + return (SUNRcos(opts.om * opts.om * t * + (ONE + SUNRexp(-(t - THREE) * (t - THREE))))); } static sunrealtype pdot(sunrealtype t, const Options& opts) { - return -HALF * sin(t); + return -HALF * SUNRsin(t); } static sunrealtype qdot(sunrealtype t, const Options& opts) { const sunrealtype tTwo = t - TWO; - const sunrealtype eterm = exp(-tTwo * tTwo); - return (-sin(opts.om * t * (ONE + eterm)) * opts.om * + const sunrealtype eterm = SUNRexp(-tTwo * tTwo); + return (-SUNRsin(opts.om * t * (ONE + eterm)) * opts.om * (ONE + eterm * (ONE - TWO * t * tTwo))); } static sunrealtype rdot(sunrealtype t, const Options& opts) { const sunrealtype tThree = t - THREE; - const sunrealtype eterm = exp(-tThree * tThree); - return (-sin(opts.om * opts.om * t * (ONE + eterm)) * opts.om * opts.om * + const sunrealtype eterm = SUNRexp(-tThree * tThree); + return (-SUNRsin(opts.om * opts.om * t * (ONE + eterm)) * opts.om * opts.om * (ONE + eterm * (ONE - TWO * t * tThree))); } static sunrealtype utrue(sunrealtype t, const Options& opts) { - return (std::sqrt(TWO + p(t, opts))); + return (SUNRsqrt(TWO + p(t, opts))); } static sunrealtype vtrue(sunrealtype t, const Options& opts) { - return (std::sqrt(TWO + q(t, opts))); + return (SUNRsqrt(TWO + q(t, opts))); } static sunrealtype wtrue(sunrealtype t, const Options& opts) { - return (std::sqrt(TWO + r(t, opts))); + return (SUNRsqrt(TWO + r(t, opts))); } static int Ytrue(sunrealtype t, N_Vector y, const Options& opts) @@ -1738,13 +1742,13 @@ static void PrintSlowAdaptivity(Options opts) << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; - if (!std::isnan(opts.k1s)) + if (!SUNRisnan(opts.k1s)) { std::cout << " slow/intermediate controller parameter: " << opts.k1s << "\n"; } - if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || - std::isnan(opts.htol_maxfac))) + if (!(SUNRisnan(opts.htol_relch) || SUNRisnan(opts.htol_minfac) || + SUNRisnan(opts.htol_maxfac))) { std::cout << " HTol controller parameters: " << opts.htol_relch << " " << opts.htol_minfac << " " << opts.htol_maxfac << "\n"; @@ -1758,13 +1762,13 @@ static void PrintSlowAdaptivity(Options opts) << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; - if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) + if (!(SUNRisnan(opts.k1s) || SUNRisnan(opts.k2s))) { std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " << opts.k2s << "\n"; } - if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || - std::isnan(opts.htol_maxfac))) + if (!(SUNRisnan(opts.htol_relch) || SUNRisnan(opts.htol_minfac) || + SUNRisnan(opts.htol_maxfac))) { std::cout << " HTol controller parameters: " << opts.htol_relch << " " << opts.htol_minfac << " " << opts.htol_maxfac << "\n"; @@ -1778,13 +1782,13 @@ static void PrintSlowAdaptivity(Options opts) << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; - if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s) || std::isnan(opts.k3s))) + if (!(SUNRisnan(opts.k1s) || SUNRisnan(opts.k2s) || SUNRisnan(opts.k3s))) { std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " << opts.k2s << " " << opts.k3s << "\n"; } - if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || - std::isnan(opts.htol_maxfac))) + if (!(SUNRisnan(opts.htol_relch) || SUNRisnan(opts.htol_minfac) || + SUNRisnan(opts.htol_maxfac))) { std::cout << " HTol controller parameters: " << opts.htol_relch << " " << opts.htol_minfac << " " << opts.htol_maxfac << "\n"; @@ -1798,13 +1802,13 @@ static void PrintSlowAdaptivity(Options opts) << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; - if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) + if (!(SUNRisnan(opts.k1s) || SUNRisnan(opts.k2s))) { std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " << opts.k2s << "\n"; } - if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || - std::isnan(opts.htol_maxfac))) + if (!(SUNRisnan(opts.htol_relch) || SUNRisnan(opts.htol_minfac) || + SUNRisnan(opts.htol_maxfac))) { std::cout << " HTol controller parameters: " << opts.htol_relch << " " << opts.htol_minfac << " " << opts.htol_maxfac << "\n"; @@ -1818,13 +1822,13 @@ static void PrintSlowAdaptivity(Options opts) << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; - if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) + if (!(SUNRisnan(opts.k1s) || SUNRisnan(opts.k2s))) { std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " << opts.k2s << "\n"; } - if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || - std::isnan(opts.htol_maxfac))) + if (!(SUNRisnan(opts.htol_relch) || SUNRisnan(opts.htol_minfac) || + SUNRisnan(opts.htol_maxfac))) { std::cout << " HTol controller parameters: " << opts.htol_relch << " " << opts.htol_minfac << " " << opts.htol_maxfac << "\n"; @@ -1846,7 +1850,7 @@ static void PrintSlowAdaptivity(Options opts) "order of MRI " << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; - if (!std::isnan(opts.k1s)) + if (!SUNRisnan(opts.k1s)) { std::cout << " slow/intermediate controller parameter: " << opts.k1s << "\n"; @@ -1859,7 +1863,7 @@ static void PrintSlowAdaptivity(Options opts) "order of MRI " << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; - if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) + if (!(SUNRisnan(opts.k1s) || SUNRisnan(opts.k2s))) { std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " << opts.k2s << "\n"; @@ -1872,7 +1876,7 @@ static void PrintSlowAdaptivity(Options opts) "order of MRI " << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; - if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s) || std::isnan(opts.k3s))) + if (!(SUNRisnan(opts.k1s) || SUNRisnan(opts.k2s) || SUNRisnan(opts.k3s))) { std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " << opts.k2s << " " << opts.k3s << "\n"; @@ -1885,7 +1889,7 @@ static void PrintSlowAdaptivity(Options opts) "on order of MRI " << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; - if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) + if (!(SUNRisnan(opts.k1s) || SUNRisnan(opts.k2s))) { std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " << opts.k2s << "\n"; @@ -1898,7 +1902,7 @@ static void PrintSlowAdaptivity(Options opts) "on order of MRI " << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; - if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) + if (!(SUNRisnan(opts.k1s) || SUNRisnan(opts.k2s))) { std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " << opts.k2s << "\n"; @@ -1914,11 +1918,11 @@ static void PrintSlowAdaptivity(Options opts) break; } } - if (!std::isnan(opts.bias)) + if (!SUNRisnan(opts.bias)) { std::cout << " controller bias factor: " << opts.bias << "\n"; } - if (!std::isnan(opts.slow_safety)) + if (!SUNRisnan(opts.slow_safety)) { std::cout << " slow step safety factor: " << opts.slow_safety << "\n"; } @@ -1941,7 +1945,7 @@ static void PrintFastAdaptivity(Options opts) << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); std::cout << " fast_rtol = " << opts.fast_rtol << ", atol = " << opts.atol << "\n"; - if (!std::isnan(opts.k1f)) + if (!SUNRisnan(opts.k1f)) { std::cout << " fast controller parameter: " << opts.k1f << "\n"; } @@ -1953,7 +1957,7 @@ static void PrintFastAdaptivity(Options opts) << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); std::cout << " fast_rtol = " << opts.fast_rtol << ", atol = " << opts.atol << "\n"; - if (!(std::isnan(opts.k1f) || std::isnan(opts.k2f))) + if (!(SUNRisnan(opts.k1f) || SUNRisnan(opts.k2f))) { std::cout << " fast controller parameters: " << opts.k1f << " " << opts.k2f << "\n"; @@ -1966,7 +1970,7 @@ static void PrintFastAdaptivity(Options opts) << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); std::cout << " fast_rtol = " << opts.fast_rtol << ", atol = " << opts.atol << "\n"; - if (!(std::isnan(opts.k1f) || std::isnan(opts.k2f) || std::isnan(opts.k3f))) + if (!(SUNRisnan(opts.k1f) || SUNRisnan(opts.k2f) || SUNRisnan(opts.k3f))) { std::cout << " fast controller parameters: " << opts.k1f << " " << opts.k2f << " " << opts.k3f << "\n"; @@ -1980,7 +1984,7 @@ static void PrintFastAdaptivity(Options opts) << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); std::cout << " fast_rtol = " << opts.fast_rtol << ", atol = " << opts.atol << "\n"; - if (!(std::isnan(opts.k1f) || std::isnan(opts.k2f))) + if (!(SUNRisnan(opts.k1f) || SUNRisnan(opts.k2f))) { std::cout << " fast controller parameters: " << opts.k1f << " " << opts.k2f << "\n"; @@ -1994,7 +1998,7 @@ static void PrintFastAdaptivity(Options opts) << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); std::cout << " fast_rtol = " << opts.fast_rtol << ", atol = " << opts.atol << "\n"; - if (!(std::isnan(opts.k1f) || std::isnan(opts.k2f))) + if (!(SUNRisnan(opts.k1f) || SUNRisnan(opts.k2f))) { std::cout << " fast controller parameters: " << opts.k1f << " " << opts.k2f << "\n"; diff --git a/examples/arkode/CXX_serial/ark_pendulum.cpp b/examples/arkode/CXX_serial/ark_pendulum.cpp index 0af2e81bbf..ac1151a376 100644 --- a/examples/arkode/CXX_serial/ark_pendulum.cpp +++ b/examples/arkode/CXX_serial/ark_pendulum.cpp @@ -178,7 +178,7 @@ int main(int argc, char* argv[]) ARKodeButcherTable B = ARKodeButcherTable_Alloc(2, SUNFALSE); const sunrealtype gamma = - ((SUN_RCONST(3.0) + std::sqrt(SUN_RCONST(3.0))) / SUN_RCONST(6.0)); + ((SUN_RCONST(3.0) + SUNRsqrt(SUN_RCONST(3.0))) / SUN_RCONST(6.0)); B->A[0][0] = gamma; B->A[1][0] = SUN_RCONST(1.0) - SUN_RCONST(2.0) * gamma; @@ -228,12 +228,12 @@ int main(int argc, char* argv[]) // Output the initial condition and energy int swidth = 8; - int rwidth = std::numeric_limits::digits10 + 8; + int rwidth = SUN_DIGITS10 + 8; std::ofstream outfile("ark_pendulum.txt"); outfile << "# vars: t u v energy energy_err\n"; outfile << std::scientific; - outfile << std::setprecision(std::numeric_limits::digits10); + outfile << std::setprecision(SUN_DIGITS10); outfile << t << " " << ydata[0] << " " << ydata[1] << " " << eng0 << " " << SUN_RCONST(0.0) << std::endl; @@ -245,7 +245,7 @@ int main(int argc, char* argv[]) std::cout << std::endl; std::cout << std::scientific; - std::cout << std::setprecision(std::numeric_limits::digits10); + std::cout << std::setprecision(SUN_DIGITS10); std::cout << std::setw(swidth) << 0 << std::setw(rwidth) << t << std::setw(rwidth) << ydata[0] << std::setw(rwidth) << ydata[1] << std::setw(rwidth) << eng0 << std::setw(rwidth) << SUN_RCONST(0.0); @@ -398,7 +398,7 @@ int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) sunrealtype* ydata = N_VGetArrayPointer(y); sunrealtype* fdata = N_VGetArrayPointer(ydot); - fdata[0] = -std::sin(ydata[1]); + fdata[0] = -SUNRsin(ydata[1]); fdata[1] = ydata[0]; return 0; @@ -416,7 +416,7 @@ int Jac(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, Jdata[1] = SUN_RCONST(1.0); // column 1 - Jdata[2] = -std::cos(ydata[1]); + Jdata[2] = -SUNRcos(ydata[1]); Jdata[3] = SUN_RCONST(0.0); return 0; @@ -427,7 +427,7 @@ int Eng(N_Vector y, sunrealtype* e, void* user_data) { sunrealtype* ydata = N_VGetArrayPointer(y); - *e = SUN_RCONST(0.5) * ydata[0] * ydata[0] - std::cos(ydata[1]); + *e = SUN_RCONST(0.5) * ydata[0] * ydata[0] - SUNRcos(ydata[1]); return 0; } @@ -439,7 +439,7 @@ int JacEng(N_Vector y, N_Vector J, void* user_data) sunrealtype* jdata = N_VGetArrayPointer(J); jdata[0] = ydata[0]; - jdata[1] = std::sin(ydata[1]); + jdata[1] = SUNRsin(ydata[1]); return 0; } diff --git a/examples/arkode/CXX_xbraid/ark_heat2D_hypre_pfmg_xbraid.cpp b/examples/arkode/CXX_xbraid/ark_heat2D_hypre_pfmg_xbraid.cpp index d82229f6f6..8bc09a23a5 100644 --- a/examples/arkode/CXX_xbraid/ark_heat2D_hypre_pfmg_xbraid.cpp +++ b/examples/arkode/CXX_xbraid/ark_heat2D_hypre_pfmg_xbraid.cpp @@ -1049,7 +1049,7 @@ int MyAccess(braid_App app, braid_Vector u, braid_AccessStatus astatus) udata->uout.open(fname.str()); udata->uout << scientific; - udata->uout << setprecision(numeric_limits::digits10); + udata->uout << setprecision(SUN_DIGITS10); fname.str(""); fname.clear(); @@ -1058,7 +1058,7 @@ int MyAccess(braid_App app, braid_Vector u, braid_AccessStatus astatus) udata->eout.open(fname.str()); udata->eout << scientific; - udata->eout << setprecision(numeric_limits::digits10); + udata->eout << setprecision(SUN_DIGITS10); // Compute the error flag = SolutionError(t, y, udata->e, udata); @@ -1104,7 +1104,7 @@ int MyAccess(braid_App app, braid_Vector u, braid_AccessStatus astatus) if (udata->myid_c == 0) { cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << " Max error = " << maxerr << endl << endl; } } diff --git a/examples/arkode/CXX_xbraid/ark_heat2D_p_xbraid.cpp b/examples/arkode/CXX_xbraid/ark_heat2D_p_xbraid.cpp index 2e22855e98..71b25ab844 100644 --- a/examples/arkode/CXX_xbraid/ark_heat2D_p_xbraid.cpp +++ b/examples/arkode/CXX_xbraid/ark_heat2D_p_xbraid.cpp @@ -982,7 +982,7 @@ int MyAccess(braid_App app, braid_Vector u, braid_AccessStatus astatus) udata->uout.open(fname.str()); udata->uout << scientific; - udata->uout << setprecision(numeric_limits::digits10); + udata->uout << setprecision(SUN_DIGITS10); fname.str(""); fname.clear(); @@ -991,7 +991,7 @@ int MyAccess(braid_App app, braid_Vector u, braid_AccessStatus astatus) udata->eout.open(fname.str()); udata->eout << scientific; - udata->eout << setprecision(numeric_limits::digits10); + udata->eout << setprecision(SUN_DIGITS10); // Compute the error flag = SolutionError(t, y, udata->e, udata); @@ -1037,7 +1037,7 @@ int MyAccess(braid_App app, braid_Vector u, braid_AccessStatus astatus) if (udata->myid_c == 0) { cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << " Max error = " << maxerr << endl << endl; } } diff --git a/examples/arkode/CXX_xbraid/ark_heat2D_xbraid.cpp b/examples/arkode/CXX_xbraid/ark_heat2D_xbraid.cpp index 325a89e5bb..72ae4e74f1 100644 --- a/examples/arkode/CXX_xbraid/ark_heat2D_xbraid.cpp +++ b/examples/arkode/CXX_xbraid/ark_heat2D_xbraid.cpp @@ -703,7 +703,7 @@ int MyAccess(braid_App app, braid_Vector u, braid_AccessStatus astatus) udata->uout.open(fname.str()); udata->uout << scientific; - udata->uout << setprecision(numeric_limits::digits10); + udata->uout << setprecision(SUN_DIGITS10); fname.str(""); fname.clear(); @@ -712,7 +712,7 @@ int MyAccess(braid_App app, braid_Vector u, braid_AccessStatus astatus) udata->eout.open(fname.str()); udata->eout << scientific; - udata->eout << setprecision(numeric_limits::digits10); + udata->eout << setprecision(SUN_DIGITS10); // Compute the error flag = SolutionError(t, y, udata->e, udata); @@ -756,7 +756,7 @@ int MyAccess(braid_App app, braid_Vector u, braid_AccessStatus astatus) sunrealtype maxerr = N_VMaxNorm(udata->e); cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << " Max error = " << maxerr << endl << endl; } } diff --git a/examples/arkode/C_manyvector/ark_brusselator1D_manyvec.c b/examples/arkode/C_manyvector/ark_brusselator1D_manyvec.c index bb72d8dc22..3b243a7ca0 100644 --- a/examples/arkode/C_manyvector/ark_brusselator1D_manyvec.c +++ b/examples/arkode/C_manyvector/ark_brusselator1D_manyvec.c @@ -63,7 +63,11 @@ #include /* defs. of sunrealtype, sunindextype, etc */ #include /* access to SPGMR SUNLinearSolver */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#define ESYM "Qe" +#define FSYM "Qf" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #define ESYM "Le" #define FSYM "Lf" diff --git a/examples/arkode/C_openmp/ark_brusselator1D_omp.c b/examples/arkode/C_openmp/ark_brusselator1D_omp.c index 99a45e21f7..9511fed564 100644 --- a/examples/arkode/C_openmp/ark_brusselator1D_omp.c +++ b/examples/arkode/C_openmp/ark_brusselator1D_omp.c @@ -60,8 +60,11 @@ #ifdef _OPENMP #include /* OpenMP functions */ #endif - -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#define ESYM "Qe" +#define FSYM "Qf" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #define ESYM "Le" #define FSYM "Lf" @@ -110,15 +113,15 @@ int main(int argc, char* argv[]) int Nvar = 3; /* number of solution fields */ UserData udata = NULL; sunrealtype* data; - sunindextype N = 201; /* spatial mesh size */ - sunrealtype a = 0.6; /* problem parameters */ - sunrealtype b = 2.0; - sunrealtype du = 0.025; - sunrealtype dv = 0.025; - sunrealtype dw = 0.025; - sunrealtype ep = 1.0e-5; /* stiffness parameter */ - sunrealtype reltol = 1.0e-6; /* tolerances */ - sunrealtype abstol = 1.0e-10; + sunindextype N = 201; /* spatial mesh size */ + sunrealtype a = SUN_RCONST(0.6); /* problem parameters */ + sunrealtype b = SUN_RCONST(2.0); + sunrealtype du = SUN_RCONST(0.025); + sunrealtype dv = SUN_RCONST(0.025); + sunrealtype dw = SUN_RCONST(0.025); + sunrealtype ep = SUN_RCONST(1.0e-5); /* stiffness parameter */ + sunrealtype reltol = SUN_RCONST(1.0e-6); /* tolerances */ + sunrealtype abstol = SUN_RCONST(1.0e-10); sunindextype NEQ, i; /* general problem variables */ @@ -204,9 +207,9 @@ int main(int argc, char* argv[]) pi = SUN_RCONST(4.0) * atan(SUN_RCONST(1.0)); for (i = 0; i < N; i++) { - data[IDX(i, 0)] = a + SUN_RCONST(0.1) * sin(pi * i * udata->dx); /* u */ - data[IDX(i, 1)] = b / a + SUN_RCONST(0.1) * sin(pi * i * udata->dx); /* v */ - data[IDX(i, 2)] = b + SUN_RCONST(0.1) * sin(pi * i * udata->dx); /* w */ + data[IDX(i, 0)] = a + SUN_RCONST(0.1) * SUNRsin(pi * i * udata->dx); /* u */ + data[IDX(i, 1)] = b / a + SUN_RCONST(0.1) * SUNRsin(pi * i * udata->dx); /* v */ + data[IDX(i, 2)] = b + SUN_RCONST(0.1) * SUNRsin(pi * i * udata->dx); /* w */ } /* Set mask array values for each solution component */ @@ -290,11 +293,11 @@ int main(int argc, char* argv[]) flag = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ if (check_flag(&flag, "ARKodeEvolve", 1)) { break; } u = N_VWL2Norm(y, umask); /* access/print solution statistics */ - u = sqrt(u * u / N); + u = SUNRsqrt(u * u / N); v = N_VWL2Norm(y, vmask); - v = sqrt(v * v / N); + v = SUNRsqrt(v * v / N); w = N_VWL2Norm(y, wmask); - w = sqrt(w * w / N); + w = SUNRsqrt(w * w / N); printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %10.6" FSYM "\n", t, u, v, w); if (flag >= 0) @@ -431,8 +434,9 @@ static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) } /* enforce stationary boundaries */ - dYdata[IDX(0, 0)] = dYdata[IDX(0, 1)] = dYdata[IDX(0, 2)] = 0.0; - dYdata[IDX(N - 1, 0)] = dYdata[IDX(N - 1, 1)] = dYdata[IDX(N - 1, 2)] = 0.0; + dYdata[IDX(0, 0)] = dYdata[IDX(0, 1)] = dYdata[IDX(0, 2)] = SUN_RCONST(0.0); + dYdata[IDX(N - 1, 0)] = dYdata[IDX(N - 1, 1)] = dYdata[IDX(N - 1, 2)] = + SUN_RCONST(0.0); return 0; } diff --git a/examples/arkode/C_openmp/ark_heat1D_omp.c b/examples/arkode/C_openmp/ark_heat1D_omp.c index 919365bb10..f7509619dc 100644 --- a/examples/arkode/C_openmp/ark_heat1D_omp.c +++ b/examples/arkode/C_openmp/ark_heat1D_omp.c @@ -54,7 +54,11 @@ #include /* OpenMP function defs. */ #endif -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#define ESYM "Qe" +#define FSYM "Qf" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #define ESYM "Le" #define FSYM "Lf" @@ -85,15 +89,15 @@ static int check_flag(void* flagvalue, const char* funcname, int opt); int main(int argc, char* argv[]) { /* general problem parameters */ - sunrealtype T0 = SUN_RCONST(0.0); /* initial time */ - sunrealtype Tf = SUN_RCONST(1.0); /* final time */ - int Nt = 10; /* total number of output times */ - sunrealtype rtol = 1.e-4; /* relative tolerance */ - sunrealtype atol = 1.e-6; /* absolute tolerance */ + sunrealtype T0 = SUN_RCONST(0.0); /* initial time */ + sunrealtype Tf = SUN_RCONST(1.0); /* final time */ + int Nt = 10; /* total number of output times */ + sunrealtype rtol = SUN_RCONST(1.e-4); /* relative tolerance */ + sunrealtype atol = SUN_RCONST(1.e-6); /* absolute tolerance */ UserData udata = NULL; sunrealtype* data; - sunindextype N = 201; /* spatial mesh size */ - sunrealtype k = 0.5; /* heat conductivity */ + sunindextype N = 201; /* spatial mesh size */ + sunrealtype k = SUN_RCONST(0.5); /* heat conductivity */ sunindextype i; /* general problem variables */ @@ -188,13 +192,13 @@ int main(int argc, char* argv[]) tout = T0 + dTout; printf(" t ||u||_rms\n"); printf(" -------------------------\n"); - printf(" %10.6" FSYM " %10.6f\n", t, sqrt(N_VDotProd(y, y) / N)); + printf(" %10.6" FSYM " %10.6" FSYM "\n", t, SUNRsqrt(N_VDotProd(y, y) / N)); for (iout = 0; iout < Nt; iout++) { flag = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ if (check_flag(&flag, "ARKodeEvolve", 1)) { break; } - printf(" %10.6" FSYM " %10.6f\n", t, - sqrt(N_VDotProd(y, y) / N)); /* print solution stats */ + printf(" %10.6" FSYM " %10.6" FSYM "\n", t, + SUNRsqrt(N_VDotProd(y, y) / N)); /* print solution stats */ if (flag >= 0) { /* successful solve: update output time */ tout += dTout; @@ -285,15 +289,15 @@ static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) c1 = k / dx / dx; c2 = -SUN_RCONST(2.0) * k / dx / dx; isource = N / 2; - Ydot[0] = 0.0; /* left boundary condition */ + Ydot[0] = SUN_RCONST(0.0); /* left boundary condition */ #pragma omp parallel for default(shared) private(i) schedule(static) \ num_threads(udata->nthreads) for (i = 1; i < N - 1; i++) { Ydot[i] = c1 * Y[i - 1] + c2 * Y[i] + c1 * Y[i + 1]; } - Ydot[N - 1] = 0.0; /* right boundary condition */ - Ydot[isource] += 0.01 / dx; /* source term */ + Ydot[N - 1] = SUN_RCONST(0.0); /* right boundary condition */ + Ydot[isource] += SUN_RCONST(0.01) / dx; /* source term */ return 0; /* Return with success */ } @@ -319,14 +323,14 @@ static int Jac(N_Vector v, N_Vector Jv, sunrealtype t, N_Vector y, N_Vector fy, /* iterate over domain, computing all Jacobian-vector products */ c1 = k / dx / dx; c2 = -SUN_RCONST(2.0) * k / dx / dx; - JV[0] = 0.0; + JV[0] = SUN_RCONST(0.0); #pragma omp parallel for default(shared) private(i) schedule(static) \ num_threads(udata->nthreads) for (i = 1; i < N - 1; i++) { JV[i] = c1 * V[i - 1] + c2 * V[i] + c1 * V[i + 1]; } - JV[N - 1] = 0.0; + JV[N - 1] = SUN_RCONST(0.0); return 0; /* Return with success */ } diff --git a/examples/arkode/C_openmpdev/CMakeLists.txt b/examples/arkode/C_openmpdev/CMakeLists.txt index e9952d4ea7..3273a7c226 100644 --- a/examples/arkode/C_openmpdev/CMakeLists.txt +++ b/examples/arkode/C_openmpdev/CMakeLists.txt @@ -30,7 +30,7 @@ set(ARKODE_LIB sundials_arkode) set(NVECOMP_LIB sundials_nvecopenmpdev) # Set-up linker flags and link libraries -set(SUNDIALS_LIBS ${ARKODE_LIB} ${NVECOMP_LIB} ${EXE_EXTRA_LINK_LIBS}) +set(SUNDIALS_LIBS ${ARKODE_LIB} ${NVECOMPDEV_LIB} ${EXE_EXTRA_LINK_LIBS}) # Add the build and install targets for each ARKODE example foreach(example_tuple ${ARKODE_examples}) @@ -54,7 +54,8 @@ foreach(example_tuple ${ARKODE_examples}) EXAMPLE_TYPE ${example_type}) # libraries to link against - target_link_libraries(${example} ${SUNDIALS_LIBS}) + target_link_libraries(${example} sundials_arkode sundials_nvecopenmpdev + ${EXE_EXTRA_LINK_LIBS}) # install example source and out files if(SUNDIALS_ENABLE_EXAMPLES_INSTALL) diff --git a/examples/arkode/C_openmpdev/ark_analytic_nonlin_ompdev.c b/examples/arkode/C_openmpdev/ark_analytic_nonlin_ompdev.c index d58980128f..9deb39e2fb 100644 --- a/examples/arkode/C_openmpdev/ark_analytic_nonlin_ompdev.c +++ b/examples/arkode/C_openmpdev/ark_analytic_nonlin_ompdev.c @@ -43,7 +43,10 @@ #include /* OpenMP functions */ #endif -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define ESYM "Qe" +#define FSYM "Qf" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define ESYM "Le" #define FSYM "Lf" #else diff --git a/examples/arkode/C_openmpdev/ark_heat1D_ompdev.c b/examples/arkode/C_openmpdev/ark_heat1D_ompdev.c index f924f4dbe2..2b5e841a08 100644 --- a/examples/arkode/C_openmpdev/ark_heat1D_ompdev.c +++ b/examples/arkode/C_openmpdev/ark_heat1D_ompdev.c @@ -55,7 +55,11 @@ #include /* OpenMP functions */ #endif -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#define ESYM "Qe" +#define FSYM "Qf" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #define ESYM "Le" #define FSYM "Lf" diff --git a/examples/arkode/C_parallel/CMakeLists.txt b/examples/arkode/C_parallel/CMakeLists.txt index ad2c7f842a..6261f665a3 100644 --- a/examples/arkode/C_parallel/CMakeLists.txt +++ b/examples/arkode/C_parallel/CMakeLists.txt @@ -24,23 +24,19 @@ set(ARKODE_examples "ark_diurnal_kry_p\;\;1\;4\;exclude-single\;default" "ark_diurnal_kry_bbd_p\;\;1\;4\;exclude-single\;default") -if(SUNDIALS_PRECISION MATCHES "DOUBLE" AND SUNDIALS_INDEX_SIZE MATCHES "64") - - list(APPEND ARKODE_examples - "ark_brusselator1D_task_local_nls\;--monitor\;1\;4\;develop\;2") - list( - APPEND ARKODE_examples - "ark_brusselator1D_task_local_nls\;--monitor --global-nls\;1\;4\;develop\;2" - ) - list( - APPEND - ARKODE_examples - "ark_brusselator1D_task_local_nls\;--monitor --explicit --tf 3\;1\;4\;develop\;2" - ) - - # Auxiliary files to install - set(ARKODE_extras "plot_brusselator1D.py") -endif() +list(APPEND ARKODE_examples + "ark_brusselator1D_task_local_nls\;--monitor\;1\;4\;develop\;2") +list( + APPEND ARKODE_examples + "ark_brusselator1D_task_local_nls\;--monitor --global-nls\;1\;4\;develop\;2") +list( + APPEND + ARKODE_examples + "ark_brusselator1D_task_local_nls\;--monitor --explicit --tf 3\;1\;4\;develop\;2" +) + +# Auxiliary files to install +set(ARKODE_extras "plot_brusselator1D.py") if(MPI_C_COMPILER) set(CMAKE_C_COMPILER ${MPI_C_COMPILER}) diff --git a/examples/arkode/C_parallel/ark_brusselator1D_task_local_nls.c b/examples/arkode/C_parallel/ark_brusselator1D_task_local_nls.c index 4feb0685c7..92b8623716 100644 --- a/examples/arkode/C_parallel/ark_brusselator1D_task_local_nls.c +++ b/examples/arkode/C_parallel/ark_brusselator1D_task_local_nls.c @@ -79,6 +79,19 @@ #include "sunmatrix/sunmatrix_dense.h" /* dense SUNMatrix */ #include "sunnonlinsol/sunnonlinsol_newton.h" /* Newton SUNNonlinearSolver */ +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#define ESYM "Qe" +#define FSYM "Qf" +#elif defined(SUNDIALS_EXTENDED_PRECISION) +#define GSYM "Lg" +#define ESYM "Le" +#define FSYM "Lf" +#else +#define GSYM "g" +#define ESYM "e" +#define FSYM "f" +#endif /* Maximum size of output directory string */ #define MXSTR 2048 @@ -94,19 +107,19 @@ typedef struct { - double t0; /* initial time */ - double tf; /* final time */ - double rtol; /* relative tolerance */ - double atol; /* absolute tolerance */ - int order; /* method order */ - int explicit; /* imex method or explicit */ - int global; /* use global nonlinear solve */ - int fused; /* use fused vector ops */ - int nout; /* number of outputs */ - int monitor; /* print solution to screen */ - int printtime; /* print timing information */ - FILE* TFID; /* time output file pointer */ - FILE* UFID; /* solution output file pointer */ + sunrealtype t0; /* initial time */ + sunrealtype tf; /* final time */ + sunrealtype rtol; /* relative tolerance */ + sunrealtype atol; /* absolute tolerance */ + int order; /* method order */ + int explicit; /* imex method or explicit */ + int global; /* use global nonlinear solve */ + int fused; /* use fused vector ops */ + int nout; /* number of outputs */ + int monitor; /* print solution to screen */ + int printtime; /* print timing information */ + FILE* TFID; /* time output file pointer */ + FILE* UFID; /* solution output file pointer */ FILE* VFID; FILE* WFID; const char* outputdir; @@ -124,10 +137,10 @@ typedef struct int nprocs; MPI_Request reqS; MPI_Request reqR; - double* Wsend; - double* Esend; - double* Wrecv; - double* Erecv; + sunrealtype* Wsend; + sunrealtype* Esend; + sunrealtype* Wrecv; + sunrealtype* Erecv; /* data structures for per mesh node linear system */ N_Vector b_node; @@ -145,21 +158,21 @@ typedef struct N_Vector wmask; /* problem parameters */ - long long nvar; /* number of species */ - long long nx; /* number of intervals globally */ - long long nxl; /* number of intervals locally */ - long long NEQ; /* number of equations locally */ - double dx; /* mesh spacing */ - double xmax; /* maximum x value */ - double A; /* concentration of species A */ - double B; /* w source rate */ - double k1; /* reaction rates */ - double k2; - double k3; - double k4; - double k5; - double k6; - double c; /* advection coefficient */ + sunindextype nvar; /* number of species */ + sunindextype nx; /* number of intervals globally */ + sunindextype nxl; /* number of intervals locally */ + sunindextype NEQ; /* number of equations locally */ + sunrealtype dx; /* mesh spacing */ + sunrealtype xmax; /* maximum x value */ + sunrealtype A; /* concentration of species A */ + sunrealtype B; /* w source rate */ + sunrealtype k1; /* reaction rates */ + sunrealtype k2; + sunrealtype k3; + sunrealtype k4; + sunrealtype k5; + sunrealtype k6; + sunrealtype c; /* advection coefficient */ /* integrator options */ UserOptions uopt; @@ -189,19 +202,19 @@ static SUNNonlinearSolver TaskLocalNewton(SUNContext ctx, N_Vector y); * RHS functions provided to the integrator */ -static int Advection(double t, N_Vector y, N_Vector ydot, void* user_data); -static int Reaction(double t, N_Vector y, N_Vector ydot, void* user_data); -static int AdvectionReaction(double t, N_Vector y, N_Vector ydot, +static int Advection(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int Reaction(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int AdvectionReaction(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); /* * Preconditioner functions (used only when using the global nonlinear solver) */ -static int PSetup(double t, N_Vector y, N_Vector f, sunbooleantype jok, - sunbooleantype* jcurPtr, double gamma, void* user_data); -static int PSolve(double t, N_Vector y, N_Vector f, N_Vector r, N_Vector z, - double gamma, double delta, int lr, void* user_data); +static int PSetup(sunrealtype t, N_Vector y, N_Vector f, sunbooleantype jok, + sunbooleantype* jcurPtr, sunrealtype gamma, void* user_data); +static int PSolve(sunrealtype t, N_Vector y, N_Vector f, N_Vector r, N_Vector z, + sunrealtype gamma, sunrealtype delta, int lr, void* user_data); /* * Helper functions @@ -229,7 +242,8 @@ static int SetupProblem(int argc, char* argv[], UserData udata, static void InputError(char* name); /* function to write solution to disk */ -static int WriteOutput(double t, N_Vector y, UserData udata, UserOptions uopt); +static int WriteOutput(sunrealtype t, N_Vector y, UserData udata, + UserOptions uopt); /* function to free the problem data */ static void FreeProblem(UserData udata, UserOptions uopt); @@ -245,7 +259,7 @@ int main(int argc, char* argv[]) UserData udata; /* user data */ UserOptions uopt; /* user options */ int retval; /* reusable error-checking flag */ - long long i; /* loop counter */ + sunindextype i; /* loop counter */ FILE* MFID; /* mesh output file pointer */ char fname[MXSTR]; MPI_Comm comm; @@ -323,7 +337,7 @@ int main(int argc, char* argv[]) MFID = fopen(fname, "w"); for (i = 0; i < udata->nx + 1; i++) { - fprintf(MFID, " %.16e\n", udata->dx * i); + fprintf(MFID, " %.16" ESYM "\n", udata->dx * i); } fclose(MFID); } @@ -362,13 +376,13 @@ static int EvolveProblemIMEX(N_Vector y, UserData udata, UserOptions uopt, SUNNonlinearSolver NLS = NULL; /* empty nonlinear solver structure */ SUNLinearSolver LS = NULL; /* empty linear solver structure */ - double t, dtout, tout; /* current/output time data */ - int retval; /* reusable error-checking flag */ - int iout; /* output counter */ - long int nst, nst_a, netf; /* step stats */ - long int nfe, nfi; /* RHS stats */ - long int nni, ncnf; /* nonlinear solver stats */ - long int nli, npre, npsol; /* linear solver stats */ + sunrealtype t, dtout, tout; /* current/output time data */ + int retval; /* reusable error-checking flag */ + int iout; /* output counter */ + long int nst, nst_a, netf; /* step stats */ + long int nfe, nfi; /* RHS stats */ + long int nni, ncnf; /* nonlinear solver stats */ + long int nli, npre, npsol; /* linear solver stats */ /* Create the ARK timestepper module */ arkode_mem = ARKStepCreate(Advection, Reaction, uopt->t0, y, ctx); @@ -512,12 +526,12 @@ static int EvolveProblemIMEX(N_Vector y, UserData udata, UserOptions uopt, static int EvolveProblemExplicit(N_Vector y, UserData udata, UserOptions uopt, SUNContext ctx) { - void* arkode_mem = NULL; /* empty ARKODE memory structure */ - double t, dtout, tout; /* current/output time data */ - int retval; /* reusable error-checking flag */ - int iout; /* output counter */ - long int nst, nst_a, netf; /* step stats */ - long int nfe; /* RHS stats */ + void* arkode_mem = NULL; /* empty ARKODE memory structure */ + sunrealtype t, dtout, tout; /* current/output time data */ + int retval; /* reusable error-checking flag */ + int iout; /* output counter */ + long int nst, nst_a, netf; /* step stats */ + long int nfe; /* RHS stats */ /* Create the ERK timestepper module */ arkode_mem = ERKStepCreate(AdvectionReaction, uopt->t0, y, ctx); @@ -597,25 +611,27 @@ static int EvolveProblemExplicit(N_Vector y, UserData udata, UserOptions uopt, } /* Write time and solution to disk */ -static int WriteOutput(double t, N_Vector y, UserData udata, UserOptions uopt) +static int WriteOutput(sunrealtype t, N_Vector y, UserData udata, UserOptions uopt) { - long long i; - long long nvar = udata->nvar; - double u, v, w; - double* data = NULL; + sunindextype i; + sunindextype nvar = udata->nvar; + sunrealtype u, v, w; + sunrealtype* data = NULL; /* output current solution norm to screen */ if (uopt->monitor) { u = N_VWL2Norm(y, udata->umask); - u = sqrt(u * u / udata->nx); + u = SUNRsqrt(u * u / udata->nx); v = N_VWL2Norm(y, udata->vmask); - v = sqrt(v * v / udata->nx); + v = SUNRsqrt(v * v / udata->nx); w = N_VWL2Norm(y, udata->wmask); - w = sqrt(w * w / udata->nx); + w = SUNRsqrt(w * w / udata->nx); if (udata->myid == 0) { - printf(" %10.6f %10.6f %10.6f %10.6f\n", t, u, v, w); + printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %10.6" FSYM + "\n", + t, u, v, w); } } @@ -629,22 +645,25 @@ static int WriteOutput(double t, N_Vector y, UserData udata, UserOptions uopt) if (check_retval((void*)data, "N_VGetArrayPointer", 0)) { return 1; } /* output the times to disk */ - if (udata->myid == 0 && uopt->TFID) { fprintf(uopt->TFID, " %.16e\n", t); } + if (udata->myid == 0 && uopt->TFID) + { + fprintf(uopt->TFID, " %.16" ESYM "\n", t); + } /* output results to disk */ for (i = 0; i < udata->nxl; i++) { - fprintf(uopt->UFID, " %.16e", data[IDX(nvar, i, 0)]); - fprintf(uopt->VFID, " %.16e", data[IDX(nvar, i, 1)]); - fprintf(uopt->WFID, " %.16e", data[IDX(nvar, i, 2)]); + fprintf(uopt->UFID, " %.16" ESYM, data[IDX(nvar, i, 0)]); + fprintf(uopt->VFID, " %.16" ESYM, data[IDX(nvar, i, 1)]); + fprintf(uopt->WFID, " %.16" ESYM, data[IDX(nvar, i, 2)]); } /* we have one extra output because of the periodic BCs */ if (udata->myid == (udata->nprocs - 1)) { - fprintf(uopt->UFID, " %.16e\n", udata->Erecv[IDX(nvar, 0, 0)]); - fprintf(uopt->VFID, " %.16e\n", udata->Erecv[IDX(nvar, 0, 1)]); - fprintf(uopt->WFID, " %.16e\n", udata->Erecv[IDX(nvar, 0, 2)]); + fprintf(uopt->UFID, " %.16" ESYM "\n", udata->Erecv[IDX(nvar, 0, 0)]); + fprintf(uopt->VFID, " %.16" ESYM "\n", udata->Erecv[IDX(nvar, 0, 1)]); + fprintf(uopt->WFID, " %.16" ESYM "\n", udata->Erecv[IDX(nvar, 0, 2)]); } else { @@ -661,26 +680,26 @@ static int WriteOutput(double t, N_Vector y, UserData udata, UserOptions uopt) static int SetIC(N_Vector y, UserData udata) { /* Variable shortcuts */ - long long nvar = udata->nvar; - long long N = udata->nxl; - double dx = udata->dx; - double A = udata->A; - double B = udata->B; - double k1 = udata->k1; - double k2 = udata->k2; - double k3 = udata->k3; - double k4 = udata->k4; - int myid = udata->myid; + sunindextype nvar = udata->nvar; + sunindextype N = udata->nxl; + sunrealtype dx = udata->dx; + sunrealtype A = udata->A; + sunrealtype B = udata->B; + sunrealtype k1 = udata->k1; + sunrealtype k2 = udata->k2; + sunrealtype k3 = udata->k3; + sunrealtype k4 = udata->k4; + int myid = udata->myid; /* Local variables */ - double* data = NULL; - double x, us, vs, ws, p; - long long i; + sunrealtype* data = NULL; + sunrealtype x, us, vs, ws, p; + sunindextype i; /* Gaussian distribution defaults */ - double mu = udata->xmax / 2.0; - double sigma = udata->xmax / 4.0; - double alpha = 0.1; + sunrealtype mu = udata->xmax / SUN_RCONST(2.0); + sunrealtype sigma = udata->xmax / SUN_RCONST(4.0); + sunrealtype alpha = SUN_RCONST(0.1); /* Access data array from NVector y */ data = N_VGetArrayPointer(y); @@ -688,13 +707,14 @@ static int SetIC(N_Vector y, UserData udata) /* Steady state solution */ us = k1 * A / k4; vs = k2 * k4 * B / (k1 * k3 * A); - ws = 3.0; + ws = SUN_RCONST(3.0); /* Gaussian perturbation of the steady state solution */ for (i = 0; i < N; i++) { x = (myid * N + i) * dx; - p = alpha * exp(-((x - mu) * (x - mu)) / (2.0 * sigma * sigma)); + p = alpha * + SUNRexp(-((x - mu) * (x - mu)) / (SUN_RCONST(2.0) * sigma * sigma)); data[IDX(nvar, i, 0)] = us + p; data[IDX(nvar, i, 1)] = vs + p; data[IDX(nvar, i, 2)] = ws + p; @@ -709,22 +729,22 @@ static int SetIC(N_Vector y, UserData udata) * --------------------------------------------------------------*/ /* Compute the advection term. */ -static int Advection(double t, N_Vector y, N_Vector ydot, void* user_data) +static int Advection(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { /* access problem data */ UserData udata = (UserData)user_data; /* set variable shortcuts */ - long long nvar = udata->nvar; - long long N = udata->nxl; - double dx = udata->dx; - double c = udata->c; + sunindextype nvar = udata->nvar; + sunindextype N = udata->nxl; + sunrealtype dx = udata->dx; + sunrealtype c = udata->c; /* local variables */ - double* Ydata = NULL; - double* dYdata = NULL; - double tmp; - long long i, var; + sunrealtype* Ydata = NULL; + sunrealtype* dYdata = NULL; + sunrealtype tmp; + sunindextype i, var; int retval; /* set output to zero */ @@ -756,7 +776,7 @@ static int Advection(double t, N_Vector y, N_Vector ydot, void* user_data) } } } - else if (c < 0.0) + else if (c < SUN_RCONST(0.0)) { /* left moving flow */ for (i = 0; i < N - 1; i++) @@ -774,7 +794,7 @@ static int Advection(double t, N_Vector y, N_Vector ydot, void* user_data) if (check_retval(&retval, "ExchangeAllEnd", 1)) { return (-1); } /* compute advection at local boundaries */ - if (c > 0.0) + if (c > SUN_RCONST(0.0)) { /* right moving flow (left boundary) */ for (var = 0; var < nvar; var++) @@ -783,7 +803,7 @@ static int Advection(double t, N_Vector y, N_Vector ydot, void* user_data) tmp * (Ydata[IDX(nvar, 0, var)] - udata->Wrecv[IDX(nvar, 0, var)]); } } - else if (c < 0.0) + else if (c < SUN_RCONST(0.0)) { /* left moving flow (right boundary) */ for (var = 0; var < nvar; var++) @@ -798,28 +818,28 @@ static int Advection(double t, N_Vector y, N_Vector ydot, void* user_data) } /* Compute the reaction term. */ -static int Reaction(double t, N_Vector y, N_Vector ydot, void* user_data) +static int Reaction(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { /* access problem data */ UserData udata = (UserData)user_data; /* set variable shortcuts */ - long long nvar = udata->nvar; - long long N = udata->nxl; - double A = udata->A; - double B = udata->B; - double k1 = udata->k1; - double k2 = udata->k2; - double k3 = udata->k3; - double k4 = udata->k4; - double k5 = udata->k5; - double k6 = udata->k6; + sunindextype nvar = udata->nvar; + sunindextype N = udata->nxl; + sunrealtype A = udata->A; + sunrealtype B = udata->B; + sunrealtype k1 = udata->k1; + sunrealtype k2 = udata->k2; + sunrealtype k3 = udata->k3; + sunrealtype k4 = udata->k4; + sunrealtype k5 = udata->k5; + sunrealtype k6 = udata->k6; /* local variables */ - double* Ydata = NULL; - double* dYdata = NULL; - double u, v, w; - long long i; + sunrealtype* Ydata = NULL; + sunrealtype* dYdata = NULL; + sunrealtype u, v, w; + sunindextype i; /* access data arrays */ Ydata = N_VGetArrayPointer(y); @@ -864,7 +884,8 @@ static int Reaction(double t, N_Vector y, N_Vector ydot, void* user_data) } /* Compute the RHS as Advection+Reaction. */ -static int AdvectionReaction(double t, N_Vector y, N_Vector ydot, void* user_data) +static int AdvectionReaction(sunrealtype t, N_Vector y, N_Vector ydot, + void* user_data) { int retval; @@ -890,12 +911,12 @@ static int TaskLocalNlsResidual(N_Vector ycor, N_Vector F, void* arkode_mem) /* temporary variables */ UserData udata; int retval; - double c[3]; + sunrealtype c[3]; N_Vector X[3]; /* nonlinear system data */ N_Vector z, zpred, Fi, sdata; - double tcur, gamma; + sunrealtype tcur, gamma; void* user_data; retval = ARKodeGetNonlinearSystemData(arkode_mem, &tcur, &zpred, &z, &Fi, @@ -920,8 +941,8 @@ static int TaskLocalNlsResidual(N_Vector ycor, N_Vector F, void* arkode_mem) /* update with y, sdata, and gamma * fy */ X[0] = ycor; - c[0] = 1.0; - c[1] = -1.0; + c[0] = SUN_RCONST(1.0); + c[1] = -SUN_RCONST(1.0); X[1] = N_VGetLocalVector_MPIPlusX(sdata); c[2] = -gamma; X[2] = N_VGetLocalVector_MPIPlusX(Fi); @@ -935,23 +956,23 @@ static int TaskLocalNlsResidual(N_Vector ycor, N_Vector F, void* arkode_mem) static int TaskLocalLSolve(N_Vector delta, void* arkode_mem) { /* local variables */ - UserData udata = NULL; - double* Zdata = NULL; - double* Bdata = NULL; - double u, v, w; - long long i, j; + UserData udata = NULL; + sunrealtype* Zdata = NULL; + sunrealtype* Bdata = NULL; + sunrealtype u, v, w; + sunindextype i, j; int retval; /* shortcuts */ - long long nvar, N; - double k2, k3, k4, k6; + sunindextype nvar, N; + sunrealtype k2, k3, k4, k6; N_Vector b_node; SUNMatrix Jac; SUNLinearSolver LS; /* nonlinear system data */ N_Vector z, zpred, Fi, sdata; - double tcur, gamma; + sunrealtype tcur, gamma; void* user_data = NULL; retval = ARKodeGetNonlinearSystemData(arkode_mem, &tcur, &zpred, &z, &Fi, @@ -992,14 +1013,14 @@ static int TaskLocalLSolve(N_Vector delta, void* arkode_mem) w = Zdata[IDX(nvar, i, 2)]; /* all vars wrt u */ - SM_ELEMENT_D(Jac, 0, 0) = -k2 * w + 2.0 * k3 * u * v - k4; - SM_ELEMENT_D(Jac, 1, 0) = k2 * w - 2.0 * k3 * u * v; + SM_ELEMENT_D(Jac, 0, 0) = -k2 * w + SUN_RCONST(2.0) * k3 * u * v - k4; + SM_ELEMENT_D(Jac, 1, 0) = k2 * w - SUN_RCONST(2.0) * k3 * u * v; SM_ELEMENT_D(Jac, 2, 0) = -k2 * w; /* all vars wrt v */ SM_ELEMENT_D(Jac, 0, 1) = k3 * u * u; SM_ELEMENT_D(Jac, 1, 1) = -k3 * u * u; - SM_ELEMENT_D(Jac, 2, 1) = 0.0; + SM_ELEMENT_D(Jac, 2, 1) = SUN_RCONST(0.0); /* all vars wrt w */ SM_ELEMENT_D(Jac, 0, 2) = -k2 * u; @@ -1051,7 +1072,7 @@ static SUNErrCode TaskLocalNewton_Initialize(SUNNonlinearSolver NLS) } static int TaskLocalNewton_Solve(SUNNonlinearSolver NLS, N_Vector y0, - N_Vector ycor, N_Vector w, double tol, + N_Vector ycor, N_Vector w, sunrealtype tol, sunbooleantype callLSetup, void* mem) { /* local variables */ @@ -1137,7 +1158,7 @@ static SUNErrCode TaskLocalNewton_GetNumConvFails(SUNNonlinearSolver NLS, /* check that the nonlinear solver is non-null */ if (NLS == NULL) { return SUN_ERR_ARG_CORRUPT; } - return (GET_NLS_CONTENT(NLS)->ncnf); + return (SUNErrCode)(GET_NLS_CONTENT(NLS)->ncnf); } static SUNNonlinearSolver TaskLocalNewton(SUNContext ctx, N_Vector y) @@ -1207,19 +1228,19 @@ static SUNNonlinearSolver TaskLocalNewton(SUNContext ctx, N_Vector y) * --------------------------------------------------------------*/ /* Sets P = I - gamma * J */ -static int PSetup(double t, N_Vector y, N_Vector ydot, sunbooleantype jok, - sunbooleantype* jcurPtr, double gamma, void* user_data) +static int PSetup(sunrealtype t, N_Vector y, N_Vector ydot, sunbooleantype jok, + sunbooleantype* jcurPtr, sunrealtype gamma, void* user_data) { /* local variables */ UserData udata = (UserData)user_data; - double* Ydata; - double u, v, w; - long long i, blocki; + sunrealtype* Ydata; + sunrealtype u, v, w; + sunindextype i, blocki; int retval = 0; /* shortcuts */ - long long nvar, N; - double k2, k3, k4, k6; + sunindextype nvar, N; + sunrealtype k2, k3, k4, k6; SUNMatrix P; SUNLinearSolver LS; @@ -1251,14 +1272,15 @@ static int PSetup(double t, N_Vector y, N_Vector ydot, sunbooleantype jok, w = Ydata[IDX(nvar, i, 2)]; /* all vars wrt u */ - SM_ELEMENT_D(P, blocki, blocki) = -k2 * w + 2.0 * k3 * u * v - k4; - SM_ELEMENT_D(P, blocki + 1, blocki) = k2 * w - 2.0 * k3 * u * v; + SM_ELEMENT_D(P, blocki, blocki) = -k2 * w + SUN_RCONST(2.0) * k3 * u * v - + k4; + SM_ELEMENT_D(P, blocki + 1, blocki) = k2 * w - SUN_RCONST(2.0) * k3 * u * v; SM_ELEMENT_D(P, blocki + 2, blocki) = -k2 * w; /* all vars wrt v */ SM_ELEMENT_D(P, blocki, blocki + 1) = k3 * u * u; SM_ELEMENT_D(P, blocki + 1, blocki + 1) = -k3 * u * u; - SM_ELEMENT_D(P, blocki + 2, blocki + 1) = 0.0; + SM_ELEMENT_D(P, blocki + 2, blocki + 1) = SUN_RCONST(0.0); /* all vars wrt w */ SM_ELEMENT_D(P, blocki, blocki + 2) = -k2 * u; @@ -1280,8 +1302,9 @@ static int PSetup(double t, N_Vector y, N_Vector ydot, sunbooleantype jok, } /* Solves Pz = r */ -static int PSolve(double t, N_Vector y, N_Vector ydot, N_Vector r, N_Vector z, - double gamma, double delta, int lr, void* user_data) +static int PSolve(sunrealtype t, N_Vector y, N_Vector ydot, N_Vector r, + N_Vector z, sunrealtype gamma, sunrealtype delta, int lr, + void* user_data) { /* local variables */ UserData udata = (UserData)user_data; @@ -1298,7 +1321,7 @@ static int PSolve(double t, N_Vector y, N_Vector ydot, N_Vector r, N_Vector z, r_local = N_VGetLocalVector_MPIPlusX(r); /* solve the task-local linear system Pz = r */ - retval = SUNLinSolSolve(LS, P, z_local, r_local, 0.0); + retval = SUNLinSolSolve(LS, P, z_local, r_local, SUN_RCONST(0.0)); return (retval); } @@ -1322,12 +1345,12 @@ static int ExchangeBCOnly(N_Vector y, UserData udata) int last = udata->nprocs - 1; /* extract the data */ - double* Ydata = N_VGetArrayPointer(y); + sunrealtype* Ydata = N_VGetArrayPointer(y); /* open the East Irecv buffer */ if (myid == last) { - ierr = MPI_Irecv(udata->Erecv, nvar, MPI_DOUBLE, first, MPI_ANY_TAG, + ierr = MPI_Irecv(udata->Erecv, nvar, MPI_SUNREALTYPE, first, MPI_ANY_TAG, udata->comm, &reqR); } @@ -1338,7 +1361,8 @@ static int ExchangeBCOnly(N_Vector y, UserData udata) { udata->Wsend[IDX(nvar, 0, var)] = Ydata[IDX(nvar, 0, var)]; } - ierr = MPI_Isend(udata->Wsend, nvar, MPI_DOUBLE, last, 0, udata->comm, &reqS); + ierr = MPI_Isend(udata->Wsend, nvar, MPI_SUNREALTYPE, last, 0, udata->comm, + &reqS); } /* wait for exchange to finish */ @@ -1372,24 +1396,24 @@ static int ExchangeAllStart(N_Vector y, UserData udata) int retval; /* shortcuts */ - double c = udata->c; - long long N = udata->nxl; - int nvar = udata->nvar; - int myid = udata->myid; - int first = 0; - int last = udata->nprocs - 1; - int ipW = (myid == first) ? last : udata->myid - 1; /* periodic BC */ - int ipE = (myid == last) ? first : udata->myid + 1; /* periodic BC */ + sunrealtype c = udata->c; + sunindextype N = udata->nxl; + int nvar = udata->nvar; + int myid = udata->myid; + int first = 0; + int last = udata->nprocs - 1; + int ipW = (myid == first) ? last : udata->myid - 1; /* periodic BC */ + int ipE = (myid == last) ? first : udata->myid + 1; /* periodic BC */ /* extract the data */ - double* Ydata = N_VGetArrayPointer(y); + sunrealtype* Ydata = N_VGetArrayPointer(y); - if (c > 0.0) + if (c > SUN_RCONST(0.0)) { /* Right moving flow uses backward difference. Send from west to east (last processor sends to first) */ - retval = MPI_Irecv(udata->Wrecv, nvar, MPI_DOUBLE, ipW, MPI_ANY_TAG, + retval = MPI_Irecv(udata->Wrecv, nvar, MPI_SUNREALTYPE, ipW, MPI_ANY_TAG, udata->comm, &udata->reqR); if (retval != MPI_SUCCESS) { MPI_Abort(udata->comm, 1); } @@ -1398,16 +1422,16 @@ static int ExchangeAllStart(N_Vector y, UserData udata) udata->Esend[IDX(nvar, 0, var)] = Ydata[IDX(nvar, N - 1, var)]; } - retval = MPI_Isend(udata->Esend, nvar, MPI_DOUBLE, ipE, 0, udata->comm, + retval = MPI_Isend(udata->Esend, nvar, MPI_SUNREALTYPE, ipE, 0, udata->comm, &udata->reqS); if (retval != MPI_SUCCESS) { MPI_Abort(udata->comm, 1); } } - else if (c < 0.0) + else if (c < SUN_RCONST(0.0)) { /* Left moving flow uses forward difference. Send from east to west (first processor sends to last) */ - retval = MPI_Irecv(udata->Erecv, nvar, MPI_DOUBLE, ipE, MPI_ANY_TAG, + retval = MPI_Irecv(udata->Erecv, nvar, MPI_SUNREALTYPE, ipE, MPI_ANY_TAG, udata->comm, &udata->reqR); if (retval != MPI_SUCCESS) { MPI_Abort(udata->comm, 1); } @@ -1416,7 +1440,7 @@ static int ExchangeAllStart(N_Vector y, UserData udata) udata->Wsend[IDX(nvar, 0, var)] = Ydata[IDX(nvar, 0, var)]; } - retval = MPI_Isend(udata->Wsend, nvar, MPI_DOUBLE, ipW, 0, udata->comm, + retval = MPI_Isend(udata->Wsend, nvar, MPI_SUNREALTYPE, ipW, 0, udata->comm, &udata->reqS); if (retval != MPI_SUCCESS) { MPI_Abort(udata->comm, 1); } } @@ -1456,9 +1480,9 @@ static int SetupProblem(int argc, char* argv[], UserData udata, { /* local variables */ int i, retval; - double* data = NULL; /* data pointer */ - N_Vector tmp = NULL; /* temporary local vector */ - char fname[MXSTR]; /* output file name */ + sunrealtype* data = NULL; /* data pointer */ + N_Vector tmp = NULL; /* temporary local vector */ + char fname[MXSTR]; /* output file name */ /* MPI variables */ udata->comm = MPI_COMM_WORLD; @@ -1466,13 +1490,13 @@ static int SetupProblem(int argc, char* argv[], UserData udata, MPI_Comm_size(udata->comm, &udata->nprocs); /* default problem parameters */ - const long long nvar = 3; /* number of solution fields */ - const long long NX = 100; /* global spatial mesh size (NX intervals) */ - const double xmax = 1.0; /* maximum x value */ - const double A = 1.0; /* problem parameters */ - const double B = 3.5; - const double k = 1.0; - const double c = 0.01; + const sunindextype nvar = 3; /* number of solution fields */ + const sunindextype NX = 100; /* global spatial mesh size (NX intervals) */ + const sunrealtype xmax = 1.0; /* maximum x value */ + const sunrealtype A = 1.0; /* problem parameters */ + const sunrealtype B = 3.5; + const sunrealtype k = 1.0; + const sunrealtype c = 0.01; /* set default user data values */ udata->nvar = nvar; @@ -1497,17 +1521,17 @@ static int SetupProblem(int argc, char* argv[], UserData udata, udata->uopt = uopt; /* set default integrator options */ - uopt->order = 3; /* method order */ - uopt->explicit = 0; /* imex or explicit */ - uopt->t0 = 0.0; /* initial time */ - uopt->tf = 10.0; /* final time */ - uopt->rtol = 1.0e-6; /* relative tolerance */ - uopt->atol = 1.0e-9; /* absolute tolerance */ - uopt->global = 0; /* use global NLS */ - uopt->fused = 0; /* use fused vector ops */ - uopt->monitor = 0; /* print solution to screen */ - uopt->printtime = 0; /* print timing */ - uopt->nout = 40; /* number of output times */ + uopt->order = 3; /* method order */ + uopt->explicit = 0; /* imex or explicit */ + uopt->t0 = SUN_RCONST(0.0); /* initial time */ + uopt->tf = SUN_RCONST(10.0); /* final time */ + uopt->rtol = SUN_RCONST(1.0e-6); /* relative tolerance */ + uopt->atol = SUN_RCONST(1.0e-9); /* absolute tolerance */ + uopt->global = 0; /* use global NLS */ + uopt->fused = 0; /* use fused vector ops */ + uopt->monitor = 0; /* print solution to screen */ + uopt->printtime = 0; /* print timing */ + uopt->nout = 40; /* number of output times */ uopt->TFID = NULL; uopt->UFID = NULL; uopt->VFID = NULL; @@ -1552,30 +1576,30 @@ static int SetupProblem(int argc, char* argv[], UserData udata, } else if (strcmp(argv[i], "--xmax") == 0) { - udata->xmax = strtod(argv[i + 1], NULL); + udata->xmax = SUNStrToReal(argv[i + 1]); i++; } else if (strcmp(argv[i], "--A") == 0) { - udata->A = strtod(argv[i + 1], NULL); + udata->A = SUNStrToReal(argv[i + 1]); i++; } else if (strcmp(argv[i], "--B") == 0) { - udata->B = strtod(argv[i + 1], NULL); + udata->B = SUNStrToReal(argv[i + 1]); i++; } else if (strcmp(argv[i], "--k") == 0) { - udata->k1 = strtod(argv[i + 1], NULL); - udata->k2 = strtod(argv[i + 2], NULL); - udata->k3 = strtod(argv[i + 3], NULL); - udata->k4 = strtod(argv[i + 4], NULL); + udata->k1 = SUNStrToReal(argv[i + 1]); + udata->k2 = SUNStrToReal(argv[i + 2]); + udata->k3 = SUNStrToReal(argv[i + 3]); + udata->k4 = SUNStrToReal(argv[i + 4]); i += 4; } else if (strcmp(argv[i], "--c") == 0) { - udata->c = strtod(argv[i + 1], NULL); + udata->c = SUNStrToReal(argv[i + 1]); i++; } else if (strcmp(argv[i], "--order") == 0) @@ -1588,17 +1612,17 @@ static int SetupProblem(int argc, char* argv[], UserData udata, else if (strcmp(argv[i], "--fused") == 0) { uopt->fused = 1; } else if (strcmp(argv[i], "--tf") == 0) { - uopt->tf = strtod(argv[i + 1], NULL); + uopt->tf = SUNStrToReal(argv[i + 1]); i++; } else if (strcmp(argv[i], "--rtol") == 0) { - uopt->rtol = strtod(argv[i + 1], NULL); + uopt->rtol = SUNStrToReal(argv[i + 1]); i++; } else if (strcmp(argv[i], "--atol") == 0) { - uopt->atol = strtod(argv[i + 1], NULL); + uopt->atol = SUNStrToReal(argv[i + 1]); i++; } else @@ -1621,16 +1645,16 @@ static int SetupProblem(int argc, char* argv[], UserData udata, udata->dx = udata->xmax / udata->nx; /* nx is number of intervals */ /* Create the MPI exchange buffers */ - udata->Wsend = (double*)calloc(udata->nvar, sizeof(double)); + udata->Wsend = (sunrealtype*)calloc(udata->nvar, sizeof(sunrealtype)); if (check_retval((void*)udata->Wsend, "calloc", 0)) { return 1; } - udata->Wrecv = (double*)calloc(udata->nvar, sizeof(double)); + udata->Wrecv = (sunrealtype*)calloc(udata->nvar, sizeof(sunrealtype)); if (check_retval((void*)udata->Wrecv, "calloc", 0)) { return 1; } - udata->Esend = (double*)calloc(udata->nvar, sizeof(double)); + udata->Esend = (sunrealtype*)calloc(udata->nvar, sizeof(sunrealtype)); if (check_retval((void*)udata->Esend, "calloc", 0)) { return 1; } - udata->Erecv = (double*)calloc(udata->nvar, sizeof(double)); + udata->Erecv = (sunrealtype*)calloc(udata->nvar, sizeof(sunrealtype)); if (check_retval((void*)udata->Erecv, "calloc", 0)) { return 1; } /* Create the solution masks */ @@ -1714,21 +1738,22 @@ static int SetupProblem(int argc, char* argv[], UserData udata, printf("\n1D Advection-Reaction Test Problem\n\n"); printf("Number of Processors = %li\n", (long int)udata->nprocs); printf("Mesh Info:\n"); - printf(" NX = %lli, NXL = %lli, dx = %.6f, xmax = %.6f\n", udata->nx, - udata->nxl, udata->dx, udata->xmax); + printf(" NX = %lli, NXL = %lli, dx = %.6" FSYM ", xmax = %.6" FSYM "\n", + (long long int)udata->nx, (long long int)udata->nxl, udata->dx, + udata->xmax); printf("Problem Parameters:\n"); - printf(" A = %g\n", udata->A); - printf(" B = %g\n", udata->B); - printf(" k = %g\n", udata->k1); - printf(" c = %g\n", udata->c); + printf(" A = %" GSYM "\n", udata->A); + printf(" B = %" GSYM "\n", udata->B); + printf(" k = %" GSYM "\n", udata->k1); + printf(" c = %" GSYM "\n", udata->c); printf("Integrator Options:\n"); printf(" order = %d\n", uopt->order); printf(" method = %s\n", uopt->explicit ? "explicit" : "imex"); printf(" fused vector ops = %d\n", uopt->fused); - printf(" t0 = %g\n", uopt->t0); - printf(" tf = %g\n", uopt->tf); - printf(" reltol = %.1e\n", uopt->rtol); - printf(" abstol = %.1e\n", uopt->atol); + printf(" t0 = %" GSYM "\n", uopt->t0); + printf(" tf = %" GSYM "\n", uopt->tf); + printf(" reltol = %.1" ESYM "\n", uopt->rtol); + printf(" abstol = %.1" ESYM "\n", uopt->atol); printf(" nout = %d\n", uopt->nout); if (uopt->explicit) { printf(" nonlinear solver = none\n"); } else diff --git a/examples/arkode/C_parallel/ark_diurnal_kry_bbd_p.c b/examples/arkode/C_parallel/ark_diurnal_kry_bbd_p.c index e2ea59a659..08b28a9bc2 100644 --- a/examples/arkode/C_parallel/ark_diurnal_kry_bbd_p.c +++ b/examples/arkode/C_parallel/ark_diurnal_kry_bbd_p.c @@ -67,12 +67,6 @@ #include /* SUNDIALS type definitions */ #include /* access to SPGMR SUNLinearSolver */ -/* helpful macros */ - -#ifndef SQR -#define SQR(A) ((A) * (A)) -#endif - /* Problem Constants */ #define ZERO SUN_RCONST(0.0) #define NVARS 2 /* number of species */ @@ -91,7 +85,7 @@ #define NOUT 12 /* number of output times */ #define TWOHR SUN_RCONST(7200.0) /* number of seconds in two hours */ #define HALFDAY SUN_RCONST(4.32e4) /* number of seconds in a half day */ -#define PI SUN_RCONST(3.1415926535898) /* pi */ +#define PI SUN_RCONST(3.141592653589793238462643383279502884197169) /* pi */ #define XMIN ZERO /* grid boundaries in x */ #define XMAX SUN_RCONST(20.0) @@ -341,9 +335,9 @@ static void InitUserData(int my_pe, sunindextype local_N, MPI_Comm comm, data->om = PI / HALFDAY; data->dx = (XMAX - XMIN) / ((sunrealtype)(MX - 1)); data->dy = (YMAX - YMIN) / ((sunrealtype)(MY - 1)); - data->hdco = KH / SQR(data->dx); + data->hdco = KH / SUNSQR(data->dx); data->haco = VEL / (SUN_RCONST(2.0) * data->dx); - data->vdco = (SUN_RCONST(1.0) / SQR(data->dy)) * KV0; + data->vdco = (SUN_RCONST(1.0) / SUNSQR(data->dy)) * KV0; /* Set machine-related constants */ data->comm = comm; @@ -387,14 +381,14 @@ static void SetInitialProfiles(N_Vector u, UserData data) { jy = ly + isuby * MYSUB; y = YMIN + jy * dy; - cy = SQR(SUN_RCONST(0.1) * (y - ymid)); - cy = SUN_RCONST(1.0) - cy + SUN_RCONST(0.5) * SQR(cy); + cy = SUNSQR(SUN_RCONST(0.1) * (y - ymid)); + cy = SUN_RCONST(1.0) - cy + SUN_RCONST(0.5) * SUNSQR(cy); for (lx = 0; lx < MXSUB; lx++) { jx = lx + isubx * MXSUB; x = XMIN + jx * dx; - cx = SQR(SUN_RCONST(0.1) * (x - xmid)); - cx = SUN_RCONST(1.0) - cx + SUN_RCONST(0.5) * SQR(cx); + cx = SUNSQR(SUN_RCONST(0.1) * (x - xmid)); + cx = SUN_RCONST(1.0) - cx + SUN_RCONST(0.5) * SUNSQR(cx); uarray[offset] = C1_SCALE * cx * cy; uarray[offset + 1] = C2_SCALE * cx * cy; offset = offset + 2; @@ -454,7 +448,11 @@ static void PrintOutput(void* arkode_mem, int my_pe, MPI_Comm comm, N_Vector u, check_flag(&flag, "ARKodeGetNumSteps", 1, my_pe); flag = ARKodeGetLastStep(arkode_mem, &hu); check_flag(&flag, "ARKodeGetLastStep", 1, my_pe); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("t = %.2Qe no. steps = %ld stepsize = %.2Qe\n", t, nst, hu); + printf("At bottom left: c1, c2 = %12.3Qe %12.3Qe \n", uarray[0], uarray[1]); + printf("At top right: c1, c2 = %12.3Qe %12.3Qe \n\n", tempu[0], tempu[1]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("t = %.2Le no. steps = %ld stepsize = %.2Le\n", t, nst, hu); printf("At bottom left: c1, c2 = %12.3Le %12.3Le \n", uarray[0], uarray[1]); printf("At top right: c1, c2 = %12.3Le %12.3Le \n\n", tempu[0], tempu[1]); @@ -824,11 +822,11 @@ static int flocal(sunindextype Nlocal, sunrealtype t, N_Vector u, N_Vector udot, /* Set diurnal rate coefficients as functions of t, and save q4 in data block for use by preconditioner evaluation routine */ - s = sin((data->om) * t); + s = SUNRsin((data->om) * t); if (s > ZERO) { - q3 = exp(-A3 / s); - q4coef = exp(-A4 / s); + q3 = SUNRexp(-A3 / s); + q4coef = SUNRexp(-A4 / s); } else { @@ -845,8 +843,8 @@ static int flocal(sunindextype Nlocal, sunrealtype t, N_Vector u, N_Vector udot, /* Set vertical diffusion coefficients at jy +- 1/2 */ ydn = YMIN + (jy - SUN_RCONST(0.5)) * dely; yup = ydn + dely; - cydn = verdco * exp(SUN_RCONST(0.2) * ydn); - cyup = verdco * exp(SUN_RCONST(0.2) * yup); + cydn = verdco * SUNRexp(SUN_RCONST(0.2) * ydn); + cyup = verdco * SUNRexp(SUN_RCONST(0.2) * yup); for (lx = 0; lx < MXSUB; lx++) { /* Extract c1 and c2, and set kinetic rate terms */ diff --git a/examples/arkode/C_parallel/ark_diurnal_kry_bbd_p.out b/examples/arkode/C_parallel/ark_diurnal_kry_bbd_p.out index a30074040d..39769c7ea6 100644 --- a/examples/arkode/C_parallel/ark_diurnal_kry_bbd_p.out +++ b/examples/arkode/C_parallel/ark_diurnal_kry_bbd_p.out @@ -19,53 +19,53 @@ t = 2.16e+04 no. steps = 115 stepsize = 6.88e+02 At bottom left: c1, c2 = 2.665e+07 2.993e+11 At top right: c1, c2 = 2.931e+07 3.313e+11 -t = 2.88e+04 no. steps = 133 stepsize = 2.55e+02 +t = 2.88e+04 no. steps = 133 stepsize = 2.57e+02 At bottom left: c1, c2 = 8.702e+06 3.380e+11 At top right: c1, c2 = 9.650e+06 3.751e+11 -t = 3.60e+04 no. steps = 161 stepsize = 7.55e+01 +t = 3.60e+04 no. steps = 161 stepsize = 7.53e+01 At bottom left: c1, c2 = 1.404e+04 3.387e+11 At top right: c1, c2 = 1.561e+04 3.765e+11 -t = 4.32e+04 no. steps = 201 stepsize = 1.77e+03 -At bottom left: c1, c2 = -1.994e-07 3.382e+11 -At top right: c1, c2 = 4.533e-06 3.804e+11 +t = 4.32e+04 no. steps = 201 stepsize = 1.78e+03 +At bottom left: c1, c2 = -1.339e-07 3.382e+11 +At top right: c1, c2 = 4.458e-06 3.804e+11 -t = 5.04e+04 no. steps = 206 stepsize = 7.73e+02 -At bottom left: c1, c2 = -2.848e-08 3.358e+11 -At top right: c1, c2 = -1.542e-07 3.864e+11 +t = 5.04e+04 no. steps = 205 stepsize = 1.30e+03 +At bottom left: c1, c2 = -1.120e-06 3.358e+11 +At top right: c1, c2 = 5.028e-07 3.864e+11 -t = 5.76e+04 no. steps = 210 stepsize = 1.55e+03 -At bottom left: c1, c2 = -8.395e-07 3.320e+11 -At top right: c1, c2 = -4.284e-07 3.909e+11 +t = 5.76e+04 no. steps = 211 stepsize = 2.61e+02 +At bottom left: c1, c2 = 2.304e-09 3.320e+11 +At top right: c1, c2 = 3.415e-09 3.909e+11 -t = 6.48e+04 no. steps = 215 stepsize = 1.89e+03 -At bottom left: c1, c2 = 1.234e-08 3.313e+11 -At top right: c1, c2 = 9.230e-08 3.963e+11 +t = 6.48e+04 no. steps = 216 stepsize = 1.94e+03 +At bottom left: c1, c2 = -1.762e-07 3.313e+11 +At top right: c1, c2 = -1.956e-06 3.963e+11 -t = 7.20e+04 no. steps = 218 stepsize = 2.21e+03 -At bottom left: c1, c2 = -4.001e-08 3.330e+11 -At top right: c1, c2 = -7.099e-06 4.039e+11 +t = 7.20e+04 no. steps = 220 stepsize = 2.10e+03 +At bottom left: c1, c2 = -3.297e-08 3.330e+11 +At top right: c1, c2 = 7.118e-07 4.039e+11 -t = 7.92e+04 no. steps = 221 stepsize = 2.32e+03 -At bottom left: c1, c2 = 3.713e-08 3.334e+11 -At top right: c1, c2 = -3.992e-07 4.120e+11 +t = 7.92e+04 no. steps = 223 stepsize = 2.32e+03 +At bottom left: c1, c2 = -3.113e-07 3.334e+11 +At top right: c1, c2 = 3.116e-06 4.120e+11 -t = 8.64e+04 no. steps = 224 stepsize = 2.47e+03 -At bottom left: c1, c2 = 3.734e-07 3.352e+11 -At top right: c1, c2 = 3.748e-07 4.163e+11 +t = 8.64e+04 no. steps = 226 stepsize = 2.41e+03 +At bottom left: c1, c2 = 5.520e-07 3.352e+11 +At top right: c1, c2 = -5.018e-06 4.163e+11 Final Statistics: lenrw = 4118 leniw = 291 lenrwls = 2455 leniwls = 126 -nst = 224 nfe = 0 -nfe = 3315 nfels = 6886 -nni = 2077 nli = 6886 -nsetups = 73 netf = 23 -npe = 4 nps = 8881 -ncfn = 0 ncfl = 530 +nst = 226 nfe = 0 +nfe = 3363 nfels = 6972 +nni = 2110 nli = 6972 +nsetups = 77 netf = 24 +npe = 4 nps = 9000 +ncfn = 0 ncfl = 534 In ARKBBDPRE: real/integer local work space sizes = 1300, 192 no. flocal evals. = 88 @@ -88,7 +88,7 @@ t = 2.16e+04 no. steps = 114 stepsize = 6.89e+02 At bottom left: c1, c2 = 2.665e+07 2.993e+11 At top right: c1, c2 = 2.931e+07 3.313e+11 -t = 2.88e+04 no. steps = 131 stepsize = 1.93e+02 +t = 2.88e+04 no. steps = 131 stepsize = 1.94e+02 At bottom left: c1, c2 = 8.702e+06 3.380e+11 At top right: c1, c2 = 9.650e+06 3.751e+11 @@ -96,45 +96,45 @@ t = 3.60e+04 no. steps = 159 stepsize = 7.48e+01 At bottom left: c1, c2 = 1.404e+04 3.387e+11 At top right: c1, c2 = 1.561e+04 3.765e+11 -t = 4.32e+04 no. steps = 199 stepsize = 1.75e+03 -At bottom left: c1, c2 = -1.508e-07 3.382e+11 -At top right: c1, c2 = -1.680e-07 3.804e+11 +t = 4.32e+04 no. steps = 199 stepsize = 1.76e+03 +At bottom left: c1, c2 = -1.411e-07 3.382e+11 +At top right: c1, c2 = -1.598e-07 3.804e+11 -t = 5.04e+04 no. steps = 203 stepsize = 1.28e+03 -At bottom left: c1, c2 = 8.151e-09 3.358e+11 -At top right: c1, c2 = -1.358e-08 3.864e+11 +t = 5.04e+04 no. steps = 203 stepsize = 1.29e+03 +At bottom left: c1, c2 = 1.379e-08 3.358e+11 +At top right: c1, c2 = -1.821e-08 3.864e+11 -t = 5.76e+04 no. steps = 208 stepsize = 9.65e+02 -At bottom left: c1, c2 = 5.968e-08 3.320e+11 -At top right: c1, c2 = 1.041e-08 3.909e+11 +t = 5.76e+04 no. steps = 210 stepsize = 7.26e+02 +At bottom left: c1, c2 = 5.031e-15 3.320e+11 +At top right: c1, c2 = 2.131e-13 3.909e+11 -t = 6.48e+04 no. steps = 213 stepsize = 1.90e+03 -At bottom left: c1, c2 = -4.322e-09 3.313e+11 -At top right: c1, c2 = 4.258e-10 3.963e+11 +t = 6.48e+04 no. steps = 214 stepsize = 2.05e+03 +At bottom left: c1, c2 = -4.619e-12 3.313e+11 +At top right: c1, c2 = 1.070e-10 3.963e+11 -t = 7.20e+04 no. steps = 216 stepsize = 2.21e+03 -At bottom left: c1, c2 = 1.431e-07 3.330e+11 -At top right: c1, c2 = 1.210e-06 4.039e+11 +t = 7.20e+04 no. steps = 218 stepsize = 2.19e+03 +At bottom left: c1, c2 = 6.198e-08 3.330e+11 +At top right: c1, c2 = 8.649e-07 4.039e+11 -t = 7.92e+04 no. steps = 219 stepsize = 2.32e+03 -At bottom left: c1, c2 = 2.679e-08 3.334e+11 -At top right: c1, c2 = 1.594e-07 4.120e+11 +t = 7.92e+04 no. steps = 221 stepsize = 2.32e+03 +At bottom left: c1, c2 = 5.697e-08 3.334e+11 +At top right: c1, c2 = 1.397e-07 4.120e+11 -t = 8.64e+04 no. steps = 222 stepsize = 2.47e+03 -At bottom left: c1, c2 = 6.003e-08 3.352e+11 -At top right: c1, c2 = -1.811e-07 4.163e+11 +t = 8.64e+04 no. steps = 224 stepsize = 2.47e+03 +At bottom left: c1, c2 = -1.180e-08 3.352e+11 +At top right: c1, c2 = 6.919e-08 4.163e+11 Final Statistics: lenrw = 4118 leniw = 297 lenrwls = 2455 leniwls = 126 -nst = 222 nfe = 0 -nfe = 3244 nfels = 7604 -nni = 2021 nli = 7604 -nsetups = 77 netf = 22 -npe = 8 nps = 9536 -ncfn = 4 ncfl = 950 +nst = 224 nfe = 0 +nfe = 3306 nfels = 7713 +nni = 2063 nli = 7713 +nsetups = 81 netf = 24 +npe = 8 nps = 9687 +ncfn = 4 ncfl = 958 In ARKBBDPRE: real/integer local work space sizes = 1300, 192 no. flocal evals. = 176 diff --git a/examples/arkode/C_parallel/ark_diurnal_kry_p.c b/examples/arkode/C_parallel/ark_diurnal_kry_p.c index 377d57827f..6d18301148 100644 --- a/examples/arkode/C_parallel/ark_diurnal_kry_p.c +++ b/examples/arkode/C_parallel/ark_diurnal_kry_p.c @@ -64,12 +64,6 @@ #include /* SUNDIALS type definitions */ #include /* access to SPGMR SUNLinearSolver */ -/* helpful macros */ - -#ifndef SQR -#define SQR(A) ((A) * (A)) -#endif - /* Problem Constants */ #define NVARS 2 /* number of species */ #define KH SUN_RCONST(4.0e-6) /* horizontal diffusivity Kh */ @@ -87,7 +81,7 @@ #define NOUT 12 /* number of output times */ #define TWOHR SUN_RCONST(7200.0) /* number of seconds in two hours */ #define HALFDAY SUN_RCONST(4.32e4) /* number of seconds in a half day */ -#define PI SUN_RCONST(3.1415926535898) /* pi */ +#define PI SUN_RCONST(3.141592653589793238462643383279502884197169) /* pi */ #define XMIN SUN_RCONST(0.0) /* grid boundaries in x */ #define XMAX SUN_RCONST(20.0) @@ -320,9 +314,9 @@ static void InitUserData(int my_pe, MPI_Comm comm, UserData data) data->om = PI / HALFDAY; data->dx = (XMAX - XMIN) / ((sunrealtype)(MX - 1)); data->dy = (YMAX - YMIN) / ((sunrealtype)(MY - 1)); - data->hdco = KH / SQR(data->dx); + data->hdco = KH / SUNSQR(data->dx); data->haco = VEL / (SUN_RCONST(2.0) * data->dx); - data->vdco = (SUN_RCONST(1.0) / SQR(data->dy)) * KV0; + data->vdco = (SUN_RCONST(1.0) / SUNSQR(data->dy)) * KV0; /* Set machine-related constants */ data->comm = comm; @@ -393,14 +387,14 @@ static void SetInitialProfiles(N_Vector u, UserData data) { jy = ly + isuby * MYSUB; y = YMIN + jy * dy; - cy = SQR(SUN_RCONST(0.1) * (y - ymid)); - cy = SUN_RCONST(1.0) - cy + SUN_RCONST(0.5) * SQR(cy); + cy = SUNSQR(SUN_RCONST(0.1) * (y - ymid)); + cy = SUN_RCONST(1.0) - cy + SUN_RCONST(0.5) * SUNSQR(cy); for (lx = 0; lx < MXSUB; lx++) { jx = lx + isubx * MXSUB; x = XMIN + jx * dx; - cx = SQR(SUN_RCONST(0.1) * (x - xmid)); - cx = SUN_RCONST(1.0) - cx + SUN_RCONST(0.5) * SQR(cx); + cx = SUNSQR(SUN_RCONST(0.1) * (x - xmid)); + cx = SUN_RCONST(1.0) - cx + SUN_RCONST(0.5) * SUNSQR(cx); udata[offset] = C1_SCALE * cx * cy; udata[offset + 1] = C2_SCALE * cx * cy; offset = offset + 2; @@ -448,7 +442,11 @@ static void PrintOutput(void* arkode_mem, int my_pe, MPI_Comm comm, N_Vector u, flag = ARKodeGetLastStep(arkode_mem, &hu); check_flag(&flag, "ARKodeGetLastStep", 1, my_pe); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("t = %.2Qe no. steps = %ld stepsize = %.2Qe\n", t, nst, hu); + printf("At bottom left: c1, c2 = %12.3Qe %12.3Qe \n", udata[0], udata[1]); + printf("At top right: c1, c2 = %12.3Qe %12.3Qe \n\n", tempu[0], tempu[1]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("t = %.2Le no. steps = %ld stepsize = %.2Le\n", t, nst, hu); printf("At bottom left: c1, c2 = %12.3Le %12.3Le \n", udata[0], udata[1]); printf("At top right: c1, c2 = %12.3Le %12.3Le \n\n", tempu[0], tempu[1]); @@ -783,11 +781,11 @@ static void fcalc(sunrealtype t, sunrealtype udata[], sunrealtype dudata[], /* Set diurnal rate coefficients as functions of t, and save q4 in data block for use by preconditioner evaluation routine */ - s = sin((data->om) * t); + s = SUNRsin((data->om) * t); if (s > SUN_RCONST(0.0)) { - q3 = exp(-A3 / s); - q4coef = exp(-A4 / s); + q3 = SUNRexp(-A3 / s); + q4coef = SUNRexp(-A4 / s); } else { @@ -804,8 +802,8 @@ static void fcalc(sunrealtype t, sunrealtype udata[], sunrealtype dudata[], /* Set vertical diffusion coefficients at jy +- 1/2 */ ydn = YMIN + (jy - SUN_RCONST(0.5)) * dely; yup = ydn + dely; - cydn = verdco * exp(SUN_RCONST(0.2) * ydn); - cyup = verdco * exp(SUN_RCONST(0.2) * yup); + cydn = verdco * SUNRexp(SUN_RCONST(0.2) * ydn); + cyup = verdco * SUNRexp(SUN_RCONST(0.2) * yup); for (lx = 0; lx < MXSUB; lx++) { /* Extract c1 and c2, and set kinetic rate terms */ @@ -922,8 +920,8 @@ static int Precond(sunrealtype tn, N_Vector u, N_Vector fu, sunbooleantype jok, jy = ly + isuby * MYSUB; ydn = YMIN + (jy - SUN_RCONST(0.5)) * dely; yup = ydn + dely; - cydn = verdco * exp(SUN_RCONST(0.2) * ydn); - cyup = verdco * exp(SUN_RCONST(0.2) * yup); + cydn = verdco * SUNRexp(SUN_RCONST(0.2) * ydn); + cyup = verdco * SUNRexp(SUN_RCONST(0.2) * yup); diag = -(cydn + cyup + SUN_RCONST(2.0) * hordco); for (lx = 0; lx < MXSUB; lx++) { diff --git a/examples/arkode/C_parallel/ark_diurnal_kry_p.out b/examples/arkode/C_parallel/ark_diurnal_kry_p.out index 62b62514e4..a2f0b2cfcc 100644 --- a/examples/arkode/C_parallel/ark_diurnal_kry_p.out +++ b/examples/arkode/C_parallel/ark_diurnal_kry_p.out @@ -22,32 +22,32 @@ At bottom left: c1, c2 = 1.404e+04 3.387e+11 At top right: c1, c2 = 1.561e+04 3.765e+11 t = 4.32e+04 no. steps = 196 stepsize = 1.75e+03 -At bottom left: c1, c2 = -4.884e-08 3.382e+11 -At top right: c1, c2 = -8.694e-07 3.804e+11 +At bottom left: c1, c2 = -4.835e-08 3.382e+11 +At top right: c1, c2 = -8.697e-07 3.804e+11 t = 5.04e+04 no. steps = 200 stepsize = 1.26e+03 -At bottom left: c1, c2 = -7.230e-09 3.358e+11 -At top right: c1, c2 = 3.094e-08 3.864e+11 +At bottom left: c1, c2 = -7.426e-09 3.358e+11 +At top right: c1, c2 = 3.187e-08 3.864e+11 -t = 5.76e+04 no. steps = 205 stepsize = 1.08e+03 -At bottom left: c1, c2 = 4.422e-06 3.320e+11 -At top right: c1, c2 = -2.623e-05 3.909e+11 +t = 5.76e+04 no. steps = 205 stepsize = 1.09e+03 +At bottom left: c1, c2 = 4.570e-06 3.320e+11 +At top right: c1, c2 = -2.713e-05 3.909e+11 t = 6.48e+04 no. steps = 209 stepsize = 2.05e+03 -At bottom left: c1, c2 = 1.105e-08 3.313e+11 -At top right: c1, c2 = 7.165e-08 3.963e+11 +At bottom left: c1, c2 = 1.360e-08 3.313e+11 +At top right: c1, c2 = 9.541e-08 3.963e+11 -t = 7.20e+04 no. steps = 213 stepsize = 2.13e+03 -At bottom left: c1, c2 = -4.810e-06 3.330e+11 -At top right: c1, c2 = -1.198e-04 4.039e+11 +t = 7.20e+04 no. steps = 213 stepsize = 2.14e+03 +At bottom left: c1, c2 = -4.071e-06 3.330e+11 +At top right: c1, c2 = -1.276e-04 4.039e+11 t = 7.92e+04 no. steps = 216 stepsize = 2.32e+03 -At bottom left: c1, c2 = 7.856e-08 3.334e+11 -At top right: c1, c2 = 6.407e-07 4.120e+11 +At bottom left: c1, c2 = 1.342e-07 3.334e+11 +At top right: c1, c2 = 1.106e-06 4.120e+11 t = 8.64e+04 no. steps = 219 stepsize = 2.47e+03 -At bottom left: c1, c2 = 1.878e-08 3.352e+11 -At top right: c1, c2 = 2.566e-08 4.163e+11 +At bottom left: c1, c2 = 2.723e-08 3.352e+11 +At top right: c1, c2 = 2.857e-08 4.163e+11 Final Statistics: diff --git a/examples/arkode/C_parhyp/ark_diurnal_kry_ph.c b/examples/arkode/C_parhyp/ark_diurnal_kry_ph.c index 0247ed97a9..a4c8883173 100644 --- a/examples/arkode/C_parhyp/ark_diurnal_kry_ph.c +++ b/examples/arkode/C_parhyp/ark_diurnal_kry_ph.c @@ -65,7 +65,7 @@ #include #include #include /* prototypes for small dense fcts. */ -#include /* definition of macros SUNSQR and EXP */ +#include /* definition of macros SUNSQR and SUNRexp */ #include /* definitions of sunrealtype, sunbooleantype */ #include /* access to SPGMR SUNLinearSolver */ @@ -86,7 +86,7 @@ #define NOUT 12 /* number of output times */ #define TWOHR SUN_RCONST(7200.0) /* number of seconds in two hours */ #define HALFDAY SUN_RCONST(4.32e4) /* number of seconds in a half day */ -#define PI SUN_RCONST(3.1415926535898) /* pi */ +#define PI SUN_RCONST(3.141592653589793238462643383279502884197169) /* pi */ #define XMIN SUN_RCONST(0.0) /* grid boundaries in x */ #define XMAX SUN_RCONST(20.0) diff --git a/examples/arkode/C_serial/ark_KrylovDemo_prec.c b/examples/arkode/C_serial/ark_KrylovDemo_prec.c index 0a8e250d38..d8a1ed3f4e 100644 --- a/examples/arkode/C_serial/ark_KrylovDemo_prec.c +++ b/examples/arkode/C_serial/ark_KrylovDemo_prec.c @@ -107,36 +107,6 @@ #include /* definition of sunrealtype */ #include /* access to SPGMR SUNLinearSolver */ -/* helpful macros */ - -#ifndef MAX -#define MAX(A, B) ((A) > (B) ? (A) : (B)) -#endif - -#ifndef SQR -#define SQR(A) ((A) * (A)) -#endif - -#ifndef SQRT -#if defined(SUNDIALS_DOUBLE_PRECISION) -#define SQRT(x) (sqrt((x))) -#elif defined(SUNDIALS_SINGLE_PRECISION) -#define SQRT(x) (sqrtf((x))) -#elif defined(SUNDIALS_EXTENDED_PRECISION) -#define SQRT(x) (sqrtl((x))) -#endif -#endif - -#ifndef ABS -#if defined(SUNDIALS_DOUBLE_PRECISION) -#define ABS(x) (fabs((x))) -#elif defined(SUNDIALS_SINGLE_PRECISION) -#define ABS(x) (fabsf((x))) -#elif defined(SUNDIALS_EXTENDED_PRECISION) -#define ABS(x) (fabsl((x))) -#endif -#endif - /* Constants */ #define ZERO SUN_RCONST(0.0) @@ -346,7 +316,7 @@ int main(int argc, char* argv[]) { case (1): /* use the square root of the vector length */ - nrmfac = SQRT((sunrealtype)NEQ); + nrmfac = SUNRsqrt((sunrealtype)NEQ); break; case (2): /* compute with dot product */ @@ -459,8 +429,8 @@ static void InitUserData(WebData wdata) dy = wdata->dy = DY; for (i = 0; i < ns; i++) { - cox[i] = diff[i] / SQR(dx); - coy[i] = diff[i] / SQR(dy); + cox[i] = diff[i] / SUNSQR(dx); + coy[i] = diff[i] / SUNSQR(dy); } /* Set remaining method parameters */ @@ -469,7 +439,7 @@ static void InitUserData(WebData wdata) wdata->mq = MQ; wdata->mx = MX; wdata->my = MY; - wdata->srur = sqrt(SUN_UNIT_ROUNDOFF); + wdata->srur = SUNRsqrt(SUN_UNIT_ROUNDOFF); wdata->mxmp = MXMP; wdata->ngrp = NGRP; wdata->ngx = NGX; @@ -518,17 +488,17 @@ static void CInit(N_Vector c, WebData wdata) dx = wdata->dx; dy = wdata->dy; - x_factor = SUN_RCONST(4.0) / SQR(AX); - y_factor = SUN_RCONST(4.0) / SQR(AY); + x_factor = SUN_RCONST(4.0) / SUNSQR(AX); + y_factor = SUN_RCONST(4.0) / SUNSQR(AY); for (jy = 0; jy < MY; jy++) { y = jy * dy; - argy = SQR(y_factor * y * (AY - y)); + argy = SUNSQR(y_factor * y * (AY - y)); iyoff = mxns * jy; for (jx = 0; jx < MX; jx++) { x = jx * dx; - argx = SQR(x_factor * x * (AX - x)); + argx = SUNSQR(x_factor * x * (AX - x)); ioff = iyoff + ns * jx; for (i = 1; i <= ns; i++) { @@ -544,16 +514,16 @@ static void PrintIntro(void) printf("\n\nDemonstration program for ARKODE - SPGMR linear solver\n\n"); printf("Food web problem with ns species, ns = %d\n", NS); printf("Predator-prey interaction and diffusion on a 2-D square\n\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Matrix parameters: a = %.2Qg e = %.2Qg g = %.2Qg\n", AA, EE, GG); + printf("b parameter = %.2Qg\n", BB); + printf("Diffusion coefficients: Dprey = %.2Qg Dpred = %.2Qg\n", DPREY, DPRED); + printf("Rate parameter alpha = %.2Qg\n\n", ALPHA); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Matrix parameters: a = %.2Lg e = %.2Lg g = %.2Lg\n", AA, EE, GG); printf("b parameter = %.2Lg\n", BB); printf("Diffusion coefficients: Dprey = %.2Lg Dpred = %.2Lg\n", DPREY, DPRED); printf("Rate parameter alpha = %.2Lg\n\n", ALPHA); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Matrix parameters: a = %.2g e = %.2g g = %.2g\n", AA, EE, GG); - printf("b parameter = %.2g\n", BB); - printf("Diffusion coefficients: Dprey = %.2g Dpred = %.2g\n", DPREY, DPRED); - printf("Rate parameter alpha = %.2g\n\n", ALPHA); #else printf("Matrix parameters: a = %.2g e = %.2g g = %.2g\n", AA, EE, GG); printf("b parameter = %.2g\n", BB); @@ -562,10 +532,10 @@ static void PrintIntro(void) #endif printf("Mesh dimensions (mx,my) are %d, %d. ", MX, MY); printf("Total system size is neq = %d \n\n", NEQ); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerances: reltol = %.2Qg, abstol = %.2Qg \n\n", RTOL, ATOL); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerances: reltol = %.2Lg, abstol = %.2Lg \n\n", RTOL, ATOL); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerances: reltol = %.2g, abstol = %.2g \n\n", RTOL, ATOL); #else printf("Tolerances: reltol = %.2g, abstol = %.2g \n\n", RTOL, ATOL); #endif @@ -610,10 +580,10 @@ static void PrintAllSpecies(N_Vector c, int ns, int mxns, sunrealtype t) sunrealtype* cdata; cdata = N_VGetArrayPointer(c); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("c values at t = %Qg:\n\n", t); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("c values at t = %Lg:\n\n", t); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("c values at t = %g:\n\n", t); #else printf("c values at t = %g:\n\n", t); #endif @@ -624,10 +594,10 @@ static void PrintAllSpecies(N_Vector c, int ns, int mxns, sunrealtype t) { for (jx = 0; jx < MX; jx++) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%-10.6Qg", cdata[(i - 1) + jx * ns + jy * mxns]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%-10.6Lg", cdata[(i - 1) + jx * ns + jy * mxns]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%-10.6g", cdata[(i - 1) + jx * ns + jy * mxns]); #else printf("%-10.6g", cdata[(i - 1) + jx * ns + jy * mxns]); #endif @@ -655,14 +625,14 @@ static void PrintOutput(void* arkode_mem, sunrealtype t) flag = ARKodeGetLastStep(arkode_mem, &hu); check_flag(&flag, "ARKodeGetLastStep", 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("t = %10.2Qe nst = %ld nfe = %ld nfi = %ld nni = %ld", t, nst, nfe, + nfi, nni); + printf(" hu = %11.2Qe\n\n", hu); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("t = %10.2Le nst = %ld nfe = %ld nfi = %ld nni = %ld", t, nst, nfe, nfi, nni); printf(" hu = %11.2Le\n\n", hu); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("t = %10.2e nst = %ld nfe = %ld nfi = %ld nni = %ld", t, nst, nfe, - nfi, nni); - printf(" hu = %11.2e\n\n", hu); #else printf("t = %10.2e nst = %ld nfe = %ld nfi = %ld nni = %ld", t, nst, nfe, nfi, nni); @@ -728,7 +698,9 @@ static void PrintFinalStats(void* arkode_mem) printf(" Number of nonlinear conv. failures = %4ld \n", ncfn); printf(" Number of linear convergence failures = %4ld \n", ncfl); avdim = (nni > 0) ? ((sunrealtype)nli) / ((sunrealtype)nni) : ZERO; -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" Average Krylov subspace dimension = %.3Qf \n", avdim); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" Average Krylov subspace dimension = %.3Lf \n", avdim); #else printf(" Average Krylov subspace dimension = %.3f \n", avdim); @@ -895,7 +867,7 @@ static int Precond(sunrealtype t, N_Vector c, N_Vector fc, sunbooleantype jok, f1 = N_VGetArrayPointer(wdata->tmp); fac = N_VWrmsNorm(fc, rewt); - r0 = SUN_RCONST(1000.0) * ABS(gamma) * uround * NEQ * fac; + r0 = SUN_RCONST(1000.0) * SUNRabs(gamma) * uround * NEQ * fac; if (r0 == ZERO) { r0 = ONE; } for (igy = 0; igy < ngy; igy++) @@ -913,7 +885,7 @@ static int Precond(sunrealtype t, N_Vector c, N_Vector fc, sunbooleantype jok, /* Generate the jth column as a difference quotient */ jj = if0 + j; save = cdata[jj]; - r = MAX(srur * ABS(save), r0 / rewtdata[jj]); + r = SUNMAX(srur * SUNRabs(save), r0 / rewtdata[jj]); cdata[jj] += r; fac = -gamma / r; fblock(t, cdata, jx, jy, f1, wdata); diff --git a/examples/arkode/C_serial/ark_advection_diffusion_reaction_splitting.c b/examples/arkode/C_serial/ark_advection_diffusion_reaction_splitting.c index ab4ea863aa..97171b90af 100644 --- a/examples/arkode/C_serial/ark_advection_diffusion_reaction_splitting.c +++ b/examples/arkode/C_serial/ark_advection_diffusion_reaction_splitting.c @@ -46,7 +46,10 @@ #include #include -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#define FSYM "Qf" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #define FSYM "Lf" #else @@ -180,12 +183,14 @@ int main(void) sunrealtype tret = T0; printf(" t ||u||_rms\n"); printf(" ----------------------\n"); - printf(" %10.6" FSYM " %10.6f\n", tret, sqrt(N_VDotProd(y, y) / udata.N)); + printf(" %10.6" FSYM " %10.6" FSYM "\n", tret, + SUNRsqrt(N_VDotProd(y, y) / udata.N)); while (tret < Tf) { flag = ARKodeEvolve(arkode_mem, Tf, y, &tret, ARK_ONE_STEP); if (check_flag(&flag, "ARKodeEvolve", 1)) { return 1; } - printf(" %10.6" FSYM " %10.6f\n", tret, sqrt(N_VDotProd(y, y) / udata.N)); + printf(" %10.6" FSYM " %10.6" FSYM "\n", tret, + SUNRsqrt(N_VDotProd(y, y) / udata.N)); } printf(" ----------------------\n"); diff --git a/examples/arkode/C_serial/ark_analytic.c b/examples/arkode/C_serial/ark_analytic.c index ea9fcae67c..96dcdaf099 100644 --- a/examples/arkode/C_serial/ark_analytic.c +++ b/examples/arkode/C_serial/ark_analytic.c @@ -42,7 +42,11 @@ #include /* access to dense SUNLinearSolver */ #include /* access to dense SUNMatrix */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#define ESYM "Qe" +#define FSYM "Qf" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #define ESYM "Le" #define FSYM "Lf" @@ -152,7 +156,7 @@ int main(int argc, char* argv[]) tout = T0 + dTout; printf(" t u\n"); printf(" ---------------------\n"); - while (Tf - t > 1.0e-15) + while (Tf - t > SUN_RCONST(1.0e-15)) { flag = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ if (check_flag(&flag, "ARKodeEvolve", 1)) { break; } @@ -231,7 +235,7 @@ static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) /* fill in the RHS function: "NV_Ith_S" accesses the 0th entry of ydot */ NV_Ith_S(ydot, 0) = lambda * u + SUN_RCONST(1.0) / (SUN_RCONST(1.0) + t * t) - - lambda * atan(t); + lambda * SUNRatan(t); return 0; /* return with success */ } @@ -304,7 +308,7 @@ static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, sunrealtype at sunrealtype ans, err, ewt; /* answer data, error, and error weight */ /* compute solution error */ - ans = atan(t); + ans = SUNRatan(t); ewt = SUN_RCONST(1.0) / (rtol * SUNRabs(ans) + atol); err = ewt * SUNRabs(NV_Ith_S(y, 0) - ans); diff --git a/examples/arkode/C_serial/ark_analytic_lsrk.c b/examples/arkode/C_serial/ark_analytic_lsrk.c index 2702048ab8..8e56b90b39 100644 --- a/examples/arkode/C_serial/ark_analytic_lsrk.c +++ b/examples/arkode/C_serial/ark_analytic_lsrk.c @@ -39,7 +39,11 @@ #include /* def. of SUNRsqrt, etc. */ #include /* definition of type sunrealtype */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#define ESYM "Qe" +#define FSYM "Qf" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #define ESYM "Le" #define FSYM "Lf" @@ -49,14 +53,6 @@ #define FSYM "f" #endif -#if defined(SUNDIALS_DOUBLE_PRECISION) -#define ATAN(x) (atan((x))) -#elif defined(SUNDIALS_SINGLE_PRECISION) -#define ATAN(x) (atanf((x))) -#elif defined(SUNDIALS_EXTENDED_PRECISION) -#define ATAN(x) (atanl((x))) -#endif - /* User-supplied Functions Called by the Solver */ static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); @@ -96,6 +92,10 @@ int main(void) sunrealtype reltol = SUN_RCONST(1.0e-8); /* tolerances */ sunrealtype abstol = SUN_RCONST(1.0e-8); sunrealtype lambda = SUN_RCONST(-1000000.0); /* stiffness parameter */ +#elif defined(SUNDIALS_FLOAT128_PRECISION) + sunrealtype reltol = SUN_RCONST(1.0e-8); /* tolerances */ + sunrealtype abstol = SUN_RCONST(1.0e-8); + sunrealtype lambda = SUN_RCONST(-1000000.0); /* stiffness parameter */ #endif /* general problem variables */ @@ -228,8 +228,9 @@ static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) sunrealtype u = N_VGetArrayPointer(y)[0]; /* access current solution value */ /* fill in the RHS function: "N_VGetArrayPointer" accesses the 0th entry of ydot */ - N_VGetArrayPointer(ydot)[0] = - lambda * u + SUN_RCONST(1.0) / (SUN_RCONST(1.0) + t * t) - lambda * ATAN(t); + N_VGetArrayPointer(ydot)[0] = lambda * u + + SUN_RCONST(1.0) / (SUN_RCONST(1.0) + t * t) - + lambda * SUNRatan(t); return 0; /* return with success */ } @@ -300,7 +301,7 @@ static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, sunrealtype at sunrealtype ans, err, ewt; /* answer data, error, and error weight */ /* compute solution error */ - ans = ATAN(t); + ans = SUNRatan(t); ewt = SUN_RCONST(1.0) / (rtol * SUNRabs(ans) + atol); err = ewt * SUNRabs(N_VGetArrayPointer(y)[0] - ans); @@ -321,7 +322,7 @@ static int compute_error(N_Vector y, sunrealtype t) sunrealtype ans, err; /* answer data, error */ /* compute solution error */ - ans = ATAN(t); + ans = SUNRatan(t); err = SUNRabs(N_VGetArrayPointer(y)[0] - ans); fprintf(stdout, "\nACCURACY at the final time = %" GSYM "\n", err); diff --git a/examples/arkode/C_serial/ark_analytic_lsrk_domeigest.c b/examples/arkode/C_serial/ark_analytic_lsrk_domeigest.c index 5c35c8802a..c36c5d3837 100644 --- a/examples/arkode/C_serial/ark_analytic_lsrk_domeigest.c +++ b/examples/arkode/C_serial/ark_analytic_lsrk_domeigest.c @@ -50,7 +50,11 @@ #include /* definition of type sunrealtype */ #include /* access to Power Iteration module */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#define ESYM "Qe" +#define FSYM "Qf" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #define ESYM "Le" #define FSYM "Lf" @@ -60,20 +64,6 @@ #define FSYM "f" #endif -#if defined(SUNDIALS_DOUBLE_PRECISION) -#define ATAN(x) (atan((x))) -#define ACOS(x) (acos((x))) -#define COS(x) (cos((x))) -#elif defined(SUNDIALS_SINGLE_PRECISION) -#define ATAN(x) (atanf((x))) -#define ACOS(x) (acosf((x))) -#define COS(x) (cosf((x))) -#elif defined(SUNDIALS_EXTENDED_PRECISION) -#define ATAN(x) (atanl((x))) -#define ACOS(x) (acosl((x))) -#define COS(x) (cosl((x))) -#endif - /* User-supplied Functions Called by the Solver */ static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); @@ -111,6 +101,11 @@ int main(int argc, char* argv[]) sunrealtype abstol = SUN_RCONST(1.0e-8); sunrealtype lambda = SUN_RCONST(-1.0e+6); /* stiffness parameter 1 */ sunrealtype alpha = SUN_RCONST(1.0e+2); /* stiffness parameter 2 */ +#elif defined(SUNDIALS_FLOAT128_PRECISION) + sunrealtype reltol = SUN_RCONST(1.0e-8); /* tolerances */ + sunrealtype abstol = SUN_RCONST(1.0e-8); + sunrealtype lambda = SUN_RCONST(-1.0e+6); /* stiffness parameter 1 */ + sunrealtype alpha = SUN_RCONST(1.0e+2); /* stiffness parameter 2 */ #endif sunrealtype UserData[2]; @@ -307,13 +302,13 @@ static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) /* fill in the RHS function: "N_VGetArrayPointer" accesses the 0th entry of ydot */ N_VGetArrayPointer(ydot)[0] = - (lambda - alpha * COS((SUN_RCONST(10.0) - t) / SUN_RCONST(10.0) * - ACOS(SUN_RCONST(-1.0)))) * + (lambda - alpha * SUNRcos((SUN_RCONST(10.0) - t) / SUN_RCONST(10.0) * + SUNRacos(SUN_RCONST(-1.0)))) * u + SUN_RCONST(1.0) / (SUN_RCONST(1.0) + t * t) - - (lambda - alpha * COS((SUN_RCONST(10.0) - t) / SUN_RCONST(10.0) * - ACOS(SUN_RCONST(-1.0)))) * - ATAN(t); + (lambda - alpha * SUNRcos((SUN_RCONST(10.0) - t) / SUN_RCONST(10.0) * + SUNRacos(SUN_RCONST(-1.0)))) * + SUNRatan(t); return 0; /* return with success */ } @@ -372,7 +367,7 @@ static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, sunrealtype at sunrealtype ans, err, ewt; /* answer data, error, and error weight */ /* compute solution error */ - ans = ATAN(t); + ans = SUNRatan(t); ewt = SUN_RCONST(1.0) / (rtol * SUNRabs(ans) + atol); err = ewt * SUNRabs(N_VGetArrayPointer(y)[0] - ans); @@ -393,7 +388,7 @@ static int compute_error(N_Vector y, sunrealtype t) sunrealtype ans, err; /* answer data, error */ /* compute solution error */ - ans = ATAN(t); + ans = SUNRatan(t); err = SUNRabs(N_VGetArrayPointer(y)[0] - ans); fprintf(stdout, "\nACCURACY at the final time = %" GSYM "\n", err); diff --git a/examples/arkode/C_serial/ark_analytic_lsrk_varjac.c b/examples/arkode/C_serial/ark_analytic_lsrk_varjac.c index 87be61b4cf..072aaad324 100644 --- a/examples/arkode/C_serial/ark_analytic_lsrk_varjac.c +++ b/examples/arkode/C_serial/ark_analytic_lsrk_varjac.c @@ -48,7 +48,11 @@ #include /* def. of SUNRsqrt, etc. */ #include /* definition of type sunrealtype */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#define ESYM "Qe" +#define FSYM "Qf" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #define ESYM "Le" #define FSYM "Lf" @@ -58,20 +62,6 @@ #define FSYM "f" #endif -#if defined(SUNDIALS_DOUBLE_PRECISION) -#define ATAN(x) (atan((x))) -#define ACOS(x) (acos((x))) -#define COS(x) (cos((x))) -#elif defined(SUNDIALS_SINGLE_PRECISION) -#define ATAN(x) (atanf((x))) -#define ACOS(x) (acosf((x))) -#define COS(x) (cosf((x))) -#elif defined(SUNDIALS_EXTENDED_PRECISION) -#define ATAN(x) (atanl((x))) -#define ACOS(x) (acosl((x))) -#define COS(x) (cosl((x))) -#endif - /* User-supplied Functions Called by the Solver */ static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); @@ -114,6 +104,11 @@ int main(void) sunrealtype abstol = SUN_RCONST(1.0e-8); sunrealtype lambda = SUN_RCONST(-1.0e+6); /* stiffness parameter 1 */ sunrealtype alpha = SUN_RCONST(1.0e+2); /* stiffness parameter 2 */ +#elif defined(SUNDIALS_FLOAT128_PRECISION) + sunrealtype reltol = SUN_RCONST(1.0e-8); /* tolerances */ + sunrealtype abstol = SUN_RCONST(1.0e-8); + sunrealtype lambda = SUN_RCONST(-1.0e+6); /* stiffness parameter 1 */ + sunrealtype alpha = SUN_RCONST(1.0e+2); /* stiffness parameter 2 */ #endif sunrealtype UserData[2]; @@ -174,7 +169,7 @@ int main(void) if (check_flag(&flag, "LSRKStepSetMaxNumStages", 1)) { return 1; } /* Specify max number of steps allowed */ - flag = ARKodeSetMaxNumSteps(arkode_mem, 2000); + flag = ARKodeSetMaxNumSteps(arkode_mem, 2000000); if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } /* Specify safety factor for user provided dom_eig */ @@ -254,13 +249,13 @@ static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) /* fill in the RHS function: "N_VGetArrayPointer" accesses the 0th entry of ydot */ N_VGetArrayPointer(ydot)[0] = - (lambda - alpha * COS((SUN_RCONST(10.0) - t) / SUN_RCONST(10.0) * - ACOS(SUN_RCONST(-1.0)))) * + (lambda - alpha * SUNRcos((SUN_RCONST(10.0) - t) / SUN_RCONST(10.0) * + SUNRacos(SUN_RCONST(-1.0)))) * u + SUN_RCONST(1.0) / (SUN_RCONST(1.0) + t * t) - - (lambda - alpha * COS((SUN_RCONST(10.0) - t) / SUN_RCONST(10.0) * - ACOS(SUN_RCONST(-1.0)))) * - ATAN(t); + (lambda - alpha * SUNRcos((SUN_RCONST(10.0) - t) / SUN_RCONST(10.0) * + SUNRacos(SUN_RCONST(-1.0)))) * + SUNRatan(t); return 0; /* return with success */ } @@ -275,8 +270,8 @@ static int dom_eig(sunrealtype t, N_Vector y, N_Vector fn, sunrealtype* lambdaR, sunrealtype alpha = rdata[1]; /* set shortcut for stiffness parameter 2 */ *lambdaR = (lambda - - alpha * COS((SUN_RCONST(10.0) - t) / SUN_RCONST(10.0) * - ACOS(SUN_RCONST(-1.0)))); /* access current solution value */ + alpha * SUNRcos((SUN_RCONST(10.0) - t) / SUN_RCONST(10.0) * + SUNRacos(SUN_RCONST(-1.0)))); /* access current solution value */ *lambdaI = SUN_RCONST(0.0); return 0; /* return with success */ @@ -336,7 +331,7 @@ static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, sunrealtype at sunrealtype ans, err, ewt; /* answer data, error, and error weight */ /* compute solution error */ - ans = ATAN(t); + ans = SUNRatan(t); ewt = SUN_RCONST(1.0) / (rtol * SUNRabs(ans) + atol); err = ewt * SUNRabs(N_VGetArrayPointer(y)[0] - ans); @@ -357,7 +352,7 @@ static int compute_error(N_Vector y, sunrealtype t) sunrealtype ans, err; /* answer data, error */ /* compute solution error */ - ans = ATAN(t); + ans = SUNRatan(t); err = SUNRabs(N_VGetArrayPointer(y)[0] - ans); fprintf(stdout, "\nACCURACY at the final time = %" GSYM "\n", err); diff --git a/examples/arkode/C_serial/ark_analytic_mels.c b/examples/arkode/C_serial/ark_analytic_mels.c index 56303bad5f..853ab0f952 100644 --- a/examples/arkode/C_serial/ark_analytic_mels.c +++ b/examples/arkode/C_serial/ark_analytic_mels.c @@ -39,7 +39,11 @@ #include #include /* definition of type sunrealtype */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#define ESYM "Qe" +#define FSYM "Qf" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #define ESYM "Le" #define FSYM "Lf" diff --git a/examples/arkode/C_serial/ark_analytic_nonlin.c b/examples/arkode/C_serial/ark_analytic_nonlin.c index 5bafbca8b5..30d3ef0857 100644 --- a/examples/arkode/C_serial/ark_analytic_nonlin.c +++ b/examples/arkode/C_serial/ark_analytic_nonlin.c @@ -36,7 +36,10 @@ #include /* def. of SUNRsqrt, etc. */ #include /* def. of type 'sunrealtype' */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define ESYM "Qe" +#define FSYM "Qf" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define ESYM "Le" #define FSYM "Lf" #else diff --git a/examples/arkode/C_serial/ark_analytic_partitioned.c b/examples/arkode/C_serial/ark_analytic_partitioned.c index e08357e8eb..eec40e2dc3 100644 --- a/examples/arkode/C_serial/ark_analytic_partitioned.c +++ b/examples/arkode/C_serial/ark_analytic_partitioned.c @@ -47,7 +47,9 @@ #include #include -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #else #define GSYM "g" diff --git a/examples/arkode/C_serial/ark_analytic_ssprk.c b/examples/arkode/C_serial/ark_analytic_ssprk.c index fa74f07eb0..f17344a97c 100644 --- a/examples/arkode/C_serial/ark_analytic_ssprk.c +++ b/examples/arkode/C_serial/ark_analytic_ssprk.c @@ -39,7 +39,11 @@ #include /* def. of SUNRsqrt, etc. */ #include /* definition of type sunrealtype */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#define ESYM "Qe" +#define FSYM "Qf" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #define ESYM "Le" #define FSYM "Lf" @@ -49,14 +53,6 @@ #define FSYM "f" #endif -#if defined(SUNDIALS_DOUBLE_PRECISION) -#define ATAN(x) (atan((x))) -#elif defined(SUNDIALS_SINGLE_PRECISION) -#define ATAN(x) (atanf((x))) -#elif defined(SUNDIALS_EXTENDED_PRECISION) -#define ATAN(x) (atanl((x))) -#endif - /* User-supplied Functions Called by the Solver */ static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); @@ -87,6 +83,10 @@ int main(void) sunrealtype reltol = SUN_RCONST(1.0e-8); /* tolerances */ sunrealtype abstol = SUN_RCONST(1.0e-8); sunrealtype lambda = SUN_RCONST(-10.0); /* stiffness parameter */ +#elif defined(SUNDIALS_FLOAT128_PRECISION) + sunrealtype reltol = SUN_RCONST(1.0e-8); /* tolerances */ + sunrealtype abstol = SUN_RCONST(1.0e-8); + sunrealtype lambda = SUN_RCONST(-10.0); /* stiffness parameter */ #endif /* general problem variables */ @@ -205,8 +205,9 @@ static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) sunrealtype u = N_VGetArrayPointer(y)[0]; /* access current solution value */ /* fill in the RHS function: "N_VGetArrayPointer" accesses the 0th entry of ydot */ - N_VGetArrayPointer(ydot)[0] = - lambda * u + SUN_RCONST(1.0) / (SUN_RCONST(1.0) + t * t) - lambda * ATAN(t); + N_VGetArrayPointer(ydot)[0] = lambda * u + + SUN_RCONST(1.0) / (SUN_RCONST(1.0) + t * t) - + lambda * SUNRatan(t); return 0; /* return with success */ } @@ -264,7 +265,7 @@ static int compute_error(N_Vector y, sunrealtype t) sunrealtype ans, err; /* answer data, error */ /* compute solution error */ - ans = ATAN(t); + ans = SUNRatan(t); err = SUNRabs(N_VGetArrayPointer(y)[0] - ans); fprintf(stdout, "\nACCURACY at the final time = %" GSYM "\n", err); diff --git a/examples/arkode/C_serial/ark_brusselator.c b/examples/arkode/C_serial/ark_brusselator.c index da2fddb8b3..5b2032725b 100644 --- a/examples/arkode/C_serial/ark_brusselator.c +++ b/examples/arkode/C_serial/ark_brusselator.c @@ -65,7 +65,11 @@ #include /* access to dense SUNLinearSolver */ #include /* access to dense SUNMatrix */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#define ESYM "Qe" +#define FSYM "Qf" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #define ESYM "Le" #define FSYM "Lf" diff --git a/examples/arkode/C_serial/ark_brusselator1D.c b/examples/arkode/C_serial/ark_brusselator1D.c index 05038effb3..9b69e911ee 100644 --- a/examples/arkode/C_serial/ark_brusselator1D.c +++ b/examples/arkode/C_serial/ark_brusselator1D.c @@ -55,7 +55,11 @@ #include /* access to band SUNLinearSolver */ #include /* access to band SUNMatrix */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#define ESYM "Qe" +#define FSYM "Qf" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #define ESYM "Le" #define FSYM "Lf" diff --git a/examples/arkode/C_serial/ark_brusselator1D_FEM_slu.out b/examples/arkode/C_serial/ark_brusselator1D_FEM_slu.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/examples/arkode/C_serial/ark_brusselator1D_imexmri.c b/examples/arkode/C_serial/ark_brusselator1D_imexmri.c index 7b9f4a1b7a..f5fc7b72aa 100644 --- a/examples/arkode/C_serial/ark_brusselator1D_imexmri.c +++ b/examples/arkode/C_serial/ark_brusselator1D_imexmri.c @@ -77,7 +77,11 @@ #include /* access to band SUNLinearSolver */ #include /* access to band SUNMatrix */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#define ESYM "Qe" +#define FSYM "Qf" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #define ESYM "Le" #define FSYM "Lf" diff --git a/examples/arkode/C_serial/ark_brusselator1D_klu.out b/examples/arkode/C_serial/ark_brusselator1D_klu.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/examples/arkode/C_serial/ark_brusselator_1D_mri.c b/examples/arkode/C_serial/ark_brusselator_1D_mri.c index 03fe21d7c0..2fb7c7f332 100644 --- a/examples/arkode/C_serial/ark_brusselator_1D_mri.c +++ b/examples/arkode/C_serial/ark_brusselator_1D_mri.c @@ -65,7 +65,11 @@ #include /* access to band SUNLinearSolver */ #include /* access to band SUNMatrix */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#define ESYM "Qe" +#define FSYM "Qf" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #define ESYM "Le" #define FSYM "Lf" diff --git a/examples/arkode/C_serial/ark_brusselator_fp.c b/examples/arkode/C_serial/ark_brusselator_fp.c index 9c373a34d9..cd0eeb7c4c 100644 --- a/examples/arkode/C_serial/ark_brusselator_fp.c +++ b/examples/arkode/C_serial/ark_brusselator_fp.c @@ -64,7 +64,11 @@ #include /* def. of type 'sunrealtype' */ #include /* access to FP nonlinear solver */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#define ESYM "Qe" +#define FSYM "Qf" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #define ESYM "Le" #define FSYM "Lf" diff --git a/examples/arkode/C_serial/ark_brusselator_mri.c b/examples/arkode/C_serial/ark_brusselator_mri.c index 2c1f92d052..7416712e6a 100644 --- a/examples/arkode/C_serial/ark_brusselator_mri.c +++ b/examples/arkode/C_serial/ark_brusselator_mri.c @@ -43,7 +43,11 @@ #include #include /* def. of type 'sunrealtype' */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#define ESYM "Qe" +#define FSYM "Qf" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #define ESYM "Le" #define FSYM "Lf" diff --git a/examples/arkode/C_serial/ark_conserved_exp_entropy_ark.c b/examples/arkode/C_serial/ark_conserved_exp_entropy_ark.c index 44d829601d..fd1c6d25af 100644 --- a/examples/arkode/C_serial/ark_conserved_exp_entropy_ark.c +++ b/examples/arkode/C_serial/ark_conserved_exp_entropy_ark.c @@ -58,25 +58,13 @@ #include /* Value of the natural number e */ -#define EVAL 2.718281828459045235360287471352662497757247093699959574966 - -/* Convince macros for calling precision-specific math functions */ -#if defined(SUNDIALS_DOUBLE_PRECISION) -#define EXP(x) (exp((x))) -#define SQRT(x) (sqrt((x))) -#define LOG(x) (log((x))) -#elif defined(SUNDIALS_SINGLE_PRECISION) -#define EXP(x) (expf((x))) -#define SQRT(x) (sqrtf((x))) -#define LOG(x) (logf((x))) -#elif defined(SUNDIALS_EXTENDED_PRECISION) -#define EXP(x) (expl((x))) -#define SQRT(x) (sqrtl((x))) -#define LOG(x) (logl((x))) -#endif +#define EVAL \ + SUN_RCONST(2.718281828459045235360287471352662497757247093699959574966) /* Convince macros for using precision-specific format specifiers */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define ESYM "Qe" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define ESYM "Le" #else #define ESYM "e" @@ -427,8 +415,8 @@ int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) sunrealtype* ydata = N_VGetArrayPointer(y); sunrealtype* fdata = N_VGetArrayPointer(ydot); - fdata[0] = -EXP(ydata[1]); - fdata[1] = EXP(ydata[0]); + fdata[0] = -SUNRexp(ydata[1]); + fdata[1] = SUNRexp(ydata[0]); return 0; } @@ -442,10 +430,10 @@ int Jac(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, /* column 0 */ Jdata[0] = SUN_RCONST(0.0); - Jdata[1] = EXP(ydata[0]); + Jdata[1] = SUNRexp(ydata[0]); /* column 1 */ - Jdata[2] = -EXP(ydata[1]); + Jdata[2] = -SUNRexp(ydata[1]); Jdata[3] = SUN_RCONST(0.0); return 0; @@ -456,7 +444,7 @@ int Ent(N_Vector y, sunrealtype* e, void* user_data) { sunrealtype* ydata = N_VGetArrayPointer(y); - *e = EXP(ydata[0]) + EXP(ydata[1]); + *e = SUNRexp(ydata[0]) + SUNRexp(ydata[1]); return 0; } @@ -467,8 +455,8 @@ int JacEnt(N_Vector y, N_Vector J, void* user_data) sunrealtype* ydata = N_VGetArrayPointer(y); sunrealtype* jdata = N_VGetArrayPointer(J); - jdata[0] = EXP(ydata[0]); - jdata[1] = EXP(ydata[1]); + jdata[0] = SUNRexp(ydata[0]); + jdata[1] = SUNRexp(ydata[1]); return 0; } @@ -483,11 +471,11 @@ int ans(sunrealtype t, N_Vector y) sunrealtype a, b; sunrealtype* ydata = N_VGetArrayPointer(y); - a = SQRT(EVAL) + EVAL; - b = SQRT(EVAL) + EXP(a * t); + a = SUNRsqrt(EVAL) + EVAL; + b = SUNRsqrt(EVAL) + SUNRexp(a * t); - ydata[0] = LOG(EVAL + EXP(SUN_RCONST(1.5))) - LOG(b); - ydata[1] = LOG(a * EXP(a * t)) - LOG(b); + ydata[0] = SUNRlog(EVAL + SUNRexp(SUN_RCONST(1.5))) - SUNRlog(b); + ydata[1] = SUNRlog(a * SUNRexp(a * t)) - SUNRlog(b); return 0; } diff --git a/examples/arkode/C_serial/ark_conserved_exp_entropy_erk.c b/examples/arkode/C_serial/ark_conserved_exp_entropy_erk.c index 71319488da..78ffabc271 100644 --- a/examples/arkode/C_serial/ark_conserved_exp_entropy_erk.c +++ b/examples/arkode/C_serial/ark_conserved_exp_entropy_erk.c @@ -56,26 +56,14 @@ #include /* Value of the natural number e */ -#define EVAL 2.718281828459045235360287471352662497757247093699959574966 - -/* Convince macros for calling precision-specific math functions */ -#if defined(SUNDIALS_DOUBLE_PRECISION) -#define EXP(x) (exp((x))) -#define SQRT(x) (sqrt((x))) -#define LOG(x) (log((x))) -#elif defined(SUNDIALS_SINGLE_PRECISION) -#define EXP(x) (expf((x))) -#define SQRT(x) (sqrtf((x))) -#define LOG(x) (logf((x))) -#elif defined(SUNDIALS_EXTENDED_PRECISION) -#define EXP(x) (expl((x))) -#define SQRT(x) (sqrtl((x))) -#define LOG(x) (logl((x))) -#endif +#define EVAL \ + SUN_RCONST(2.718281828459045235360287471352662497757247093699959574966) /* Convince macros for using precision-specific format specifiers */ #if defined(SUNDIALS_EXTENDED_PRECISION) #define ESYM "Le" +#elif defined(SUNDIALS_FLOAT128_PRECISION) +#define ESYM "Qe" #else #define ESYM "e" #endif @@ -363,8 +351,8 @@ int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) sunrealtype* ydata = N_VGetArrayPointer(y); sunrealtype* fdata = N_VGetArrayPointer(ydot); - fdata[0] = -EXP(ydata[1]); - fdata[1] = EXP(ydata[0]); + fdata[0] = -SUNRexp(ydata[1]); + fdata[1] = SUNRexp(ydata[0]); return 0; } @@ -374,7 +362,7 @@ int Ent(N_Vector y, sunrealtype* e, void* user_data) { sunrealtype* ydata = N_VGetArrayPointer(y); - *e = EXP(ydata[0]) + EXP(ydata[1]); + *e = SUNRexp(ydata[0]) + SUNRexp(ydata[1]); return 0; } @@ -385,8 +373,8 @@ int JacEnt(N_Vector y, N_Vector J, void* user_data) sunrealtype* ydata = N_VGetArrayPointer(y); sunrealtype* jdata = N_VGetArrayPointer(J); - jdata[0] = EXP(ydata[0]); - jdata[1] = EXP(ydata[1]); + jdata[0] = SUNRexp(ydata[0]); + jdata[1] = SUNRexp(ydata[1]); return 0; } @@ -401,11 +389,11 @@ int ans(sunrealtype t, N_Vector y) sunrealtype a, b; sunrealtype* ydata = N_VGetArrayPointer(y); - a = SQRT(EVAL) + EVAL; - b = SQRT(EVAL) + EXP(a * t); + a = SUNRsqrt(EVAL) + EVAL; + b = SUNRsqrt(EVAL) + SUNRexp(a * t); - ydata[0] = LOG(EVAL + EXP(SUN_RCONST(1.5))) - LOG(b); - ydata[1] = LOG(a * EXP(a * t)) - LOG(b); + ydata[0] = SUNRlog(EVAL + SUNRexp(SUN_RCONST(1.5))) - SUNRlog(b); + ydata[1] = SUNRlog(a * SUNRexp(a * t)) - SUNRlog(b); return 0; } diff --git a/examples/arkode/C_serial/ark_damped_harmonic_symplectic.h b/examples/arkode/C_serial/ark_damped_harmonic_symplectic.h index 5a02f3b112..8531d10c95 100644 --- a/examples/arkode/C_serial/ark_damped_harmonic_symplectic.h +++ b/examples/arkode/C_serial/ark_damped_harmonic_symplectic.h @@ -25,7 +25,7 @@ #include #include -#define PI SUN_RCONST(3.14159265358979323846264338327950) +#define PI SUN_RCONST(3.141592653589793238462643383279502884197169) typedef struct { diff --git a/examples/arkode/C_serial/ark_dissipated_exp_entropy.c b/examples/arkode/C_serial/ark_dissipated_exp_entropy.c index 9d76bf23c7..e4dee179d9 100644 --- a/examples/arkode/C_serial/ark_dissipated_exp_entropy.c +++ b/examples/arkode/C_serial/ark_dissipated_exp_entropy.c @@ -40,20 +40,10 @@ #include #include -/* Convince macros for calling precision-specific math functions */ -#if defined(SUNDIALS_DOUBLE_PRECISION) -#define EXP(x) (exp((x))) -#define LOG(x) (log((x))) -#elif defined(SUNDIALS_SINGLE_PRECISION) -#define EXP(x) (expf((x))) -#define LOG(x) (logf((x))) -#elif defined(SUNDIALS_EXTENDED_PRECISION) -#define EXP(x) (expl((x))) -#define LOG(x) (logl((x))) -#endif - /* Convince macros for using precision-specific format specifiers */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define ESYM "Qe" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define ESYM "Le" #else #define ESYM "e" @@ -400,7 +390,7 @@ int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { sunrealtype* ydata = N_VGetArrayPointer(y); sunrealtype* fdata = N_VGetArrayPointer(ydot); - fdata[0] = -EXP(ydata[0]); + fdata[0] = -SUNRexp(ydata[0]); return 0; } @@ -410,7 +400,7 @@ int Jac(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, { sunrealtype* ydata = N_VGetArrayPointer(y); sunrealtype* Jdata = SUNDenseMatrix_Data(J); - Jdata[0] = -EXP(ydata[0]); + Jdata[0] = -SUNRexp(ydata[0]); return 0; } @@ -418,7 +408,7 @@ int Jac(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, int Ent(N_Vector y, sunrealtype* e, void* user_data) { sunrealtype* ydata = N_VGetArrayPointer(y); - *e = EXP(ydata[0]); + *e = SUNRexp(ydata[0]); return 0; } @@ -427,7 +417,7 @@ int JacEnt(N_Vector y, N_Vector J, void* user_data) { sunrealtype* ydata = N_VGetArrayPointer(y); sunrealtype* jdata = N_VGetArrayPointer(J); - jdata[0] = EXP(ydata[0]); + jdata[0] = SUNRexp(ydata[0]); return 0; } @@ -439,7 +429,7 @@ int JacEnt(N_Vector y, N_Vector J, void* user_data) int ans(sunrealtype t, N_Vector y) { sunrealtype* ydata = N_VGetArrayPointer(y); - ydata[0] = -LOG(EXP(SUN_RCONST(-0.5)) + t); + ydata[0] = -SUNRlog(SUNRexp(SUN_RCONST(-0.5)) + t); return 0; } diff --git a/examples/arkode/C_serial/ark_harmonic_symplectic.c b/examples/arkode/C_serial/ark_harmonic_symplectic.c index aa32316740..86a4281cac 100644 --- a/examples/arkode/C_serial/ark_harmonic_symplectic.c +++ b/examples/arkode/C_serial/ark_harmonic_symplectic.c @@ -119,8 +119,8 @@ int main(int argc, char* argv[]) /* Fill the initial conditions (x0 then v0) */ ydata = N_VGetArrayPointer(y); - ydata[0] = A * cos(phi); - ydata[1] = -A * omega * sin(phi); + ydata[0] = A * SUNRcos(phi); + ydata[1] = -A * omega * SUNRsin(phi); /* Create SPRKStep integrator */ arkode_mem = SPRKStepCreate(xdot, vdot, T0, y, sunctx); @@ -158,7 +158,7 @@ int main(int argc, char* argv[]) /* Compute L2 error */ N_VLinearSum(SUN_RCONST(1.0), y, -SUN_RCONST(1.0), solution, solution); - sunrealtype err = sqrt(N_VDotProd(solution, solution)); + sunrealtype err = SUNRsqrt(N_VDotProd(solution, solution)); /* Output current integration status */ fprintf(stdout, "t = %.6Lf, x(t) = %.6Lf, E = %.6Lf, sol. err = %.16Le\n", @@ -200,8 +200,8 @@ void Solution(sunrealtype t, N_Vector y, N_Vector solvec, UserData* udata) sunrealtype* sol = N_VGetArrayPointer(solvec); /* compute solution */ - sol[0] = udata->A * cos(udata->omega * t + udata->phi); - sol[1] = -udata->A * udata->omega * sin(udata->omega * t + udata->phi); + sol[0] = udata->A * SUNRcos(udata->omega * t + udata->phi); + sol[1] = -udata->A * udata->omega * SUNRsin(udata->omega * t + udata->phi); } sunrealtype Energy(N_Vector yvec, sunrealtype dt, UserData* udata) diff --git a/examples/arkode/C_serial/ark_harmonic_symplectic.h b/examples/arkode/C_serial/ark_harmonic_symplectic.h index e60d1f518b..e16602d335 100644 --- a/examples/arkode/C_serial/ark_harmonic_symplectic.h +++ b/examples/arkode/C_serial/ark_harmonic_symplectic.h @@ -23,9 +23,9 @@ #include #include #include +#include #include - -#define PI SUN_RCONST(3.14159265358979323846264338327950) +#define PI SUN_RCONST(3.141592653589793238462643383279502884197169) typedef struct { @@ -82,24 +82,12 @@ static int ParseArgs(int argc, char* argv[], ProgramArgs* args) else if (!strcmp(argv[argi], "--tf")) { argi++; -#if defined(SUNDIALS_SINGLE_PRECISION) - args->Tf = strtof(argv[argi], NULL); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - args->Tf = strtod(argv[argi], NULL); -#elif defined(SUNDIALS_EXTENDED_PRECISION) - args->Tf = strtold(argv[argi], NULL); -#endif + args->Tf = SUNStrToReal(argv[argi]); } else if (!strcmp(argv[argi], "--dt")) { argi++; -#if defined(SUNDIALS_SINGLE_PRECISION) - args->dt = strtof(argv[argi], NULL); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - args->dt = strtod(argv[argi], NULL); -#elif defined(SUNDIALS_EXTENDED_PRECISION) - args->dt = strtold(argv[argi], NULL); -#endif + args->dt = SUNStrToReal(argv[argi]); } else if (!strcmp(argv[argi], "--nout")) { diff --git a/examples/arkode/C_serial/ark_heat1D.c b/examples/arkode/C_serial/ark_heat1D.c index a512054285..252d2123d5 100644 --- a/examples/arkode/C_serial/ark_heat1D.c +++ b/examples/arkode/C_serial/ark_heat1D.c @@ -47,7 +47,11 @@ #include /* defs. of sunrealtype, sunindextype, etc */ #include /* access to PCG SUNLinearSolver */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#define ESYM "Qe" +#define FSYM "Qf" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #define ESYM "Le" #define FSYM "Lf" @@ -179,13 +183,13 @@ int main(int argc, char* argv[]) tout = T0 + dTout; printf(" t ||u||_rms\n"); printf(" -------------------------\n"); - printf(" %10.6" FSYM " %10.6f\n", t, sqrt(N_VDotProd(y, y) / N)); + printf(" %10.6" FSYM " %10.6" FSYM "\n", t, SUNRsqrt(N_VDotProd(y, y) / N)); for (iout = 0; iout < Nt; iout++) { flag = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ if (check_flag(&flag, "ARKodeEvolve", 1)) { break; } - printf(" %10.6" FSYM " %10.6f\n", t, - sqrt(N_VDotProd(y, y) / N)); /* print solution stats */ + printf(" %10.6" FSYM " %10.6" FSYM "\n", t, + SUNRsqrt(N_VDotProd(y, y) / N)); /* print solution stats */ if (flag >= 0) { /* successful solve: update output time */ tout += dTout; @@ -307,12 +311,12 @@ static int Jac(N_Vector v, N_Vector Jv, sunrealtype t, N_Vector y, N_Vector fy, /* iterate over domain, computing all Jacobian-vector products */ c1 = k / dx / dx; c2 = -SUN_RCONST(2.0) * k / dx / dx; - JV[0] = 0.0; + JV[0] = SUN_RCONST(0.0); for (i = 1; i < N - 1; i++) { JV[i] = c1 * V[i - 1] + c2 * V[i] + c1 * V[i + 1]; } - JV[N - 1] = 0.0; + JV[N - 1] = SUN_RCONST(0.0); return 0; /* Return with success */ } diff --git a/examples/arkode/C_serial/ark_heat1D_adapt.c b/examples/arkode/C_serial/ark_heat1D_adapt.c index f434d50326..3e4cbe437f 100644 --- a/examples/arkode/C_serial/ark_heat1D_adapt.c +++ b/examples/arkode/C_serial/ark_heat1D_adapt.c @@ -47,7 +47,10 @@ #include /* defs. of sunrealtype, sunindextype, etc */ #include /* access to PCG SUNLinearSolver */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#define ESYM "Qe" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #define ESYM "Le" #else @@ -199,8 +202,9 @@ int main(void) "||u||_rms N NNI NLI\n"); printf(" --------------------------------------------------------------------" "--------------------\n"); - printf(" %4i %19.15" ESYM " %19.15" ESYM " %19.15e %li %2i %3i\n", - iout, olddt, newdt, sqrt(N_VDotProd(y, y) / udata->N), + printf(" %4i %19.15" ESYM " %19.15" ESYM " %19.15" ESYM + " %li %2i %3i\n", + iout, olddt, newdt, SUNRsqrt(N_VDotProd(y, y) / udata->N), (long int)udata->N, 0, 0); while (t < Tf) { @@ -224,8 +228,9 @@ int main(void) /* print current solution stats */ iout++; - printf(" %4i %19.15" ESYM " %19.15" ESYM " %19.15e %li %2li %3li\n", - iout, olddt, newdt, sqrt(N_VDotProd(y, y) / udata->N), + printf(" %4i %19.15" ESYM " %19.15" ESYM " %19.15" ESYM + " %li %2li %3li\n", + iout, olddt, newdt, SUNRsqrt(N_VDotProd(y, y) / udata->N), (long int)udata->N, nni, nli); nni_tot += nni; nli_tot += nli; @@ -330,10 +335,10 @@ static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) Ydot[i] = Y[i - 1] * k * TWO / (dxL * (dxL + dxR)) - Y[i] * k * TWO / (dxL * dxR) + Y[i + 1] * k * TWO / (dxR * (dxL + dxR)) + - TWO * exp(-TWOHUNDRED * (x[i] - PT25) * (x[i] - PT25)) /* source term */ - - exp(-FOURHUNDRED * (x[i] - PT7) * (x[i] - PT7)) + - exp(-FIVEHUNDRED * (x[i] - PT4) * (x[i] - PT4)) - - TWO * exp(-SIXHUNDRED * (x[i] - PT55) * (x[i] - PT55)); + TWO * SUNRexp(-TWOHUNDRED * (x[i] - PT25) * (x[i] - PT25)) /* source term */ + - SUNRexp(-FOURHUNDRED * (x[i] - PT7) * (x[i] - PT7)) + + SUNRexp(-FIVEHUNDRED * (x[i] - PT4) * (x[i] - PT4)) - + TWO * SUNRexp(-SIXHUNDRED * (x[i] - PT55) * (x[i] - PT55)); } return 0; /* Return with success */ diff --git a/examples/arkode/C_serial/ark_kpr_mri.c b/examples/arkode/C_serial/ark_kpr_mri.c index 7d861de5a8..a4f42883d8 100644 --- a/examples/arkode/C_serial/ark_kpr_mri.c +++ b/examples/arkode/C_serial/ark_kpr_mri.c @@ -94,28 +94,11 @@ #include /* dense linear solver */ #include /* dense matrix type, fcts., macros */ -/* Convenience macros for calling precision-specific math functions */ -#if defined(SUNDIALS_DOUBLE_PRECISION) -#define CEIL(x) (ceil((x))) -#define COS(x) (cos((x))) -#define FABS(x) (fabs((x))) -#define SIN(x) (sin((x))) -#define SQRT(x) (sqrt((x))) -#elif defined(SUNDIALS_SINGLE_PRECISION) -#define CEIL(x) (ceilf((x))) -#define COS(x) (cosf((x))) -#define FABS(x) (fabsf((x))) -#define SIN(x) (sinf((x))) -#define SQRT(x) (sqrtf((x))) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM ".20Qg" +#define ESYM "Qe" +#define FSYM "Qf" #elif defined(SUNDIALS_EXTENDED_PRECISION) -#define CEIL(x) (ceill((x))) -#define COS(x) (cosl((x))) -#define FABS(x) (fabsl((x))) -#define SIN(x) (sinl((x))) -#define SQRT(x) (sqrtl((x))) -#endif - -#if defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM ".20Lg" #define ESYM "Le" #define FSYM "Lf" @@ -161,17 +144,17 @@ int main(int argc, char* argv[]) SUNContext ctx; /* general problem parameters */ - sunrealtype T0 = SUN_RCONST(0.0); /* initial time */ - sunrealtype Tf = SUN_RCONST(5.0); /* final time */ - sunrealtype dTout = SUN_RCONST(0.1); /* time between outputs */ - sunindextype NEQ = 2; /* number of dependent vars. */ - int Nt = (int)CEIL(Tf / dTout); /* number of output times */ - int slow_type = 0; /* problem configuration type */ - int fast_type = 0; /* problem configuration type */ - sunrealtype hs = SUN_RCONST(0.01); /* slow step size */ - sunrealtype e = SUN_RCONST(0.5); /* fast/slow coupling strength */ - sunrealtype G = SUN_RCONST(-100.0); /* stiffness at slow time scale */ - sunrealtype w = SUN_RCONST(100.0); /* time-scale separation factor */ + sunrealtype T0 = SUN_RCONST(0.0); /* initial time */ + sunrealtype Tf = SUN_RCONST(5.0); /* final time */ + sunrealtype dTout = SUN_RCONST(0.1); /* time between outputs */ + sunindextype NEQ = 2; /* number of dependent vars. */ + int Nt = (int)SUNRceil(Tf / dTout); /* number of output times */ + int slow_type = 0; /* problem configuration type */ + int fast_type = 0; /* problem configuration type */ + sunrealtype hs = SUN_RCONST(0.01); /* slow step size */ + sunrealtype e = SUN_RCONST(0.5); /* fast/slow coupling strength */ + sunrealtype G = SUN_RCONST(-100.0); /* stiffness at slow time scale */ + sunrealtype w = SUN_RCONST(100.0); /* time-scale separation factor */ sunrealtype reltol = SUN_RCONST(0.01); sunrealtype abstol = SUN_RCONST(1.0e-11); @@ -260,7 +243,7 @@ int main(int argc, char* argv[]) printf("ERROR: hs must be in positive\n"); return (-1); } - if ((hs > ONE / FABS(G)) && (!implicit_slow)) + if ((hs > ONE / SUNRabs(G)) && (!implicit_slow)) { printf("ERROR: hs must be in (0, 1/|G|)\n"); return (-1); @@ -476,8 +459,8 @@ int main(int argc, char* argv[]) case (1): B = ARKodeButcherTable_Alloc(3, SUNFALSE); if (check_retval((void*)B, "ARKodeButcherTable_Alloc", 0)) { return 1; } - beta = SQRT(SUN_RCONST(3.0)) / SUN_RCONST(6.0) + SUN_RCONST(0.5); - gamma = (-ONE / SUN_RCONST(8.0)) * (SQRT(SUN_RCONST(3.0)) + ONE); + beta = SUNRsqrt(SUN_RCONST(3.0)) / SUN_RCONST(6.0) + SUN_RCONST(0.5); + gamma = (-ONE / SUN_RCONST(8.0)) * (SUNRsqrt(SUN_RCONST(3.0)) + ONE); B->A[1][0] = SUN_RCONST(4.0) * gamma + TWO * beta; B->A[1][1] = ONE - SUN_RCONST(4.0) * gamma - TWO * beta; B->A[2][0] = SUN_RCONST(0.5) - beta - gamma; @@ -559,7 +542,7 @@ int main(int argc, char* argv[]) if (check_retval(&retval, "ARKodeSetOptions", 1)) { return 1; } /* Create inner stepper */ - retval = ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); + retval = ARKStepCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); if (check_retval(&retval, "ARKodeCreateMRIStepInnerStepper", 1)) { return 1; } /* @@ -725,8 +708,8 @@ int main(int argc, char* argv[]) fprintf(UFID, " %.16" ESYM " %.16" ESYM " %.16" ESYM " %.16" ESYM " %.16" ESYM "\n", T0, NV_Ith_S(y, 0), NV_Ith_S(y, 1), - FABS(NV_Ith_S(y, 0) - utrue(T0, rpar)), - FABS(NV_Ith_S(y, 1) - vtrue(T0, rpar))); + SUNRabs(NV_Ith_S(y, 0) - utrue(T0, rpar)), + SUNRabs(NV_Ith_S(y, 1) - vtrue(T0, rpar))); /* Main time-stepping loop: calls ARKodeEvolve to perform the integration, then prints results. Stops when the final time @@ -751,8 +734,8 @@ int main(int argc, char* argv[]) if (check_retval(&retval, "ARKodeEvolve", 1)) { break; } /* access/print solution and error */ - uerr = FABS(NV_Ith_S(y, 0) - utrue(t, rpar)); - verr = FABS(NV_Ith_S(y, 1) - vtrue(t, rpar)); + uerr = SUNRabs(NV_Ith_S(y, 0) - utrue(t, rpar)); + verr = SUNRabs(NV_Ith_S(y, 1) - vtrue(t, rpar)); printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %.2" ESYM " %.2" ESYM "\n", t, NV_Ith_S(y, 0), NV_Ith_S(y, 1), uerr, verr); @@ -767,9 +750,9 @@ int main(int argc, char* argv[]) tout += dTout; tout = (tout > Tf) ? Tf : tout; } - uerrtot = SQRT(uerrtot / Nt); - verrtot = SQRT(verrtot / Nt); - errtot = SQRT(errtot / Nt / 2); + uerrtot = SUNRsqrt(uerrtot / Nt); + verrtot = SUNRsqrt(verrtot / Nt); + errtot = SUNRsqrt(errtot / Nt / 2); printf(" ------------------------------------------------------\n"); fclose(UFID); @@ -1049,34 +1032,34 @@ static int Jf(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, static sunrealtype r(sunrealtype t, void* user_data) { - return (SUN_RCONST(0.5) * COS(t)); + return (SUN_RCONST(0.5) * SUNRcos(t)); } static sunrealtype s(sunrealtype t, void* user_data) { sunrealtype* rpar = (sunrealtype*)user_data; - return (COS(rpar[1] * t)); + return (SUNRcos(rpar[1] * t)); } static sunrealtype rdot(sunrealtype t, void* user_data) { - return (-SUN_RCONST(0.5) * SIN(t)); + return (-SUN_RCONST(0.5) * SUNRsin(t)); } static sunrealtype sdot(sunrealtype t, void* user_data) { sunrealtype* rpar = (sunrealtype*)user_data; - return (-rpar[1] * SIN(rpar[1] * t)); + return (-rpar[1] * SUNRsin(rpar[1] * t)); } static sunrealtype utrue(sunrealtype t, void* user_data) { - return (SQRT(ONE + r(t, user_data))); + return (SUNRsqrt(ONE + r(t, user_data))); } static sunrealtype vtrue(sunrealtype t, void* user_data) { - return (SQRT(TWO + s(t, user_data))); + return (SUNRsqrt(TWO + s(t, user_data))); } static int Ytrue(sunrealtype t, N_Vector y, void* user_data) diff --git a/examples/arkode/C_serial/ark_lotka_volterra_ASA.c b/examples/arkode/C_serial/ark_lotka_volterra_ASA.c index b72c8386c2..af86e9dff6 100644 --- a/examples/arkode/C_serial/ark_lotka_volterra_ASA.c +++ b/examples/arkode/C_serial/ark_lotka_volterra_ASA.c @@ -115,7 +115,7 @@ int main(int argc, char* argv[]) const sunrealtype dt = args.dt; sunrealtype t0 = SUN_RCONST(0.0); sunrealtype tf = args.tf; - const int nsteps = (int)ceil(((tf - t0) / dt)); + const int nsteps = (int)SUNRceil(((tf - t0) / dt)); const int order = args.order; void* arkode_mem = ARKStepCreate(lotka_volterra, NULL, t0, u, sunctx); diff --git a/examples/arkode/C_serial/ark_onewaycouple_mri.c b/examples/arkode/C_serial/ark_onewaycouple_mri.c index cb5f71d65e..d7c1fff18e 100644 --- a/examples/arkode/C_serial/ark_onewaycouple_mri.c +++ b/examples/arkode/C_serial/ark_onewaycouple_mri.c @@ -51,7 +51,11 @@ #include #include /* def. of type 'sunrealtype' */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#define ESYM "Qe" +#define FSYM "Qf" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #define ESYM "Le" #define FSYM "Lf" @@ -300,9 +304,10 @@ static int ans(sunrealtype t, N_Vector ytrue, void* user_data) sunrealtype c4 = SUN_RCONST(51.0) / SUN_RCONST(2501.0); /* fill in the solution vector */ - NV_Ith_S(ytrue, 0) = cos(c1 * t); - NV_Ith_S(ytrue, 1) = sin(c1 * t); - NV_Ith_S(ytrue, 2) = c2 * exp(-t) - c3 * cos(c1 * t) + c4 * sin(c1 * t); + NV_Ith_S(ytrue, 0) = SUNRcos(c1 * t); + NV_Ith_S(ytrue, 1) = SUNRsin(c1 * t); + NV_Ith_S(ytrue, 2) = c2 * SUNRexp(-t) - c3 * SUNRcos(c1 * t) + + c4 * SUNRsin(c1 * t); /* Return with success */ return 0; diff --git a/examples/arkode/C_serial/ark_reaction_diffusion_mri.c b/examples/arkode/C_serial/ark_reaction_diffusion_mri.c index d8b78adffc..4bbd2bc004 100644 --- a/examples/arkode/C_serial/ark_reaction_diffusion_mri.c +++ b/examples/arkode/C_serial/ark_reaction_diffusion_mri.c @@ -52,7 +52,11 @@ #include #include /* defs. of sunrealtype, sunindextype, etc */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#define ESYM "Qe" +#define FSYM "Qf" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #define ESYM "Le" #define FSYM "Lf" @@ -209,7 +213,7 @@ int main(void) tout = T0 + dTout; printf(" t ||u||_rms\n"); printf(" -------------------------\n"); - printf(" %10.6" FSYM " %10.6f\n", t, sqrt(N_VDotProd(y, y) / N)); + printf(" %10.6" FSYM " %10.6" FSYM "\n", t, SUNRsqrt(N_VDotProd(y, y) / N)); for (iout = 0; iout < Nt; iout++) { /* call integrator */ @@ -217,7 +221,7 @@ int main(void) if (check_retval(&retval, "ARKodeEvolve", 1)) { break; } /* print solution stats and output results to disk */ - printf(" %10.6" FSYM " %10.6f\n", t, sqrt(N_VDotProd(y, y) / N)); + printf(" %10.6" FSYM " %10.6" FSYM "\n", t, SUNRsqrt(N_VDotProd(y, y) / N)); for (i = 0; i < N; i++) { fprintf(UFID, " %.16" ESYM "", data[i]); } fprintf(UFID, "\n"); diff --git a/examples/arkode/C_serial/ark_robertson.c b/examples/arkode/C_serial/ark_robertson.c index c1cd368409..c22b468450 100644 --- a/examples/arkode/C_serial/ark_robertson.c +++ b/examples/arkode/C_serial/ark_robertson.c @@ -44,7 +44,10 @@ #include /* access to dense SUNLinearSolver */ #include /* access to dense SUNMatrix */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#define ESYM "Qe" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #define ESYM "Le" #else @@ -68,11 +71,11 @@ static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, int main(void) { /* general problem parameters */ - sunrealtype T0 = SUN_RCONST(0.0); /* initial time */ - sunrealtype Tf = SUN_RCONST(1.e11); /* final time */ - sunrealtype dTout = (Tf - T0) / 100; /* time between outputs */ - int Nt = (int)ceil(Tf / dTout); /* number of output times */ - sunindextype NEQ = 3; /* number of dependent vars. */ + sunrealtype T0 = SUN_RCONST(0.0); /* initial time */ + sunrealtype Tf = SUN_RCONST(1.e11); /* final time */ + sunrealtype dTout = (Tf - T0) / SUN_RCONST(100.0); /* time between outputs */ + int Nt = (int)SUNRceil(Tf / dTout); /* number of output times */ + sunindextype NEQ = 3; /* number of dependent vars. */ /* general problem variables */ int flag; /* reusable error-checking flag */ @@ -222,9 +225,10 @@ static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) sunrealtype w = NV_Ith_S(y, 2); /* Fill in ODE RHS function */ - NV_Ith_S(ydot, 0) = -0.04 * u + 1.e4 * v * w; - NV_Ith_S(ydot, 1) = 0.04 * u - 1.e4 * v * w - 3.e7 * v * v; - NV_Ith_S(ydot, 2) = 3.e7 * v * v; + NV_Ith_S(ydot, 0) = -SUN_RCONST(0.04) * u + SUN_RCONST(1.e4) * v * w; + NV_Ith_S(ydot, 1) = SUN_RCONST(0.04) * u - SUN_RCONST(1.e4) * v * w - + SUN_RCONST(3.e7) * v * v; + NV_Ith_S(ydot, 2) = SUN_RCONST(3.e7) * v * v; return 0; /* Return with success */ } @@ -238,15 +242,15 @@ static int Jac(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, SUNMatZero(J); /* initialize Jacobian to zero */ /* Fill in the Jacobian of the ODE RHS function */ - SM_ELEMENT_D(J, 0, 0) = -0.04; - SM_ELEMENT_D(J, 0, 1) = 1.e4 * w; - SM_ELEMENT_D(J, 0, 2) = 1.e4 * v; + SM_ELEMENT_D(J, 0, 0) = -SUN_RCONST(0.04); + SM_ELEMENT_D(J, 0, 1) = SUN_RCONST(1.e4) * w; + SM_ELEMENT_D(J, 0, 2) = SUN_RCONST(1.e4) * v; - SM_ELEMENT_D(J, 1, 0) = 0.04; - SM_ELEMENT_D(J, 1, 1) = -1.e4 * w - 6.e7 * v; - SM_ELEMENT_D(J, 1, 2) = -1.e4 * v; + SM_ELEMENT_D(J, 1, 0) = SUN_RCONST(0.04); + SM_ELEMENT_D(J, 1, 1) = -SUN_RCONST(1.e4) * w - SUN_RCONST(6.e7) * v; + SM_ELEMENT_D(J, 1, 2) = -SUN_RCONST(1.e4) * v; - SM_ELEMENT_D(J, 2, 1) = 6.e7 * v; + SM_ELEMENT_D(J, 2, 1) = SUN_RCONST(6.e7) * v; return 0; /* Return with success */ } diff --git a/examples/arkode/C_serial/ark_robertson_constraints.c b/examples/arkode/C_serial/ark_robertson_constraints.c index 81873fff5b..96eacf6ed4 100644 --- a/examples/arkode/C_serial/ark_robertson_constraints.c +++ b/examples/arkode/C_serial/ark_robertson_constraints.c @@ -45,7 +45,10 @@ #include /* access to dense SUNLinearSolver */ #include /* access to dense SUNMatrix */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#define ESYM "Qe" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #define ESYM "Le" #else @@ -71,11 +74,11 @@ int main(void) sunrealtype ONE = SUN_RCONST(1.0); /* general problem parameters */ - sunrealtype T0 = SUN_RCONST(0.0); /* initial time */ - sunrealtype Tf = SUN_RCONST(1.e11); /* final time */ - sunrealtype dTout = (Tf - T0) / 100; /* time between outputs */ - int Nt = (int)ceil(Tf / dTout); /* number of output times */ - sunindextype NEQ = 3; /* number of dependent vars. */ + sunrealtype T0 = SUN_RCONST(0.0); /* initial time */ + sunrealtype Tf = SUN_RCONST(1.e11); /* final time */ + sunrealtype dTout = (Tf - T0) / SUN_RCONST(100.); /* time between outputs */ + int Nt = (int)SUNRceil(Tf / dTout); /* number of output times */ + sunindextype NEQ = 3; /* number of dependent vars. */ /* general problem variables */ int flag; /* reusable error-checking flag */ @@ -264,9 +267,10 @@ static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) sunrealtype w = NV_Ith_S(y, 2); /* Fill in ODE RHS function */ - NV_Ith_S(ydot, 0) = -0.04 * u + 1.e4 * v * w; - NV_Ith_S(ydot, 1) = 0.04 * u - 1.e4 * v * w - 3.e7 * v * v; - NV_Ith_S(ydot, 2) = 3.e7 * v * v; + NV_Ith_S(ydot, 0) = -SUN_RCONST(0.04) * u + SUN_RCONST(1.e4) * v * w; + NV_Ith_S(ydot, 1) = SUN_RCONST(0.04) * u - SUN_RCONST(1.e4) * v * w - + SUN_RCONST(3.e7) * v * v; + NV_Ith_S(ydot, 2) = SUN_RCONST(3.e7) * v * v; return 0; /* Return with success */ } @@ -280,15 +284,15 @@ static int Jac(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, SUNMatZero(J); /* initialize Jacobian to zero */ /* Fill in the Jacobian of the ODE RHS function */ - SM_ELEMENT_D(J, 0, 0) = -0.04; - SM_ELEMENT_D(J, 0, 1) = 1.e4 * w; - SM_ELEMENT_D(J, 0, 2) = 1.e4 * v; + SM_ELEMENT_D(J, 0, 0) = -SUN_RCONST(0.04); + SM_ELEMENT_D(J, 0, 1) = SUN_RCONST(1.e4) * w; + SM_ELEMENT_D(J, 0, 2) = SUN_RCONST(1.e4) * v; - SM_ELEMENT_D(J, 1, 0) = 0.04; - SM_ELEMENT_D(J, 1, 1) = -1.e4 * w - 6.e7 * v; - SM_ELEMENT_D(J, 1, 2) = -1.e4 * v; + SM_ELEMENT_D(J, 1, 0) = SUN_RCONST(0.04); + SM_ELEMENT_D(J, 1, 1) = -SUN_RCONST(1.e4) * w - SUN_RCONST(6.e7) * v; + SM_ELEMENT_D(J, 1, 2) = -SUN_RCONST(1.e4) * v; - SM_ELEMENT_D(J, 2, 1) = 6.e7 * v; + SM_ELEMENT_D(J, 2, 1) = SUN_RCONST(6.e7) * v; return 0; /* Return with success */ } diff --git a/examples/arkode/C_serial/ark_robertson_root.c b/examples/arkode/C_serial/ark_robertson_root.c index d7d3cbadad..d15a45cbf9 100644 --- a/examples/arkode/C_serial/ark_robertson_root.c +++ b/examples/arkode/C_serial/ark_robertson_root.c @@ -47,7 +47,10 @@ #include /* access to dense SUNLinearSolver */ #include /* access to dense SUNMatrix */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#define ESYM "Qe" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #define ESYM "Le" #else @@ -271,9 +274,10 @@ static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) sunrealtype w = NV_Ith_S(y, 2); /* Fill in ODE RHS function */ - NV_Ith_S(ydot, 0) = -0.04 * u + 1.e4 * v * w; - NV_Ith_S(ydot, 1) = 0.04 * u - 1.e4 * v * w - 3.e7 * v * v; - NV_Ith_S(ydot, 2) = 3.e7 * v * v; + NV_Ith_S(ydot, 0) = -SUN_RCONST(0.04) * u + SUN_RCONST(1.e4) * v * w; + NV_Ith_S(ydot, 1) = SUN_RCONST(0.04) * u - SUN_RCONST(1.e4) * v * w - + SUN_RCONST(3.e7) * v * v; + NV_Ith_S(ydot, 2) = SUN_RCONST(3.e7) * v * v; return 0; /* Return with success */ } @@ -287,15 +291,15 @@ static int Jac(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, SUNMatZero(J); /* initialize Jacobian to zero */ /* Fill in the Jacobian of the ODE RHS function */ - SM_ELEMENT_D(J, 0, 0) = -0.04; - SM_ELEMENT_D(J, 0, 1) = 1.e4 * w; - SM_ELEMENT_D(J, 0, 2) = 1.e4 * v; + SM_ELEMENT_D(J, 0, 0) = -SUN_RCONST(0.04); + SM_ELEMENT_D(J, 0, 1) = SUN_RCONST(1.e4) * w; + SM_ELEMENT_D(J, 0, 2) = SUN_RCONST(1.e4) * v; - SM_ELEMENT_D(J, 1, 0) = 0.04; - SM_ELEMENT_D(J, 1, 1) = -1.e4 * w - 6.e7 * v; - SM_ELEMENT_D(J, 1, 2) = -1.e4 * v; + SM_ELEMENT_D(J, 1, 0) = SUN_RCONST(0.04); + SM_ELEMENT_D(J, 1, 1) = -SUN_RCONST(1.e4) * w - SUN_RCONST(6.e7) * v; + SM_ELEMENT_D(J, 1, 2) = -SUN_RCONST(1.e4) * v; - SM_ELEMENT_D(J, 2, 1) = 6.e7 * v; + SM_ELEMENT_D(J, 2, 1) = SUN_RCONST(6.e7) * v; return 0; /* Return with success */ } diff --git a/examples/arkode/C_serial/ark_twowaycouple_mri.c b/examples/arkode/C_serial/ark_twowaycouple_mri.c index 1cf39b46ff..ad71e907aa 100644 --- a/examples/arkode/C_serial/ark_twowaycouple_mri.c +++ b/examples/arkode/C_serial/ark_twowaycouple_mri.c @@ -42,7 +42,11 @@ #include #include /* def. of type 'sunrealtype' */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#define ESYM "Qe" +#define FSYM "Qf" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #define ESYM "Le" #define FSYM "Lf" @@ -63,14 +67,14 @@ static int check_retval(void* returnvalue, const char* funcname, int opt); int main(void) { /* general problem parameters */ - sunrealtype T0 = SUN_RCONST(0.0); /* initial time */ - sunrealtype Tf = SUN_RCONST(2.0); /* final time */ - sunrealtype dTout = SUN_RCONST(0.1); /* time between outputs */ - sunindextype NEQ = 3; /* number of dependent vars. */ - int Nt = (int)ceil(Tf / dTout); /* number of output times */ - sunrealtype hs = SUN_RCONST(0.001); /* slow step size */ - sunrealtype hf = SUN_RCONST(0.00002); /* fast step size */ - sunrealtype u0, v0, w0; /* initial conditions */ + sunrealtype T0 = SUN_RCONST(0.0); /* initial time */ + sunrealtype Tf = SUN_RCONST(2.0); /* final time */ + sunrealtype dTout = SUN_RCONST(0.1); /* time between outputs */ + sunindextype NEQ = 3; /* number of dependent vars. */ + int Nt = (int)SUNRceil(Tf / dTout); /* number of output times */ + sunrealtype hs = SUN_RCONST(0.001); /* slow step size */ + sunrealtype hf = SUN_RCONST(0.00002); /* fast step size */ + sunrealtype u0, v0, w0; /* initial conditions */ /* general problem variables */ int retval; /* reusable error-checking flag */ diff --git a/examples/cvode/CXX_parallel/cv_heat2D_p.cpp b/examples/cvode/CXX_parallel/cv_heat2D_p.cpp index ca190834a1..a3a2a39464 100644 --- a/examples/cvode/CXX_parallel/cv_heat2D_p.cpp +++ b/examples/cvode/CXX_parallel/cv_heat2D_p.cpp @@ -478,7 +478,7 @@ int main(int argc, char* argv[]) if (outproc) { cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << " Max error = " << maxerr << endl; } } @@ -753,8 +753,8 @@ static int f(sunrealtype t, N_Vector u, N_Vector f, void* user_data) sunrealtype bx = (udata->kx) * TWO * PI * PI; sunrealtype by = (udata->ky) * TWO * PI * PI; - sunrealtype sin_t_cos_t = sin(PI * t) * cos(PI * t); - sunrealtype cos_sqr_t = cos(PI * t) * cos(PI * t); + sunrealtype sin_t_cos_t = SUNRsin(PI * t) * SUNRcos(PI * t); + sunrealtype cos_sqr_t = SUNRcos(PI * t) * SUNRcos(PI * t); for (j = jstart; j < jend; j++) { @@ -763,11 +763,11 @@ static int f(sunrealtype t, N_Vector u, N_Vector f, void* user_data) x = (udata->is + i) * udata->dx; y = (udata->js + j) * udata->dy; - sin_sqr_x = sin(PI * x) * sin(PI * x); - sin_sqr_y = sin(PI * y) * sin(PI * y); + sin_sqr_x = SUNRsin(PI * x) * SUNRsin(PI * x); + sin_sqr_y = SUNRsin(PI * y) * SUNRsin(PI * y); - cos_sqr_x = cos(PI * x) * cos(PI * x); - cos_sqr_y = cos(PI * y) * cos(PI * y); + cos_sqr_x = SUNRcos(PI * x) * SUNRcos(PI * x); + cos_sqr_y = SUNRcos(PI * y) * SUNRcos(PI * y); farray[IDX(i, j, nx_loc)] = -TWO * PI * sin_sqr_x * sin_sqr_y * sin_t_cos_t - @@ -1425,7 +1425,7 @@ static int Solution(sunrealtype t, N_Vector u, UserData* udata) sunrealtype sin_sqr_x, sin_sqr_y; // Constants for computing solution - cos_sqr_t = cos(PI * t) * cos(PI * t); + cos_sqr_t = SUNRcos(PI * t) * SUNRcos(PI * t); // Initialize u to zero (handles boundary conditions) N_VConst(ZERO, u); @@ -1447,8 +1447,8 @@ static int Solution(sunrealtype t, N_Vector u, UserData* udata) x = (udata->is + i) * udata->dx; y = (udata->js + j) * udata->dy; - sin_sqr_x = sin(PI * x) * sin(PI * x); - sin_sqr_y = sin(PI * y) * sin(PI * y); + sin_sqr_x = SUNRsin(PI * x) * SUNRsin(PI * x); + sin_sqr_y = SUNRsin(PI * y) * SUNRsin(PI * y); uarray[IDX(i, j, udata->nx_loc)] = sin_sqr_x * sin_sqr_y * cos_sqr_t; } @@ -1550,7 +1550,7 @@ static int OpenOutput(UserData* udata) if (udata->output > 0 && outproc) { cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); if (udata->forcing) { cout << " t "; @@ -1600,7 +1600,7 @@ static int OpenOutput(UserData* udata) udata->uout.open(fname.str()); udata->uout << scientific; - udata->uout << setprecision(numeric_limits::digits10); + udata->uout << setprecision(SUN_DIGITS10); if (udata->forcing) { @@ -1611,7 +1611,7 @@ static int OpenOutput(UserData* udata) udata->eout.open(fname.str()); udata->eout << scientific; - udata->eout << setprecision(numeric_limits::digits10); + udata->eout << setprecision(SUN_DIGITS10); } } @@ -1638,7 +1638,7 @@ static int WriteOutput(sunrealtype t, N_Vector u, UserData* udata) } // Compute rms norm of the state - sunrealtype urms = sqrt(N_VDotProd(u, u) / udata->nx / udata->ny); + sunrealtype urms = SUNRsqrt(N_VDotProd(u, u) / udata->nx / udata->ny); // Output current status if (outproc) diff --git a/examples/cvode/CXX_parhyp/cv_heat2D_hypre_ls.cpp b/examples/cvode/CXX_parhyp/cv_heat2D_hypre_ls.cpp index 3b61f9e104..86fa091e05 100644 --- a/examples/cvode/CXX_parhyp/cv_heat2D_hypre_ls.cpp +++ b/examples/cvode/CXX_parhyp/cv_heat2D_hypre_ls.cpp @@ -552,7 +552,7 @@ int main(int argc, char* argv[]) if (outproc) { cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << " Max error = " << maxerr << endl; } } @@ -834,8 +834,8 @@ static int f(sunrealtype t, N_Vector u, N_Vector f, void* user_data) sunrealtype bx = (udata->kx) * TWO * PI * PI; sunrealtype by = (udata->ky) * TWO * PI * PI; - sunrealtype sin_t_cos_t = sin(PI * t) * cos(PI * t); - sunrealtype cos_sqr_t = cos(PI * t) * cos(PI * t); + sunrealtype sin_t_cos_t = SUNRsin(PI * t) * SUNRcos(PI * t); + sunrealtype cos_sqr_t = SUNRcos(PI * t) * SUNRcos(PI * t); for (j = jstart; j < jend; j++) { @@ -844,11 +844,11 @@ static int f(sunrealtype t, N_Vector u, N_Vector f, void* user_data) x = (udata->is + i) * udata->dx; y = (udata->js + j) * udata->dy; - sin_sqr_x = sin(PI * x) * sin(PI * x); - sin_sqr_y = sin(PI * y) * sin(PI * y); + sin_sqr_x = SUNRsin(PI * x) * SUNRsin(PI * x); + sin_sqr_y = SUNRsin(PI * y) * SUNRsin(PI * y); - cos_sqr_x = cos(PI * x) * cos(PI * x); - cos_sqr_y = cos(PI * y) * cos(PI * y); + cos_sqr_x = SUNRcos(PI * x) * SUNRcos(PI * x); + cos_sqr_y = SUNRcos(PI * y) * SUNRcos(PI * y); farray[IDX(i, j, nx_loc)] = -TWO * PI * sin_sqr_x * sin_sqr_y * sin_t_cos_t - @@ -1876,7 +1876,7 @@ static int OpenOutput(UserData* udata) if (udata->output > 0 && outproc) { cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); if (udata->forcing) { cout << " t "; @@ -1926,7 +1926,7 @@ static int OpenOutput(UserData* udata) udata->uout.open(fname.str()); udata->uout << scientific; - udata->uout << setprecision(numeric_limits::digits10); + udata->uout << setprecision(SUN_DIGITS10); if (udata->forcing) { @@ -1937,7 +1937,7 @@ static int OpenOutput(UserData* udata) udata->eout.open(fname.str()); udata->eout << scientific; - udata->eout << setprecision(numeric_limits::digits10); + udata->eout << setprecision(SUN_DIGITS10); } } diff --git a/examples/cvode/CXX_parhyp/cv_heat2D_hypre_pfmg.cpp b/examples/cvode/CXX_parhyp/cv_heat2D_hypre_pfmg.cpp index 993af3b972..b61d50e3a7 100644 --- a/examples/cvode/CXX_parhyp/cv_heat2D_hypre_pfmg.cpp +++ b/examples/cvode/CXX_parhyp/cv_heat2D_hypre_pfmg.cpp @@ -535,7 +535,7 @@ int main(int argc, char* argv[]) if (outproc) { cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << " Max error = " << maxerr << endl; } } @@ -2390,7 +2390,7 @@ static int OpenOutput(UserData* udata) if (udata->output > 0 && outproc) { cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); if (udata->forcing) { cout << " t "; @@ -2440,7 +2440,7 @@ static int OpenOutput(UserData* udata) udata->uout.open(fname.str()); udata->uout << scientific; - udata->uout << setprecision(numeric_limits::digits10); + udata->uout << setprecision(SUN_DIGITS10); if (udata->forcing) { @@ -2451,7 +2451,7 @@ static int OpenOutput(UserData* udata) udata->eout.open(fname.str()); udata->eout << scientific; - udata->eout << setprecision(numeric_limits::digits10); + udata->eout << setprecision(SUN_DIGITS10); } } diff --git a/examples/cvode/CXX_serial/cv_heat2D.cpp b/examples/cvode/CXX_serial/cv_heat2D.cpp index 84ddd5f007..b5ddb2a858 100644 --- a/examples/cvode/CXX_serial/cv_heat2D.cpp +++ b/examples/cvode/CXX_serial/cv_heat2D.cpp @@ -281,8 +281,7 @@ int main(int argc, char* argv[]) sunrealtype maxerr = N_VMaxNorm(e); - std::cout << std::scientific - << std::setprecision(std::numeric_limits::digits10) + std::cout << std::scientific << std::setprecision(SUN_DIGITS10) << " Max error = " << maxerr << std::endl; // -------------------- @@ -328,8 +327,8 @@ int f(sunrealtype t, N_Vector u, N_Vector f, void* user_data) const auto bx = kx * TWO * PI * PI; const auto by = ky * TWO * PI * PI; - const auto sin_t_cos_t = sin(PI * t) * cos(PI * t); - const auto cos_sqr_t = cos(PI * t) * cos(PI * t); + const auto sin_t_cos_t = SUNRsin(PI * t) * SUNRcos(PI * t); + const auto cos_sqr_t = SUNRcos(PI * t) * SUNRcos(PI * t); // Initialize RHS vector to zero (handles boundary conditions) N_VConst(ZERO, f); @@ -342,11 +341,11 @@ int f(sunrealtype t, N_Vector u, N_Vector f, void* user_data) auto x = i * dx; auto y = j * dy; - auto sin_sqr_x = sin(PI * x) * sin(PI * x); - auto sin_sqr_y = sin(PI * y) * sin(PI * y); + auto sin_sqr_x = SUNRsin(PI * x) * SUNRsin(PI * x); + auto sin_sqr_y = SUNRsin(PI * y) * SUNRsin(PI * y); - auto cos_sqr_x = cos(PI * x) * cos(PI * x); - auto cos_sqr_y = cos(PI * y) * cos(PI * y); + auto cos_sqr_x = SUNRcos(PI * x) * SUNRcos(PI * x); + auto cos_sqr_y = SUNRcos(PI * y) * SUNRcos(PI * y); // center, north, south, east, and west indices auto idx_c = i + j * nx; diff --git a/examples/cvode/CXX_serial/cv_heat2D.hpp b/examples/cvode/CXX_serial/cv_heat2D.hpp index 9bdbfdc168..759c543c56 100644 --- a/examples/cvode/CXX_serial/cv_heat2D.hpp +++ b/examples/cvode/CXX_serial/cv_heat2D.hpp @@ -28,8 +28,9 @@ #include // SUNDIALS types +#include //for macros of SUNRcos and SUNRsin #include -#include +#include // Common utility functions #include @@ -118,7 +119,7 @@ static int Solution(sunrealtype t, N_Vector u, UserData& udata) N_VConst(ONE, u); // Compute the true solution - auto cos_sqr_t = cos(PI * t) * cos(PI * t); + auto cos_sqr_t = SUNRcos(PI * t) * SUNRcos(PI * t); for (sunindextype j = 1; j < udata.ny - 1; j++) { @@ -127,8 +128,8 @@ static int Solution(sunrealtype t, N_Vector u, UserData& udata) auto x = i * udata.dx; auto y = j * udata.dy; - auto sin_sqr_x = sin(PI * x) * sin(PI * x); - auto sin_sqr_y = sin(PI * y) * sin(PI * y); + auto sin_sqr_x = SUNRsin(PI * x) * SUNRsin(PI * x); + auto sin_sqr_y = SUNRsin(PI * y) * SUNRsin(PI * y); auto idx = i + j * udata.nx; uarray[idx] = sin_sqr_x * sin_sqr_y * cos_sqr_t + ONE; @@ -248,8 +249,7 @@ static void PrintUserData(UserData& udata) static int OpenOutput(UserData& udata) { // Header for status output - std::cout << std::scientific - << std::setprecision(std::numeric_limits::digits10) + std::cout << std::scientific << std::setprecision(SUN_DIGITS10) << " t ||u||_rms " << " max error\n" << " ----------------------------------------------" @@ -270,12 +270,10 @@ static int OpenOutput(UserData& udata) // Open output streams for solution and error udata.uout.open("heat2d_solution.txt"); - udata.uout << std::scientific - << std::setprecision(std::numeric_limits::digits10); + udata.uout << std::scientific << std::setprecision(SUN_DIGITS10); udata.eout.open("heat2d_error.txt"); - udata.eout << std::scientific - << std::setprecision(std::numeric_limits::digits10); + udata.eout << std::scientific << std::setprecision(SUN_DIGITS10); } return 0; @@ -292,7 +290,7 @@ static int WriteOutput(sunrealtype t, N_Vector u, N_Vector e, UserData& udata) sunrealtype max = N_VMaxNorm(e); // Compute rms norm of the state - sunrealtype urms = sqrt(N_VDotProd(u, u) / udata.nx / udata.ny); + sunrealtype urms = SUNRsqrt(N_VDotProd(u, u) / udata.nx / udata.ny); // Output current status std::cout << std::setw(22) << t << std::setw(25) << urms << std::setw(25) diff --git a/examples/cvode/CXX_serial/cv_kpr.cpp b/examples/cvode/CXX_serial/cv_kpr.cpp index ff0aad9f79..e0f31b515d 100644 --- a/examples/cvode/CXX_serial/cv_kpr.cpp +++ b/examples/cvode/CXX_serial/cv_kpr.cpp @@ -123,7 +123,7 @@ int main(int argc, char* argv[]) // Output initial contion std::cout << std::scientific; - std::cout << std::setprecision(std::numeric_limits::digits10); + std::cout << std::setprecision(SUN_DIGITS10); std::cout << " t "; std::cout << " u "; std::cout << " v "; @@ -134,8 +134,8 @@ int main(int argc, char* argv[]) std::cout << std::setw(22) << tret << std::setw(25) << ydata[0] << std::setw(25) << ydata[1] << std::setw(25) - << std::abs(ydata[0] - utrue) << std::setw(25) - << std::abs(ydata[1] - vtrue) << std::endl; + << SUNRabs(ydata[0] - utrue) << std::setw(25) + << SUNRabs(ydata[1] - vtrue) << std::endl; // Advance in time for (int i = 0; i < opts.nout; i++) @@ -148,8 +148,8 @@ int main(int argc, char* argv[]) std::cout << std::setw(22) << tret << std::setw(25) << ydata[0] << std::setw(25) << ydata[1] << std::setw(25) - << std::abs(ydata[0] - utrue) << std::setw(25) - << std::abs(ydata[1] - vtrue) << std::endl; + << SUNRabs(ydata[0] - utrue) << std::setw(25) + << SUNRabs(ydata[1] - vtrue) << std::endl; // update output time tout += opts.dtout; diff --git a/examples/cvode/CXX_serial/cv_kpr.hpp b/examples/cvode/CXX_serial/cv_kpr.hpp index ef5dd77d84..8079d3e87e 100644 --- a/examples/cvode/CXX_serial/cv_kpr.hpp +++ b/examples/cvode/CXX_serial/cv_kpr.hpp @@ -28,6 +28,7 @@ #include // SUNDIALS types +#include //for macros of SUNRcos, SUNRsin and SUNRabs #include #include @@ -64,22 +65,22 @@ struct Options // ----------------------------------------------------------------------------- // Compute r(t) -inline sunrealtype r(sunrealtype t) { return HALF * cos(t); } +inline sunrealtype r(sunrealtype t) { return HALF * SUNRcos(t); } // Compute the derivative of r(t) -inline sunrealtype rdot(sunrealtype t) { return -HALF * sin(t); } +inline sunrealtype rdot(sunrealtype t) { return -HALF * SUNRsin(t); } // Compute s(t) -inline sunrealtype s(sunrealtype t) { return cos(TWENTY * t); } +inline sunrealtype s(sunrealtype t) { return SUNRcos(TWENTY * t); } // Compute the derivative of s(t) -inline sunrealtype sdot(sunrealtype t) { return -TWENTY * sin(TWENTY * t); } +inline sunrealtype sdot(sunrealtype t) { return -TWENTY * SUNRsin(TWENTY * t); } // Compute the true solution inline int true_sol(sunrealtype t, sunrealtype* u, sunrealtype* v) { - *u = sqrt(ONE + r(t)); - *v = sqrt(TWO + s(t)); + *u = SUNRsqrt(ONE + r(t)); + *v = SUNRsqrt(TWO + s(t)); return 0; } diff --git a/examples/cvode/C_mpimanyvector/cvDiurnal_kry_mpimanyvec.c b/examples/cvode/C_mpimanyvector/cvDiurnal_kry_mpimanyvec.c index 27a22100d1..d61b2f6ad4 100644 --- a/examples/cvode/C_mpimanyvector/cvDiurnal_kry_mpimanyvec.c +++ b/examples/cvode/C_mpimanyvector/cvDiurnal_kry_mpimanyvec.c @@ -70,12 +70,6 @@ #include /* definitions of sunrealtype, sunbooleantype */ #include /* access to SPGMR SUNLinearSolver */ -/* helpful macros */ - -#ifndef SQR -#define SQR(A) ((A) * (A)) -#endif - /* Problem Constants */ #define NVARS 2 /* number of species */ @@ -94,7 +88,7 @@ #define NOUT 12 /* number of output times */ #define TWOHR SUN_RCONST(7200.0) /* number of seconds in two hours */ #define HALFDAY SUN_RCONST(4.32e4) /* number of seconds in a half day */ -#define PI SUN_RCONST(3.1415926535898) /* pi */ +#define PI SUN_RCONST(3.141592653589793238462643383279502884197169) /* pi */ #define XMIN SUN_RCONST(0.0) /* grid boundaries in x */ #define XMAX SUN_RCONST(20.0) @@ -361,9 +355,9 @@ static void InitUserData(int my_pe, MPI_Comm comm, UserData data) data->om = PI / HALFDAY; data->dx = (XMAX - XMIN) / ((sunrealtype)(MX - 1)); data->dy = (YMAX - YMIN) / ((sunrealtype)(MY - 1)); - data->hdco = KH / SQR(data->dx); + data->hdco = KH / SUNSQR(data->dx); data->haco = VEL / (SUN_RCONST(2.0) * data->dx); - data->vdco = (SUN_RCONST(1.0) / SQR(data->dy)) * KV0; + data->vdco = (SUN_RCONST(1.0) / SUNSQR(data->dy)) * KV0; /* Set machine-related constants */ data->comm = comm; @@ -430,14 +424,14 @@ static void SetInitialProfiles(N_Vector u, UserData data) { jy = ly + (data->isuby) * MYSUB; y = YMIN + jy * (data->dy); - cy = SQR(SUN_RCONST(0.1) * (y - ymid)); - cy = SUN_RCONST(1.0) - cy + SUN_RCONST(0.5) * SQR(cy); + cy = SUNSQR(SUN_RCONST(0.1) * (y - ymid)); + cy = SUN_RCONST(1.0) - cy + SUN_RCONST(0.5) * SUNSQR(cy); for (lx = 0; lx < MXSUB; lx++) { jx = lx + (data->isubx) * MXSUB; x = XMIN + jx * (data->dx); - cx = SQR(SUN_RCONST(0.1) * (x - xmid)); - cx = SUN_RCONST(1.0) - cx + SUN_RCONST(0.5) * SQR(cx); + cx = SUNSQR(SUN_RCONST(0.1) * (x - xmid)); + cx = SUN_RCONST(1.0) - cx + SUN_RCONST(0.5) * SUNSQR(cx); c1data[offset] = C1_SCALE * cx * cy; c2data[offset] = C2_SCALE * cx * cy; offset++; @@ -488,7 +482,12 @@ static void PrintOutput(void* cvode_mem, int my_pe, MPI_Comm comm, N_Vector u, retval = CVodeGetLastStep(cvode_mem, &hu); check_retval(&retval, "CVodeGetLastStep", 1, my_pe); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("t = %.2Qe no. steps = %ld order = %d stepsize = %.2Qe\n", t, + nst, qu, hu); + printf("At bottom left: c1, c2 = %12.3Qe %12.3Qe \n", c1data[0], c2data[0]); + printf("At top right: c1, c2 = %12.3Qe %12.3Qe \n\n", tempu[0], tempu[1]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("t = %.2Le no. steps = %ld order = %d stepsize = %.2Le\n", t, nst, qu, hu); printf("At bottom left: c1, c2 = %12.3Le %12.3Le \n", c1data[0], c2data[0]); @@ -909,11 +908,11 @@ static void fcalc(sunrealtype t, N_Vector udot, UserData data) /* Set diurnal rate coefficients as functions of t, and save q4 in data block for use by preconditioner evaluation routine */ - s = sin((data->om) * t); + s = SUNRsin((data->om) * t); if (s > SUN_RCONST(0.0)) { - q3 = exp(-A3 / s); - q4coef = exp(-A4 / s); + q3 = SUNRexp(-A3 / s); + q4coef = SUNRexp(-A4 / s); } else { @@ -931,8 +930,8 @@ static void fcalc(sunrealtype t, N_Vector udot, UserData data) /* Set vertical diffusion coefficients at jy +- 1/2 */ ydn = YMIN + (jy - SUN_RCONST(0.5)) * (data->dy); yup = ydn + data->dy; - cydn = (data->vdco) * exp(SUN_RCONST(0.2) * ydn); - cyup = (data->vdco) * exp(SUN_RCONST(0.2) * yup); + cydn = (data->vdco) * SUNRexp(SUN_RCONST(0.2) * ydn); + cyup = (data->vdco) * SUNRexp(SUN_RCONST(0.2) * yup); /* Loop over x-direction */ for (lx = 0; lx < MXSUB; lx++) @@ -1037,8 +1036,8 @@ static int Precond(sunrealtype tn, N_Vector u, N_Vector fu, sunbooleantype jok, jy = ly + (data->isuby) * MYSUB; ydn = YMIN + (jy - SUN_RCONST(0.5)) * (data->dy); yup = ydn + (data->dy); - cydn = (data->vdco) * exp(SUN_RCONST(0.2) * ydn); - cyup = (data->vdco) * exp(SUN_RCONST(0.2) * yup); + cydn = (data->vdco) * SUNRexp(SUN_RCONST(0.2) * ydn); + cyup = (data->vdco) * SUNRexp(SUN_RCONST(0.2) * yup); diag = -(cydn + cyup + SUN_RCONST(2.0) * (data->hdco)); for (lx = 0; lx < MXSUB; lx++) { diff --git a/examples/cvode/C_mpimanyvector/cvDiurnal_kry_mpimanyvec.out b/examples/cvode/C_mpimanyvector/cvDiurnal_kry_mpimanyvec.out index 761d4006e9..6d15796faf 100644 --- a/examples/cvode/C_mpimanyvector/cvDiurnal_kry_mpimanyvec.out +++ b/examples/cvode/C_mpimanyvector/cvDiurnal_kry_mpimanyvec.out @@ -17,51 +17,51 @@ t = 2.16e+04 no. steps = 289 order = 4 stepsize = 2.96e+02 At bottom left: c1, c2 = 2.665e+07 2.993e+11 At top right: c1, c2 = 2.931e+07 3.313e+11 -t = 2.88e+04 no. steps = 330 order = 4 stepsize = 1.00e+02 +t = 2.88e+04 no. steps = 329 order = 4 stepsize = 1.35e+02 At bottom left: c1, c2 = 8.702e+06 3.380e+11 At top right: c1, c2 = 9.650e+06 3.751e+11 -t = 3.60e+04 no. steps = 371 order = 4 stepsize = 7.53e+01 +t = 3.60e+04 no. steps = 371 order = 4 stepsize = 6.46e+01 At bottom left: c1, c2 = 1.404e+04 3.387e+11 At top right: c1, c2 = 1.561e+04 3.765e+11 -t = 4.32e+04 no. steps = 442 order = 4 stepsize = 3.67e+02 -At bottom left: c1, c2 = 1.540e-09 3.382e+11 -At top right: c1, c2 = 1.086e-09 3.804e+11 +t = 4.32e+04 no. steps = 427 order = 4 stepsize = 3.20e+02 +At bottom left: c1, c2 = 1.436e-11 3.382e+11 +At top right: c1, c2 = -2.731e-11 3.804e+11 -t = 5.04e+04 no. steps = 455 order = 5 stepsize = 3.88e+02 -At bottom left: c1, c2 = -5.142e-12 3.358e+11 -At top right: c1, c2 = -1.575e-11 3.864e+11 +t = 5.04e+04 no. steps = 442 order = 5 stepsize = 6.04e+02 +At bottom left: c1, c2 = 1.462e-10 3.358e+11 +At top right: c1, c2 = 7.569e-11 3.864e+11 -t = 5.76e+04 no. steps = 469 order = 4 stepsize = 2.10e+02 -At bottom left: c1, c2 = -4.462e-07 3.320e+11 -At top right: c1, c2 = -4.738e-07 3.909e+11 +t = 5.76e+04 no. steps = 454 order = 5 stepsize = 3.56e+02 +At bottom left: c1, c2 = -5.097e-12 3.320e+11 +At top right: c1, c2 = 9.753e-13 3.909e+11 -t = 6.48e+04 no. steps = 484 order = 4 stepsize = 5.41e+02 -At bottom left: c1, c2 = 1.188e-10 3.313e+11 -At top right: c1, c2 = 4.248e-12 3.963e+11 +t = 6.48e+04 no. steps = 465 order = 5 stepsize = 6.35e+02 +At bottom left: c1, c2 = 2.361e-11 3.313e+11 +At top right: c1, c2 = -5.333e-11 3.963e+11 -t = 7.20e+04 no. steps = 498 order = 4 stepsize = 5.41e+02 -At bottom left: c1, c2 = -1.561e-11 3.330e+11 -At top right: c1, c2 = 3.527e-12 4.039e+11 +t = 7.20e+04 no. steps = 477 order = 5 stepsize = 6.35e+02 +At bottom left: c1, c2 = 3.889e-12 3.330e+11 +At top right: c1, c2 = -5.416e-13 4.039e+11 -t = 7.92e+04 no. steps = 511 order = 4 stepsize = 5.41e+02 -At bottom left: c1, c2 = 4.246e-11 3.334e+11 -At top right: c1, c2 = 4.577e-11 4.120e+11 +t = 7.92e+04 no. steps = 488 order = 5 stepsize = 6.35e+02 +At bottom left: c1, c2 = 5.977e-11 3.334e+11 +At top right: c1, c2 = 3.997e-12 4.120e+11 -t = 8.64e+04 no. steps = 524 order = 4 stepsize = 5.41e+02 -At bottom left: c1, c2 = 1.106e-10 3.352e+11 -At top right: c1, c2 = -2.106e-11 4.163e+11 +t = 8.64e+04 no. steps = 499 order = 5 stepsize = 6.35e+02 +At bottom left: c1, c2 = 4.942e-11 3.352e+11 +At top right: c1, c2 = -1.352e-11 4.163e+11 Final Statistics: lenrw = 2689 leniw = 248 lenrwls = 2454 leniwls = 222 -nst = 524 -nfe = 660 nfels = 1250 -nni = 657 nli = 1250 -nsetups = 92 netf = 28 -npe = 9 nps = 1801 -ncfn = 0 ncfl = 1 +nst = 499 +nfe = 624 nfels = 1144 +nni = 621 nli = 1144 +nsetups = 85 netf = 25 +npe = 9 nps = 1667 +ncfn = 0 ncfl = 0 diff --git a/examples/cvode/C_openmp/cvAdvDiff_bnd_omp.c b/examples/cvode/C_openmp/cvAdvDiff_bnd_omp.c index 293cfebc07..45d2d0cdfe 100644 --- a/examples/cvode/C_openmp/cvAdvDiff_bnd_omp.c +++ b/examples/cvode/C_openmp/cvAdvDiff_bnd_omp.c @@ -382,8 +382,8 @@ static void SetIC(N_Vector u, UserData data) y = j * dy; for (i = 1; i <= MX; i++) { - x = i * dx; - IJth(udata, i, j) = x * (XMAX - x) * y * (YMAX - y) * exp(FIVE * x * y); + x = i * dx; + IJth(udata, i, j) = x * (XMAX - x) * y * (YMAX - y) * SUNRexp(FIVE * x * y); } } } @@ -395,12 +395,12 @@ static void PrintHeader(sunrealtype reltol, sunrealtype abstol, sunrealtype umax printf("\n2-D Advection-Diffusion Equation\n"); printf("Mesh dimensions = %d X %d\n", MX, MY); printf("Total system size = %d\n", NEQ); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: reltol = %Qg abstol = %Qg\n\n", reltol, abstol); + printf("At t = %Qg max.norm(u) =%14.6Qe \n", T0, umax); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: reltol = %Lg abstol = %Lg\n\n", reltol, abstol); printf("At t = %Lg max.norm(u) =%14.6Le \n", T0, umax); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: reltol = %g abstol = %g\n\n", reltol, abstol); - printf("At t = %g max.norm(u) =%14.6e \n", T0, umax); #else printf("Tolerance parameters: reltol = %g abstol = %g\n\n", reltol, abstol); printf("At t = %g max.norm(u) =%14.6e \n", T0, umax); @@ -413,10 +413,10 @@ static void PrintHeader(sunrealtype reltol, sunrealtype abstol, sunrealtype umax static void PrintOutput(sunrealtype t, sunrealtype umax, long int nst) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("At t = %4.2Qf max.norm(u) =%14.6Qe nst = %4ld\n", t, umax, nst); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("At t = %4.2Lf max.norm(u) =%14.6Le nst = %4ld\n", t, umax, nst); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("At t = %4.2f max.norm(u) =%14.6e nst = %4ld\n", t, umax, nst); #else printf("At t = %4.2f max.norm(u) =%14.6e nst = %4ld\n", t, umax, nst); #endif diff --git a/examples/cvode/C_openmpdev/cvAdvDiff_kry_ompdev.c b/examples/cvode/C_openmpdev/cvAdvDiff_kry_ompdev.c index 6da64b18d0..4d456f2e52 100644 --- a/examples/cvode/C_openmpdev/cvAdvDiff_kry_ompdev.c +++ b/examples/cvode/C_openmpdev/cvAdvDiff_kry_ompdev.c @@ -46,7 +46,7 @@ #include /* OpenMPDEV N_Vector types, fcts., macros */ #include #include -#include /* definition of ABS and EXP */ +#include /* definition of SUNRexp */ #include /* definition of type sunrealtype */ #include /* access to SPGMR SUNLinearSolver */ diff --git a/examples/cvode/cuda/cvAdvDiff_kry_cuda_managed.cu b/examples/cvode/cuda/cvAdvDiff_kry_cuda_managed.cu index a528cb3150..b364b0beae 100644 --- a/examples/cvode/cuda/cvAdvDiff_kry_cuda_managed.cu +++ b/examples/cvode/cuda/cvAdvDiff_kry_cuda_managed.cu @@ -46,7 +46,7 @@ #include #include #include -#include /* definition of ABS and EXP */ +#include /* definition of SUNRexp */ #include /* definition of type sunrealtype */ #include /* access to SPGMR SUNLinearSolver */ diff --git a/examples/cvode/ginkgo/cv_heat2D_ginkgo.cpp b/examples/cvode/ginkgo/cv_heat2D_ginkgo.cpp index 3a0653c62e..0cbc638f3a 100644 --- a/examples/cvode/ginkgo/cv_heat2D_ginkgo.cpp +++ b/examples/cvode/ginkgo/cv_heat2D_ginkgo.cpp @@ -263,8 +263,7 @@ int main(int argc, char* argv[]) sunrealtype maxerr = N_VMaxNorm(e); - std::cout << std::scientific - << std::setprecision(std::numeric_limits::digits10) + std::cout << std::scientific << std::setprecision(SUN_DIGITS10) << "\nMax error = " << maxerr << std::endl; // -------------------- diff --git a/examples/cvode/ginkgo/cv_heat2D_ginkgo.hpp b/examples/cvode/ginkgo/cv_heat2D_ginkgo.hpp index 5b6eea2265..3150bbe2c3 100644 --- a/examples/cvode/ginkgo/cv_heat2D_ginkgo.hpp +++ b/examples/cvode/ginkgo/cv_heat2D_ginkgo.hpp @@ -308,8 +308,7 @@ static void PrintUserData(UserData& udata) static int OpenOutput(UserData& udata) { // Header for status output - std::cout << std::scientific - << std::setprecision(std::numeric_limits::digits10) + std::cout << std::scientific << std::setprecision(SUN_DIGITS10) << " t ||u||_rms " << " max error\n" << " ----------------------------------------------" @@ -330,12 +329,10 @@ static int OpenOutput(UserData& udata) // Open output streams for solution and error udata.uout.open("heat2d_solution.txt"); - udata.uout << std::scientific - << std::setprecision(std::numeric_limits::digits10); + udata.uout << std::scientific << std::setprecision(SUN_DIGITS10); udata.eout.open("heat2d_error.txt"); - udata.eout << std::scientific - << std::setprecision(std::numeric_limits::digits10); + udata.eout << std::scientific << std::setprecision(SUN_DIGITS10); } return 0; diff --git a/examples/cvode/ginkgo/cv_kpr_ginkgo.cpp b/examples/cvode/ginkgo/cv_kpr_ginkgo.cpp index 5154b6dd5a..01e12213c7 100644 --- a/examples/cvode/ginkgo/cv_kpr_ginkgo.cpp +++ b/examples/cvode/ginkgo/cv_kpr_ginkgo.cpp @@ -147,7 +147,7 @@ int main(int argc, char* argv[]) // Output initial contion std::cout << std::scientific; - std::cout << std::setprecision(std::numeric_limits::digits10); + std::cout << std::setprecision(SUN_DIGITS10); std::cout << " t "; std::cout << " u "; std::cout << " v "; @@ -158,8 +158,8 @@ int main(int argc, char* argv[]) std::cout << std::setw(22) << tret << std::setw(25) << ydata[0] << std::setw(25) << ydata[1] << std::setw(25) - << std::abs(ydata[0] - utrue) << std::setw(25) - << std::abs(ydata[1] - vtrue) << std::endl; + << SUNRabs(ydata[0] - utrue) << std::setw(25) + << SUNRabs(ydata[1] - vtrue) << std::endl; // Advance in time for (int i = 0; i < opts.nout; i++) @@ -172,8 +172,8 @@ int main(int argc, char* argv[]) std::cout << std::setw(22) << tret << std::setw(25) << ydata[0] << std::setw(25) << ydata[1] << std::setw(25) - << std::abs(ydata[0] - utrue) << std::setw(25) - << std::abs(ydata[1] - vtrue) << std::endl; + << SUNRabs(ydata[0] - utrue) << std::setw(25) + << SUNRabs(ydata[1] - vtrue) << std::endl; // update output time tout += opts.dtout; diff --git a/examples/cvode/parallel/cvAdvDiff_diag_p.c b/examples/cvode/parallel/cvAdvDiff_diag_p.c index 2b82a552dd..154902ba06 100644 --- a/examples/cvode/parallel/cvAdvDiff_diag_p.c +++ b/examples/cvode/parallel/cvAdvDiff_diag_p.c @@ -308,7 +308,7 @@ static void SetIC(N_Vector u, sunrealtype dx, sunindextype my_length, { iglobal = my_base + i; x = iglobal * dx; - udata[i - 1] = x * (XMAX - x) * exp(SUN_RCONST(2.0) * x); + udata[i - 1] = x * (XMAX - x) * SUNRexp(SUN_RCONST(2.0) * x); } } @@ -327,10 +327,10 @@ static void PrintIntro(int npes) static void PrintData(sunrealtype t, sunrealtype umax, long int nst) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("At t = %4.2Qf max.norm(u) =%14.6Qe nst =%4ld \n", t, umax, nst); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("At t = %4.2Lf max.norm(u) =%14.6Le nst =%4ld \n", t, umax, nst); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("At t = %4.2f max.norm(u) =%14.6e nst =%4ld \n", t, umax, nst); #else printf("At t = %4.2f max.norm(u) =%14.6e nst =%4ld \n", t, umax, nst); #endif diff --git a/examples/cvode/parallel/cvAdvDiff_non_p.c b/examples/cvode/parallel/cvAdvDiff_non_p.c index 57fcdc8c8f..9e5346d7c2 100644 --- a/examples/cvode/parallel/cvAdvDiff_non_p.c +++ b/examples/cvode/parallel/cvAdvDiff_non_p.c @@ -250,7 +250,7 @@ static void SetIC(N_Vector u, sunrealtype dx, sunindextype my_length, { iglobal = my_base + i; x = iglobal * dx; - udata[i - 1] = x * (XMAX - x) * exp(SUN_RCONST(2.0) * x); + udata[i - 1] = x * (XMAX - x) * SUNRexp(SUN_RCONST(2.0) * x); } } @@ -268,10 +268,10 @@ static void PrintIntro(int npes) static void PrintData(sunrealtype t, sunrealtype umax, long int nst) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("At t = %4.2Qf max.norm(u) =%14.6Qe nst =%4ld \n", t, umax, nst); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("At t = %4.2Lf max.norm(u) =%14.6Le nst =%4ld \n", t, umax, nst); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("At t = %4.2f max.norm(u) =%14.6e nst =%4ld \n", t, umax, nst); #else printf("At t = %4.2f max.norm(u) =%14.6e nst =%4ld \n", t, umax, nst); #endif diff --git a/examples/cvode/parallel/cvDiurnal_kry_bbd_p.c b/examples/cvode/parallel/cvDiurnal_kry_bbd_p.c index 50c5885e99..a5d0552911 100644 --- a/examples/cvode/parallel/cvDiurnal_kry_bbd_p.c +++ b/examples/cvode/parallel/cvDiurnal_kry_bbd_p.c @@ -71,12 +71,6 @@ #include /* definitions of sunrealtype, sunbooleantype */ #include /* access to SPGMR SUNLinearSolver */ -/* helpful macros */ - -#ifndef SQR -#define SQR(A) ((A) * (A)) -#endif - /* Problem Constants */ #define ZERO SUN_RCONST(0.0) @@ -97,7 +91,7 @@ #define NOUT 12 /* number of output times */ #define TWOHR SUN_RCONST(7200.0) /* number of seconds in two hours */ #define HALFDAY SUN_RCONST(4.32e4) /* number of seconds in a half day */ -#define PI SUN_RCONST(3.1415926535898) /* pi */ +#define PI SUN_RCONST(3.141592653589793238462643383279502884197169) /* pi */ #define XMIN ZERO /* grid boundaries in x */ #define XMAX SUN_RCONST(20.0) @@ -363,9 +357,9 @@ static void InitUserData(int my_pe, sunindextype local_N, MPI_Comm comm, data->om = PI / HALFDAY; data->dx = (XMAX - XMIN) / ((sunrealtype)(MX - 1)); data->dy = (YMAX - YMIN) / ((sunrealtype)(MY - 1)); - data->hdco = KH / SQR(data->dx); + data->hdco = KH / SUNSQR(data->dx); data->haco = VEL / (SUN_RCONST(2.0) * data->dx); - data->vdco = (SUN_RCONST(1.0) / SQR(data->dy)) * KV0; + data->vdco = (SUN_RCONST(1.0) / SUNSQR(data->dy)) * KV0; /* Set machine-related constants */ data->comm = comm; @@ -413,14 +407,14 @@ static void SetInitialProfiles(N_Vector u, UserData data) { jy = ly + isuby * MYSUB; y = YMIN + jy * dy; - cy = SQR(SUN_RCONST(0.1) * (y - ymid)); - cy = SUN_RCONST(1.0) - cy + SUN_RCONST(0.5) * SQR(cy); + cy = SUNSQR(SUN_RCONST(0.1) * (y - ymid)); + cy = SUN_RCONST(1.0) - cy + SUN_RCONST(0.5) * SUNSQR(cy); for (lx = 0; lx < MXSUB; lx++) { jx = lx + isubx * MXSUB; x = XMIN + jx * dx; - cx = SQR(SUN_RCONST(0.1) * (x - xmid)); - cx = SUN_RCONST(1.0) - cx + SUN_RCONST(0.5) * SQR(cx); + cx = SUNSQR(SUN_RCONST(0.1) * (x - xmid)); + cx = SUN_RCONST(1.0) - cx + SUN_RCONST(0.5) * SUNSQR(cx); uarray[offset] = C1_SCALE * cx * cy; uarray[offset + 1] = C2_SCALE * cx * cy; offset = offset + 2; @@ -485,16 +479,16 @@ static void PrintOutput(void* cvode_mem, int my_pe, MPI_Comm comm, N_Vector u, check_retval(&retval, "CVodeGetLastOrder", 1, my_pe); retval = CVodeGetLastStep(cvode_mem, &hu); check_retval(&retval, "CVodeGetLastStep", 1, my_pe); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("t = %.2Qe no. steps = %ld order = %d stepsize = %.2Qe\n", t, + nst, qu, hu); + printf("At bottom left: c1, c2 = %12.3Qe %12.3Qe \n", uarray[0], uarray[1]); + printf("At top right: c1, c2 = %12.3Qe %12.3Qe \n\n", tempu[0], tempu[1]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("t = %.2Le no. steps = %ld order = %d stepsize = %.2Le\n", t, nst, qu, hu); printf("At bottom left: c1, c2 = %12.3Le %12.3Le \n", uarray[0], uarray[1]); printf("At top right: c1, c2 = %12.3Le %12.3Le \n\n", tempu[0], tempu[1]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("t = %.2e no. steps = %ld order = %d stepsize = %.2e\n", t, - nst, qu, hu); - printf("At bottom left: c1, c2 = %12.3e %12.3e \n", uarray[0], uarray[1]); - printf("At top right: c1, c2 = %12.3e %12.3e \n\n", tempu[0], tempu[1]); #else printf("t = %.2e no. steps = %ld order = %d stepsize = %.2e\n", t, nst, qu, hu); @@ -876,11 +870,11 @@ static int flocal(sunindextype Nlocal, sunrealtype t, N_Vector u, N_Vector udot, /* Set diurnal rate coefficients as functions of t, and save q4 in data block for use by preconditioner evaluation routine */ - s = sin((data->om) * t); + s = SUNRsin((data->om) * t); if (s > ZERO) { - q3 = exp(-A3 / s); - q4coef = exp(-A4 / s); + q3 = SUNRexp(-A3 / s); + q4coef = SUNRexp(-A4 / s); } else { @@ -899,8 +893,8 @@ static int flocal(sunindextype Nlocal, sunrealtype t, N_Vector u, N_Vector udot, ydn = YMIN + (jy - SUN_RCONST(0.5)) * dely; yup = ydn + dely; - cydn = verdco * exp(SUN_RCONST(0.2) * ydn); - cyup = verdco * exp(SUN_RCONST(0.2) * yup); + cydn = verdco * SUNRexp(SUN_RCONST(0.2) * ydn); + cyup = verdco * SUNRexp(SUN_RCONST(0.2) * yup); for (lx = 0; lx < MXSUB; lx++) { /* Extract c1 and c2, and set kinetic rate terms */ diff --git a/examples/cvode/parallel/cvDiurnal_kry_bbd_p.out b/examples/cvode/parallel/cvDiurnal_kry_bbd_p.out index 80ef50f734..1d88606944 100644 --- a/examples/cvode/parallel/cvDiurnal_kry_bbd_p.out +++ b/examples/cvode/parallel/cvDiurnal_kry_bbd_p.out @@ -19,56 +19,56 @@ t = 2.16e+04 no. steps = 247 order = 5 stepsize = 3.00e+02 At bottom left: c1, c2 = 2.665e+07 2.993e+11 At top right: c1, c2 = 2.931e+07 3.313e+11 -t = 2.88e+04 no. steps = 272 order = 4 stepsize = 2.13e+02 +t = 2.88e+04 no. steps = 273 order = 5 stepsize = 1.42e+02 At bottom left: c1, c2 = 8.702e+06 3.380e+11 At top right: c1, c2 = 9.650e+06 3.751e+11 -t = 3.60e+04 no. steps = 311 order = 4 stepsize = 9.70e+01 +t = 3.60e+04 no. steps = 312 order = 4 stepsize = 7.17e+01 At bottom left: c1, c2 = 1.404e+04 3.387e+11 At top right: c1, c2 = 1.561e+04 3.765e+11 -t = 4.32e+04 no. steps = 368 order = 4 stepsize = 3.95e+02 -At bottom left: c1, c2 = 6.245e-08 3.382e+11 -At top right: c1, c2 = 7.023e-08 3.804e+11 +t = 4.32e+04 no. steps = 375 order = 4 stepsize = 3.40e+02 +At bottom left: c1, c2 = -7.157e-05 3.382e+11 +At top right: c1, c2 = -8.149e-05 3.804e+11 -t = 5.04e+04 no. steps = 388 order = 5 stepsize = 4.74e+02 -At bottom left: c1, c2 = 3.031e-07 3.358e+11 -At top right: c1, c2 = 3.340e-07 3.864e+11 +t = 5.04e+04 no. steps = 398 order = 4 stepsize = 3.54e+02 +At bottom left: c1, c2 = -3.568e-08 3.358e+11 +At top right: c1, c2 = -4.039e-08 3.864e+11 -t = 5.76e+04 no. steps = 401 order = 5 stepsize = 3.50e+02 -At bottom left: c1, c2 = 4.503e-11 3.320e+11 -At top right: c1, c2 = 1.065e-10 3.909e+11 +t = 5.76e+04 no. steps = 412 order = 5 stepsize = 3.51e+02 +At bottom left: c1, c2 = -5.103e-10 3.320e+11 +At top right: c1, c2 = -5.628e-10 3.909e+11 -t = 6.48e+04 no. steps = 418 order = 5 stepsize = 5.80e+02 -At bottom left: c1, c2 = -5.893e-09 3.313e+11 -At top right: c1, c2 = -1.672e-08 3.963e+11 +t = 6.48e+04 no. steps = 426 order = 5 stepsize = 5.46e+02 +At bottom left: c1, c2 = -1.226e-12 3.313e+11 +At top right: c1, c2 = -1.328e-12 3.963e+11 -t = 7.20e+04 no. steps = 430 order = 5 stepsize = 5.80e+02 -At bottom left: c1, c2 = -7.098e-11 3.330e+11 -At top right: c1, c2 = -2.001e-10 4.039e+11 +t = 7.20e+04 no. steps = 439 order = 5 stepsize = 5.46e+02 +At bottom left: c1, c2 = 4.130e-16 3.330e+11 +At top right: c1, c2 = 1.105e-16 4.039e+11 -t = 7.92e+04 no. steps = 443 order = 5 stepsize = 5.80e+02 -At bottom left: c1, c2 = 7.023e-13 3.334e+11 -At top right: c1, c2 = 1.967e-12 4.120e+11 +t = 7.92e+04 no. steps = 453 order = 5 stepsize = 5.46e+02 +At bottom left: c1, c2 = 3.929e-16 3.334e+11 +At top right: c1, c2 = 5.692e-16 4.120e+11 -t = 8.64e+04 no. steps = 455 order = 5 stepsize = 5.80e+02 -At bottom left: c1, c2 = 5.803e-14 3.352e+11 -At top right: c1, c2 = 1.602e-13 4.163e+11 +t = 8.64e+04 no. steps = 465 order = 5 stepsize = 8.19e+02 +At bottom left: c1, c2 = -4.318e-15 3.352e+11 +At top right: c1, c2 = -9.624e-15 4.163e+11 Final Statistics: lenrw = 2689 leniw = 144 lenrwls = 2454 leniwls = 126 -nst = 455 -nfe = 596 nfels = 531 -nni = 593 nli = 531 -nsetups = 83 netf = 30 -npe = 8 nps = 1066 +nst = 465 +nfe = 606 nfels = 533 +nni = 603 nli = 533 +nsetups = 85 netf = 32 +npe = 9 nps = 1081 ncfn = 0 ncfl = 0 In CVBBDPRE: real/integer local work space sizes = 1300, 192 - no. flocal evals. = 176 + no. flocal evals. = 198 ------------------------------------------------------------------- @@ -88,52 +88,52 @@ t = 2.16e+04 no. steps = 249 order = 5 stepsize = 4.31e+02 At bottom left: c1, c2 = 2.665e+07 2.993e+11 At top right: c1, c2 = 2.931e+07 3.313e+11 -t = 2.88e+04 no. steps = 309 order = 4 stepsize = 1.32e+02 +t = 2.88e+04 no. steps = 309 order = 4 stepsize = 1.33e+02 At bottom left: c1, c2 = 8.702e+06 3.380e+11 At top right: c1, c2 = 9.650e+06 3.751e+11 -t = 3.60e+04 no. steps = 342 order = 5 stepsize = 1.28e+02 +t = 3.60e+04 no. steps = 342 order = 5 stepsize = 9.78e+01 At bottom left: c1, c2 = 1.404e+04 3.387e+11 At top right: c1, c2 = 1.561e+04 3.765e+11 -t = 4.32e+04 no. steps = 393 order = 4 stepsize = 3.91e+02 -At bottom left: c1, c2 = 1.998e-09 3.382e+11 -At top right: c1, c2 = 2.210e-09 3.804e+11 +t = 4.32e+04 no. steps = 395 order = 4 stepsize = 3.88e+02 +At bottom left: c1, c2 = 1.592e-09 3.382e+11 +At top right: c1, c2 = 1.777e-09 3.804e+11 -t = 5.04e+04 no. steps = 406 order = 5 stepsize = 6.68e+02 -At bottom left: c1, c2 = 4.173e-11 3.358e+11 -At top right: c1, c2 = 4.509e-11 3.864e+11 +t = 5.04e+04 no. steps = 409 order = 5 stepsize = 4.22e+02 +At bottom left: c1, c2 = 1.346e-11 3.358e+11 +At top right: c1, c2 = 1.458e-11 3.864e+11 -t = 5.76e+04 no. steps = 421 order = 4 stepsize = 1.46e+02 -At bottom left: c1, c2 = 1.346e-13 3.320e+11 -At top right: c1, c2 = 1.429e-13 3.909e+11 +t = 5.76e+04 no. steps = 421 order = 5 stepsize = 4.51e+02 +At bottom left: c1, c2 = 5.778e-13 3.320e+11 +At top right: c1, c2 = 6.210e-13 3.909e+11 -t = 6.48e+04 no. steps = 436 order = 4 stepsize = 5.90e+02 -At bottom left: c1, c2 = 4.188e-18 3.313e+11 -At top right: c1, c2 = -4.796e-15 3.963e+11 +t = 6.48e+04 no. steps = 431 order = 5 stepsize = 7.50e+02 +At bottom left: c1, c2 = -1.460e-13 3.313e+11 +At top right: c1, c2 = -1.632e-13 3.963e+11 -t = 7.20e+04 no. steps = 448 order = 4 stepsize = 5.90e+02 -At bottom left: c1, c2 = -4.919e-18 3.330e+11 -At top right: c1, c2 = 8.770e-17 4.039e+11 +t = 7.20e+04 no. steps = 441 order = 5 stepsize = 7.50e+02 +At bottom left: c1, c2 = -7.013e-15 3.330e+11 +At top right: c1, c2 = -2.704e-15 4.039e+11 -t = 7.92e+04 no. steps = 460 order = 4 stepsize = 5.90e+02 -At bottom left: c1, c2 = 2.462e-20 3.334e+11 -At top right: c1, c2 = -2.599e-20 4.120e+11 +t = 7.92e+04 no. steps = 450 order = 5 stepsize = 7.50e+02 +At bottom left: c1, c2 = -8.873e-16 3.334e+11 +At top right: c1, c2 = 1.114e-17 4.120e+11 -t = 8.64e+04 no. steps = 472 order = 4 stepsize = 5.90e+02 -At bottom left: c1, c2 = 3.021e-23 3.352e+11 -At top right: c1, c2 = -3.233e-23 4.163e+11 +t = 8.64e+04 no. steps = 460 order = 5 stepsize = 7.50e+02 +At bottom left: c1, c2 = -1.289e-15 3.352e+11 +At top right: c1, c2 = 4.974e-18 4.163e+11 Final Statistics: lenrw = 2689 leniw = 144 lenrwls = 2454 leniwls = 126 -nst = 472 -nfe = 603 nfels = 758 -nni = 600 nli = 758 -nsetups = 94 netf = 29 -npe = 9 nps = 1257 +nst = 460 +nfe = 585 nfels = 732 +nni = 582 nli = 732 +nsetups = 89 netf = 27 +npe = 9 nps = 1218 ncfn = 0 ncfl = 0 In CVBBDPRE: real/integer local work space sizes = 1300, 192 diff --git a/examples/cvode/parallel/cvDiurnal_kry_p.c b/examples/cvode/parallel/cvDiurnal_kry_p.c index b6af788ec2..45ef87a54f 100644 --- a/examples/cvode/parallel/cvDiurnal_kry_p.c +++ b/examples/cvode/parallel/cvDiurnal_kry_p.c @@ -68,12 +68,6 @@ #include /* definitions of sunrealtype, sunbooleantype */ #include /* access to SPGMR SUNLinearSolver */ -/* helpful macros */ - -#ifndef SQR -#define SQR(A) ((A) * (A)) -#endif - /* Problem Constants */ #define NVARS 2 /* number of species */ @@ -92,7 +86,7 @@ #define NOUT 12 /* number of output times */ #define TWOHR SUN_RCONST(7200.0) /* number of seconds in two hours */ #define HALFDAY SUN_RCONST(4.32e4) /* number of seconds in a half day */ -#define PI SUN_RCONST(3.1415926535898) /* pi */ +#define PI SUN_RCONST(3.141592653589793238462643383279502884197169) /* pi */ #define XMIN SUN_RCONST(0.0) /* grid boundaries in x */ #define XMAX SUN_RCONST(20.0) @@ -332,9 +326,9 @@ static void InitUserData(int my_pe, MPI_Comm comm, UserData data) data->om = PI / HALFDAY; data->dx = (XMAX - XMIN) / ((sunrealtype)(MX - 1)); data->dy = (YMAX - YMIN) / ((sunrealtype)(MY - 1)); - data->hdco = KH / SQR(data->dx); + data->hdco = KH / SUNSQR(data->dx); data->haco = VEL / (SUN_RCONST(2.0) * data->dx); - data->vdco = (SUN_RCONST(1.0) / SQR(data->dy)) * KV0; + data->vdco = (SUN_RCONST(1.0) / SUNSQR(data->dy)) * KV0; /* Set machine-related constants */ data->comm = comm; @@ -409,14 +403,14 @@ static void SetInitialProfiles(N_Vector u, UserData data) { jy = ly + isuby * MYSUB; y = YMIN + jy * dy; - cy = SQR(SUN_RCONST(0.1) * (y - ymid)); - cy = SUN_RCONST(1.0) - cy + SUN_RCONST(0.5) * SQR(cy); + cy = SUNSQR(SUN_RCONST(0.1) * (y - ymid)); + cy = SUN_RCONST(1.0) - cy + SUN_RCONST(0.5) * SUNSQR(cy); for (lx = 0; lx < MXSUB; lx++) { jx = lx + isubx * MXSUB; x = XMIN + jx * dx; - cx = SQR(SUN_RCONST(0.1) * (x - xmid)); - cx = SUN_RCONST(1.0) - cx + SUN_RCONST(0.5) * SQR(cx); + cx = SUNSQR(SUN_RCONST(0.1) * (x - xmid)); + cx = SUN_RCONST(1.0) - cx + SUN_RCONST(0.5) * SUNSQR(cx); udata[offset] = C1_SCALE * cx * cy; udata[offset + 1] = C2_SCALE * cx * cy; offset = offset + 2; @@ -467,16 +461,16 @@ static void PrintOutput(void* cvode_mem, int my_pe, MPI_Comm comm, N_Vector u, retval = CVodeGetLastStep(cvode_mem, &hu); check_retval(&retval, "CVodeGetLastStep", 1, my_pe); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("t = %.2Qe no. steps = %ld order = %d stepsize = %.2Qe\n", t, + nst, qu, hu); + printf("At bottom left: c1, c2 = %12.3Qe %12.3Qe \n", udata[0], udata[1]); + printf("At top right: c1, c2 = %12.3Qe %12.3Qe \n\n", tempu[0], tempu[1]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("t = %.2Le no. steps = %ld order = %d stepsize = %.2Le\n", t, nst, qu, hu); printf("At bottom left: c1, c2 = %12.3Le %12.3Le \n", udata[0], udata[1]); printf("At top right: c1, c2 = %12.3Le %12.3Le \n\n", tempu[0], tempu[1]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("t = %.2e no. steps = %ld order = %d stepsize = %.2e\n", t, - nst, qu, hu); - printf("At bottom left: c1, c2 = %12.3e %12.3e \n", udata[0], udata[1]); - printf("At top right: c1, c2 = %12.3e %12.3e \n\n", tempu[0], tempu[1]); #else printf("t = %.2e no. steps = %ld order = %d stepsize = %.2e\n", t, nst, qu, hu); @@ -805,11 +799,11 @@ static void fcalc(sunrealtype t, sunrealtype udata[], sunrealtype dudata[], /* Set diurnal rate coefficients as functions of t, and save q4 in data block for use by preconditioner evaluation routine */ - s = sin((data->om) * t); + s = SUNRsin((data->om) * t); if (s > SUN_RCONST(0.0)) { - q3 = exp(-A3 / s); - q4coef = exp(-A4 / s); + q3 = SUNRexp(-A3 / s); + q4coef = SUNRexp(-A4 / s); } else { @@ -826,8 +820,8 @@ static void fcalc(sunrealtype t, sunrealtype udata[], sunrealtype dudata[], /* Set vertical diffusion coefficients at jy +- 1/2 */ ydn = YMIN + (jy - SUN_RCONST(0.5)) * dely; yup = ydn + dely; - cydn = verdco * exp(SUN_RCONST(0.2) * ydn); - cyup = verdco * exp(SUN_RCONST(0.2) * yup); + cydn = verdco * SUNRexp(SUN_RCONST(0.2) * ydn); + cyup = verdco * SUNRexp(SUN_RCONST(0.2) * yup); for (lx = 0; lx < MXSUB; lx++) { /* Extract c1 and c2, and set kinetic rate terms */ @@ -944,8 +938,8 @@ static int Precond(sunrealtype tn, N_Vector u, N_Vector fu, sunbooleantype jok, jy = ly + isuby * MYSUB; ydn = YMIN + (jy - SUN_RCONST(0.5)) * dely; yup = ydn + dely; - cydn = verdco * exp(SUN_RCONST(0.2) * ydn); - cyup = verdco * exp(SUN_RCONST(0.2) * yup); + cydn = verdco * SUNRexp(SUN_RCONST(0.2) * ydn); + cyup = verdco * SUNRexp(SUN_RCONST(0.2) * yup); diag = -(cydn + cyup + SUN_RCONST(2.0) * hordco); for (lx = 0; lx < MXSUB; lx++) { diff --git a/examples/cvode/parallel/cvDiurnal_kry_p.out b/examples/cvode/parallel/cvDiurnal_kry_p.out index 9639084c30..e99b0f7985 100644 --- a/examples/cvode/parallel/cvDiurnal_kry_p.out +++ b/examples/cvode/parallel/cvDiurnal_kry_p.out @@ -13,51 +13,51 @@ t = 2.16e+04 no. steps = 277 order = 5 stepsize = 2.75e+02 At bottom left: c1, c2 = 2.665e+07 2.993e+11 At top right: c1, c2 = 2.931e+07 3.313e+11 -t = 2.88e+04 no. steps = 316 order = 4 stepsize = 1.51e+02 +t = 2.88e+04 no. steps = 326 order = 3 stepsize = 8.13e+01 At bottom left: c1, c2 = 8.702e+06 3.380e+11 At top right: c1, c2 = 9.650e+06 3.751e+11 -t = 3.60e+04 no. steps = 355 order = 4 stepsize = 7.19e+01 +t = 3.60e+04 no. steps = 389 order = 4 stepsize = 1.02e+02 At bottom left: c1, c2 = 1.404e+04 3.387e+11 At top right: c1, c2 = 1.561e+04 3.765e+11 -t = 4.32e+04 no. steps = 416 order = 4 stepsize = 3.62e+02 -At bottom left: c1, c2 = -1.316e-07 3.382e+11 -At top right: c1, c2 = -1.475e-07 3.804e+11 +t = 4.32e+04 no. steps = 448 order = 4 stepsize = 4.89e+02 +At bottom left: c1, c2 = -9.142e-07 3.382e+11 +At top right: c1, c2 = -9.439e-07 3.804e+11 -t = 5.04e+04 no. steps = 430 order = 5 stepsize = 6.16e+02 -At bottom left: c1, c2 = -3.937e-07 3.358e+11 -At top right: c1, c2 = -4.373e-07 3.864e+11 +t = 5.04e+04 no. steps = 464 order = 4 stepsize = 3.31e+02 +At bottom left: c1, c2 = -2.154e-08 3.358e+11 +At top right: c1, c2 = -4.243e-08 3.864e+11 -t = 5.76e+04 no. steps = 442 order = 5 stepsize = 4.00e+02 -At bottom left: c1, c2 = -4.342e-10 3.320e+11 -At top right: c1, c2 = -4.873e-10 3.909e+11 +t = 5.76e+04 no. steps = 478 order = 5 stepsize = 4.28e+02 +At bottom left: c1, c2 = -6.204e-09 3.320e+11 +At top right: c1, c2 = -9.573e-09 3.909e+11 -t = 6.48e+04 no. steps = 453 order = 5 stepsize = 6.52e+02 -At bottom left: c1, c2 = 2.031e-10 3.313e+11 -At top right: c1, c2 = 2.236e-10 3.963e+11 +t = 6.48e+04 no. steps = 488 order = 5 stepsize = 7.33e+02 +At bottom left: c1, c2 = -5.614e-09 3.313e+11 +At top right: c1, c2 = -8.664e-09 3.963e+11 -t = 7.20e+04 no. steps = 465 order = 5 stepsize = 6.52e+02 -At bottom left: c1, c2 = -2.118e-12 3.330e+11 -At top right: c1, c2 = -2.335e-12 4.039e+11 +t = 7.20e+04 no. steps = 498 order = 5 stepsize = 7.33e+02 +At bottom left: c1, c2 = 4.705e-10 3.330e+11 +At top right: c1, c2 = 7.262e-10 4.039e+11 -t = 7.92e+04 no. steps = 476 order = 5 stepsize = 6.52e+02 -At bottom left: c1, c2 = -6.684e-14 3.334e+11 -At top right: c1, c2 = -7.358e-14 4.120e+11 +t = 7.92e+04 no. steps = 508 order = 5 stepsize = 7.33e+02 +At bottom left: c1, c2 = -2.584e-11 3.334e+11 +At top right: c1, c2 = -3.989e-11 4.120e+11 -t = 8.64e+04 no. steps = 487 order = 5 stepsize = 6.52e+02 -At bottom left: c1, c2 = -1.055e-15 3.352e+11 -At top right: c1, c2 = -1.168e-15 4.163e+11 +t = 8.64e+04 no. steps = 518 order = 5 stepsize = 7.33e+02 +At bottom left: c1, c2 = 1.296e-12 3.352e+11 +At top right: c1, c2 = 2.001e-12 4.163e+11 Final Statistics: lenrw = 2689 leniw = 144 lenrwls = 2454 leniwls = 126 -nst = 487 -nfe = 618 nfels = 623 -nni = 615 nli = 623 -nsetups = 79 netf = 26 -npe = 9 nps = 1179 +nst = 518 +nfe = 670 nfels = 700 +nni = 667 nli = 700 +nsetups = 92 netf = 31 +npe = 9 nps = 1310 ncfn = 0 ncfl = 0 diff --git a/examples/cvode/parhyp/cvAdvDiff_non_ph.c b/examples/cvode/parhyp/cvAdvDiff_non_ph.c index e812421eac..04561ad35a 100644 --- a/examples/cvode/parhyp/cvAdvDiff_non_ph.c +++ b/examples/cvode/parhyp/cvAdvDiff_non_ph.c @@ -54,7 +54,7 @@ #include /* nvector implementation */ #include #include -#include /* definition of EXP */ +#include /* definition of SUNRexp */ #include /* definition of sunrealtype */ #include "sunnonlinsol/sunnonlinsol_fixedpoint.h" /* access to the fixed point SUNNonlinearSolver */ diff --git a/examples/cvode/petsc/cvAdvDiff_petsc.c b/examples/cvode/petsc/cvAdvDiff_petsc.c index cff0fcbd48..fe7ae4ebb7 100644 --- a/examples/cvode/petsc/cvAdvDiff_petsc.c +++ b/examples/cvode/petsc/cvAdvDiff_petsc.c @@ -49,7 +49,7 @@ #include /* access to the PETSc N_Vector */ #include #include -#include /* definition of ABS and EXP */ +#include /* definition of SUNRexp */ #include /* definition of type sunrealtype */ #include "sunnonlinsol/sunnonlinsol_petscsnes.h" /* access to the fixed point SUNNonlinearSolver */ diff --git a/examples/cvode/serial/cvAdvDiff_bnd.c b/examples/cvode/serial/cvAdvDiff_bnd.c index 18495f5950..078a498cb0 100644 --- a/examples/cvode/serial/cvAdvDiff_bnd.c +++ b/examples/cvode/serial/cvAdvDiff_bnd.c @@ -397,12 +397,12 @@ static void PrintHeader(sunrealtype reltol, sunrealtype abstol, sunrealtype umax printf("\n2-D Advection-Diffusion Equation\n"); printf("Mesh dimensions = %d X %d\n", MX, MY); printf("Total system size = %d\n", NEQ); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: reltol = %Qg abstol = %Qg\n\n", reltol, abstol); + printf("At t = %Qg max.norm(u) =%14.6Qe \n", T0, umax); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: reltol = %Lg abstol = %Lg\n\n", reltol, abstol); printf("At t = %Lg max.norm(u) =%14.6Le \n", T0, umax); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: reltol = %g abstol = %g\n\n", reltol, abstol); - printf("At t = %g max.norm(u) =%14.6e \n", T0, umax); #else printf("Tolerance parameters: reltol = %g abstol = %g\n\n", reltol, abstol); printf("At t = %g max.norm(u) =%14.6e \n", T0, umax); @@ -415,10 +415,10 @@ static void PrintHeader(sunrealtype reltol, sunrealtype abstol, sunrealtype umax static void PrintOutput(sunrealtype t, sunrealtype umax, long int nst) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("At t = %4.2Qf max.norm(u) =%14.6Qe nst = %4ld\n", t, umax, nst); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("At t = %4.2Lf max.norm(u) =%14.6Le nst = %4ld\n", t, umax, nst); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("At t = %4.2f max.norm(u) =%14.6e nst = %4ld\n", t, umax, nst); #else printf("At t = %4.2f max.norm(u) =%14.6e nst = %4ld\n", t, umax, nst); #endif diff --git a/examples/cvode/serial/cvAdvDiff_bndL.c b/examples/cvode/serial/cvAdvDiff_bndL.c index 096bec6f1d..509ad4cdd0 100644 --- a/examples/cvode/serial/cvAdvDiff_bndL.c +++ b/examples/cvode/serial/cvAdvDiff_bndL.c @@ -41,7 +41,7 @@ #include /* access to serial N_Vector */ #include #include -#include /* definition of ABS and EXP */ +#include /* definition of SUNRexp */ #include /* definition of type sunrealtype */ #include /* access to band SUNLinearSolver */ #include /* access to band SUNMatrix */ @@ -351,7 +351,10 @@ static void PrintHeader(sunrealtype reltol, sunrealtype abstol, sunrealtype umax printf("\n2-D Advection-Diffusion Equation\n"); printf("Mesh dimensions = %d X %d\n", MX, MY); printf("Total system size = %d\n", NEQ); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: reltol = %Qg abstol = %Qg\n\n", reltol, abstol); + printf("At t = %Qg max.norm(u) =%14.6Qe \n", T0, umax); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: reltol = %Lg abstol = %Lg\n\n", reltol, abstol); printf("At t = %Lg max.norm(u) =%14.6Le \n", T0, umax); #else @@ -366,7 +369,9 @@ static void PrintHeader(sunrealtype reltol, sunrealtype abstol, sunrealtype umax static void PrintOutput(sunrealtype t, sunrealtype umax, long int nst) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("At t = %4.2Qf max.norm(u) =%14.6Qe nst = %4ld\n", t, umax, nst); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("At t = %4.2Lf max.norm(u) =%14.6Le nst = %4ld\n", t, umax, nst); #else printf("At t = %4.2f max.norm(u) =%14.6e nst = %4ld\n", t, umax, nst); diff --git a/examples/cvode/serial/cvAnalytic_mels.c b/examples/cvode/serial/cvAnalytic_mels.c index 9046c71dc4..f23bc7775b 100644 --- a/examples/cvode/serial/cvAnalytic_mels.c +++ b/examples/cvode/serial/cvAnalytic_mels.c @@ -38,7 +38,11 @@ #include #include /* defs. of sunrealtype, sunindextype */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#define ESYM "Qe" +#define FSYM "Qf" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #define ESYM "Le" #define FSYM "Lf" @@ -208,7 +212,7 @@ static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) /* fill in the RHS function: "NV_Ith_S" accesses the 0th entry of ydot */ NV_Ith_S(ydot, 0) = lambda * u + SUN_RCONST(1.0) / (SUN_RCONST(1.0) + t * t) - - lambda * atan(t); + lambda * SUNRatan(t); return 0; /* return with success */ } @@ -336,7 +340,7 @@ static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, sunrealtype at sunrealtype ans, err, ewt; /* answer data, error, and error weight */ /* compute solution error */ - ans = atan(t); + ans = SUNRatan(t); ewt = SUN_RCONST(1.0) / (rtol * SUNRabs(ans) + atol); err = ewt * SUNRabs(NV_Ith_S(y, 0) - ans); diff --git a/examples/cvode/serial/cvDirectDemo_ls.c b/examples/cvode/serial/cvDirectDemo_ls.c index bf2bbcea70..e49608d740 100644 --- a/examples/cvode/serial/cvDirectDemo_ls.c +++ b/examples/cvode/serial/cvDirectDemo_ls.c @@ -78,12 +78,6 @@ #include "sunnonlinsol/sunnonlinsol_fixedpoint.h" /* access to the fixed point SUNNonlinearSolver */ #include "sunnonlinsol/sunnonlinsol_newton.h" /* access to the newton SUNNonlinearSolver */ -/* helpful macros */ - -#ifndef SQR -#define SQR(A) ((A) * (A)) -#endif - /* Shared Problem Constants */ #define ATOL SUN_RCONST(1.0e-6) @@ -350,10 +344,10 @@ static void PrintIntro1(void) printf("\n\n"); printf("Problem 1: Van der Pol oscillator\n"); printf(" xdotdot - 3*(1 - x^2)*xdot + x = 0, x(0) = 2, xdot(0) = 0\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" neq = %d, reltol = %.2Qg, abstol = %.2Qg", P1_NEQ, RTOL, ATOL); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" neq = %d, reltol = %.2Lg, abstol = %.2Lg", P1_NEQ, RTOL, ATOL); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf(" neq = %d, reltol = %.2g, abstol = %.2g", P1_NEQ, RTOL, ATOL); #else printf(" neq = %d, reltol = %.2g, abstol = %.2g", P1_NEQ, RTOL, ATOL); #endif @@ -369,10 +363,10 @@ static void PrintHeader1(void) static void PrintOutput1(sunrealtype t, sunrealtype y0, sunrealtype y1, int qu, sunrealtype hu) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%10.5Qf %12.5Qe %12.5Qe %2d %6.4Qe\n", t, y0, y1, qu, hu); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%10.5Lf %12.5Le %12.5Le %2d %6.4Le\n", t, y0, y1, qu, hu); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%10.5f %12.5e %12.5e %2d %6.4e\n", t, y0, y1, qu, hu); #else printf("%10.5f %12.5e %12.5e %2d %6.4e\n", t, y0, y1, qu, hu); #endif @@ -388,7 +382,7 @@ static int f1(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) y1 = NV_Ith_S(y, 1); NV_Ith_S(ydot, 0) = y1; - NV_Ith_S(ydot, 1) = (ONE - SQR(y0)) * P1_ETA * y1 - y0; + NV_Ith_S(ydot, 1) = (ONE - SUNSQR(y0)) * P1_ETA * y1 - y0; return (0); } @@ -403,7 +397,7 @@ static int Jac1(sunrealtype tn, N_Vector y, N_Vector fy, SUNMatrix J, SM_ELEMENT_D(J, 0, 1) = ONE; SM_ELEMENT_D(J, 1, 0) = -TWO * P1_ETA * y0 * y1 - ONE; - SM_ELEMENT_D(J, 1, 1) = P1_ETA * (ONE - SQR(y0)); + SM_ELEMENT_D(J, 1, 1) = P1_ETA * (ONE - SUNSQR(y0)); return (0); } @@ -584,10 +578,10 @@ static void PrintIntro2(void) printf("\n\nProblem 2: ydot = A * y, where A is a banded lower\n"); printf("triangular matrix derived from 2-D advection PDE\n\n"); printf(" neq = %d, ml = %d, mu = %d\n", P2_NEQ, P2_ML, P2_MU); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" itol = %s, reltol = %.2Qg, abstol = %.2Qg", "CV_SS", RTOL, ATOL); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" itol = %s, reltol = %.2Lg, abstol = %.2Lg", "CV_SS", RTOL, ATOL); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf(" itol = %s, reltol = %.2g, abstol = %.2g", "CV_SS", RTOL, ATOL); #else printf(" itol = %s, reltol = %.2g, abstol = %.2g", "CV_SS", RTOL, ATOL); #endif @@ -602,10 +596,10 @@ static void PrintHeader2(void) static void PrintOutput2(sunrealtype t, sunrealtype erm, int qu, sunrealtype hu) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%10.3Qf %12.4Qe %2d %12.4Qe\n", t, erm, qu, hu); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%10.3Lf %12.4Le %2d %12.4Le\n", t, erm, qu, hu); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%10.3f %12.4e %2d %12.4e\n", t, erm, qu, hu); #else printf("%10.3f %12.4e %2d %12.4e\n", t, erm, qu, hu); #endif @@ -695,7 +689,7 @@ static sunrealtype MaxError(N_Vector y, sunrealtype t) if (t == ZERO) { return (ZERO); } ydata = N_VGetArrayPointer(y); - if (t <= THIRTY) { ex = exp(-TWO * t); } + if (t <= THIRTY) { ex = SUNRexp(-TWO * t); } for (j = 0; j < P2_MESHY; j++) { @@ -703,7 +697,7 @@ static sunrealtype MaxError(N_Vector y, sunrealtype t) for (i = 0; i < P2_MESHX; i++) { k = i + j * P2_MESHX; - yt = pow(t, i + j) * ex * ifact_inv * jfact_inv; + yt = SUNRpowerI(t, i + j) * ex * ifact_inv * jfact_inv; er = SUNRabs(ydata[k] - yt); if (er > maxError) { maxError = er; } ifact_inv /= (i + 1); @@ -854,10 +848,10 @@ static int PrepareNextRun(SUNContext sunctx, void* cvode_mem, int lmm, static void PrintErrOutput(sunrealtype tol_factor) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("\n\n Error exceeds %Qg * tolerance \n\n", tol_factor); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("\n\n Error exceeds %Lg * tolerance \n\n", tol_factor); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("\n\n Error exceeds %g * tolerance \n\n", tol_factor); #else printf("\n\n Error exceeds %g * tolerance \n\n", tol_factor); #endif @@ -921,7 +915,9 @@ static void PrintFinalStats(void* cvode_mem, int miter, sunrealtype ero) printf(" Number of f evals. in linear solver = %4ld \n\n", nfeLS); } -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" Error overrun = %.3Qf \n", ero); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" Error overrun = %.3Lf \n", ero); #else printf(" Error overrun = %.3f \n", ero); diff --git a/examples/cvode/serial/cvDisc_dns.c b/examples/cvode/serial/cvDisc_dns.c index aa5fdd6fe4..2f57a8eeb0 100644 --- a/examples/cvode/serial/cvDisc_dns.c +++ b/examples/cvode/serial/cvDisc_dns.c @@ -24,7 +24,9 @@ #include /* access to dense SUNLinearSolver */ #include /* access to dense SUNMatrix */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define ESYM "Qe" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define ESYM "Le" #else #define ESYM "e" @@ -344,7 +346,7 @@ static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* f_data) switch (*flag) { case RHS1: NV_Ith_S(ydot, 0) = -NV_Ith_S(y, 0); break; - case RHS2: NV_Ith_S(ydot, 0) = -5.0 * NV_Ith_S(y, 0); break; + case RHS2: NV_Ith_S(ydot, 0) = -SUN_RCONST(5.0) * NV_Ith_S(y, 0); break; } return (0); diff --git a/examples/cvode/serial/cvDiurnal_kry.c b/examples/cvode/serial/cvDiurnal_kry.c index 6b32b582b1..87dc7f3c74 100644 --- a/examples/cvode/serial/cvDiurnal_kry.c +++ b/examples/cvode/serial/cvDiurnal_kry.c @@ -49,12 +49,6 @@ #include /* defs. of sunrealtype, sunindextype */ #include /* access to SPGMR SUNLinearSolver */ -/* helpful macros */ - -#ifndef SQR -#define SQR(A) ((A) * (A)) -#endif - /* Problem Constants */ #define ZERO SUN_RCONST(0.0) @@ -77,7 +71,7 @@ #define NOUT 12 /* number of output times */ #define TWOHR SUN_RCONST(7200.0) /* number of seconds in two hours */ #define HALFDAY SUN_RCONST(4.32e4) /* number of seconds in a half day */ -#define PI SUN_RCONST(3.1415926535898) /* pi */ +#define PI SUN_RCONST(3.141592653589793238462643383279502884197169) /* pi */ #define XMIN ZERO /* grid boundaries in x */ #define XMAX SUN_RCONST(20.0) @@ -285,9 +279,9 @@ static void InitUserData(UserData data) data->om = PI / HALFDAY; data->dx = (XMAX - XMIN) / (MX - 1); data->dy = (YMAX - YMIN) / (MY - 1); - data->hdco = KH / SQR(data->dx); + data->hdco = KH / SUNSQR(data->dx); data->haco = VEL / (TWO * data->dx); - data->vdco = (ONE / SQR(data->dy)) * KV0; + data->vdco = (ONE / SUNSQR(data->dy)) * KV0; } /* Free data memory */ @@ -326,13 +320,13 @@ static void SetInitialProfiles(N_Vector u, sunrealtype dx, sunrealtype dy) for (jy = 0; jy < MY; jy++) { y = YMIN + jy * dy; - cy = SQR(SUN_RCONST(0.1) * (y - YMID)); - cy = ONE - cy + SUN_RCONST(0.5) * SQR(cy); + cy = SUNSQR(SUN_RCONST(0.1) * (y - YMID)); + cy = ONE - cy + SUN_RCONST(0.5) * SUNSQR(cy); for (jx = 0; jx < MX; jx++) { x = XMIN + jx * dx; - cx = SQR(SUN_RCONST(0.1) * (x - XMID)); - cx = ONE - cx + SUN_RCONST(0.5) * SQR(cx); + cx = SUNSQR(SUN_RCONST(0.1) * (x - XMID)); + cx = ONE - cx + SUN_RCONST(0.5) * SUNSQR(cx); IJKth(udata, 1, jx, jy) = C1_SCALE * cx * cy; IJKth(udata, 2, jx, jy) = C2_SCALE * cx * cy; } @@ -357,22 +351,22 @@ static void PrintOutput(void* cvode_mem, N_Vector u, sunrealtype t) retval = CVodeGetLastStep(cvode_mem, &hu); check_retval(&retval, "CVodeGetLastStep", 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) - printf("t = %.2Le no. steps = %ld order = %d stepsize = %.2Le\n", t, +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("t = %.2Qe no. steps = %ld order = %d stepsize = %.2Qe\n", t, nst, qu, hu); - printf("c1 (bot.left/middle/top rt.) = %12.3Le %12.3Le %12.3Le\n", + printf("c1 (bot.left/middle/top rt.) = %12.3Qe %12.3Qe %12.3Qe\n", IJKth(udata, 1, 0, 0), IJKth(udata, 1, mxh, myh), IJKth(udata, 1, mx1, my1)); - printf("c2 (bot.left/middle/top rt.) = %12.3Le %12.3Le %12.3Le\n\n", + printf("c2 (bot.left/middle/top rt.) = %12.3Qe %12.3Qe %12.3Qe\n\n", IJKth(udata, 2, 0, 0), IJKth(udata, 2, mxh, myh), IJKth(udata, 2, mx1, my1)); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("t = %.2e no. steps = %ld order = %d stepsize = %.2e\n", t, nst, - qu, hu); - printf("c1 (bot.left/middle/top rt.) = %12.3e %12.3e %12.3e\n", +#elif defined(SUNDIALS_EXTENDED_PRECISION) + printf("t = %.2Le no. steps = %ld order = %d stepsize = %.2Le\n", t, + nst, qu, hu); + printf("c1 (bot.left/middle/top rt.) = %12.3Le %12.3Le %12.3Le\n", IJKth(udata, 1, 0, 0), IJKth(udata, 1, mxh, myh), IJKth(udata, 1, mx1, my1)); - printf("c2 (bot.left/middle/top rt.) = %12.3e %12.3e %12.3e\n\n", + printf("c2 (bot.left/middle/top rt.) = %12.3Le %12.3Le %12.3Le\n\n", IJKth(udata, 2, 0, 0), IJKth(udata, 2, mxh, myh), IJKth(udata, 2, mx1, my1)); #else @@ -503,11 +497,11 @@ static int f(sunrealtype t, N_Vector u, N_Vector udot, void* user_data) /* Set diurnal rate coefficients. */ - s = sin(data->om * t); + s = SUNRsin(data->om * t); if (s > ZERO) { - q3 = exp(-A3 / s); - data->q4 = exp(-A4 / s); + q3 = SUNRexp(-A3 / s); + data->q4 = SUNRexp(-A4 / s); } else { @@ -531,8 +525,8 @@ static int f(sunrealtype t, N_Vector u, N_Vector udot, void* user_data) ydn = YMIN + (jy - SUN_RCONST(0.5)) * dely; yup = ydn + dely; - cydn = verdco * exp(SUN_RCONST(0.2) * ydn); - cyup = verdco * exp(SUN_RCONST(0.2) * yup); + cydn = verdco * SUNRexp(SUN_RCONST(0.2) * ydn); + cyup = verdco * SUNRexp(SUN_RCONST(0.2) * yup); idn = (jy == 0) ? 1 : -1; iup = (jy == MY - 1) ? -1 : 1; for (jx = 0; jx < MX; jx++) @@ -603,8 +597,8 @@ static int jtv(N_Vector v, N_Vector Jv, sunrealtype t, N_Vector u, N_Vector fu, /* Set diurnal rate coefficients. */ - s = sin(data->om * t); - if (s > ZERO) { data->q4 = exp(-A4 / s); } + s = SUNRsin(data->om * t); + if (s > ZERO) { data->q4 = SUNRexp(-A4 / s); } else { data->q4 = ZERO; } /* Make local copies of problem variables, for efficiency. */ @@ -624,8 +618,8 @@ static int jtv(N_Vector v, N_Vector Jv, sunrealtype t, N_Vector u, N_Vector fu, ydn = YMIN + (jy - SUN_RCONST(0.5)) * dely; yup = ydn + dely; - cydn = verdco * exp(SUN_RCONST(0.2) * ydn); - cyup = verdco * exp(SUN_RCONST(0.2) * yup); + cydn = verdco * SUNRexp(SUN_RCONST(0.2) * ydn); + cyup = verdco * SUNRexp(SUN_RCONST(0.2) * yup); idn = (jy == 0) ? 1 : -1; iup = (jy == MY - 1) ? -1 : 1; @@ -762,8 +756,8 @@ static int Precond(sunrealtype tn, N_Vector u, N_Vector fu, sunbooleantype jok, { ydn = YMIN + (jy - SUN_RCONST(0.5)) * dely; yup = ydn + dely; - cydn = verdco * exp(SUN_RCONST(0.2) * ydn); - cyup = verdco * exp(SUN_RCONST(0.2) * yup); + cydn = verdco * SUNRexp(SUN_RCONST(0.2) * ydn); + cyup = verdco * SUNRexp(SUN_RCONST(0.2) * yup); diag = -(cydn + cyup + TWO * hordco); for (jx = 0; jx < MX; jx++) { diff --git a/examples/cvode/serial/cvDiurnal_kry.out b/examples/cvode/serial/cvDiurnal_kry.out index 3db1024d7c..f95a162809 100644 --- a/examples/cvode/serial/cvDiurnal_kry.out +++ b/examples/cvode/serial/cvDiurnal_kry.out @@ -17,47 +17,47 @@ t = 2.88e+04 no. steps = 307 order = 4 stepsize = 2.03e+02 c1 (bot.left/middle/top rt.) = 8.702e+06 1.292e+07 9.650e+06 c2 (bot.left/middle/top rt.) = 3.380e+11 5.029e+11 3.751e+11 -t = 3.60e+04 no. steps = 338 order = 5 stepsize = 9.92e+01 +t = 3.60e+04 no. steps = 337 order = 5 stepsize = 1.15e+02 c1 (bot.left/middle/top rt.) = 1.404e+04 2.029e+04 1.561e+04 c2 (bot.left/middle/top rt.) = 3.387e+11 4.894e+11 3.765e+11 -t = 4.32e+04 no. steps = 393 order = 4 stepsize = 2.57e+02 -c1 (bot.left/middle/top rt.) = -7.924e-06 -1.148e-06 -8.759e-06 +t = 4.32e+04 no. steps = 391 order = 5 stepsize = 5.46e+02 +c1 (bot.left/middle/top rt.) = 1.666e-07 -1.151e-05 2.097e-07 c2 (bot.left/middle/top rt.) = 3.382e+11 1.355e+11 3.804e+11 -t = 5.04e+04 no. steps = 421 order = 5 stepsize = 4.96e+02 -c1 (bot.left/middle/top rt.) = -1.599e-08 -1.775e-06 -3.124e-08 +t = 5.04e+04 no. steps = 406 order = 5 stepsize = 3.61e+02 +c1 (bot.left/middle/top rt.) = -2.555e-08 -5.151e-06 -5.725e-09 c2 (bot.left/middle/top rt.) = 3.358e+11 4.930e+11 3.864e+11 -t = 5.76e+04 no. steps = 437 order = 5 stepsize = 2.10e+02 -c1 (bot.left/middle/top rt.) = -1.239e-08 -8.964e-07 -1.736e-08 +t = 5.76e+04 no. steps = 425 order = 5 stepsize = 3.61e+02 +c1 (bot.left/middle/top rt.) = 8.696e-10 5.089e-08 2.252e-09 c2 (bot.left/middle/top rt.) = 3.320e+11 9.650e+11 3.909e+11 -t = 6.48e+04 no. steps = 464 order = 5 stepsize = 7.69e+02 -c1 (bot.left/middle/top rt.) = 4.297e-11 2.962e-09 5.854e-11 +t = 6.48e+04 no. steps = 438 order = 5 stepsize = 8.53e+02 +c1 (bot.left/middle/top rt.) = -1.998e-10 2.676e-07 -8.889e-09 c2 (bot.left/middle/top rt.) = 3.313e+11 8.922e+11 3.963e+11 -t = 7.20e+04 no. steps = 473 order = 5 stepsize = 7.69e+02 -c1 (bot.left/middle/top rt.) = 1.150e-11 7.919e-10 1.566e-11 +t = 7.20e+04 no. steps = 447 order = 5 stepsize = 8.53e+02 +c1 (bot.left/middle/top rt.) = 1.272e-10 3.282e-08 -4.906e-10 c2 (bot.left/middle/top rt.) = 3.330e+11 6.186e+11 4.039e+11 -t = 7.92e+04 no. steps = 483 order = 5 stepsize = 7.69e+02 -c1 (bot.left/middle/top rt.) = -4.188e-13 -2.884e-11 -5.703e-13 +t = 7.92e+04 no. steps = 455 order = 5 stepsize = 8.53e+02 +c1 (bot.left/middle/top rt.) = 8.839e-11 1.110e-08 1.240e-11 c2 (bot.left/middle/top rt.) = 3.334e+11 6.669e+11 4.120e+11 -t = 8.64e+04 no. steps = 492 order = 5 stepsize = 7.69e+02 -c1 (bot.left/middle/top rt.) = -3.268e-14 -2.246e-12 -4.447e-14 -c2 (bot.left/middle/top rt.) = 3.352e+11 9.107e+11 4.163e+11 +t = 8.64e+04 no. steps = 463 order = 5 stepsize = 8.53e+02 +c1 (bot.left/middle/top rt.) = 1.089e-11 8.265e-10 1.786e-11 +c2 (bot.left/middle/top rt.) = 3.352e+11 9.106e+11 4.163e+11 Final Statistics.. lenrw = 2689 leniw = 53 lenrwLS = 2454 leniwLS = 42 -nst = 492 -nfe = 637 nfeLS = 0 -nni = 634 nli = 649 -nsetups = 88 netf = 32 -npe = 9 nps = 1223 +nst = 463 +nfe = 585 nfeLS = 0 +nni = 582 nli = 607 +nsetups = 73 netf = 24 +npe = 8 nps = 1136 ncfn = 0 ncfl = 0 diff --git a/examples/cvode/serial/cvDiurnal_kry_bp.c b/examples/cvode/serial/cvDiurnal_kry_bp.c index d3010837bf..56b48947f1 100644 --- a/examples/cvode/serial/cvDiurnal_kry_bp.c +++ b/examples/cvode/serial/cvDiurnal_kry_bp.c @@ -48,12 +48,6 @@ #include /* defs. of sunrealtype, sunindextype */ #include /* access to SPGMR SUNLinearSolver */ -/* helpful macros */ - -#ifndef SQR -#define SQR(A) ((A) * (A)) -#endif - /* Problem Constants */ #define ZERO SUN_RCONST(0.0) @@ -76,7 +70,7 @@ #define NOUT 12 /* number of output times */ #define TWOHR SUN_RCONST(7200.0) /* number of seconds in two hours */ #define HALFDAY SUN_RCONST(4.32e4) /* number of seconds in a half day */ -#define PI SUN_RCONST(3.1415926535898) /* pi */ +#define PI SUN_RCONST(3.141592653589793238462643383279502884197169) /* pi */ #define XMIN ZERO /* grid boundaries in x */ #define XMAX SUN_RCONST(20.0) @@ -276,9 +270,9 @@ static void InitUserData(UserData data) data->om = PI / HALFDAY; data->dx = (XMAX - XMIN) / (MX - 1); data->dy = (YMAX - YMIN) / (MY - 1); - data->hdco = KH / SQR(data->dx); + data->hdco = KH / SUNSQR(data->dx); data->haco = VEL / (TWO * data->dx); - data->vdco = (ONE / SQR(data->dy)) * KV0; + data->vdco = (ONE / SUNSQR(data->dy)) * KV0; } /* Set initial conditions in u */ @@ -298,13 +292,13 @@ static void SetInitialProfiles(N_Vector u, sunrealtype dx, sunrealtype dy) for (jy = 0; jy < MY; jy++) { y = YMIN + jy * dy; - cy = SQR(SUN_RCONST(0.1) * (y - YMID)); - cy = ONE - cy + SUN_RCONST(0.5) * SQR(cy); + cy = SUNSQR(SUN_RCONST(0.1) * (y - YMID)); + cy = ONE - cy + SUN_RCONST(0.5) * SUNSQR(cy); for (jx = 0; jx < MX; jx++) { x = XMIN + jx * dx; - cx = SQR(SUN_RCONST(0.1) * (x - XMID)); - cx = ONE - cx + SUN_RCONST(0.5) * SQR(cx); + cx = SUNSQR(SUN_RCONST(0.1) * (x - XMID)); + cx = ONE - cx + SUN_RCONST(0.5) * SUNSQR(cx); IJKth(udata, 1, jx, jy) = C1_SCALE * cx * cy; IJKth(udata, 2, jx, jy) = C2_SCALE * cx * cy; } @@ -339,22 +333,22 @@ static void PrintOutput(void* cvode_mem, N_Vector u, sunrealtype t) retval = CVodeGetLastStep(cvode_mem, &hu); check_retval(&retval, "CVodeGetLastStep", 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) - printf("t = %.2Le no. steps = %ld order = %d stepsize = %.2Le\n", t, +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("t = %.2Qe no. steps = %ld order = %d stepsize = %.2Qe\n", t, nst, qu, hu); - printf("c1 (bot.left/middle/top rt.) = %12.3Le %12.3Le %12.3Le\n", + printf("c1 (bot.left/middle/top rt.) = %12.3Qe %12.3Qe %12.3Qe\n", IJKth(udata, 1, 0, 0), IJKth(udata, 1, mxh, myh), IJKth(udata, 1, mx1, my1)); - printf("c2 (bot.left/middle/top rt.) = %12.3Le %12.3Le %12.3Le\n\n", + printf("c2 (bot.left/middle/top rt.) = %12.3Qe %12.3Qe %12.3Qe\n\n", IJKth(udata, 2, 0, 0), IJKth(udata, 2, mxh, myh), IJKth(udata, 2, mx1, my1)); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("t = %.2e no. steps = %ld order = %d stepsize = %.2e\n", t, nst, - qu, hu); - printf("c1 (bot.left/middle/top rt.) = %12.3e %12.3e %12.3e\n", +#elif defined(SUNDIALS_EXTENDED_PRECISION) + printf("t = %.2Le no. steps = %ld order = %d stepsize = %.2Le\n", t, + nst, qu, hu); + printf("c1 (bot.left/middle/top rt.) = %12.3Le %12.3Le %12.3Le\n", IJKth(udata, 1, 0, 0), IJKth(udata, 1, mxh, myh), IJKth(udata, 1, mx1, my1)); - printf("c2 (bot.left/middle/top rt.) = %12.3e %12.3e %12.3e\n\n", + printf("c2 (bot.left/middle/top rt.) = %12.3Le %12.3Le %12.3Le\n\n", IJKth(udata, 2, 0, 0), IJKth(udata, 2, mxh, myh), IJKth(udata, 2, mx1, my1)); #else @@ -494,11 +488,11 @@ static int f(sunrealtype t, N_Vector u, N_Vector udot, void* user_data) /* Set diurnal rate coefficients. */ - s = sin(data->om * t); + s = SUNRsin(data->om * t); if (s > ZERO) { - q3 = exp(-A3 / s); - data->q4 = exp(-A4 / s); + q3 = SUNRexp(-A3 / s); + data->q4 = SUNRexp(-A4 / s); } else { @@ -522,8 +516,8 @@ static int f(sunrealtype t, N_Vector u, N_Vector udot, void* user_data) ydn = YMIN + (jy - SUN_RCONST(0.5)) * dely; yup = ydn + dely; - cydn = verdco * exp(SUN_RCONST(0.2) * ydn); - cyup = verdco * exp(SUN_RCONST(0.2) * yup); + cydn = verdco * SUNRexp(SUN_RCONST(0.2) * ydn); + cyup = verdco * SUNRexp(SUN_RCONST(0.2) * yup); idn = (jy == 0) ? 1 : -1; iup = (jy == MY - 1) ? -1 : 1; for (jx = 0; jx < MX; jx++) diff --git a/examples/cvode/serial/cvDiurnal_kry_bp.out b/examples/cvode/serial/cvDiurnal_kry_bp.out index 06b0c57bcd..b560364dcd 100644 --- a/examples/cvode/serial/cvDiurnal_kry_bp.out +++ b/examples/cvode/serial/cvDiurnal_kry_bp.out @@ -17,40 +17,40 @@ t = 2.16e+04 no. steps = 246 order = 5 stepsize = 2.78e+02 c1 (bot.left/middle/top rt.) = 2.665e+07 1.036e+07 2.931e+07 c2 (bot.left/middle/top rt.) = 2.993e+11 1.028e+11 3.313e+11 -t = 2.88e+04 no. steps = 298 order = 3 stepsize = 1.33e+02 +t = 2.88e+04 no. steps = 296 order = 3 stepsize = 1.41e+02 c1 (bot.left/middle/top rt.) = 8.702e+06 1.292e+07 9.650e+06 c2 (bot.left/middle/top rt.) = 3.380e+11 5.029e+11 3.751e+11 -t = 3.60e+04 no. steps = 341 order = 4 stepsize = 6.31e+01 +t = 3.60e+04 no. steps = 337 order = 4 stepsize = 1.01e+02 c1 (bot.left/middle/top rt.) = 1.404e+04 2.029e+04 1.561e+04 c2 (bot.left/middle/top rt.) = 3.387e+11 4.894e+11 3.765e+11 -t = 4.32e+04 no. steps = 402 order = 4 stepsize = 4.48e+02 -c1 (bot.left/middle/top rt.) = 1.929e-07 -6.029e-06 4.403e-07 +t = 4.32e+04 no. steps = 397 order = 4 stepsize = 4.61e+02 +c1 (bot.left/middle/top rt.) = 2.741e-13 1.852e-09 2.860e-10 c2 (bot.left/middle/top rt.) = 3.382e+11 1.355e+11 3.804e+11 -t = 5.04e+04 no. steps = 421 order = 4 stepsize = 3.30e+02 -c1 (bot.left/middle/top rt.) = 1.559e-09 6.319e-07 6.062e-10 +t = 5.04e+04 no. steps = 413 order = 5 stepsize = 4.27e+02 +c1 (bot.left/middle/top rt.) = 2.071e-08 1.302e-05 6.023e-09 c2 (bot.left/middle/top rt.) = 3.358e+11 4.930e+11 3.864e+11 -t = 5.76e+04 no. steps = 435 order = 5 stepsize = 4.67e+02 -c1 (bot.left/middle/top rt.) = -2.660e-12 -1.080e-09 -1.030e-12 +t = 5.76e+04 no. steps = 445 order = 4 stepsize = 2.03e+02 +c1 (bot.left/middle/top rt.) = 1.075e-10 3.461e-09 2.529e-10 c2 (bot.left/middle/top rt.) = 3.320e+11 9.650e+11 3.909e+11 -t = 6.48e+04 no. steps = 447 order = 5 stepsize = 7.06e+02 -c1 (bot.left/middle/top rt.) = -7.375e-15 -2.742e-12 -2.920e-15 +t = 6.48e+04 no. steps = 458 order = 5 stepsize = 7.28e+02 +c1 (bot.left/middle/top rt.) = -5.415e-15 -4.724e-12 1.913e-15 c2 (bot.left/middle/top rt.) = 3.313e+11 8.922e+11 3.963e+11 -t = 7.20e+04 no. steps = 457 order = 5 stepsize = 7.06e+02 -c1 (bot.left/middle/top rt.) = -1.202e-17 -4.105e-15 -5.445e-18 +t = 7.20e+04 no. steps = 468 order = 5 stepsize = 7.28e+02 +c1 (bot.left/middle/top rt.) = 5.341e-15 4.064e-12 -4.304e-16 c2 (bot.left/middle/top rt.) = 3.330e+11 6.186e+11 4.039e+11 -t = 7.92e+04 no. steps = 467 order = 5 stepsize = 7.06e+02 -c1 (bot.left/middle/top rt.) = -8.193e-21 -1.461e-15 -7.837e-19 +t = 7.92e+04 no. steps = 478 order = 5 stepsize = 7.28e+02 +c1 (bot.left/middle/top rt.) = 7.167e-19 7.839e-16 5.290e-16 c2 (bot.left/middle/top rt.) = 3.334e+11 6.669e+11 4.120e+11 -t = 8.64e+04 no. steps = 477 order = 5 stepsize = 7.06e+02 -c1 (bot.left/middle/top rt.) = -7.290e-20 -3.730e-15 -4.364e-20 +t = 8.64e+04 no. steps = 488 order = 5 stepsize = 7.28e+02 +c1 (bot.left/middle/top rt.) = -1.746e-24 -4.277e-19 7.334e-15 c2 (bot.left/middle/top rt.) = 3.352e+11 9.106e+11 4.162e+11 @@ -59,12 +59,12 @@ Final Statistics.. lenrw = 2689 leniw = 53 lenrwls = 2454 leniwls = 42 lenrwbp = 2800 leniwbp = 622 -nst = 477 -nfe = 613 nfetot = 1267 -nfeLS = 614 nfeBP = 40 -nni = 610 nli = 614 -nsetups = 85 netf = 28 -npe = 8 nps = 1142 +nst = 488 +nfe = 648 nfetot = 1325 +nfeLS = 632 nfeBP = 45 +nni = 645 nli = 632 +nsetups = 95 netf = 37 +npe = 9 nps = 1185 ncfn = 0 ncfl = 0 @@ -94,32 +94,32 @@ t = 3.60e+04 no. steps = 329 order = 5 stepsize = 1.16e+02 c1 (bot.left/middle/top rt.) = 1.404e+04 2.029e+04 1.561e+04 c2 (bot.left/middle/top rt.) = 3.387e+11 4.894e+11 3.765e+11 -t = 4.32e+04 no. steps = 381 order = 4 stepsize = 4.67e+02 -c1 (bot.left/middle/top rt.) = 8.674e-09 7.020e-09 9.676e-09 +t = 4.32e+04 no. steps = 381 order = 4 stepsize = 4.65e+02 +c1 (bot.left/middle/top rt.) = 6.465e-09 5.239e-09 7.212e-09 c2 (bot.left/middle/top rt.) = 3.382e+11 1.355e+11 3.804e+11 -t = 5.04e+04 no. steps = 398 order = 4 stepsize = 3.23e+02 -c1 (bot.left/middle/top rt.) = 3.531e-15 -4.895e-12 -1.356e-13 +t = 5.04e+04 no. steps = 398 order = 5 stepsize = 5.38e+02 +c1 (bot.left/middle/top rt.) = -3.309e-11 6.096e-08 -3.239e-10 c2 (bot.left/middle/top rt.) = 3.358e+11 4.930e+11 3.864e+11 -t = 5.76e+04 no. steps = 411 order = 5 stepsize = 4.75e+02 -c1 (bot.left/middle/top rt.) = 1.279e-13 -4.506e-11 -1.318e-12 +t = 5.76e+04 no. steps = 410 order = 5 stepsize = 5.91e+02 +c1 (bot.left/middle/top rt.) = 6.558e-14 7.386e-12 2.808e-13 c2 (bot.left/middle/top rt.) = 3.320e+11 9.650e+11 3.909e+11 -t = 6.48e+04 no. steps = 423 order = 5 stepsize = 7.28e+02 -c1 (bot.left/middle/top rt.) = -1.113e-17 6.813e-16 1.742e-17 +t = 6.48e+04 no. steps = 422 order = 5 stepsize = 5.91e+02 +c1 (bot.left/middle/top rt.) = 1.418e-13 -5.989e-12 -1.356e-13 c2 (bot.left/middle/top rt.) = 3.313e+11 8.922e+11 3.963e+11 -t = 7.20e+04 no. steps = 433 order = 5 stepsize = 7.28e+02 -c1 (bot.left/middle/top rt.) = -1.369e-20 3.565e-21 -5.202e-25 +t = 7.20e+04 no. steps = 434 order = 5 stepsize = 5.91e+02 +c1 (bot.left/middle/top rt.) = 1.725e-18 1.355e-15 -2.409e-17 c2 (bot.left/middle/top rt.) = 3.330e+11 6.186e+11 4.039e+11 -t = 7.92e+04 no. steps = 443 order = 5 stepsize = 7.28e+02 -c1 (bot.left/middle/top rt.) = 1.471e-20 -1.150e-20 -1.118e-25 +t = 7.92e+04 no. steps = 447 order = 5 stepsize = 5.91e+02 +c1 (bot.left/middle/top rt.) = 7.942e-25 5.762e-22 -1.438e-25 c2 (bot.left/middle/top rt.) = 3.334e+11 6.669e+11 4.120e+11 -t = 8.64e+04 no. steps = 452 order = 5 stepsize = 7.28e+02 -c1 (bot.left/middle/top rt.) = 1.949e-20 -1.947e-21 1.946e-25 +t = 8.64e+04 no. steps = 459 order = 5 stepsize = 5.91e+02 +c1 (bot.left/middle/top rt.) = -1.316e-25 -1.130e-22 4.894e-25 c2 (bot.left/middle/top rt.) = 3.352e+11 9.106e+11 4.163e+11 @@ -128,11 +128,11 @@ Final Statistics.. lenrw = 2689 leniw = 53 lenrwls = 2454 leniwls = 42 lenrwbp = 2800 leniwbp = 622 -nst = 452 -nfe = 570 nfetot = 1335 -nfeLS = 725 nfeBP = 40 -nni = 567 nli = 725 +nst = 459 +nfe = 575 nfetot = 1356 +nfeLS = 741 nfeBP = 40 +nni = 572 nli = 741 nsetups = 74 netf = 23 -npe = 8 nps = 1199 +npe = 8 nps = 1222 ncfn = 0 ncfl = 0 diff --git a/examples/cvode/serial/cvKrylovDemo_ls.c b/examples/cvode/serial/cvKrylovDemo_ls.c index cbd9af8610..6ce7d71328 100644 --- a/examples/cvode/serial/cvKrylovDemo_ls.c +++ b/examples/cvode/serial/cvKrylovDemo_ls.c @@ -57,22 +57,6 @@ #include /* access to SPTFQMR SUNLinearSolver */ #include /* access to Newton SUNNonlinearSolver */ -/* helpful macros */ - -#ifndef SQR -#define SQR(A) ((A) * (A)) -#endif - -#ifndef SQRT -#if defined(SUNDIALS_DOUBLE_PRECISION) -#define SQRT(x) (sqrt((x))) -#elif defined(SUNDIALS_SINGLE_PRECISION) -#define SQRT(x) (sqrtf((x))) -#elif defined(SUNDIALS_EXTENDED_PRECISION) -#define SQRT(x) (sqrtl((x))) -#endif -#endif - /* Problem Constants */ #define ZERO SUN_RCONST(0.0) @@ -95,7 +79,7 @@ #define NOUT 12 /* number of output times */ #define TWOHR SUN_RCONST(7200.0) /* number of seconds in two hours */ #define HALFDAY SUN_RCONST(4.32e4) /* number of seconds in a half day */ -#define PI SUN_RCONST(3.1415926535898) /* pi */ +#define PI SUN_RCONST(3.141592653589793238462643383279502884197169) /* pi */ #define XMIN ZERO /* grid boundaries in x */ #define XMAX SUN_RCONST(20.0) @@ -387,7 +371,7 @@ int main(int argc, char* argv[]) { case (1): /* use the square root of the vector length */ - nrmfac = SQRT((sunrealtype)NEQ); + nrmfac = SUNRsqrt((sunrealtype)NEQ); break; case (2): /* compute with dot product */ @@ -463,9 +447,9 @@ static void InitUserData(UserData data, N_Vector u) data->om = PI / HALFDAY; data->dx = (XMAX - XMIN) / (MX - 1); data->dy = (YMAX - YMIN) / (MY - 1); - data->hdco = KH / SQR(data->dx); + data->hdco = KH / SUNSQR(data->dx); data->haco = VEL / (TWO * data->dx); - data->vdco = (ONE / SQR(data->dy)) * KV0; + data->vdco = (ONE / SUNSQR(data->dy)) * KV0; } /* Free data memory */ @@ -504,13 +488,13 @@ static void SetInitialProfiles(N_Vector u, sunrealtype dx, sunrealtype dy) for (jy = 0; jy < MY; jy++) { y = YMIN + jy * dy; - cy = SQR(SUN_RCONST(0.1) * (y - YMID)); - cy = ONE - cy + SUN_RCONST(0.5) * SQR(cy); + cy = SUNSQR(SUN_RCONST(0.1) * (y - YMID)); + cy = ONE - cy + SUN_RCONST(0.5) * SUNSQR(cy); for (jx = 0; jx < MX; jx++) { x = XMIN + jx * dx; - cx = SQR(SUN_RCONST(0.1) * (x - XMID)); - cx = ONE - cx + SUN_RCONST(0.5) * SQR(cx); + cx = SUNSQR(SUN_RCONST(0.1) * (x - XMID)); + cx = ONE - cx + SUN_RCONST(0.5) * SUNSQR(cx); IJKth(udata, 1, jx, jy) = C1_SCALE * cx * cy; IJKth(udata, 2, jx, jy) = C2_SCALE * cx * cy; } @@ -535,22 +519,22 @@ static void PrintOutput(void* cvode_mem, N_Vector u, sunrealtype t) retval = CVodeGetLastStep(cvode_mem, &hu); check_retval(&retval, "CVodeGetLastStep", 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) - printf("t = %.2Le no. steps = %ld order = %d stepsize = %.2Le\n", t, +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("t = %.2Qe no. steps = %ld order = %d stepsize = %.2Qe\n", t, nst, qu, hu); - printf("c1 (bot.left/middle/top rt.) = %12.3Le %12.3Le %12.3Le\n", + printf("c1 (bot.left/middle/top rt.) = %12.3Qe %12.3Qe %12.3Qe\n", IJKth(udata, 1, 0, 0), IJKth(udata, 1, mxh, myh), IJKth(udata, 1, mx1, my1)); - printf("c2 (bot.left/middle/top rt.) = %12.3Le %12.3Le %12.3Le\n\n", + printf("c2 (bot.left/middle/top rt.) = %12.3Qe %12.3Qe %12.3Qe\n\n", IJKth(udata, 2, 0, 0), IJKth(udata, 2, mxh, myh), IJKth(udata, 2, mx1, my1)); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("t = %.2e no. steps = %ld order = %d stepsize = %.2e\n", t, nst, - qu, hu); - printf("c1 (bot.left/middle/top rt.) = %12.3e %12.3e %12.3e\n", +#elif defined(SUNDIALS_EXTENDED_PRECISION) + printf("t = %.2Le no. steps = %ld order = %d stepsize = %.2Le\n", t, + nst, qu, hu); + printf("c1 (bot.left/middle/top rt.) = %12.3Le %12.3Le %12.3Le\n", IJKth(udata, 1, 0, 0), IJKth(udata, 1, mxh, myh), IJKth(udata, 1, mx1, my1)); - printf("c2 (bot.left/middle/top rt.) = %12.3e %12.3e %12.3e\n\n", + printf("c2 (bot.left/middle/top rt.) = %12.3Le %12.3Le %12.3Le\n\n", IJKth(udata, 2, 0, 0), IJKth(udata, 2, mxh, myh), IJKth(udata, 2, mx1, my1)); #else @@ -681,11 +665,11 @@ static int f(sunrealtype t, N_Vector u, N_Vector udot, void* user_data) /* Set diurnal rate coefficients. */ - s = sin(data->om * t); + s = SUNRsin(data->om * t); if (s > ZERO) { - q3 = exp(-A3 / s); - data->q4 = exp(-A4 / s); + q3 = SUNRexp(-A3 / s); + data->q4 = SUNRexp(-A4 / s); } else { @@ -709,8 +693,8 @@ static int f(sunrealtype t, N_Vector u, N_Vector udot, void* user_data) ydn = YMIN + (jy - SUN_RCONST(0.5)) * dely; yup = ydn + dely; - cydn = verdco * exp(SUN_RCONST(0.2) * ydn); - cyup = verdco * exp(SUN_RCONST(0.2) * yup); + cydn = verdco * SUNRexp(SUN_RCONST(0.2) * ydn); + cyup = verdco * SUNRexp(SUN_RCONST(0.2) * yup); idn = (jy == 0) ? 1 : -1; iup = (jy == MY - 1) ? -1 : 1; for (jx = 0; jx < MX; jx++) @@ -811,8 +795,8 @@ static int Precond(sunrealtype tn, N_Vector u, N_Vector fu, sunbooleantype jok, { ydn = YMIN + (jy - SUN_RCONST(0.5)) * dely; yup = ydn + dely; - cydn = verdco * exp(SUN_RCONST(0.2) * ydn); - cyup = verdco * exp(SUN_RCONST(0.2) * yup); + cydn = verdco * SUNRexp(SUN_RCONST(0.2) * ydn); + cyup = verdco * SUNRexp(SUN_RCONST(0.2) * yup); diag = -(cydn + cyup + TWO * hordco); for (jx = 0; jx < MX; jx++) { diff --git a/examples/cvode/serial/cvKrylovDemo_ls.out b/examples/cvode/serial/cvKrylovDemo_ls.out index 6f1196281d..5245d0b27e 100644 --- a/examples/cvode/serial/cvKrylovDemo_ls.out +++ b/examples/cvode/serial/cvKrylovDemo_ls.out @@ -16,40 +16,40 @@ t = 2.16e+04 no. steps = 277 order = 5 stepsize = 2.75e+02 c1 (bot.left/middle/top rt.) = 2.665e+07 1.036e+07 2.931e+07 c2 (bot.left/middle/top rt.) = 2.993e+11 1.028e+11 3.313e+11 -t = 2.88e+04 no. steps = 307 order = 4 stepsize = 2.01e+02 +t = 2.88e+04 no. steps = 307 order = 4 stepsize = 2.03e+02 c1 (bot.left/middle/top rt.) = 8.702e+06 1.292e+07 9.650e+06 c2 (bot.left/middle/top rt.) = 3.380e+11 5.029e+11 3.751e+11 -t = 3.60e+04 no. steps = 336 order = 5 stepsize = 1.02e+02 +t = 3.60e+04 no. steps = 338 order = 5 stepsize = 9.92e+01 c1 (bot.left/middle/top rt.) = 1.404e+04 2.029e+04 1.561e+04 c2 (bot.left/middle/top rt.) = 3.387e+11 4.894e+11 3.765e+11 -t = 4.32e+04 no. steps = 385 order = 4 stepsize = 4.57e+02 -c1 (bot.left/middle/top rt.) = 5.226e-08 -6.075e-06 8.713e-08 +t = 4.32e+04 no. steps = 393 order = 4 stepsize = 2.57e+02 +c1 (bot.left/middle/top rt.) = -7.685e-06 -9.677e-07 -8.494e-06 c2 (bot.left/middle/top rt.) = 3.382e+11 1.355e+11 3.804e+11 -t = 5.04e+04 no. steps = 403 order = 4 stepsize = 2.77e+02 -c1 (bot.left/middle/top rt.) = -2.670e-08 -4.510e-06 -2.672e-08 +t = 5.04e+04 no. steps = 421 order = 5 stepsize = 4.93e+02 +c1 (bot.left/middle/top rt.) = -1.570e-08 -1.745e-06 -3.070e-08 c2 (bot.left/middle/top rt.) = 3.358e+11 4.930e+11 3.864e+11 -t = 5.76e+04 no. steps = 419 order = 5 stepsize = 3.44e+02 -c1 (bot.left/middle/top rt.) = -1.147e-09 -5.871e-08 -2.195e-09 +t = 5.76e+04 no. steps = 440 order = 5 stepsize = 8.59e+01 +c1 (bot.left/middle/top rt.) = 9.046e-08 6.799e-06 1.298e-07 c2 (bot.left/middle/top rt.) = 3.320e+11 9.650e+11 3.909e+11 -t = 6.48e+04 no. steps = 431 order = 5 stepsize = 9.50e+02 -c1 (bot.left/middle/top rt.) = 3.792e-10 1.901e-08 7.196e-10 +t = 6.48e+04 no. steps = 459 order = 5 stepsize = 6.72e+02 +c1 (bot.left/middle/top rt.) = 4.888e-09 3.680e-07 7.026e-09 c2 (bot.left/middle/top rt.) = 3.313e+11 8.922e+11 3.963e+11 -t = 7.20e+04 no. steps = 441 order = 5 stepsize = 7.01e+02 -c1 (bot.left/middle/top rt.) = -1.872e-11 -9.361e-10 -3.550e-11 +t = 7.20e+04 no. steps = 470 order = 5 stepsize = 6.72e+02 +c1 (bot.left/middle/top rt.) = 7.580e-11 5.711e-09 1.090e-10 c2 (bot.left/middle/top rt.) = 3.330e+11 6.186e+11 4.039e+11 -t = 7.92e+04 no. steps = 451 order = 5 stepsize = 7.01e+02 -c1 (bot.left/middle/top rt.) = 1.365e-13 6.739e-12 2.585e-13 +t = 7.92e+04 no. steps = 481 order = 5 stepsize = 6.72e+02 +c1 (bot.left/middle/top rt.) = 2.772e-13 2.088e-11 4.012e-13 c2 (bot.left/middle/top rt.) = 3.334e+11 6.669e+11 4.120e+11 -t = 8.64e+04 no. steps = 461 order = 5 stepsize = 7.01e+02 -c1 (bot.left/middle/top rt.) = 4.144e-14 2.072e-12 7.862e-14 +t = 8.64e+04 no. steps = 491 order = 5 stepsize = 6.72e+02 +c1 (bot.left/middle/top rt.) = -1.017e-13 -7.659e-12 -1.461e-13 c2 (bot.left/middle/top rt.) = 3.352e+11 9.107e+11 4.163e+11 @@ -57,11 +57,11 @@ Final Statistics.. lenrw = 2689 leniw = 53 lenrwLS = 2454 leniwLS = 42 -nst = 461 -nfe = 597 nfeLS = 636 -nni = 594 nli = 636 -nsetups = 78 netf = 27 -npe = 8 nps = 1176 +nst = 491 +nfe = 631 nfeLS = 652 +nni = 628 nli = 652 +nsetups = 86 netf = 31 +npe = 9 nps = 1227 ncfn = 0 ncfl = 0 ====================================================================== @@ -93,31 +93,31 @@ c1 (bot.left/middle/top rt.) = 1.404e+04 2.029e+04 1.561e+04 c2 (bot.left/middle/top rt.) = 3.387e+11 4.895e+11 3.765e+11 t = 4.32e+04 no. steps = 378 order = 5 stepsize = 5.86e+02 -c1 (bot.left/middle/top rt.) = 1.180e-09 7.956e-08 1.490e-09 +c1 (bot.left/middle/top rt.) = 1.184e-09 7.952e-08 1.494e-09 c2 (bot.left/middle/top rt.) = 3.382e+11 1.355e+11 3.804e+11 -t = 5.04e+04 no. steps = 391 order = 5 stepsize = 4.27e+02 -c1 (bot.left/middle/top rt.) = 6.580e-11 2.809e-08 1.507e-10 +t = 5.04e+04 no. steps = 391 order = 5 stepsize = 4.28e+02 +c1 (bot.left/middle/top rt.) = 6.549e-11 2.778e-08 1.492e-10 c2 (bot.left/middle/top rt.) = 3.358e+11 4.930e+11 3.864e+11 -t = 5.76e+04 no. steps = 402 order = 5 stepsize = 4.96e+02 -c1 (bot.left/middle/top rt.) = 2.069e-10 1.559e-08 2.264e-10 +t = 5.76e+04 no. steps = 402 order = 5 stepsize = 4.97e+02 +c1 (bot.left/middle/top rt.) = 2.130e-10 1.597e-08 2.338e-10 c2 (bot.left/middle/top rt.) = 3.320e+11 9.650e+11 3.909e+11 -t = 6.48e+04 no. steps = 412 order = 5 stepsize = 7.86e+02 -c1 (bot.left/middle/top rt.) = 3.735e-11 -1.076e-09 -3.688e-11 +t = 6.48e+04 no. steps = 412 order = 5 stepsize = 7.84e+02 +c1 (bot.left/middle/top rt.) = 3.694e-11 -1.057e-09 -3.646e-11 c2 (bot.left/middle/top rt.) = 3.313e+11 8.922e+11 3.963e+11 -t = 7.20e+04 no. steps = 421 order = 5 stepsize = 7.86e+02 -c1 (bot.left/middle/top rt.) = -1.410e-11 -1.148e-09 9.417e-11 +t = 7.20e+04 no. steps = 421 order = 5 stepsize = 7.84e+02 +c1 (bot.left/middle/top rt.) = -1.398e-11 -1.129e-09 9.313e-11 c2 (bot.left/middle/top rt.) = 3.330e+11 6.186e+11 4.039e+11 -t = 7.92e+04 no. steps = 430 order = 5 stepsize = 7.86e+02 -c1 (bot.left/middle/top rt.) = 1.671e-12 -2.171e-10 -4.471e-12 +t = 7.92e+04 no. steps = 430 order = 5 stepsize = 7.84e+02 +c1 (bot.left/middle/top rt.) = 1.779e-12 -2.371e-10 -4.669e-12 c2 (bot.left/middle/top rt.) = 3.334e+11 6.669e+11 4.120e+11 -t = 8.64e+04 no. steps = 439 order = 5 stepsize = 7.86e+02 -c1 (bot.left/middle/top rt.) = 5.687e-13 -9.924e-11 -1.149e-12 +t = 8.64e+04 no. steps = 439 order = 5 stepsize = 7.84e+02 +c1 (bot.left/middle/top rt.) = 5.057e-13 -8.836e-11 -1.020e-12 c2 (bot.left/middle/top rt.) = 3.352e+11 9.106e+11 4.162e+11 @@ -126,8 +126,8 @@ Final Statistics.. lenrw = 2689 leniw = 53 lenrwLS = 3254 leniwLS = 46 nst = 439 -nfe = 565 nfeLS = 858 -nni = 562 nli = 858 +nfe = 564 nfeLS = 858 +nni = 561 nli = 858 nsetups = 77 netf = 26 npe = 8 nps = 858 ncfn = 0 ncfl = 0 @@ -161,31 +161,31 @@ c1 (bot.left/middle/top rt.) = 1.404e+04 2.029e+04 1.561e+04 c2 (bot.left/middle/top rt.) = 3.387e+11 4.894e+11 3.765e+11 t = 4.32e+04 no. steps = 369 order = 4 stepsize = 5.46e+02 -c1 (bot.left/middle/top rt.) = -6.037e-10 -6.053e-10 -5.358e-10 +c1 (bot.left/middle/top rt.) = -9.938e-10 -9.097e-10 -9.708e-10 c2 (bot.left/middle/top rt.) = 3.382e+11 1.355e+11 3.804e+11 -t = 5.04e+04 no. steps = 385 order = 4 stepsize = 3.19e+02 -c1 (bot.left/middle/top rt.) = -1.354e-14 1.127e-12 -4.255e-14 +t = 5.04e+04 no. steps = 385 order = 4 stepsize = 3.20e+02 +c1 (bot.left/middle/top rt.) = -1.367e-14 1.251e-12 -4.382e-14 c2 (bot.left/middle/top rt.) = 3.358e+11 4.930e+11 3.864e+11 -t = 5.76e+04 no. steps = 399 order = 5 stepsize = 5.96e+02 -c1 (bot.left/middle/top rt.) = 3.721e-14 6.437e-12 2.771e-14 +t = 5.76e+04 no. steps = 399 order = 5 stepsize = 5.75e+02 +c1 (bot.left/middle/top rt.) = 4.897e-14 1.134e-11 2.663e-15 c2 (bot.left/middle/top rt.) = 3.320e+11 9.650e+11 3.909e+11 -t = 6.48e+04 no. steps = 411 order = 5 stepsize = 5.96e+02 -c1 (bot.left/middle/top rt.) = -3.191e-14 3.975e-12 -1.260e-13 +t = 6.48e+04 no. steps = 411 order = 5 stepsize = 5.75e+02 +c1 (bot.left/middle/top rt.) = -2.822e-14 3.240e-12 -1.006e-13 c2 (bot.left/middle/top rt.) = 3.313e+11 8.922e+11 3.963e+11 -t = 7.20e+04 no. steps = 423 order = 5 stepsize = 5.96e+02 -c1 (bot.left/middle/top rt.) = -4.209e-15 -1.602e-13 1.053e-15 +t = 7.20e+04 no. steps = 424 order = 5 stepsize = 5.75e+02 +c1 (bot.left/middle/top rt.) = 1.532e-16 5.896e-15 -3.955e-17 c2 (bot.left/middle/top rt.) = 3.330e+11 6.186e+11 4.039e+11 -t = 7.92e+04 no. steps = 435 order = 5 stepsize = 5.96e+02 -c1 (bot.left/middle/top rt.) = -3.762e-23 -1.366e-21 1.010e-23 +t = 7.92e+04 no. steps = 436 order = 5 stepsize = 5.75e+02 +c1 (bot.left/middle/top rt.) = 7.713e-25 8.129e-23 -1.539e-25 c2 (bot.left/middle/top rt.) = 3.334e+11 6.669e+11 4.120e+11 -t = 8.64e+04 no. steps = 447 order = 5 stepsize = 5.96e+02 -c1 (bot.left/middle/top rt.) = -9.999e-27 -1.866e-22 -1.581e-27 +t = 8.64e+04 no. steps = 449 order = 5 stepsize = 5.75e+02 +c1 (bot.left/middle/top rt.) = -7.037e-27 -1.020e-22 -9.928e-28 c2 (bot.left/middle/top rt.) = 3.352e+11 9.107e+11 4.163e+11 @@ -193,11 +193,11 @@ Final Statistics.. lenrw = 2689 leniw = 53 lenrwLS = 2202 leniwLS = 41 -nst = 447 -nfe = 569 nfeLS = 964 -nni = 566 nli = 482 +nst = 449 +nfe = 570 nfeLS = 968 +nni = 567 nli = 484 nsetups = 72 netf = 25 -npe = 8 nps = 1453 +npe = 8 nps = 1459 ncfn = 0 ncfl = 0 --------- @@ -214,55 +214,55 @@ t = 1.44e+04 no. steps = 250 order = 5 stepsize = 3.27e+02 c1 (bot.left/middle/top rt.) = 6.659e+06 5.316e+06 7.301e+06 c2 (bot.left/middle/top rt.) = 2.582e+11 2.057e+11 2.833e+11 -t = 2.16e+04 no. steps = 275 order = 5 stepsize = 3.50e+02 +t = 2.16e+04 no. steps = 275 order = 5 stepsize = 3.49e+02 c1 (bot.left/middle/top rt.) = 2.665e+07 1.036e+07 2.931e+07 c2 (bot.left/middle/top rt.) = 2.993e+11 1.028e+11 3.313e+11 -t = 2.88e+04 no. steps = 298 order = 5 stepsize = 2.18e+02 +t = 2.88e+04 no. steps = 330 order = 4 stepsize = 2.14e+02 c1 (bot.left/middle/top rt.) = 8.702e+06 1.292e+07 9.650e+06 c2 (bot.left/middle/top rt.) = 3.380e+11 5.029e+11 3.751e+11 -t = 3.60e+04 no. steps = 326 order = 5 stepsize = 1.31e+02 +t = 3.60e+04 no. steps = 369 order = 4 stepsize = 9.72e+01 c1 (bot.left/middle/top rt.) = 1.404e+04 2.029e+04 1.561e+04 c2 (bot.left/middle/top rt.) = 3.387e+11 4.894e+11 3.765e+11 -t = 4.32e+04 no. steps = 377 order = 4 stepsize = 3.89e+02 -c1 (bot.left/middle/top rt.) = 5.444e-07 -1.657e-06 6.244e-07 +t = 4.32e+04 no. steps = 439 order = 4 stepsize = 1.70e+02 +c1 (bot.left/middle/top rt.) = -3.131e-08 -1.943e-08 -3.934e-08 c2 (bot.left/middle/top rt.) = 3.382e+11 1.355e+11 3.804e+11 -t = 5.04e+04 no. steps = 391 order = 5 stepsize = 6.79e+02 -c1 (bot.left/middle/top rt.) = -1.730e-09 -6.249e-07 -9.039e-10 +t = 5.04e+04 no. steps = 454 order = 4 stepsize = 3.71e+02 +c1 (bot.left/middle/top rt.) = -4.557e-11 1.086e-09 -8.068e-11 c2 (bot.left/middle/top rt.) = 3.358e+11 4.930e+11 3.864e+11 -t = 5.76e+04 no. steps = 403 order = 5 stepsize = 4.21e+02 -c1 (bot.left/middle/top rt.) = 7.982e-10 2.122e-07 -1.172e-09 +t = 5.76e+04 no. steps = 467 order = 5 stepsize = 5.82e+02 +c1 (bot.left/middle/top rt.) = 5.569e-11 -8.256e-09 -4.063e-11 c2 (bot.left/middle/top rt.) = 3.320e+11 9.650e+11 3.909e+11 -t = 6.48e+04 no. steps = 414 order = 5 stepsize = 6.89e+02 -c1 (bot.left/middle/top rt.) = 1.420e-09 3.489e-07 -2.356e-09 +t = 6.48e+04 no. steps = 479 order = 5 stepsize = 8.84e+02 +c1 (bot.left/middle/top rt.) = 2.899e-10 -1.355e-07 5.869e-10 c2 (bot.left/middle/top rt.) = 3.313e+11 8.922e+11 3.963e+11 -t = 7.20e+04 no. steps = 424 order = 5 stepsize = 6.89e+02 -c1 (bot.left/middle/top rt.) = 1.045e-12 2.583e-10 -1.763e-12 +t = 7.20e+04 no. steps = 489 order = 5 stepsize = 6.53e+02 +c1 (bot.left/middle/top rt.) = 9.493e-14 -4.124e-13 4.162e-14 c2 (bot.left/middle/top rt.) = 3.330e+11 6.186e+11 4.039e+11 -t = 7.92e+04 no. steps = 435 order = 5 stepsize = 6.89e+02 -c1 (bot.left/middle/top rt.) = -2.523e-19 5.442e-16 4.663e-19 +t = 7.92e+04 no. steps = 500 order = 5 stepsize = 6.53e+02 +c1 (bot.left/middle/top rt.) = -4.240e-21 7.214e-18 -5.798e-20 c2 (bot.left/middle/top rt.) = 3.334e+11 6.669e+11 4.120e+11 -t = 8.64e+04 no. steps = 445 order = 5 stepsize = 6.89e+02 -c1 (bot.left/middle/top rt.) = -1.673e-20 -1.128e-15 -3.081e-21 -c2 (bot.left/middle/top rt.) = 3.352e+11 9.106e+11 4.163e+11 +t = 8.64e+04 no. steps = 512 order = 5 stepsize = 6.53e+02 +c1 (bot.left/middle/top rt.) = -2.841e-21 -1.757e-17 2.220e-21 +c2 (bot.left/middle/top rt.) = 3.352e+11 9.107e+11 4.163e+11 Final Statistics.. lenrw = 2689 leniw = 53 lenrwLS = 2602 leniwLS = 43 -nst = 445 -nfe = 558 nfeLS = 1143 -nni = 555 nli = 477 -nsetups = 67 netf = 21 -npe = 8 nps = 1805 +nst = 512 +nfe = 657 nfeLS = 1293 +nni = 654 nli = 557 +nsetups = 90 netf = 29 +npe = 9 nps = 2027 ncfn = 0 ncfl = 0 diff --git a/examples/cvode/serial/cvKrylovDemo_ls_0_1.out b/examples/cvode/serial/cvKrylovDemo_ls_0_1.out index 2a61824c44..45e08fbfd0 100644 --- a/examples/cvode/serial/cvKrylovDemo_ls_0_1.out +++ b/examples/cvode/serial/cvKrylovDemo_ls_0_1.out @@ -94,9 +94,9 @@ ncfn = 0 ncfl = 0 ====================================================================== -t = 2.79e+04 no. steps = 300 order = 4 stepsize = 4.41e+01 -c1 (bot.left/middle/top rt.) = 1.189e+07 1.588e+07 1.317e+07 -c2 (bot.left/middle/top rt.) = 3.375e+11 4.520e+11 3.743e+11 +t = 2.79e+04 no. steps = 300 order = 4 stepsize = 4.39e+01 +c1 (bot.left/middle/top rt.) = 1.190e+07 1.589e+07 1.318e+07 +c2 (bot.left/middle/top rt.) = 3.375e+11 4.519e+11 3.743e+11 Intermediate Statistics.. @@ -112,9 +112,9 @@ ncfn = 0 ncfl = 0 ====================================================================== -t = 3.74e+04 no. steps = 350 order = 5 stepsize = 1.02e+02 -c1 (bot.left/middle/top rt.) = 4.321e+02 5.131e+02 4.808e+02 -c2 (bot.left/middle/top rt.) = 3.387e+11 4.022e+11 3.769e+11 +t = 3.72e+04 no. steps = 350 order = 5 stepsize = 9.92e+01 +c1 (bot.left/middle/top rt.) = 8.729e+02 1.076e+03 9.711e+02 +c2 (bot.left/middle/top rt.) = 3.387e+11 4.175e+11 3.768e+11 Intermediate Statistics.. @@ -122,17 +122,17 @@ Intermediate Statistics.. lenrw = 2689 leniw = 53 lenrwLS = 2454 leniwLS = 42 nst = 350 -nfe = 461 nfeLS = 428 -nni = 458 nli = 428 +nfe = 460 nfeLS = 427 +nni = 457 nli = 427 nsetups = 62 netf = 22 -npe = 6 nps = 837 +npe = 6 nps = 835 ncfn = 0 ncfl = 0 ====================================================================== -t = 4.98e+04 no. steps = 400 order = 4 stepsize = 3.15e+02 -c1 (bot.left/middle/top rt.) = -3.654e-08 -4.295e-06 -6.514e-08 -c2 (bot.left/middle/top rt.) = 3.361e+11 4.418e+11 3.860e+11 +t = 4.50e+04 no. steps = 400 order = 4 stepsize = 2.57e+02 +c1 (bot.left/middle/top rt.) = 1.180e-06 4.444e-05 1.240e-06 +c2 (bot.left/middle/top rt.) = 3.378e+11 1.535e+11 3.819e+11 Intermediate Statistics.. @@ -140,17 +140,17 @@ Intermediate Statistics.. lenrw = 2689 leniw = 53 lenrwLS = 2454 leniwLS = 42 nst = 400 -nfe = 518 nfeLS = 521 -nni = 515 nli = 521 -nsetups = 68 netf = 23 -npe = 7 nps = 985 +nfe = 512 nfeLS = 489 +nni = 509 nli = 489 +nsetups = 66 netf = 22 +npe = 7 nps = 947 ncfn = 0 ncfl = 0 ====================================================================== -t = 7.88e+04 no. steps = 450 order = 5 stepsize = 7.01e+02 -c1 (bot.left/middle/top rt.) = 6.689e-13 3.345e-11 1.269e-12 -c2 (bot.left/middle/top rt.) = 3.334e+11 6.542e+11 4.117e+11 +t = 6.04e+04 no. steps = 450 order = 4 stepsize = 4.44e+02 +c1 (bot.left/middle/top rt.) = -4.474e-08 -3.368e-06 -6.431e-08 +c2 (bot.left/middle/top rt.) = 3.312e+11 9.977e+11 3.927e+11 Intermediate Statistics.. @@ -158,16 +158,16 @@ Intermediate Statistics.. lenrw = 2689 leniw = 53 lenrwLS = 2454 leniwLS = 42 nst = 450 -nfe = 586 nfeLS = 614 -nni = 583 nli = 614 -nsetups = 77 netf = 27 -npe = 8 nps = 1143 +nfe = 588 nfeLS = 577 +nni = 585 nli = 577 +nsetups = 84 netf = 31 +npe = 8 nps = 1109 ncfn = 0 ncfl = 0 ====================================================================== -t = 8.64e+04 no. steps = 461 order = 5 stepsize = 7.01e+02 -c1 (bot.left/middle/top rt.) = 4.144e-14 2.072e-12 7.862e-14 +t = 8.64e+04 no. steps = 491 order = 5 stepsize = 6.72e+02 +c1 (bot.left/middle/top rt.) = -1.017e-13 -7.659e-12 -1.461e-13 c2 (bot.left/middle/top rt.) = 3.352e+11 9.107e+11 4.163e+11 @@ -175,11 +175,11 @@ Final Statistics.. lenrw = 2689 leniw = 53 lenrwLS = 2454 leniwLS = 42 -nst = 461 -nfe = 597 nfeLS = 636 -nni = 594 nli = 636 -nsetups = 78 netf = 27 -npe = 8 nps = 1176 +nst = 491 +nfe = 631 nfeLS = 652 +nni = 628 nli = 652 +nsetups = 86 netf = 31 +npe = 9 nps = 1227 ncfn = 0 ncfl = 0 ====================================================================== @@ -281,7 +281,7 @@ ncfn = 0 ncfl = 0 ====================================================================== t = 3.01e+04 no. steps = 300 order = 4 stepsize = 1.75e+02 -c1 (bot.left/middle/top rt.) = 5.017e+06 8.298e+06 5.570e+06 +c1 (bot.left/middle/top rt.) = 5.017e+06 8.297e+06 5.570e+06 c2 (bot.left/middle/top rt.) = 3.383e+11 5.600e+11 3.757e+11 @@ -299,7 +299,7 @@ ncfn = 0 ncfl = 0 ====================================================================== t = 3.86e+04 no. steps = 350 order = 5 stepsize = 8.38e+01 -c1 (bot.left/middle/top rt.) = 4.314e+00 4.141e+00 4.806e+00 +c1 (bot.left/middle/top rt.) = 4.313e+00 4.140e+00 4.805e+00 c2 (bot.left/middle/top rt.) = 3.387e+11 3.251e+11 3.774e+11 @@ -317,8 +317,8 @@ ncfn = 0 ncfl = 0 ====================================================================== t = 5.68e+04 no. steps = 400 order = 5 stepsize = 7.44e+02 -c1 (bot.left/middle/top rt.) = -1.055e-12 -8.927e-09 2.668e-11 -c2 (bot.left/middle/top rt.) = 3.324e+11 9.373e+11 3.904e+11 +c1 (bot.left/middle/top rt.) = -1.052e-12 -8.980e-09 2.681e-11 +c2 (bot.left/middle/top rt.) = 3.324e+11 9.375e+11 3.904e+11 Intermediate Statistics.. @@ -334,8 +334,8 @@ ncfn = 0 ncfl = 0 ====================================================================== -t = 8.64e+04 no. steps = 439 order = 5 stepsize = 7.86e+02 -c1 (bot.left/middle/top rt.) = 5.687e-13 -9.924e-11 -1.149e-12 +t = 8.64e+04 no. steps = 439 order = 5 stepsize = 7.84e+02 +c1 (bot.left/middle/top rt.) = 5.057e-13 -8.836e-11 -1.020e-12 c2 (bot.left/middle/top rt.) = 3.352e+11 9.106e+11 4.162e+11 @@ -344,8 +344,8 @@ Final Statistics.. lenrw = 2689 leniw = 53 lenrwLS = 3254 leniwLS = 46 nst = 439 -nfe = 565 nfeLS = 858 -nni = 562 nli = 858 +nfe = 564 nfeLS = 858 +nni = 561 nli = 858 nsetups = 77 netf = 26 npe = 8 nps = 858 ncfn = 0 ncfl = 0 @@ -439,7 +439,7 @@ npe = 5 nps = 788 ncfn = 0 ncfl = 0 t = 3.34e+04 no. steps = 300 order = 5 stepsize = 2.67e+02 -c1 (bot.left/middle/top rt.) = 5.232e+05 9.140e+05 5.813e+05 +c1 (bot.left/middle/top rt.) = 5.232e+05 9.141e+05 5.813e+05 c2 (bot.left/middle/top rt.) = 3.385e+11 5.914e+11 3.761e+11 @@ -455,7 +455,7 @@ npe = 5 nps = 975 ncfn = 0 ncfl = 0 t = 3.92e+04 no. steps = 350 order = 5 stepsize = 9.48e+01 -c1 (bot.left/middle/top rt.) = 1.804e-01 1.542e-01 2.011e-01 +c1 (bot.left/middle/top rt.) = 1.803e-01 1.542e-01 2.011e-01 c2 (bot.left/middle/top rt.) = 3.387e+11 2.896e+11 3.776e+11 @@ -470,9 +470,9 @@ nsetups = 63 netf = 23 npe = 6 nps = 1140 ncfn = 0 ncfl = 0 -t = 5.86e+04 no. steps = 400 order = 5 stepsize = 5.96e+02 -c1 (bot.left/middle/top rt.) = 7.894e-14 -5.680e-12 1.260e-13 -c2 (bot.left/middle/top rt.) = 3.317e+11 9.872e+11 3.915e+11 +t = 5.85e+04 no. steps = 400 order = 5 stepsize = 5.75e+02 +c1 (bot.left/middle/top rt.) = 6.557e-14 -5.241e-12 1.117e-13 +c2 (bot.left/middle/top rt.) = 3.317e+11 9.866e+11 3.915e+11 Intermediate Statistics.. @@ -480,14 +480,14 @@ Intermediate Statistics.. lenrw = 2689 leniw = 53 lenrwLS = 2202 leniwLS = 41 nst = 400 -nfe = 522 nfeLS = 870 -nni = 519 nli = 435 +nfe = 521 nfeLS = 870 +nni = 518 nli = 435 nsetups = 70 netf = 25 npe = 7 nps = 1312 ncfn = 0 ncfl = 0 -t = 8.64e+04 no. steps = 447 order = 5 stepsize = 5.96e+02 -c1 (bot.left/middle/top rt.) = -9.999e-27 -1.866e-22 -1.581e-27 +t = 8.64e+04 no. steps = 449 order = 5 stepsize = 5.75e+02 +c1 (bot.left/middle/top rt.) = -7.037e-27 -1.020e-22 -9.928e-28 c2 (bot.left/middle/top rt.) = 3.352e+11 9.107e+11 4.163e+11 @@ -495,11 +495,11 @@ Final Statistics.. lenrw = 2689 leniw = 53 lenrwLS = 2202 leniwLS = 41 -nst = 447 -nfe = 569 nfeLS = 964 -nni = 566 nli = 482 +nst = 449 +nfe = 570 nfeLS = 968 +nni = 567 nli = 484 nsetups = 72 netf = 25 -npe = 8 nps = 1453 +npe = 8 nps = 1459 ncfn = 0 ncfl = 0 --------- @@ -588,9 +588,9 @@ nsetups = 44 netf = 11 npe = 5 nps = 798 ncfn = 0 ncfl = 0 -t = 2.94e+04 no. steps = 300 order = 5 stepsize = 3.39e+02 -c1 (bot.left/middle/top rt.) = 6.796e+06 1.069e+07 7.541e+06 -c2 (bot.left/middle/top rt.) = 3.382e+11 5.329e+11 3.754e+11 +t = 2.76e+04 no. steps = 300 order = 5 stepsize = 1.10e+00 +c1 (bot.left/middle/top rt.) = 1.289e+07 1.661e+07 1.427e+07 +c2 (bot.left/middle/top rt.) = 3.373e+11 4.360e+11 3.739e+11 Intermediate Statistics.. @@ -598,15 +598,15 @@ Intermediate Statistics.. lenrw = 2689 leniw = 53 lenrwLS = 2602 leniwLS = 43 nst = 300 -nfe = 382 nfeLS = 671 -nni = 379 nli = 313 -nsetups = 51 netf = 14 -npe = 6 nps = 1040 +nfe = 391 nfeLS = 678 +nni = 388 nli = 317 +nsetups = 55 netf = 18 +npe = 6 nps = 1051 ncfn = 0 ncfl = 0 -t = 3.87e+04 no. steps = 350 order = 5 stepsize = 9.42e+01 -c1 (bot.left/middle/top rt.) = 3.613e+00 3.443e+00 4.025e+00 -c2 (bot.left/middle/top rt.) = 3.387e+11 3.228e+11 3.774e+11 +t = 3.33e+04 no. steps = 350 order = 4 stepsize = 2.14e+02 +c1 (bot.left/middle/top rt.) = 5.756e+05 1.009e+06 6.395e+05 +c2 (bot.left/middle/top rt.) = 3.385e+11 5.932e+11 3.761e+11 Intermediate Statistics.. @@ -614,15 +614,15 @@ Intermediate Statistics.. lenrw = 2689 leniw = 53 lenrwLS = 2602 leniwLS = 43 nst = 350 -nfe = 448 nfeLS = 840 -nni = 445 nli = 370 -nsetups = 55 netf = 18 -npe = 6 nps = 1324 +nfe = 454 nfeLS = 806 +nni = 451 nli = 369 +nsetups = 69 netf = 20 +npe = 7 nps = 1263 ncfn = 0 ncfl = 0 -t = 5.67e+04 no. steps = 400 order = 5 stepsize = 6.79e+02 -c1 (bot.left/middle/top rt.) = 4.357e-09 5.640e-07 2.278e-09 -c2 (bot.left/middle/top rt.) = 3.324e+11 9.339e+11 3.904e+11 +t = 3.83e+04 no. steps = 400 order = 5 stepsize = 7.34e+01 +c1 (bot.left/middle/top rt.) = 1.891e+01 1.931e+01 2.106e+01 +c2 (bot.left/middle/top rt.) = 3.387e+11 3.459e+11 3.772e+11 Intermediate Statistics.. @@ -630,25 +630,57 @@ Intermediate Statistics.. lenrw = 2689 leniw = 53 lenrwLS = 2602 leniwLS = 43 nst = 400 -nfe = 505 nfeLS = 987 -nni = 502 nli = 424 -nsetups = 62 netf = 19 -npe = 7 nps = 1554 +nfe = 523 nfeLS = 941 +nni = 520 nli = 424 +nsetups = 75 netf = 24 +npe = 7 nps = 1491 +ncfn = 0 ncfl = 0 + +t = 4.91e+04 no. steps = 450 order = 4 stepsize = 3.71e+02 +c1 (bot.left/middle/top rt.) = 6.111e-11 2.392e-08 1.832e-11 +c2 (bot.left/middle/top rt.) = 3.364e+11 3.892e+11 3.855e+11 + + +Intermediate Statistics.. + +lenrw = 2689 leniw = 53 +lenrwLS = 2602 leniwLS = 43 +nst = 450 +nfe = 588 nfeLS = 1100 +nni = 585 nli = 489 +nsetups = 85 netf = 28 +npe = 8 nps = 1720 +ncfn = 0 ncfl = 0 + +t = 7.92e+04 no. steps = 500 order = 5 stepsize = 6.53e+02 +c1 (bot.left/middle/top rt.) = -7.936e-21 -6.429e-18 -6.492e-21 +c2 (bot.left/middle/top rt.) = 3.334e+11 6.673e+11 4.120e+11 + + +Intermediate Statistics.. + +lenrw = 2689 leniw = 53 +lenrwLS = 2602 leniwLS = 43 +nst = 500 +nfe = 645 nfeLS = 1263 +nni = 642 nli = 545 +nsetups = 89 netf = 29 +npe = 9 nps = 1979 ncfn = 0 ncfl = 0 -t = 8.64e+04 no. steps = 445 order = 5 stepsize = 6.89e+02 -c1 (bot.left/middle/top rt.) = -1.673e-20 -1.128e-15 -3.081e-21 -c2 (bot.left/middle/top rt.) = 3.352e+11 9.106e+11 4.163e+11 +t = 8.64e+04 no. steps = 512 order = 5 stepsize = 6.53e+02 +c1 (bot.left/middle/top rt.) = -2.841e-21 -1.757e-17 2.220e-21 +c2 (bot.left/middle/top rt.) = 3.352e+11 9.107e+11 4.163e+11 Final Statistics.. lenrw = 2689 leniw = 53 lenrwLS = 2602 leniwLS = 43 -nst = 445 -nfe = 558 nfeLS = 1143 -nni = 555 nli = 477 -nsetups = 67 netf = 21 -npe = 8 nps = 1805 +nst = 512 +nfe = 657 nfeLS = 1293 +nni = 654 nli = 557 +nsetups = 90 netf = 29 +npe = 9 nps = 2027 ncfn = 0 ncfl = 0 diff --git a/examples/cvode/serial/cvKrylovDemo_ls_1.out b/examples/cvode/serial/cvKrylovDemo_ls_1.out index 6f1196281d..5245d0b27e 100644 --- a/examples/cvode/serial/cvKrylovDemo_ls_1.out +++ b/examples/cvode/serial/cvKrylovDemo_ls_1.out @@ -16,40 +16,40 @@ t = 2.16e+04 no. steps = 277 order = 5 stepsize = 2.75e+02 c1 (bot.left/middle/top rt.) = 2.665e+07 1.036e+07 2.931e+07 c2 (bot.left/middle/top rt.) = 2.993e+11 1.028e+11 3.313e+11 -t = 2.88e+04 no. steps = 307 order = 4 stepsize = 2.01e+02 +t = 2.88e+04 no. steps = 307 order = 4 stepsize = 2.03e+02 c1 (bot.left/middle/top rt.) = 8.702e+06 1.292e+07 9.650e+06 c2 (bot.left/middle/top rt.) = 3.380e+11 5.029e+11 3.751e+11 -t = 3.60e+04 no. steps = 336 order = 5 stepsize = 1.02e+02 +t = 3.60e+04 no. steps = 338 order = 5 stepsize = 9.92e+01 c1 (bot.left/middle/top rt.) = 1.404e+04 2.029e+04 1.561e+04 c2 (bot.left/middle/top rt.) = 3.387e+11 4.894e+11 3.765e+11 -t = 4.32e+04 no. steps = 385 order = 4 stepsize = 4.57e+02 -c1 (bot.left/middle/top rt.) = 5.226e-08 -6.075e-06 8.713e-08 +t = 4.32e+04 no. steps = 393 order = 4 stepsize = 2.57e+02 +c1 (bot.left/middle/top rt.) = -7.685e-06 -9.677e-07 -8.494e-06 c2 (bot.left/middle/top rt.) = 3.382e+11 1.355e+11 3.804e+11 -t = 5.04e+04 no. steps = 403 order = 4 stepsize = 2.77e+02 -c1 (bot.left/middle/top rt.) = -2.670e-08 -4.510e-06 -2.672e-08 +t = 5.04e+04 no. steps = 421 order = 5 stepsize = 4.93e+02 +c1 (bot.left/middle/top rt.) = -1.570e-08 -1.745e-06 -3.070e-08 c2 (bot.left/middle/top rt.) = 3.358e+11 4.930e+11 3.864e+11 -t = 5.76e+04 no. steps = 419 order = 5 stepsize = 3.44e+02 -c1 (bot.left/middle/top rt.) = -1.147e-09 -5.871e-08 -2.195e-09 +t = 5.76e+04 no. steps = 440 order = 5 stepsize = 8.59e+01 +c1 (bot.left/middle/top rt.) = 9.046e-08 6.799e-06 1.298e-07 c2 (bot.left/middle/top rt.) = 3.320e+11 9.650e+11 3.909e+11 -t = 6.48e+04 no. steps = 431 order = 5 stepsize = 9.50e+02 -c1 (bot.left/middle/top rt.) = 3.792e-10 1.901e-08 7.196e-10 +t = 6.48e+04 no. steps = 459 order = 5 stepsize = 6.72e+02 +c1 (bot.left/middle/top rt.) = 4.888e-09 3.680e-07 7.026e-09 c2 (bot.left/middle/top rt.) = 3.313e+11 8.922e+11 3.963e+11 -t = 7.20e+04 no. steps = 441 order = 5 stepsize = 7.01e+02 -c1 (bot.left/middle/top rt.) = -1.872e-11 -9.361e-10 -3.550e-11 +t = 7.20e+04 no. steps = 470 order = 5 stepsize = 6.72e+02 +c1 (bot.left/middle/top rt.) = 7.580e-11 5.711e-09 1.090e-10 c2 (bot.left/middle/top rt.) = 3.330e+11 6.186e+11 4.039e+11 -t = 7.92e+04 no. steps = 451 order = 5 stepsize = 7.01e+02 -c1 (bot.left/middle/top rt.) = 1.365e-13 6.739e-12 2.585e-13 +t = 7.92e+04 no. steps = 481 order = 5 stepsize = 6.72e+02 +c1 (bot.left/middle/top rt.) = 2.772e-13 2.088e-11 4.012e-13 c2 (bot.left/middle/top rt.) = 3.334e+11 6.669e+11 4.120e+11 -t = 8.64e+04 no. steps = 461 order = 5 stepsize = 7.01e+02 -c1 (bot.left/middle/top rt.) = 4.144e-14 2.072e-12 7.862e-14 +t = 8.64e+04 no. steps = 491 order = 5 stepsize = 6.72e+02 +c1 (bot.left/middle/top rt.) = -1.017e-13 -7.659e-12 -1.461e-13 c2 (bot.left/middle/top rt.) = 3.352e+11 9.107e+11 4.163e+11 @@ -57,11 +57,11 @@ Final Statistics.. lenrw = 2689 leniw = 53 lenrwLS = 2454 leniwLS = 42 -nst = 461 -nfe = 597 nfeLS = 636 -nni = 594 nli = 636 -nsetups = 78 netf = 27 -npe = 8 nps = 1176 +nst = 491 +nfe = 631 nfeLS = 652 +nni = 628 nli = 652 +nsetups = 86 netf = 31 +npe = 9 nps = 1227 ncfn = 0 ncfl = 0 ====================================================================== @@ -93,31 +93,31 @@ c1 (bot.left/middle/top rt.) = 1.404e+04 2.029e+04 1.561e+04 c2 (bot.left/middle/top rt.) = 3.387e+11 4.895e+11 3.765e+11 t = 4.32e+04 no. steps = 378 order = 5 stepsize = 5.86e+02 -c1 (bot.left/middle/top rt.) = 1.180e-09 7.956e-08 1.490e-09 +c1 (bot.left/middle/top rt.) = 1.184e-09 7.952e-08 1.494e-09 c2 (bot.left/middle/top rt.) = 3.382e+11 1.355e+11 3.804e+11 -t = 5.04e+04 no. steps = 391 order = 5 stepsize = 4.27e+02 -c1 (bot.left/middle/top rt.) = 6.580e-11 2.809e-08 1.507e-10 +t = 5.04e+04 no. steps = 391 order = 5 stepsize = 4.28e+02 +c1 (bot.left/middle/top rt.) = 6.549e-11 2.778e-08 1.492e-10 c2 (bot.left/middle/top rt.) = 3.358e+11 4.930e+11 3.864e+11 -t = 5.76e+04 no. steps = 402 order = 5 stepsize = 4.96e+02 -c1 (bot.left/middle/top rt.) = 2.069e-10 1.559e-08 2.264e-10 +t = 5.76e+04 no. steps = 402 order = 5 stepsize = 4.97e+02 +c1 (bot.left/middle/top rt.) = 2.130e-10 1.597e-08 2.338e-10 c2 (bot.left/middle/top rt.) = 3.320e+11 9.650e+11 3.909e+11 -t = 6.48e+04 no. steps = 412 order = 5 stepsize = 7.86e+02 -c1 (bot.left/middle/top rt.) = 3.735e-11 -1.076e-09 -3.688e-11 +t = 6.48e+04 no. steps = 412 order = 5 stepsize = 7.84e+02 +c1 (bot.left/middle/top rt.) = 3.694e-11 -1.057e-09 -3.646e-11 c2 (bot.left/middle/top rt.) = 3.313e+11 8.922e+11 3.963e+11 -t = 7.20e+04 no. steps = 421 order = 5 stepsize = 7.86e+02 -c1 (bot.left/middle/top rt.) = -1.410e-11 -1.148e-09 9.417e-11 +t = 7.20e+04 no. steps = 421 order = 5 stepsize = 7.84e+02 +c1 (bot.left/middle/top rt.) = -1.398e-11 -1.129e-09 9.313e-11 c2 (bot.left/middle/top rt.) = 3.330e+11 6.186e+11 4.039e+11 -t = 7.92e+04 no. steps = 430 order = 5 stepsize = 7.86e+02 -c1 (bot.left/middle/top rt.) = 1.671e-12 -2.171e-10 -4.471e-12 +t = 7.92e+04 no. steps = 430 order = 5 stepsize = 7.84e+02 +c1 (bot.left/middle/top rt.) = 1.779e-12 -2.371e-10 -4.669e-12 c2 (bot.left/middle/top rt.) = 3.334e+11 6.669e+11 4.120e+11 -t = 8.64e+04 no. steps = 439 order = 5 stepsize = 7.86e+02 -c1 (bot.left/middle/top rt.) = 5.687e-13 -9.924e-11 -1.149e-12 +t = 8.64e+04 no. steps = 439 order = 5 stepsize = 7.84e+02 +c1 (bot.left/middle/top rt.) = 5.057e-13 -8.836e-11 -1.020e-12 c2 (bot.left/middle/top rt.) = 3.352e+11 9.106e+11 4.162e+11 @@ -126,8 +126,8 @@ Final Statistics.. lenrw = 2689 leniw = 53 lenrwLS = 3254 leniwLS = 46 nst = 439 -nfe = 565 nfeLS = 858 -nni = 562 nli = 858 +nfe = 564 nfeLS = 858 +nni = 561 nli = 858 nsetups = 77 netf = 26 npe = 8 nps = 858 ncfn = 0 ncfl = 0 @@ -161,31 +161,31 @@ c1 (bot.left/middle/top rt.) = 1.404e+04 2.029e+04 1.561e+04 c2 (bot.left/middle/top rt.) = 3.387e+11 4.894e+11 3.765e+11 t = 4.32e+04 no. steps = 369 order = 4 stepsize = 5.46e+02 -c1 (bot.left/middle/top rt.) = -6.037e-10 -6.053e-10 -5.358e-10 +c1 (bot.left/middle/top rt.) = -9.938e-10 -9.097e-10 -9.708e-10 c2 (bot.left/middle/top rt.) = 3.382e+11 1.355e+11 3.804e+11 -t = 5.04e+04 no. steps = 385 order = 4 stepsize = 3.19e+02 -c1 (bot.left/middle/top rt.) = -1.354e-14 1.127e-12 -4.255e-14 +t = 5.04e+04 no. steps = 385 order = 4 stepsize = 3.20e+02 +c1 (bot.left/middle/top rt.) = -1.367e-14 1.251e-12 -4.382e-14 c2 (bot.left/middle/top rt.) = 3.358e+11 4.930e+11 3.864e+11 -t = 5.76e+04 no. steps = 399 order = 5 stepsize = 5.96e+02 -c1 (bot.left/middle/top rt.) = 3.721e-14 6.437e-12 2.771e-14 +t = 5.76e+04 no. steps = 399 order = 5 stepsize = 5.75e+02 +c1 (bot.left/middle/top rt.) = 4.897e-14 1.134e-11 2.663e-15 c2 (bot.left/middle/top rt.) = 3.320e+11 9.650e+11 3.909e+11 -t = 6.48e+04 no. steps = 411 order = 5 stepsize = 5.96e+02 -c1 (bot.left/middle/top rt.) = -3.191e-14 3.975e-12 -1.260e-13 +t = 6.48e+04 no. steps = 411 order = 5 stepsize = 5.75e+02 +c1 (bot.left/middle/top rt.) = -2.822e-14 3.240e-12 -1.006e-13 c2 (bot.left/middle/top rt.) = 3.313e+11 8.922e+11 3.963e+11 -t = 7.20e+04 no. steps = 423 order = 5 stepsize = 5.96e+02 -c1 (bot.left/middle/top rt.) = -4.209e-15 -1.602e-13 1.053e-15 +t = 7.20e+04 no. steps = 424 order = 5 stepsize = 5.75e+02 +c1 (bot.left/middle/top rt.) = 1.532e-16 5.896e-15 -3.955e-17 c2 (bot.left/middle/top rt.) = 3.330e+11 6.186e+11 4.039e+11 -t = 7.92e+04 no. steps = 435 order = 5 stepsize = 5.96e+02 -c1 (bot.left/middle/top rt.) = -3.762e-23 -1.366e-21 1.010e-23 +t = 7.92e+04 no. steps = 436 order = 5 stepsize = 5.75e+02 +c1 (bot.left/middle/top rt.) = 7.713e-25 8.129e-23 -1.539e-25 c2 (bot.left/middle/top rt.) = 3.334e+11 6.669e+11 4.120e+11 -t = 8.64e+04 no. steps = 447 order = 5 stepsize = 5.96e+02 -c1 (bot.left/middle/top rt.) = -9.999e-27 -1.866e-22 -1.581e-27 +t = 8.64e+04 no. steps = 449 order = 5 stepsize = 5.75e+02 +c1 (bot.left/middle/top rt.) = -7.037e-27 -1.020e-22 -9.928e-28 c2 (bot.left/middle/top rt.) = 3.352e+11 9.107e+11 4.163e+11 @@ -193,11 +193,11 @@ Final Statistics.. lenrw = 2689 leniw = 53 lenrwLS = 2202 leniwLS = 41 -nst = 447 -nfe = 569 nfeLS = 964 -nni = 566 nli = 482 +nst = 449 +nfe = 570 nfeLS = 968 +nni = 567 nli = 484 nsetups = 72 netf = 25 -npe = 8 nps = 1453 +npe = 8 nps = 1459 ncfn = 0 ncfl = 0 --------- @@ -214,55 +214,55 @@ t = 1.44e+04 no. steps = 250 order = 5 stepsize = 3.27e+02 c1 (bot.left/middle/top rt.) = 6.659e+06 5.316e+06 7.301e+06 c2 (bot.left/middle/top rt.) = 2.582e+11 2.057e+11 2.833e+11 -t = 2.16e+04 no. steps = 275 order = 5 stepsize = 3.50e+02 +t = 2.16e+04 no. steps = 275 order = 5 stepsize = 3.49e+02 c1 (bot.left/middle/top rt.) = 2.665e+07 1.036e+07 2.931e+07 c2 (bot.left/middle/top rt.) = 2.993e+11 1.028e+11 3.313e+11 -t = 2.88e+04 no. steps = 298 order = 5 stepsize = 2.18e+02 +t = 2.88e+04 no. steps = 330 order = 4 stepsize = 2.14e+02 c1 (bot.left/middle/top rt.) = 8.702e+06 1.292e+07 9.650e+06 c2 (bot.left/middle/top rt.) = 3.380e+11 5.029e+11 3.751e+11 -t = 3.60e+04 no. steps = 326 order = 5 stepsize = 1.31e+02 +t = 3.60e+04 no. steps = 369 order = 4 stepsize = 9.72e+01 c1 (bot.left/middle/top rt.) = 1.404e+04 2.029e+04 1.561e+04 c2 (bot.left/middle/top rt.) = 3.387e+11 4.894e+11 3.765e+11 -t = 4.32e+04 no. steps = 377 order = 4 stepsize = 3.89e+02 -c1 (bot.left/middle/top rt.) = 5.444e-07 -1.657e-06 6.244e-07 +t = 4.32e+04 no. steps = 439 order = 4 stepsize = 1.70e+02 +c1 (bot.left/middle/top rt.) = -3.131e-08 -1.943e-08 -3.934e-08 c2 (bot.left/middle/top rt.) = 3.382e+11 1.355e+11 3.804e+11 -t = 5.04e+04 no. steps = 391 order = 5 stepsize = 6.79e+02 -c1 (bot.left/middle/top rt.) = -1.730e-09 -6.249e-07 -9.039e-10 +t = 5.04e+04 no. steps = 454 order = 4 stepsize = 3.71e+02 +c1 (bot.left/middle/top rt.) = -4.557e-11 1.086e-09 -8.068e-11 c2 (bot.left/middle/top rt.) = 3.358e+11 4.930e+11 3.864e+11 -t = 5.76e+04 no. steps = 403 order = 5 stepsize = 4.21e+02 -c1 (bot.left/middle/top rt.) = 7.982e-10 2.122e-07 -1.172e-09 +t = 5.76e+04 no. steps = 467 order = 5 stepsize = 5.82e+02 +c1 (bot.left/middle/top rt.) = 5.569e-11 -8.256e-09 -4.063e-11 c2 (bot.left/middle/top rt.) = 3.320e+11 9.650e+11 3.909e+11 -t = 6.48e+04 no. steps = 414 order = 5 stepsize = 6.89e+02 -c1 (bot.left/middle/top rt.) = 1.420e-09 3.489e-07 -2.356e-09 +t = 6.48e+04 no. steps = 479 order = 5 stepsize = 8.84e+02 +c1 (bot.left/middle/top rt.) = 2.899e-10 -1.355e-07 5.869e-10 c2 (bot.left/middle/top rt.) = 3.313e+11 8.922e+11 3.963e+11 -t = 7.20e+04 no. steps = 424 order = 5 stepsize = 6.89e+02 -c1 (bot.left/middle/top rt.) = 1.045e-12 2.583e-10 -1.763e-12 +t = 7.20e+04 no. steps = 489 order = 5 stepsize = 6.53e+02 +c1 (bot.left/middle/top rt.) = 9.493e-14 -4.124e-13 4.162e-14 c2 (bot.left/middle/top rt.) = 3.330e+11 6.186e+11 4.039e+11 -t = 7.92e+04 no. steps = 435 order = 5 stepsize = 6.89e+02 -c1 (bot.left/middle/top rt.) = -2.523e-19 5.442e-16 4.663e-19 +t = 7.92e+04 no. steps = 500 order = 5 stepsize = 6.53e+02 +c1 (bot.left/middle/top rt.) = -4.240e-21 7.214e-18 -5.798e-20 c2 (bot.left/middle/top rt.) = 3.334e+11 6.669e+11 4.120e+11 -t = 8.64e+04 no. steps = 445 order = 5 stepsize = 6.89e+02 -c1 (bot.left/middle/top rt.) = -1.673e-20 -1.128e-15 -3.081e-21 -c2 (bot.left/middle/top rt.) = 3.352e+11 9.106e+11 4.163e+11 +t = 8.64e+04 no. steps = 512 order = 5 stepsize = 6.53e+02 +c1 (bot.left/middle/top rt.) = -2.841e-21 -1.757e-17 2.220e-21 +c2 (bot.left/middle/top rt.) = 3.352e+11 9.107e+11 4.163e+11 Final Statistics.. lenrw = 2689 leniw = 53 lenrwLS = 2602 leniwLS = 43 -nst = 445 -nfe = 558 nfeLS = 1143 -nni = 555 nli = 477 -nsetups = 67 netf = 21 -npe = 8 nps = 1805 +nst = 512 +nfe = 657 nfeLS = 1293 +nni = 654 nli = 557 +nsetups = 90 netf = 29 +npe = 9 nps = 2027 ncfn = 0 ncfl = 0 diff --git a/examples/cvode/serial/cvKrylovDemo_ls_2.out b/examples/cvode/serial/cvKrylovDemo_ls_2.out index 6f1196281d..5245d0b27e 100644 --- a/examples/cvode/serial/cvKrylovDemo_ls_2.out +++ b/examples/cvode/serial/cvKrylovDemo_ls_2.out @@ -16,40 +16,40 @@ t = 2.16e+04 no. steps = 277 order = 5 stepsize = 2.75e+02 c1 (bot.left/middle/top rt.) = 2.665e+07 1.036e+07 2.931e+07 c2 (bot.left/middle/top rt.) = 2.993e+11 1.028e+11 3.313e+11 -t = 2.88e+04 no. steps = 307 order = 4 stepsize = 2.01e+02 +t = 2.88e+04 no. steps = 307 order = 4 stepsize = 2.03e+02 c1 (bot.left/middle/top rt.) = 8.702e+06 1.292e+07 9.650e+06 c2 (bot.left/middle/top rt.) = 3.380e+11 5.029e+11 3.751e+11 -t = 3.60e+04 no. steps = 336 order = 5 stepsize = 1.02e+02 +t = 3.60e+04 no. steps = 338 order = 5 stepsize = 9.92e+01 c1 (bot.left/middle/top rt.) = 1.404e+04 2.029e+04 1.561e+04 c2 (bot.left/middle/top rt.) = 3.387e+11 4.894e+11 3.765e+11 -t = 4.32e+04 no. steps = 385 order = 4 stepsize = 4.57e+02 -c1 (bot.left/middle/top rt.) = 5.226e-08 -6.075e-06 8.713e-08 +t = 4.32e+04 no. steps = 393 order = 4 stepsize = 2.57e+02 +c1 (bot.left/middle/top rt.) = -7.685e-06 -9.677e-07 -8.494e-06 c2 (bot.left/middle/top rt.) = 3.382e+11 1.355e+11 3.804e+11 -t = 5.04e+04 no. steps = 403 order = 4 stepsize = 2.77e+02 -c1 (bot.left/middle/top rt.) = -2.670e-08 -4.510e-06 -2.672e-08 +t = 5.04e+04 no. steps = 421 order = 5 stepsize = 4.93e+02 +c1 (bot.left/middle/top rt.) = -1.570e-08 -1.745e-06 -3.070e-08 c2 (bot.left/middle/top rt.) = 3.358e+11 4.930e+11 3.864e+11 -t = 5.76e+04 no. steps = 419 order = 5 stepsize = 3.44e+02 -c1 (bot.left/middle/top rt.) = -1.147e-09 -5.871e-08 -2.195e-09 +t = 5.76e+04 no. steps = 440 order = 5 stepsize = 8.59e+01 +c1 (bot.left/middle/top rt.) = 9.046e-08 6.799e-06 1.298e-07 c2 (bot.left/middle/top rt.) = 3.320e+11 9.650e+11 3.909e+11 -t = 6.48e+04 no. steps = 431 order = 5 stepsize = 9.50e+02 -c1 (bot.left/middle/top rt.) = 3.792e-10 1.901e-08 7.196e-10 +t = 6.48e+04 no. steps = 459 order = 5 stepsize = 6.72e+02 +c1 (bot.left/middle/top rt.) = 4.888e-09 3.680e-07 7.026e-09 c2 (bot.left/middle/top rt.) = 3.313e+11 8.922e+11 3.963e+11 -t = 7.20e+04 no. steps = 441 order = 5 stepsize = 7.01e+02 -c1 (bot.left/middle/top rt.) = -1.872e-11 -9.361e-10 -3.550e-11 +t = 7.20e+04 no. steps = 470 order = 5 stepsize = 6.72e+02 +c1 (bot.left/middle/top rt.) = 7.580e-11 5.711e-09 1.090e-10 c2 (bot.left/middle/top rt.) = 3.330e+11 6.186e+11 4.039e+11 -t = 7.92e+04 no. steps = 451 order = 5 stepsize = 7.01e+02 -c1 (bot.left/middle/top rt.) = 1.365e-13 6.739e-12 2.585e-13 +t = 7.92e+04 no. steps = 481 order = 5 stepsize = 6.72e+02 +c1 (bot.left/middle/top rt.) = 2.772e-13 2.088e-11 4.012e-13 c2 (bot.left/middle/top rt.) = 3.334e+11 6.669e+11 4.120e+11 -t = 8.64e+04 no. steps = 461 order = 5 stepsize = 7.01e+02 -c1 (bot.left/middle/top rt.) = 4.144e-14 2.072e-12 7.862e-14 +t = 8.64e+04 no. steps = 491 order = 5 stepsize = 6.72e+02 +c1 (bot.left/middle/top rt.) = -1.017e-13 -7.659e-12 -1.461e-13 c2 (bot.left/middle/top rt.) = 3.352e+11 9.107e+11 4.163e+11 @@ -57,11 +57,11 @@ Final Statistics.. lenrw = 2689 leniw = 53 lenrwLS = 2454 leniwLS = 42 -nst = 461 -nfe = 597 nfeLS = 636 -nni = 594 nli = 636 -nsetups = 78 netf = 27 -npe = 8 nps = 1176 +nst = 491 +nfe = 631 nfeLS = 652 +nni = 628 nli = 652 +nsetups = 86 netf = 31 +npe = 9 nps = 1227 ncfn = 0 ncfl = 0 ====================================================================== @@ -93,31 +93,31 @@ c1 (bot.left/middle/top rt.) = 1.404e+04 2.029e+04 1.561e+04 c2 (bot.left/middle/top rt.) = 3.387e+11 4.895e+11 3.765e+11 t = 4.32e+04 no. steps = 378 order = 5 stepsize = 5.86e+02 -c1 (bot.left/middle/top rt.) = 1.180e-09 7.956e-08 1.490e-09 +c1 (bot.left/middle/top rt.) = 1.184e-09 7.952e-08 1.494e-09 c2 (bot.left/middle/top rt.) = 3.382e+11 1.355e+11 3.804e+11 -t = 5.04e+04 no. steps = 391 order = 5 stepsize = 4.27e+02 -c1 (bot.left/middle/top rt.) = 6.580e-11 2.809e-08 1.507e-10 +t = 5.04e+04 no. steps = 391 order = 5 stepsize = 4.28e+02 +c1 (bot.left/middle/top rt.) = 6.549e-11 2.778e-08 1.492e-10 c2 (bot.left/middle/top rt.) = 3.358e+11 4.930e+11 3.864e+11 -t = 5.76e+04 no. steps = 402 order = 5 stepsize = 4.96e+02 -c1 (bot.left/middle/top rt.) = 2.069e-10 1.559e-08 2.264e-10 +t = 5.76e+04 no. steps = 402 order = 5 stepsize = 4.97e+02 +c1 (bot.left/middle/top rt.) = 2.130e-10 1.597e-08 2.338e-10 c2 (bot.left/middle/top rt.) = 3.320e+11 9.650e+11 3.909e+11 -t = 6.48e+04 no. steps = 412 order = 5 stepsize = 7.86e+02 -c1 (bot.left/middle/top rt.) = 3.735e-11 -1.076e-09 -3.688e-11 +t = 6.48e+04 no. steps = 412 order = 5 stepsize = 7.84e+02 +c1 (bot.left/middle/top rt.) = 3.694e-11 -1.057e-09 -3.646e-11 c2 (bot.left/middle/top rt.) = 3.313e+11 8.922e+11 3.963e+11 -t = 7.20e+04 no. steps = 421 order = 5 stepsize = 7.86e+02 -c1 (bot.left/middle/top rt.) = -1.410e-11 -1.148e-09 9.417e-11 +t = 7.20e+04 no. steps = 421 order = 5 stepsize = 7.84e+02 +c1 (bot.left/middle/top rt.) = -1.398e-11 -1.129e-09 9.313e-11 c2 (bot.left/middle/top rt.) = 3.330e+11 6.186e+11 4.039e+11 -t = 7.92e+04 no. steps = 430 order = 5 stepsize = 7.86e+02 -c1 (bot.left/middle/top rt.) = 1.671e-12 -2.171e-10 -4.471e-12 +t = 7.92e+04 no. steps = 430 order = 5 stepsize = 7.84e+02 +c1 (bot.left/middle/top rt.) = 1.779e-12 -2.371e-10 -4.669e-12 c2 (bot.left/middle/top rt.) = 3.334e+11 6.669e+11 4.120e+11 -t = 8.64e+04 no. steps = 439 order = 5 stepsize = 7.86e+02 -c1 (bot.left/middle/top rt.) = 5.687e-13 -9.924e-11 -1.149e-12 +t = 8.64e+04 no. steps = 439 order = 5 stepsize = 7.84e+02 +c1 (bot.left/middle/top rt.) = 5.057e-13 -8.836e-11 -1.020e-12 c2 (bot.left/middle/top rt.) = 3.352e+11 9.106e+11 4.162e+11 @@ -126,8 +126,8 @@ Final Statistics.. lenrw = 2689 leniw = 53 lenrwLS = 3254 leniwLS = 46 nst = 439 -nfe = 565 nfeLS = 858 -nni = 562 nli = 858 +nfe = 564 nfeLS = 858 +nni = 561 nli = 858 nsetups = 77 netf = 26 npe = 8 nps = 858 ncfn = 0 ncfl = 0 @@ -161,31 +161,31 @@ c1 (bot.left/middle/top rt.) = 1.404e+04 2.029e+04 1.561e+04 c2 (bot.left/middle/top rt.) = 3.387e+11 4.894e+11 3.765e+11 t = 4.32e+04 no. steps = 369 order = 4 stepsize = 5.46e+02 -c1 (bot.left/middle/top rt.) = -6.037e-10 -6.053e-10 -5.358e-10 +c1 (bot.left/middle/top rt.) = -9.938e-10 -9.097e-10 -9.708e-10 c2 (bot.left/middle/top rt.) = 3.382e+11 1.355e+11 3.804e+11 -t = 5.04e+04 no. steps = 385 order = 4 stepsize = 3.19e+02 -c1 (bot.left/middle/top rt.) = -1.354e-14 1.127e-12 -4.255e-14 +t = 5.04e+04 no. steps = 385 order = 4 stepsize = 3.20e+02 +c1 (bot.left/middle/top rt.) = -1.367e-14 1.251e-12 -4.382e-14 c2 (bot.left/middle/top rt.) = 3.358e+11 4.930e+11 3.864e+11 -t = 5.76e+04 no. steps = 399 order = 5 stepsize = 5.96e+02 -c1 (bot.left/middle/top rt.) = 3.721e-14 6.437e-12 2.771e-14 +t = 5.76e+04 no. steps = 399 order = 5 stepsize = 5.75e+02 +c1 (bot.left/middle/top rt.) = 4.897e-14 1.134e-11 2.663e-15 c2 (bot.left/middle/top rt.) = 3.320e+11 9.650e+11 3.909e+11 -t = 6.48e+04 no. steps = 411 order = 5 stepsize = 5.96e+02 -c1 (bot.left/middle/top rt.) = -3.191e-14 3.975e-12 -1.260e-13 +t = 6.48e+04 no. steps = 411 order = 5 stepsize = 5.75e+02 +c1 (bot.left/middle/top rt.) = -2.822e-14 3.240e-12 -1.006e-13 c2 (bot.left/middle/top rt.) = 3.313e+11 8.922e+11 3.963e+11 -t = 7.20e+04 no. steps = 423 order = 5 stepsize = 5.96e+02 -c1 (bot.left/middle/top rt.) = -4.209e-15 -1.602e-13 1.053e-15 +t = 7.20e+04 no. steps = 424 order = 5 stepsize = 5.75e+02 +c1 (bot.left/middle/top rt.) = 1.532e-16 5.896e-15 -3.955e-17 c2 (bot.left/middle/top rt.) = 3.330e+11 6.186e+11 4.039e+11 -t = 7.92e+04 no. steps = 435 order = 5 stepsize = 5.96e+02 -c1 (bot.left/middle/top rt.) = -3.762e-23 -1.366e-21 1.010e-23 +t = 7.92e+04 no. steps = 436 order = 5 stepsize = 5.75e+02 +c1 (bot.left/middle/top rt.) = 7.713e-25 8.129e-23 -1.539e-25 c2 (bot.left/middle/top rt.) = 3.334e+11 6.669e+11 4.120e+11 -t = 8.64e+04 no. steps = 447 order = 5 stepsize = 5.96e+02 -c1 (bot.left/middle/top rt.) = -9.999e-27 -1.866e-22 -1.581e-27 +t = 8.64e+04 no. steps = 449 order = 5 stepsize = 5.75e+02 +c1 (bot.left/middle/top rt.) = -7.037e-27 -1.020e-22 -9.928e-28 c2 (bot.left/middle/top rt.) = 3.352e+11 9.107e+11 4.163e+11 @@ -193,11 +193,11 @@ Final Statistics.. lenrw = 2689 leniw = 53 lenrwLS = 2202 leniwLS = 41 -nst = 447 -nfe = 569 nfeLS = 964 -nni = 566 nli = 482 +nst = 449 +nfe = 570 nfeLS = 968 +nni = 567 nli = 484 nsetups = 72 netf = 25 -npe = 8 nps = 1453 +npe = 8 nps = 1459 ncfn = 0 ncfl = 0 --------- @@ -214,55 +214,55 @@ t = 1.44e+04 no. steps = 250 order = 5 stepsize = 3.27e+02 c1 (bot.left/middle/top rt.) = 6.659e+06 5.316e+06 7.301e+06 c2 (bot.left/middle/top rt.) = 2.582e+11 2.057e+11 2.833e+11 -t = 2.16e+04 no. steps = 275 order = 5 stepsize = 3.50e+02 +t = 2.16e+04 no. steps = 275 order = 5 stepsize = 3.49e+02 c1 (bot.left/middle/top rt.) = 2.665e+07 1.036e+07 2.931e+07 c2 (bot.left/middle/top rt.) = 2.993e+11 1.028e+11 3.313e+11 -t = 2.88e+04 no. steps = 298 order = 5 stepsize = 2.18e+02 +t = 2.88e+04 no. steps = 330 order = 4 stepsize = 2.14e+02 c1 (bot.left/middle/top rt.) = 8.702e+06 1.292e+07 9.650e+06 c2 (bot.left/middle/top rt.) = 3.380e+11 5.029e+11 3.751e+11 -t = 3.60e+04 no. steps = 326 order = 5 stepsize = 1.31e+02 +t = 3.60e+04 no. steps = 369 order = 4 stepsize = 9.72e+01 c1 (bot.left/middle/top rt.) = 1.404e+04 2.029e+04 1.561e+04 c2 (bot.left/middle/top rt.) = 3.387e+11 4.894e+11 3.765e+11 -t = 4.32e+04 no. steps = 377 order = 4 stepsize = 3.89e+02 -c1 (bot.left/middle/top rt.) = 5.444e-07 -1.657e-06 6.244e-07 +t = 4.32e+04 no. steps = 439 order = 4 stepsize = 1.70e+02 +c1 (bot.left/middle/top rt.) = -3.131e-08 -1.943e-08 -3.934e-08 c2 (bot.left/middle/top rt.) = 3.382e+11 1.355e+11 3.804e+11 -t = 5.04e+04 no. steps = 391 order = 5 stepsize = 6.79e+02 -c1 (bot.left/middle/top rt.) = -1.730e-09 -6.249e-07 -9.039e-10 +t = 5.04e+04 no. steps = 454 order = 4 stepsize = 3.71e+02 +c1 (bot.left/middle/top rt.) = -4.557e-11 1.086e-09 -8.068e-11 c2 (bot.left/middle/top rt.) = 3.358e+11 4.930e+11 3.864e+11 -t = 5.76e+04 no. steps = 403 order = 5 stepsize = 4.21e+02 -c1 (bot.left/middle/top rt.) = 7.982e-10 2.122e-07 -1.172e-09 +t = 5.76e+04 no. steps = 467 order = 5 stepsize = 5.82e+02 +c1 (bot.left/middle/top rt.) = 5.569e-11 -8.256e-09 -4.063e-11 c2 (bot.left/middle/top rt.) = 3.320e+11 9.650e+11 3.909e+11 -t = 6.48e+04 no. steps = 414 order = 5 stepsize = 6.89e+02 -c1 (bot.left/middle/top rt.) = 1.420e-09 3.489e-07 -2.356e-09 +t = 6.48e+04 no. steps = 479 order = 5 stepsize = 8.84e+02 +c1 (bot.left/middle/top rt.) = 2.899e-10 -1.355e-07 5.869e-10 c2 (bot.left/middle/top rt.) = 3.313e+11 8.922e+11 3.963e+11 -t = 7.20e+04 no. steps = 424 order = 5 stepsize = 6.89e+02 -c1 (bot.left/middle/top rt.) = 1.045e-12 2.583e-10 -1.763e-12 +t = 7.20e+04 no. steps = 489 order = 5 stepsize = 6.53e+02 +c1 (bot.left/middle/top rt.) = 9.493e-14 -4.124e-13 4.162e-14 c2 (bot.left/middle/top rt.) = 3.330e+11 6.186e+11 4.039e+11 -t = 7.92e+04 no. steps = 435 order = 5 stepsize = 6.89e+02 -c1 (bot.left/middle/top rt.) = -2.523e-19 5.442e-16 4.663e-19 +t = 7.92e+04 no. steps = 500 order = 5 stepsize = 6.53e+02 +c1 (bot.left/middle/top rt.) = -4.240e-21 7.214e-18 -5.798e-20 c2 (bot.left/middle/top rt.) = 3.334e+11 6.669e+11 4.120e+11 -t = 8.64e+04 no. steps = 445 order = 5 stepsize = 6.89e+02 -c1 (bot.left/middle/top rt.) = -1.673e-20 -1.128e-15 -3.081e-21 -c2 (bot.left/middle/top rt.) = 3.352e+11 9.106e+11 4.163e+11 +t = 8.64e+04 no. steps = 512 order = 5 stepsize = 6.53e+02 +c1 (bot.left/middle/top rt.) = -2.841e-21 -1.757e-17 2.220e-21 +c2 (bot.left/middle/top rt.) = 3.352e+11 9.107e+11 4.163e+11 Final Statistics.. lenrw = 2689 leniw = 53 lenrwLS = 2602 leniwLS = 43 -nst = 445 -nfe = 558 nfeLS = 1143 -nni = 555 nli = 477 -nsetups = 67 netf = 21 -npe = 8 nps = 1805 +nst = 512 +nfe = 657 nfeLS = 1293 +nni = 654 nli = 557 +nsetups = 90 netf = 29 +npe = 9 nps = 2027 ncfn = 0 ncfl = 0 diff --git a/examples/cvode/serial/cvKrylovDemo_prec.c b/examples/cvode/serial/cvKrylovDemo_prec.c index 9975217d35..51b4638aae 100644 --- a/examples/cvode/serial/cvKrylovDemo_prec.c +++ b/examples/cvode/serial/cvKrylovDemo_prec.c @@ -110,16 +110,6 @@ #include /* definition of sunrealtype */ #include /* access to SPGMR SUNLinearSolver */ -/* helpful macros */ - -#ifndef MAX -#define MAX(A, B) ((A) > (B) ? (A) : (B)) -#endif - -#ifndef SQR -#define SQR(A) ((A) * (A)) -#endif - /* Constants */ #define ZERO SUN_RCONST(0.0) @@ -420,8 +410,8 @@ static void InitUserData(WebData wdata) dy = wdata->dy = DY; for (i = 0; i < ns; i++) { - cox[i] = diff[i] / SQR(dx); - coy[i] = diff[i] / SQR(dy); + cox[i] = diff[i] / SUNSQR(dx); + coy[i] = diff[i] / SUNSQR(dy); } /* Set remaining method parameters */ @@ -430,7 +420,7 @@ static void InitUserData(WebData wdata) wdata->mq = MQ; wdata->mx = MX; wdata->my = MY; - wdata->srur = sqrt(SUN_UNIT_ROUNDOFF); + wdata->srur = SUNRsqrt(SUN_UNIT_ROUNDOFF); wdata->mxmp = MXMP; wdata->ngrp = NGRP; wdata->ngx = NGX; @@ -479,17 +469,17 @@ static void CInit(N_Vector c, WebData wdata) dx = wdata->dx; dy = wdata->dy; - x_factor = SUN_RCONST(4.0) / SQR(AX); - y_factor = SUN_RCONST(4.0) / SQR(AY); + x_factor = SUN_RCONST(4.0) / SUNSQR(AX); + y_factor = SUN_RCONST(4.0) / SUNSQR(AY); for (jy = 0; jy < MY; jy++) { y = jy * dy; - argy = SQR(y_factor * y * (AY - y)); + argy = SUNSQR(y_factor * y * (AY - y)); iyoff = mxns * jy; for (jx = 0; jx < MX; jx++) { x = jx * dx; - argx = SQR(x_factor * x * (AX - x)); + argx = SUNSQR(x_factor * x * (AX - x)); ioff = iyoff + ns * jx; for (i = 1; i <= ns; i++) { @@ -505,16 +495,16 @@ static void PrintIntro(void) printf("\n\nDemonstration program for CVODE - SPGMR linear solver\n\n"); printf("Food web problem with ns species, ns = %d\n", NS); printf("Predator-prey interaction and diffusion on a 2-D square\n\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Matrix parameters: a = %.2Qg e = %.2Qg g = %.2Qg\n", AA, EE, GG); + printf("b parameter = %.2Qg\n", BB); + printf("Diffusion coefficients: Dprey = %.2Qg Dpred = %.2Qg\n", DPREY, DPRED); + printf("Rate parameter alpha = %.2Qg\n\n", ALPHA); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Matrix parameters: a = %.2Lg e = %.2Lg g = %.2Lg\n", AA, EE, GG); printf("b parameter = %.2Lg\n", BB); printf("Diffusion coefficients: Dprey = %.2Lg Dpred = %.2Lg\n", DPREY, DPRED); printf("Rate parameter alpha = %.2Lg\n\n", ALPHA); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Matrix parameters: a = %.2g e = %.2g g = %.2g\n", AA, EE, GG); - printf("b parameter = %.2g\n", BB); - printf("Diffusion coefficients: Dprey = %.2g Dpred = %.2g\n", DPREY, DPRED); - printf("Rate parameter alpha = %.2g\n\n", ALPHA); #else printf("Matrix parameters: a = %.2g e = %.2g g = %.2g\n", AA, EE, GG); printf("b parameter = %.2g\n", BB); @@ -523,10 +513,10 @@ static void PrintIntro(void) #endif printf("Mesh dimensions (mx,my) are %d, %d. ", MX, MY); printf("Total system size is neq = %d \n\n", NEQ); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerances: reltol = %.2Qg, abstol = %.2Qg \n\n", RTOL, ATOL); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerances: reltol = %.2Lg, abstol = %.2Lg \n\n", RTOL, ATOL); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerances: reltol = %.2g, abstol = %.2g \n\n", RTOL, ATOL); #else printf("Tolerances: reltol = %.2g, abstol = %.2g \n\n", RTOL, ATOL); #endif @@ -571,10 +561,10 @@ static void PrintAllSpecies(N_Vector c, int ns, int mxns, sunrealtype t) sunrealtype* cdata; cdata = N_VGetArrayPointer(c); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("c values at t = %Qg:\n\n", t); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("c values at t = %Lg:\n\n", t); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("c values at t = %g:\n\n", t); #else printf("c values at t = %g:\n\n", t); #endif @@ -585,10 +575,10 @@ static void PrintAllSpecies(N_Vector c, int ns, int mxns, sunrealtype t) { for (jx = 0; jx < MX; jx++) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%-10.6Qg", cdata[(i - 1) + jx * ns + jy * mxns]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%-10.6Lg", cdata[(i - 1) + jx * ns + jy * mxns]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%-10.6g", cdata[(i - 1) + jx * ns + jy * mxns]); #else printf("%-10.6g", cdata[(i - 1) + jx * ns + jy * mxns]); #endif @@ -616,12 +606,12 @@ static void PrintOutput(void* cvode_mem, sunrealtype t) retval = CVodeGetLastStep(cvode_mem, &hu); check_retval(&retval, "CVodeGetLastStep", 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("t = %10.2Qe nst = %ld nfe = %ld nni = %ld", t, nst, nfe, nni); + printf(" qu = %d hu = %11.2Qe\n\n", qu, hu); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("t = %10.2Le nst = %ld nfe = %ld nni = %ld", t, nst, nfe, nni); printf(" qu = %d hu = %11.2Le\n\n", qu, hu); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("t = %10.2e nst = %ld nfe = %ld nni = %ld", t, nst, nfe, nni); - printf(" qu = %d hu = %11.2e\n\n", qu, hu); #else printf("t = %10.2e nst = %ld nfe = %ld nni = %ld", t, nst, nfe, nni); printf(" qu = %d hu = %11.2e\n\n", qu, hu); @@ -683,7 +673,9 @@ static void PrintFinalStats(void* cvode_mem) printf(" Number of nonlinear conv. failures = %4ld \n", ncfn); printf(" Number of linear convergence failures = %4ld \n", ncfl); avdim = (nni > 0) ? ((sunrealtype)nli) / ((sunrealtype)nni) : ZERO; -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" Average Krylov subspace dimension = %.3Qf \n", avdim); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" Average Krylov subspace dimension = %.3Lf \n", avdim); #else printf(" Average Krylov subspace dimension = %.3f \n", avdim); @@ -868,7 +860,7 @@ static int Precond(sunrealtype t, N_Vector c, N_Vector fc, sunbooleantype jok, /* Generate the jth column as a difference quotient */ jj = if0 + j; save = cdata[jj]; - r = MAX(srur * SUNRabs(save), r0 / rewtdata[jj]); + r = SUNMAX(srur * SUNRabs(save), r0 / rewtdata[jj]); cdata[jj] += r; fac = -gamma / r; fblock(t, cdata, jx, jy, f1, wdata); diff --git a/examples/cvode/serial/cvParticle_dns.c b/examples/cvode/serial/cvParticle_dns.c index 0fe1d0a4ad..f24b6c11fd 100644 --- a/examples/cvode/serial/cvParticle_dns.c +++ b/examples/cvode/serial/cvParticle_dns.c @@ -46,7 +46,10 @@ #include /* access to dense SUNMatrix */ /* Precision specific formatting macros */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#define ESYM "Qe" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #define ESYM "Le" #else @@ -54,21 +57,6 @@ #define ESYM "e" #endif -/* Precision specific math function macros */ -#if defined(SUNDIALS_DOUBLE_PRECISION) -#define SIN(x) (sin((x))) -#define COS(x) (cos((x))) -#define SQRT(x) (sqrt((x))) -#elif defined(SUNDIALS_SINGLE_PRECISION) -#define SIN(x) (sinf((x))) -#define COS(x) (cosf((x))) -#define SQRT(x) (sqrtf((x))) -#elif defined(SUNDIALS_EXTENDED_PRECISION) -#define SIN(x) (sinl((x))) -#define COS(x) (cosl((x))) -#define SQRT(x) (sqrtl((x))) -#endif - /* Problem Constants */ #define PI SUN_RCONST(3.141592653589793238462643383279502884197169) #define ZERO SUN_RCONST(0.0) @@ -343,7 +331,7 @@ static int Proj(sunrealtype t, N_Vector ycur, N_Vector corr, sunrealtype errxp, erryp; /* project onto the unit circle */ - r = SQRT(x * x + y * y); + r = SUNRsqrt(x * x + y * y); xp = x / r; yp = y / r; @@ -396,7 +384,7 @@ static int InitUserData(int* argc, char*** argv, UserData udata) if (strcmp((*argv)[arg_idx], "--alpha") == 0) { arg_idx++; - udata->alpha = atof((*argv)[arg_idx++]); + udata->alpha = (sunrealtype)(atof((*argv)[arg_idx++])); udata->torbit = (TWO * PI) / udata->alpha; } else if (strcmp((*argv)[arg_idx], "--orbits") == 0) @@ -407,12 +395,12 @@ static int InitUserData(int* argc, char*** argv, UserData udata) else if (strcmp((*argv)[arg_idx], "--rtol") == 0) { arg_idx++; - udata->rtol = atof((*argv)[arg_idx++]); + udata->rtol = (sunrealtype)(atof((*argv)[arg_idx++])); } else if (strcmp((*argv)[arg_idx], "--atol") == 0) { arg_idx++; - udata->atol = atof((*argv)[arg_idx++]); + udata->atol = (sunrealtype)(atof((*argv)[arg_idx++])); } else if (strcmp((*argv)[arg_idx], "--proj") == 0) { @@ -493,8 +481,8 @@ static int ComputeSolution(sunrealtype t, N_Vector y, UserData udata) { sunrealtype* ydata = N_VGetArrayPointer(y); - ydata[0] = COS((udata->alpha) * t); - ydata[1] = SIN((udata->alpha) * t); + ydata[0] = SUNRcos((udata->alpha) * t); + ydata[1] = SUNRsin((udata->alpha) * t); return (0); } diff --git a/examples/cvode/serial/cvPendulum_dns.c b/examples/cvode/serial/cvPendulum_dns.c index 6fe318eb10..f0b177d29b 100644 --- a/examples/cvode/serial/cvPendulum_dns.c +++ b/examples/cvode/serial/cvPendulum_dns.c @@ -69,30 +69,14 @@ #include /* access to dense SUNmatrix */ /* Precision specific formatting macros */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define ESYM "Qe" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define ESYM "Le" #else #define ESYM "e" #endif -/* Precision specific math function macros */ -#if defined(SUNDIALS_DOUBLE_PRECISION) -#define SIN(x) (sin((x))) -#define COS(x) (cos((x))) -#define SQRT(x) (sqrt((x))) -#define ABS(x) (fabs((x))) -#elif defined(SUNDIALS_SINGLE_PRECISION) -#define SIN(x) (sinf((x))) -#define COS(x) (cosf((x))) -#define SQRT(x) (sqrtf((x))) -#define ABS(x) (fabsf((x))) -#elif defined(SUNDIALS_EXTENDED_PRECISION) -#define SIN(x) (sinl((x))) -#define COS(x) (cosl((x))) -#define SQRT(x) (sqrtl((x))) -#define ABS(x) (fabsl((x))) -#endif - /* Problem Constants */ #define ZERO SUN_RCONST(0.0) #define ONE SUN_RCONST(1.0) @@ -361,7 +345,7 @@ int GetSol(void* cvode_mem, N_Vector yy0, sunrealtype rtol, sunrealtype atol, /* Compute the constraint violation */ x = yydata[0]; y = yydata[1]; - g = ABS(x * x + y * y - ONE); + g = SUNRabs(x * x + y * y - ONE); /* Compute the absolute error compared to the reference solution */ N_VLinearSum(ONE, yy, -ONE, yref, yy); @@ -480,7 +464,7 @@ int RefSol(sunrealtype tf, N_Vector yref, int nout) fprintf(FID, "%24.16" ESYM " %24.16" ESYM " %24.16" ESYM " %24.16" ESYM " %24.16" ESYM "\n", - ZERO, COS(th), SIN(th), -thd * SIN(th), thd * COS(th)); + ZERO, SUNRcos(th), SUNRsin(th), -thd * SUNRsin(th), thd * SUNRcos(th)); /* Integrate to tf and periodically output the solution */ dtout = tf / nout; @@ -518,7 +502,7 @@ int RefSol(sunrealtype tf, N_Vector yref, int nout) fprintf(FID, "%24.16" ESYM " %24.16" ESYM " %24.16" ESYM " %24.16" ESYM " %24.16" ESYM "\n", - t, COS(th), SIN(th), -thd * SIN(th), thd * COS(th)); + t, SUNRcos(th), SUNRsin(th), -thd * SUNRsin(th), thd * SUNRcos(th)); /* Update output time */ if (out < nout - 1) { tout += dtout; } @@ -535,10 +519,10 @@ int RefSol(sunrealtype tf, N_Vector yref, int nout) /* Convert to Cartesian reference solution */ yydata = N_VGetArrayPointer(yref); - yydata[0] = COS(th); - yydata[1] = SIN(th); - yydata[2] = -thd * SIN(th); - yydata[3] = thd * COS(th); + yydata[0] = SUNRcos(th); + yydata[1] = SUNRsin(th); + yydata[2] = -thd * SUNRsin(th); + yydata[3] = thd * SUNRcos(th); /* Free memory */ N_VDestroy_Serial(yy); @@ -563,8 +547,8 @@ static int fref(sunrealtype t, N_Vector yy, N_Vector fy, void* f_data) yydata = N_VGetArrayPointer(yy); fydata = N_VGetArrayPointer(fy); - fydata[0] = yydata[1]; /* theta' */ - fydata[1] = -GRAV * COS(yydata[0]); /* -g * cos(theta) */ + fydata[0] = yydata[1]; /* theta' */ + fydata[1] = -GRAV * SUNRcos(yydata[0]); /* -g * cos(theta) */ return (0); } @@ -629,7 +613,7 @@ static int proj(sunrealtype t, N_Vector yy, N_Vector corr, sunrealtype epsProj, /* Project positions */ - R = SQRT(x * x + y * y); + R = SUNRsqrt(x * x + y * y); x_new = x / R; y_new = y / R; @@ -695,13 +679,13 @@ static int ReadInputs(int* argc, char*** argv, sunrealtype* rtol, if (strcmp((*argv)[arg_idx], "--tol") == 0) { arg_idx++; - *rtol = atof((*argv)[arg_idx++]); - *atol = atof((*argv)[arg_idx++]); + *rtol = (sunrealtype)atof((*argv)[arg_idx++]); + *atol = (sunrealtype)atof((*argv)[arg_idx++]); } else if (strcmp((*argv)[arg_idx], "--tf") == 0) { arg_idx++; - *tf = atof((*argv)[arg_idx++]); + *tf = (sunrealtype)atof((*argv)[arg_idx++]); } else if (strcmp((*argv)[arg_idx], "--nout") == 0) { diff --git a/examples/cvode/serial/cvRoberts_dns.c b/examples/cvode/serial/cvRoberts_dns.c index a1ee98ff11..d829f12c2c 100644 --- a/examples/cvode/serial/cvRoberts_dns.c +++ b/examples/cvode/serial/cvRoberts_dns.c @@ -42,7 +42,9 @@ #include /* access to dense SUNLinearSolver */ #include /* access to dense SUNMatrix */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #else #define GSYM "g" @@ -319,10 +321,10 @@ static int Jac(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, static void PrintOutput(sunrealtype t, sunrealtype y1, sunrealtype y2, sunrealtype y3) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("At t = %0.4Qe y =%14.6Qe %14.6Qe %14.6Qe\n", t, y1, y2, y3); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("At t = %0.4Le y =%14.6Le %14.6Le %14.6Le\n", t, y1, y2, y3); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("At t = %0.4e y =%14.6e %14.6e %14.6e\n", t, y1, y2, y3); #else printf("At t = %0.4e y =%14.6e %14.6e %14.6e\n", t, y1, y2, y3); #endif diff --git a/examples/cvode/serial/cvRoberts_dnsL.c b/examples/cvode/serial/cvRoberts_dnsL.c index 898b6f5e64..95b7c998d4 100644 --- a/examples/cvode/serial/cvRoberts_dnsL.c +++ b/examples/cvode/serial/cvRoberts_dnsL.c @@ -301,10 +301,10 @@ static int Jac(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, static void PrintOutput(sunrealtype t, sunrealtype y1, sunrealtype y2, sunrealtype y3) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("At t = %0.4Qe y =%14.6Qe %14.6Qe %14.6Qe\n", t, y1, y2, y3); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("At t = %0.4Le y =%14.6Le %14.6Le %14.6Le\n", t, y1, y2, y3); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("At t = %0.4e y =%14.6e %14.6e %14.6e\n", t, y1, y2, y3); #else printf("At t = %0.4e y =%14.6e %14.6e %14.6e\n", t, y1, y2, y3); #endif diff --git a/examples/cvode/serial/cvRoberts_dns_constraints.c b/examples/cvode/serial/cvRoberts_dns_constraints.c index d096932c30..f821fac732 100644 --- a/examples/cvode/serial/cvRoberts_dns_constraints.c +++ b/examples/cvode/serial/cvRoberts_dns_constraints.c @@ -44,7 +44,9 @@ #include /* access to dense SUNLinearSolver */ #include /* access to dense SUNMatrix */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #else #define GSYM "g" @@ -331,10 +333,10 @@ static int Jac(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, static void PrintOutput(sunrealtype t, sunrealtype y1, sunrealtype y2, sunrealtype y3) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("At t = %0.4Qe y =%14.6Qe %14.6Qe %14.6Qe\n", t, y1, y2, y3); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("At t = %0.4Le y =%14.6Le %14.6Le %14.6Le\n", t, y1, y2, y3); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("At t = %0.4e y =%14.6e %14.6e %14.6e\n", t, y1, y2, y3); #else printf("At t = %0.4e y =%14.6e %14.6e %14.6e\n", t, y1, y2, y3); #endif diff --git a/examples/cvode/serial/cvRoberts_dns_negsol.c b/examples/cvode/serial/cvRoberts_dns_negsol.c index 9e29d0ed21..8470086260 100644 --- a/examples/cvode/serial/cvRoberts_dns_negsol.c +++ b/examples/cvode/serial/cvRoberts_dns_negsol.c @@ -238,10 +238,10 @@ static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) static void PrintOutput(sunrealtype t, sunrealtype y1, sunrealtype y2, sunrealtype y3) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("At t = %0.4Qe y =%14.6Qe %14.6Qe %14.6Qe\n", t, y1, y2, y3); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("At t = %0.4Le y =%14.6Le %14.6Le %14.6Le\n", t, y1, y2, y3); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("At t = %0.4e y =%14.6e %14.6e %14.6e\n", t, y1, y2, y3); #else printf("At t = %0.4e y =%14.6e %14.6e %14.6e\n", t, y1, y2, y3); #endif diff --git a/examples/cvode/serial/cvRoberts_dns_uw.c b/examples/cvode/serial/cvRoberts_dns_uw.c index bcdf5b793b..f74e877d2a 100644 --- a/examples/cvode/serial/cvRoberts_dns_uw.c +++ b/examples/cvode/serial/cvRoberts_dns_uw.c @@ -63,16 +63,6 @@ #define IJth(A, i, j) \ SM_ELEMENT_D(A, i - 1, j - 1) /* (i,j)-th matrix component i,j=1..NEQ */ -/* Precision specific math function macros */ - -#if defined(SUNDIALS_DOUBLE_PRECISION) -#define ABS(x) (fabs((x))) -#elif defined(SUNDIALS_SINGLE_PRECISION) -#define ABS(x) (fabsf((x))) -#elif defined(SUNDIALS_EXTENDED_PRECISION) -#define ABS(x) (fabsl((x))) -#endif - /* Problem Constants */ #define NEQ 3 /* number of equations */ @@ -312,9 +302,9 @@ static int ewt(N_Vector y, N_Vector w, void* user_data) for (i = 1; i <= 3; i++) { yy = Ith(y, i); - ww = rtol * ABS(yy) + atol[i - 1]; - if (ww <= 0.0) { return (-1); } - Ith(w, i) = 1.0 / ww; + ww = rtol * SUNRabs(yy) + atol[i - 1]; + if (ww <= SUN_RCONST(0.0)) { return (-1); } + Ith(w, i) = SUN_RCONST(1.0) / ww; } return (0); @@ -329,10 +319,10 @@ static int ewt(N_Vector y, N_Vector w, void* user_data) static void PrintOutput(sunrealtype t, sunrealtype y1, sunrealtype y2, sunrealtype y3) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("At t = %0.4Qe y =%14.6Qe %14.6Qe %14.6Qe\n", t, y1, y2, y3); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("At t = %0.4Le y =%14.6Le %14.6Le %14.6Le\n", t, y1, y2, y3); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("At t = %0.4e y =%14.6e %14.6e %14.6e\n", t, y1, y2, y3); #else printf("At t = %0.4e y =%14.6e %14.6e %14.6e\n", t, y1, y2, y3); #endif diff --git a/examples/cvode/serial/cvRocket_dns.c b/examples/cvode/serial/cvRocket_dns.c index 30a3cd0fb6..68e540704a 100644 --- a/examples/cvode/serial/cvRocket_dns.c +++ b/examples/cvode/serial/cvRocket_dns.c @@ -328,10 +328,10 @@ static int g(sunrealtype t, N_Vector y, sunrealtype* gout, void* user_data) static void PrintOutput(sunrealtype t, sunrealtype y1, sunrealtype y2) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("At t = %0.4Qe y =%14.6Qe %14.6Qe\n", t, y1, y2); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("At t = %0.4Le y =%14.6Le %14.6Le\n", t, y1, y2); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("At t = %0.4e y =%14.6e %14.6e\n", t, y1, y2); #else printf("At t = %0.4e y =%14.6e %14.6e\n", t, y1, y2); #endif diff --git a/examples/cvodes/C_openmp/cvsAdvDiff_bnd_omp.c b/examples/cvodes/C_openmp/cvsAdvDiff_bnd_omp.c index 04c180126c..4a8d49de57 100644 --- a/examples/cvodes/C_openmp/cvsAdvDiff_bnd_omp.c +++ b/examples/cvodes/C_openmp/cvsAdvDiff_bnd_omp.c @@ -394,12 +394,12 @@ static void PrintHeader(sunrealtype reltol, sunrealtype abstol, sunrealtype umax printf("\n2-D Advection-Diffusion Equation\n"); printf("Mesh dimensions = %d X %d\n", MX, MY); printf("Total system size = %d\n", NEQ); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: reltol = %Qg abstol = %Qg\n\n", reltol, abstol); + printf("At t = %Qg max.norm(u) =%14.6Qe \n", T0, umax); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: reltol = %Lg abstol = %Lg\n\n", reltol, abstol); printf("At t = %Lg max.norm(u) =%14.6Le \n", T0, umax); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: reltol = %g abstol = %g\n\n", reltol, abstol); - printf("At t = %g max.norm(u) =%14.6e \n", T0, umax); #else printf("Tolerance parameters: reltol = %g abstol = %g\n\n", reltol, abstol); printf("At t = %g max.norm(u) =%14.6e \n", T0, umax); @@ -412,10 +412,10 @@ static void PrintHeader(sunrealtype reltol, sunrealtype abstol, sunrealtype umax static void PrintOutput(sunrealtype t, sunrealtype umax, long int nst) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("At t = %4.2Qf max.norm(u) =%14.6Qe nst = %4ld\n", t, umax, nst); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("At t = %4.2Lf max.norm(u) =%14.6Le nst = %4ld\n", t, umax, nst); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("At t = %4.2f max.norm(u) =%14.6e nst = %4ld\n", t, umax, nst); #else printf("At t = %4.2f max.norm(u) =%14.6e nst = %4ld\n", t, umax, nst); #endif diff --git a/examples/cvodes/parallel/cvsAdvDiff_ASAp_non_p.c b/examples/cvodes/parallel/cvsAdvDiff_ASAp_non_p.c index 741362610a..c3e90b0281 100644 --- a/examples/cvodes/parallel/cvsAdvDiff_ASAp_non_p.c +++ b/examples/cvodes/parallel/cvsAdvDiff_ASAp_non_p.c @@ -731,12 +731,12 @@ static void PrintOutput(sunrealtype g_val, N_Vector uB, UserData data) if (my_pe == npes) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("\ng(tf) = %8Qe\n\n", g_val); + printf("dgdp(tf)\n [ 1]: %8Qe\n [ 2]: %8Qe\n\n", -uBdata[0], -uBdata[1]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("\ng(tf) = %8Le\n\n", g_val); printf("dgdp(tf)\n [ 1]: %8Le\n [ 2]: %8Le\n\n", -uBdata[0], -uBdata[1]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("\ng(tf) = %8e\n\n", g_val); - printf("dgdp(tf)\n [ 1]: %8e\n [ 2]: %8e\n\n", -uBdata[0], -uBdata[1]); #else printf("\ng(tf) = %8e\n\n", g_val); printf("dgdp(tf)\n [ 1]: %8e\n [ 2]: %8e\n\n", -uBdata[0], -uBdata[1]); @@ -755,14 +755,12 @@ static void PrintOutput(sunrealtype g_val, N_Vector uB, UserData data) printf("mu(t0)\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) for (i = 0; i < NEQ; i++) - printf(" [%2ld]: %8Le\n", (long int)i + 1, mu[i]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) + printf(" [%2ld]: %8Qe\n", (long int)i + 1, mu[i]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) for (i = 0; i < NEQ; i++) - { - printf(" [%2ld]: %8e\n", (long int)i + 1, mu[i]); - } + printf(" [%2ld]: %8Le\n", (long int)i + 1, mu[i]); #else for (i = 0; i < NEQ; i++) printf(" [%2ld]: %8e\n", (long int)i + 1, mu[i]); #endif diff --git a/examples/cvodes/parallel/cvsAdvDiff_FSA_non_p.c b/examples/cvodes/parallel/cvsAdvDiff_FSA_non_p.c index 5022b170db..a6a0cf985e 100644 --- a/examples/cvodes/parallel/cvsAdvDiff_FSA_non_p.c +++ b/examples/cvodes/parallel/cvsAdvDiff_FSA_non_p.c @@ -559,20 +559,20 @@ static void PrintOutput(void* cvode_mem, int my_pe, sunrealtype t, N_Vector u) if (my_pe == 0) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%8.3Qe %2d %8.3Qe %5ld\n", t, qu, hu, nst); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%8.3Le %2d %8.3Le %5ld\n", t, qu, hu, nst); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%8.3e %2d %8.3e %5ld\n", t, qu, hu, nst); #else printf("%8.3e %2d %8.3e %5ld\n", t, qu, hu, nst); #endif printf(" Solution "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe \n", umax); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le \n", umax); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e \n", umax); #else printf("%12.4e \n", umax); #endif @@ -591,10 +591,10 @@ static void PrintOutputS(int my_pe, N_Vector* uS) if (my_pe == 0) { printf(" Sensitivity 1 "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe \n", smax); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le \n", smax); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e \n", smax); #else printf("%12.4e \n", smax); #endif @@ -604,10 +604,10 @@ static void PrintOutputS(int my_pe, N_Vector* uS) if (my_pe == 0) { printf(" Sensitivity 2 "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe \n", smax); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le \n", smax); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e \n", smax); #else printf("%12.4e \n", smax); #endif diff --git a/examples/cvodes/parallel/cvsAdvDiff_non_p.c b/examples/cvodes/parallel/cvsAdvDiff_non_p.c index 0d421f1706..78adff38a9 100644 --- a/examples/cvodes/parallel/cvsAdvDiff_non_p.c +++ b/examples/cvodes/parallel/cvsAdvDiff_non_p.c @@ -272,10 +272,10 @@ static void PrintIntro(int npes) static void PrintData(sunrealtype t, sunrealtype umax, long int nst) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("At t = %4.2Qf max.norm(u) =%14.6Qe nst =%4ld \n", t, umax, nst); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("At t = %4.2Lf max.norm(u) =%14.6Le nst =%4ld \n", t, umax, nst); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("At t = %4.2f max.norm(u) =%14.6e nst =%4ld \n", t, umax, nst); #else printf("At t = %4.2f max.norm(u) =%14.6e nst =%4ld \n", t, umax, nst); #endif diff --git a/examples/cvodes/parallel/cvsAtmDisp_ASAi_kry_bbd_p.c b/examples/cvodes/parallel/cvsAtmDisp_ASAi_kry_bbd_p.c index d6847bd802..9a33304a9b 100644 --- a/examples/cvodes/parallel/cvsAtmDisp_ASAi_kry_bbd_p.c +++ b/examples/cvodes/parallel/cvsAtmDisp_ASAi_kry_bbd_p.c @@ -369,7 +369,9 @@ int main(int argc, char* argv[]) qdata = N_VGetArrayPointer(q); MPI_Allreduce(&qdata[0], &G, 1, MPI_SUNREALTYPE, MPI_SUM, comm); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + if (myId == 0) printf(" G = %Qe\n", G); +#elif defined(SUNDIALS_EXTENDED_PRECISION) if (myId == 0) printf(" G = %Le\n", G); #else if (myId == 0) { printf(" G = %e\n", G); } @@ -1132,8 +1134,10 @@ static void PrintHeader(void) printf("with respect to the source values at each grid point.\n\n"); printf("Domain:\n"); - -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" %Qf < x < %Qf mx = %d npe_x = %d \n", XMIN, XMAX, MX, NPX); + printf(" %Qf < y < %Qf my = %d npe_y = %d \n", YMIN, YMAX, MY, NPY); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" %Lf < x < %Lf mx = %d npe_x = %d \n", XMIN, XMAX, MX, NPX); printf(" %Lf < y < %Lf my = %d npe_y = %d \n", YMIN, YMAX, MY, NPY); #else @@ -1142,7 +1146,9 @@ static void PrintHeader(void) #endif #ifdef USE3D -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" %Qf < z < %Qf mz = %d npe_z = %d \n", ZMIN, ZMAX, MZ, NPZ); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" %Lf < z < %Lf mz = %d npe_z = %d \n", ZMIN, ZMAX, MZ, NPZ); #else printf(" %f < z < %f mz = %d npe_z = %d \n", ZMIN, ZMAX, MZ, NPZ); @@ -1272,7 +1278,9 @@ static void OutputGradient(int myId, N_Vector qB, ProblemData d) for (i[0] = 0; i[0] < l_m[0]; i[0]++) { x[0] = xmin[0] + (m_start[0] + i[0]) * dx[0]; -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + fprintf(fid, "x%d(%d,1) = %Qe; \n", myId, i[0] + 1, x[0]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) fprintf(fid, "x%d(%d,1) = %Le; \n", myId, i[0] + 1, x[0]); #else fprintf(fid, "x%d(%d,1) = %e; \n", myId, i[0] + 1, x[0]); @@ -1282,7 +1290,9 @@ static void OutputGradient(int myId, N_Vector qB, ProblemData d) for (i[1] = 0; i[1] < l_m[1]; i[1]++) { x[1] = xmin[1] + (m_start[1] + i[1]) * dx[1]; -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + fprintf(fid, "y%d(%d,1) = %Qe; \n", myId, i[1] + 1, x[1]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) fprintf(fid, "y%d(%d,1) = %Le; \n", myId, i[1] + 1, x[1]); #else fprintf(fid, "y%d(%d,1) = %e; \n", myId, i[1] + 1, x[1]); @@ -1293,7 +1303,9 @@ static void OutputGradient(int myId, N_Vector qB, ProblemData d) for (i[2] = 0; i[2] < l_m[2]; i[2]++) { x[2] = xmin[2] + (m_start[2] + i[2]) * dx[2]; -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + fprintf(fid, "z%d(%d,1) = %Qe; \n", myId, i[2] + 1, x[2]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) fprintf(fid, "z%d(%d,1) = %Le; \n", myId, i[2] + 1, x[2]); #else fprintf(fid, "z%d(%d,1) = %e; \n", myId, i[2] + 1, x[2]); @@ -1315,7 +1327,12 @@ static void OutputGradient(int myId, N_Vector qB, ProblemData d) x[2] = xmin[2] + (m_start[2] + i[2]) * dx[2]; g = IJth(qBdata, i); p = IJth(pdata, i); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + fprintf(fid, "p%d(%d,%d,%d) = %Qe; \n", myId, i[1] + 1, i[0] + 1, + i[2] + 1, p); + fprintf(fid, "g%d(%d,%d,%d) = %Qe; \n", myId, i[1] + 1, i[0] + 1, + i[2] + 1, g); +#elif defined(SUNDIALS_EXTENDED_PRECISION) fprintf(fid, "p%d(%d,%d,%d) = %Le; \n", myId, i[1] + 1, i[0] + 1, i[2] + 1, p); fprintf(fid, "g%d(%d,%d,%d) = %Le; \n", myId, i[1] + 1, i[0] + 1, @@ -1330,7 +1347,10 @@ static void OutputGradient(int myId, N_Vector qB, ProblemData d) #else g = IJth(qBdata, i); p = IJth(pdata, i); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + fprintf(fid, "p%d(%d,%d) = %Qe; \n", myId, i[1] + 1, i[0] + 1, p); + fprintf(fid, "g%d(%d,%d) = %Qe; \n", myId, i[1] + 1, i[0] + 1, g); +#elif defined(SUNDIALS_EXTENDED_PRECISION) fprintf(fid, "p%d(%d,%d) = %Le; \n", myId, i[1] + 1, i[0] + 1, p); fprintf(fid, "g%d(%d,%d) = %Le; \n", myId, i[1] + 1, i[0] + 1, g); #else @@ -1359,7 +1379,11 @@ static void OutputGradient(int myId, N_Vector qB, ProblemData d) fprintf(fid, "gcol1 = 'blue';\n"); fprintf(fid, "gcol2 = 'green';\n"); fprintf(fid, "gtrans = 0.5;\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + fprintf(fid, "xp=[%Qf %Qf];\n", G1_X, G2_X); + fprintf(fid, "yp=[%Qf];\n", G2_Y); + fprintf(fid, "zp=[%Qf];\n", G1_Z); +#elif defined(SUNDIALS_EXTENDED_PRECISION) fprintf(fid, "xp=[%Lf %Lf];\n", G1_X, G2_X); fprintf(fid, "yp=[%Lf];\n", G2_Y); fprintf(fid, "zp=[%Lf];\n", G1_Z); diff --git a/examples/cvodes/parallel/cvsDiurnal_FSA_kry_p.c b/examples/cvodes/parallel/cvsDiurnal_FSA_kry_p.c index 6f5ce101e3..fb487d5c3f 100644 --- a/examples/cvodes/parallel/cvsDiurnal_FSA_kry_p.c +++ b/examples/cvodes/parallel/cvsDiurnal_FSA_kry_p.c @@ -86,12 +86,6 @@ #include /* def. of sunrealtype */ #include /* defs. for SUNLinSol_SPGMR fcts. and constants */ -/* helpful macros */ - -#ifndef SQR -#define SQR(A) ((A) * (A)) -#endif - /* Problem Constants */ #define NVARS 2 /* number of species */ @@ -102,7 +96,9 @@ #define NOUT 12 /* number of output times */ #define TWOHR SUN_RCONST(7200.0) /* number of seconds in two hours */ #define HALFDAY SUN_RCONST(4.32e4) /* number of seconds in a half day */ -#define PI SUN_RCONST(3.1415926535898) /* pi */ +#define PI \ + SUN_RCONST( \ + 3.141592653589793238462643383279502884197169) /* pi */ #define XMIN SUN_RCONST(0.0) /* grid boundaries in x */ #define XMAX SUN_RCONST(20.0) @@ -542,8 +538,8 @@ static int Precond(sunrealtype tn, N_Vector u, N_Vector fu, sunbooleantype jok, jy = ly + isuby * MYSUB; ydn = YMIN + (jy - SUN_RCONST(0.5)) * dely; yup = ydn + dely; - cydn = verdco * exp(SUN_RCONST(0.2) * ydn); - cyup = verdco * exp(SUN_RCONST(0.2) * yup); + cydn = verdco * SUNRexp(SUN_RCONST(0.2) * ydn); + cyup = verdco * SUNRexp(SUN_RCONST(0.2) * yup); diag = -(cydn + cyup + SUN_RCONST(2.0) * hordco); for (lx = 0; lx < MXSUB; lx++) { @@ -698,9 +694,9 @@ static void InitUserData(int my_pe, MPI_Comm comm, UserData data) data->om = PI / HALFDAY; data->dx = (XMAX - XMIN) / ((sunrealtype)(MX - 1)); data->dy = (YMAX - YMIN) / ((sunrealtype)(MY - 1)); - data->hdco = KH / SQR(data->dx); + data->hdco = KH / SUNSQR(data->dx); data->haco = VEL / (SUN_RCONST(2.0) * data->dx); - data->vdco = (SUN_RCONST(1.0) / SQR(data->dy)) * KV0; + data->vdco = (SUN_RCONST(1.0) / SUNSQR(data->dy)) * KV0; /* Set machine-related constants */ data->comm = comm; @@ -781,14 +777,14 @@ static void SetInitialProfiles(N_Vector u, UserData data) { jy = ly + isuby * MYSUB; y = YMIN + jy * dy; - cy = SQR(SUN_RCONST(0.1) * (y - ymid)); - cy = SUN_RCONST(1.0) - cy + SUN_RCONST(0.5) * SQR(cy); + cy = SUNSQR(SUN_RCONST(0.1) * (y - ymid)); + cy = SUN_RCONST(1.0) - cy + SUN_RCONST(0.5) * SUNSQR(cy); for (lx = 0; lx < MXSUB; lx++) { jx = lx + isubx * MXSUB; x = XMIN + jx * dx; - cx = SQR(SUN_RCONST(0.1) * (x - xmid)); - cx = SUN_RCONST(1.0) - cx + SUN_RCONST(0.5) * SQR(cx); + cx = SUNSQR(SUN_RCONST(0.1) * (x - xmid)); + cx = SUN_RCONST(1.0) - cx + SUN_RCONST(0.5) * SUNSQR(cx); udata[offset] = C1_SCALE * cx * cy; udata[offset + 1] = C2_SCALE * cx * cy; offset = offset + 2; @@ -1084,11 +1080,11 @@ static void fcalc(sunrealtype t, sunrealtype udata[], sunrealtype dudata[], /* Set diurnal rate coefficients as functions of t, and save q4 in data block for use by preconditioner evaluation routine */ - s = sin((data->om) * t); + s = SUNRsin((data->om) * t); if (s > ZERO) { - q3 = exp(-A3 / s); - q4coef = exp(-A4 / s); + q3 = SUNRexp(-A3 / s); + q4coef = SUNRexp(-A4 / s); } else { @@ -1105,8 +1101,8 @@ static void fcalc(sunrealtype t, sunrealtype udata[], sunrealtype dudata[], /* Set vertical diffusion coefficients at jy +- 1/2 */ ydn = YMIN + (jy - .5) * dely; yup = ydn + dely; - cydn = verdco * exp(SUN_RCONST(0.2) * ydn); - cyup = verdco * exp(SUN_RCONST(0.2) * yup); + cydn = verdco * SUNRexp(SUN_RCONST(0.2) * ydn); + cyup = verdco * SUNRexp(SUN_RCONST(0.2) * yup); for (lx = 0; lx < MXSUB; lx++) { /* Extract c1 and c2, and set kinetic rate terms */ @@ -1191,29 +1187,29 @@ static void PrintOutput(void* cvode_mem, int my_pe, MPI_Comm comm, retval = CVodeGetLastStep(cvode_mem, &hu); check_retval(&retval, "CVodeGetLastStep", 1, my_pe); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%8.3Qe %2d %8.3Qe %5ld\n", t, qu, hu, nst); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%8.3Le %2d %8.3Le %5ld\n", t, qu, hu, nst); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%8.3e %2d %8.3e %5ld\n", t, qu, hu, nst); #else printf("%8.3e %2d %8.3e %5ld\n", t, qu, hu, nst); #endif printf(" Solution "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe \n", udata[0], tempu[0]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le %12.4Le \n", udata[0], tempu[0]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e \n", udata[0], tempu[0]); #else printf("%12.4e %12.4e \n", udata[0], tempu[0]); #endif printf(" "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe \n", udata[1], tempu[1]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le %12.4Le \n", udata[1], tempu[1]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e \n", udata[1], tempu[1]); #else printf("%12.4e %12.4e \n", udata[1], tempu[1]); #endif @@ -1258,18 +1254,18 @@ static void PrintOutputS(int my_pe, MPI_Comm comm, N_Vector* uS) printf(" " "----------------------------------------\n"); printf(" Sensitivity 1 "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe \n", sdata[0], temps[0]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le %12.4Le \n", sdata[0], temps[0]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e \n", sdata[0], temps[0]); #else printf("%12.4e %12.4e \n", sdata[0], temps[0]); #endif printf(" "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe \n", sdata[1], temps[1]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le %12.4Le \n", sdata[1], temps[1]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e \n", sdata[1], temps[1]); #else printf("%12.4e %12.4e \n", sdata[1], temps[1]); #endif @@ -1300,18 +1296,18 @@ static void PrintOutputS(int my_pe, MPI_Comm comm, N_Vector* uS) printf(" " "----------------------------------------\n"); printf(" Sensitivity 2 "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe \n", sdata[0], temps[0]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le %12.4Le \n", sdata[0], temps[0]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e \n", sdata[0], temps[0]); #else printf("%12.4e %12.4e \n", sdata[0], temps[0]); #endif printf(" "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe \n", sdata[1], temps[1]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le %12.4Le \n", sdata[1], temps[1]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e \n", sdata[1], temps[1]); #else printf("%12.4e %12.4e \n", sdata[1], temps[1]); #endif diff --git a/examples/cvodes/parallel/cvsDiurnal_FSA_kry_p_-sensi_sim_t.out b/examples/cvodes/parallel/cvsDiurnal_FSA_kry_p_-sensi_sim_t.out index 41a2300a7b..db8c82a269 100644 --- a/examples/cvodes/parallel/cvsDiurnal_FSA_kry_p_-sensi_sim_t.out +++ b/examples/cvodes/parallel/cvsDiurnal_FSA_kry_p_-sensi_sim_t.out @@ -5,7 +5,7 @@ Sensitivity: YES ( SIMULTANEOUS + FULL ERROR CONTROL ) ======================================================================== T Q H NST Bottom left Top right ======================================================================== -7.200e+03 3 3.475e+01 345 +7.200e+03 3 3.559e+01 343 Solution 1.0468e+04 1.1185e+04 2.5267e+11 2.6998e+11 ---------------------------------------- @@ -15,7 +15,7 @@ Sensitivity: YES ( SIMULTANEOUS + FULL ERROR CONTROL ) Sensitivity 2 -4.3853e+14 -5.0065e+14 -2.4407e+18 -2.7843e+18 ------------------------------------------------------------------------ -1.440e+04 3 1.064e+02 612 +1.440e+04 3 7.000e+01 533 Solution 6.6590e+06 7.3008e+06 2.5819e+11 2.8329e+11 ---------------------------------------- @@ -25,7 +25,7 @@ Sensitivity: YES ( SIMULTANEOUS + FULL ERROR CONTROL ) Sensitivity 2 -4.5235e+17 -5.4318e+17 -6.5418e+21 -7.8315e+21 ------------------------------------------------------------------------ -2.160e+04 3 7.174e+01 890 +2.160e+04 3 3.218e+01 943 Solution 2.6650e+07 2.9308e+07 2.9928e+11 3.3134e+11 ---------------------------------------- @@ -35,8 +35,8 @@ Sensitivity: YES ( SIMULTANEOUS + FULL ERROR CONTROL ) Sensitivity 2 -7.6601e+18 -9.4433e+18 -7.6459e+22 -9.4501e+22 ------------------------------------------------------------------------ -2.880e+04 3 6.438e+01 1123 - Solution 8.7021e+06 9.6500e+06 +2.880e+04 3 4.684e+01 1130 + Solution 8.7021e+06 9.6501e+06 3.3804e+11 3.7510e+11 ---------------------------------------- Sensitivity 1 -5.3375e+22 -5.9187e+22 @@ -45,95 +45,95 @@ Sensitivity: YES ( SIMULTANEOUS + FULL ERROR CONTROL ) Sensitivity 2 -4.8855e+18 -6.1040e+18 -1.7194e+23 -2.1518e+23 ------------------------------------------------------------------------ -3.600e+04 4 3.134e+01 1265 +3.600e+04 4 4.796e+01 1305 Solution 1.4040e+04 1.5609e+04 3.3868e+11 3.7652e+11 ---------------------------------------- - Sensitivity 1 -8.6141e+19 -9.5761e+19 + Sensitivity 1 -8.6141e+19 -9.5762e+19 5.2718e+23 6.6030e+23 ---------------------------------------- Sensitivity 2 -8.4328e+15 -1.0549e+16 -1.8439e+23 -2.3096e+23 ------------------------------------------------------------------------ -4.320e+04 4 2.857e+02 1891 - Solution -3.3615e-10 -3.9530e-10 +4.320e+04 3 1.260e+02 1652 + Solution -7.9750e-08 -8.9121e-08 3.3823e+11 3.8035e+11 ---------------------------------------- - Sensitivity 1 7.3630e+08 8.0958e+08 + Sensitivity 1 2.4186e+10 2.6731e+10 5.2753e+23 6.7448e+23 ---------------------------------------- - Sensitivity 2 2.1809e+05 1.1760e+05 + Sensitivity 2 2.0478e+07 2.5166e+07 -1.8454e+23 -2.3595e+23 ------------------------------------------------------------------------ -5.040e+04 5 3.151e+02 1962 - Solution -8.0116e-11 -2.5727e-10 +5.040e+04 4 3.337e+02 1717 + Solution 9.7674e-14 1.0637e-13 3.3582e+11 3.8645e+11 ---------------------------------------- - Sensitivity 1 3.5267e+07 1.1344e+08 - 5.2066e+23 6.9664e+23 + Sensitivity 1 -1.1939e+07 -1.3053e+07 + 5.2067e+23 6.9664e+23 ---------------------------------------- - Sensitivity 2 8.5297e+02 3.2356e+03 - -1.8214e+23 -2.4370e+23 + Sensitivity 2 -1.4810e+02 -1.8401e+02 + -1.8214e+23 -2.4371e+23 ------------------------------------------------------------------------ -5.760e+04 5 4.748e+02 1978 - Solution -9.9136e-10 -3.1770e-09 +5.760e+04 5 3.669e+02 1733 + Solution 6.1841e-11 5.4260e-11 3.3203e+11 3.9090e+11 ---------------------------------------- - Sensitivity 1 -1.1351e+08 -3.5554e+08 + Sensitivity 1 -3.0155e+05 -3.1542e+05 5.0825e+23 7.1205e+23 ---------------------------------------- - Sensitivity 2 -7.2327e+02 -2.6860e+03 + Sensitivity 2 -3.5076e+00 -4.2351e+00 -1.7780e+23 -2.4910e+23 ------------------------------------------------------------------------ -6.480e+04 3 1.695e+02 2091 - Solution 2.2622e-12 5.4339e-13 +6.480e+04 3 1.752e+02 1860 + Solution 1.2265e-10 1.8170e-10 3.3130e+11 3.9634e+11 ---------------------------------------- - Sensitivity 1 2.6502e+07 7.2017e+06 + Sensitivity 1 4.3636e+08 6.5192e+08 5.0442e+23 7.3274e+23 ---------------------------------------- - Sensitivity 2 1.3184e+06 1.8801e+06 + Sensitivity 2 7.8414e+05 6.6450e+05 -1.7646e+23 -2.5633e+23 ------------------------------------------------------------------------ -7.200e+04 4 3.017e+02 2123 - Solution -1.3609e-12 -5.8149e-13 +7.200e+04 4 2.194e+02 1887 + Solution 6.1755e-07 8.8076e-07 3.3297e+11 4.0389e+11 ---------------------------------------- - Sensitivity 1 -3.3229e+06 -1.2125e+06 + Sensitivity 1 -1.3160e+11 -1.8741e+11 5.0783e+23 7.6382e+23 ---------------------------------------- - Sensitivity 2 -4.3073e+03 -6.2477e+03 + Sensitivity 2 -3.8665e+07 -6.6616e+07 -1.7765e+23 -2.6721e+23 ------------------------------------------------------------------------ -7.920e+04 5 5.440e+02 2140 - Solution 7.8343e-11 1.5542e-11 +7.920e+04 4 2.194e+02 1920 + Solution 4.3295e-06 6.0330e-06 3.3344e+11 4.1203e+11 ---------------------------------------- - Sensitivity 1 3.3505e+06 6.6024e+05 + Sensitivity 1 -1.9478e+11 -2.7175e+11 5.0730e+23 7.9960e+23 ---------------------------------------- - Sensitivity 2 2.3901e+01 -2.0257e+00 + Sensitivity 2 4.8273e+08 8.2390e+08 -1.7747e+23 -2.7972e+23 ------------------------------------------------------------------------ -8.640e+04 5 5.440e+02 2153 - Solution 3.1822e-13 3.6061e-14 +8.640e+04 4 2.194e+02 1953 + Solution -1.7657e-07 -2.3971e-07 3.3518e+11 4.1625e+11 ---------------------------------------- - Sensitivity 1 6.2294e+05 1.8989e+05 - 5.1171e+23 8.2142e+23 + Sensitivity 1 -4.7645e+11 -6.5075e+11 + 5.1171e+23 8.2143e+23 ---------------------------------------- - Sensitivity 2 5.8847e+00 2.9717e+00 + Sensitivity 2 3.1935e+08 5.1519e+08 -1.7901e+23 -2.8736e+23 ------------------------------------------------------------------------ Final Statistics -nst = 2153 +nst = 1953 -nfe = 3024 -netf = 130 nsetups = 383 -nni = 3020 ncfn = 8 +nfe = 2701 +netf = 121 nsetups = 332 +nni = 2699 ncfn = 11 -nfSe = 6048 nfeS = 12096 +nfSe = 5402 nfeS = 10804 netfs = 0 nsetupsS = 0 nniS = 0 ncfnS = 0 diff --git a/examples/cvodes/parallel/cvsDiurnal_FSA_kry_p_-sensi_stg_t.out b/examples/cvodes/parallel/cvsDiurnal_FSA_kry_p_-sensi_stg_t.out index 436d47edd6..4aa7be89f9 100644 --- a/examples/cvodes/parallel/cvsDiurnal_FSA_kry_p_-sensi_stg_t.out +++ b/examples/cvodes/parallel/cvsDiurnal_FSA_kry_p_-sensi_stg_t.out @@ -5,7 +5,7 @@ Sensitivity: YES ( STAGGERED + FULL ERROR CONTROL ) ======================================================================== T Q H NST Bottom left Top right ======================================================================== -7.200e+03 4 6.240e+01 456 +7.200e+03 4 6.442e+01 456 Solution 1.0468e+04 1.1185e+04 2.5267e+11 2.6998e+11 ---------------------------------------- @@ -15,7 +15,7 @@ Sensitivity: YES ( STAGGERED + FULL ERROR CONTROL ) Sensitivity 2 -4.3853e+14 -5.0065e+14 -2.4408e+18 -2.7843e+18 ------------------------------------------------------------------------ -1.440e+04 4 1.666e+02 521 +1.440e+04 4 1.090e+02 519 Solution 6.6590e+06 7.3008e+06 2.5819e+11 2.8329e+11 ---------------------------------------- @@ -25,7 +25,7 @@ Sensitivity: YES ( STAGGERED + FULL ERROR CONTROL ) Sensitivity 2 -4.5235e+17 -5.4317e+17 -6.5418e+21 -7.8315e+21 ------------------------------------------------------------------------ -2.160e+04 4 1.992e+02 606 +2.160e+04 5 1.728e+02 562 Solution 2.6650e+07 2.9308e+07 2.9928e+11 3.3134e+11 ---------------------------------------- @@ -33,10 +33,10 @@ Sensitivity: YES ( STAGGERED + FULL ERROR CONTROL ) 3.8203e+23 4.4991e+23 ---------------------------------------- Sensitivity 2 -7.6601e+18 -9.4433e+18 - -7.6459e+22 -9.4501e+22 + -7.6459e+22 -9.4502e+22 ------------------------------------------------------------------------ -2.880e+04 3 1.091e+02 673 - Solution 8.7021e+06 9.6500e+06 +2.880e+04 4 1.740e+02 605 + Solution 8.7021e+06 9.6501e+06 3.3804e+11 3.7510e+11 ---------------------------------------- Sensitivity 1 -5.3375e+22 -5.9187e+22 @@ -45,7 +45,7 @@ Sensitivity: YES ( STAGGERED + FULL ERROR CONTROL ) Sensitivity 2 -4.8855e+18 -6.1040e+18 -1.7194e+23 -2.1518e+23 ------------------------------------------------------------------------ -3.600e+04 4 8.486e+01 726 +3.600e+04 4 8.152e+01 650 Solution 1.4040e+04 1.5609e+04 3.3868e+11 3.7652e+11 ---------------------------------------- @@ -55,85 +55,85 @@ Sensitivity: YES ( STAGGERED + FULL ERROR CONTROL ) Sensitivity 2 -8.4328e+15 -1.0549e+16 -1.8439e+23 -2.3096e+23 ------------------------------------------------------------------------ -4.320e+04 5 2.007e+02 799 - Solution -3.2053e-07 -8.2067e-08 +4.320e+04 4 1.807e+02 716 + Solution 4.3849e-07 4.8692e-07 3.3823e+11 3.8035e+11 ---------------------------------------- - Sensitivity 1 2.5041e+09 1.1068e+09 + Sensitivity 1 -1.8038e+09 -2.0012e+09 5.2753e+23 6.7448e+23 ---------------------------------------- - Sensitivity 2 -2.7306e+08 -3.2516e+08 - -1.8454e+23 -2.3595e+23 + Sensitivity 2 1.8791e+07 2.2600e+07 + -1.8455e+23 -2.3595e+23 ------------------------------------------------------------------------ -5.040e+04 4 3.505e+02 834 - Solution -3.8285e-06 -4.1822e-06 +5.040e+04 4 2.973e+02 763 + Solution 5.8649e-13 1.1598e-12 3.3582e+11 3.8645e+11 ---------------------------------------- - Sensitivity 1 1.6643e+10 1.8174e+10 + Sensitivity 1 1.0914e+08 1.2515e+08 5.2067e+23 6.9664e+23 ---------------------------------------- - Sensitivity 2 4.0895e+10 4.6693e+10 + Sensitivity 2 5.7063e+03 4.7505e+03 -1.8214e+23 -2.4371e+23 ------------------------------------------------------------------------ -5.760e+04 5 3.805e+02 851 - Solution -3.3001e-09 -3.6176e-09 +5.760e+04 5 3.194e+02 779 + Solution -2.1167e-13 -4.8313e-13 3.3203e+11 3.9090e+11 ---------------------------------------- - Sensitivity 1 -8.4985e+07 -9.3979e+07 - 5.0825e+23 7.1205e+23 + Sensitivity 1 3.2266e+07 3.6718e+07 + 5.0825e+23 7.1206e+23 ---------------------------------------- - Sensitivity 2 2.0322e+07 2.4170e+07 + Sensitivity 2 1.7061e+03 1.4244e+03 -1.7780e+23 -2.4910e+23 ------------------------------------------------------------------------ -6.480e+04 5 3.938e+02 872 - Solution 1.1051e-06 1.2213e-06 +6.480e+04 5 3.625e+02 802 + Solution -6.0596e-08 -1.4191e-07 3.3130e+11 3.9634e+11 ---------------------------------------- - Sensitivity 1 7.1018e+10 7.8084e+10 + Sensitivity 1 1.2981e+08 2.9999e+08 5.0442e+23 7.3274e+23 ---------------------------------------- - Sensitivity 2 -4.9939e+06 -5.8955e+06 + Sensitivity 2 -7.3058e+06 -3.8580e+07 -1.7646e+23 -2.5633e+23 ------------------------------------------------------------------------ -7.200e+04 5 3.938e+02 890 - Solution -4.0822e-06 -4.3014e-06 +7.200e+04 3 2.012e+02 834 + Solution -1.0993e-10 -2.8400e-10 3.3297e+11 4.0389e+11 ---------------------------------------- - Sensitivity 1 3.7438e+10 3.9806e+10 + Sensitivity 1 2.9624e+06 7.6473e+06 5.0783e+23 7.6382e+23 ---------------------------------------- - Sensitivity 2 -2.8120e+07 -3.3371e+07 + Sensitivity 2 7.9950e+04 4.1258e+05 -1.7765e+23 -2.6721e+23 ------------------------------------------------------------------------ -7.920e+04 5 6.446e+02 905 - Solution -5.9523e-06 -6.1213e-06 +7.920e+04 5 5.597e+02 850 + Solution -9.5775e-15 -2.4666e-14 3.3344e+11 4.1203e+11 ---------------------------------------- - Sensitivity 1 7.5332e+10 7.7483e+10 - 5.0730e+23 7.9960e+23 + Sensitivity 1 -1.7091e+03 -4.4197e+03 + 5.0731e+23 7.9960e+23 ---------------------------------------- - Sensitivity 2 7.4326e+05 9.4687e+05 + Sensitivity 2 -1.5250e+01 -7.9003e+01 -1.7747e+23 -2.7972e+23 ------------------------------------------------------------------------ -8.640e+04 5 6.446e+02 916 - Solution -1.2279e-07 -1.2697e-07 +8.640e+04 5 5.597e+02 863 + Solution 1.6149e-18 2.3373e-18 3.3518e+11 4.1625e+11 ---------------------------------------- - Sensitivity 1 3.2765e+09 3.3795e+09 - 5.1171e+23 8.2142e+23 + Sensitivity 1 9.0665e+01 2.3661e+02 + 5.1171e+23 8.2143e+23 ---------------------------------------- - Sensitivity 2 3.1113e+04 4.0059e+04 + Sensitivity 2 7.1765e-01 3.7332e+00 -1.7901e+23 -2.8736e+23 ------------------------------------------------------------------------ Final Statistics -nst = 916 +nst = 863 -nfe = 1986 -netf = 12 nsetups = 134 -nni = 1039 ncfn = 0 +nfe = 1870 +netf = 12 nsetups = 119 +nni = 981 ncfn = 0 -nfSe = 2198 nfeS = 4396 -netfs = 29 nsetupsS = 0 -nniS = 1097 ncfnS = 0 +nfSe = 2036 nfeS = 4072 +netfs = 24 nsetupsS = 0 +nniS = 1016 ncfnS = 0 diff --git a/examples/cvodes/parallel/cvsDiurnal_kry_bbd_p.c b/examples/cvodes/parallel/cvsDiurnal_kry_bbd_p.c index 25f32b4269..273a61bc1a 100644 --- a/examples/cvodes/parallel/cvsDiurnal_kry_bbd_p.c +++ b/examples/cvodes/parallel/cvsDiurnal_kry_bbd_p.c @@ -72,12 +72,6 @@ #include /* definitions of sunrealtype, sunbooleantype */ #include /* prototypes and constants for SUNLinSol_SPGMR solver */ -/* helpful macros */ - -#ifndef SQR -#define SQR(A) ((A) * (A)) -#endif - /* Problem Constants */ #define ZERO SUN_RCONST(0.0) @@ -98,7 +92,7 @@ #define NOUT 12 /* number of output times */ #define TWOHR SUN_RCONST(7200.0) /* number of seconds in two hours */ #define HALFDAY SUN_RCONST(4.32e4) /* number of seconds in a half day */ -#define PI SUN_RCONST(3.1415926535898) /* pi */ +#define PI SUN_RCONST(3.141592653589793238462643383279502884197169) /* pi */ #define XMIN ZERO /* grid boundaries in x */ #define XMAX SUN_RCONST(20.0) @@ -368,9 +362,9 @@ static void InitUserData(int my_pe, sunindextype local_N, MPI_Comm comm, data->om = PI / HALFDAY; data->dx = (XMAX - XMIN) / ((sunrealtype)(MX - 1)); data->dy = (YMAX - YMIN) / ((sunrealtype)(MY - 1)); - data->hdco = KH / SQR(data->dx); + data->hdco = KH / SUNSQR(data->dx); data->haco = VEL / (SUN_RCONST(2.0) * data->dx); - data->vdco = (SUN_RCONST(1.0) / SQR(data->dy)) * KV0; + data->vdco = (SUN_RCONST(1.0) / SUNSQR(data->dy)) * KV0; /* Set machine-related constants */ data->comm = comm; @@ -418,14 +412,14 @@ static void SetInitialProfiles(N_Vector u, UserData data) { jy = ly + isuby * MYSUB; y = YMIN + jy * dy; - cy = SQR(SUN_RCONST(0.1) * (y - ymid)); - cy = SUN_RCONST(1.0) - cy + SUN_RCONST(0.5) * SQR(cy); + cy = SUNSQR(SUN_RCONST(0.1) * (y - ymid)); + cy = SUN_RCONST(1.0) - cy + SUN_RCONST(0.5) * SUNSQR(cy); for (lx = 0; lx < MXSUB; lx++) { jx = lx + isubx * MXSUB; x = XMIN + jx * dx; - cx = SQR(SUN_RCONST(0.1) * (x - xmid)); - cx = SUN_RCONST(1.0) - cx + SUN_RCONST(0.5) * SQR(cx); + cx = SUNSQR(SUN_RCONST(0.1) * (x - xmid)); + cx = SUN_RCONST(1.0) - cx + SUN_RCONST(0.5) * SUNSQR(cx); uarray[offset] = C1_SCALE * cx * cy; uarray[offset + 1] = C2_SCALE * cx * cy; offset = offset + 2; @@ -490,16 +484,16 @@ static void PrintOutput(void* cvode_mem, int my_pe, MPI_Comm comm, N_Vector u, check_retval(&retval, "CVodeGetLastOrder", 1, my_pe); retval = CVodeGetLastStep(cvode_mem, &hu); check_retval(&retval, "CVodeGetLastStep", 1, my_pe); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("t = %.2Qe no. steps = %ld order = %d stepsize = %.2Qe\n", t, + nst, qu, hu); + printf("At bottom left: c1, c2 = %12.3Qe %12.3Qe \n", uarray[0], uarray[1]); + printf("At top right: c1, c2 = %12.3Qe %12.3Qe \n\n", tempu[0], tempu[1]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("t = %.2Le no. steps = %ld order = %d stepsize = %.2Le\n", t, nst, qu, hu); printf("At bottom left: c1, c2 = %12.3Le %12.3Le \n", uarray[0], uarray[1]); printf("At top right: c1, c2 = %12.3Le %12.3Le \n\n", tempu[0], tempu[1]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("t = %.2e no. steps = %ld order = %d stepsize = %.2e\n", t, - nst, qu, hu); - printf("At bottom left: c1, c2 = %12.3e %12.3e \n", uarray[0], uarray[1]); - printf("At top right: c1, c2 = %12.3e %12.3e \n\n", tempu[0], tempu[1]); #else printf("t = %.2e no. steps = %ld order = %d stepsize = %.2e\n", t, nst, qu, hu); @@ -881,11 +875,11 @@ static int flocal(sunindextype Nlocal, sunrealtype t, N_Vector u, N_Vector udot, /* Set diurnal rate coefficients as functions of t, and save q4 in data block for use by preconditioner evaluation routine */ - s = sin((data->om) * t); + s = SUNRsin((data->om) * t); if (s > ZERO) { - q3 = exp(-A3 / s); - q4coef = exp(-A4 / s); + q3 = SUNRexp(-A3 / s); + q4coef = SUNRexp(-A4 / s); } else { @@ -904,8 +898,8 @@ static int flocal(sunindextype Nlocal, sunrealtype t, N_Vector u, N_Vector udot, ydn = YMIN + (jy - SUN_RCONST(0.5)) * dely; yup = ydn + dely; - cydn = verdco * exp(SUN_RCONST(0.2) * ydn); - cyup = verdco * exp(SUN_RCONST(0.2) * yup); + cydn = verdco * SUNRexp(SUN_RCONST(0.2) * ydn); + cyup = verdco * SUNRexp(SUN_RCONST(0.2) * yup); for (lx = 0; lx < MXSUB; lx++) { /* Extract c1 and c2, and set kinetic rate terms */ diff --git a/examples/cvodes/parallel/cvsDiurnal_kry_bbd_p.out b/examples/cvodes/parallel/cvsDiurnal_kry_bbd_p.out index e526a71063..a975e1c16e 100644 --- a/examples/cvodes/parallel/cvsDiurnal_kry_bbd_p.out +++ b/examples/cvodes/parallel/cvsDiurnal_kry_bbd_p.out @@ -19,56 +19,56 @@ t = 2.16e+04 no. steps = 247 order = 5 stepsize = 3.00e+02 At bottom left: c1, c2 = 2.665e+07 2.993e+11 At top right: c1, c2 = 2.931e+07 3.313e+11 -t = 2.88e+04 no. steps = 272 order = 4 stepsize = 2.13e+02 +t = 2.88e+04 no. steps = 273 order = 5 stepsize = 1.42e+02 At bottom left: c1, c2 = 8.702e+06 3.380e+11 At top right: c1, c2 = 9.650e+06 3.751e+11 -t = 3.60e+04 no. steps = 311 order = 4 stepsize = 9.70e+01 +t = 3.60e+04 no. steps = 312 order = 4 stepsize = 7.17e+01 At bottom left: c1, c2 = 1.404e+04 3.387e+11 At top right: c1, c2 = 1.561e+04 3.765e+11 -t = 4.32e+04 no. steps = 368 order = 4 stepsize = 3.95e+02 -At bottom left: c1, c2 = 6.245e-08 3.382e+11 -At top right: c1, c2 = 7.023e-08 3.804e+11 +t = 4.32e+04 no. steps = 375 order = 4 stepsize = 3.40e+02 +At bottom left: c1, c2 = -7.157e-05 3.382e+11 +At top right: c1, c2 = -8.149e-05 3.804e+11 -t = 5.04e+04 no. steps = 388 order = 5 stepsize = 4.74e+02 -At bottom left: c1, c2 = 3.031e-07 3.358e+11 -At top right: c1, c2 = 3.340e-07 3.864e+11 +t = 5.04e+04 no. steps = 398 order = 4 stepsize = 3.54e+02 +At bottom left: c1, c2 = -3.568e-08 3.358e+11 +At top right: c1, c2 = -4.039e-08 3.864e+11 -t = 5.76e+04 no. steps = 401 order = 5 stepsize = 3.50e+02 -At bottom left: c1, c2 = 4.503e-11 3.320e+11 -At top right: c1, c2 = 1.065e-10 3.909e+11 +t = 5.76e+04 no. steps = 412 order = 5 stepsize = 3.51e+02 +At bottom left: c1, c2 = -5.103e-10 3.320e+11 +At top right: c1, c2 = -5.628e-10 3.909e+11 -t = 6.48e+04 no. steps = 418 order = 5 stepsize = 5.80e+02 -At bottom left: c1, c2 = -5.893e-09 3.313e+11 -At top right: c1, c2 = -1.672e-08 3.963e+11 +t = 6.48e+04 no. steps = 426 order = 5 stepsize = 5.46e+02 +At bottom left: c1, c2 = -1.226e-12 3.313e+11 +At top right: c1, c2 = -1.328e-12 3.963e+11 -t = 7.20e+04 no. steps = 430 order = 5 stepsize = 5.80e+02 -At bottom left: c1, c2 = -7.098e-11 3.330e+11 -At top right: c1, c2 = -2.001e-10 4.039e+11 +t = 7.20e+04 no. steps = 439 order = 5 stepsize = 5.46e+02 +At bottom left: c1, c2 = 4.130e-16 3.330e+11 +At top right: c1, c2 = 1.105e-16 4.039e+11 -t = 7.92e+04 no. steps = 443 order = 5 stepsize = 5.80e+02 -At bottom left: c1, c2 = 7.023e-13 3.334e+11 -At top right: c1, c2 = 1.967e-12 4.120e+11 +t = 7.92e+04 no. steps = 453 order = 5 stepsize = 5.46e+02 +At bottom left: c1, c2 = 3.929e-16 3.334e+11 +At top right: c1, c2 = 5.692e-16 4.120e+11 -t = 8.64e+04 no. steps = 455 order = 5 stepsize = 5.80e+02 -At bottom left: c1, c2 = 5.803e-14 3.352e+11 -At top right: c1, c2 = 1.602e-13 4.163e+11 +t = 8.64e+04 no. steps = 465 order = 5 stepsize = 8.19e+02 +At bottom left: c1, c2 = -4.318e-15 3.352e+11 +At top right: c1, c2 = -9.624e-15 4.163e+11 Final Statistics: lenrw = 2696 leniw = 156 lenrwls = 2454 leniwls = 126 -nst = 455 -nfe = 596 nfels = 531 -nni = 593 nli = 531 -nsetups = 83 netf = 30 -npe = 8 nps = 1066 +nst = 465 +nfe = 606 nfels = 533 +nni = 603 nli = 533 +nsetups = 85 netf = 32 +npe = 9 nps = 1081 ncfn = 0 ncfl = 0 In CVBBDPRE: real/integer local work space sizes = 1300, 192 - no. flocal evals. = 176 + no. flocal evals. = 198 ------------------------------------------------------------------- @@ -88,52 +88,52 @@ t = 2.16e+04 no. steps = 249 order = 5 stepsize = 4.31e+02 At bottom left: c1, c2 = 2.665e+07 2.993e+11 At top right: c1, c2 = 2.931e+07 3.313e+11 -t = 2.88e+04 no. steps = 309 order = 4 stepsize = 1.32e+02 +t = 2.88e+04 no. steps = 309 order = 4 stepsize = 1.33e+02 At bottom left: c1, c2 = 8.702e+06 3.380e+11 At top right: c1, c2 = 9.650e+06 3.751e+11 -t = 3.60e+04 no. steps = 342 order = 5 stepsize = 1.28e+02 +t = 3.60e+04 no. steps = 342 order = 5 stepsize = 9.78e+01 At bottom left: c1, c2 = 1.404e+04 3.387e+11 At top right: c1, c2 = 1.561e+04 3.765e+11 -t = 4.32e+04 no. steps = 393 order = 4 stepsize = 3.91e+02 -At bottom left: c1, c2 = 1.998e-09 3.382e+11 -At top right: c1, c2 = 2.210e-09 3.804e+11 +t = 4.32e+04 no. steps = 395 order = 4 stepsize = 3.88e+02 +At bottom left: c1, c2 = 1.592e-09 3.382e+11 +At top right: c1, c2 = 1.777e-09 3.804e+11 -t = 5.04e+04 no. steps = 406 order = 5 stepsize = 6.68e+02 -At bottom left: c1, c2 = 4.173e-11 3.358e+11 -At top right: c1, c2 = 4.509e-11 3.864e+11 +t = 5.04e+04 no. steps = 409 order = 5 stepsize = 4.22e+02 +At bottom left: c1, c2 = 1.346e-11 3.358e+11 +At top right: c1, c2 = 1.458e-11 3.864e+11 -t = 5.76e+04 no. steps = 421 order = 4 stepsize = 1.46e+02 -At bottom left: c1, c2 = 1.346e-13 3.320e+11 -At top right: c1, c2 = 1.429e-13 3.909e+11 +t = 5.76e+04 no. steps = 421 order = 5 stepsize = 4.51e+02 +At bottom left: c1, c2 = 5.778e-13 3.320e+11 +At top right: c1, c2 = 6.210e-13 3.909e+11 -t = 6.48e+04 no. steps = 436 order = 4 stepsize = 5.90e+02 -At bottom left: c1, c2 = 4.188e-18 3.313e+11 -At top right: c1, c2 = -4.796e-15 3.963e+11 +t = 6.48e+04 no. steps = 431 order = 5 stepsize = 7.50e+02 +At bottom left: c1, c2 = -1.460e-13 3.313e+11 +At top right: c1, c2 = -1.632e-13 3.963e+11 -t = 7.20e+04 no. steps = 448 order = 4 stepsize = 5.90e+02 -At bottom left: c1, c2 = -4.919e-18 3.330e+11 -At top right: c1, c2 = 8.770e-17 4.039e+11 +t = 7.20e+04 no. steps = 441 order = 5 stepsize = 7.50e+02 +At bottom left: c1, c2 = -7.013e-15 3.330e+11 +At top right: c1, c2 = -2.704e-15 4.039e+11 -t = 7.92e+04 no. steps = 460 order = 4 stepsize = 5.90e+02 -At bottom left: c1, c2 = 2.462e-20 3.334e+11 -At top right: c1, c2 = -2.599e-20 4.120e+11 +t = 7.92e+04 no. steps = 450 order = 5 stepsize = 7.50e+02 +At bottom left: c1, c2 = -8.873e-16 3.334e+11 +At top right: c1, c2 = 1.114e-17 4.120e+11 -t = 8.64e+04 no. steps = 472 order = 4 stepsize = 5.90e+02 -At bottom left: c1, c2 = 3.021e-23 3.352e+11 -At top right: c1, c2 = -3.233e-23 4.163e+11 +t = 8.64e+04 no. steps = 460 order = 5 stepsize = 7.50e+02 +At bottom left: c1, c2 = -1.289e-15 3.352e+11 +At top right: c1, c2 = 4.974e-18 4.163e+11 Final Statistics: lenrw = 2696 leniw = 156 lenrwls = 2454 leniwls = 126 -nst = 472 -nfe = 603 nfels = 758 -nni = 600 nli = 758 -nsetups = 94 netf = 29 -npe = 9 nps = 1257 +nst = 460 +nfe = 585 nfels = 732 +nni = 582 nli = 732 +nsetups = 89 netf = 27 +npe = 9 nps = 1218 ncfn = 0 ncfl = 0 In CVBBDPRE: real/integer local work space sizes = 1300, 192 diff --git a/examples/cvodes/parallel/cvsDiurnal_kry_p.c b/examples/cvodes/parallel/cvsDiurnal_kry_p.c index 01e2388165..21e30f763b 100644 --- a/examples/cvodes/parallel/cvsDiurnal_kry_p.c +++ b/examples/cvodes/parallel/cvsDiurnal_kry_p.c @@ -56,12 +56,6 @@ #include /* definitions of sunrealtype, sunbooleantype */ #include /* prototypes and constants for SUNLinSol_SPGMR solver */ -/* helpful macros */ - -#ifndef SQR -#define SQR(A) ((A) * (A)) -#endif - /* Problem Constants */ #define NVARS 2 /* number of species */ @@ -80,7 +74,7 @@ #define NOUT 12 /* number of output times */ #define TWOHR SUN_RCONST(7200.0) /* number of seconds in two hours */ #define HALFDAY SUN_RCONST(4.32e4) /* number of seconds in a half day */ -#define PI SUN_RCONST(3.1415926535898) /* pi */ +#define PI SUN_RCONST(3.141592653589793238462643383279502884197169) /* pi */ #define XMIN SUN_RCONST(0.0) /* grid boundaries in x */ #define XMAX SUN_RCONST(20.0) @@ -323,9 +317,9 @@ static void InitUserData(int my_pe, MPI_Comm comm, UserData data) data->om = PI / HALFDAY; data->dx = (XMAX - XMIN) / ((sunrealtype)(MX - 1)); data->dy = (YMAX - YMIN) / ((sunrealtype)(MY - 1)); - data->hdco = KH / SQR(data->dx); + data->hdco = KH / SUNSQR(data->dx); data->haco = VEL / (SUN_RCONST(2.0) * data->dx); - data->vdco = (SUN_RCONST(1.0) / SQR(data->dy)) * KV0; + data->vdco = (SUN_RCONST(1.0) / SUNSQR(data->dy)) * KV0; /* Set machine-related constants */ data->comm = comm; @@ -400,14 +394,14 @@ static void SetInitialProfiles(N_Vector u, UserData data) { jy = ly + isuby * MYSUB; y = YMIN + jy * dy; - cy = SQR(SUN_RCONST(0.1) * (y - ymid)); - cy = SUN_RCONST(1.0) - cy + SUN_RCONST(0.5) * SQR(cy); + cy = SUNSQR(SUN_RCONST(0.1) * (y - ymid)); + cy = SUN_RCONST(1.0) - cy + SUN_RCONST(0.5) * SUNSQR(cy); for (lx = 0; lx < MXSUB; lx++) { jx = lx + isubx * MXSUB; x = XMIN + jx * dx; - cx = SQR(SUN_RCONST(0.1) * (x - xmid)); - cx = SUN_RCONST(1.0) - cx + SUN_RCONST(0.5) * SQR(cx); + cx = SUNSQR(SUN_RCONST(0.1) * (x - xmid)); + cx = SUN_RCONST(1.0) - cx + SUN_RCONST(0.5) * SUNSQR(cx); udata[offset] = C1_SCALE * cx * cy; udata[offset + 1] = C2_SCALE * cx * cy; offset = offset + 2; @@ -458,7 +452,12 @@ static void PrintOutput(void* cvode_mem, int my_pe, MPI_Comm comm, N_Vector u, retval = CVodeGetLastStep(cvode_mem, &hu); check_retval(&retval, "CVodeGetLastStep", 1, my_pe); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("t = %.2Qe no. steps = %ld order = %d stepsize = %.2Qe\n", t, + nst, qu, hu); + printf("At bottom left: c1, c2 = %12.3Qe %12.3Qe \n", udata[0], udata[1]); + printf("At top right: c1, c2 = %12.3Qe %12.3Qe \n\n", tempu[0], tempu[1]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("t = %.2Le no. steps = %ld order = %d stepsize = %.2Le\n", t, nst, qu, hu); printf("At bottom left: c1, c2 = %12.3Le %12.3Le \n", udata[0], udata[1]); @@ -796,11 +795,11 @@ static void fcalc(sunrealtype t, sunrealtype udata[], sunrealtype dudata[], /* Set diurnal rate coefficients as functions of t, and save q4 in data block for use by preconditioner evaluation routine */ - s = sin((data->om) * t); + s = SUNRsin((data->om) * t); if (s > SUN_RCONST(0.0)) { - q3 = exp(-A3 / s); - q4coef = exp(-A4 / s); + q3 = SUNRexp(-A3 / s); + q4coef = SUNRexp(-A4 / s); } else { @@ -817,8 +816,8 @@ static void fcalc(sunrealtype t, sunrealtype udata[], sunrealtype dudata[], /* Set vertical diffusion coefficients at jy +- 1/2 */ ydn = YMIN + (jy - SUN_RCONST(0.5)) * dely; yup = ydn + dely; - cydn = verdco * exp(SUN_RCONST(0.2) * ydn); - cyup = verdco * exp(SUN_RCONST(0.2) * yup); + cydn = verdco * SUNRexp(SUN_RCONST(0.2) * ydn); + cyup = verdco * SUNRexp(SUN_RCONST(0.2) * yup); for (lx = 0; lx < MXSUB; lx++) { /* Extract c1 and c2, and set kinetic rate terms */ @@ -934,8 +933,8 @@ static int Precond(sunrealtype tn, N_Vector u, N_Vector fu, sunbooleantype jok, jy = ly + isuby * MYSUB; ydn = YMIN + (jy - SUN_RCONST(0.5)) * dely; yup = ydn + dely; - cydn = verdco * exp(SUN_RCONST(0.2) * ydn); - cyup = verdco * exp(SUN_RCONST(0.2) * yup); + cydn = verdco * SUNRexp(SUN_RCONST(0.2) * ydn); + cyup = verdco * SUNRexp(SUN_RCONST(0.2) * yup); diag = -(cydn + cyup + SUN_RCONST(2.0) * hordco); for (lx = 0; lx < MXSUB; lx++) { diff --git a/examples/cvodes/parallel/cvsDiurnal_kry_p.out b/examples/cvodes/parallel/cvsDiurnal_kry_p.out index 9d51f8eb28..839da8b04b 100644 --- a/examples/cvodes/parallel/cvsDiurnal_kry_p.out +++ b/examples/cvodes/parallel/cvsDiurnal_kry_p.out @@ -13,51 +13,51 @@ t = 2.16e+04 no. steps = 277 order = 5 stepsize = 2.75e+02 At bottom left: c1, c2 = 2.665e+07 2.993e+11 At top right: c1, c2 = 2.931e+07 3.313e+11 -t = 2.88e+04 no. steps = 316 order = 4 stepsize = 1.51e+02 +t = 2.88e+04 no. steps = 326 order = 3 stepsize = 8.13e+01 At bottom left: c1, c2 = 8.702e+06 3.380e+11 At top right: c1, c2 = 9.650e+06 3.751e+11 -t = 3.60e+04 no. steps = 355 order = 4 stepsize = 7.19e+01 +t = 3.60e+04 no. steps = 389 order = 4 stepsize = 1.02e+02 At bottom left: c1, c2 = 1.404e+04 3.387e+11 At top right: c1, c2 = 1.561e+04 3.765e+11 -t = 4.32e+04 no. steps = 416 order = 4 stepsize = 3.62e+02 -At bottom left: c1, c2 = -1.316e-07 3.382e+11 -At top right: c1, c2 = -1.475e-07 3.804e+11 +t = 4.32e+04 no. steps = 448 order = 4 stepsize = 4.89e+02 +At bottom left: c1, c2 = -9.142e-07 3.382e+11 +At top right: c1, c2 = -9.439e-07 3.804e+11 -t = 5.04e+04 no. steps = 430 order = 5 stepsize = 6.16e+02 -At bottom left: c1, c2 = -3.937e-07 3.358e+11 -At top right: c1, c2 = -4.373e-07 3.864e+11 +t = 5.04e+04 no. steps = 464 order = 4 stepsize = 3.31e+02 +At bottom left: c1, c2 = -2.154e-08 3.358e+11 +At top right: c1, c2 = -4.243e-08 3.864e+11 -t = 5.76e+04 no. steps = 442 order = 5 stepsize = 4.00e+02 -At bottom left: c1, c2 = -4.342e-10 3.320e+11 -At top right: c1, c2 = -4.873e-10 3.909e+11 +t = 5.76e+04 no. steps = 478 order = 5 stepsize = 4.28e+02 +At bottom left: c1, c2 = -6.204e-09 3.320e+11 +At top right: c1, c2 = -9.573e-09 3.909e+11 -t = 6.48e+04 no. steps = 453 order = 5 stepsize = 6.52e+02 -At bottom left: c1, c2 = 2.031e-10 3.313e+11 -At top right: c1, c2 = 2.236e-10 3.963e+11 +t = 6.48e+04 no. steps = 488 order = 5 stepsize = 7.33e+02 +At bottom left: c1, c2 = -5.614e-09 3.313e+11 +At top right: c1, c2 = -8.664e-09 3.963e+11 -t = 7.20e+04 no. steps = 465 order = 5 stepsize = 6.52e+02 -At bottom left: c1, c2 = -2.118e-12 3.330e+11 -At top right: c1, c2 = -2.335e-12 4.039e+11 +t = 7.20e+04 no. steps = 498 order = 5 stepsize = 7.33e+02 +At bottom left: c1, c2 = 4.705e-10 3.330e+11 +At top right: c1, c2 = 7.262e-10 4.039e+11 -t = 7.92e+04 no. steps = 476 order = 5 stepsize = 6.52e+02 -At bottom left: c1, c2 = -6.684e-14 3.334e+11 -At top right: c1, c2 = -7.358e-14 4.120e+11 +t = 7.92e+04 no. steps = 508 order = 5 stepsize = 7.33e+02 +At bottom left: c1, c2 = -2.584e-11 3.334e+11 +At top right: c1, c2 = -3.989e-11 4.120e+11 -t = 8.64e+04 no. steps = 487 order = 5 stepsize = 6.52e+02 -At bottom left: c1, c2 = -1.055e-15 3.352e+11 -At top right: c1, c2 = -1.168e-15 4.163e+11 +t = 8.64e+04 no. steps = 518 order = 5 stepsize = 7.33e+02 +At bottom left: c1, c2 = 1.296e-12 3.352e+11 +At top right: c1, c2 = 2.001e-12 4.163e+11 Final Statistics: lenrw = 2696 leniw = 156 lenrwls = 2454 leniwls = 126 -nst = 487 -nfe = 618 nfels = 623 -nni = 615 nli = 623 -nsetups = 79 netf = 26 -npe = 9 nps = 1179 +nst = 518 +nfe = 670 nfels = 700 +nni = 667 nli = 700 +nsetups = 92 netf = 31 +npe = 9 nps = 1310 ncfn = 0 ncfl = 0 diff --git a/examples/cvodes/serial/cvsAdvDiff_ASAi_bnd.c b/examples/cvodes/serial/cvsAdvDiff_ASAi_bnd.c index 34d7fa6385..c5e2c1e5b4 100644 --- a/examples/cvodes/serial/cvsAdvDiff_ASAi_bnd.c +++ b/examples/cvodes/serial/cvsAdvDiff_ASAi_bnd.c @@ -546,18 +546,18 @@ static void PrintOutput(N_Vector uB, UserData data) } printf("\nMaximum sensitivity\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" lambda max = %Qe\n", uBmax); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" lambda max = %Le\n", uBmax); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf(" lambda max = %e\n", uBmax); #else printf(" lambda max = %e\n", uBmax); #endif printf("at\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" x = %Qe\n y = %Qe\n", x, y); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" x = %Le\n y = %Le\n", x, y); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf(" x = %e\n y = %e\n", x, y); #else printf(" x = %e\n y = %e\n", x, y); #endif diff --git a/examples/cvodes/serial/cvsAdvDiff_FSA_non.c b/examples/cvodes/serial/cvsAdvDiff_FSA_non.c index 6fdfb7e495..a74e9b91ab 100644 --- a/examples/cvodes/serial/cvsAdvDiff_FSA_non.c +++ b/examples/cvodes/serial/cvsAdvDiff_FSA_non.c @@ -419,20 +419,20 @@ static void PrintOutput(void* cvode_mem, sunrealtype t, N_Vector u) retval = CVodeGetLastStep(cvode_mem, &hu); check_retval(&retval, "CVodeGetLastStep", 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%8.3Qe %2d %8.3Qe %5ld\n", t, qu, hu, nst); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%8.3Le %2d %8.3Le %5ld\n", t, qu, hu, nst); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%8.3e %2d %8.3e %5ld\n", t, qu, hu, nst); #else printf("%8.3e %2d %8.3e %5ld\n", t, qu, hu, nst); #endif printf(" Solution "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe \n", N_VMaxNorm(u)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le \n", N_VMaxNorm(u)); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e \n", N_VMaxNorm(u)); #else printf("%12.4e \n", N_VMaxNorm(u)); #endif @@ -445,19 +445,19 @@ static void PrintOutput(void* cvode_mem, sunrealtype t, N_Vector u) static void PrintOutputS(N_Vector* uS) { printf(" Sensitivity 1 "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe \n", N_VMaxNorm(uS[0])); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le \n", N_VMaxNorm(uS[0])); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e \n", N_VMaxNorm(uS[0])); #else printf("%12.4e \n", N_VMaxNorm(uS[0])); #endif printf(" Sensitivity 2 "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe \n", N_VMaxNorm(uS[1])); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le \n", N_VMaxNorm(uS[1])); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e \n", N_VMaxNorm(uS[1])); #else printf("%12.4e \n", N_VMaxNorm(uS[1])); #endif diff --git a/examples/cvodes/serial/cvsAdvDiff_bnd.c b/examples/cvodes/serial/cvsAdvDiff_bnd.c index b10362fe8a..71de0ae4f5 100644 --- a/examples/cvodes/serial/cvsAdvDiff_bnd.c +++ b/examples/cvodes/serial/cvsAdvDiff_bnd.c @@ -351,12 +351,12 @@ static void PrintHeader(sunrealtype reltol, sunrealtype abstol, sunrealtype umax printf("\n2-D Advection-Diffusion Equation\n"); printf("Mesh dimensions = %d X %d\n", MX, MY); printf("Total system size = %d\n", NEQ); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: reltol = %Qg abstol = %Qg\n\n", reltol, abstol); + printf("At t = %Qg max.norm(u) =%14.6Qe \n", T0, umax); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: reltol = %Lg abstol = %Lg\n\n", reltol, abstol); printf("At t = %Lg max.norm(u) =%14.6Le \n", T0, umax); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: reltol = %g abstol = %g\n\n", reltol, abstol); - printf("At t = %g max.norm(u) =%14.6e \n", T0, umax); #else printf("Tolerance parameters: reltol = %g abstol = %g\n\n", reltol, abstol); printf("At t = %g max.norm(u) =%14.6e \n", T0, umax); @@ -369,10 +369,10 @@ static void PrintHeader(sunrealtype reltol, sunrealtype abstol, sunrealtype umax static void PrintOutput(sunrealtype t, sunrealtype umax, long int nst) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("At t = %4.2Qf max.norm(u) =%14.6Qe nst = %4ld\n", t, umax, nst); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("At t = %4.2Lf max.norm(u) =%14.6Le nst = %4ld\n", t, umax, nst); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("At t = %4.2f max.norm(u) =%14.6e nst = %4ld\n", t, umax, nst); #else printf("At t = %4.2f max.norm(u) =%14.6e nst = %4ld\n", t, umax, nst); #endif diff --git a/examples/cvodes/serial/cvsAdvDiff_bndL.c b/examples/cvodes/serial/cvsAdvDiff_bndL.c index 067293e300..1cca27fc7d 100644 --- a/examples/cvodes/serial/cvsAdvDiff_bndL.c +++ b/examples/cvodes/serial/cvsAdvDiff_bndL.c @@ -41,7 +41,7 @@ #include /* access to serial N_Vector */ #include #include -#include /* definition of ABS and EXP */ +#include /* definition of SUNRexp */ #include /* definition of type sunrealtype */ #include /* access to band SUNLinearSolver */ #include /* access to band SUNMatrix */ @@ -349,8 +349,13 @@ static void PrintHeader(sunrealtype reltol, sunrealtype abstol, sunrealtype umax printf("\n2-D Advection-Diffusion Equation\n"); printf("Mesh dimensions = %d X %d\n", MX, MY); printf("Total system size = %d\n", NEQ); -#if defined(SUNDIALS_EXTENDED_PRECISION) - printf("Tolerance parameters: reltol = %Lg abstol = %Lg\n\n", reltol, abstol); +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: reltol = %Qg abstol = %Qg\n\n", reltol, + abstol); + printf("At t = %Qg max.norm(u) =%14.6Qe \n", T0, umax); +#elif defined(SUNDIALS_EXTENDED_PRECISION) + printf("Tolerance parameters: reltol = %Lg abstol = %Lg\n\n", reltol, + abstol); printf("At t = %Lg max.norm(u) =%14.6Le \n", T0, umax); #else printf("Tolerance parameters: reltol = %g abstol = %g\n\n", reltol, abstol); @@ -364,8 +369,10 @@ static void PrintHeader(sunrealtype reltol, sunrealtype abstol, sunrealtype umax static void PrintOutput(sunrealtype t, sunrealtype umax, long int nst) { -#if defined(SUNDIALS_EXTENDED_PRECISION) - printf("At t = %4.2Lf max.norm(u) =%14.6Le nst = %4ld\n", t, umax, nst); +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("At t = %4.2Qf max.norm(u) =%14.6Qe nst = %4ld\n", t, umax, nst); +#elif defined(SUNDIALS_EXTENDED_PRECISION) + printf("At t = %4.2Lf max.norm(u) =%14.6Le nst = %4ld\n", t, umax, nst); #else printf("At t = %4.2f max.norm(u) =%14.6e nst = %4ld\n", t, umax, nst); #endif diff --git a/examples/cvodes/serial/cvsAnalytic_mels.c b/examples/cvodes/serial/cvsAnalytic_mels.c index 874c94db61..93d4ac5025 100644 --- a/examples/cvodes/serial/cvsAnalytic_mels.c +++ b/examples/cvodes/serial/cvsAnalytic_mels.c @@ -38,7 +38,11 @@ #include #include /* defs. of sunrealtype, sunindextype */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#define ESYM "Qe" +#define FSYM "Qf" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #define ESYM "Le" #define FSYM "Lf" @@ -212,7 +216,7 @@ static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) /* fill in the RHS function: "NV_Ith_S" accesses the 0th entry of ydot */ NV_Ith_S(ydot, 0) = lambda * u + SUN_RCONST(1.0) / (SUN_RCONST(1.0) + t * t) - - lambda * atan(t); + lambda * SUNRatan(t); return 0; /* return with success */ } @@ -340,7 +344,7 @@ static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, sunrealtype at sunrealtype ans, err, ewt; /* answer data, error, and error weight */ /* compute solution error */ - ans = atan(t); + ans = SUNRatan(t); ewt = SUN_RCONST(1.0) / (rtol * SUNRabs(ans) + atol); err = ewt * SUNRabs(NV_Ith_S(y, 0) - ans); diff --git a/examples/cvodes/serial/cvsDirectDemo_ls.c b/examples/cvodes/serial/cvsDirectDemo_ls.c index 1a2e3ab905..b3ceb90c6a 100644 --- a/examples/cvodes/serial/cvsDirectDemo_ls.c +++ b/examples/cvodes/serial/cvsDirectDemo_ls.c @@ -78,12 +78,6 @@ #include "sunnonlinsol/sunnonlinsol_fixedpoint.h" /* access to the fixed point SUNNonlinearSolver */ #include "sunnonlinsol/sunnonlinsol_newton.h" /* access to the newton SUNNonlinearSolver */ -/* helpful macros */ - -#ifndef SQR -#define SQR(A) ((A) * (A)) -#endif - /* Shared Problem Constants */ #define ATOL SUN_RCONST(1.0e-6) @@ -349,10 +343,10 @@ static void PrintIntro1(void) printf("\n\n"); printf("Problem 1: Van der Pol oscillator\n"); printf(" xdotdot - 3*(1 - x^2)*xdot + x = 0, x(0) = 2, xdot(0) = 0\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" neq = %d, reltol = %.2Qg, abstol = %.2Qg", P1_NEQ, RTOL, ATOL); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" neq = %d, reltol = %.2Lg, abstol = %.2Lg", P1_NEQ, RTOL, ATOL); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf(" neq = %d, reltol = %.2g, abstol = %.2g", P1_NEQ, RTOL, ATOL); #else printf(" neq = %d, reltol = %.2g, abstol = %.2g", P1_NEQ, RTOL, ATOL); #endif @@ -368,10 +362,10 @@ static void PrintHeader1(void) static void PrintOutput1(sunrealtype t, sunrealtype y0, sunrealtype y1, int qu, sunrealtype hu) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%10.5Qf %12.5Qe %12.5Qe %2d %6.4Qe\n", t, y0, y1, qu, hu); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%10.5Lf %12.5Le %12.5Le %2d %6.4Le\n", t, y0, y1, qu, hu); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%10.5f %12.5e %12.5e %2d %6.4e\n", t, y0, y1, qu, hu); #else printf("%10.5f %12.5e %12.5e %2d %6.4e\n", t, y0, y1, qu, hu); #endif @@ -387,7 +381,7 @@ static int f1(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) y1 = NV_Ith_S(y, 1); NV_Ith_S(ydot, 0) = y1; - NV_Ith_S(ydot, 1) = (ONE - SQR(y0)) * P1_ETA * y1 - y0; + NV_Ith_S(ydot, 1) = (ONE - SUNSQR(y0)) * P1_ETA * y1 - y0; return (0); } @@ -402,7 +396,7 @@ static int Jac1(sunrealtype tn, N_Vector y, N_Vector fy, SUNMatrix J, SM_ELEMENT_D(J, 0, 1) = ONE; SM_ELEMENT_D(J, 1, 0) = -TWO * P1_ETA * y0 * y1 - ONE; - SM_ELEMENT_D(J, 1, 1) = P1_ETA * (ONE - SQR(y0)); + SM_ELEMENT_D(J, 1, 1) = P1_ETA * (ONE - SUNSQR(y0)); return (0); } @@ -582,10 +576,10 @@ static void PrintIntro2(void) printf("\n\nProblem 2: ydot = A * y, where A is a banded lower\n"); printf("triangular matrix derived from 2-D advection PDE\n\n"); printf(" neq = %d, ml = %d, mu = %d\n", P2_NEQ, P2_ML, P2_MU); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" itol = %s, reltol = %.2Qg, abstol = %.2Qg", "CV_SS", RTOL, ATOL); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" itol = %s, reltol = %.2Lg, abstol = %.2Lg", "CV_SS", RTOL, ATOL); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf(" itol = %s, reltol = %.2g, abstol = %.2g", "CV_SS", RTOL, ATOL); #else printf(" itol = %s, reltol = %.2g, abstol = %.2g", "CV_SS", RTOL, ATOL); #endif @@ -601,10 +595,10 @@ static void PrintHeader2(void) static void PrintOutput2(sunrealtype t, sunrealtype erm, int qu, sunrealtype hu) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%10.3Qf %12.4Qe %2d %12.4Qe\n", t, erm, qu, hu); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%10.3Lf %12.4Le %2d %12.4Le\n", t, erm, qu, hu); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%10.3f %12.4e %2d %12.4e\n", t, erm, qu, hu); #else printf("%10.3f %12.4e %2d %12.4e\n", t, erm, qu, hu); #endif @@ -853,10 +847,10 @@ static int PrepareNextRun(SUNContext sunctx, void* cvode_mem, int lmm, static void PrintErrOutput(sunrealtype tol_factor) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("\n\n Error exceeds %Qg * tolerance \n\n", tol_factor); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("\n\n Error exceeds %Lg * tolerance \n\n", tol_factor); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("\n\n Error exceeds %g * tolerance \n\n", tol_factor); #else printf("\n\n Error exceeds %g * tolerance \n\n", tol_factor); #endif @@ -920,7 +914,9 @@ static void PrintFinalStats(void* cvode_mem, int miter, sunrealtype ero) printf(" Number of f evals. in linear solver = %4ld \n\n", nfeLS); } -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" Error overrun = %.3Qf \n", ero); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" Error overrun = %.3Lf \n", ero); #else printf(" Error overrun = %.3f \n", ero); diff --git a/examples/cvodes/serial/cvsDiurnal_FSA_kry.c b/examples/cvodes/serial/cvsDiurnal_FSA_kry.c index 192eae023a..dc34edba10 100644 --- a/examples/cvodes/serial/cvsDiurnal_FSA_kry.c +++ b/examples/cvodes/serial/cvsDiurnal_FSA_kry.c @@ -65,12 +65,6 @@ #include /* defs. of sunrealtype, sunindextype */ #include /* access to SPGMR SUNLinearSolver */ -/* helpful macros */ - -#ifndef SQR -#define SQR(A) ((A) * (A)) -#endif - /* Problem Constants */ #define NUM_SPECIES 2 /* number of species */ @@ -81,7 +75,7 @@ #define NOUT 12 /* number of output times */ #define TWOHR SUN_RCONST(7200.0) /* number of seconds in two hours */ #define HALFDAY SUN_RCONST(4.32e4) /* number of seconds in a half day */ -#define PI SUN_RCONST(3.1415926535898) /* pi */ +#define PI SUN_RCONST(3.141592653589793238462643383279502884197169) /* pi */ #define XMIN SUN_RCONST(0.0) /* grid boundaries in x */ #define XMAX SUN_RCONST(20.0) @@ -371,11 +365,11 @@ static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) /* Set diurnal rate coefficients. */ - s = sin(data->om * t); + s = SUNRsin(data->om * t); if (s > ZERO) { - q3 = exp(-A3 / s); - data->q4 = exp(-A4 / s); + q3 = SUNRexp(-A3 / s); + data->q4 = SUNRexp(-A4 / s); } else { @@ -399,8 +393,8 @@ static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) zdn = ZMIN + (jz - SUN_RCONST(0.5)) * delz; zup = zdn + delz; - czdn = verdco * exp(SUN_RCONST(0.2) * zdn); - czup = verdco * exp(SUN_RCONST(0.2) * zup); + czdn = verdco * SUNRexp(SUN_RCONST(0.2) * zdn); + czup = verdco * SUNRexp(SUN_RCONST(0.2) * zup); idn = (jz == 0) ? 1 : -1; iup = (jz == MZ - 1) ? -1 : 1; for (jx = 0; jx < MX; jx++) @@ -509,8 +503,8 @@ static int Precond(sunrealtype tn, N_Vector y, N_Vector fy, sunbooleantype jok, { zdn = ZMIN + (jz - SUN_RCONST(0.5)) * delz; zup = zdn + delz; - czdn = verdco * exp(SUN_RCONST(0.2) * zdn); - czup = verdco * exp(SUN_RCONST(0.2) * zup); + czdn = verdco * SUNRexp(SUN_RCONST(0.2) * zdn); + czup = verdco * SUNRexp(SUN_RCONST(0.2) * zup); diag = -(czdn + czup + SUN_RCONST(2.0) * hordco); for (jx = 0; jx < MX; jx++) { @@ -686,9 +680,9 @@ static void InitUserData(UserData data) data->om = PI / HALFDAY; data->dx = (XMAX - XMIN) / (MX - 1); data->dz = (ZMAX - ZMIN) / (MZ - 1); - data->hdco = KH / SQR(data->dx); + data->hdco = KH / SUNSQR(data->dx); data->haco = VEL / (SUN_RCONST(2.0) * data->dx); - data->vdco = (ONE / SQR(data->dz)) * KV0; + data->vdco = (ONE / SUNSQR(data->dz)) * KV0; data->p[0] = Q1; data->p[1] = Q2; @@ -742,13 +736,13 @@ static void SetInitialProfiles(N_Vector y, sunrealtype dx, sunrealtype dz) for (jz = 0; jz < MZ; jz++) { z = ZMIN + jz * dz; - cz = SQR(SUN_RCONST(0.1) * (z - ZMID)); - cz = ONE - cz + SUN_RCONST(0.5) * SQR(cz); + cz = SUNSQR(SUN_RCONST(0.1) * (z - ZMID)); + cz = ONE - cz + SUN_RCONST(0.5) * SUNSQR(cz); for (jx = 0; jx < MX; jx++) { x = XMIN + jx * dx; - cx = SQR(SUN_RCONST(0.1) * (x - XMID)); - cx = ONE - cx + SUN_RCONST(0.5) * SQR(cx); + cx = SUNSQR(SUN_RCONST(0.1) * (x - XMID)); + cx = ONE - cx + SUN_RCONST(0.5) * SUNSQR(cx); IJKth(ydata, 1, jx, jz) = C1_SCALE * cx * cz; IJKth(ydata, 2, jx, jz) = C2_SCALE * cx * cz; } @@ -775,31 +769,31 @@ static void PrintOutput(void* cvode_mem, sunrealtype t, N_Vector y) retval = CVodeGetLastStep(cvode_mem, &hu); check_retval(&retval, "CVodeGetLastStep", 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%8.3Qe %2d %8.3Qe %5ld\n", t, qu, hu, nst); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%8.3Le %2d %8.3Le %5ld\n", t, qu, hu, nst); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%8.3e %2d %8.3e %5ld\n", t, qu, hu, nst); #else printf("%8.3e %2d %8.3e %5ld\n", t, qu, hu, nst); #endif printf(" Solution "); -#if defined(SUNDIALS_EXTENDED_PRECISION) - printf("%12.4Le %12.4Le \n", IJKth(ydata, 1, 0, 0), +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe \n", IJKth(ydata, 1, 0, 0), IJKth(ydata, 1, MX - 1, MZ - 1)); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e \n", IJKth(ydata, 1, 0, 0), +#elif defined(SUNDIALS_EXTENDED_PRECISION) + printf("%12.4Le %12.4Le \n", IJKth(ydata, 1, 0, 0), IJKth(ydata, 1, MX - 1, MZ - 1)); #else printf("%12.4e %12.4e \n", IJKth(ydata, 1, 0, 0), IJKth(ydata, 1, MX - 1, MZ - 1)); #endif printf(" "); -#if defined(SUNDIALS_EXTENDED_PRECISION) - printf("%12.4Le %12.4Le \n", IJKth(ydata, 2, 0, 0), +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe \n", IJKth(ydata, 2, 0, 0), IJKth(ydata, 2, MX - 1, MZ - 1)); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e \n", IJKth(ydata, 2, 0, 0), +#elif defined(SUNDIALS_EXTENDED_PRECISION) + printf("%12.4Le %12.4Le \n", IJKth(ydata, 2, 0, 0), IJKth(ydata, 2, MX - 1, MZ - 1)); #else printf("%12.4e %12.4e \n", IJKth(ydata, 2, 0, 0), @@ -820,22 +814,22 @@ static void PrintOutputS(N_Vector* uS) printf(" " "----------------------------------------\n"); printf(" Sensitivity 1 "); -#if defined(SUNDIALS_EXTENDED_PRECISION) - printf("%12.4Le %12.4Le \n", IJKth(sdata, 1, 0, 0), +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe \n", IJKth(sdata, 1, 0, 0), IJKth(sdata, 1, MX - 1, MZ - 1)); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e \n", IJKth(sdata, 1, 0, 0), +#elif defined(SUNDIALS_EXTENDED_PRECISION) + printf("%12.4Le %12.4Le \n", IJKth(sdata, 1, 0, 0), IJKth(sdata, 1, MX - 1, MZ - 1)); #else printf("%12.4e %12.4e \n", IJKth(sdata, 1, 0, 0), IJKth(sdata, 1, MX - 1, MZ - 1)); #endif printf(" "); -#if defined(SUNDIALS_EXTENDED_PRECISION) - printf("%12.4Le %12.4Le \n", IJKth(sdata, 2, 0, 0), +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe \n", IJKth(sdata, 2, 0, 0), IJKth(sdata, 2, MX - 1, MZ - 1)); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e \n", IJKth(sdata, 2, 0, 0), +#elif defined(SUNDIALS_EXTENDED_PRECISION) + printf("%12.4Le %12.4Le \n", IJKth(sdata, 2, 0, 0), IJKth(sdata, 2, MX - 1, MZ - 1)); #else printf("%12.4e %12.4e \n", IJKth(sdata, 2, 0, 0), @@ -847,22 +841,22 @@ static void PrintOutputS(N_Vector* uS) printf(" " "----------------------------------------\n"); printf(" Sensitivity 2 "); -#if defined(SUNDIALS_EXTENDED_PRECISION) - printf("%12.4Le %12.4Le \n", IJKth(sdata, 1, 0, 0), +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe \n", IJKth(sdata, 1, 0, 0), IJKth(sdata, 1, MX - 1, MZ - 1)); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e \n", IJKth(sdata, 1, 0, 0), +#elif defined(SUNDIALS_EXTENDED_PRECISION) + printf("%12.4Le %12.4Le \n", IJKth(sdata, 1, 0, 0), IJKth(sdata, 1, MX - 1, MZ - 1)); #else printf("%12.4e %12.4e \n", IJKth(sdata, 1, 0, 0), IJKth(sdata, 1, MX - 1, MZ - 1)); #endif printf(" "); -#if defined(SUNDIALS_EXTENDED_PRECISION) - printf("%12.4Le %12.4Le \n", IJKth(sdata, 2, 0, 0), +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe \n", IJKth(sdata, 2, 0, 0), IJKth(sdata, 2, MX - 1, MZ - 1)); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e \n", IJKth(sdata, 2, 0, 0), +#elif defined(SUNDIALS_EXTENDED_PRECISION) + printf("%12.4Le %12.4Le \n", IJKth(sdata, 2, 0, 0), IJKth(sdata, 2, MX - 1, MZ - 1)); #else printf("%12.4e %12.4e \n", IJKth(sdata, 2, 0, 0), diff --git a/examples/cvodes/serial/cvsDiurnal_FSA_kry_-sensi_sim_t.out b/examples/cvodes/serial/cvsDiurnal_FSA_kry_-sensi_sim_t.out index 337b222f38..02475d230f 100644 --- a/examples/cvodes/serial/cvsDiurnal_FSA_kry_-sensi_sim_t.out +++ b/examples/cvodes/serial/cvsDiurnal_FSA_kry_-sensi_sim_t.out @@ -5,7 +5,7 @@ Sensitivity: YES ( SIMULTANEOUS + FULL ERROR CONTROL ) ======================================================================== T Q H NST Bottom left Top right ======================================================================== -7.200e+03 3 3.247e+01 644 +7.200e+03 3 2.984e+01 653 Solution 1.0593e+04 1.1152e+04 2.5567e+11 2.6917e+11 ---------------------------------------- @@ -15,7 +15,7 @@ Sensitivity: YES ( SIMULTANEOUS + FULL ERROR CONTROL ) Sensitivity 2 -4.4900e+14 -4.9768e+14 -2.5039e+18 -2.7672e+18 ------------------------------------------------------------------------ -1.440e+04 2 2.683e+01 1018 +1.440e+04 3 3.541e+01 1313 Solution 6.9172e+06 7.2517e+06 2.6829e+11 2.8137e+11 ---------------------------------------- @@ -25,7 +25,7 @@ Sensitivity: YES ( SIMULTANEOUS + FULL ERROR CONTROL ) Sensitivity 2 -4.8955e+17 -5.3580e+17 -7.1116e+21 -7.7236e+21 ------------------------------------------------------------------------ -2.160e+04 2 1.865e+01 1614 +2.160e+04 2 2.245e+01 2004 Solution 2.7558e+07 2.9196e+07 3.1024e+11 3.3000e+11 ---------------------------------------- @@ -35,108 +35,108 @@ Sensitivity: YES ( SIMULTANEOUS + FULL ERROR CONTROL ) Sensitivity 2 -8.2851e+18 -9.3610e+18 -8.2851e+22 -9.3662e+22 ------------------------------------------------------------------------ -2.880e+04 3 8.477e+01 1863 +2.880e+04 3 7.575e+01 2410 Solution 8.9631e+06 9.8602e+06 3.4824e+11 3.8331e+11 ---------------------------------------- Sensitivity 1 -5.4975e+22 -6.0476e+22 - 5.8239e+23 7.0579e+23 + 5.8239e+23 7.0578e+23 ---------------------------------------- - Sensitivity 2 -5.2367e+18 -6.4007e+18 + Sensitivity 2 -5.2367e+18 -6.4006e+18 -1.8450e+23 -2.2574e+23 ------------------------------------------------------------------------ -3.600e+04 2 8.923e+00 2073 +3.600e+04 2 8.909e+00 2619 Solution 1.4433e+04 1.6660e+04 3.4814e+11 4.0186e+11 ---------------------------------------- - Sensitivity 1 -8.8547e+19 -1.0221e+20 - 5.6474e+23 7.6273e+23 + Sensitivity 1 -8.8547e+19 -1.0220e+20 + 5.6473e+23 7.6273e+23 ---------------------------------------- - Sensitivity 2 -9.0221e+15 -1.2170e+16 + Sensitivity 2 -9.0220e+15 -1.2170e+16 -1.9753e+23 -2.6679e+23 ------------------------------------------------------------------------ -4.320e+04 4 4.127e+02 2392 - Solution -7.6378e-13 -5.2974e-13 +4.320e+04 3 2.658e+02 2941 + Solution -1.2255e-09 -1.5551e-09 3.4900e+11 4.0867e+11 ---------------------------------------- - Sensitivity 1 2.3442e+05 2.2420e+05 + Sensitivity 1 -2.0045e+08 1.4041e+08 5.7083e+23 7.9553e+23 ---------------------------------------- - Sensitivity 2 -9.0425e+00 -4.6301e+01 + Sensitivity 2 -2.1152e+02 3.8101e+03 -1.9969e+23 -2.7830e+23 ------------------------------------------------------------------------ -5.040e+04 4 4.127e+02 2410 - Solution -1.2200e-16 -1.0627e-16 - 3.5570e+11 4.1225e+11 +5.040e+04 3 2.658e+02 2968 + Solution -5.8409e-16 -5.4748e-16 + 3.5569e+11 4.1225e+11 ---------------------------------------- - Sensitivity 1 2.6846e+02 2.0083e+02 - 5.9553e+23 8.1823e+23 + Sensitivity 1 9.3367e+02 7.5058e+02 + 5.9552e+23 8.1822e+23 ---------------------------------------- - Sensitivity 2 1.1054e-03 -3.9916e-03 + Sensitivity 2 9.8708e-03 9.2921e-03 -2.0833e+23 -2.8624e+23 ------------------------------------------------------------------------ -5.760e+04 3 5.281e+01 2549 - Solution -4.7059e-08 -4.8769e-08 +5.760e+04 4 1.253e+02 3010 + Solution 3.0010e-09 3.2234e-10 3.6425e+11 4.1628e+11 ---------------------------------------- - Sensitivity 1 -6.4064e+08 -6.6478e+08 + Sensitivity 1 1.1609e+09 1.3150e+08 6.2592e+23 8.4334e+23 ---------------------------------------- - Sensitivity 2 4.3302e+05 1.7919e+05 - -2.1897e+23 -2.9503e+23 + Sensitivity 2 -1.3302e+04 -1.0289e+03 + -2.1897e+23 -2.9502e+23 ------------------------------------------------------------------------ -6.480e+04 4 1.937e+02 2599 - Solution 2.1648e-07 2.3190e-07 +6.480e+04 4 1.253e+02 3067 + Solution -1.0761e-07 -1.3224e-09 3.6334e+11 4.2182e+11 ---------------------------------------- - Sensitivity 1 -6.6816e+09 -7.1969e+09 + Sensitivity 1 5.0006e+09 8.2188e+07 6.2461e+23 8.7310e+23 ---------------------------------------- - Sensitivity 2 9.5725e+04 1.2031e+05 - -2.1851e+23 -3.0544e+23 + Sensitivity 2 3.1430e+04 2.1149e+02 + -2.1850e+23 -3.0543e+23 ------------------------------------------------------------------------ -7.200e+04 4 3.045e+02 2634 - Solution 6.7125e-09 6.6994e-09 +7.200e+04 4 3.522e+02 3109 + Solution 2.5027e-13 -6.4654e-15 3.6192e+11 4.3354e+11 ---------------------------------------- - Sensitivity 1 6.3368e+09 6.3708e+09 - 6.2311e+23 9.2797e+23 + Sensitivity 1 -6.2092e+05 1.7519e+04 + 6.2310e+23 9.2796e+23 ---------------------------------------- - Sensitivity 2 -2.0880e+07 -2.5165e+07 + Sensitivity 2 -6.5976e+00 1.9606e-01 -2.1798e+23 -3.2463e+23 ------------------------------------------------------------------------ -7.920e+04 5 4.818e+02 2652 - Solution 5.4650e-12 5.4746e-12 +7.920e+04 5 5.331e+02 3125 + Solution 5.9629e-15 -1.9457e-16 3.6148e+11 4.4474e+11 ---------------------------------------- - Sensitivity 1 -2.4107e+07 -2.3698e+07 + Sensitivity 1 -9.3088e+03 3.5260e+02 6.2481e+23 9.8067e+23 ---------------------------------------- - Sensitivity 2 -1.6403e+06 -1.9530e+06 + Sensitivity 2 -6.7114e-02 3.2232e-03 -2.1858e+23 -3.4307e+23 ------------------------------------------------------------------------ -8.640e+04 5 4.818e+02 2667 - Solution 1.6088e-14 1.6027e-14 +8.640e+04 5 5.331e+02 3138 + Solution 7.0356e-16 -2.5898e-17 3.6318e+11 4.4524e+11 ---------------------------------------- - Sensitivity 1 3.5626e+04 3.5472e+04 - 6.3248e+23 9.8820e+23 + Sensitivity 1 -5.8191e+02 2.1621e+01 + 6.3248e+23 9.8819e+23 ---------------------------------------- - Sensitivity 2 2.6242e+03 3.1708e+03 + Sensitivity 2 -6.9598e-03 3.2170e-04 -2.2126e+23 -3.4570e+23 ------------------------------------------------------------------------ Final Statistics -nst = 2667 +nst = 3138 -nfe = 3902 -netf = 166 nsetups = 477 -nni = 3899 ncfn = 8 +nfe = 4773 +netf = 216 nsetups = 626 +nni = 4771 ncfn = 32 -nfSe = 7804 nfeS = 15608 +nfSe = 9546 nfeS = 19092 netfs = 0 nsetupsS = 0 nniS = 0 ncfnS = 0 -nli = 8496 ncfl = 0 -npe = 52 nps = 18412 +nli = 9717 ncfl = 0 +npe = 84 nps = 21064 diff --git a/examples/cvodes/serial/cvsDiurnal_FSA_kry_-sensi_stg_t.out b/examples/cvodes/serial/cvsDiurnal_FSA_kry_-sensi_stg_t.out index 79c508bb92..470eda2d50 100644 --- a/examples/cvodes/serial/cvsDiurnal_FSA_kry_-sensi_stg_t.out +++ b/examples/cvodes/serial/cvsDiurnal_FSA_kry_-sensi_stg_t.out @@ -5,17 +5,17 @@ Sensitivity: YES ( STAGGERED + FULL ERROR CONTROL ) ======================================================================== T Q H NST Bottom left Top right ======================================================================== -7.200e+03 3 2.815e+01 511 +7.200e+03 3 2.886e+01 512 Solution 1.0593e+04 1.1152e+04 2.5567e+11 2.6917e+11 ---------------------------------------- Sensitivity 1 -6.4963e+19 -6.8394e+19 - 7.2120e+19 7.6304e+19 + 7.2120e+19 7.6303e+19 ---------------------------------------- Sensitivity 2 -4.4900e+14 -4.9768e+14 -2.5039e+18 -2.7672e+18 ------------------------------------------------------------------------ -1.440e+04 5 1.808e+02 572 +1.440e+04 5 1.863e+02 574 Solution 6.9172e+06 7.2517e+06 2.6829e+11 2.8137e+11 ---------------------------------------- @@ -25,7 +25,7 @@ Sensitivity: YES ( STAGGERED + FULL ERROR CONTROL ) Sensitivity 2 -4.8955e+17 -5.3580e+17 -7.1115e+21 -7.7236e+21 ------------------------------------------------------------------------ -2.160e+04 4 1.648e+02 645 +2.160e+04 4 1.631e+02 811 Solution 2.7558e+07 2.9196e+07 3.1024e+11 3.3000e+11 ---------------------------------------- @@ -35,7 +35,7 @@ Sensitivity: YES ( STAGGERED + FULL ERROR CONTROL ) Sensitivity 2 -8.2851e+18 -9.3610e+18 -8.2851e+22 -9.3662e+22 ------------------------------------------------------------------------ -2.880e+04 5 1.691e+02 697 +2.880e+04 4 1.462e+02 861 Solution 8.9631e+06 9.8602e+06 3.4824e+11 3.8331e+11 ---------------------------------------- @@ -45,7 +45,7 @@ Sensitivity: YES ( STAGGERED + FULL ERROR CONTROL ) Sensitivity 2 -5.2367e+18 -6.4007e+18 -1.8450e+23 -2.2574e+23 ------------------------------------------------------------------------ -3.600e+04 5 1.808e+02 727 +3.600e+04 4 1.547e+02 897 Solution 1.4433e+04 1.6660e+04 3.4814e+11 4.0186e+11 ---------------------------------------- @@ -55,88 +55,88 @@ Sensitivity: YES ( STAGGERED + FULL ERROR CONTROL ) Sensitivity 2 -9.0220e+15 -1.2170e+16 -1.9753e+23 -2.6679e+23 ------------------------------------------------------------------------ -4.320e+04 4 4.251e+02 776 - Solution 5.1068e-10 1.0826e-09 +4.320e+04 4 3.025e+02 967 + Solution -2.2488e-08 -2.4010e-08 3.4900e+11 4.0867e+11 ---------------------------------------- - Sensitivity 1 -5.6091e+07 -7.0966e+07 + Sensitivity 1 5.6058e+07 4.6610e+07 5.7083e+23 7.9553e+23 ---------------------------------------- - Sensitivity 2 1.2561e+05 -4.4688e+04 + Sensitivity 2 6.7577e+06 9.4144e+06 -1.9969e+23 -2.7830e+23 ------------------------------------------------------------------------ -5.040e+04 4 4.251e+02 793 - Solution 1.7699e-10 1.9346e-10 +5.040e+04 5 4.961e+02 982 + Solution 4.2103e-09 7.5550e-10 3.5570e+11 4.1225e+11 ---------------------------------------- - Sensitivity 1 -1.0790e+06 -1.1785e+06 + Sensitivity 1 -7.5291e+07 -8.8599e+06 5.9553e+23 8.1823e+23 ---------------------------------------- - Sensitivity 2 2.9690e+02 2.9830e+02 + Sensitivity 2 -7.6308e+05 -1.0333e+06 -2.0833e+23 -2.8624e+23 ------------------------------------------------------------------------ -5.760e+04 4 1.433e+02 819 - Solution 1.2056e-09 5.7155e-10 +5.760e+04 5 2.179e+02 1001 + Solution 8.4788e-09 1.9383e-08 3.6425e+11 4.1628e+11 ---------------------------------------- - Sensitivity 1 -6.6358e+07 -3.5425e+07 + Sensitivity 1 -7.6507e+07 -1.9460e+08 6.2592e+23 8.4334e+23 ---------------------------------------- - Sensitivity 2 -8.5680e+02 -5.2643e+02 - -2.1897e+23 -2.9502e+23 + Sensitivity 2 6.4750e+04 9.1143e+04 + -2.1896e+23 -2.9502e+23 ------------------------------------------------------------------------ -6.480e+04 5 2.550e+02 874 - Solution -5.9740e-09 -3.6109e-09 +6.480e+04 4 1.942e+02 1057 + Solution -2.7398e-09 -5.3491e-09 3.6334e+11 4.2182e+11 ---------------------------------------- - Sensitivity 1 -5.2152e+08 -2.7586e+08 + Sensitivity 1 -1.9340e+08 -4.0860e+08 6.2461e+23 8.7310e+23 ---------------------------------------- - Sensitivity 2 -5.3535e+03 -3.2743e+03 - -2.1851e+23 -3.0544e+23 + Sensitivity 2 -2.4346e+07 -4.9050e+07 + -2.1851e+23 -3.0543e+23 ------------------------------------------------------------------------ -7.200e+04 5 3.604e+02 898 - Solution 1.2430e-09 5.5176e-10 +7.200e+04 5 4.968e+02 1082 + Solution -6.0170e-10 -1.1638e-09 3.6192e+11 4.3354e+11 ---------------------------------------- - Sensitivity 1 -2.4602e+08 -8.2132e+07 - 6.2311e+23 9.2797e+23 + Sensitivity 1 1.5995e+07 3.0194e+07 + 6.2310e+23 9.2797e+23 ---------------------------------------- - Sensitivity 2 -8.0444e+07 -5.3447e+07 + Sensitivity 2 -1.0918e+05 -2.1650e+05 -2.1798e+23 -3.2463e+23 ------------------------------------------------------------------------ -7.920e+04 5 5.591e+02 912 - Solution 6.7937e-11 2.9510e-11 +7.920e+04 5 4.968e+02 1097 + Solution -4.1268e-12 -8.2288e-12 3.6148e+11 4.4474e+11 ---------------------------------------- - Sensitivity 1 -2.0967e+07 -7.0002e+06 + Sensitivity 1 1.4602e+06 2.8216e+06 6.2481e+23 9.8067e+23 ---------------------------------------- - Sensitivity 2 -3.6878e+06 -2.4190e+06 + Sensitivity 2 -1.1233e+04 -2.2516e+04 -2.1858e+23 -3.4306e+23 ------------------------------------------------------------------------ -8.640e+04 5 5.591e+02 925 - Solution -8.7012e-12 -3.7665e-12 +8.640e+04 5 4.968e+02 1111 + Solution 3.3744e-15 3.5641e-15 3.6318e+11 4.4524e+11 ---------------------------------------- - Sensitivity 1 1.8542e+06 6.3152e+05 + Sensitivity 1 7.6736e+04 1.4885e+05 6.3248e+23 9.8820e+23 ---------------------------------------- - Sensitivity 2 3.0873e+05 2.0266e+05 + Sensitivity 2 -6.3403e+02 -1.2725e+03 -2.2126e+23 -3.4570e+23 ------------------------------------------------------------------------ Final Statistics -nst = 925 +nst = 1111 -nfe = 1951 -netf = 5 nsetups = 126 -nni = 998 ncfn = 0 +nfe = 2360 +netf = 6 nsetups = 154 +nni = 1206 ncfn = 0 -nfSe = 2164 nfeS = 4328 -netfs = 26 nsetupsS = 0 -nniS = 1080 ncfnS = 0 +nfSe = 2658 nfeS = 5316 +netfs = 41 nsetupsS = 0 +nniS = 1327 ncfnS = 0 -nli = 2946 ncfl = 0 -npe = 17 nps = 5795 +nli = 3425 ncfl = 0 +npe = 20 nps = 6786 diff --git a/examples/cvodes/serial/cvsDiurnal_kry.c b/examples/cvodes/serial/cvsDiurnal_kry.c index 49c45fdf10..d5d8ae9bfc 100644 --- a/examples/cvodes/serial/cvsDiurnal_kry.c +++ b/examples/cvodes/serial/cvsDiurnal_kry.c @@ -49,12 +49,6 @@ #include /* defs. of sunrealtype, sunindextype */ #include /* access to SPGMR SUNLinearSolver */ -/* helpful macros */ - -#ifndef SQR -#define SQR(A) ((A) * (A)) -#endif - /* Problem Constants */ #define ZERO SUN_RCONST(0.0) @@ -77,7 +71,7 @@ #define NOUT 12 /* number of output times */ #define TWOHR SUN_RCONST(7200.0) /* number of seconds in two hours */ #define HALFDAY SUN_RCONST(4.32e4) /* number of seconds in a half day */ -#define PI SUN_RCONST(3.1415926535898) /* pi */ +#define PI SUN_RCONST(3.141592653589793238462643383279502884197169) /* pi */ #define XMIN ZERO /* grid boundaries in x */ #define XMAX SUN_RCONST(20.0) @@ -283,9 +277,9 @@ static void InitUserData(UserData data) data->om = PI / HALFDAY; data->dx = (XMAX - XMIN) / (MX - 1); data->dy = (YMAX - YMIN) / (MY - 1); - data->hdco = KH / SQR(data->dx); + data->hdco = KH / SUNSQR(data->dx); data->haco = VEL / (TWO * data->dx); - data->vdco = (ONE / SQR(data->dy)) * KV0; + data->vdco = (ONE / SUNSQR(data->dy)) * KV0; } /* Free data memory */ @@ -324,13 +318,13 @@ static void SetInitialProfiles(N_Vector u, sunrealtype dx, sunrealtype dy) for (jy = 0; jy < MY; jy++) { y = YMIN + jy * dy; - cy = SQR(SUN_RCONST(0.1) * (y - YMID)); - cy = ONE - cy + SUN_RCONST(0.5) * SQR(cy); + cy = SUNSQR(SUN_RCONST(0.1) * (y - YMID)); + cy = ONE - cy + SUN_RCONST(0.5) * SUNSQR(cy); for (jx = 0; jx < MX; jx++) { x = XMIN + jx * dx; - cx = SQR(SUN_RCONST(0.1) * (x - XMID)); - cx = ONE - cx + SUN_RCONST(0.5) * SQR(cx); + cx = SUNSQR(SUN_RCONST(0.1) * (x - XMID)); + cx = ONE - cx + SUN_RCONST(0.5) * SUNSQR(cx); IJKth(udata, 1, jx, jy) = C1_SCALE * cx * cy; IJKth(udata, 2, jx, jy) = C2_SCALE * cx * cy; } @@ -355,22 +349,22 @@ static void PrintOutput(void* cvode_mem, N_Vector u, sunrealtype t) retval = CVodeGetLastStep(cvode_mem, &hu); check_retval(&retval, "CVodeGetLastStep", 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) - printf("t = %.2Le no. steps = %ld order = %d stepsize = %.2Le\n", t, +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("t = %.2Qe no. steps = %ld order = %d stepsize = %.2Qe\n", t, nst, qu, hu); - printf("c1 (bot.left/middle/top rt.) = %12.3Le %12.3Le %12.3Le\n", + printf("c1 (bot.left/middle/top rt.) = %12.3Qe %12.3Qe %12.3Qe\n", IJKth(udata, 1, 0, 0), IJKth(udata, 1, mxh, myh), IJKth(udata, 1, mx1, my1)); - printf("c2 (bot.left/middle/top rt.) = %12.3Le %12.3Le %12.3Le\n\n", + printf("c2 (bot.left/middle/top rt.) = %12.3Qe %12.3Qe %12.3Qe\n\n", IJKth(udata, 2, 0, 0), IJKth(udata, 2, mxh, myh), IJKth(udata, 2, mx1, my1)); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("t = %.2e no. steps = %ld order = %d stepsize = %.2e\n", t, nst, - qu, hu); - printf("c1 (bot.left/middle/top rt.) = %12.3e %12.3e %12.3e\n", +#elif defined(SUNDIALS_EXTENDED_PRECISION) + printf("t = %.2Le no. steps = %ld order = %d stepsize = %.2Le\n", t, + nst, qu, hu); + printf("c1 (bot.left/middle/top rt.) = %12.3Le %12.3Le %12.3Le\n", IJKth(udata, 1, 0, 0), IJKth(udata, 1, mxh, myh), IJKth(udata, 1, mx1, my1)); - printf("c2 (bot.left/middle/top rt.) = %12.3e %12.3e %12.3e\n\n", + printf("c2 (bot.left/middle/top rt.) = %12.3Le %12.3Le %12.3Le\n\n", IJKth(udata, 2, 0, 0), IJKth(udata, 2, mxh, myh), IJKth(udata, 2, mx1, my1)); #else @@ -501,11 +495,11 @@ static int f(sunrealtype t, N_Vector u, N_Vector udot, void* user_data) /* Set diurnal rate coefficients. */ - s = sin(data->om * t); + s = SUNRsin(data->om * t); if (s > ZERO) { - q3 = exp(-A3 / s); - data->q4 = exp(-A4 / s); + q3 = SUNRexp(-A3 / s); + data->q4 = SUNRexp(-A4 / s); } else { @@ -529,8 +523,8 @@ static int f(sunrealtype t, N_Vector u, N_Vector udot, void* user_data) ydn = YMIN + (jy - SUN_RCONST(0.5)) * dely; yup = ydn + dely; - cydn = verdco * exp(SUN_RCONST(0.2) * ydn); - cyup = verdco * exp(SUN_RCONST(0.2) * yup); + cydn = verdco * SUNRexp(SUN_RCONST(0.2) * ydn); + cyup = verdco * SUNRexp(SUN_RCONST(0.2) * yup); idn = (jy == 0) ? 1 : -1; iup = (jy == MY - 1) ? -1 : 1; for (jx = 0; jx < MX; jx++) @@ -601,8 +595,8 @@ static int jtv(N_Vector v, N_Vector Jv, sunrealtype t, N_Vector u, N_Vector fu, /* Set diurnal rate coefficients. */ - s = sin(data->om * t); - if (s > ZERO) { data->q4 = exp(-A4 / s); } + s = SUNRsin(data->om * t); + if (s > ZERO) { data->q4 = SUNRexp(-A4 / s); } else { data->q4 = ZERO; } /* Make local copies of problem variables, for efficiency. */ @@ -622,8 +616,8 @@ static int jtv(N_Vector v, N_Vector Jv, sunrealtype t, N_Vector u, N_Vector fu, ydn = YMIN + (jy - SUN_RCONST(0.5)) * dely; yup = ydn + dely; - cydn = verdco * exp(SUN_RCONST(0.2) * ydn); - cyup = verdco * exp(SUN_RCONST(0.2) * yup); + cydn = verdco * SUNRexp(SUN_RCONST(0.2) * ydn); + cyup = verdco * SUNRexp(SUN_RCONST(0.2) * yup); idn = (jy == 0) ? 1 : -1; iup = (jy == MY - 1) ? -1 : 1; @@ -760,8 +754,8 @@ static int Precond(sunrealtype tn, N_Vector u, N_Vector fu, sunbooleantype jok, { ydn = YMIN + (jy - SUN_RCONST(0.5)) * dely; yup = ydn + dely; - cydn = verdco * exp(SUN_RCONST(0.2) * ydn); - cyup = verdco * exp(SUN_RCONST(0.2) * yup); + cydn = verdco * SUNRexp(SUN_RCONST(0.2) * ydn); + cyup = verdco * SUNRexp(SUN_RCONST(0.2) * yup); diag = -(cydn + cyup + TWO * hordco); for (jx = 0; jx < MX; jx++) { diff --git a/examples/cvodes/serial/cvsDiurnal_kry.out b/examples/cvodes/serial/cvsDiurnal_kry.out index 56aae6c198..20624190fc 100644 --- a/examples/cvodes/serial/cvsDiurnal_kry.out +++ b/examples/cvodes/serial/cvsDiurnal_kry.out @@ -17,47 +17,47 @@ t = 2.88e+04 no. steps = 307 order = 4 stepsize = 2.03e+02 c1 (bot.left/middle/top rt.) = 8.702e+06 1.292e+07 9.650e+06 c2 (bot.left/middle/top rt.) = 3.380e+11 5.029e+11 3.751e+11 -t = 3.60e+04 no. steps = 338 order = 5 stepsize = 9.92e+01 +t = 3.60e+04 no. steps = 337 order = 5 stepsize = 1.15e+02 c1 (bot.left/middle/top rt.) = 1.404e+04 2.029e+04 1.561e+04 c2 (bot.left/middle/top rt.) = 3.387e+11 4.894e+11 3.765e+11 -t = 4.32e+04 no. steps = 393 order = 4 stepsize = 2.57e+02 -c1 (bot.left/middle/top rt.) = -7.924e-06 -1.148e-06 -8.759e-06 +t = 4.32e+04 no. steps = 391 order = 5 stepsize = 5.46e+02 +c1 (bot.left/middle/top rt.) = 1.666e-07 -1.151e-05 2.097e-07 c2 (bot.left/middle/top rt.) = 3.382e+11 1.355e+11 3.804e+11 -t = 5.04e+04 no. steps = 421 order = 5 stepsize = 4.96e+02 -c1 (bot.left/middle/top rt.) = -1.599e-08 -1.775e-06 -3.124e-08 +t = 5.04e+04 no. steps = 406 order = 5 stepsize = 3.61e+02 +c1 (bot.left/middle/top rt.) = -2.555e-08 -5.151e-06 -5.725e-09 c2 (bot.left/middle/top rt.) = 3.358e+11 4.930e+11 3.864e+11 -t = 5.76e+04 no. steps = 437 order = 5 stepsize = 2.10e+02 -c1 (bot.left/middle/top rt.) = -1.239e-08 -8.964e-07 -1.736e-08 +t = 5.76e+04 no. steps = 425 order = 5 stepsize = 3.61e+02 +c1 (bot.left/middle/top rt.) = 8.696e-10 5.089e-08 2.252e-09 c2 (bot.left/middle/top rt.) = 3.320e+11 9.650e+11 3.909e+11 -t = 6.48e+04 no. steps = 464 order = 5 stepsize = 7.69e+02 -c1 (bot.left/middle/top rt.) = 4.297e-11 2.962e-09 5.854e-11 +t = 6.48e+04 no. steps = 438 order = 5 stepsize = 8.53e+02 +c1 (bot.left/middle/top rt.) = -1.998e-10 2.676e-07 -8.889e-09 c2 (bot.left/middle/top rt.) = 3.313e+11 8.922e+11 3.963e+11 -t = 7.20e+04 no. steps = 473 order = 5 stepsize = 7.69e+02 -c1 (bot.left/middle/top rt.) = 1.150e-11 7.919e-10 1.566e-11 +t = 7.20e+04 no. steps = 447 order = 5 stepsize = 8.53e+02 +c1 (bot.left/middle/top rt.) = 1.272e-10 3.282e-08 -4.906e-10 c2 (bot.left/middle/top rt.) = 3.330e+11 6.186e+11 4.039e+11 -t = 7.92e+04 no. steps = 483 order = 5 stepsize = 7.69e+02 -c1 (bot.left/middle/top rt.) = -4.188e-13 -2.884e-11 -5.703e-13 +t = 7.92e+04 no. steps = 455 order = 5 stepsize = 8.53e+02 +c1 (bot.left/middle/top rt.) = 8.839e-11 1.110e-08 1.240e-11 c2 (bot.left/middle/top rt.) = 3.334e+11 6.669e+11 4.120e+11 -t = 8.64e+04 no. steps = 492 order = 5 stepsize = 7.69e+02 -c1 (bot.left/middle/top rt.) = -3.268e-14 -2.246e-12 -4.447e-14 -c2 (bot.left/middle/top rt.) = 3.352e+11 9.107e+11 4.163e+11 +t = 8.64e+04 no. steps = 463 order = 5 stepsize = 8.53e+02 +c1 (bot.left/middle/top rt.) = 1.089e-11 8.265e-10 1.786e-11 +c2 (bot.left/middle/top rt.) = 3.352e+11 9.106e+11 4.163e+11 Final Statistics.. lenrw = 2696 leniw = 65 lenrwLS = 2454 leniwLS = 42 -nst = 492 -nfe = 637 nfeLS = 0 -nni = 634 nli = 649 -nsetups = 88 netf = 32 -npe = 9 nps = 1223 +nst = 463 +nfe = 585 nfeLS = 0 +nni = 582 nli = 607 +nsetups = 73 netf = 24 +npe = 8 nps = 1136 ncfn = 0 ncfl = 0 diff --git a/examples/cvodes/serial/cvsDiurnal_kry_bp.c b/examples/cvodes/serial/cvsDiurnal_kry_bp.c index 4d311d2758..978a4f781d 100644 --- a/examples/cvodes/serial/cvsDiurnal_kry_bp.c +++ b/examples/cvodes/serial/cvsDiurnal_kry_bp.c @@ -49,12 +49,6 @@ #include /* defs. of sunrealtype, sunindextype */ #include /* access to SPGMR SUNLinearSolver */ -/* helpful macros */ - -#ifndef SQR -#define SQR(A) ((A) * (A)) -#endif - /* Problem Constants */ #define ZERO SUN_RCONST(0.0) @@ -77,7 +71,7 @@ #define NOUT 12 /* number of output times */ #define TWOHR SUN_RCONST(7200.0) /* number of seconds in two hours */ #define HALFDAY SUN_RCONST(4.32e4) /* number of seconds in a half day */ -#define PI SUN_RCONST(3.1415926535898) /* pi */ +#define PI SUN_RCONST(3.141592653589793238462643383279502884197169) /* pi */ #define XMIN ZERO /* grid boundaries in x */ #define XMAX SUN_RCONST(20.0) @@ -277,9 +271,9 @@ static void InitUserData(UserData data) data->om = PI / HALFDAY; data->dx = (XMAX - XMIN) / (MX - 1); data->dy = (YMAX - YMIN) / (MY - 1); - data->hdco = KH / SQR(data->dx); + data->hdco = KH / SUNSQR(data->dx); data->haco = VEL / (TWO * data->dx); - data->vdco = (ONE / SQR(data->dy)) * KV0; + data->vdco = (ONE / SUNSQR(data->dy)) * KV0; } /* Set initial conditions in u */ @@ -299,13 +293,13 @@ static void SetInitialProfiles(N_Vector u, sunrealtype dx, sunrealtype dy) for (jy = 0; jy < MY; jy++) { y = YMIN + jy * dy; - cy = SQR(SUN_RCONST(0.1) * (y - YMID)); - cy = ONE - cy + SUN_RCONST(0.5) * SQR(cy); + cy = SUNSQR(SUN_RCONST(0.1) * (y - YMID)); + cy = ONE - cy + SUN_RCONST(0.5) * SUNSQR(cy); for (jx = 0; jx < MX; jx++) { x = XMIN + jx * dx; - cx = SQR(SUN_RCONST(0.1) * (x - XMID)); - cx = ONE - cx + SUN_RCONST(0.5) * SQR(cx); + cx = SUNSQR(SUN_RCONST(0.1) * (x - XMID)); + cx = ONE - cx + SUN_RCONST(0.5) * SUNSQR(cx); IJKth(udata, 1, jx, jy) = C1_SCALE * cx * cy; IJKth(udata, 2, jx, jy) = C2_SCALE * cx * cy; } @@ -340,22 +334,22 @@ static void PrintOutput(void* cvode_mem, N_Vector u, sunrealtype t) retval = CVodeGetLastStep(cvode_mem, &hu); check_retval(&retval, "CVodeGetLastStep", 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) - printf("t = %.2Le no. steps = %ld order = %d stepsize = %.2Le\n", t, +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("t = %.2Qe no. steps = %ld order = %d stepsize = %.2Qe\n", t, nst, qu, hu); - printf("c1 (bot.left/middle/top rt.) = %12.3Le %12.3Le %12.3Le\n", + printf("c1 (bot.left/middle/top rt.) = %12.3Qe %12.3Qe %12.3Qe\n", IJKth(udata, 1, 0, 0), IJKth(udata, 1, mxh, myh), IJKth(udata, 1, mx1, my1)); - printf("c2 (bot.left/middle/top rt.) = %12.3Le %12.3Le %12.3Le\n\n", + printf("c2 (bot.left/middle/top rt.) = %12.3Qe %12.3Qe %12.3Qe\n\n", IJKth(udata, 2, 0, 0), IJKth(udata, 2, mxh, myh), IJKth(udata, 2, mx1, my1)); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("t = %.2e no. steps = %ld order = %d stepsize = %.2e\n", t, nst, - qu, hu); - printf("c1 (bot.left/middle/top rt.) = %12.3e %12.3e %12.3e\n", +#elif defined(SUNDIALS_EXTENDED_PRECISION) + printf("t = %.2Le no. steps = %ld order = %d stepsize = %.2Le\n", t, + nst, qu, hu); + printf("c1 (bot.left/middle/top rt.) = %12.3Le %12.3Le %12.3Le\n", IJKth(udata, 1, 0, 0), IJKth(udata, 1, mxh, myh), IJKth(udata, 1, mx1, my1)); - printf("c2 (bot.left/middle/top rt.) = %12.3e %12.3e %12.3e\n\n", + printf("c2 (bot.left/middle/top rt.) = %12.3Le %12.3Le %12.3Le\n\n", IJKth(udata, 2, 0, 0), IJKth(udata, 2, mxh, myh), IJKth(udata, 2, mx1, my1)); #else @@ -495,11 +489,11 @@ static int f(sunrealtype t, N_Vector u, N_Vector udot, void* user_data) /* Set diurnal rate coefficients. */ - s = sin(data->om * t); + s = SUNRsin(data->om * t); if (s > ZERO) { - q3 = exp(-A3 / s); - data->q4 = exp(-A4 / s); + q3 = SUNRexp(-A3 / s); + data->q4 = SUNRexp(-A4 / s); } else { @@ -523,8 +517,8 @@ static int f(sunrealtype t, N_Vector u, N_Vector udot, void* user_data) ydn = YMIN + (jy - SUN_RCONST(0.5)) * dely; yup = ydn + dely; - cydn = verdco * exp(SUN_RCONST(0.2) * ydn); - cyup = verdco * exp(SUN_RCONST(0.2) * yup); + cydn = verdco * SUNRexp(SUN_RCONST(0.2) * ydn); + cyup = verdco * SUNRexp(SUN_RCONST(0.2) * yup); idn = (jy == 0) ? 1 : -1; iup = (jy == MY - 1) ? -1 : 1; for (jx = 0; jx < MX; jx++) diff --git a/examples/cvodes/serial/cvsDiurnal_kry_bp.out b/examples/cvodes/serial/cvsDiurnal_kry_bp.out index 8f837871a9..ef117c7053 100644 --- a/examples/cvodes/serial/cvsDiurnal_kry_bp.out +++ b/examples/cvodes/serial/cvsDiurnal_kry_bp.out @@ -17,40 +17,40 @@ t = 2.16e+04 no. steps = 246 order = 5 stepsize = 2.78e+02 c1 (bot.left/middle/top rt.) = 2.665e+07 1.036e+07 2.931e+07 c2 (bot.left/middle/top rt.) = 2.993e+11 1.028e+11 3.313e+11 -t = 2.88e+04 no. steps = 298 order = 3 stepsize = 1.33e+02 +t = 2.88e+04 no. steps = 296 order = 3 stepsize = 1.41e+02 c1 (bot.left/middle/top rt.) = 8.702e+06 1.292e+07 9.650e+06 c2 (bot.left/middle/top rt.) = 3.380e+11 5.029e+11 3.751e+11 -t = 3.60e+04 no. steps = 341 order = 4 stepsize = 6.31e+01 +t = 3.60e+04 no. steps = 337 order = 4 stepsize = 1.01e+02 c1 (bot.left/middle/top rt.) = 1.404e+04 2.029e+04 1.561e+04 c2 (bot.left/middle/top rt.) = 3.387e+11 4.894e+11 3.765e+11 -t = 4.32e+04 no. steps = 402 order = 4 stepsize = 4.48e+02 -c1 (bot.left/middle/top rt.) = 1.929e-07 -6.029e-06 4.403e-07 +t = 4.32e+04 no. steps = 397 order = 4 stepsize = 4.61e+02 +c1 (bot.left/middle/top rt.) = 2.741e-13 1.852e-09 2.860e-10 c2 (bot.left/middle/top rt.) = 3.382e+11 1.355e+11 3.804e+11 -t = 5.04e+04 no. steps = 421 order = 4 stepsize = 3.30e+02 -c1 (bot.left/middle/top rt.) = 1.559e-09 6.319e-07 6.062e-10 +t = 5.04e+04 no. steps = 413 order = 5 stepsize = 4.27e+02 +c1 (bot.left/middle/top rt.) = 2.071e-08 1.302e-05 6.023e-09 c2 (bot.left/middle/top rt.) = 3.358e+11 4.930e+11 3.864e+11 -t = 5.76e+04 no. steps = 435 order = 5 stepsize = 4.67e+02 -c1 (bot.left/middle/top rt.) = -2.660e-12 -1.080e-09 -1.030e-12 +t = 5.76e+04 no. steps = 445 order = 4 stepsize = 2.03e+02 +c1 (bot.left/middle/top rt.) = 1.075e-10 3.461e-09 2.529e-10 c2 (bot.left/middle/top rt.) = 3.320e+11 9.650e+11 3.909e+11 -t = 6.48e+04 no. steps = 447 order = 5 stepsize = 7.06e+02 -c1 (bot.left/middle/top rt.) = -7.375e-15 -2.742e-12 -2.920e-15 +t = 6.48e+04 no. steps = 458 order = 5 stepsize = 7.28e+02 +c1 (bot.left/middle/top rt.) = -5.415e-15 -4.724e-12 1.913e-15 c2 (bot.left/middle/top rt.) = 3.313e+11 8.922e+11 3.963e+11 -t = 7.20e+04 no. steps = 457 order = 5 stepsize = 7.06e+02 -c1 (bot.left/middle/top rt.) = -1.202e-17 -4.105e-15 -5.445e-18 +t = 7.20e+04 no. steps = 468 order = 5 stepsize = 7.28e+02 +c1 (bot.left/middle/top rt.) = 5.341e-15 4.064e-12 -4.304e-16 c2 (bot.left/middle/top rt.) = 3.330e+11 6.186e+11 4.039e+11 -t = 7.92e+04 no. steps = 467 order = 5 stepsize = 7.06e+02 -c1 (bot.left/middle/top rt.) = -8.193e-21 -1.461e-15 -7.837e-19 +t = 7.92e+04 no. steps = 478 order = 5 stepsize = 7.28e+02 +c1 (bot.left/middle/top rt.) = 7.167e-19 7.839e-16 5.290e-16 c2 (bot.left/middle/top rt.) = 3.334e+11 6.669e+11 4.120e+11 -t = 8.64e+04 no. steps = 477 order = 5 stepsize = 7.06e+02 -c1 (bot.left/middle/top rt.) = -7.290e-20 -3.730e-15 -4.364e-20 +t = 8.64e+04 no. steps = 488 order = 5 stepsize = 7.28e+02 +c1 (bot.left/middle/top rt.) = -1.746e-24 -4.277e-19 7.334e-15 c2 (bot.left/middle/top rt.) = 3.352e+11 9.106e+11 4.162e+11 @@ -59,12 +59,12 @@ Final Statistics.. lenrw = 2696 leniw = 65 lenrwls = 2454 leniwls = 42 lenrwbp = 2800 leniwbp = 622 -nst = 477 -nfe = 613 nfetot = 1267 -nfeLS = 614 nfeBP = 40 -nni = 610 nli = 614 -nsetups = 85 netf = 28 -npe = 8 nps = 1142 +nst = 488 +nfe = 648 nfetot = 1325 +nfeLS = 632 nfeBP = 45 +nni = 645 nli = 632 +nsetups = 95 netf = 37 +npe = 9 nps = 1185 ncfn = 0 ncfl = 0 @@ -94,32 +94,32 @@ t = 3.60e+04 no. steps = 329 order = 5 stepsize = 1.16e+02 c1 (bot.left/middle/top rt.) = 1.404e+04 2.029e+04 1.561e+04 c2 (bot.left/middle/top rt.) = 3.387e+11 4.894e+11 3.765e+11 -t = 4.32e+04 no. steps = 381 order = 4 stepsize = 4.67e+02 -c1 (bot.left/middle/top rt.) = 8.674e-09 7.020e-09 9.676e-09 +t = 4.32e+04 no. steps = 381 order = 4 stepsize = 4.65e+02 +c1 (bot.left/middle/top rt.) = 6.465e-09 5.239e-09 7.212e-09 c2 (bot.left/middle/top rt.) = 3.382e+11 1.355e+11 3.804e+11 -t = 5.04e+04 no. steps = 398 order = 4 stepsize = 3.23e+02 -c1 (bot.left/middle/top rt.) = 3.531e-15 -4.895e-12 -1.356e-13 +t = 5.04e+04 no. steps = 398 order = 5 stepsize = 5.38e+02 +c1 (bot.left/middle/top rt.) = -3.309e-11 6.096e-08 -3.239e-10 c2 (bot.left/middle/top rt.) = 3.358e+11 4.930e+11 3.864e+11 -t = 5.76e+04 no. steps = 411 order = 5 stepsize = 4.75e+02 -c1 (bot.left/middle/top rt.) = 1.279e-13 -4.506e-11 -1.318e-12 +t = 5.76e+04 no. steps = 410 order = 5 stepsize = 5.91e+02 +c1 (bot.left/middle/top rt.) = 6.558e-14 7.386e-12 2.808e-13 c2 (bot.left/middle/top rt.) = 3.320e+11 9.650e+11 3.909e+11 -t = 6.48e+04 no. steps = 423 order = 5 stepsize = 7.28e+02 -c1 (bot.left/middle/top rt.) = -1.113e-17 6.813e-16 1.742e-17 +t = 6.48e+04 no. steps = 422 order = 5 stepsize = 5.91e+02 +c1 (bot.left/middle/top rt.) = 1.418e-13 -5.989e-12 -1.356e-13 c2 (bot.left/middle/top rt.) = 3.313e+11 8.922e+11 3.963e+11 -t = 7.20e+04 no. steps = 433 order = 5 stepsize = 7.28e+02 -c1 (bot.left/middle/top rt.) = -1.369e-20 3.565e-21 -5.202e-25 +t = 7.20e+04 no. steps = 434 order = 5 stepsize = 5.91e+02 +c1 (bot.left/middle/top rt.) = 1.725e-18 1.355e-15 -2.409e-17 c2 (bot.left/middle/top rt.) = 3.330e+11 6.186e+11 4.039e+11 -t = 7.92e+04 no. steps = 443 order = 5 stepsize = 7.28e+02 -c1 (bot.left/middle/top rt.) = 1.471e-20 -1.150e-20 -1.118e-25 +t = 7.92e+04 no. steps = 447 order = 5 stepsize = 5.91e+02 +c1 (bot.left/middle/top rt.) = 7.942e-25 5.762e-22 -1.438e-25 c2 (bot.left/middle/top rt.) = 3.334e+11 6.669e+11 4.120e+11 -t = 8.64e+04 no. steps = 452 order = 5 stepsize = 7.28e+02 -c1 (bot.left/middle/top rt.) = 1.949e-20 -1.947e-21 1.946e-25 +t = 8.64e+04 no. steps = 459 order = 5 stepsize = 5.91e+02 +c1 (bot.left/middle/top rt.) = -1.316e-25 -1.130e-22 4.894e-25 c2 (bot.left/middle/top rt.) = 3.352e+11 9.106e+11 4.163e+11 @@ -128,11 +128,11 @@ Final Statistics.. lenrw = 2696 leniw = 65 lenrwls = 2454 leniwls = 42 lenrwbp = 2800 leniwbp = 622 -nst = 452 -nfe = 570 nfetot = 1335 -nfeLS = 725 nfeBP = 40 -nni = 567 nli = 725 +nst = 459 +nfe = 575 nfetot = 1356 +nfeLS = 741 nfeBP = 40 +nni = 572 nli = 741 nsetups = 74 netf = 23 -npe = 8 nps = 1199 +npe = 8 nps = 1222 ncfn = 0 ncfl = 0 diff --git a/examples/cvodes/serial/cvsFoodWeb_ASAi_kry.c b/examples/cvodes/serial/cvsFoodWeb_ASAi_kry.c index 02709f9f79..e080a0c371 100644 --- a/examples/cvodes/serial/cvsFoodWeb_ASAi_kry.c +++ b/examples/cvodes/serial/cvsFoodWeb_ASAi_kry.c @@ -99,16 +99,6 @@ #include /* defs. of sunrealtype, sunindextype */ #include /* access to SPGMR SUNLinearSolver */ -/* helpful macros */ - -#ifndef MAX -#define MAX(A, B) ((A) > (B) ? (A) : (B)) -#endif - -#ifndef SQR -#define SQR(A) ((A) * (A)) -#endif - /* Constants */ #define ZERO SUN_RCONST(0.0) @@ -326,7 +316,10 @@ int main(int argc, char* argv[]) printf("\nncheck = %d\n", ncheck); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("\n G = int_t int_x int_y c%d(t,x,y) dx dy dt = %Qf \n\n", ISPEC, + N_VGetArrayPointer(c)[NEQ]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("\n G = int_t int_x int_y c%d(t,x,y) dx dy dt = %Lf \n\n", ISPEC, N_VGetArrayPointer(c)[NEQ]); #else @@ -537,7 +530,7 @@ static int Precond(sunrealtype t, N_Vector c, N_Vector fc, sunbooleantype jok, /* Generate the jth column as a difference quotient */ jj = if0 + j; save = cdata[jj]; - r = MAX(srur * SUNRabs(save), r0 / rewtdata[jj]); + r = SUNMAX(srur * SUNRabs(save), r0 / rewtdata[jj]); cdata[jj] += r; fac = -gamma / r; fblock(t, cdata, jx, jy, f1, wdata); @@ -757,7 +750,7 @@ static int PrecondB(sunrealtype t, N_Vector c, N_Vector cB, N_Vector fcB, /* Generate the jth column as a difference quotient */ jj = if0 + j; save = cdata[jj]; - r = MAX(srur * SUNRabs(save), r0 / rewtdata[jj]); + r = SUNMAX(srur * SUNRabs(save), r0 / rewtdata[jj]); cdata[jj] += r; fac = gamma / r; fblock(t, cdata, jx, jy, f1, wdata); @@ -904,8 +897,8 @@ static void InitUserData(WebData wdata) dy = wdata->dy = DY; for (i = 0; i < ns; i++) { - cox[i] = diff[i] / SQR(dx); - coy[i] = diff[i] / SQR(dy); + cox[i] = diff[i] / SUNSQR(dx); + coy[i] = diff[i] / SUNSQR(dy); } /* Set remaining method parameters */ @@ -967,17 +960,17 @@ static void CInit(N_Vector c, WebData wdata) dx = wdata->dx; dy = wdata->dy; - x_factor = SUN_RCONST(4.0) / SQR(AX); - y_factor = SUN_RCONST(4.0) / SQR(AY); + x_factor = SUN_RCONST(4.0) / SUNSQR(AX); + y_factor = SUN_RCONST(4.0) / SUNSQR(AY); for (jy = 0; jy < MY; jy++) { y = jy * dy; - argy = SQR(y_factor * y * (AY - y)); + argy = SUNSQR(y_factor * y * (AY - y)); iyoff = mxns * jy; for (jx = 0; jx < MX; jx++) { x = jx * dx; - argx = SQR(x_factor * x * (AX - x)); + argx = SUNSQR(x_factor * x * (AX - x)); ioff = iyoff + ns * jx; for (i = 1; i <= ns; i++) { @@ -1304,18 +1297,18 @@ static void PrintOutput(N_Vector cB, int ns, int mxns, WebData wdata) } printf("\nMaximum sensitivity with respect to I.C. of species %d\n", i); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" lambda max = %Qe\n", cmax); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" lambda max = %Le\n", cmax); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf(" lambda max = %e\n", cmax); #else printf(" lambda max = %e\n", cmax); #endif printf("at\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" x = %Qe\n y = %Qe\n", x, y); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" x = %Le\n y = %Le\n", x, y); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf(" x = %e\n y = %e\n", x, y); #else printf(" x = %e\n y = %e\n", x, y); #endif diff --git a/examples/cvodes/serial/cvsFoodWeb_ASAp_kry.c b/examples/cvodes/serial/cvsFoodWeb_ASAp_kry.c index 3b2a6c5b2f..3daf66a636 100644 --- a/examples/cvodes/serial/cvsFoodWeb_ASAp_kry.c +++ b/examples/cvodes/serial/cvsFoodWeb_ASAp_kry.c @@ -92,16 +92,6 @@ #include /* defs. of sunrealtype, sunindextype */ #include /* access to SPGMR SUNLinearSolver */ -/* helpful macros */ - -#ifndef MAX -#define MAX(A, B) ((A) > (B) ? (A) : (B)) -#endif - -#ifndef SQR -#define SQR(A) ((A) * (A)) -#endif - /* Constants */ #define ZERO SUN_RCONST(0.0) @@ -318,7 +308,10 @@ int main(int argc, char* argv[]) printf("\nncheck = %d\n", ncheck); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("\n g = int_x int_y c%d(Tfinal,x,y) dx dy = %Qf \n\n", ISPEC, + doubleIntgr(c, ISPEC, wdata)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("\n g = int_x int_y c%d(Tfinal,x,y) dx dy = %Lf \n\n", ISPEC, doubleIntgr(c, ISPEC, wdata)); #else @@ -524,7 +517,7 @@ static int Precond(sunrealtype t, N_Vector c, N_Vector fc, sunbooleantype jok, /* Generate the jth column as a difference quotient */ jj = if0 + j; save = cdata[jj]; - r = MAX(srur * SUNRabs(save), r0 / rewtdata[jj]); + r = SUNMAX(srur * SUNRabs(save), r0 / rewtdata[jj]); cdata[jj] += r; fac = -gamma / r; fblock(t, cdata, jx, jy, f1, wdata); @@ -735,7 +728,7 @@ static int PrecondB(sunrealtype t, N_Vector c, N_Vector cB, N_Vector fcB, /* Generate the jth column as a difference quotient */ jj = if0 + j; save = cdata[jj]; - r = MAX(srur * SUNRabs(save), r0 / rewtdata[jj]); + r = SUNMAX(srur * SUNRabs(save), r0 / rewtdata[jj]); cdata[jj] += r; fac = gamma / r; fblock(t, cdata, jx, jy, f1, wdata); @@ -880,8 +873,8 @@ static void InitUserData(WebData wdata) dy = wdata->dy = DY; for (i = 0; i < ns; i++) { - cox[i] = diff[i] / SQR(dx); - coy[i] = diff[i] / SQR(dy); + cox[i] = diff[i] / SUNSQR(dx); + coy[i] = diff[i] / SUNSQR(dy); } /* Set remaining method parameters */ @@ -943,17 +936,17 @@ static void CInit(N_Vector c, WebData wdata) dx = wdata->dx; dy = wdata->dy; - x_factor = SUN_RCONST(4.0) / SQR(AX); - y_factor = SUN_RCONST(4.0) / SQR(AY); + x_factor = SUN_RCONST(4.0) / SUNSQR(AX); + y_factor = SUN_RCONST(4.0) / SUNSQR(AY); for (jy = 0; jy < MY; jy++) { y = jy * dy; - argy = SQR(y_factor * y * (AY - y)); + argy = SUNSQR(y_factor * y * (AY - y)); iyoff = mxns * jy; for (jx = 0; jx < MX; jx++) { x = jx * dx; - argx = SQR(x_factor * x * (AX - x)); + argx = SUNSQR(x_factor * x * (AX - x)); ioff = iyoff + ns * jx; for (i = 1; i <= ns; i++) { @@ -1308,18 +1301,18 @@ static void PrintOutput(N_Vector cB, int ns, int mxns, WebData wdata) } printf("\nMaximum sensitivity with respect to I.C. of species %d\n", i); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" mu max = %Qe\n", cmax); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" mu max = %Le\n", cmax); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf(" mu max = %e\n", cmax); #else printf(" mu max = %e\n", cmax); #endif printf("at\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" x = %Qe\n y = %Qe\n", x, y); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" x = %Le\n y = %Le\n", x, y); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf(" x = %e\n y = %e\n", x, y); #else printf(" x = %e\n y = %e\n", x, y); #endif diff --git a/examples/cvodes/serial/cvsHessian_ASA_FSA.c b/examples/cvodes/serial/cvsHessian_ASA_FSA.c index 39cecacfe0..3ab419df69 100644 --- a/examples/cvodes/serial/cvsHessian_ASA_FSA.c +++ b/examples/cvodes/serial/cvsHessian_ASA_FSA.c @@ -253,7 +253,17 @@ int main(int argc, char* argv[]) printf("ncheck = %d\n", ncheck); printf("\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" y: %12.4Qe %12.4Qe %12.4Qe", Ith(y, 1), Ith(y, 2), Ith(y, 3)); + printf(" G: %12.4Qe\n", Ith(yQ, 1)); + printf("\n"); + printf(" yS1: %12.4Qe %12.4Qe %12.4Qe\n", Ith(yS[0], 1), Ith(yS[0], 2), + Ith(yS[0], 3)); + printf(" yS2: %12.4Qe %12.4Qe %12.4Qe\n", Ith(yS[1], 1), Ith(yS[1], 2), + Ith(yS[1], 3)); + printf("\n"); + printf(" dG/dp: %12.4Qe %12.4Qe\n", Ith(yQS[0], 1), Ith(yQS[1], 1)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" y: %12.4Le %12.4Le %12.4Le", Ith(y, 1), Ith(y, 2), Ith(y, 3)); printf(" G: %12.4Le\n", Ith(yQ, 1)); printf("\n"); @@ -396,7 +406,12 @@ int main(int argc, char* argv[]) retval = CVodeGetQuadB(cvode_mem, indexB2, &time, yQB2); if (check_retval(&retval, "CVodeGetQuadB", 1)) { return (1); } -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" dG/dp: %12.4Qe %12.4Qe (from backward pb. 1)\n", -Ith(yQB1, 1), + -Ith(yQB1, 2)); + printf(" %12.4Qe %12.4Qe (from backward pb. 2)\n", -Ith(yQB2, 1), + -Ith(yQB2, 2)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" dG/dp: %12.4Le %12.4Le (from backward pb. 1)\n", -Ith(yQB1, 1), -Ith(yQB1, 2)); printf(" %12.4Le %12.4Le (from backward pb. 2)\n", -Ith(yQB2, 1), @@ -410,7 +425,10 @@ int main(int argc, char* argv[]) printf("\n"); printf(" H = d2G/dp2:\n"); printf(" (1) (2)\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" %12.4Qe %12.4Qe\n", -Ith(yQB1, 3), -Ith(yQB2, 3)); + printf(" %12.4Qe %12.4Qe\n", -Ith(yQB1, 4), -Ith(yQB2, 4)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" %12.4Le %12.4Le\n", -Ith(yQB1, 3), -Ith(yQB2, 3)); printf(" %12.4Le %12.4Le\n", -Ith(yQB1, 4), -Ith(yQB2, 4)); #else @@ -447,7 +465,9 @@ int main(int argc, char* argv[]) printf("Finite Difference tests\n"); printf("-----------------------\n\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("del_p = %Qg\n\n", dp); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("del_p = %Lg\n\n", dp); #else printf("del_p = %g\n\n", dp); @@ -497,8 +517,10 @@ int main(int argc, char* argv[]) if (check_retval(&retval, "CVodeGetQuad", 1)) { return (1); } Gp = Ith(yQ, 1); - -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("p1+ y: %12.4Qe %12.4Qe %12.4Qe", Ith(y, 1), Ith(y, 2), Ith(y, 3)); + printf(" G: %12.4Qe\n", Ith(yQ, 1)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("p1+ y: %12.4Le %12.4Le %12.4Le", Ith(y, 1), Ith(y, 2), Ith(y, 3)); printf(" G: %12.4Le\n", Ith(yQ, 1)); #else @@ -520,7 +542,10 @@ int main(int argc, char* argv[]) if (check_retval(&retval, "CVodeGetQuad", 1)) { return (1); } Gm = Ith(yQ, 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("p1- y: %12.4Qe %12.4Qe %12.4Qe", Ith(y, 1), Ith(y, 2), Ith(y, 3)); + printf(" G: %12.4Qe\n", Ith(yQ, 1)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("p1- y: %12.4Le %12.4Le %12.4Le", Ith(y, 1), Ith(y, 2), Ith(y, 3)); printf(" G: %12.4Le\n", Ith(yQ, 1)); #else @@ -549,7 +574,10 @@ int main(int argc, char* argv[]) if (check_retval(&retval, "CVodeGetQuad", 1)) { return (1); } Gp = Ith(yQ, 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("p2+ y: %12.4Qe %12.4Qe %12.4Qe", Ith(y, 1), Ith(y, 2), Ith(y, 3)); + printf(" G: %12.4Qe\n", Ith(yQ, 1)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("p2+ y: %12.4Le %12.4Le %12.4Le", Ith(y, 1), Ith(y, 2), Ith(y, 3)); printf(" G: %12.4Le\n", Ith(yQ, 1)); #else @@ -571,7 +599,10 @@ int main(int argc, char* argv[]) if (check_retval(&retval, "CVodeGetQuad", 1)) { return (1); } Gm = Ith(yQ, 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("p2- y: %12.4Qe %12.4Qe %12.4Qe", Ith(y, 1), Ith(y, 2), Ith(y, 3)); + printf(" G: %12.4Qe\n", Ith(yQ, 1)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("p2- y: %12.4Le %12.4Le %12.4Le", Ith(y, 1), Ith(y, 2), Ith(y, 3)); printf(" G: %12.4Le\n", Ith(yQ, 1)); #else @@ -587,7 +618,14 @@ int main(int argc, char* argv[]) printf("\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" dG/dp: %12.4Qe %12.4Qe (fwd FD)\n", grdG_fwd[0], grdG_fwd[1]); + printf(" %12.4Qe %12.4Qe (bck FD)\n", grdG_bck[0], grdG_bck[1]); + printf(" %12.4Qe %12.4Qe (cntr FD)\n", grdG_cntr[0], grdG_cntr[1]); + printf("\n"); + printf(" H(1,1): %12.4Qe\n", H11); + printf(" H(2,2): %12.4Qe\n", H22); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" dG/dp: %12.4Le %12.4Le (fwd FD)\n", grdG_fwd[0], grdG_fwd[1]); printf(" %12.4Le %12.4Le (bck FD)\n", grdG_bck[0], grdG_bck[1]); printf(" %12.4Le %12.4Le (cntr FD)\n", grdG_cntr[0], grdG_cntr[1]); @@ -662,7 +700,7 @@ static int fQ(sunrealtype t, N_Vector y, N_Vector qdot, void* user_data) y2 = Ith(y, 2); y3 = Ith(y, 3); - Ith(qdot, 1) = 0.5 * (y1 * y1 + y2 * y2 + y3 * y3); + Ith(qdot, 1) = SUN_RCONST(0.5) * (y1 * y1 + y2 * y2 + y3 * y3); return (0); } diff --git a/examples/cvodes/serial/cvsKrylovDemo_ls.c b/examples/cvodes/serial/cvsKrylovDemo_ls.c index 58a5a1dba5..7ccc391cea 100644 --- a/examples/cvodes/serial/cvsKrylovDemo_ls.c +++ b/examples/cvodes/serial/cvsKrylovDemo_ls.c @@ -56,22 +56,6 @@ #include /* access to SPTFQMR SUNLinearSolver */ #include /* access to Newton SUNNonlinearSolver */ -/* helpful macros */ - -#ifndef SQR -#define SQR(A) ((A) * (A)) -#endif - -#ifndef SQRT -#if defined(SUNDIALS_DOUBLE_PRECISION) -#define SQRT(x) (sqrt((x))) -#elif defined(SUNDIALS_SINGLE_PRECISION) -#define SQRT(x) (sqrtf((x))) -#elif defined(SUNDIALS_EXTENDED_PRECISION) -#define SQRT(x) (sqrtl((x))) -#endif -#endif - /* Problem Constants */ #define ZERO SUN_RCONST(0.0) @@ -94,7 +78,7 @@ #define NOUT 12 /* number of output times */ #define TWOHR SUN_RCONST(7200.0) /* number of seconds in two hours */ #define HALFDAY SUN_RCONST(4.32e4) /* number of seconds in a half day */ -#define PI SUN_RCONST(3.1415926535898) /* pi */ +#define PI SUN_RCONST(3.141592653589793238462643383279502884197169) /* pi */ #define XMIN ZERO /* grid boundaries in x */ #define XMAX SUN_RCONST(20.0) @@ -369,7 +353,7 @@ int main(int argc, char* argv[]) { case (1): /* use the square root of the vector length */ - nrmfac = SQRT((sunrealtype)NEQ); + nrmfac = SUNRsqrt((sunrealtype)NEQ); break; case (2): /* compute with dot product */ @@ -444,9 +428,9 @@ static void InitUserData(UserData data) data->om = PI / HALFDAY; data->dx = (XMAX - XMIN) / (MX - 1); data->dy = (YMAX - YMIN) / (MY - 1); - data->hdco = KH / SQR(data->dx); + data->hdco = KH / SUNSQR(data->dx); data->haco = VEL / (TWO * data->dx); - data->vdco = (ONE / SQR(data->dy)) * KV0; + data->vdco = (ONE / SUNSQR(data->dy)) * KV0; } /* Free data memory */ @@ -485,13 +469,13 @@ static void SetInitialProfiles(N_Vector u, sunrealtype dx, sunrealtype dy) for (jy = 0; jy < MY; jy++) { y = YMIN + jy * dy; - cy = SQR(SUN_RCONST(0.1) * (y - YMID)); - cy = ONE - cy + SUN_RCONST(0.5) * SQR(cy); + cy = SUNSQR(SUN_RCONST(0.1) * (y - YMID)); + cy = ONE - cy + SUN_RCONST(0.5) * SUNSQR(cy); for (jx = 0; jx < MX; jx++) { x = XMIN + jx * dx; - cx = SQR(SUN_RCONST(0.1) * (x - XMID)); - cx = ONE - cx + SUN_RCONST(0.5) * SQR(cx); + cx = SUNSQR(SUN_RCONST(0.1) * (x - XMID)); + cx = ONE - cx + SUN_RCONST(0.5) * SUNSQR(cx); IJKth(udata, 1, jx, jy) = C1_SCALE * cx * cy; IJKth(udata, 2, jx, jy) = C2_SCALE * cx * cy; } @@ -516,22 +500,22 @@ static void PrintOutput(void* cvode_mem, N_Vector u, sunrealtype t) retval = CVodeGetLastStep(cvode_mem, &hu); check_retval(&retval, "CVodeGetLastStep", 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) - printf("t = %.2Le no. steps = %ld order = %d stepsize = %.2Le\n", t, +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("t = %.2Qe no. steps = %ld order = %d stepsize = %.2Qe\n", t, nst, qu, hu); - printf("c1 (bot.left/middle/top rt.) = %12.3Le %12.3Le %12.3Le\n", + printf("c1 (bot.left/middle/top rt.) = %12.3Qe %12.3Qe %12.3Qe\n", IJKth(udata, 1, 0, 0), IJKth(udata, 1, mxh, myh), IJKth(udata, 1, mx1, my1)); - printf("c2 (bot.left/middle/top rt.) = %12.3Le %12.3Le %12.3Le\n\n", + printf("c2 (bot.left/middle/top rt.) = %12.3Qe %12.3Qe %12.3Qe\n\n", IJKth(udata, 2, 0, 0), IJKth(udata, 2, mxh, myh), IJKth(udata, 2, mx1, my1)); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("t = %.2e no. steps = %ld order = %d stepsize = %.2e\n", t, nst, - qu, hu); - printf("c1 (bot.left/middle/top rt.) = %12.3e %12.3e %12.3e\n", +#elif defined(SUNDIALS_EXTENDED_PRECISION) + printf("t = %.2Le no. steps = %ld order = %d stepsize = %.2Le\n", t, + nst, qu, hu); + printf("c1 (bot.left/middle/top rt.) = %12.3Le %12.3Le %12.3Le\n", IJKth(udata, 1, 0, 0), IJKth(udata, 1, mxh, myh), IJKth(udata, 1, mx1, my1)); - printf("c2 (bot.left/middle/top rt.) = %12.3e %12.3e %12.3e\n\n", + printf("c2 (bot.left/middle/top rt.) = %12.3Le %12.3Le %12.3Le\n\n", IJKth(udata, 2, 0, 0), IJKth(udata, 2, mxh, myh), IJKth(udata, 2, mx1, my1)); #else @@ -668,11 +652,11 @@ static int f(sunrealtype t, N_Vector u, N_Vector udot, void* user_data) /* Set diurnal rate coefficients. */ - s = sin(data->om * t); + s = SUNRsin(data->om * t); if (s > ZERO) { - q3 = exp(-A3 / s); - data->q4 = exp(-A4 / s); + q3 = SUNRexp(-A3 / s); + data->q4 = SUNRexp(-A4 / s); } else { @@ -696,8 +680,8 @@ static int f(sunrealtype t, N_Vector u, N_Vector udot, void* user_data) ydn = YMIN + (jy - SUN_RCONST(0.5)) * dely; yup = ydn + dely; - cydn = verdco * exp(SUN_RCONST(0.2) * ydn); - cyup = verdco * exp(SUN_RCONST(0.2) * yup); + cydn = verdco * SUNRexp(SUN_RCONST(0.2) * ydn); + cyup = verdco * SUNRexp(SUN_RCONST(0.2) * yup); idn = (jy == 0) ? 1 : -1; iup = (jy == MY - 1) ? -1 : 1; for (jx = 0; jx < MX; jx++) @@ -798,8 +782,8 @@ static int Precond(sunrealtype tn, N_Vector u, N_Vector fu, sunbooleantype jok, { ydn = YMIN + (jy - SUN_RCONST(0.5)) * dely; yup = ydn + dely; - cydn = verdco * exp(SUN_RCONST(0.2) * ydn); - cyup = verdco * exp(SUN_RCONST(0.2) * yup); + cydn = verdco * SUNRexp(SUN_RCONST(0.2) * ydn); + cyup = verdco * SUNRexp(SUN_RCONST(0.2) * yup); diag = -(cydn + cyup + TWO * hordco); for (jx = 0; jx < MX; jx++) { diff --git a/examples/cvodes/serial/cvsKrylovDemo_ls.out b/examples/cvodes/serial/cvsKrylovDemo_ls.out index 7352f513b9..b91d400935 100644 --- a/examples/cvodes/serial/cvsKrylovDemo_ls.out +++ b/examples/cvodes/serial/cvsKrylovDemo_ls.out @@ -1,7 +1,7 @@ - ------- + ------- | SPGMR | ------- - + 2-species diurnal advection-diffusion problem t = 7.20e+03 no. steps = 219 order = 5 stepsize = 1.59e+02 @@ -16,60 +16,60 @@ t = 2.16e+04 no. steps = 277 order = 5 stepsize = 2.75e+02 c1 (bot.left/middle/top rt.) = 2.665e+07 1.036e+07 2.931e+07 c2 (bot.left/middle/top rt.) = 2.993e+11 1.028e+11 3.313e+11 -t = 2.88e+04 no. steps = 307 order = 4 stepsize = 2.01e+02 +t = 2.88e+04 no. steps = 307 order = 4 stepsize = 2.03e+02 c1 (bot.left/middle/top rt.) = 8.702e+06 1.292e+07 9.650e+06 c2 (bot.left/middle/top rt.) = 3.380e+11 5.029e+11 3.751e+11 -t = 3.60e+04 no. steps = 336 order = 5 stepsize = 1.02e+02 +t = 3.60e+04 no. steps = 338 order = 5 stepsize = 9.92e+01 c1 (bot.left/middle/top rt.) = 1.404e+04 2.029e+04 1.561e+04 c2 (bot.left/middle/top rt.) = 3.387e+11 4.894e+11 3.765e+11 -t = 4.32e+04 no. steps = 385 order = 4 stepsize = 4.57e+02 -c1 (bot.left/middle/top rt.) = 5.226e-08 -6.075e-06 8.713e-08 +t = 4.32e+04 no. steps = 393 order = 4 stepsize = 2.57e+02 +c1 (bot.left/middle/top rt.) = -7.685e-06 -9.677e-07 -8.494e-06 c2 (bot.left/middle/top rt.) = 3.382e+11 1.355e+11 3.804e+11 -t = 5.04e+04 no. steps = 403 order = 4 stepsize = 2.77e+02 -c1 (bot.left/middle/top rt.) = -2.670e-08 -4.510e-06 -2.672e-08 +t = 5.04e+04 no. steps = 421 order = 5 stepsize = 4.93e+02 +c1 (bot.left/middle/top rt.) = -1.570e-08 -1.745e-06 -3.070e-08 c2 (bot.left/middle/top rt.) = 3.358e+11 4.930e+11 3.864e+11 -t = 5.76e+04 no. steps = 419 order = 5 stepsize = 3.44e+02 -c1 (bot.left/middle/top rt.) = -1.147e-09 -5.871e-08 -2.195e-09 +t = 5.76e+04 no. steps = 440 order = 5 stepsize = 8.59e+01 +c1 (bot.left/middle/top rt.) = 9.046e-08 6.799e-06 1.298e-07 c2 (bot.left/middle/top rt.) = 3.320e+11 9.650e+11 3.909e+11 -t = 6.48e+04 no. steps = 431 order = 5 stepsize = 9.50e+02 -c1 (bot.left/middle/top rt.) = 3.792e-10 1.901e-08 7.196e-10 +t = 6.48e+04 no. steps = 459 order = 5 stepsize = 6.72e+02 +c1 (bot.left/middle/top rt.) = 4.888e-09 3.680e-07 7.026e-09 c2 (bot.left/middle/top rt.) = 3.313e+11 8.922e+11 3.963e+11 -t = 7.20e+04 no. steps = 441 order = 5 stepsize = 7.01e+02 -c1 (bot.left/middle/top rt.) = -1.872e-11 -9.361e-10 -3.550e-11 +t = 7.20e+04 no. steps = 470 order = 5 stepsize = 6.72e+02 +c1 (bot.left/middle/top rt.) = 7.580e-11 5.711e-09 1.090e-10 c2 (bot.left/middle/top rt.) = 3.330e+11 6.186e+11 4.039e+11 -t = 7.92e+04 no. steps = 451 order = 5 stepsize = 7.01e+02 -c1 (bot.left/middle/top rt.) = 1.365e-13 6.739e-12 2.585e-13 +t = 7.92e+04 no. steps = 481 order = 5 stepsize = 6.72e+02 +c1 (bot.left/middle/top rt.) = 2.772e-13 2.088e-11 4.012e-13 c2 (bot.left/middle/top rt.) = 3.334e+11 6.669e+11 4.120e+11 -t = 8.64e+04 no. steps = 461 order = 5 stepsize = 7.01e+02 -c1 (bot.left/middle/top rt.) = 4.144e-14 2.072e-12 7.862e-14 +t = 8.64e+04 no. steps = 491 order = 5 stepsize = 6.72e+02 +c1 (bot.left/middle/top rt.) = -1.017e-13 -7.659e-12 -1.461e-13 c2 (bot.left/middle/top rt.) = 3.352e+11 9.107e+11 4.163e+11 -Final Statistics.. +Final Statistics.. lenrw = 2696 leniw = 65 lenrwLS = 2454 leniwLS = 42 -nst = 461 -nfe = 597 nfeLS = 636 -nni = 594 nli = 636 -nsetups = 78 netf = 27 -npe = 8 nps = 1176 +nst = 491 +nfe = 631 nfeLS = 652 +nni = 628 nli = 652 +nsetups = 86 netf = 31 +npe = 9 nps = 1227 ncfn = 0 ncfl = 0 ====================================================================== - --------- + --------- | SPFGMR | --------- - + 2-species diurnal advection-diffusion problem t = 7.20e+03 no. steps = 192 order = 5 stepsize = 1.34e+02 @@ -93,51 +93,51 @@ c1 (bot.left/middle/top rt.) = 1.404e+04 2.029e+04 1.561e+04 c2 (bot.left/middle/top rt.) = 3.387e+11 4.895e+11 3.765e+11 t = 4.32e+04 no. steps = 378 order = 5 stepsize = 5.86e+02 -c1 (bot.left/middle/top rt.) = 1.180e-09 7.956e-08 1.490e-09 +c1 (bot.left/middle/top rt.) = 1.184e-09 7.952e-08 1.494e-09 c2 (bot.left/middle/top rt.) = 3.382e+11 1.355e+11 3.804e+11 -t = 5.04e+04 no. steps = 391 order = 5 stepsize = 4.27e+02 -c1 (bot.left/middle/top rt.) = 6.580e-11 2.809e-08 1.507e-10 +t = 5.04e+04 no. steps = 391 order = 5 stepsize = 4.28e+02 +c1 (bot.left/middle/top rt.) = 6.549e-11 2.778e-08 1.492e-10 c2 (bot.left/middle/top rt.) = 3.358e+11 4.930e+11 3.864e+11 -t = 5.76e+04 no. steps = 402 order = 5 stepsize = 4.96e+02 -c1 (bot.left/middle/top rt.) = 2.069e-10 1.559e-08 2.264e-10 +t = 5.76e+04 no. steps = 402 order = 5 stepsize = 4.97e+02 +c1 (bot.left/middle/top rt.) = 2.130e-10 1.597e-08 2.338e-10 c2 (bot.left/middle/top rt.) = 3.320e+11 9.650e+11 3.909e+11 -t = 6.48e+04 no. steps = 412 order = 5 stepsize = 7.86e+02 -c1 (bot.left/middle/top rt.) = 3.735e-11 -1.076e-09 -3.688e-11 +t = 6.48e+04 no. steps = 412 order = 5 stepsize = 7.84e+02 +c1 (bot.left/middle/top rt.) = 3.694e-11 -1.057e-09 -3.646e-11 c2 (bot.left/middle/top rt.) = 3.313e+11 8.922e+11 3.963e+11 -t = 7.20e+04 no. steps = 421 order = 5 stepsize = 7.86e+02 -c1 (bot.left/middle/top rt.) = -1.410e-11 -1.148e-09 9.417e-11 +t = 7.20e+04 no. steps = 421 order = 5 stepsize = 7.84e+02 +c1 (bot.left/middle/top rt.) = -1.398e-11 -1.129e-09 9.313e-11 c2 (bot.left/middle/top rt.) = 3.330e+11 6.186e+11 4.039e+11 -t = 7.92e+04 no. steps = 430 order = 5 stepsize = 7.86e+02 -c1 (bot.left/middle/top rt.) = 1.671e-12 -2.171e-10 -4.471e-12 +t = 7.92e+04 no. steps = 430 order = 5 stepsize = 7.84e+02 +c1 (bot.left/middle/top rt.) = 1.779e-12 -2.371e-10 -4.669e-12 c2 (bot.left/middle/top rt.) = 3.334e+11 6.669e+11 4.120e+11 -t = 8.64e+04 no. steps = 439 order = 5 stepsize = 7.86e+02 -c1 (bot.left/middle/top rt.) = 5.687e-13 -9.924e-11 -1.149e-12 +t = 8.64e+04 no. steps = 439 order = 5 stepsize = 7.84e+02 +c1 (bot.left/middle/top rt.) = 5.057e-13 -8.836e-11 -1.020e-12 c2 (bot.left/middle/top rt.) = 3.352e+11 9.106e+11 4.162e+11 -Final Statistics.. +Final Statistics.. lenrw = 2696 leniw = 65 lenrwLS = 3254 leniwLS = 46 nst = 439 -nfe = 565 nfeLS = 858 -nni = 562 nli = 858 +nfe = 564 nfeLS = 858 +nni = 561 nli = 858 nsetups = 77 netf = 26 npe = 8 nps = 858 ncfn = 0 ncfl = 0 ====================================================================== - ------- + ------- | SPBCGS | ------- - + 2-species diurnal advection-diffusion problem t = 7.20e+03 no. steps = 190 order = 5 stepsize = 1.58e+02 @@ -161,49 +161,49 @@ c1 (bot.left/middle/top rt.) = 1.404e+04 2.029e+04 1.561e+04 c2 (bot.left/middle/top rt.) = 3.387e+11 4.894e+11 3.765e+11 t = 4.32e+04 no. steps = 369 order = 4 stepsize = 5.46e+02 -c1 (bot.left/middle/top rt.) = -6.037e-10 -6.053e-10 -5.358e-10 +c1 (bot.left/middle/top rt.) = -9.938e-10 -9.097e-10 -9.708e-10 c2 (bot.left/middle/top rt.) = 3.382e+11 1.355e+11 3.804e+11 -t = 5.04e+04 no. steps = 385 order = 4 stepsize = 3.19e+02 -c1 (bot.left/middle/top rt.) = -1.354e-14 1.127e-12 -4.255e-14 +t = 5.04e+04 no. steps = 385 order = 4 stepsize = 3.20e+02 +c1 (bot.left/middle/top rt.) = -1.367e-14 1.251e-12 -4.382e-14 c2 (bot.left/middle/top rt.) = 3.358e+11 4.930e+11 3.864e+11 -t = 5.76e+04 no. steps = 399 order = 5 stepsize = 5.96e+02 -c1 (bot.left/middle/top rt.) = 3.721e-14 6.437e-12 2.771e-14 +t = 5.76e+04 no. steps = 399 order = 5 stepsize = 5.75e+02 +c1 (bot.left/middle/top rt.) = 4.897e-14 1.134e-11 2.663e-15 c2 (bot.left/middle/top rt.) = 3.320e+11 9.650e+11 3.909e+11 -t = 6.48e+04 no. steps = 411 order = 5 stepsize = 5.96e+02 -c1 (bot.left/middle/top rt.) = -3.191e-14 3.975e-12 -1.260e-13 +t = 6.48e+04 no. steps = 411 order = 5 stepsize = 5.75e+02 +c1 (bot.left/middle/top rt.) = -2.822e-14 3.240e-12 -1.006e-13 c2 (bot.left/middle/top rt.) = 3.313e+11 8.922e+11 3.963e+11 -t = 7.20e+04 no. steps = 423 order = 5 stepsize = 5.96e+02 -c1 (bot.left/middle/top rt.) = -4.209e-15 -1.602e-13 1.053e-15 +t = 7.20e+04 no. steps = 424 order = 5 stepsize = 5.75e+02 +c1 (bot.left/middle/top rt.) = 1.532e-16 5.896e-15 -3.955e-17 c2 (bot.left/middle/top rt.) = 3.330e+11 6.186e+11 4.039e+11 -t = 7.92e+04 no. steps = 435 order = 5 stepsize = 5.96e+02 -c1 (bot.left/middle/top rt.) = -3.762e-23 -1.366e-21 1.010e-23 +t = 7.92e+04 no. steps = 436 order = 5 stepsize = 5.75e+02 +c1 (bot.left/middle/top rt.) = 7.713e-25 8.129e-23 -1.539e-25 c2 (bot.left/middle/top rt.) = 3.334e+11 6.669e+11 4.120e+11 -t = 8.64e+04 no. steps = 447 order = 5 stepsize = 5.96e+02 -c1 (bot.left/middle/top rt.) = -9.999e-27 -1.866e-22 -1.581e-27 +t = 8.64e+04 no. steps = 449 order = 5 stepsize = 5.75e+02 +c1 (bot.left/middle/top rt.) = -7.037e-27 -1.020e-22 -9.928e-28 c2 (bot.left/middle/top rt.) = 3.352e+11 9.107e+11 4.163e+11 -Final Statistics.. +Final Statistics.. lenrw = 2696 leniw = 65 lenrwLS = 2202 leniwLS = 41 -nst = 447 -nfe = 569 nfeLS = 964 -nni = 566 nli = 482 +nst = 449 +nfe = 570 nfeLS = 968 +nni = 567 nli = 484 nsetups = 72 netf = 25 -npe = 8 nps = 1453 +npe = 8 nps = 1459 ncfn = 0 ncfl = 0 - --------- + --------- | SPTFQMR | --------- - + 2-species diurnal advection-diffusion problem t = 7.20e+03 no. steps = 218 order = 5 stepsize = 1.44e+02 @@ -214,54 +214,55 @@ t = 1.44e+04 no. steps = 250 order = 5 stepsize = 3.27e+02 c1 (bot.left/middle/top rt.) = 6.659e+06 5.316e+06 7.301e+06 c2 (bot.left/middle/top rt.) = 2.582e+11 2.057e+11 2.833e+11 -t = 2.16e+04 no. steps = 275 order = 5 stepsize = 3.50e+02 +t = 2.16e+04 no. steps = 275 order = 5 stepsize = 3.49e+02 c1 (bot.left/middle/top rt.) = 2.665e+07 1.036e+07 2.931e+07 c2 (bot.left/middle/top rt.) = 2.993e+11 1.028e+11 3.313e+11 -t = 2.88e+04 no. steps = 298 order = 5 stepsize = 2.18e+02 +t = 2.88e+04 no. steps = 330 order = 4 stepsize = 2.14e+02 c1 (bot.left/middle/top rt.) = 8.702e+06 1.292e+07 9.650e+06 c2 (bot.left/middle/top rt.) = 3.380e+11 5.029e+11 3.751e+11 -t = 3.60e+04 no. steps = 326 order = 5 stepsize = 1.31e+02 +t = 3.60e+04 no. steps = 369 order = 4 stepsize = 9.72e+01 c1 (bot.left/middle/top rt.) = 1.404e+04 2.029e+04 1.561e+04 c2 (bot.left/middle/top rt.) = 3.387e+11 4.894e+11 3.765e+11 -t = 4.32e+04 no. steps = 377 order = 4 stepsize = 3.89e+02 -c1 (bot.left/middle/top rt.) = 5.444e-07 -1.657e-06 6.244e-07 +t = 4.32e+04 no. steps = 439 order = 4 stepsize = 1.70e+02 +c1 (bot.left/middle/top rt.) = -3.131e-08 -1.943e-08 -3.934e-08 c2 (bot.left/middle/top rt.) = 3.382e+11 1.355e+11 3.804e+11 -t = 5.04e+04 no. steps = 391 order = 5 stepsize = 6.79e+02 -c1 (bot.left/middle/top rt.) = -1.730e-09 -6.249e-07 -9.039e-10 +t = 5.04e+04 no. steps = 454 order = 4 stepsize = 3.71e+02 +c1 (bot.left/middle/top rt.) = -4.557e-11 1.086e-09 -8.068e-11 c2 (bot.left/middle/top rt.) = 3.358e+11 4.930e+11 3.864e+11 -t = 5.76e+04 no. steps = 403 order = 5 stepsize = 4.21e+02 -c1 (bot.left/middle/top rt.) = 7.982e-10 2.122e-07 -1.172e-09 +t = 5.76e+04 no. steps = 467 order = 5 stepsize = 5.82e+02 +c1 (bot.left/middle/top rt.) = 5.569e-11 -8.256e-09 -4.063e-11 c2 (bot.left/middle/top rt.) = 3.320e+11 9.650e+11 3.909e+11 -t = 6.48e+04 no. steps = 414 order = 5 stepsize = 6.89e+02 -c1 (bot.left/middle/top rt.) = 1.420e-09 3.489e-07 -2.356e-09 +t = 6.48e+04 no. steps = 479 order = 5 stepsize = 8.84e+02 +c1 (bot.left/middle/top rt.) = 2.899e-10 -1.355e-07 5.869e-10 c2 (bot.left/middle/top rt.) = 3.313e+11 8.922e+11 3.963e+11 -t = 7.20e+04 no. steps = 424 order = 5 stepsize = 6.89e+02 -c1 (bot.left/middle/top rt.) = 1.045e-12 2.583e-10 -1.763e-12 +t = 7.20e+04 no. steps = 489 order = 5 stepsize = 6.53e+02 +c1 (bot.left/middle/top rt.) = 9.493e-14 -4.124e-13 4.162e-14 c2 (bot.left/middle/top rt.) = 3.330e+11 6.186e+11 4.039e+11 -t = 7.92e+04 no. steps = 435 order = 5 stepsize = 6.89e+02 -c1 (bot.left/middle/top rt.) = -2.523e-19 5.442e-16 4.663e-19 +t = 7.92e+04 no. steps = 500 order = 5 stepsize = 6.53e+02 +c1 (bot.left/middle/top rt.) = -4.240e-21 7.214e-18 -5.798e-20 c2 (bot.left/middle/top rt.) = 3.334e+11 6.669e+11 4.120e+11 -t = 8.64e+04 no. steps = 445 order = 5 stepsize = 6.89e+02 -c1 (bot.left/middle/top rt.) = -1.673e-20 -1.128e-15 -3.081e-21 -c2 (bot.left/middle/top rt.) = 3.352e+11 9.106e+11 4.163e+11 +t = 8.64e+04 no. steps = 512 order = 5 stepsize = 6.53e+02 +c1 (bot.left/middle/top rt.) = -2.841e-21 -1.757e-17 2.220e-21 +c2 (bot.left/middle/top rt.) = 3.352e+11 9.107e+11 4.163e+11 -Final Statistics.. +Final Statistics.. lenrw = 2696 leniw = 65 lenrwLS = 2602 leniwLS = 43 -nst = 445 -nfe = 558 nfeLS = 1143 -nni = 555 nli = 477 -nsetups = 67 netf = 21 -npe = 8 nps = 1805 +nst = 512 +nfe = 657 nfeLS = 1293 +nni = 654 nli = 557 +nsetups = 90 netf = 29 +npe = 9 nps = 2027 ncfn = 0 ncfl = 0 + diff --git a/examples/cvodes/serial/cvsKrylovDemo_ls_1.out b/examples/cvodes/serial/cvsKrylovDemo_ls_1.out index 7352f513b9..b91d400935 100644 --- a/examples/cvodes/serial/cvsKrylovDemo_ls_1.out +++ b/examples/cvodes/serial/cvsKrylovDemo_ls_1.out @@ -1,7 +1,7 @@ - ------- + ------- | SPGMR | ------- - + 2-species diurnal advection-diffusion problem t = 7.20e+03 no. steps = 219 order = 5 stepsize = 1.59e+02 @@ -16,60 +16,60 @@ t = 2.16e+04 no. steps = 277 order = 5 stepsize = 2.75e+02 c1 (bot.left/middle/top rt.) = 2.665e+07 1.036e+07 2.931e+07 c2 (bot.left/middle/top rt.) = 2.993e+11 1.028e+11 3.313e+11 -t = 2.88e+04 no. steps = 307 order = 4 stepsize = 2.01e+02 +t = 2.88e+04 no. steps = 307 order = 4 stepsize = 2.03e+02 c1 (bot.left/middle/top rt.) = 8.702e+06 1.292e+07 9.650e+06 c2 (bot.left/middle/top rt.) = 3.380e+11 5.029e+11 3.751e+11 -t = 3.60e+04 no. steps = 336 order = 5 stepsize = 1.02e+02 +t = 3.60e+04 no. steps = 338 order = 5 stepsize = 9.92e+01 c1 (bot.left/middle/top rt.) = 1.404e+04 2.029e+04 1.561e+04 c2 (bot.left/middle/top rt.) = 3.387e+11 4.894e+11 3.765e+11 -t = 4.32e+04 no. steps = 385 order = 4 stepsize = 4.57e+02 -c1 (bot.left/middle/top rt.) = 5.226e-08 -6.075e-06 8.713e-08 +t = 4.32e+04 no. steps = 393 order = 4 stepsize = 2.57e+02 +c1 (bot.left/middle/top rt.) = -7.685e-06 -9.677e-07 -8.494e-06 c2 (bot.left/middle/top rt.) = 3.382e+11 1.355e+11 3.804e+11 -t = 5.04e+04 no. steps = 403 order = 4 stepsize = 2.77e+02 -c1 (bot.left/middle/top rt.) = -2.670e-08 -4.510e-06 -2.672e-08 +t = 5.04e+04 no. steps = 421 order = 5 stepsize = 4.93e+02 +c1 (bot.left/middle/top rt.) = -1.570e-08 -1.745e-06 -3.070e-08 c2 (bot.left/middle/top rt.) = 3.358e+11 4.930e+11 3.864e+11 -t = 5.76e+04 no. steps = 419 order = 5 stepsize = 3.44e+02 -c1 (bot.left/middle/top rt.) = -1.147e-09 -5.871e-08 -2.195e-09 +t = 5.76e+04 no. steps = 440 order = 5 stepsize = 8.59e+01 +c1 (bot.left/middle/top rt.) = 9.046e-08 6.799e-06 1.298e-07 c2 (bot.left/middle/top rt.) = 3.320e+11 9.650e+11 3.909e+11 -t = 6.48e+04 no. steps = 431 order = 5 stepsize = 9.50e+02 -c1 (bot.left/middle/top rt.) = 3.792e-10 1.901e-08 7.196e-10 +t = 6.48e+04 no. steps = 459 order = 5 stepsize = 6.72e+02 +c1 (bot.left/middle/top rt.) = 4.888e-09 3.680e-07 7.026e-09 c2 (bot.left/middle/top rt.) = 3.313e+11 8.922e+11 3.963e+11 -t = 7.20e+04 no. steps = 441 order = 5 stepsize = 7.01e+02 -c1 (bot.left/middle/top rt.) = -1.872e-11 -9.361e-10 -3.550e-11 +t = 7.20e+04 no. steps = 470 order = 5 stepsize = 6.72e+02 +c1 (bot.left/middle/top rt.) = 7.580e-11 5.711e-09 1.090e-10 c2 (bot.left/middle/top rt.) = 3.330e+11 6.186e+11 4.039e+11 -t = 7.92e+04 no. steps = 451 order = 5 stepsize = 7.01e+02 -c1 (bot.left/middle/top rt.) = 1.365e-13 6.739e-12 2.585e-13 +t = 7.92e+04 no. steps = 481 order = 5 stepsize = 6.72e+02 +c1 (bot.left/middle/top rt.) = 2.772e-13 2.088e-11 4.012e-13 c2 (bot.left/middle/top rt.) = 3.334e+11 6.669e+11 4.120e+11 -t = 8.64e+04 no. steps = 461 order = 5 stepsize = 7.01e+02 -c1 (bot.left/middle/top rt.) = 4.144e-14 2.072e-12 7.862e-14 +t = 8.64e+04 no. steps = 491 order = 5 stepsize = 6.72e+02 +c1 (bot.left/middle/top rt.) = -1.017e-13 -7.659e-12 -1.461e-13 c2 (bot.left/middle/top rt.) = 3.352e+11 9.107e+11 4.163e+11 -Final Statistics.. +Final Statistics.. lenrw = 2696 leniw = 65 lenrwLS = 2454 leniwLS = 42 -nst = 461 -nfe = 597 nfeLS = 636 -nni = 594 nli = 636 -nsetups = 78 netf = 27 -npe = 8 nps = 1176 +nst = 491 +nfe = 631 nfeLS = 652 +nni = 628 nli = 652 +nsetups = 86 netf = 31 +npe = 9 nps = 1227 ncfn = 0 ncfl = 0 ====================================================================== - --------- + --------- | SPFGMR | --------- - + 2-species diurnal advection-diffusion problem t = 7.20e+03 no. steps = 192 order = 5 stepsize = 1.34e+02 @@ -93,51 +93,51 @@ c1 (bot.left/middle/top rt.) = 1.404e+04 2.029e+04 1.561e+04 c2 (bot.left/middle/top rt.) = 3.387e+11 4.895e+11 3.765e+11 t = 4.32e+04 no. steps = 378 order = 5 stepsize = 5.86e+02 -c1 (bot.left/middle/top rt.) = 1.180e-09 7.956e-08 1.490e-09 +c1 (bot.left/middle/top rt.) = 1.184e-09 7.952e-08 1.494e-09 c2 (bot.left/middle/top rt.) = 3.382e+11 1.355e+11 3.804e+11 -t = 5.04e+04 no. steps = 391 order = 5 stepsize = 4.27e+02 -c1 (bot.left/middle/top rt.) = 6.580e-11 2.809e-08 1.507e-10 +t = 5.04e+04 no. steps = 391 order = 5 stepsize = 4.28e+02 +c1 (bot.left/middle/top rt.) = 6.549e-11 2.778e-08 1.492e-10 c2 (bot.left/middle/top rt.) = 3.358e+11 4.930e+11 3.864e+11 -t = 5.76e+04 no. steps = 402 order = 5 stepsize = 4.96e+02 -c1 (bot.left/middle/top rt.) = 2.069e-10 1.559e-08 2.264e-10 +t = 5.76e+04 no. steps = 402 order = 5 stepsize = 4.97e+02 +c1 (bot.left/middle/top rt.) = 2.130e-10 1.597e-08 2.338e-10 c2 (bot.left/middle/top rt.) = 3.320e+11 9.650e+11 3.909e+11 -t = 6.48e+04 no. steps = 412 order = 5 stepsize = 7.86e+02 -c1 (bot.left/middle/top rt.) = 3.735e-11 -1.076e-09 -3.688e-11 +t = 6.48e+04 no. steps = 412 order = 5 stepsize = 7.84e+02 +c1 (bot.left/middle/top rt.) = 3.694e-11 -1.057e-09 -3.646e-11 c2 (bot.left/middle/top rt.) = 3.313e+11 8.922e+11 3.963e+11 -t = 7.20e+04 no. steps = 421 order = 5 stepsize = 7.86e+02 -c1 (bot.left/middle/top rt.) = -1.410e-11 -1.148e-09 9.417e-11 +t = 7.20e+04 no. steps = 421 order = 5 stepsize = 7.84e+02 +c1 (bot.left/middle/top rt.) = -1.398e-11 -1.129e-09 9.313e-11 c2 (bot.left/middle/top rt.) = 3.330e+11 6.186e+11 4.039e+11 -t = 7.92e+04 no. steps = 430 order = 5 stepsize = 7.86e+02 -c1 (bot.left/middle/top rt.) = 1.671e-12 -2.171e-10 -4.471e-12 +t = 7.92e+04 no. steps = 430 order = 5 stepsize = 7.84e+02 +c1 (bot.left/middle/top rt.) = 1.779e-12 -2.371e-10 -4.669e-12 c2 (bot.left/middle/top rt.) = 3.334e+11 6.669e+11 4.120e+11 -t = 8.64e+04 no. steps = 439 order = 5 stepsize = 7.86e+02 -c1 (bot.left/middle/top rt.) = 5.687e-13 -9.924e-11 -1.149e-12 +t = 8.64e+04 no. steps = 439 order = 5 stepsize = 7.84e+02 +c1 (bot.left/middle/top rt.) = 5.057e-13 -8.836e-11 -1.020e-12 c2 (bot.left/middle/top rt.) = 3.352e+11 9.106e+11 4.162e+11 -Final Statistics.. +Final Statistics.. lenrw = 2696 leniw = 65 lenrwLS = 3254 leniwLS = 46 nst = 439 -nfe = 565 nfeLS = 858 -nni = 562 nli = 858 +nfe = 564 nfeLS = 858 +nni = 561 nli = 858 nsetups = 77 netf = 26 npe = 8 nps = 858 ncfn = 0 ncfl = 0 ====================================================================== - ------- + ------- | SPBCGS | ------- - + 2-species diurnal advection-diffusion problem t = 7.20e+03 no. steps = 190 order = 5 stepsize = 1.58e+02 @@ -161,49 +161,49 @@ c1 (bot.left/middle/top rt.) = 1.404e+04 2.029e+04 1.561e+04 c2 (bot.left/middle/top rt.) = 3.387e+11 4.894e+11 3.765e+11 t = 4.32e+04 no. steps = 369 order = 4 stepsize = 5.46e+02 -c1 (bot.left/middle/top rt.) = -6.037e-10 -6.053e-10 -5.358e-10 +c1 (bot.left/middle/top rt.) = -9.938e-10 -9.097e-10 -9.708e-10 c2 (bot.left/middle/top rt.) = 3.382e+11 1.355e+11 3.804e+11 -t = 5.04e+04 no. steps = 385 order = 4 stepsize = 3.19e+02 -c1 (bot.left/middle/top rt.) = -1.354e-14 1.127e-12 -4.255e-14 +t = 5.04e+04 no. steps = 385 order = 4 stepsize = 3.20e+02 +c1 (bot.left/middle/top rt.) = -1.367e-14 1.251e-12 -4.382e-14 c2 (bot.left/middle/top rt.) = 3.358e+11 4.930e+11 3.864e+11 -t = 5.76e+04 no. steps = 399 order = 5 stepsize = 5.96e+02 -c1 (bot.left/middle/top rt.) = 3.721e-14 6.437e-12 2.771e-14 +t = 5.76e+04 no. steps = 399 order = 5 stepsize = 5.75e+02 +c1 (bot.left/middle/top rt.) = 4.897e-14 1.134e-11 2.663e-15 c2 (bot.left/middle/top rt.) = 3.320e+11 9.650e+11 3.909e+11 -t = 6.48e+04 no. steps = 411 order = 5 stepsize = 5.96e+02 -c1 (bot.left/middle/top rt.) = -3.191e-14 3.975e-12 -1.260e-13 +t = 6.48e+04 no. steps = 411 order = 5 stepsize = 5.75e+02 +c1 (bot.left/middle/top rt.) = -2.822e-14 3.240e-12 -1.006e-13 c2 (bot.left/middle/top rt.) = 3.313e+11 8.922e+11 3.963e+11 -t = 7.20e+04 no. steps = 423 order = 5 stepsize = 5.96e+02 -c1 (bot.left/middle/top rt.) = -4.209e-15 -1.602e-13 1.053e-15 +t = 7.20e+04 no. steps = 424 order = 5 stepsize = 5.75e+02 +c1 (bot.left/middle/top rt.) = 1.532e-16 5.896e-15 -3.955e-17 c2 (bot.left/middle/top rt.) = 3.330e+11 6.186e+11 4.039e+11 -t = 7.92e+04 no. steps = 435 order = 5 stepsize = 5.96e+02 -c1 (bot.left/middle/top rt.) = -3.762e-23 -1.366e-21 1.010e-23 +t = 7.92e+04 no. steps = 436 order = 5 stepsize = 5.75e+02 +c1 (bot.left/middle/top rt.) = 7.713e-25 8.129e-23 -1.539e-25 c2 (bot.left/middle/top rt.) = 3.334e+11 6.669e+11 4.120e+11 -t = 8.64e+04 no. steps = 447 order = 5 stepsize = 5.96e+02 -c1 (bot.left/middle/top rt.) = -9.999e-27 -1.866e-22 -1.581e-27 +t = 8.64e+04 no. steps = 449 order = 5 stepsize = 5.75e+02 +c1 (bot.left/middle/top rt.) = -7.037e-27 -1.020e-22 -9.928e-28 c2 (bot.left/middle/top rt.) = 3.352e+11 9.107e+11 4.163e+11 -Final Statistics.. +Final Statistics.. lenrw = 2696 leniw = 65 lenrwLS = 2202 leniwLS = 41 -nst = 447 -nfe = 569 nfeLS = 964 -nni = 566 nli = 482 +nst = 449 +nfe = 570 nfeLS = 968 +nni = 567 nli = 484 nsetups = 72 netf = 25 -npe = 8 nps = 1453 +npe = 8 nps = 1459 ncfn = 0 ncfl = 0 - --------- + --------- | SPTFQMR | --------- - + 2-species diurnal advection-diffusion problem t = 7.20e+03 no. steps = 218 order = 5 stepsize = 1.44e+02 @@ -214,54 +214,55 @@ t = 1.44e+04 no. steps = 250 order = 5 stepsize = 3.27e+02 c1 (bot.left/middle/top rt.) = 6.659e+06 5.316e+06 7.301e+06 c2 (bot.left/middle/top rt.) = 2.582e+11 2.057e+11 2.833e+11 -t = 2.16e+04 no. steps = 275 order = 5 stepsize = 3.50e+02 +t = 2.16e+04 no. steps = 275 order = 5 stepsize = 3.49e+02 c1 (bot.left/middle/top rt.) = 2.665e+07 1.036e+07 2.931e+07 c2 (bot.left/middle/top rt.) = 2.993e+11 1.028e+11 3.313e+11 -t = 2.88e+04 no. steps = 298 order = 5 stepsize = 2.18e+02 +t = 2.88e+04 no. steps = 330 order = 4 stepsize = 2.14e+02 c1 (bot.left/middle/top rt.) = 8.702e+06 1.292e+07 9.650e+06 c2 (bot.left/middle/top rt.) = 3.380e+11 5.029e+11 3.751e+11 -t = 3.60e+04 no. steps = 326 order = 5 stepsize = 1.31e+02 +t = 3.60e+04 no. steps = 369 order = 4 stepsize = 9.72e+01 c1 (bot.left/middle/top rt.) = 1.404e+04 2.029e+04 1.561e+04 c2 (bot.left/middle/top rt.) = 3.387e+11 4.894e+11 3.765e+11 -t = 4.32e+04 no. steps = 377 order = 4 stepsize = 3.89e+02 -c1 (bot.left/middle/top rt.) = 5.444e-07 -1.657e-06 6.244e-07 +t = 4.32e+04 no. steps = 439 order = 4 stepsize = 1.70e+02 +c1 (bot.left/middle/top rt.) = -3.131e-08 -1.943e-08 -3.934e-08 c2 (bot.left/middle/top rt.) = 3.382e+11 1.355e+11 3.804e+11 -t = 5.04e+04 no. steps = 391 order = 5 stepsize = 6.79e+02 -c1 (bot.left/middle/top rt.) = -1.730e-09 -6.249e-07 -9.039e-10 +t = 5.04e+04 no. steps = 454 order = 4 stepsize = 3.71e+02 +c1 (bot.left/middle/top rt.) = -4.557e-11 1.086e-09 -8.068e-11 c2 (bot.left/middle/top rt.) = 3.358e+11 4.930e+11 3.864e+11 -t = 5.76e+04 no. steps = 403 order = 5 stepsize = 4.21e+02 -c1 (bot.left/middle/top rt.) = 7.982e-10 2.122e-07 -1.172e-09 +t = 5.76e+04 no. steps = 467 order = 5 stepsize = 5.82e+02 +c1 (bot.left/middle/top rt.) = 5.569e-11 -8.256e-09 -4.063e-11 c2 (bot.left/middle/top rt.) = 3.320e+11 9.650e+11 3.909e+11 -t = 6.48e+04 no. steps = 414 order = 5 stepsize = 6.89e+02 -c1 (bot.left/middle/top rt.) = 1.420e-09 3.489e-07 -2.356e-09 +t = 6.48e+04 no. steps = 479 order = 5 stepsize = 8.84e+02 +c1 (bot.left/middle/top rt.) = 2.899e-10 -1.355e-07 5.869e-10 c2 (bot.left/middle/top rt.) = 3.313e+11 8.922e+11 3.963e+11 -t = 7.20e+04 no. steps = 424 order = 5 stepsize = 6.89e+02 -c1 (bot.left/middle/top rt.) = 1.045e-12 2.583e-10 -1.763e-12 +t = 7.20e+04 no. steps = 489 order = 5 stepsize = 6.53e+02 +c1 (bot.left/middle/top rt.) = 9.493e-14 -4.124e-13 4.162e-14 c2 (bot.left/middle/top rt.) = 3.330e+11 6.186e+11 4.039e+11 -t = 7.92e+04 no. steps = 435 order = 5 stepsize = 6.89e+02 -c1 (bot.left/middle/top rt.) = -2.523e-19 5.442e-16 4.663e-19 +t = 7.92e+04 no. steps = 500 order = 5 stepsize = 6.53e+02 +c1 (bot.left/middle/top rt.) = -4.240e-21 7.214e-18 -5.798e-20 c2 (bot.left/middle/top rt.) = 3.334e+11 6.669e+11 4.120e+11 -t = 8.64e+04 no. steps = 445 order = 5 stepsize = 6.89e+02 -c1 (bot.left/middle/top rt.) = -1.673e-20 -1.128e-15 -3.081e-21 -c2 (bot.left/middle/top rt.) = 3.352e+11 9.106e+11 4.163e+11 +t = 8.64e+04 no. steps = 512 order = 5 stepsize = 6.53e+02 +c1 (bot.left/middle/top rt.) = -2.841e-21 -1.757e-17 2.220e-21 +c2 (bot.left/middle/top rt.) = 3.352e+11 9.107e+11 4.163e+11 -Final Statistics.. +Final Statistics.. lenrw = 2696 leniw = 65 lenrwLS = 2602 leniwLS = 43 -nst = 445 -nfe = 558 nfeLS = 1143 -nni = 555 nli = 477 -nsetups = 67 netf = 21 -npe = 8 nps = 1805 +nst = 512 +nfe = 657 nfeLS = 1293 +nni = 654 nli = 557 +nsetups = 90 netf = 29 +npe = 9 nps = 2027 ncfn = 0 ncfl = 0 + diff --git a/examples/cvodes/serial/cvsKrylovDemo_ls_2.out b/examples/cvodes/serial/cvsKrylovDemo_ls_2.out index 7352f513b9..b91d400935 100644 --- a/examples/cvodes/serial/cvsKrylovDemo_ls_2.out +++ b/examples/cvodes/serial/cvsKrylovDemo_ls_2.out @@ -1,7 +1,7 @@ - ------- + ------- | SPGMR | ------- - + 2-species diurnal advection-diffusion problem t = 7.20e+03 no. steps = 219 order = 5 stepsize = 1.59e+02 @@ -16,60 +16,60 @@ t = 2.16e+04 no. steps = 277 order = 5 stepsize = 2.75e+02 c1 (bot.left/middle/top rt.) = 2.665e+07 1.036e+07 2.931e+07 c2 (bot.left/middle/top rt.) = 2.993e+11 1.028e+11 3.313e+11 -t = 2.88e+04 no. steps = 307 order = 4 stepsize = 2.01e+02 +t = 2.88e+04 no. steps = 307 order = 4 stepsize = 2.03e+02 c1 (bot.left/middle/top rt.) = 8.702e+06 1.292e+07 9.650e+06 c2 (bot.left/middle/top rt.) = 3.380e+11 5.029e+11 3.751e+11 -t = 3.60e+04 no. steps = 336 order = 5 stepsize = 1.02e+02 +t = 3.60e+04 no. steps = 338 order = 5 stepsize = 9.92e+01 c1 (bot.left/middle/top rt.) = 1.404e+04 2.029e+04 1.561e+04 c2 (bot.left/middle/top rt.) = 3.387e+11 4.894e+11 3.765e+11 -t = 4.32e+04 no. steps = 385 order = 4 stepsize = 4.57e+02 -c1 (bot.left/middle/top rt.) = 5.226e-08 -6.075e-06 8.713e-08 +t = 4.32e+04 no. steps = 393 order = 4 stepsize = 2.57e+02 +c1 (bot.left/middle/top rt.) = -7.685e-06 -9.677e-07 -8.494e-06 c2 (bot.left/middle/top rt.) = 3.382e+11 1.355e+11 3.804e+11 -t = 5.04e+04 no. steps = 403 order = 4 stepsize = 2.77e+02 -c1 (bot.left/middle/top rt.) = -2.670e-08 -4.510e-06 -2.672e-08 +t = 5.04e+04 no. steps = 421 order = 5 stepsize = 4.93e+02 +c1 (bot.left/middle/top rt.) = -1.570e-08 -1.745e-06 -3.070e-08 c2 (bot.left/middle/top rt.) = 3.358e+11 4.930e+11 3.864e+11 -t = 5.76e+04 no. steps = 419 order = 5 stepsize = 3.44e+02 -c1 (bot.left/middle/top rt.) = -1.147e-09 -5.871e-08 -2.195e-09 +t = 5.76e+04 no. steps = 440 order = 5 stepsize = 8.59e+01 +c1 (bot.left/middle/top rt.) = 9.046e-08 6.799e-06 1.298e-07 c2 (bot.left/middle/top rt.) = 3.320e+11 9.650e+11 3.909e+11 -t = 6.48e+04 no. steps = 431 order = 5 stepsize = 9.50e+02 -c1 (bot.left/middle/top rt.) = 3.792e-10 1.901e-08 7.196e-10 +t = 6.48e+04 no. steps = 459 order = 5 stepsize = 6.72e+02 +c1 (bot.left/middle/top rt.) = 4.888e-09 3.680e-07 7.026e-09 c2 (bot.left/middle/top rt.) = 3.313e+11 8.922e+11 3.963e+11 -t = 7.20e+04 no. steps = 441 order = 5 stepsize = 7.01e+02 -c1 (bot.left/middle/top rt.) = -1.872e-11 -9.361e-10 -3.550e-11 +t = 7.20e+04 no. steps = 470 order = 5 stepsize = 6.72e+02 +c1 (bot.left/middle/top rt.) = 7.580e-11 5.711e-09 1.090e-10 c2 (bot.left/middle/top rt.) = 3.330e+11 6.186e+11 4.039e+11 -t = 7.92e+04 no. steps = 451 order = 5 stepsize = 7.01e+02 -c1 (bot.left/middle/top rt.) = 1.365e-13 6.739e-12 2.585e-13 +t = 7.92e+04 no. steps = 481 order = 5 stepsize = 6.72e+02 +c1 (bot.left/middle/top rt.) = 2.772e-13 2.088e-11 4.012e-13 c2 (bot.left/middle/top rt.) = 3.334e+11 6.669e+11 4.120e+11 -t = 8.64e+04 no. steps = 461 order = 5 stepsize = 7.01e+02 -c1 (bot.left/middle/top rt.) = 4.144e-14 2.072e-12 7.862e-14 +t = 8.64e+04 no. steps = 491 order = 5 stepsize = 6.72e+02 +c1 (bot.left/middle/top rt.) = -1.017e-13 -7.659e-12 -1.461e-13 c2 (bot.left/middle/top rt.) = 3.352e+11 9.107e+11 4.163e+11 -Final Statistics.. +Final Statistics.. lenrw = 2696 leniw = 65 lenrwLS = 2454 leniwLS = 42 -nst = 461 -nfe = 597 nfeLS = 636 -nni = 594 nli = 636 -nsetups = 78 netf = 27 -npe = 8 nps = 1176 +nst = 491 +nfe = 631 nfeLS = 652 +nni = 628 nli = 652 +nsetups = 86 netf = 31 +npe = 9 nps = 1227 ncfn = 0 ncfl = 0 ====================================================================== - --------- + --------- | SPFGMR | --------- - + 2-species diurnal advection-diffusion problem t = 7.20e+03 no. steps = 192 order = 5 stepsize = 1.34e+02 @@ -93,51 +93,51 @@ c1 (bot.left/middle/top rt.) = 1.404e+04 2.029e+04 1.561e+04 c2 (bot.left/middle/top rt.) = 3.387e+11 4.895e+11 3.765e+11 t = 4.32e+04 no. steps = 378 order = 5 stepsize = 5.86e+02 -c1 (bot.left/middle/top rt.) = 1.180e-09 7.956e-08 1.490e-09 +c1 (bot.left/middle/top rt.) = 1.184e-09 7.952e-08 1.494e-09 c2 (bot.left/middle/top rt.) = 3.382e+11 1.355e+11 3.804e+11 -t = 5.04e+04 no. steps = 391 order = 5 stepsize = 4.27e+02 -c1 (bot.left/middle/top rt.) = 6.580e-11 2.809e-08 1.507e-10 +t = 5.04e+04 no. steps = 391 order = 5 stepsize = 4.28e+02 +c1 (bot.left/middle/top rt.) = 6.549e-11 2.778e-08 1.492e-10 c2 (bot.left/middle/top rt.) = 3.358e+11 4.930e+11 3.864e+11 -t = 5.76e+04 no. steps = 402 order = 5 stepsize = 4.96e+02 -c1 (bot.left/middle/top rt.) = 2.069e-10 1.559e-08 2.264e-10 +t = 5.76e+04 no. steps = 402 order = 5 stepsize = 4.97e+02 +c1 (bot.left/middle/top rt.) = 2.130e-10 1.597e-08 2.338e-10 c2 (bot.left/middle/top rt.) = 3.320e+11 9.650e+11 3.909e+11 -t = 6.48e+04 no. steps = 412 order = 5 stepsize = 7.86e+02 -c1 (bot.left/middle/top rt.) = 3.735e-11 -1.076e-09 -3.688e-11 +t = 6.48e+04 no. steps = 412 order = 5 stepsize = 7.84e+02 +c1 (bot.left/middle/top rt.) = 3.694e-11 -1.057e-09 -3.646e-11 c2 (bot.left/middle/top rt.) = 3.313e+11 8.922e+11 3.963e+11 -t = 7.20e+04 no. steps = 421 order = 5 stepsize = 7.86e+02 -c1 (bot.left/middle/top rt.) = -1.410e-11 -1.148e-09 9.417e-11 +t = 7.20e+04 no. steps = 421 order = 5 stepsize = 7.84e+02 +c1 (bot.left/middle/top rt.) = -1.398e-11 -1.129e-09 9.313e-11 c2 (bot.left/middle/top rt.) = 3.330e+11 6.186e+11 4.039e+11 -t = 7.92e+04 no. steps = 430 order = 5 stepsize = 7.86e+02 -c1 (bot.left/middle/top rt.) = 1.671e-12 -2.171e-10 -4.471e-12 +t = 7.92e+04 no. steps = 430 order = 5 stepsize = 7.84e+02 +c1 (bot.left/middle/top rt.) = 1.779e-12 -2.371e-10 -4.669e-12 c2 (bot.left/middle/top rt.) = 3.334e+11 6.669e+11 4.120e+11 -t = 8.64e+04 no. steps = 439 order = 5 stepsize = 7.86e+02 -c1 (bot.left/middle/top rt.) = 5.687e-13 -9.924e-11 -1.149e-12 +t = 8.64e+04 no. steps = 439 order = 5 stepsize = 7.84e+02 +c1 (bot.left/middle/top rt.) = 5.057e-13 -8.836e-11 -1.020e-12 c2 (bot.left/middle/top rt.) = 3.352e+11 9.106e+11 4.162e+11 -Final Statistics.. +Final Statistics.. lenrw = 2696 leniw = 65 lenrwLS = 3254 leniwLS = 46 nst = 439 -nfe = 565 nfeLS = 858 -nni = 562 nli = 858 +nfe = 564 nfeLS = 858 +nni = 561 nli = 858 nsetups = 77 netf = 26 npe = 8 nps = 858 ncfn = 0 ncfl = 0 ====================================================================== - ------- + ------- | SPBCGS | ------- - + 2-species diurnal advection-diffusion problem t = 7.20e+03 no. steps = 190 order = 5 stepsize = 1.58e+02 @@ -161,49 +161,49 @@ c1 (bot.left/middle/top rt.) = 1.404e+04 2.029e+04 1.561e+04 c2 (bot.left/middle/top rt.) = 3.387e+11 4.894e+11 3.765e+11 t = 4.32e+04 no. steps = 369 order = 4 stepsize = 5.46e+02 -c1 (bot.left/middle/top rt.) = -6.037e-10 -6.053e-10 -5.358e-10 +c1 (bot.left/middle/top rt.) = -9.938e-10 -9.097e-10 -9.708e-10 c2 (bot.left/middle/top rt.) = 3.382e+11 1.355e+11 3.804e+11 -t = 5.04e+04 no. steps = 385 order = 4 stepsize = 3.19e+02 -c1 (bot.left/middle/top rt.) = -1.354e-14 1.127e-12 -4.255e-14 +t = 5.04e+04 no. steps = 385 order = 4 stepsize = 3.20e+02 +c1 (bot.left/middle/top rt.) = -1.367e-14 1.251e-12 -4.382e-14 c2 (bot.left/middle/top rt.) = 3.358e+11 4.930e+11 3.864e+11 -t = 5.76e+04 no. steps = 399 order = 5 stepsize = 5.96e+02 -c1 (bot.left/middle/top rt.) = 3.721e-14 6.437e-12 2.771e-14 +t = 5.76e+04 no. steps = 399 order = 5 stepsize = 5.75e+02 +c1 (bot.left/middle/top rt.) = 4.897e-14 1.134e-11 2.663e-15 c2 (bot.left/middle/top rt.) = 3.320e+11 9.650e+11 3.909e+11 -t = 6.48e+04 no. steps = 411 order = 5 stepsize = 5.96e+02 -c1 (bot.left/middle/top rt.) = -3.191e-14 3.975e-12 -1.260e-13 +t = 6.48e+04 no. steps = 411 order = 5 stepsize = 5.75e+02 +c1 (bot.left/middle/top rt.) = -2.822e-14 3.240e-12 -1.006e-13 c2 (bot.left/middle/top rt.) = 3.313e+11 8.922e+11 3.963e+11 -t = 7.20e+04 no. steps = 423 order = 5 stepsize = 5.96e+02 -c1 (bot.left/middle/top rt.) = -4.209e-15 -1.602e-13 1.053e-15 +t = 7.20e+04 no. steps = 424 order = 5 stepsize = 5.75e+02 +c1 (bot.left/middle/top rt.) = 1.532e-16 5.896e-15 -3.955e-17 c2 (bot.left/middle/top rt.) = 3.330e+11 6.186e+11 4.039e+11 -t = 7.92e+04 no. steps = 435 order = 5 stepsize = 5.96e+02 -c1 (bot.left/middle/top rt.) = -3.762e-23 -1.366e-21 1.010e-23 +t = 7.92e+04 no. steps = 436 order = 5 stepsize = 5.75e+02 +c1 (bot.left/middle/top rt.) = 7.713e-25 8.129e-23 -1.539e-25 c2 (bot.left/middle/top rt.) = 3.334e+11 6.669e+11 4.120e+11 -t = 8.64e+04 no. steps = 447 order = 5 stepsize = 5.96e+02 -c1 (bot.left/middle/top rt.) = -9.999e-27 -1.866e-22 -1.581e-27 +t = 8.64e+04 no. steps = 449 order = 5 stepsize = 5.75e+02 +c1 (bot.left/middle/top rt.) = -7.037e-27 -1.020e-22 -9.928e-28 c2 (bot.left/middle/top rt.) = 3.352e+11 9.107e+11 4.163e+11 -Final Statistics.. +Final Statistics.. lenrw = 2696 leniw = 65 lenrwLS = 2202 leniwLS = 41 -nst = 447 -nfe = 569 nfeLS = 964 -nni = 566 nli = 482 +nst = 449 +nfe = 570 nfeLS = 968 +nni = 567 nli = 484 nsetups = 72 netf = 25 -npe = 8 nps = 1453 +npe = 8 nps = 1459 ncfn = 0 ncfl = 0 - --------- + --------- | SPTFQMR | --------- - + 2-species diurnal advection-diffusion problem t = 7.20e+03 no. steps = 218 order = 5 stepsize = 1.44e+02 @@ -214,54 +214,55 @@ t = 1.44e+04 no. steps = 250 order = 5 stepsize = 3.27e+02 c1 (bot.left/middle/top rt.) = 6.659e+06 5.316e+06 7.301e+06 c2 (bot.left/middle/top rt.) = 2.582e+11 2.057e+11 2.833e+11 -t = 2.16e+04 no. steps = 275 order = 5 stepsize = 3.50e+02 +t = 2.16e+04 no. steps = 275 order = 5 stepsize = 3.49e+02 c1 (bot.left/middle/top rt.) = 2.665e+07 1.036e+07 2.931e+07 c2 (bot.left/middle/top rt.) = 2.993e+11 1.028e+11 3.313e+11 -t = 2.88e+04 no. steps = 298 order = 5 stepsize = 2.18e+02 +t = 2.88e+04 no. steps = 330 order = 4 stepsize = 2.14e+02 c1 (bot.left/middle/top rt.) = 8.702e+06 1.292e+07 9.650e+06 c2 (bot.left/middle/top rt.) = 3.380e+11 5.029e+11 3.751e+11 -t = 3.60e+04 no. steps = 326 order = 5 stepsize = 1.31e+02 +t = 3.60e+04 no. steps = 369 order = 4 stepsize = 9.72e+01 c1 (bot.left/middle/top rt.) = 1.404e+04 2.029e+04 1.561e+04 c2 (bot.left/middle/top rt.) = 3.387e+11 4.894e+11 3.765e+11 -t = 4.32e+04 no. steps = 377 order = 4 stepsize = 3.89e+02 -c1 (bot.left/middle/top rt.) = 5.444e-07 -1.657e-06 6.244e-07 +t = 4.32e+04 no. steps = 439 order = 4 stepsize = 1.70e+02 +c1 (bot.left/middle/top rt.) = -3.131e-08 -1.943e-08 -3.934e-08 c2 (bot.left/middle/top rt.) = 3.382e+11 1.355e+11 3.804e+11 -t = 5.04e+04 no. steps = 391 order = 5 stepsize = 6.79e+02 -c1 (bot.left/middle/top rt.) = -1.730e-09 -6.249e-07 -9.039e-10 +t = 5.04e+04 no. steps = 454 order = 4 stepsize = 3.71e+02 +c1 (bot.left/middle/top rt.) = -4.557e-11 1.086e-09 -8.068e-11 c2 (bot.left/middle/top rt.) = 3.358e+11 4.930e+11 3.864e+11 -t = 5.76e+04 no. steps = 403 order = 5 stepsize = 4.21e+02 -c1 (bot.left/middle/top rt.) = 7.982e-10 2.122e-07 -1.172e-09 +t = 5.76e+04 no. steps = 467 order = 5 stepsize = 5.82e+02 +c1 (bot.left/middle/top rt.) = 5.569e-11 -8.256e-09 -4.063e-11 c2 (bot.left/middle/top rt.) = 3.320e+11 9.650e+11 3.909e+11 -t = 6.48e+04 no. steps = 414 order = 5 stepsize = 6.89e+02 -c1 (bot.left/middle/top rt.) = 1.420e-09 3.489e-07 -2.356e-09 +t = 6.48e+04 no. steps = 479 order = 5 stepsize = 8.84e+02 +c1 (bot.left/middle/top rt.) = 2.899e-10 -1.355e-07 5.869e-10 c2 (bot.left/middle/top rt.) = 3.313e+11 8.922e+11 3.963e+11 -t = 7.20e+04 no. steps = 424 order = 5 stepsize = 6.89e+02 -c1 (bot.left/middle/top rt.) = 1.045e-12 2.583e-10 -1.763e-12 +t = 7.20e+04 no. steps = 489 order = 5 stepsize = 6.53e+02 +c1 (bot.left/middle/top rt.) = 9.493e-14 -4.124e-13 4.162e-14 c2 (bot.left/middle/top rt.) = 3.330e+11 6.186e+11 4.039e+11 -t = 7.92e+04 no. steps = 435 order = 5 stepsize = 6.89e+02 -c1 (bot.left/middle/top rt.) = -2.523e-19 5.442e-16 4.663e-19 +t = 7.92e+04 no. steps = 500 order = 5 stepsize = 6.53e+02 +c1 (bot.left/middle/top rt.) = -4.240e-21 7.214e-18 -5.798e-20 c2 (bot.left/middle/top rt.) = 3.334e+11 6.669e+11 4.120e+11 -t = 8.64e+04 no. steps = 445 order = 5 stepsize = 6.89e+02 -c1 (bot.left/middle/top rt.) = -1.673e-20 -1.128e-15 -3.081e-21 -c2 (bot.left/middle/top rt.) = 3.352e+11 9.106e+11 4.163e+11 +t = 8.64e+04 no. steps = 512 order = 5 stepsize = 6.53e+02 +c1 (bot.left/middle/top rt.) = -2.841e-21 -1.757e-17 2.220e-21 +c2 (bot.left/middle/top rt.) = 3.352e+11 9.107e+11 4.163e+11 -Final Statistics.. +Final Statistics.. lenrw = 2696 leniw = 65 lenrwLS = 2602 leniwLS = 43 -nst = 445 -nfe = 558 nfeLS = 1143 -nni = 555 nli = 477 -nsetups = 67 netf = 21 -npe = 8 nps = 1805 +nst = 512 +nfe = 657 nfeLS = 1293 +nni = 654 nli = 557 +nsetups = 90 netf = 29 +npe = 9 nps = 2027 ncfn = 0 ncfl = 0 + diff --git a/examples/cvodes/serial/cvsKrylovDemo_prec.c b/examples/cvodes/serial/cvsKrylovDemo_prec.c index b5c57a6368..0fedabac7a 100644 --- a/examples/cvodes/serial/cvsKrylovDemo_prec.c +++ b/examples/cvodes/serial/cvsKrylovDemo_prec.c @@ -109,16 +109,6 @@ #include /* definition of sunrealtype */ #include /* access to SPGMR SUNLinearSolver */ -/* helpful macros */ - -#ifndef MAX -#define MAX(A, B) ((A) > (B) ? (A) : (B)) -#endif - -#ifndef SQR -#define SQR(A) ((A) * (A)) -#endif - /* Constants */ #define ZERO SUN_RCONST(0.0) @@ -421,8 +411,8 @@ static void InitUserData(WebData wdata) dy = wdata->dy = DY; for (i = 0; i < ns; i++) { - cox[i] = diff[i] / SQR(dx); - coy[i] = diff[i] / SQR(dy); + cox[i] = diff[i] / SUNSQR(dx); + coy[i] = diff[i] / SUNSQR(dy); } /* Set remaining method parameters */ @@ -480,17 +470,17 @@ static void CInit(N_Vector c, WebData wdata) dx = wdata->dx; dy = wdata->dy; - x_factor = SUN_RCONST(4.0) / SQR(AX); - y_factor = SUN_RCONST(4.0) / SQR(AY); + x_factor = SUN_RCONST(4.0) / SUNSQR(AX); + y_factor = SUN_RCONST(4.0) / SUNSQR(AY); for (jy = 0; jy < MY; jy++) { y = jy * dy; - argy = SQR(y_factor * y * (AY - y)); + argy = SUNSQR(y_factor * y * (AY - y)); iyoff = mxns * jy; for (jx = 0; jx < MX; jx++) { x = jx * dx; - argx = SQR(x_factor * x * (AX - x)); + argx = SUNSQR(x_factor * x * (AX - x)); ioff = iyoff + ns * jx; for (i = 1; i <= ns; i++) { @@ -506,16 +496,16 @@ static void PrintIntro(void) printf("\n\nDemonstration program for CVODES - SPGMR linear solver\n\n"); printf("Food web problem with ns species, ns = %d\n", NS); printf("Predator-prey interaction and diffusion on a 2-D square\n\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Matrix parameters: a = %.2Qg e = %.2Qg g = %.2Qg\n", AA, EE, GG); + printf("b parameter = %.2Qg\n", BB); + printf("Diffusion coefficients: Dprey = %.2Qg Dpred = %.2Qg\n", DPREY, DPRED); + printf("Rate parameter alpha = %.2Qg\n\n", ALPHA); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Matrix parameters: a = %.2Lg e = %.2Lg g = %.2Lg\n", AA, EE, GG); printf("b parameter = %.2Lg\n", BB); printf("Diffusion coefficients: Dprey = %.2Lg Dpred = %.2Lg\n", DPREY, DPRED); printf("Rate parameter alpha = %.2Lg\n\n", ALPHA); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Matrix parameters: a = %.2g e = %.2g g = %.2g\n", AA, EE, GG); - printf("b parameter = %.2g\n", BB); - printf("Diffusion coefficients: Dprey = %.2g Dpred = %.2g\n", DPREY, DPRED); - printf("Rate parameter alpha = %.2g\n\n", ALPHA); #else printf("Matrix parameters: a = %.2g e = %.2g g = %.2g\n", AA, EE, GG); printf("b parameter = %.2g\n", BB); @@ -524,10 +514,10 @@ static void PrintIntro(void) #endif printf("Mesh dimensions (mx,my) are %d, %d. ", MX, MY); printf("Total system size is neq = %d \n\n", NEQ); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerances: reltol = %.2Qg, abstol = %.2Qg \n\n", RTOL, ATOL); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerances: reltol = %.2Lg, abstol = %.2Lg \n\n", RTOL, ATOL); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerances: reltol = %.2g, abstol = %.2g \n\n", RTOL, ATOL); #else printf("Tolerances: reltol = %.2g, abstol = %.2g \n\n", RTOL, ATOL); #endif @@ -572,10 +562,10 @@ static void PrintAllSpecies(N_Vector c, int ns, int mxns, sunrealtype t) sunrealtype* cdata; cdata = N_VGetArrayPointer(c); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("c values at t = %Qg:\n\n", t); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("c values at t = %Lg:\n\n", t); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("c values at t = %g:\n\n", t); #else printf("c values at t = %g:\n\n", t); #endif @@ -586,10 +576,10 @@ static void PrintAllSpecies(N_Vector c, int ns, int mxns, sunrealtype t) { for (jx = 0; jx < MX; jx++) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%-10.6Qg", cdata[(i - 1) + jx * ns + jy * mxns]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%-10.6Lg", cdata[(i - 1) + jx * ns + jy * mxns]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%-10.6g", cdata[(i - 1) + jx * ns + jy * mxns]); #else printf("%-10.6g", cdata[(i - 1) + jx * ns + jy * mxns]); #endif @@ -617,12 +607,12 @@ static void PrintOutput(void* cvode_mem, sunrealtype t) retval = CVodeGetLastStep(cvode_mem, &hu); check_retval(&retval, "CVodeGetLastStep", 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("t = %10.2Qe nst = %ld nfe = %ld nni = %ld", t, nst, nfe, nni); + printf(" qu = %d hu = %11.2Qe\n\n", qu, hu); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("t = %10.2Le nst = %ld nfe = %ld nni = %ld", t, nst, nfe, nni); printf(" qu = %d hu = %11.2Le\n\n", qu, hu); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("t = %10.2e nst = %ld nfe = %ld nni = %ld", t, nst, nfe, nni); - printf(" qu = %d hu = %11.2e\n\n", qu, hu); #else printf("t = %10.2e nst = %ld nfe = %ld nni = %ld", t, nst, nfe, nni); printf(" qu = %d hu = %11.2e\n\n", qu, hu); @@ -684,7 +674,9 @@ static void PrintFinalStats(void* cvode_mem) printf(" Number of nonlinear conv. failures = %4ld \n", ncfn); printf(" Number of linear convergence failures = %4ld \n", ncfl); avdim = (nni > 0) ? ((sunrealtype)nli) / ((sunrealtype)nni) : ZERO; -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" Average Krylov subspace dimension = %.3Qf \n", avdim); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" Average Krylov subspace dimension = %.3Lf \n", avdim); #else printf(" Average Krylov subspace dimension = %.3f \n", avdim); @@ -869,7 +861,7 @@ static int Precond(sunrealtype t, N_Vector c, N_Vector fc, sunbooleantype jok, /* Generate the jth column as a difference quotient */ jj = if0 + j; save = cdata[jj]; - r = MAX(srur * SUNRabs(save), r0 / rewtdata[jj]); + r = SUNMAX(srur * SUNRabs(save), r0 / rewtdata[jj]); cdata[jj] += r; fac = -gamma / r; fblock(t, cdata, jx, jy, f1, wdata); diff --git a/examples/cvodes/serial/cvsLotkaVolterra_ASA.c b/examples/cvodes/serial/cvsLotkaVolterra_ASA.c index dae3e6bc6e..2675891a3e 100644 --- a/examples/cvodes/serial/cvsLotkaVolterra_ASA.c +++ b/examples/cvodes/serial/cvsLotkaVolterra_ASA.c @@ -53,7 +53,9 @@ #endif #define STEPS 5 /* checkpoint interval */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #else #define GSYM "g" @@ -95,7 +97,7 @@ int main(int argc, char* argv[]) if (check_retval((void*)u, "N_VNew_Serial", 0)) { return 1; } /* Initialize the solution vector */ - N_VConst(1.0, u); + N_VConst(SUN_RCONST(1.0), u); /* Set the tolerances */ reltol = RTOL; diff --git a/examples/cvodes/serial/cvsParticle_dns.c b/examples/cvodes/serial/cvsParticle_dns.c index 9a72c688c8..e5a367c9d5 100644 --- a/examples/cvodes/serial/cvsParticle_dns.c +++ b/examples/cvodes/serial/cvsParticle_dns.c @@ -46,7 +46,10 @@ #include /* access to dense SUNMatrix */ /* Precision specific formatting macros */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#define ESYM "Qe" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #define ESYM "Le" #else @@ -54,21 +57,6 @@ #define ESYM "e" #endif -/* Precision specific math function macros */ -#if defined(SUNDIALS_DOUBLE_PRECISION) -#define SIN(x) (sin((x))) -#define COS(x) (cos((x))) -#define SQRT(x) (sqrt((x))) -#elif defined(SUNDIALS_SINGLE_PRECISION) -#define SIN(x) (sinf((x))) -#define COS(x) (cosf((x))) -#define SQRT(x) (sqrtf((x))) -#elif defined(SUNDIALS_EXTENDED_PRECISION) -#define SIN(x) (sinl((x))) -#define COS(x) (cosl((x))) -#define SQRT(x) (sqrtl((x))) -#endif - /* Problem Constants */ #define PI SUN_RCONST(3.141592653589793238462643383279502884197169) #define ZERO SUN_RCONST(0.0) @@ -343,7 +331,7 @@ static int Proj(sunrealtype t, N_Vector ycur, N_Vector corr, sunrealtype errxp, erryp; /* project onto the unit circle */ - r = SQRT(x * x + y * y); + r = SUNRsqrt(x * x + y * y); xp = x / r; yp = y / r; @@ -493,8 +481,8 @@ static int ComputeSolution(sunrealtype t, N_Vector y, UserData udata) { sunrealtype* ydata = N_VGetArrayPointer(y); - ydata[0] = COS((udata->alpha) * t); - ydata[1] = SIN((udata->alpha) * t); + ydata[0] = SUNRcos((udata->alpha) * t); + ydata[1] = SUNRsin((udata->alpha) * t); return (0); } diff --git a/examples/cvodes/serial/cvsPendulum_dns.c b/examples/cvodes/serial/cvsPendulum_dns.c index 32ef26314b..2fc6f26e9d 100644 --- a/examples/cvodes/serial/cvsPendulum_dns.c +++ b/examples/cvodes/serial/cvsPendulum_dns.c @@ -69,30 +69,14 @@ #include /* access to dense SUNmatrix */ /* Precision specific formatting macros */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define ESYM "Qe" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define ESYM "Le" #else #define ESYM "e" #endif -/* Precision specific math function macros */ -#if defined(SUNDIALS_DOUBLE_PRECISION) -#define SIN(x) (sin((x))) -#define COS(x) (cos((x))) -#define SQRT(x) (sqrt((x))) -#define ABS(x) (fabs((x))) -#elif defined(SUNDIALS_SINGLE_PRECISION) -#define SIN(x) (sinf((x))) -#define COS(x) (cosf((x))) -#define SQRT(x) (sqrtf((x))) -#define ABS(x) (fabsf((x))) -#elif defined(SUNDIALS_EXTENDED_PRECISION) -#define SIN(x) (sinl((x))) -#define COS(x) (cosl((x))) -#define SQRT(x) (sqrtl((x))) -#define ABS(x) (fabsl((x))) -#endif - /* Problem Constants */ #define ZERO SUN_RCONST(0.0) #define ONE SUN_RCONST(1.0) @@ -361,7 +345,7 @@ int GetSol(void* cvode_mem, N_Vector yy0, sunrealtype rtol, sunrealtype atol, /* Compute the constraint violation */ x = yydata[0]; y = yydata[1]; - g = ABS(x * x + y * y - ONE); + g = SUNRabs(x * x + y * y - ONE); /* Compute the absolute error compared to the reference solution */ N_VLinearSum(ONE, yy, -ONE, yref, yy); @@ -480,7 +464,7 @@ int RefSol(sunrealtype tf, N_Vector yref, int nout) fprintf(FID, "%24.16" ESYM " %24.16" ESYM " %24.16" ESYM " %24.16" ESYM " %24.16" ESYM "\n", - ZERO, COS(th), SIN(th), -thd * SIN(th), thd * COS(th)); + ZERO, SUNRcos(th), SUNRsin(th), -thd * SUNRsin(th), thd * SUNRcos(th)); /* Integrate to tf and periodically output the solution */ dtout = tf / nout; @@ -518,7 +502,7 @@ int RefSol(sunrealtype tf, N_Vector yref, int nout) fprintf(FID, "%24.16" ESYM " %24.16" ESYM " %24.16" ESYM " %24.16" ESYM " %24.16" ESYM "\n", - t, COS(th), SIN(th), -thd * SIN(th), thd * COS(th)); + t, SUNRcos(th), SUNRsin(th), -thd * SUNRsin(th), thd * SUNRcos(th)); /* Update output time */ if (out < nout - 1) { tout += dtout; } @@ -535,10 +519,10 @@ int RefSol(sunrealtype tf, N_Vector yref, int nout) /* Convert to Cartesian reference solution */ yydata = N_VGetArrayPointer(yref); - yydata[0] = COS(th); - yydata[1] = SIN(th); - yydata[2] = -thd * SIN(th); - yydata[3] = thd * COS(th); + yydata[0] = SUNRcos(th); + yydata[1] = SUNRsin(th); + yydata[2] = -thd * SUNRsin(th); + yydata[3] = thd * SUNRcos(th); /* Free memory */ N_VDestroy_Serial(yy); @@ -563,8 +547,8 @@ static int fref(sunrealtype t, N_Vector yy, N_Vector fy, void* f_data) yydata = N_VGetArrayPointer(yy); fydata = N_VGetArrayPointer(fy); - fydata[0] = yydata[1]; /* theta' */ - fydata[1] = -GRAV * COS(yydata[0]); /* -g * cos(theta) */ + fydata[0] = yydata[1]; /* theta' */ + fydata[1] = -GRAV * SUNRcos(yydata[0]); /* -g * cos(theta) */ return (0); } @@ -629,7 +613,7 @@ static int proj(sunrealtype t, N_Vector yy, N_Vector corr, sunrealtype epsProj, /* Project positions */ - R = SQRT(x * x + y * y); + R = SUNRsqrt(x * x + y * y); x_new = x / R; y_new = y / R; diff --git a/examples/cvodes/serial/cvsRoberts_ASAi_dns.c b/examples/cvodes/serial/cvsRoberts_ASAi_dns.c index aeab818da4..b54434f053 100644 --- a/examples/cvodes/serial/cvsRoberts_ASAi_dns.c +++ b/examples/cvodes/serial/cvsRoberts_ASAi_dns.c @@ -289,10 +289,10 @@ int main(int argc, char* argv[]) if (check_retval(&retval, "CVodeGetQuad", 1)) { return (1); } printf("--------------------------------------------------------\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("G: %12.4Qe \n", Ith(q, 1)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("G: %12.4Le \n", Ith(q, 1)); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("G: %12.4e \n", Ith(q, 1)); #else printf("G: %12.4e \n", Ith(q, 1)); #endif @@ -702,7 +702,7 @@ static int JacB(sunrealtype t, N_Vector y, N_Vector yB, N_Vector fyB, IJth(JB, 1, 2) = -p1; IJth(JB, 1, 3) = ZERO; IJth(JB, 2, 1) = -p2 * y3; - IJth(JB, 2, 2) = p2 * y3 + 2.0 * p3 * y2; + IJth(JB, 2, 2) = p2 * y3 + SUN_RCONST(2.0) * p3 * y2; IJth(JB, 2, 3) = SUN_RCONST(-2.0) * p3 * y2; IJth(JB, 3, 1) = -p2 * y2; IJth(JB, 3, 2) = p2 * y2; @@ -756,10 +756,10 @@ static int fQB(sunrealtype t, N_Vector y, N_Vector yB, N_Vector qBdot, static void PrintHead(sunrealtype tB0) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Backward integration from tB0 = %12.4Qe\n\n", tB0); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Backward integration from tB0 = %12.4Le\n\n", tB0); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Backward integration from tB0 = %12.4e\n\n", tB0); #else printf("Backward integration from tB0 = %12.4e\n\n", tB0); #endif @@ -772,25 +772,26 @@ static void PrintHead(sunrealtype tB0) static void PrintOutput1(sunrealtype time, sunrealtype t, N_Vector y, N_Vector yB) { printf("--------------------------------------------------------\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("returned t: %12.4Qe\n", time); + printf("tout: %12.4Qe\n", t); + printf("lambda(t): %12.4Qe %12.4Qe %12.4Qe\n", Ith(yB, 1), Ith(yB, 2), + Ith(yB, 3)); + printf("y(t): %12.4Qe %12.4Qe %12.4Qe\n", Ith(y, 1), Ith(y, 2), + Ith(y, 3)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("returned t: %12.4Le\n", time); printf("tout: %12.4Le\n", t); printf("lambda(t): %12.4Le %12.4Le %12.4Le\n", Ith(yB, 1), Ith(yB, 2), Ith(yB, 3)); printf("y(t): %12.4Le %12.4Le %12.4Le\n", Ith(y, 1), Ith(y, 2), Ith(y, 3)); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("returned t: %12.4e\n", time); - printf("tout: %12.4e\n", t); - printf("lambda(t): %12.4e %12.4e %12.4e\n", Ith(yB, 1), Ith(yB, 2), - Ith(yB, 3)); - printf("y(t): %12.4e %12.4e %12.4e\n", Ith(y, 1), Ith(y, 2), Ith(y, 3)); #else printf("returned t: %12.4e\n", time); printf("tout: %12.4e\n", t); printf("lambda(t): %12.4e %12.4e %12.4e\n", Ith(yB, 1), Ith(yB, 2), Ith(yB, 3)); - printf("y(t) : %12.4e %12.4e %12.4e\n", Ith(y, 1), Ith(y, 2), Ith(y, 3)); + printf("y(t): %12.4e %12.4e %12.4e\n", Ith(y, 1), Ith(y, 2), Ith(y, 3)); #endif printf("--------------------------------------------------------\n"); } @@ -802,7 +803,15 @@ static void PrintOutput1(sunrealtype time, sunrealtype t, N_Vector y, N_Vector y static void PrintOutput(sunrealtype tfinal, N_Vector y, N_Vector yB, N_Vector qB) { printf("--------------------------------------------------------\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("returned t: %12.4Qe\n", tfinal); + printf("lambda(t0): %12.4Qe %12.4Qe %12.4Qe\n", Ith(yB, 1), Ith(yB, 2), + Ith(yB, 3)); + printf("y(t0): %12.4Qe %12.4Qe %12.4Qe\n", Ith(y, 1), Ith(y, 2), + Ith(y, 3)); + printf("dG/dp: %12.4Qe %12.4Qe %12.4Qe\n", -Ith(qB, 1), -Ith(qB, 2), + -Ith(qB, 3)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("returned t: %12.4Le\n", tfinal); printf("lambda(t0): %12.4Le %12.4Le %12.4Le\n", Ith(yB, 1), Ith(yB, 2), Ith(yB, 3)); @@ -810,18 +819,11 @@ static void PrintOutput(sunrealtype tfinal, N_Vector y, N_Vector yB, N_Vector qB Ith(y, 3)); printf("dG/dp: %12.4Le %12.4Le %12.4Le\n", -Ith(qB, 1), -Ith(qB, 2), -Ith(qB, 3)); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("returned t: %12.4e\n", tfinal); - printf("lambda(t0): %12.4e %12.4e %12.4e\n", Ith(yB, 1), Ith(yB, 2), - Ith(yB, 3)); - printf("y(t0): %12.4e %12.4e %12.4e\n", Ith(y, 1), Ith(y, 2), Ith(y, 3)); - printf("dG/dp: %12.4e %12.4e %12.4e\n", -Ith(qB, 1), -Ith(qB, 2), - -Ith(qB, 3)); #else printf("returned t: %12.4e\n", tfinal); printf("lambda(t0): %12.4e %12.4e %12.4e\n", Ith(yB, 1), Ith(yB, 2), Ith(yB, 3)); - printf("y(t0) : %12.4e %12.4e %12.4e\n", Ith(y, 1), Ith(y, 2), Ith(y, 3)); + printf("y(t0): %12.4e %12.4e %12.4e\n", Ith(y, 1), Ith(y, 2), Ith(y, 3)); printf("dG/dp: %12.4e %12.4e %12.4e\n", -Ith(qB, 1), -Ith(qB, 2), -Ith(qB, 3)); #endif diff --git a/examples/cvodes/serial/cvsRoberts_ASAi_dns_constraints.c b/examples/cvodes/serial/cvsRoberts_ASAi_dns_constraints.c index f262ca14b5..5ddd3944a1 100644 --- a/examples/cvodes/serial/cvsRoberts_ASAi_dns_constraints.c +++ b/examples/cvodes/serial/cvsRoberts_ASAi_dns_constraints.c @@ -303,10 +303,10 @@ int main(int argc, char* argv[]) if (check_retval(&retval, "CVodeGetQuad", 1)) { return (1); } printf("--------------------------------------------------------\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("G: %12.4Qe \n", Ith(q, 1)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("G: %12.4Le \n", Ith(q, 1)); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("G: %12.4e \n", Ith(q, 1)); #else printf("G: %12.4e \n", Ith(q, 1)); #endif @@ -755,10 +755,10 @@ static int fQB(sunrealtype t, N_Vector y, N_Vector yB, N_Vector qBdot, static void PrintHead(sunrealtype tB0) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Backward integration from tB0 = %12.4Qe\n\n", tB0); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Backward integration from tB0 = %12.4Le\n\n", tB0); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Backward integration from tB0 = %12.4e\n\n", tB0); #else printf("Backward integration from tB0 = %12.4e\n\n", tB0); #endif @@ -771,25 +771,26 @@ static void PrintHead(sunrealtype tB0) static void PrintOutput1(sunrealtype time, sunrealtype t, N_Vector y, N_Vector yB) { printf("--------------------------------------------------------\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("returned t: %12.4Qe\n", time); + printf("tout: %12.4Qe\n", t); + printf("lambda(t): %12.4Qe %12.4Qe %12.4Qe\n", Ith(yB, 1), Ith(yB, 2), + Ith(yB, 3)); + printf("y(t): %12.4Qe %12.4Qe %12.4Qe\n", Ith(y, 1), Ith(y, 2), + Ith(y, 3)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("returned t: %12.4Le\n", time); printf("tout: %12.4Le\n", t); printf("lambda(t): %12.4Le %12.4Le %12.4Le\n", Ith(yB, 1), Ith(yB, 2), Ith(yB, 3)); printf("y(t): %12.4Le %12.4Le %12.4Le\n", Ith(y, 1), Ith(y, 2), Ith(y, 3)); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("returned t: %12.4e\n", time); - printf("tout: %12.4e\n", t); - printf("lambda(t): %12.4e %12.4e %12.4e\n", Ith(yB, 1), Ith(yB, 2), - Ith(yB, 3)); - printf("y(t): %12.4e %12.4e %12.4e\n", Ith(y, 1), Ith(y, 2), Ith(y, 3)); #else printf("returned t: %12.4e\n", time); printf("tout: %12.4e\n", t); printf("lambda(t): %12.4e %12.4e %12.4e\n", Ith(yB, 1), Ith(yB, 2), Ith(yB, 3)); - printf("y(t) : %12.4e %12.4e %12.4e\n", Ith(y, 1), Ith(y, 2), Ith(y, 3)); + printf("y(t): %12.4e %12.4e %12.4e\n", Ith(y, 1), Ith(y, 2), Ith(y, 3)); #endif printf("--------------------------------------------------------\n\n"); } @@ -801,7 +802,15 @@ static void PrintOutput1(sunrealtype time, sunrealtype t, N_Vector y, N_Vector y static void PrintOutput(sunrealtype tfinal, N_Vector y, N_Vector yB, N_Vector qB) { printf("--------------------------------------------------------\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("returned t: %12.4Qe\n", tfinal); + printf("lambda(t0): %12.4Qe %12.4Qe %12.4Qe\n", Ith(yB, 1), Ith(yB, 2), + Ith(yB, 3)); + printf("y(t0): %12.4Qe %12.4Qe %12.4Qe\n", Ith(y, 1), Ith(y, 2), + Ith(y, 3)); + printf("dG/dp: %12.4Qe %12.4Qe %12.4Qe\n", -Ith(qB, 1), -Ith(qB, 2), + -Ith(qB, 3)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("returned t: %12.4Le\n", tfinal); printf("lambda(t0): %12.4Le %12.4Le %12.4Le\n", Ith(yB, 1), Ith(yB, 2), Ith(yB, 3)); @@ -809,18 +818,11 @@ static void PrintOutput(sunrealtype tfinal, N_Vector y, N_Vector yB, N_Vector qB Ith(y, 3)); printf("dG/dp: %12.4Le %12.4Le %12.4Le\n", -Ith(qB, 1), -Ith(qB, 2), -Ith(qB, 3)); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("returned t: %12.4e\n", tfinal); - printf("lambda(t0): %12.4e %12.4e %12.4e\n", Ith(yB, 1), Ith(yB, 2), - Ith(yB, 3)); - printf("y(t0): %12.4e %12.4e %12.4e\n", Ith(y, 1), Ith(y, 2), Ith(y, 3)); - printf("dG/dp: %12.4e %12.4e %12.4e\n", -Ith(qB, 1), -Ith(qB, 2), - -Ith(qB, 3)); #else printf("returned t: %12.4e\n", tfinal); printf("lambda(t0): %12.4e %12.4e %12.4e\n", Ith(yB, 1), Ith(yB, 2), Ith(yB, 3)); - printf("y(t0) : %12.4e %12.4e %12.4e\n", Ith(y, 1), Ith(y, 2), Ith(y, 3)); + printf("y(t0): %12.4e %12.4e %12.4e\n", Ith(y, 1), Ith(y, 2), Ith(y, 3)); printf("dG/dp: %12.4e %12.4e %12.4e\n", -Ith(qB, 1), -Ith(qB, 2), -Ith(qB, 3)); #endif diff --git a/examples/cvodes/serial/cvsRoberts_FSA_dns.c b/examples/cvodes/serial/cvsRoberts_FSA_dns.c index 9e215ca8be..adc6ac47a8 100644 --- a/examples/cvodes/serial/cvsRoberts_FSA_dns.c +++ b/examples/cvodes/serial/cvsRoberts_FSA_dns.c @@ -81,16 +81,6 @@ #define IJth(A, i, j) \ SM_ELEMENT_D(A, i - 1, j - 1) /* (i,j)-th matrix component i,j=1..NEQ */ -/* Precision specific math function macros */ - -#if defined(SUNDIALS_DOUBLE_PRECISION) -#define ABS(x) (fabs((x))) -#elif defined(SUNDIALS_SINGLE_PRECISION) -#define ABS(x) (fabsf((x))) -#elif defined(SUNDIALS_EXTENDED_PRECISION) -#define ABS(x) (fabsl((x))) -#endif - /* Problem Constants */ #define NEQ 3 /* number of equations */ @@ -401,9 +391,9 @@ static int Jac(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, IJth(J, 1, 2) = p2 * y3; IJth(J, 1, 3) = p2 * y2; IJth(J, 2, 1) = p1; - IJth(J, 2, 2) = -p2 * y3 - 2 * p3 * y2; + IJth(J, 2, 2) = -p2 * y3 - SUN_RCONST(2.0) * p3 * y2; IJth(J, 2, 3) = -p2 * y2; - IJth(J, 3, 2) = 2 * p3 * y2; + IJth(J, 3, 2) = SUN_RCONST(2.0) * p3 * y2; return (0); } @@ -435,7 +425,7 @@ static int fS(int Ns, sunrealtype t, N_Vector y, N_Vector ydot, int iS, s3 = Ith(yS, 3); sd1 = -p1 * s1 + p2 * y3 * s2 + p2 * y2 * s3; - sd3 = 2 * p3 * y2 * s2; + sd3 = SUN_RCONST(2.0) * p3 * y2 * s2; sd2 = -sd1 - sd3; switch (iS) @@ -478,7 +468,7 @@ static int ewt(N_Vector y, N_Vector w, void* user_data) for (i = 1; i <= 3; i++) { yy = Ith(y, i); - ww = rtol * ABS(yy) + atol[i - 1]; + ww = rtol * SUNRabs(yy) + atol[i - 1]; if (ww <= 0.0) { return (-1); } Ith(w, i) = 1.0 / ww; } @@ -552,20 +542,20 @@ static void PrintOutput(void* cvode_mem, sunrealtype t, N_Vector u) retval = CVodeGetLastStep(cvode_mem, &hu); check_retval(&retval, "CVodeGetLastStep", 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%8.3Qe %2d %8.3Qe %5ld\n", t, qu, hu, nst); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%8.3Le %2d %8.3Le %5ld\n", t, qu, hu, nst); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%8.3e %2d %8.3e %5ld\n", t, qu, hu, nst); #else printf("%8.3e %2d %8.3e %5ld\n", t, qu, hu, nst); #endif printf(" Solution "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe %12.4Qe \n", udata[0], udata[1], udata[2]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le %12.4Le %12.4Le \n", udata[0], udata[1], udata[2]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e %12.4e \n", udata[0], udata[1], udata[2]); #else printf("%12.4e %12.4e %12.4e \n", udata[0], udata[1], udata[2]); #endif @@ -582,10 +572,10 @@ static void PrintOutputS(N_Vector* uS) sdata = N_VGetArrayPointer(uS[0]); printf(" Sensitivity 1 "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe %12.4Qe \n", sdata[0], sdata[1], sdata[2]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #else printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #endif @@ -593,10 +583,10 @@ static void PrintOutputS(N_Vector* uS) sdata = N_VGetArrayPointer(uS[1]); printf(" Sensitivity 2 "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe %12.4Qe \n", sdata[0], sdata[1], sdata[2]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #else printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #endif @@ -604,10 +594,10 @@ static void PrintOutputS(N_Vector* uS) sdata = N_VGetArrayPointer(uS[2]); printf(" Sensitivity 3 "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe %12.4Qe \n", sdata[0], sdata[1], sdata[2]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #else printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #endif diff --git a/examples/cvodes/serial/cvsRoberts_FSA_dns_Switch.c b/examples/cvodes/serial/cvsRoberts_FSA_dns_Switch.c index 224d410832..d17a4d008e 100644 --- a/examples/cvodes/serial/cvsRoberts_FSA_dns_Switch.c +++ b/examples/cvodes/serial/cvsRoberts_FSA_dns_Switch.c @@ -36,7 +36,9 @@ #include /* access to dense SUNLinearSolver */ #include /* access to dense SUNMatrix */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define ESYM "Qe" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define ESYM "Le" #else #define ESYM "e" diff --git a/examples/cvodes/serial/cvsRoberts_FSA_dns_constraints.c b/examples/cvodes/serial/cvsRoberts_FSA_dns_constraints.c index 12dbc1db57..3cd6f6d491 100644 --- a/examples/cvodes/serial/cvsRoberts_FSA_dns_constraints.c +++ b/examples/cvodes/serial/cvsRoberts_FSA_dns_constraints.c @@ -543,20 +543,20 @@ static void PrintOutput(void* cvode_mem, sunrealtype t, N_Vector u) retval = CVodeGetLastStep(cvode_mem, &hu); check_retval(&retval, "CVodeGetLastStep", 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%8.3Qe %2d %8.3Qe %5ld\n", t, qu, hu, nst); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%8.3Le %2d %8.3Le %5ld\n", t, qu, hu, nst); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%8.3e %2d %8.3e %5ld\n", t, qu, hu, nst); #else printf("%8.3e %2d %8.3e %5ld\n", t, qu, hu, nst); #endif printf(" Solution "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe %12.4Qe \n", udata[0], udata[1], udata[2]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le %12.4Le %12.4Le \n", udata[0], udata[1], udata[2]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e %12.4e \n", udata[0], udata[1], udata[2]); #else printf("%12.4e %12.4e %12.4e \n", udata[0], udata[1], udata[2]); #endif @@ -573,10 +573,10 @@ static void PrintOutputS(N_Vector* uS) sdata = N_VGetArrayPointer(uS[0]); printf(" Sensitivity 1 "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe %12.4Qe \n", sdata[0], sdata[1], sdata[2]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #else printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #endif @@ -584,10 +584,10 @@ static void PrintOutputS(N_Vector* uS) sdata = N_VGetArrayPointer(uS[1]); printf(" Sensitivity 2 "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe %12.4Qe \n", sdata[0], sdata[1], sdata[2]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #else printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #endif @@ -595,10 +595,10 @@ static void PrintOutputS(N_Vector* uS) sdata = N_VGetArrayPointer(uS[2]); printf(" Sensitivity 3 "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe %12.4Qe \n", sdata[0], sdata[1], sdata[2]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #else printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #endif diff --git a/examples/cvodes/serial/cvsRoberts_FSA_sps.c b/examples/cvodes/serial/cvsRoberts_FSA_sps.c index 0f1670eed0..a587ef3502 100644 --- a/examples/cvodes/serial/cvsRoberts_FSA_sps.c +++ b/examples/cvodes/serial/cvsRoberts_FSA_sps.c @@ -549,20 +549,20 @@ static void PrintOutput(void* cvode_mem, sunrealtype t, N_Vector u) retval = CVodeGetLastStep(cvode_mem, &hu); check_retval(&retval, "CVodeGetLastStep", 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%8.3Qe %2d %8.3Qe %5ld\n", t, qu, hu, nst); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%8.3Le %2d %8.3Le %5ld\n", t, qu, hu, nst); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%8.3e %2d %8.3e %5ld\n", t, qu, hu, nst); #else printf("%8.3e %2d %8.3e %5ld\n", t, qu, hu, nst); #endif printf(" Solution "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe %12.4Qe \n", udata[0], udata[1], udata[2]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le %12.4Le %12.4Le \n", udata[0], udata[1], udata[2]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e %12.4e \n", udata[0], udata[1], udata[2]); #else printf("%12.4e %12.4e %12.4e \n", udata[0], udata[1], udata[2]); #endif @@ -579,10 +579,10 @@ static void PrintOutputS(N_Vector* uS) sdata = N_VGetArrayPointer(uS[0]); printf(" Sensitivity 1 "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe %12.4Qe \n", sdata[0], sdata[1], sdata[2]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #else printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #endif @@ -590,10 +590,10 @@ static void PrintOutputS(N_Vector* uS) sdata = N_VGetArrayPointer(uS[1]); printf(" Sensitivity 2 "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe %12.4Qe \n", sdata[0], sdata[1], sdata[2]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #else printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #endif @@ -601,10 +601,10 @@ static void PrintOutputS(N_Vector* uS) sdata = N_VGetArrayPointer(uS[2]); printf(" Sensitivity 3 "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe %12.4Qe \n", sdata[0], sdata[1], sdata[2]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #else printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #endif diff --git a/examples/cvodes/serial/cvsRoberts_dns.c b/examples/cvodes/serial/cvsRoberts_dns.c index 629a564b72..ca56000d69 100644 --- a/examples/cvodes/serial/cvsRoberts_dns.c +++ b/examples/cvodes/serial/cvsRoberts_dns.c @@ -42,7 +42,9 @@ #include /* access to dense SUNLinearSolver */ #include /* access to dense SUNMatrix */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #else #define GSYM "g" @@ -319,10 +321,10 @@ static int Jac(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, static void PrintOutput(sunrealtype t, sunrealtype y1, sunrealtype y2, sunrealtype y3) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("At t = %0.4Qe y =%14.6Qe %14.6Qe %14.6Qe\n", t, y1, y2, y3); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("At t = %0.4Le y =%14.6Le %14.6Le %14.6Le\n", t, y1, y2, y3); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("At t = %0.4e y =%14.6e %14.6e %14.6e\n", t, y1, y2, y3); #else printf("At t = %0.4e y =%14.6e %14.6e %14.6e\n", t, y1, y2, y3); #endif diff --git a/examples/cvodes/serial/cvsRoberts_dnsL.c b/examples/cvodes/serial/cvsRoberts_dnsL.c index 8af63ff5a1..8cf18ca136 100644 --- a/examples/cvodes/serial/cvsRoberts_dnsL.c +++ b/examples/cvodes/serial/cvsRoberts_dnsL.c @@ -301,10 +301,10 @@ static int Jac(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, static void PrintOutput(sunrealtype t, sunrealtype y1, sunrealtype y2, sunrealtype y3) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("At t = %0.4Qe y =%14.6Qe %14.6Qe %14.6Qe\n", t, y1, y2, y3); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("At t = %0.4Le y =%14.6Le %14.6Le %14.6Le\n", t, y1, y2, y3); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("At t = %0.4e y =%14.6e %14.6e %14.6e\n", t, y1, y2, y3); #else printf("At t = %0.4e y =%14.6e %14.6e %14.6e\n", t, y1, y2, y3); #endif diff --git a/examples/cvodes/serial/cvsRoberts_dns_constraints.c b/examples/cvodes/serial/cvsRoberts_dns_constraints.c index 81ab8bd547..ce6b2cf0b2 100644 --- a/examples/cvodes/serial/cvsRoberts_dns_constraints.c +++ b/examples/cvodes/serial/cvsRoberts_dns_constraints.c @@ -44,7 +44,9 @@ #include /* access to dense SUNLinearSolver */ #include /* access to dense SUNMatrix */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #else #define GSYM "g" @@ -331,10 +333,10 @@ static int Jac(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, static void PrintOutput(sunrealtype t, sunrealtype y1, sunrealtype y2, sunrealtype y3) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("At t = %0.4Qe y =%14.6Qe %14.6Qe %14.6Qe\n", t, y1, y2, y3); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("At t = %0.4Le y =%14.6Le %14.6Le %14.6Le\n", t, y1, y2, y3); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("At t = %0.4e y =%14.6e %14.6e %14.6e\n", t, y1, y2, y3); #else printf("At t = %0.4e y =%14.6e %14.6e %14.6e\n", t, y1, y2, y3); #endif diff --git a/examples/cvodes/serial/cvsRoberts_dns_uw.c b/examples/cvodes/serial/cvsRoberts_dns_uw.c index 059225ec94..ee72c05757 100644 --- a/examples/cvodes/serial/cvsRoberts_dns_uw.c +++ b/examples/cvodes/serial/cvsRoberts_dns_uw.c @@ -63,16 +63,6 @@ #define IJth(A, i, j) \ SM_ELEMENT_D(A, i - 1, j - 1) /* (i,j)-th matrix component i,j=1..NEQ */ -/* Precision specific math function macros */ - -#if defined(SUNDIALS_DOUBLE_PRECISION) -#define ABS(x) (fabs((x))) -#elif defined(SUNDIALS_SINGLE_PRECISION) -#define ABS(x) (fabsf((x))) -#elif defined(SUNDIALS_EXTENDED_PRECISION) -#define ABS(x) (fabsl((x))) -#endif - /* Problem Constants */ #define NEQ 3 /* number of equations */ @@ -312,7 +302,7 @@ static int ewt(N_Vector y, N_Vector w, void* user_data) for (i = 1; i <= 3; i++) { yy = Ith(y, i); - ww = rtol * ABS(yy) + atol[i - 1]; + ww = rtol * SUNRabs(yy) + atol[i - 1]; if (ww <= 0.0) { return (-1); } Ith(w, i) = 1.0 / ww; } @@ -329,7 +319,9 @@ static int ewt(N_Vector y, N_Vector w, void* user_data) static void PrintOutput(sunrealtype t, sunrealtype y1, sunrealtype y2, sunrealtype y3) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("At t = %0.4Qe y =%14.6Qe %14.6Qe %14.6Qe\n", t, y1, y2, y3); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("At t = %0.4Le y =%14.6Le %14.6Le %14.6Le\n", t, y1, y2, y3); #elif defined(SUNDIALS_DOUBLE_PRECISION) printf("At t = %0.4e y =%14.6e %14.6e %14.6e\n", t, y1, y2, y3); diff --git a/examples/cvodes/serial/cvsRoberts_sps.c b/examples/cvodes/serial/cvsRoberts_sps.c index 6e418f2ed3..4759e5e865 100644 --- a/examples/cvodes/serial/cvsRoberts_sps.c +++ b/examples/cvodes/serial/cvsRoberts_sps.c @@ -322,10 +322,10 @@ static int Jac(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, static void PrintOutput(sunrealtype t, sunrealtype y1, sunrealtype y2, sunrealtype y3) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("At t = %0.4Qe y =%14.6Qe %14.6Qe %14.6Qe\n", t, y1, y2, y3); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("At t = %0.4Le y =%14.6Le %14.6Le %14.6Le\n", t, y1, y2, y3); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("At t = %0.4e y =%14.6e %14.6e %14.6e\n", t, y1, y2, y3); #else printf("At t = %0.4e y =%14.6e %14.6e %14.6e\n", t, y1, y2, y3); #endif diff --git a/examples/ida/C_openmp/idaFoodWeb_bnd_omp.c b/examples/ida/C_openmp/idaFoodWeb_bnd_omp.c index bc64de7358..27b196ac30 100644 --- a/examples/ida/C_openmp/idaFoodWeb_bnd_omp.c +++ b/examples/ida/C_openmp/idaFoodWeb_bnd_omp.c @@ -127,7 +127,7 @@ #define NPREY 1 /* No. of prey (= no. of predators). */ #define NUM_SPECIES 2 * NPREY -#define PI SUN_RCONST(3.1415926535898) +#define PI SUN_RCONST(3.141592653589793238462643383279502884197169) #define FOURPI (SUN_RCONST(4.0) * PI) #define MX 20 /* MX = number of x mesh points */ @@ -529,10 +529,10 @@ static void PrintHeader(sunindextype mu, sunindextype ml, sunrealtype rtol, printf("Number of species ns: %d", NUM_SPECIES); printf(" Mesh dimensions: %d x %d", MX, MY); printf(" System size: %d\n", NEQ); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg\n", rtol, atol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg\n", rtol, atol); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #else printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #endif @@ -567,18 +567,16 @@ static void PrintOutput(void* ida_mem, N_Vector c, sunrealtype t) c_bl = IJ_Vptr(c, 0, 0); c_tr = IJ_Vptr(c, MX - 1, MY - 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%8.2Qe %12.4Qe %12.4Qe | %3ld %1d %12.4Qe\n", t, c_bl[0], c_tr[0], + nst, kused, hused); + for (i = 1; i < NUM_SPECIES; i++) + printf(" %12.4Qe %12.4Qe |\n", c_bl[i], c_tr[i]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%8.2Le %12.4Le %12.4Le | %3ld %1d %12.4Le\n", t, c_bl[0], c_tr[0], nst, kused, hused); for (i = 1; i < NUM_SPECIES; i++) printf(" %12.4Le %12.4Le |\n", c_bl[i], c_tr[i]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%8.2e %12.4e %12.4e | %3ld %1d %12.4e\n", t, c_bl[0], c_tr[0], nst, - kused, hused); - for (i = 1; i < NUM_SPECIES; i++) - { - printf(" %12.4e %12.4e |\n", c_bl[i], c_tr[i]); - } #else printf("%8.2e %12.4e %12.4e | %3ld %1d %12.4e\n", t, c_bl[0], c_tr[0], nst, kused, hused); diff --git a/examples/ida/C_openmp/idaFoodWeb_kry_omp.c b/examples/ida/C_openmp/idaFoodWeb_kry_omp.c index 7f335d4078..3da5c0e2cc 100644 --- a/examples/ida/C_openmp/idaFoodWeb_kry_omp.c +++ b/examples/ida/C_openmp/idaFoodWeb_kry_omp.c @@ -132,7 +132,7 @@ #define NPREY 1 /* No. of prey (= no. of predators). */ #define NUM_SPECIES 2 * NPREY -#define PI SUN_RCONST(3.1415926535898) +#define PI SUN_RCONST(3.141592653589793238462643383279502884197169) #define FOURPI (SUN_RCONST(4.0) * PI) #define MX 20 /* MX = number of x mesh points */ @@ -668,10 +668,10 @@ static void PrintHeader(int maxl, sunrealtype rtol, sunrealtype atol) printf("Number of species ns: %d", NUM_SPECIES); printf(" Mesh dimensions: %d x %d", MX, MY); printf(" System size: %d\n", NEQ); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg\n", rtol, atol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg\n", rtol, atol); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #else printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #endif @@ -704,19 +704,16 @@ static void PrintOutput(void* ida_mem, N_Vector c, sunrealtype t) c_bl = IJ_Vptr(c, 0, 0); c_tr = IJ_Vptr(c, MX - 1, MY - 1); - -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%8.2Qe %12.4Qe %12.4Qe | %3ld %1d %12.4Qe\n", t, c_bl[0], c_tr[0], + nst, kused, hused); + for (i = 1; i < NUM_SPECIES; i++) + printf(" %12.4Qe %12.4Qe |\n", c_bl[i], c_tr[i]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%8.2Le %12.4Le %12.4Le | %3ld %1d %12.4Le\n", t, c_bl[0], c_tr[0], nst, kused, hused); for (i = 1; i < NUM_SPECIES; i++) printf(" %12.4Le %12.4Le |\n", c_bl[i], c_tr[i]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%8.2e %12.4e %12.4e | %3ld %1d %12.4e\n", t, c_bl[0], c_tr[0], nst, - kused, hused); - for (i = 1; i < NUM_SPECIES; i++) - { - printf(" %12.4e %12.4e |\n", c_bl[i], c_tr[i]); - } #else printf("%8.2e %12.4e %12.4e | %3ld %1d %12.4e\n", t, c_bl[0], c_tr[0], nst, kused, hused); diff --git a/examples/ida/cuda/idaHeat2D_kry_cuda.cu b/examples/ida/cuda/idaHeat2D_kry_cuda.cu index a72e740bf9..dc59694a32 100644 --- a/examples/ida/cuda/idaHeat2D_kry_cuda.cu +++ b/examples/ida/cuda/idaHeat2D_kry_cuda.cu @@ -527,7 +527,9 @@ static void PrintHeader(sunrealtype rtol, sunrealtype atol) printf(" polynomial initial conditions.\n"); printf(" Mesh dimensions: %d x %d", MGRID, MGRID); printf(" Total system size: %d\n\n", NEQ); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg\n", rtol, atol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg\n", rtol, atol); #elif defined(SUNDIALS_DOUBLE_PRECISION) printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); @@ -571,7 +573,11 @@ static void PrintOutput(void* mem, sunrealtype t, N_Vector uu) ier = IDAGetNumPrecSolves(mem, &nps); check_flag(&ier, "IDAGetNumPrecSolves", 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" %5.2Qf %13.5Qe %d %3ld %3ld %3ld %4ld %4ld %9.2Qe %3ld " + "%3ld\n", + t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" %5.2Lf %13.5Le %d %3ld %3ld %3ld %4ld %4ld %9.2Le %3ld " "%3ld\n", t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps); diff --git a/examples/ida/mpicuda/idaHeat2D_kry_p_mpicuda.cu b/examples/ida/mpicuda/idaHeat2D_kry_p_mpicuda.cu index b22e4ed7c1..f63002e798 100644 --- a/examples/ida/mpicuda/idaHeat2D_kry_p_mpicuda.cu +++ b/examples/ida/mpicuda/idaHeat2D_kry_p_mpicuda.cu @@ -1181,7 +1181,9 @@ static void PrintHeader(sunrealtype rtol, sunrealtype atol, UserData data) printf(" Total system size: %ld\n\n", (long)data->mx * data->my); printf("Subgrid dimensions: %d x %d", (int)data->mxsub, (int)data->mysub); printf(" Processor array: %d x %d\n", (int)data->npex, (int)data->npey); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg\n", rtol, atol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg\n", rtol, atol); #elif defined(SUNDIALS_DOUBLE_PRECISION) printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); @@ -1237,7 +1239,11 @@ static void PrintOutput(int id, void* ida_mem, sunrealtype t, N_Vector uu) ier = IDAGetNumPrecSolves(ida_mem, &nps); check_flag(&ier, "IDAGetNumPrecSolves", 1, id); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" %5.2Qf %13.5Qe %d %3ld %3ld %3ld %4ld %4ld %9.2Qe %3ld " + "%3ld\n", + t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" %5.2Lf %13.5Le %d %3ld %3ld %3ld %4ld %4ld %9.2Le %3ld " "%3ld\n", t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps); diff --git a/examples/ida/mpiraja/idaHeat2D_kry_p_mpiraja.cpp b/examples/ida/mpiraja/idaHeat2D_kry_p_mpiraja.cpp index 6735517feb..8a110d4c70 100644 --- a/examples/ida/mpiraja/idaHeat2D_kry_p_mpiraja.cpp +++ b/examples/ida/mpiraja/idaHeat2D_kry_p_mpiraja.cpp @@ -1053,7 +1053,9 @@ static void PrintHeader(sunrealtype rtol, sunrealtype atol, UserData data) printf(" Total system size: %ld\n\n", (long)data->mx * data->my); printf("Subgrid dimensions: %d x %d", (int)data->mxsub, (int)data->mysub); printf(" Processor array: %d x %d\n", (int)data->npex, (int)data->npey); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg\n", rtol, atol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg\n", rtol, atol); #elif defined(SUNDIALS_DOUBLE_PRECISION) printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); @@ -1109,7 +1111,11 @@ static void PrintOutput(int id, void* ida_mem, sunrealtype t, N_Vector uu) ier = IDAGetNumPrecSolves(ida_mem, &nps); check_flag(&ier, "IDAGetNumPrecSolves", 1, id); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" %5.2Qf %13.5Qe %d %3ld %3ld %3ld %4ld %4ld %9.2Qe %3ld " + "%3ld\n", + t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" %5.2Lf %13.5Le %d %3ld %3ld %3ld %4ld %4ld %9.2Le %3ld " "%3ld\n", t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps); diff --git a/examples/ida/parallel/idaFoodWeb_kry_bbd_p.c b/examples/ida/parallel/idaFoodWeb_kry_bbd_p.c index 6366cf3731..98e05b3942 100644 --- a/examples/ida/parallel/idaFoodWeb_kry_bbd_p.c +++ b/examples/ida/parallel/idaFoodWeb_kry_bbd_p.c @@ -121,8 +121,8 @@ #define NPREY 1 /* Number of prey (= number of predators). */ #define NUM_SPECIES 2 * NPREY -#define PI SUN_RCONST(3.1415926535898) /* pi */ -#define FOURPI (SUN_RCONST(4.0) * PI) /* 4 pi */ +#define PI SUN_RCONST(3.141592653589793238462643383279502884197169) /* pi */ +#define FOURPI (SUN_RCONST(4.0) * PI) /* 4 pi */ #define MXSUB 10 /* Number of x mesh points per processor subgrid */ #define MYSUB 10 /* Number of y mesh points per processor subgrid */ @@ -580,10 +580,10 @@ static void PrintHeader(sunindextype SystemSize, int maxl, sunindextype mudq, printf(" Total system size: %ld\n", (long int)SystemSize); printf("Subgrid dimensions: %d x %d", MXSUB, MYSUB); printf(" Processor array: %d x %d\n", NPEX, NPEY); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg\n", rtol, atol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg\n", rtol, atol); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #else printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #endif @@ -650,18 +650,16 @@ static void PrintOutput(void* ida_mem, N_Vector cc, sunrealtype tt, retval = IDAGetLastStep(ida_mem, &hused); check_retval(&retval, "IDAGetLastStep", 1, thispe); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%8.2Qe %12.4Qe %12.4Qe | %3ld %1d %12.4Qe\n", tt, cdata[0], + clast[0], nst, kused, hused); + for (i = 1; i < NUM_SPECIES; i++) + printf(" %12.4Qe %12.4Qe |\n", cdata[i], clast[i]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%8.2Le %12.4Le %12.4Le | %3ld %1d %12.4Le\n", tt, cdata[0], clast[0], nst, kused, hused); for (i = 1; i < NUM_SPECIES; i++) printf(" %12.4Le %12.4Le |\n", cdata[i], clast[i]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%8.2e %12.4e %12.4e | %3ld %1d %12.4e\n", tt, cdata[0], clast[0], - nst, kused, hused); - for (i = 1; i < NUM_SPECIES; i++) - { - printf(" %12.4e %12.4e |\n", cdata[i], clast[i]); - } #else printf("%8.2e %12.4e %12.4e | %3ld %1d %12.4e\n", tt, cdata[0], clast[0], nst, kused, hused); @@ -1170,7 +1168,8 @@ static void WebRates(sunrealtype xx, sunrealtype yy, sunrealtype* cxy, ratesxy[is] = dotprod(NUM_SPECIES, cxy, acoef[is]); } - fac = ONE + ALPHA * xx * yy + BETA * sin(FOURPI * xx) * sin(FOURPI * yy); + fac = ONE + ALPHA * xx * yy + + BETA * SUNRsin(FOURPI * xx) * SUNRsin(FOURPI * yy); for (is = 0; is < NUM_SPECIES; is++) { diff --git a/examples/ida/parallel/idaFoodWeb_kry_bbd_p.out b/examples/ida/parallel/idaFoodWeb_kry_bbd_p.out index 9452ed6513..7dcec43988 100644 --- a/examples/ida/parallel/idaFoodWeb_kry_bbd_p.out +++ b/examples/ida/parallel/idaFoodWeb_kry_bbd_p.out @@ -22,25 +22,25 @@ CalcIC called to correct initial predator concentrations 1.00e-02 1.6189e+02 1.9735e+02 | 118 4 1.7533e-04 1.6189e+06 1.9735e+06 | -1.00e-01 2.4019e+02 2.7072e+02 | 175 1 3.0682e-02 +1.00e-01 2.4019e+02 2.7072e+02 | 174 1 3.0667e-02 2.4019e+06 2.7072e+06 | -4.00e-01 2.4019e+02 2.7072e+02 | 178 1 2.4545e-01 +4.00e-01 2.4019e+02 2.7072e+02 | 177 1 2.4533e-01 2.4019e+06 2.7072e+06 | -7.00e-01 2.4019e+02 2.7072e+02 | 179 1 4.9091e-01 +7.00e-01 2.4019e+02 2.7072e+02 | 178 1 4.9067e-01 2.4019e+06 2.7072e+06 | -1.00e+00 2.4019e+02 2.7072e+02 | 179 1 4.9091e-01 +1.00e+00 2.4019e+02 2.7072e+02 | 178 1 4.9067e-01 2.4019e+06 2.7072e+06 | ----------------------------------------------------------- Final statistics: -Number of steps = 179 -Number of residual evaluations = 946 -Number of nonlinear iterations = 222 +Number of steps = 178 +Number of residual evaluations = 950 +Number of nonlinear iterations = 226 Number of error test failures = 0 Number of nonlinear conv. failures = 0 @@ -48,5 +48,5 @@ Number of linear iterations = 722 Number of linear conv. failures = 0 Number of preconditioner setups = 24 -Number of preconditioner solves = 946 +Number of preconditioner solves = 950 Number of local residual evals. = 1008 diff --git a/examples/ida/parallel/idaFoodWeb_kry_p.c b/examples/ida/parallel/idaFoodWeb_kry_p.c index c48bed05a9..ba899b2568 100644 --- a/examples/ida/parallel/idaFoodWeb_kry_p.c +++ b/examples/ida/parallel/idaFoodWeb_kry_p.c @@ -116,19 +116,13 @@ #include #include -/* helpful macros */ - -#ifndef MAX -#define MAX(A, B) ((A) > (B) ? (A) : (B)) -#endif - /* Problem Constants. */ #define NPREY 1 /* Number of prey (= number of predators). */ #define NUM_SPECIES 2 * NPREY -#define PI SUN_RCONST(3.1415926535898) /* pi */ -#define FOURPI (SUN_RCONST(4.0) * PI) /* 4 pi */ +#define PI SUN_RCONST(3.141592653589793238462643383279502884197169) /* pi */ +#define FOURPI (SUN_RCONST(4.0) * PI) /* 4 pi */ #define MXSUB 10 /* Number of x mesh points per processor subgrid */ #define MYSUB 10 /* Number of y mesh points per processor subgrid */ @@ -644,10 +638,10 @@ static void PrintHeader(sunindextype SystemSize, int maxl, sunrealtype rtol, printf(" Total system size: %ld\n", (long int)SystemSize); printf("Subgrid dimensions: %d x %d", MXSUB, MYSUB); printf(" Processor array: %d x %d\n", NPEX, NPEY); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg\n", rtol, atol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg\n", rtol, atol); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #else printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #endif @@ -715,18 +709,16 @@ static void PrintOutput(void* ida_mem, N_Vector cc, sunrealtype tt, retval = IDAGetLastStep(ida_mem, &hused); check_retval(&retval, "IDAGetLastStep", 1, thispe); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%8.2Qe %12.4Qe %12.4Qe | %3ld %1d %12.4Qe\n", tt, cdata[0], + clast[0], nst, kused, hused); + for (i = 1; i < NUM_SPECIES; i++) + printf(" %12.4Qe %12.4Qe |\n", cdata[i], clast[i]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%8.2Le %12.4Le %12.4Le | %3ld %1d %12.4Le\n", tt, cdata[0], clast[0], nst, kused, hused); for (i = 1; i < NUM_SPECIES; i++) printf(" %12.4Le %12.4Le |\n", cdata[i], clast[i]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%8.2e %12.4e %12.4e | %3ld %1d %12.4e\n", tt, cdata[0], clast[0], - nst, kused, hused); - for (i = 1; i < NUM_SPECIES; i++) - { - printf(" %12.4e %12.4e |\n", cdata[i], clast[i]); - } #else printf("%8.2e %12.4e %12.4e | %3ld %1d %12.4e\n", tt, cdata[0], clast[0], nst, kused, hused); @@ -1217,7 +1209,8 @@ static void WebRates(sunrealtype xx, sunrealtype yy, sunrealtype* cxy, ratesxy[is] = dotprod(NUM_SPECIES, cxy, acoef[is]); } - fac = ONE + ALPHA * xx * yy + BETA * sin(FOURPI * xx) * sin(FOURPI * yy); + fac = ONE + ALPHA * xx * yy + + BETA * SUNRsin(FOURPI * xx) * SUNRsin(FOURPI * yy); for (is = 0; is < NUM_SPECIES; is++) { @@ -1290,8 +1283,8 @@ static int Precondbd(sunrealtype tt, N_Vector cc, N_Vector cp, N_Vector rr, for (js = 0; js < ns; js++) { - inc = sqru * (MAX(SUNRabs(cxy[js]), - MAX(hh * SUNRabs(cpxy[js]), ONE / ewtxy[js]))); + inc = sqru * (SUNMAX(SUNRabs(cxy[js]), + SUNMAX(hh * SUNRabs(cpxy[js]), ONE / ewtxy[js]))); cctemp = cxy[js]; /* Save the (js,ix,jy) element of cc. */ cxy[js] += inc; /* Perturb the (js,ix,jy) element of cc. */ fac = -ONE / inc; diff --git a/examples/ida/parallel/idaFoodWeb_kry_p.out b/examples/ida/parallel/idaFoodWeb_kry_p.out index 3433dc999b..b496c8963d 100644 --- a/examples/ida/parallel/idaFoodWeb_kry_p.out +++ b/examples/ida/parallel/idaFoodWeb_kry_p.out @@ -21,30 +21,30 @@ CalcIC called to correct initial predator concentrations 1.00e-02 1.6189e+02 1.9735e+02 | 86 4 1.7533e-04 1.6189e+06 1.9735e+06 | -1.00e-01 2.4019e+02 2.7072e+02 | 163 1 2.2442e-02 +1.00e-01 2.4019e+02 2.7072e+02 | 167 1 4.4884e-02 2.4019e+06 2.7072e+06 | -4.00e-01 2.4019e+02 2.7072e+02 | 166 1 1.7954e-01 +4.00e-01 2.4019e+02 2.7072e+02 | 169 1 1.7954e-01 2.4019e+06 2.7072e+06 | -7.00e-01 2.4019e+02 2.7072e+02 | 167 1 3.5907e-01 +7.00e-01 2.4019e+02 2.7072e+02 | 170 1 3.5907e-01 2.4019e+06 2.7072e+06 | -1.00e+00 2.4019e+02 2.7072e+02 | 168 1 7.1814e-01 +1.00e+00 2.4019e+02 2.7072e+02 | 171 1 7.1814e-01 2.4019e+06 2.7072e+06 | ----------------------------------------------------------- Final statistics: -Number of steps = 168 -Number of residual evaluations = 1217 -Number of nonlinear iterations = 202 +Number of steps = 171 +Number of residual evaluations = 1247 +Number of nonlinear iterations = 209 Number of error test failures = 0 Number of nonlinear conv. failures = 0 -Number of linear iterations = 1013 +Number of linear iterations = 1036 Number of linear conv. failures = 0 Number of preconditioner setups = 26 -Number of preconditioner solves = 1217 +Number of preconditioner solves = 1247 diff --git a/examples/ida/parallel/idaHeat2D_kry_bbd_p.c b/examples/ida/parallel/idaHeat2D_kry_bbd_p.c index 08726cd366..cb80123b31 100644 --- a/examples/ida/parallel/idaHeat2D_kry_bbd_p.c +++ b/examples/ida/parallel/idaHeat2D_kry_bbd_p.c @@ -801,10 +801,10 @@ static void PrintHeader(sunindextype Neq, sunrealtype rtol, sunrealtype atol) printf("Subgrid dimensions: %d x %d", MXSUB, MYSUB); printf(" Processor array: %d x %d\n", NPEX, NPEY); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg\n", rtol, atol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg\n", rtol, atol); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #else printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #endif @@ -868,12 +868,12 @@ static void PrintOutput(int id, void* ida_mem, sunrealtype t, N_Vector uu) retval = IDAGetNumPrecSolves(ida_mem, &nps); check_retval(&retval, "IDAGetNumPrecSolves", 1, id); -#if defined(SUNDIALS_EXTENDED_PRECISION) - printf(" %5.2Lf %13.5Le %d %3ld %3ld %3ld %4ld %4ld %4ld %9.2Le %3ld " +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" %5.2Qf %13.5Qe %d %3ld %3ld %3ld %4ld %4ld %4ld %9.2Qe %3ld " "%3ld\n", t, umax, kused, nst, nni, nli, nre, nreLS, nge, hused, npe, nps); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf(" %5.2f %13.5e %d %3ld %3ld %3ld %4ld %4ld %4ld %9.2e %3ld " +#elif defined(SUNDIALS_EXTENDED_PRECISION) + printf(" %5.2Lf %13.5Le %d %3ld %3ld %3ld %4ld %4ld %4ld %9.2Le %3ld " "%3ld\n", t, umax, kused, nst, nni, nli, nre, nreLS, nge, hused, npe, nps); #else diff --git a/examples/ida/parallel/idaHeat2D_kry_p.c b/examples/ida/parallel/idaHeat2D_kry_p.c index 2a84fced64..b2e6bb31ff 100644 --- a/examples/ida/parallel/idaHeat2D_kry_p.c +++ b/examples/ida/parallel/idaHeat2D_kry_p.c @@ -923,10 +923,10 @@ static void PrintHeader(sunrealtype rtol, sunrealtype atol, UserData data) printf(" Total system size: %ld\n\n", (long)(data->mx * data->my)); printf("Subgrid dimensions: %d x %d", (int)data->mxsub, (int)data->mysub); printf(" Processor array: %d x %d\n", (int)data->npex, (int)data->npey); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg\n", rtol, atol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg\n", rtol, atol); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #else printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #endif @@ -978,13 +978,12 @@ static void PrintOutput(int id, void* ida_mem, sunrealtype t, N_Vector uu) check_retval(&retval, "IDAGetNumPrecEvals", 1, id); retval = IDAGetNumPrecSolves(ida_mem, &nps); check_retval(&retval, "IDAGetNumPrecSolves", 1, id); - -#if defined(SUNDIALS_EXTENDED_PRECISION) - printf(" %5.2Lf %13.5Le %d %3ld %3ld %3ld %4ld %4ld %9.2Le %3ld " +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" %5.2Qf %13.5Qe %d %3ld %3ld %3ld %4ld %4ld %9.2Qe %3ld " "%3ld\n", t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf(" %5.2f %13.5e %d %3ld %3ld %3ld %4ld %4ld %9.2e %3ld " +#elif defined(SUNDIALS_EXTENDED_PRECISION) + printf(" %5.2Lf %13.5Le %d %3ld %3ld %3ld %4ld %4ld %9.2Le %3ld " "%3ld\n", t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps); #else diff --git a/examples/ida/raja/idaHeat2D_kry_raja.cpp b/examples/ida/raja/idaHeat2D_kry_raja.cpp index 0f65f76b4e..bc4b55e2f7 100644 --- a/examples/ida/raja/idaHeat2D_kry_raja.cpp +++ b/examples/ida/raja/idaHeat2D_kry_raja.cpp @@ -511,7 +511,9 @@ static void PrintHeader(sunrealtype rtol, sunrealtype atol) printf(" polynomial initial conditions.\n"); printf(" Mesh dimensions: %d x %d", MGRID, MGRID); printf(" Total system size: %d\n\n", NEQ); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg\n", rtol, atol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg\n", rtol, atol); #elif defined(SUNDIALS_DOUBLE_PRECISION) printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); @@ -555,7 +557,11 @@ static void PrintOutput(void* mem, sunrealtype t, N_Vector uu) ier = IDAGetNumPrecSolves(mem, &nps); check_flag(&ier, "IDAGetNumPrecSolves", 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" %5.2Qf %13.5Qe %d %3ld %3ld %3ld %4ld %4ld %9.2Qe %3ld " + "%3ld\n", + t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" %5.2Lf %13.5Le %d %3ld %3ld %3ld %4ld %4ld %9.2Le %3ld " "%3ld\n", t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps); diff --git a/examples/ida/serial/idaAnalytic_mels.c b/examples/ida/serial/idaAnalytic_mels.c index ba5fe363b3..960376d2b2 100644 --- a/examples/ida/serial/idaAnalytic_mels.c +++ b/examples/ida/serial/idaAnalytic_mels.c @@ -37,7 +37,10 @@ #include /* defs. of SUNRabs, SUNRexp, etc. */ #include /* defs. of sunrealtype, sunindextype */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#define FSYM "Qf" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #define FSYM "Lf" #else @@ -133,7 +136,7 @@ int main(int argc, char* argv[]) tout = T0 + dTout; printf(" t x1 x2\n"); printf(" ----------------------------------\n"); - while (Tf - t > 1.0e-15) + while (Tf - t > SUN_RCONST(1.0e-15)) { retval = IDASolve(ida_mem, tout, &t, yy, yp, IDA_NORMAL); /* call integrator */ if (check_retval(&retval, "IDASolve", 1)) { return (1); } @@ -205,7 +208,7 @@ int fres(sunrealtype t, N_Vector yy, N_Vector yp, N_Vector rr, void* user_data) sunrealtype TWO = SUN_RCONST(2.0); NV_Ith_S(rr, 0) = (ONE - alpha) / (t - TWO) * x1 - x1 + (alpha - ONE) * x2 + - TWO * exp(t) - x1p; + TWO * SUNRexp(t) - x1p; NV_Ith_S(rr, 1) = (t + TWO) * x1 - (t + TWO) * SUNRexp(t); return (0); diff --git a/examples/ida/serial/idaFoodWeb_bnd.c b/examples/ida/serial/idaFoodWeb_bnd.c index a407a00286..064d99c57c 100644 --- a/examples/ida/serial/idaFoodWeb_bnd.c +++ b/examples/ida/serial/idaFoodWeb_bnd.c @@ -105,7 +105,7 @@ #define NPREY 1 /* No. of prey (= no. of predators). */ #define NUM_SPECIES 2 * NPREY -#define PI SUN_RCONST(3.1415926535898) +#define PI SUN_RCONST(3.141592653589793238462643383279502884197169) #define FOURPI (SUN_RCONST(4.0) * PI) #define MX 20 /* MX = number of x mesh points */ @@ -213,10 +213,10 @@ int main(void) if (check_retval((void*)cc, "N_VNew_Serial", 0)) { return (1); } cp = N_VClone(cc); - if (check_retval((void*)cp, "N_VNew_Serial", 0)) { return (1); } + if (check_retval((void*)cp, "N_VClone", 0)) { return (1); } id = N_VClone(cc); - if (check_retval((void*)id, "N_VNew_Serial", 0)) { return (1); } + if (check_retval((void*)id, "N_VClone", 0)) { return (1); } SetInitialProfiles(cc, cp, id, webdata); @@ -492,10 +492,10 @@ static void PrintHeader(sunindextype mu, sunindextype ml, sunrealtype rtol, printf("Number of species ns: %d", NUM_SPECIES); printf(" Mesh dimensions: %d x %d", MX, MY); printf(" System size: %d\n", NEQ); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg\n", rtol, atol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg\n", rtol, atol); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #else printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #endif @@ -530,18 +530,16 @@ static void PrintOutput(void* mem, N_Vector c, sunrealtype t) c_bl = IJ_Vptr(c, 0, 0); c_tr = IJ_Vptr(c, MX - 1, MY - 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%8.2Qe %12.4Qe %12.4Qe | %3ld %1d %12.4Qe\n", t, c_bl[0], c_tr[0], + nst, kused, hused); + for (i = 1; i < NUM_SPECIES; i++) + printf(" %12.4Qe %12.4Qe |\n", c_bl[i], c_tr[i]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%8.2Le %12.4Le %12.4Le | %3ld %1d %12.4Le\n", t, c_bl[0], c_tr[0], nst, kused, hused); for (i = 1; i < NUM_SPECIES; i++) printf(" %12.4Le %12.4Le |\n", c_bl[i], c_tr[i]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%8.2e %12.4e %12.4e | %3ld %1d %12.4e\n", t, c_bl[0], c_tr[0], nst, - kused, hused); - for (i = 1; i < NUM_SPECIES; i++) - { - printf(" %12.4e %12.4e |\n", c_bl[i], c_tr[i]); - } #else printf("%8.2e %12.4e %12.4e | %3ld %1d %12.4e\n", t, c_bl[0], c_tr[0], nst, kused, hused); @@ -658,7 +656,8 @@ static void WebRates(sunrealtype xx, sunrealtype yy, sunrealtype* cxy, ratesxy[is] = dotprod(NUM_SPECIES, cxy, acoef[is]); } - fac = ONE + ALPHA * xx * yy + BETA * sin(FOURPI * xx) * sin(FOURPI * yy); + fac = ONE + ALPHA * xx * yy + + BETA * SUNRsin(FOURPI * xx) * SUNRsin(FOURPI * yy); for (is = 0; is < NUM_SPECIES; is++) { diff --git a/examples/ida/serial/idaFoodWeb_kry.c b/examples/ida/serial/idaFoodWeb_kry.c index 3cbc943c6e..7b206afdd5 100644 --- a/examples/ida/serial/idaFoodWeb_kry.c +++ b/examples/ida/serial/idaFoodWeb_kry.c @@ -100,18 +100,12 @@ #include /* definition of type sunrealtype */ #include /* access to spgmr SUNLinearSolver */ -/* helpful macros */ - -#ifndef MAX -#define MAX(A, B) ((A) > (B) ? (A) : (B)) -#endif - /* Problem Constants. */ #define NPREY 1 /* No. of prey (= no. of predators). */ #define NUM_SPECIES 2 * NPREY -#define PI SUN_RCONST(3.1415926535898) +#define PI SUN_RCONST(3.141592653589793238462643383279502884197169) #define FOURPI (SUN_RCONST(4.0) * PI) #define MX 20 /* MX = number of x mesh points */ @@ -418,7 +412,7 @@ static int Precond(sunrealtype tt, N_Vector cc, N_Vector cp, N_Vector rr, del_y = webdata->dy; uround = SUN_UNIT_ROUNDOFF; - sqru = sqrt(uround); + sqru = SUNRsqrt(uround); mem = webdata->ida_mem; ewt = webdata->ewt; @@ -442,8 +436,8 @@ static int Precond(sunrealtype tt, N_Vector cc, N_Vector cp, N_Vector rr, for (js = 0; js < NUM_SPECIES; js++) { - inc = sqru * (MAX(SUNRabs(cxy[js]), - MAX(hh * SUNRabs(cpxy[js]), ONE / ewtxy[js]))); + inc = sqru * (SUNMAX(SUNRabs(cxy[js]), + SUNMAX(hh * SUNRabs(cpxy[js]), ONE / ewtxy[js]))); cctmp = cxy[js]; cxy[js] += inc; fac = -ONE / inc; @@ -631,10 +625,10 @@ static void PrintHeader(int maxl, sunrealtype rtol, sunrealtype atol) printf("Number of species ns: %d", NUM_SPECIES); printf(" Mesh dimensions: %d x %d", MX, MY); printf(" System size: %d\n", NEQ); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg\n", rtol, atol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg\n", rtol, atol); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #else printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #endif @@ -668,18 +662,16 @@ static void PrintOutput(void* mem, N_Vector c, sunrealtype t) c_bl = IJ_Vptr(c, 0, 0); c_tr = IJ_Vptr(c, MX - 1, MY - 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%8.2Qe %12.4Qe %12.4Qe | %3ld %1d %12.4Qe\n", t, c_bl[0], c_tr[0], + nst, kused, hused); + for (i = 1; i < NUM_SPECIES; i++) + printf(" %12.4Qe %12.4Qe |\n", c_bl[i], c_tr[i]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%8.2Le %12.4Le %12.4Le | %3ld %1d %12.4Le\n", t, c_bl[0], c_tr[0], nst, kused, hused); for (i = 1; i < NUM_SPECIES; i++) printf(" %12.4Le %12.4Le |\n", c_bl[i], c_tr[i]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%8.2e %12.4e %12.4e | %3ld %1d %12.4e\n", t, c_bl[0], c_tr[0], nst, - kused, hused); - for (i = 1; i < NUM_SPECIES; i++) - { - printf(" %12.4e %12.4e |\n", c_bl[i], c_tr[i]); - } #else printf("%8.2e %12.4e %12.4e | %3ld %1d %12.4e\n", t, c_bl[0], c_tr[0], nst, kused, hused); @@ -793,7 +785,8 @@ static void WebRates(sunrealtype xx, sunrealtype yy, sunrealtype* cxy, ratesxy[is] = dotprod(NUM_SPECIES, cxy, acoef[is]); } - fac = ONE + ALPHA * xx * yy + BETA * sin(FOURPI * xx) * sin(FOURPI * yy); + fac = ONE + ALPHA * xx * yy + + BETA * SUNRsin(FOURPI * xx) * SUNRsin(FOURPI * yy); for (is = 0; is < NUM_SPECIES; is++) { diff --git a/examples/ida/serial/idaFoodWeb_kry.out b/examples/ida/serial/idaFoodWeb_kry.out index 60e12ec765..ebd57cd3e9 100644 --- a/examples/ida/serial/idaFoodWeb_kry.out +++ b/examples/ida/serial/idaFoodWeb_kry.out @@ -19,24 +19,24 @@ CalcIC called to correct initial predator concentrations. 1.00e-02 1.6189e+02 1.9735e+02 | 86 4 1.7533e-04 1.6189e+06 1.9735e+06 | -1.00e-01 2.4019e+02 2.7072e+02 | 161 1 4.0396e-02 +1.00e-01 2.4019e+02 2.7072e+02 | 167 1 4.0396e-02 2.4019e+06 2.7072e+06 | -4.00e-01 2.4019e+02 2.7072e+02 | 164 1 3.2316e-01 +4.00e-01 2.4019e+02 2.7072e+02 | 170 1 3.2316e-01 2.4019e+06 2.7072e+06 | -7.00e-01 2.4019e+02 2.7072e+02 | 165 1 6.4633e-01 +7.00e-01 2.4019e+02 2.7072e+02 | 170 1 3.2316e-01 2.4019e+06 2.7072e+06 | -1.00e+00 2.4019e+02 2.7072e+02 | 165 1 6.4633e-01 +1.00e+00 2.4019e+02 2.7072e+02 | 171 1 6.4633e-01 2.4019e+06 2.7072e+06 | ----------------------------------------------------------- Final run statistics: -Number of steps = 165 -Number of residual evaluations = 206 +Number of steps = 171 +Number of residual evaluations = 210 Number of Preconditioner evaluations = 26 -Number of linear iterations = 1034 +Number of linear iterations = 1010 Number of error test failures = 0 -Number of precond solve fun called = 1240 +Number of precond solve fun called = 1220 diff --git a/examples/ida/serial/idaHeat2D_bnd.c b/examples/ida/serial/idaHeat2D_bnd.c index 8792d5e792..d4f9c29af6 100644 --- a/examples/ida/serial/idaHeat2D_bnd.c +++ b/examples/ida/serial/idaHeat2D_bnd.c @@ -344,20 +344,20 @@ static void PrintHeader(sunrealtype rtol, sunrealtype atol) printf(" polynomial initial conditions.\n"); printf(" Mesh dimensions: %d x %d", MGRID, MGRID); printf(" Total system size: %d\n\n", NEQ); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg\n", rtol, atol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg\n", rtol, atol); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #else printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #endif printf("Constraints set to force all solution components >= 0. \n"); printf("Linear solver: BAND, banded direct solver \n"); printf(" difference quotient Jacobian, half-bandwidths = %d \n", MGRID); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("IDACalcIC called with input boundary values = %Qg \n", BVAL); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("IDACalcIC called with input boundary values = %Lg \n", BVAL); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("IDACalcIC called with input boundary values = %g \n", BVAL); #else printf("IDACalcIC called with input boundary values = %g \n", BVAL); #endif @@ -394,13 +394,12 @@ static void PrintOutput(void* mem, sunrealtype t, N_Vector uu) check_retval(&retval, "IDAGetNumJacEvals", 1); retval = IDAGetNumLinResEvals(mem, &nreLS); check_retval(&retval, "IDAGetNumLinResEvals", 1); - -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" %5.2Qf %13.5Qe %d %3ld %3ld %3ld %4ld %4ld %9.2Qe \n", t, + umax, kused, nst, nni, nje, nre, nreLS, hused); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" %5.2Lf %13.5Le %d %3ld %3ld %3ld %4ld %4ld %9.2Le \n", t, umax, kused, nst, nni, nje, nre, nreLS, hused); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf(" %5.2f %13.5e %d %3ld %3ld %3ld %4ld %4ld %9.2e \n", t, umax, - kused, nst, nni, nje, nre, nreLS, hused); #else printf(" %5.2f %13.5e %d %3ld %3ld %3ld %4ld %4ld %9.2e \n", t, umax, kused, nst, nni, nje, nre, nreLS, hused); diff --git a/examples/ida/serial/idaHeat2D_klu.c b/examples/ida/serial/idaHeat2D_klu.c index 2aab3739a3..b52eec1f78 100644 --- a/examples/ida/serial/idaHeat2D_klu.c +++ b/examples/ida/serial/idaHeat2D_klu.c @@ -784,20 +784,20 @@ static void PrintHeader(sunrealtype rtol, sunrealtype atol) printf(" polynomial initial conditions.\n"); printf(" Mesh dimensions: %d x %d", MGRID, MGRID); printf(" Total system size: %d\n\n", NEQ); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg\n", rtol, atol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg\n", rtol, atol); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #else printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #endif printf("Constraints set to force all solution components >= 0. \n"); printf("Linear solver: KLU, sparse direct solver \n"); printf(" difference quotient Jacobian\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("IDACalcIC called with input boundary values = %Qg \n", BVAL); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("IDACalcIC called with input boundary values = %Lg \n", BVAL); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("IDACalcIC called with input boundary values = %g \n", BVAL); #else printf("IDACalcIC called with input boundary values = %g \n", BVAL); #endif @@ -833,12 +833,12 @@ static void PrintOutput(void* mem, sunrealtype t, N_Vector uu) retval = IDAGetNumJacEvals(mem, &nje); check_retval(&retval, "IDAGetNumJacEvals", 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" %5.2Qf %13.5Qe %d %3ld %3ld %3ld %4ld %9.2Qe \n", t, umax, + kused, nst, nni, nje, nre, hused); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" %5.2Lf %13.5Le %d %3ld %3ld %3ld %4ld %9.2Le \n", t, umax, kused, nst, nni, nje, nre, hused); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf(" %5.2f %13.5e %d %3ld %3ld %3ld %4ld %9.2e \n", t, umax, kused, - nst, nni, nje, nre, hused); #else printf(" %5.2f %13.5e %d %3ld %3ld %3ld %4ld %9.2e \n", t, umax, kused, nst, nni, nje, nre, hused); diff --git a/examples/ida/serial/idaHeat2D_kry.c b/examples/ida/serial/idaHeat2D_kry.c index 7b93a2b52c..8ac3e85f1b 100644 --- a/examples/ida/serial/idaHeat2D_kry.c +++ b/examples/ida/serial/idaHeat2D_kry.c @@ -484,10 +484,10 @@ static void PrintHeader(sunrealtype rtol, sunrealtype atol) printf(" polynomial initial conditions.\n"); printf(" Mesh dimensions: %d x %d", MGRID, MGRID); printf(" Total system size: %d\n\n", NEQ); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg\n", rtol, atol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg\n", rtol, atol); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #else printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #endif @@ -527,13 +527,13 @@ static void PrintOutput(void* mem, sunrealtype t, N_Vector uu) check_retval(&retval, "IDAGetNumPrecEvals", 1); retval = IDAGetNumPrecSolves(mem, &nps); check_retval(&retval, "IDAGetNumPrecSolves", 1); - -#if defined(SUNDIALS_EXTENDED_PRECISION) - printf(" %5.2Lf %13.5Le %d %3ld %3ld %3ld %4ld %4ld %9.2Le %3ld " +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" %5.2Qf %13.5Qe %d %3ld %3ld %3ld %4ld %4ld %9.2Qe %3ld " "%3ld\n", t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf(" %5.2f %13.5e %d %3ld %3ld %3ld %4ld %4ld %9.2e %3ld %3ld\n", +#elif defined(SUNDIALS_EXTENDED_PRECISION) + printf(" %5.2Lf %13.5Le %d %3ld %3ld %3ld %4ld %4ld %9.2Le %3ld " + "%3ld\n", t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps); #else printf(" %5.2f %13.5e %d %3ld %3ld %3ld %4ld %4ld %9.2e %3ld %3ld\n", diff --git a/examples/ida/serial/idaKrylovDemo_ls.c b/examples/ida/serial/idaKrylovDemo_ls.c index 1ed8ef0b97..2bccb3b4c1 100644 --- a/examples/ida/serial/idaKrylovDemo_ls.c +++ b/examples/ida/serial/idaKrylovDemo_ls.c @@ -52,18 +52,6 @@ #include /* access to SPGMR SUNLinearSolver */ #include /* access to SPTFQMR SUNLinearSolver */ -/* helpful macros */ - -#ifndef SQRT -#if defined(SUNDIALS_DOUBLE_PRECISION) -#define SQRT(x) (sqrt((x))) -#elif defined(SUNDIALS_SINGLE_PRECISION) -#define SQRT(x) (sqrtf((x))) -#elif defined(SUNDIALS_EXTENDED_PRECISION) -#define SQRT(x) (sqrtl((x))) -#endif -#endif - /* Problem Constants */ #define NOUT 11 @@ -290,7 +278,7 @@ int main(int argc, char* argv[]) { case (1): /* use the square root of the vector length */ - nrmfac = SQRT((sunrealtype)NEQ); + nrmfac = SUNRsqrt((sunrealtype)NEQ); break; case (2): /* compute with dot product */ @@ -548,10 +536,10 @@ static void PrintHeader(sunrealtype rtol, sunrealtype atol, int linsolver) printf(" polynomial initial conditions.\n"); printf(" Mesh dimensions: %d x %d", MGRID, MGRID); printf(" Total system size: %d\n\n", NEQ); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg\n", rtol, atol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg\n", rtol, atol); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #else printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #endif @@ -607,13 +595,13 @@ static void PrintOutput(void* mem, sunrealtype t, N_Vector uu, int linsolver) check_retval(&retval, "IDAGetNumPrecEvals", 1); retval = IDAGetNumPrecSolves(mem, &nps); check_retval(&retval, "IDAGetNumPrecSolves", 1); - -#if defined(SUNDIALS_EXTENDED_PRECISION) - printf(" %5.2Lf %13.5Le %d %3ld %3ld %3ld %4ld %4ld %9.2Le %3ld " +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" %5.2Qf %13.5Qe %d %3ld %3ld %3ld %4ld %4ld %9.2Qe %3ld " "%3ld\n", t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf(" %5.2f %13.5e %d %3ld %3ld %3ld %4ld %4ld %9.2e %3ld %3ld\n", +#elif defined(SUNDIALS_EXTENDED_PRECISION) + printf(" %5.2Lf %13.5Le %d %3ld %3ld %3ld %4ld %4ld %9.2Le %3ld " + "%3ld\n", t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps); #else printf(" %5.2f %13.5e %d %3ld %3ld %3ld %4ld %4ld %9.2e %3ld %3ld\n", diff --git a/examples/ida/serial/idaRoberts_dns.c b/examples/ida/serial/idaRoberts_dns.c index 99ae83caf9..59e3013af5 100644 --- a/examples/ida/serial/idaRoberts_dns.c +++ b/examples/ida/serial/idaRoberts_dns.c @@ -45,7 +45,9 @@ #include /* access to dense SUNMatrix */ #include /* access to Newton SUNNonlinearSolver */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #else #define GSYM "g" @@ -117,9 +119,9 @@ int main(void) yy = N_VNew_Serial(NEQ, ctx); if (check_retval((void*)yy, "N_VNew_Serial", 0)) { return (1); } yp = N_VClone(yy); - if (check_retval((void*)yp, "N_VNew_Serial", 0)) { return (1); } + if (check_retval((void*)yp, "N_VClone", 0)) { return (1); } avtol = N_VClone(yy); - if (check_retval((void*)avtol, "N_VNew_Serial", 0)) { return (1); } + if (check_retval((void*)avtol, "N_VClone", 0)) { return (1); } /* Create and initialize y, y', and absolute tolerance vectors. */ yval = N_VGetArrayPointer(yy); @@ -331,14 +333,14 @@ static void PrintHeader(sunrealtype rtol, N_Vector avtol, N_Vector y) "IDA\n"); printf(" Three equation chemical kinetics problem.\n\n"); printf("Linear solver: DENSE, with user-supplied Jacobian.\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg %Qg %Qg \n", rtol, + atval[0], atval[1], atval[2]); + printf("Initial conditions y0 = (%Qg %Qg %Qg)\n", yval[0], yval[1], yval[2]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg %Lg %Lg \n", rtol, atval[0], atval[1], atval[2]); printf("Initial conditions y0 = (%Lg %Lg %Lg)\n", yval[0], yval[1], yval[2]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: rtol = %g atol = %g %g %g \n", rtol, - atval[0], atval[1], atval[2]); - printf("Initial conditions y0 = (%g %g %g)\n", yval[0], yval[1], yval[2]); #else printf("Tolerance parameters: rtol = %g atol = %g %g %g \n", rtol, atval[0], atval[1], atval[2]); @@ -372,11 +374,11 @@ static void PrintOutput(void* mem, sunrealtype t, N_Vector y) check_retval(&retval, "IDAGetNumSteps", 1); retval = IDAGetLastStep(mem, &hused); check_retval(&retval, "IDAGetLastStep", 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) - printf("%10.4Le %12.4Le %12.4Le %12.4Le | %3ld %1d %12.4Le\n", t, yval[0], +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%10.4Qe %12.4Qe %12.4Qe %12.4Qe | %3ld %1d %12.4Qe\n", t, yval[0], yval[1], yval[2], nst, kused, hused); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%10.4e %12.4e %12.4e %12.4e | %3ld %1d %12.4e\n", t, yval[0], +#elif defined(SUNDIALS_EXTENDED_PRECISION) + printf("%10.4Le %12.4Le %12.4Le %12.4Le | %3ld %1d %12.4Le\n", t, yval[0], yval[1], yval[2], nst, kused, hused); #else printf("%10.4e %12.4e %12.4e %12.4e | %3ld %1d %12.4e\n", t, yval[0], @@ -433,7 +435,7 @@ static int check_retval(void* returnvalue, const char* funcname, int opt) } /* compare the solution at the final time 4e10s to a reference solution computed - using a relative tolerance of 1e-8 and absolute tolerance of 1e-14 */ + using a relative tolerance of 1e-31 and absolute tolerance of 1e-31 */ static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, N_Vector atol) { int passfail = 0; /* answer pass (0) or fail (1) retval */ @@ -445,10 +447,11 @@ static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, N_Vector atol) ref = N_VClone(y); ewt = N_VClone(y); - /* set the reference solution data */ - NV_Ith_S(ref, 0) = SUN_RCONST(5.2083474251394888e-08); - NV_Ith_S(ref, 1) = SUN_RCONST(2.0833390772616859e-13); - NV_Ith_S(ref, 2) = SUN_RCONST(9.9999994791631752e-01); + /* set the reference solution data, using float128 precision, + rtol=atol=1e-31 */ + NV_Ith_S(ref, 0) = SUN_RCONST(5.20834517679923919877889080688790329e-08); + NV_Ith_S(ref, 1) = SUN_RCONST(2.08333817792548903496396691950921252e-13); + NV_Ith_S(ref, 2) = SUN_RCONST(9.99999947916339898189815463307595615e-01); /* compute the error weight vector, loosen atol */ N_VAbs(ref, ewt); diff --git a/examples/ida/serial/idaRoberts_klu.c b/examples/ida/serial/idaRoberts_klu.c index a6ac5c0a78..a9585a25c5 100644 --- a/examples/ida/serial/idaRoberts_klu.c +++ b/examples/ida/serial/idaRoberts_klu.c @@ -374,14 +374,14 @@ static void PrintHeader(sunrealtype rtol, N_Vector avtol, N_Vector y) "IDA.\n"); printf(" Three equation chemical kinetics problem.\n\n"); printf("Linear solver: KLU, with user-supplied Jacobian.\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg %Qg %Qg \n", rtol, + atval[0], atval[1], atval[2]); + printf("Initial conditions y0 = (%Qg %Qg %Qg)\n", yval[0], yval[1], yval[2]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg %Lg %Lg \n", rtol, atval[0], atval[1], atval[2]); printf("Initial conditions y0 = (%Lg %Lg %Lg)\n", yval[0], yval[1], yval[2]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: rtol = %g atol = %g %g %g \n", rtol, - atval[0], atval[1], atval[2]); - printf("Initial conditions y0 = (%g %g %g)\n", yval[0], yval[1], yval[2]); #else printf("Tolerance parameters: rtol = %g atol = %g %g %g \n", rtol, atval[0], atval[1], atval[2]); @@ -415,11 +415,11 @@ static void PrintOutput(void* mem, sunrealtype t, N_Vector y) check_retval(&retval, "IDAGetNumSteps", 1); retval = IDAGetLastStep(mem, &hused); check_retval(&retval, "IDAGetLastStep", 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) - printf("%10.4Le %12.4Le %12.4Le %12.4Le | %3ld %1d %12.4Le\n", t, yval[0], +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%10.4Qe %12.4Qe %12.4Qe %12.4Qe | %3ld %1d %12.4Qe\n", t, yval[0], yval[1], yval[2], nst, kused, hused); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%10.4e %12.4e %12.4e %12.4e | %3ld %1d %12.4e\n", t, yval[0], +#elif defined(SUNDIALS_EXTENDED_PRECISION) + printf("%10.4Le %12.4Le %12.4Le %12.4Le | %3ld %1d %12.4Le\n", t, yval[0], yval[1], yval[2], nst, kused, hused); #else printf("%10.4e %12.4e %12.4e %12.4e | %3ld %1d %12.4e\n", t, yval[0], diff --git a/examples/ida/serial/idaRoberts_sps.c b/examples/ida/serial/idaRoberts_sps.c index 27a4247fe7..0aed9a094b 100644 --- a/examples/ida/serial/idaRoberts_sps.c +++ b/examples/ida/serial/idaRoberts_sps.c @@ -322,14 +322,14 @@ static void PrintHeader(sunrealtype rtol, N_Vector avtol, N_Vector y) "IDA.\n"); printf(" Three equation chemical kinetics problem.\n\n"); printf("Linear solver: SUPERLUMT, with user-supplied Jacobian.\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg %Qg %Qg \n", rtol, + atval[0], atval[1], atval[2]); + printf("Initial conditions y0 = (%Qg %Qg %Qg)\n", yval[0], yval[1], yval[2]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg %Lg %Lg \n", rtol, atval[0], atval[1], atval[2]); printf("Initial conditions y0 = (%Lg %Lg %Lg)\n", yval[0], yval[1], yval[2]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: rtol = %g atol = %g %g %g \n", rtol, - atval[0], atval[1], atval[2]); - printf("Initial conditions y0 = (%g %g %g)\n", yval[0], yval[1], yval[2]); #else printf("Tolerance parameters: rtol = %g atol = %g %g %g \n", rtol, atval[0], atval[1], atval[2]); @@ -363,11 +363,11 @@ static void PrintOutput(void* mem, sunrealtype t, N_Vector y) check_retval(&retval, "IDAGetNumSteps", 1); retval = IDAGetLastStep(mem, &hused); check_retval(&retval, "IDAGetLastStep", 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) - printf("%10.4Le %12.4Le %12.4Le %12.4Le | %3ld %1d %12.4Le\n", t, yval[0], +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%10.4Qe %12.4Qe %12.4Qe %12.4Qe | %3ld %1d %12.4Qe\n", t, yval[0], yval[1], yval[2], nst, kused, hused); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%10.4e %12.4e %12.4e %12.4e | %3ld %1d %12.4e\n", t, yval[0], +#elif defined(SUNDIALS_EXTENDED_PRECISION) + printf("%10.4Le %12.4Le %12.4Le %12.4Le | %3ld %1d %12.4Le\n", t, yval[0], yval[1], yval[2], nst, kused, hused); #else printf("%10.4e %12.4e %12.4e %12.4e | %3ld %1d %12.4e\n", t, yval[0], diff --git a/examples/ida/serial/idaSlCrank_dns.c b/examples/ida/serial/idaSlCrank_dns.c index 9c457ff5a1..ae76b20b58 100644 --- a/examples/ida/serial/idaSlCrank_dns.c +++ b/examples/ida/serial/idaSlCrank_dns.c @@ -198,8 +198,8 @@ void setIC(N_Vector yy, N_Vector yp, UserData data) J2 = data->J2; q = pi / TWO; - p = asin(-a); - x = cos(p); + p = SUNRasin(-a); + x = SUNRcos(p); NV_Ith_S(yy, 0) = q; NV_Ith_S(yy, 1) = x; @@ -235,15 +235,15 @@ void force(N_Vector yy, sunrealtype* Q, UserData data) xd = NV_Ith_S(yy, 4); pd = NV_Ith_S(yy, 5); - s1 = sin(q); - c1 = cos(q); - s2 = sin(p); - c2 = cos(p); + s1 = SUNRsin(q); + c1 = SUNRcos(q); + s2 = SUNRsin(p); + c2 = SUNRcos(p); s21 = s2 * c1 - c2 * s1; c21 = c2 * c1 + s2 * s1; l2 = x * x - x * (c2 + a * c1) + (ONE + a * a) / FOUR + a * c21 / TWO; - l = sqrt(l2); + l = SUNRsqrt(l2); ld = TWO * x * xd - xd * (c2 + a * c1) + x * (s2 * pd + a * s1 * qd) - a * s21 * (pd - qd) / TWO; ld /= TWO * l; @@ -292,10 +292,10 @@ int ressc(sunrealtype tres, N_Vector yy, N_Vector yp, N_Vector rr, void* user_da mu1 = yval[8]; mu2 = yval[9]; - s1 = sin(q); - c1 = cos(q); - s2 = sin(p); - c2 = cos(p); + s1 = SUNRsin(q); + c1 = SUNRcos(q); + s2 = SUNRsin(p); + c2 = SUNRcos(p); force(yy, Q, data); @@ -320,10 +320,10 @@ static void PrintHeader(sunrealtype rtol, sunrealtype atol, N_Vector y) { printf("\nidaSlCrank_dns: Slider-Crank DAE serial example problem for IDA\n"); printf("Linear solver: DENSE, Jacobian is computed by IDA.\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg\n", rtol, atol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg\n", rtol, atol); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #else printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #endif @@ -347,8 +347,10 @@ static int PrintOutput(void* mem, sunrealtype t, N_Vector y) retval = IDAGetLastOrder(mem, &kused); retval = IDAGetNumSteps(mem, &nst); retval = IDAGetLastStep(mem, &hused); - -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%10.4Qe %12.4Qe %12.4Qe %12.4Qe %3ld %1d %12.4Qe\n", t, yval[0], + yval[1], yval[2], nst, kused, hused); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%10.4Le %12.4Le %12.4Le %12.4Le %3ld %1d %12.4Le\n", t, yval[0], yval[1], yval[2], nst, kused, hused); #else diff --git a/examples/ida/trilinos/idaHeat2D_kry_p_tpetra.cpp b/examples/ida/trilinos/idaHeat2D_kry_p_tpetra.cpp index e16921e678..d54214fceb 100644 --- a/examples/ida/trilinos/idaHeat2D_kry_p_tpetra.cpp +++ b/examples/ida/trilinos/idaHeat2D_kry_p_tpetra.cpp @@ -1021,7 +1021,9 @@ static void PrintHeader(sunrealtype rtol, sunrealtype atol, UserData* data) printf(" Total system size: %ld\n\n", (long)data->mx * data->my); printf("Subgrid dimensions: %d x %d", (int)data->mxsub, (int)data->mysub); printf(" Processor array: %d x %d\n", (int)data->npex, (int)data->npey); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg\n", rtol, atol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg\n", rtol, atol); #elif defined(SUNDIALS_DOUBLE_PRECISION) printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); diff --git a/examples/ida/trilinos/idaHeat2D_kry_tpetra.cpp b/examples/ida/trilinos/idaHeat2D_kry_tpetra.cpp index 4f9af8da74..3cb3096cd4 100644 --- a/examples/ida/trilinos/idaHeat2D_kry_tpetra.cpp +++ b/examples/ida/trilinos/idaHeat2D_kry_tpetra.cpp @@ -572,7 +572,9 @@ static void PrintHeader(sunrealtype rtol, sunrealtype atol) printf(" polynomial initial conditions.\n"); printf(" Mesh dimensions: %d x %d", MGRID, MGRID); printf(" Total system size: %d\n\n", NEQ); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg\n", rtol, atol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg\n", rtol, atol); #elif defined(SUNDIALS_DOUBLE_PRECISION) printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); @@ -615,7 +617,11 @@ static void PrintOutput(void* mem, sunrealtype t, N_Vector uu) retval = IDAGetNumPrecSolves(mem, &nps); check_retval(&retval, "IDAGetNumPrecSolves", 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" %5.2Qf %13.5Qe %d %3ld %3ld %3ld %4ld %4ld %9.2Qe %3ld " + "%3ld\n", + t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" %5.2Lf %13.5Le %d %3ld %3ld %3ld %4ld %4ld %9.2Le %3ld " "%3ld\n", t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps); diff --git a/examples/idas/C_openmp/idasFoodWeb_bnd_omp.c b/examples/idas/C_openmp/idasFoodWeb_bnd_omp.c index 5a1aa47566..0c2c0d193f 100644 --- a/examples/idas/C_openmp/idasFoodWeb_bnd_omp.c +++ b/examples/idas/C_openmp/idasFoodWeb_bnd_omp.c @@ -127,7 +127,7 @@ #define NPREY 1 /* No. of prey (= no. of predators). */ #define NUM_SPECIES 2 * NPREY -#define PI SUN_RCONST(3.1415926535898) +#define PI SUN_RCONST(3.141592653589793238462643383279502884197169) #define FOURPI (SUN_RCONST(4.0) * PI) #define MX 20 /* MX = number of x mesh points */ diff --git a/examples/idas/C_openmp/idasFoodWeb_kry_omp.c b/examples/idas/C_openmp/idasFoodWeb_kry_omp.c index 4a5fc1ad94..fa304e88f8 100644 --- a/examples/idas/C_openmp/idasFoodWeb_kry_omp.c +++ b/examples/idas/C_openmp/idasFoodWeb_kry_omp.c @@ -132,7 +132,7 @@ #define NPREY 1 /* No. of prey (= no. of predators). */ #define NUM_SPECIES 2 * NPREY -#define PI SUN_RCONST(3.1415926535898) +#define PI SUN_RCONST(3.141592653589793238462643383279502884197169) #define FOURPI (SUN_RCONST(4.0) * PI) #define MX 20 /* MX = number of x mesh points */ diff --git a/examples/idas/parallel/idasBruss_ASAp_kry_bbd_p.c b/examples/idas/parallel/idasBruss_ASAp_kry_bbd_p.c index 4a9fba7506..a0d77c4761 100644 --- a/examples/idas/parallel/idasBruss_ASAp_kry_bbd_p.c +++ b/examples/idas/parallel/idasBruss_ASAp_kry_bbd_p.c @@ -91,7 +91,7 @@ #define ctB SUN_RCONST(3.4) #define ctEps SUN_RCONST(2.0e-3) -#define PI SUN_RCONST(3.1415926535898) /* pi */ +#define PI SUN_RCONST(3.141592653589793238462643383279502884197169) /* pi */ #define MXSUB 21 /* Number of x mesh points per processor subgrid */ #define MYSUB 21 /* Number of y mesh points per processor subgrid */ @@ -699,10 +699,10 @@ static void PrintHeader(sunindextype SystemSize, int maxl, sunindextype mudq, printf("Total system size: %ld\n", (long int)SystemSize); printf("Subgrid dimensions: %d x %d", MXSUB, MYSUB); printf(" Processor array: %d x %d\n", NPEX, NPEY); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg\n", rtol, atol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg\n", rtol, atol); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #else printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #endif @@ -769,18 +769,16 @@ static void PrintOutput(void* ida_mem, N_Vector uv, sunrealtype tt, retval = IDAGetLastStep(ida_mem, &hused); check_retval(&retval, "IDAGetLastStep", 1, thispe); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%8.2Qe %12.4Qe %12.4Qe | %3ld %1d %12.4Qe\n", tt, cdata[0], + clast[0], nst, kused, hused); + for (i = 1; i < NUM_SPECIES; i++) + printf(" %12.4Qe %12.4Qe |\n", cdata[i], clast[i]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%8.2Le %12.4Le %12.4Le | %3ld %1d %12.4Le\n", tt, cdata[0], clast[0], nst, kused, hused); for (i = 1; i < NUM_SPECIES; i++) printf(" %12.4Le %12.4Le |\n", cdata[i], clast[i]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%8.2e %12.4e %12.4e | %3ld %1d %12.4e\n", tt, cdata[0], clast[0], - nst, kused, hused); - for (i = 1; i < NUM_SPECIES; i++) - { - printf(" %12.4e %12.4e |\n", cdata[i], clast[i]); - } #else printf("%8.2e %12.4e %12.4e | %3ld %1d %12.4e\n", tt, cdata[0], clast[0], nst, kused, hused); @@ -835,7 +833,9 @@ static void PrintSol(void* ida_mem, N_Vector uv, N_Vector uvp, UserData data, uvxy = IJ_Vptr(uv, ix, jy); /* uvxy = (&NV_Ith_P(uv, (i)*NUM_SPECIES + (j)*NSMXSUB*npex )); */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + fprintf(fout, "%Qg\n%Qg\n", uvxy[0], uvxy[1]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) fprintf(fout, "%Lg\n%Lg\n", uvxy[0], uvxy[1]); #else fprintf(fout, "%g\n%g\n", uvxy[0], uvxy[1]); @@ -871,7 +871,9 @@ static void PrintAdjSol(N_Vector uvB, N_Vector uvpB, UserData data) for (ix = 0; ix < mxsub; ix++) { uvxy = IJ_Vptr(uvB, ix, jy); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + fprintf(fout, "%Qg\n%Qg\n", uvxy[0], uvxy[1]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) fprintf(fout, "%Lg\n%Lg\n", uvxy[0], uvxy[1]); #else fprintf(fout, "%g\n%g\n", uvxy[0], uvxy[1]); diff --git a/examples/idas/parallel/idasBruss_FSA_kry_bbd_p.c b/examples/idas/parallel/idasBruss_FSA_kry_bbd_p.c index 47bbfebb9b..58641aaf86 100644 --- a/examples/idas/parallel/idasBruss_FSA_kry_bbd_p.c +++ b/examples/idas/parallel/idasBruss_FSA_kry_bbd_p.c @@ -77,7 +77,7 @@ #define NS 2 -#define PI SUN_RCONST(3.1415926535898) /* pi */ +#define PI SUN_RCONST(3.141592653589793238462643383279502884197169) /* pi */ #define MXSUB 41 /* Number of x mesh points per processor subgrid */ #define MYSUB 41 /* Number of y mesh points per processor subgrid */ @@ -389,7 +389,9 @@ int main(int argc, char* argv[]) integr(comm, uv, data, &intval); if (thispe == 0) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("\n\nThe average of u on the domain:\ng = %Qg\n", intval); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("\n\nThe average of u on the domain:\ng = %Lg\n", intval); #else printf("\n\nThe average of u on the domain:\ng = %g\n", intval); @@ -405,7 +407,9 @@ int main(int argc, char* argv[]) integr(comm, uvS[is], data, &intval); if (thispe == 0) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("w.r.t. eps%d = %14.10Qf\n", is, intval); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("w.r.t. eps%d = %14.10Lf\n", is, intval); #else printf("w.r.t. eps%d = %14.10f\n", is, intval); @@ -579,10 +583,10 @@ static void PrintHeader(sunindextype SystemSize, int maxl, sunindextype mudq, printf("Total system size: %ld\n", (long int)SystemSize); printf("Subgrid dimensions: %d x %d", MXSUB, MYSUB); printf(" Processor array: %d x %d\n", NPEX, NPEY); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg\n", rtol, atol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg\n", rtol, atol); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #else printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #endif @@ -648,18 +652,16 @@ static void PrintOutput(void* ida_mem, N_Vector uv, sunrealtype tt, retval = IDAGetLastStep(ida_mem, &hused); check_retval(&retval, "IDAGetLastStep", 1, thispe); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%8.2Qe %12.4Qe %12.4Qe | %3ld %1d %12.4Qe\n", tt, cdata[0], + clast[0], nst, kused, hused); + for (i = 1; i < NUM_SPECIES; i++) + printf(" %12.4Qe %12.4Qe |\n", cdata[i], clast[i]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%8.2Le %12.4Le %12.4Le | %3ld %1d %12.4Le\n", tt, cdata[0], clast[0], nst, kused, hused); for (i = 1; i < NUM_SPECIES; i++) printf(" %12.4Le %12.4Le |\n", cdata[i], clast[i]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%8.2e %12.4e %12.4e | %3ld %1d %12.4e\n", tt, cdata[0], clast[0], - nst, kused, hused); - for (i = 1; i < NUM_SPECIES; i++) - { - printf(" %12.4e %12.4e |\n", cdata[i], clast[i]); - } #else printf("%8.2e %12.4e %12.4e | %3ld %1d %12.4e\n", tt, cdata[0], clast[0], nst, kused, hused); @@ -699,7 +701,9 @@ static void PrintSol(void* ida_mem, N_Vector uv, N_Vector uvp, UserData data, for (ix = 0; ix < mxsub; ix++) { uvxy = IJ_Vptr(uv, ix, jy); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + fprintf(fout, "%Qg\n%Qg\n", uvxy[0], uvxy[1]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) fprintf(fout, "%Lg\n%Lg\n", uvxy[0], uvxy[1]); #else fprintf(fout, "%g\n%g\n", uvxy[0], uvxy[1]); diff --git a/examples/idas/parallel/idasBruss_kry_bbd_p.c b/examples/idas/parallel/idasBruss_kry_bbd_p.c index eb45cf273c..d59c997603 100644 --- a/examples/idas/parallel/idasBruss_kry_bbd_p.c +++ b/examples/idas/parallel/idasBruss_kry_bbd_p.c @@ -65,7 +65,7 @@ #define ctB SUN_RCONST(3.4) #define ctEps SUN_RCONST(2.0e-3) -#define PI SUN_RCONST(3.1415926535898) /* pi */ +#define PI SUN_RCONST(3.141592653589793238462643383279502884197169) /* pi */ #define MXSUB 21 /* Number of x mesh points per processor subgrid */ #define MYSUB 21 /* Number of y mesh points per processor subgrid */ @@ -499,10 +499,10 @@ static void PrintHeader(sunindextype SystemSize, int maxl, sunindextype mudq, printf(" Total system size: %ld\n", (long int)SystemSize); printf("Subgrid dimensions: %d x %d", MXSUB, MYSUB); printf(" Processor array: %d x %d\n", NPEX, NPEY); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg\n", rtol, atol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg\n", rtol, atol); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #else printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #endif @@ -568,18 +568,16 @@ static void PrintOutput(void* ida_mem, N_Vector uv, sunrealtype tt, retval = IDAGetLastStep(ida_mem, &hused); check_retval(&retval, "IDAGetLastStep", 1, thispe); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%8.2Qe %12.4Qe %12.4Qe | %3ld %1d %12.4Qe\n", tt, cdata[0], + clast[0], nst, kused, hused); + for (i = 1; i < NUM_SPECIES; i++) + printf(" %12.4Qe %12.4Qe |\n", cdata[i], clast[i]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%8.2Le %12.4Le %12.4Le | %3ld %1d %12.4Le\n", tt, cdata[0], clast[0], nst, kused, hused); for (i = 1; i < NUM_SPECIES; i++) printf(" %12.4Le %12.4Le |\n", cdata[i], clast[i]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%8.2e %12.4e %12.4e | %3ld %1d %12.4e\n", tt, cdata[0], clast[0], - nst, kused, hused); - for (i = 1; i < NUM_SPECIES; i++) - { - printf(" %12.4e %12.4e |\n", cdata[i], clast[i]); - } #else printf("%8.2e %12.4e %12.4e | %3ld %1d %12.4e\n", tt, cdata[0], clast[0], nst, kused, hused); @@ -619,7 +617,9 @@ static void PrintSol(void* ida_mem, N_Vector uv, N_Vector uvp, UserData data, for (ix = 0; ix < mxsub; ix++) { uvxy = IJ_Vptr(uv, ix, jy); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + fprintf(fout, "%Qg\n%Qg\n", uvxy[0], uvxy[1]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) fprintf(fout, "%Lg\n%Lg\n", uvxy[0], uvxy[1]); #else fprintf(fout, "%g\n%g\n", uvxy[0], uvxy[1]); diff --git a/examples/idas/parallel/idasFoodWeb_kry_bbd_p.c b/examples/idas/parallel/idasFoodWeb_kry_bbd_p.c index 420dcbff3e..7292f90e9e 100644 --- a/examples/idas/parallel/idasFoodWeb_kry_bbd_p.c +++ b/examples/idas/parallel/idasFoodWeb_kry_bbd_p.c @@ -121,8 +121,8 @@ #define NPREY 1 /* Number of prey (= number of predators). */ #define NUM_SPECIES 2 * NPREY -#define PI SUN_RCONST(3.1415926535898) /* pi */ -#define FOURPI (SUN_RCONST(4.0) * PI) /* 4 pi */ +#define PI SUN_RCONST(3.141592653589793238462643383279502884197169) /* pi */ +#define FOURPI (SUN_RCONST(4.0) * PI) /* 4 pi */ #define MXSUB 10 /* Number of x mesh points per processor subgrid */ #define MYSUB 10 /* Number of y mesh points per processor subgrid */ @@ -580,10 +580,10 @@ static void PrintHeader(sunindextype SystemSize, int maxl, sunindextype mudq, printf(" Total system size: %ld\n", (long int)SystemSize); printf("Subgrid dimensions: %d x %d", MXSUB, MYSUB); printf(" Processor array: %d x %d\n", NPEX, NPEY); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg\n", rtol, atol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg\n", rtol, atol); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #else printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #endif @@ -650,18 +650,16 @@ static void PrintOutput(void* ida_mem, N_Vector cc, sunrealtype tt, retval = IDAGetLastStep(ida_mem, &hused); check_retval(&retval, "IDAGetLastStep", 1, thispe); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%8.2Qe %12.4Qe %12.4Qe | %3ld %1d %12.4Qe\n", tt, cdata[0], + clast[0], nst, kused, hused); + for (i = 1; i < NUM_SPECIES; i++) + printf(" %12.4Qe %12.4Qe |\n", cdata[i], clast[i]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%8.2Le %12.4Le %12.4Le | %3ld %1d %12.4Le\n", tt, cdata[0], clast[0], nst, kused, hused); for (i = 1; i < NUM_SPECIES; i++) printf(" %12.4Le %12.4Le |\n", cdata[i], clast[i]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%8.2e %12.4e %12.4e | %3ld %1d %12.4e\n", tt, cdata[0], clast[0], - nst, kused, hused); - for (i = 1; i < NUM_SPECIES; i++) - { - printf(" %12.4e %12.4e |\n", cdata[i], clast[i]); - } #else printf("%8.2e %12.4e %12.4e | %3ld %1d %12.4e\n", tt, cdata[0], clast[0], nst, kused, hused); diff --git a/examples/idas/parallel/idasFoodWeb_kry_bbd_p.out b/examples/idas/parallel/idasFoodWeb_kry_bbd_p.out index 42fcfcca16..4bb1ae3d58 100644 --- a/examples/idas/parallel/idasFoodWeb_kry_bbd_p.out +++ b/examples/idas/parallel/idasFoodWeb_kry_bbd_p.out @@ -22,25 +22,25 @@ CalcIC called to correct initial predator concentrations 1.00e-02 1.6189e+02 1.9735e+02 | 118 4 1.7533e-04 1.6189e+06 1.9735e+06 | -1.00e-01 2.4019e+02 2.7072e+02 | 175 1 3.0682e-02 +1.00e-01 2.4019e+02 2.7072e+02 | 174 1 3.0667e-02 2.4019e+06 2.7072e+06 | -4.00e-01 2.4019e+02 2.7072e+02 | 178 1 2.4545e-01 +4.00e-01 2.4019e+02 2.7072e+02 | 177 1 2.4533e-01 2.4019e+06 2.7072e+06 | -7.00e-01 2.4019e+02 2.7072e+02 | 179 1 4.9091e-01 +7.00e-01 2.4019e+02 2.7072e+02 | 178 1 4.9067e-01 2.4019e+06 2.7072e+06 | -1.00e+00 2.4019e+02 2.7072e+02 | 179 1 4.9091e-01 +1.00e+00 2.4019e+02 2.7072e+02 | 178 1 4.9067e-01 2.4019e+06 2.7072e+06 | ----------------------------------------------------------- Final statistics: -Number of steps = 179 -Number of residual evaluations = 946 -Number of nonlinear iterations = 222 +Number of steps = 178 +Number of residual evaluations = 950 +Number of nonlinear iterations = 226 Number of error test failures = 0 Number of nonlinear conv. failures = 0 @@ -48,5 +48,5 @@ Number of linear iterations = 722 Number of linear conv. failures = 0 Number of preconditioner setups = 24 -Number of preconditioner solves = 946 +Number of preconditioner solves = 950 Number of local residual evals. = 1008 diff --git a/examples/idas/parallel/idasFoodWeb_kry_p.c b/examples/idas/parallel/idasFoodWeb_kry_p.c index f62f844d65..a66f416966 100644 --- a/examples/idas/parallel/idasFoodWeb_kry_p.c +++ b/examples/idas/parallel/idasFoodWeb_kry_p.c @@ -115,19 +115,13 @@ #include #include -/* helpful macros */ - -#ifndef MAX -#define MAX(A, B) ((A) > (B) ? (A) : (B)) -#endif - /* Problem Constants. */ #define NPREY 1 /* Number of prey (= number of predators). */ #define NUM_SPECIES 2 * NPREY -#define PI SUN_RCONST(3.1415926535898) /* pi */ -#define FOURPI (SUN_RCONST(4.0) * PI) /* 4 pi */ +#define PI SUN_RCONST(3.141592653589793238462643383279502884197169) /* pi */ +#define FOURPI (SUN_RCONST(4.0) * PI) /* 4 pi */ #define MXSUB 10 /* Number of x mesh points per processor subgrid */ #define MYSUB 10 /* Number of y mesh points per processor subgrid */ @@ -643,10 +637,10 @@ static void PrintHeader(sunindextype SystemSize, int maxl, sunrealtype rtol, printf(" Total system size: %ld\n", (long int)SystemSize); printf("Subgrid dimensions: %d x %d", MXSUB, MYSUB); printf(" Processor array: %d x %d\n", NPEX, NPEY); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg\n", rtol, atol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg\n", rtol, atol); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #else printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #endif @@ -714,18 +708,16 @@ static void PrintOutput(void* ida_mem, N_Vector cc, sunrealtype tt, retval = IDAGetLastStep(ida_mem, &hused); check_retval(&retval, "IDAGetLastStep", 1, thispe); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%8.2Qe %12.4Qe %12.4Qe | %3ld %1d %12.4Qe\n", tt, cdata[0], + clast[0], nst, kused, hused); + for (i = 1; i < NUM_SPECIES; i++) + printf(" %12.4Qe %12.4Qe |\n", cdata[i], clast[i]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%8.2Le %12.4Le %12.4Le | %3ld %1d %12.4Le\n", tt, cdata[0], clast[0], nst, kused, hused); for (i = 1; i < NUM_SPECIES; i++) printf(" %12.4Le %12.4Le |\n", cdata[i], clast[i]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%8.2e %12.4e %12.4e | %3ld %1d %12.4e\n", tt, cdata[0], clast[0], - nst, kused, hused); - for (i = 1; i < NUM_SPECIES; i++) - { - printf(" %12.4e %12.4e |\n", cdata[i], clast[i]); - } #else printf("%8.2e %12.4e %12.4e | %3ld %1d %12.4e\n", tt, cdata[0], clast[0], nst, kused, hused); @@ -1216,7 +1208,8 @@ static void WebRates(sunrealtype xx, sunrealtype yy, sunrealtype* cxy, ratesxy[is] = dotprod(NUM_SPECIES, cxy, acoef[is]); } - fac = ONE + ALPHA * xx * yy + BETA * sin(FOURPI * xx) * sin(FOURPI * yy); + fac = ONE + ALPHA * xx * yy + + BETA * SUNRsin(FOURPI * xx) * SUNRsin(FOURPI * yy); for (is = 0; is < NUM_SPECIES; is++) { @@ -1289,8 +1282,8 @@ static int Precondbd(sunrealtype tt, N_Vector cc, N_Vector cp, N_Vector rr, for (js = 0; js < ns; js++) { - inc = sqru * (MAX(SUNRabs(cxy[js]), - MAX(hh * SUNRabs(cpxy[js]), ONE / ewtxy[js]))); + inc = sqru * (SUNMAX(SUNRabs(cxy[js]), + SUNMAX(hh * SUNRabs(cpxy[js]), ONE / ewtxy[js]))); cctemp = cxy[js]; /* Save the (js,ix,jy) element of cc. */ cxy[js] += inc; /* Perturb the (js,ix,jy) element of cc. */ fac = -ONE / inc; diff --git a/examples/idas/parallel/idasFoodWeb_kry_p.out b/examples/idas/parallel/idasFoodWeb_kry_p.out index 4d50701b19..9c492b896e 100644 --- a/examples/idas/parallel/idasFoodWeb_kry_p.out +++ b/examples/idas/parallel/idasFoodWeb_kry_p.out @@ -21,30 +21,30 @@ CalcIC called to correct initial predator concentrations 1.00e-02 1.6189e+02 1.9735e+02 | 86 4 1.7533e-04 1.6189e+06 1.9735e+06 | -1.00e-01 2.4019e+02 2.7072e+02 | 163 1 2.2442e-02 +1.00e-01 2.4019e+02 2.7072e+02 | 167 1 4.4884e-02 2.4019e+06 2.7072e+06 | -4.00e-01 2.4019e+02 2.7072e+02 | 166 1 1.7954e-01 +4.00e-01 2.4019e+02 2.7072e+02 | 169 1 1.7954e-01 2.4019e+06 2.7072e+06 | -7.00e-01 2.4019e+02 2.7072e+02 | 167 1 3.5907e-01 +7.00e-01 2.4019e+02 2.7072e+02 | 170 1 3.5907e-01 2.4019e+06 2.7072e+06 | -1.00e+00 2.4019e+02 2.7072e+02 | 168 1 7.1814e-01 +1.00e+00 2.4019e+02 2.7072e+02 | 171 1 7.1814e-01 2.4019e+06 2.7072e+06 | ----------------------------------------------------------- Final statistics: -Number of steps = 168 -Number of residual evaluations = 1217 -Number of nonlinear iterations = 202 +Number of steps = 171 +Number of residual evaluations = 1247 +Number of nonlinear iterations = 209 Number of error test failures = 0 Number of nonlinear conv. failures = 0 -Number of linear iterations = 1013 +Number of linear iterations = 1036 Number of linear conv. failures = 0 Number of preconditioner setups = 26 -Number of preconditioner solves = 1217 +Number of preconditioner solves = 1247 diff --git a/examples/idas/parallel/idasHeat2D_FSA_kry_bbd_p.c b/examples/idas/parallel/idasHeat2D_FSA_kry_bbd_p.c index 6ab6725e44..0a668b3ecd 100644 --- a/examples/idas/parallel/idasHeat2D_FSA_kry_bbd_p.c +++ b/examples/idas/parallel/idasHeat2D_FSA_kry_bbd_p.c @@ -880,10 +880,10 @@ static void PrintHeader(sunindextype Neq, sunrealtype rtol, sunrealtype atol, printf("Subgrid dimensions: %d x %d", MXSUB, MYSUB); printf(" Processor array: %d x %d\n", NPEX, NPEY); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg\n", rtol, atol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg\n", rtol, atol); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #else printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #endif @@ -949,12 +949,12 @@ static void PrintOutput(int id, void* ida_mem, sunrealtype t, N_Vector uu, retval = IDAGetNumPrecSolves(ida_mem, &nps); check_retval(&retval, "IDAGetNumPrecSolves", 1, id); -#if defined(SUNDIALS_EXTENDED_PRECISION) - printf(" %5.2Lf %13.5Le %d %3ld %3ld %3ld %4ld %4ld %4ld %9.2Le %3ld " +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" %5.2Qf %13.5Qe %d %3ld %3ld %3ld %4ld %4ld %4ld %9.2Qe %3ld " "%3ld\n", t, umax, kused, nst, nni, nli, nre, nreLS, nge, hused, npe, nps); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf(" %5.2f %13.5e %d %3ld %3ld %3ld %4ld %4ld %4ld %9.2e %3ld " +#elif defined(SUNDIALS_EXTENDED_PRECISION) + printf(" %5.2Lf %13.5Le %d %3ld %3ld %3ld %4ld %4ld %4ld %9.2Le %3ld " "%3ld\n", t, umax, kused, nst, nni, nli, nre, nreLS, nge, hused, npe, nps); #else @@ -971,10 +971,10 @@ static void PrintOutput(int id, void* ida_mem, sunrealtype t, N_Vector uu, umax = N_VMaxNorm(uuS[is]); if (id == 0) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" %13.5Qe\n", umax); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" %13.5Le\n", umax); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf(" %13.5e\n", umax); #else printf(" %13.5e\n", umax); #endif diff --git a/examples/idas/parallel/idasHeat2D_kry_bbd_p.c b/examples/idas/parallel/idasHeat2D_kry_bbd_p.c index 45bce90fd3..6384eb7a01 100644 --- a/examples/idas/parallel/idasHeat2D_kry_bbd_p.c +++ b/examples/idas/parallel/idasHeat2D_kry_bbd_p.c @@ -801,10 +801,10 @@ static void PrintHeader(sunindextype Neq, sunrealtype rtol, sunrealtype atol) printf("Subgrid dimensions: %d x %d", MXSUB, MYSUB); printf(" Processor array: %d x %d\n", NPEX, NPEY); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg\n", rtol, atol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg\n", rtol, atol); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #else printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #endif @@ -868,12 +868,12 @@ static void PrintOutput(int id, void* ida_mem, sunrealtype t, N_Vector uu) retval = IDAGetNumPrecSolves(ida_mem, &nps); check_retval(&retval, "IDAGetNumPrecSolves", 1, id); -#if defined(SUNDIALS_EXTENDED_PRECISION) - printf(" %5.2Lf %13.5Le %d %3ld %3ld %3ld %4ld %4ld %4ld %9.2Le %3ld " +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" %5.2Qf %13.5Qe %d %3ld %3ld %3ld %4ld %4ld %4ld %9.2Qe %3ld " "%3ld\n", t, umax, kused, nst, nni, nli, nre, nreLS, nge, hused, npe, nps); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf(" %5.2f %13.5e %d %3ld %3ld %3ld %4ld %4ld %4ld %9.2e %3ld " +#elif defined(SUNDIALS_EXTENDED_PRECISION) + printf(" %5.2Lf %13.5Le %d %3ld %3ld %3ld %4ld %4ld %4ld %9.2Le %3ld " "%3ld\n", t, umax, kused, nst, nni, nli, nre, nreLS, nge, hused, npe, nps); #else diff --git a/examples/idas/parallel/idasHeat2D_kry_p.c b/examples/idas/parallel/idasHeat2D_kry_p.c index 6d3d078676..864a7f6a6f 100644 --- a/examples/idas/parallel/idasHeat2D_kry_p.c +++ b/examples/idas/parallel/idasHeat2D_kry_p.c @@ -845,10 +845,10 @@ static void PrintHeader(sunindextype Neq, sunrealtype rtol, sunrealtype atol) printf(" Total system size: %ld\n\n", (long int)Neq); printf("Subgrid dimensions: %d x %d", MXSUB, MYSUB); printf(" Processor array: %d x %d\n", NPEX, NPEY); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg\n", rtol, atol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg\n", rtol, atol); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #else printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #endif @@ -901,12 +901,12 @@ static void PrintOutput(int id, void* ida_mem, sunrealtype t, N_Vector uu) retval = IDAGetNumPrecSolves(ida_mem, &nps); check_retval(&retval, "IDAGetNumPrecSolves", 1, id); -#if defined(SUNDIALS_EXTENDED_PRECISION) - printf(" %5.2Lf %13.5Le %d %3ld %3ld %3ld %4ld %4ld %9.2Le %3ld " +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" %5.2Qf %13.5Qe %d %3ld %3ld %3ld %4ld %4ld %9.2Qe %3ld " "%3ld\n", t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf(" %5.2f %13.5e %d %3ld %3ld %3ld %4ld %4ld %9.2e %3ld " +#elif defined(SUNDIALS_EXTENDED_PRECISION) + printf(" %5.2Lf %13.5Le %d %3ld %3ld %3ld %4ld %4ld %9.2Le %3ld " "%3ld\n", t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps); #else diff --git a/examples/idas/serial/idasAkzoNob_ASAi_dns.c b/examples/idas/serial/idasAkzoNob_ASAi_dns.c index ef80fb94dc..fce7c28fe6 100644 --- a/examples/idas/serial/idasAkzoNob_ASAi_dns.c +++ b/examples/idas/serial/idasAkzoNob_ASAi_dns.c @@ -212,7 +212,9 @@ int main(void) retval = IDAGetQuad(mem, &time, q); if (check_retval(&retval, "IDAGetQuad", 1)) { return (1); } -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("G: %24.16Qf \n", Ith(q, 1)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("G: %24.16Lf \n", Ith(q, 1)); #else printf("G: %24.16f \n", Ith(q, 1)); @@ -437,7 +439,10 @@ static int resB(sunrealtype tt, N_Vector yy, N_Vector yp, N_Vector yyB, */ static void PrintOutput(sunrealtype tfinal, N_Vector yB, N_Vector ypB) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("dG/dy0: " + "\t%12.4Qe\n\t\t%12.4Qe\n\t\t%12.4Qe\n\t\t%12.4Qe\n\t\t%12.4Qe\n", +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("dG/dy0: " "\t%12.4Le\n\t\t%12.4Le\n\t\t%12.4Le\n\t\t%12.4Le\n\t\t%12.4Le\n", #else diff --git a/examples/idas/serial/idasAkzoNob_dns.c b/examples/idas/serial/idasAkzoNob_dns.c index a309420271..dd94d5164b 100644 --- a/examples/idas/serial/idasAkzoNob_dns.c +++ b/examples/idas/serial/idasAkzoNob_dns.c @@ -205,7 +205,9 @@ int main(void) if (check_retval(&retval, "IDAGetQuad", 1)) { return (1); } printf("\n--------------------------------------------------------\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("G: %24.16Qf \n", Ith(q, 1)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("G: %24.16Lf \n", Ith(q, 1)); #else printf("G: %24.16f \n", Ith(q, 1)); @@ -297,10 +299,10 @@ static void PrintHeader(sunrealtype rtol, sunrealtype avtol, N_Vector y) printf("\nidasAkzoNob_dns: Akzo Nobel chemical kinetics DAE serial example " "problem for IDAS\n"); printf("Linear solver: DENSE, Jacobian is computed by IDAS.\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg\n", rtol, avtol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg\n", rtol, avtol); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, avtol); #else printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, avtol); #endif @@ -327,14 +329,16 @@ static void PrintOutput(void* mem, sunrealtype t, N_Vector y) check_retval(&retval, "IDAGetNumSteps", 1); retval = IDAGetLastStep(mem, &hused); check_retval(&retval, "IDAGetLastStep", 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%8.2Qe %8.2Qe %8.2Qe %8.2Qe %8.2Qe %8.2Qe %8.2Qe | %3ld %1d " + "%8.2Qe\n", + t, yval[0], yval[1], yval[2], yval[3], yval[4], yval[5], nst, kused, + hused); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%8.2Le %8.2Le %8.2Le %8.2Le %8.2Le %8.2Le %8.2Le | %3ld %1d " "%8.2Le\n", t, yval[0], yval[1], yval[2], yval[3], yval[4], yval[5], nst, kused, hused); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%8.2e %8.2e %8.2e %8.2e %8.2e %8.2e %8.2e | %3ld %1d %8.2e\n", t, - yval[0], yval[1], yval[2], yval[3], yval[4], yval[5], nst, kused, hused); #else printf("%8.2e %8.2e %8.2e %8.2e %8.2e %8.2e %8.2e | %3ld %1d %8.2e\n", t, yval[0], yval[1], yval[2], yval[3], yval[4], yval[5], nst, kused, hused); diff --git a/examples/idas/serial/idasAnalytic_mels.c b/examples/idas/serial/idasAnalytic_mels.c index 8641b3d3e2..9608a573ab 100644 --- a/examples/idas/serial/idasAnalytic_mels.c +++ b/examples/idas/serial/idasAnalytic_mels.c @@ -37,7 +37,11 @@ #include /* defs. of SUNRabs, SUNRexp, etc. */ #include /* defs. of sunrealtype, sunindextype */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#define ESYM "Qe" +#define FSYM "Qf" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #define ESYM "Le" #define FSYM "Lf" diff --git a/examples/idas/serial/idasFoodWeb_bnd.c b/examples/idas/serial/idasFoodWeb_bnd.c index 153efafe62..4410e817a6 100644 --- a/examples/idas/serial/idasFoodWeb_bnd.c +++ b/examples/idas/serial/idasFoodWeb_bnd.c @@ -105,7 +105,7 @@ #define NPREY 1 /* No. of prey (= no. of predators). */ #define NUM_SPECIES 2 * NPREY -#define PI SUN_RCONST(3.1415926535898) +#define PI SUN_RCONST(3.141592653589793238462643383279502884197169) #define FOURPI (SUN_RCONST(4.0) * PI) #define MX 20 /* MX = number of x mesh points */ @@ -492,10 +492,10 @@ static void PrintHeader(sunindextype mu, sunindextype ml, sunrealtype rtol, printf("Number of species ns: %d", NUM_SPECIES); printf(" Mesh dimensions: %d x %d", MX, MY); printf(" System size: %d\n", NEQ); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg\n", rtol, atol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg\n", rtol, atol); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #else printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #endif @@ -530,18 +530,16 @@ static void PrintOutput(void* mem, N_Vector c, sunrealtype t) c_bl = IJ_Vptr(c, 0, 0); c_tr = IJ_Vptr(c, MX - 1, MY - 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%8.2Qe %12.4Qe %12.4Qe | %3ld %1d %12.4Qe\n", t, c_bl[0], c_tr[0], + nst, kused, hused); + for (i = 1; i < NUM_SPECIES; i++) + printf(" %12.4Qe %12.4Qe |\n", c_bl[i], c_tr[i]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%8.2Le %12.4Le %12.4Le | %3ld %1d %12.4Le\n", t, c_bl[0], c_tr[0], nst, kused, hused); for (i = 1; i < NUM_SPECIES; i++) printf(" %12.4Le %12.4Le |\n", c_bl[i], c_tr[i]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%8.2e %12.4e %12.4e | %3ld %1d %12.4e\n", t, c_bl[0], c_tr[0], nst, - kused, hused); - for (i = 1; i < NUM_SPECIES; i++) - { - printf(" %12.4e %12.4e |\n", c_bl[i], c_tr[i]); - } #else printf("%8.2e %12.4e %12.4e | %3ld %1d %12.4e\n", t, c_bl[0], c_tr[0], nst, kused, hused); diff --git a/examples/idas/serial/idasHessian_ASA_FSA.c b/examples/idas/serial/idasHessian_ASA_FSA.c index 0b843eb626..05aed3e483 100644 --- a/examples/idas/serial/idasHessian_ASA_FSA.c +++ b/examples/idas/serial/idasHessian_ASA_FSA.c @@ -226,7 +226,9 @@ int main(int argc, char* argv[]) IDAGetQuad(ida_mem, &time, q); G = Ith(q, 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" G: %12.4Qe\n", G); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" G: %12.4Le\n", G); #else printf(" G: %12.4e\n", G); @@ -237,7 +239,9 @@ int main(int argc, char* argv[]) IDAGetSensDky(ida_mem, tf, 1, ypS); IDAGetQuadSens(ida_mem, &time, qS); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" dG/dp: %12.4Qe %12.4Qe\n", Ith(qS[0], 1), Ith(qS[1], 1)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" dG/dp: %12.4Le %12.4Le\n", Ith(qS[0], 1), Ith(qS[1], 1)); #else printf(" dG/dp: %12.4e %12.4e\n", Ith(qS[0], 1), Ith(qS[1], 1)); @@ -342,7 +346,12 @@ int main(int argc, char* argv[]) retval = IDAGetQuadB(ida_mem, indexB1, &time, qB1); retval = IDAGetQuadB(ida_mem, indexB2, &time, qB2); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" dG/dp: %12.4Qe %12.4Qe (from backward pb. 1)\n", Ith(qB1, 1), + Ith(qB1, 2)); + printf(" dG/dp: %12.4Qe %12.4Qe (from backward pb. 2)\n", Ith(qB2, 1), + Ith(qB2, 2)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" dG/dp: %12.4Le %12.4Le (from backward pb. 1)\n", Ith(qB1, 1), Ith(qB1, 2)); printf(" dG/dp: %12.4Le %12.4Le (from backward pb. 2)\n", Ith(qB2, 1), @@ -357,7 +366,10 @@ int main(int argc, char* argv[]) printf("\n"); printf(" H = d2G/dp2:\n"); printf(" (1) (2)\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" %12.4Qe %12.4Qe\n", Ith(qB1, 3), Ith(qB2, 3)); + printf(" %12.4Qe %12.4Qe\n", Ith(qB1, 4), Ith(qB2, 4)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" %12.4Le %12.4Le\n", Ith(qB1, 3), Ith(qB2, 3)); printf(" %12.4Le %12.4Le\n", Ith(qB1, 4), Ith(qB2, 4)); #else @@ -383,7 +395,9 @@ int main(int argc, char* argv[]) printf("\n"); printf("---------------------------------------------------------\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Finite Differences ( dp1=%6.1Qe and dp2 = %6.1Qe )\n", dp1, dp2); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Finite Differences ( dp1=%6.1Le and dp2 = %6.1Le )\n", dp1, dp2); #else printf("Finite Differences ( dp1=%6.1e and dp2 = %6.1e )\n", dp1, dp2); @@ -512,7 +526,14 @@ int main(int argc, char* argv[]) H22 = (Gp - 2.0 * G + Gm) / (dp2 * dp2); printf("\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" dG/dp: %12.4Qe %12.4Qe (fwd FD)\n", grdG_fwd[0], grdG_fwd[1]); + printf(" %12.4Qe %12.4Qe (bck FD)\n", grdG_bck[0], grdG_bck[1]); + printf(" %12.4Qe %12.4Qe (cntr FD)\n", grdG_cntr[0], grdG_cntr[1]); + printf("\n"); + printf(" H(1,1): %12.4Qe\n", H11); + printf(" H(2,2): %12.4Qe\n", H22); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" dG/dp: %12.4Le %12.4Le (fwd FD)\n", grdG_fwd[0], grdG_fwd[1]); printf(" %12.4Le %12.4Le (bck FD)\n", grdG_bck[0], grdG_bck[1]); printf(" %12.4Le %12.4Le (cntr FD)\n", grdG_cntr[0], grdG_cntr[1]); diff --git a/examples/idas/serial/idasKrylovDemo_ls.c b/examples/idas/serial/idasKrylovDemo_ls.c index 78839ff387..ece99b72a9 100644 --- a/examples/idas/serial/idasKrylovDemo_ls.c +++ b/examples/idas/serial/idasKrylovDemo_ls.c @@ -52,18 +52,6 @@ #include /* access to SPGMR SUNLinearSolver */ #include /* access to SPTFQMR SUNLinearSolver */ -/* helpful macros */ - -#ifndef SQRT -#if defined(SUNDIALS_DOUBLE_PRECISION) -#define SQRT(x) (sqrt((x))) -#elif defined(SUNDIALS_SINGLE_PRECISION) -#define SQRT(x) (sqrtf((x))) -#elif defined(SUNDIALS_EXTENDED_PRECISION) -#define SQRT(x) (sqrtl((x))) -#endif -#endif - /* Problem Constants */ #define NOUT 11 @@ -289,7 +277,7 @@ int main(int argc, char* argv[]) { case (1): /* use the square root of the vector length */ - nrmfac = SQRT((sunrealtype)NEQ); + nrmfac = SUNRsqrt((sunrealtype)NEQ); break; case (2): /* compute with dot product */ @@ -548,10 +536,10 @@ static void PrintHeader(sunrealtype rtol, sunrealtype atol, int linsolver) printf(" polynomial initial conditions.\n"); printf(" Mesh dimensions: %d x %d", MGRID, MGRID); printf(" Total system size: %d\n\n", NEQ); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg\n", rtol, atol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg\n", rtol, atol); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #else printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, atol); #endif @@ -608,12 +596,13 @@ static void PrintOutput(void* mem, sunrealtype t, N_Vector uu, int linsolver) retval = IDAGetNumPrecSolves(mem, &nps); check_retval(&retval, "IDAGetNumPrecSolves", 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) - printf(" %5.2Lf %13.5Le %d %3ld %3ld %3ld %4ld %4ld %9.2Le %3ld " +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" %5.2Qf %13.5Qe %d %3ld %3ld %3ld %4ld %4ld %9.2Qe %3ld " "%3ld\n", t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf(" %5.2f %13.5e %d %3ld %3ld %3ld %4ld %4ld %9.2e %3ld %3ld\n", +#elif defined(SUNDIALS_EXTENDED_PRECISION) + printf(" %5.2Lf %13.5Le %d %3ld %3ld %3ld %4ld %4ld %9.2Le %3ld " + "%3ld\n", t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps); #else printf(" %5.2f %13.5e %d %3ld %3ld %3ld %4ld %4ld %9.2e %3ld %3ld\n", diff --git a/examples/idas/serial/idasRoberts_ASAi_dns.c b/examples/idas/serial/idasRoberts_ASAi_dns.c index 861ac88cee..d3845ca019 100644 --- a/examples/idas/serial/idasRoberts_ASAi_dns.c +++ b/examples/idas/serial/idasRoberts_ASAi_dns.c @@ -288,10 +288,10 @@ int main(int argc, char* argv[]) if (check_retval(&retval, "IDAGetQuad", 1)) { return (1); } printf("--------------------------------------------------------\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("G: %12.4Qe \n", Ith(q, 1)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("G: %12.4Le \n", Ith(q, 1)); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("G: %12.4e \n", Ith(q, 1)); #else printf("G: %12.4e \n", Ith(q, 1)); #endif @@ -751,18 +751,18 @@ static int rhsQB(sunrealtype tt, N_Vector yy, N_Vector yp, N_Vector yyB, static void PrintOutput(sunrealtype tfinal, N_Vector yB, N_Vector ypB, N_Vector qB) { printf("--------------------------------------------------------\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("tB0: %12.4Qe\n", tfinal); + printf("dG/dp: %12.4Qe %12.4Qe %12.4Qe\n", -Ith(qB, 1), -Ith(qB, 2), + -Ith(qB, 3)); + printf("lambda(t0): %12.4Qe %12.4Qe %12.4Qe\n", Ith(yB, 1), Ith(yB, 2), + Ith(yB, 3)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("tB0: %12.4Le\n", tfinal); printf("dG/dp: %12.4Le %12.4Le %12.4Le\n", -Ith(qB, 1), -Ith(qB, 2), -Ith(qB, 3)); printf("lambda(t0): %12.4Le %12.4Le %12.4Le\n", Ith(yB, 1), Ith(yB, 2), Ith(yB, 3)); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("tB0: %12.4e\n", tfinal); - printf("dG/dp: %12.4e %12.4e %12.4e\n", -Ith(qB, 1), -Ith(qB, 2), - -Ith(qB, 3)); - printf("lambda(t0): %12.4e %12.4e %12.4e\n", Ith(yB, 1), Ith(yB, 2), - Ith(yB, 3)); #else printf("tB0: %12.4e\n", tfinal); printf("dG/dp: %12.4e %12.4e %12.4e\n", -Ith(qB, 1), -Ith(qB, 2), diff --git a/examples/idas/serial/idasRoberts_ASAi_klu.c b/examples/idas/serial/idasRoberts_ASAi_klu.c index a90a72f8dd..0689d8d5e7 100644 --- a/examples/idas/serial/idasRoberts_ASAi_klu.c +++ b/examples/idas/serial/idasRoberts_ASAi_klu.c @@ -293,10 +293,10 @@ int main(int argc, char* argv[]) if (check_retval(&retval, "IDAGetQuad", 1)) { return (1); } printf("--------------------------------------------------------\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("G: %12.4Qe \n", Ith(q, 1)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("G: %12.4Le \n", Ith(q, 1)); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("G: %12.4e \n", Ith(q, 1)); #else printf("G: %12.4e \n", Ith(q, 1)); #endif @@ -779,18 +779,18 @@ static int rhsQB(sunrealtype tt, N_Vector yy, N_Vector yp, N_Vector yyB, static void PrintOutput(sunrealtype tfinal, N_Vector yB, N_Vector ypB, N_Vector qB) { printf("--------------------------------------------------------\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("tB0: %12.4Qe\n", tfinal); + printf("dG/dp: %12.4Qe %12.4Qe %12.4Qe\n", -Ith(qB, 1), -Ith(qB, 2), + -Ith(qB, 3)); + printf("lambda(t0): %12.4Qe %12.4Qe %12.4Qe\n", Ith(yB, 1), Ith(yB, 2), + Ith(yB, 3)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("tB0: %12.4Le\n", tfinal); printf("dG/dp: %12.4Le %12.4Le %12.4Le\n", -Ith(qB, 1), -Ith(qB, 2), -Ith(qB, 3)); printf("lambda(t0): %12.4Le %12.4Le %12.4Le\n", Ith(yB, 1), Ith(yB, 2), Ith(yB, 3)); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("tB0: %12.4e\n", tfinal); - printf("dG/dp: %12.4e %12.4e %12.4e\n", -Ith(qB, 1), -Ith(qB, 2), - -Ith(qB, 3)); - printf("lambda(t0): %12.4e %12.4e %12.4e\n", Ith(yB, 1), Ith(yB, 2), - Ith(yB, 3)); #else printf("tB0: %12.4e\n", tfinal); printf("dG/dp: %12.4e %12.4e %12.4e\n", -Ith(qB, 1), -Ith(qB, 2), diff --git a/examples/idas/serial/idasRoberts_ASAi_sps.c b/examples/idas/serial/idasRoberts_ASAi_sps.c index 1e7208200d..064b65706a 100644 --- a/examples/idas/serial/idasRoberts_ASAi_sps.c +++ b/examples/idas/serial/idasRoberts_ASAi_sps.c @@ -294,10 +294,10 @@ int main(int argc, char* argv[]) if (check_retval(&retval, "IDAGetQuad", 1)) { return (1); } printf("--------------------------------------------------------\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("G: %12.4Qe \n", Ith(q, 1)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("G: %12.4Le \n", Ith(q, 1)); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("G: %12.4e \n", Ith(q, 1)); #else printf("G: %12.4e \n", Ith(q, 1)); #endif @@ -780,18 +780,18 @@ static int rhsQB(sunrealtype tt, N_Vector yy, N_Vector yp, N_Vector yyB, static void PrintOutput(sunrealtype tfinal, N_Vector yB, N_Vector ypB, N_Vector qB) { printf("--------------------------------------------------------\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("tB0: %12.4Qe\n", tfinal); + printf("dG/dp: %12.4Qe %12.4Qe %12.4Qe\n", -Ith(qB, 1), -Ith(qB, 2), + -Ith(qB, 3)); + printf("lambda(t0): %12.4Qe %12.4Qe %12.4Qe\n", Ith(yB, 1), Ith(yB, 2), + Ith(yB, 3)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("tB0: %12.4Le\n", tfinal); printf("dG/dp: %12.4Le %12.4Le %12.4Le\n", -Ith(qB, 1), -Ith(qB, 2), -Ith(qB, 3)); printf("lambda(t0): %12.4Le %12.4Le %12.4Le\n", Ith(yB, 1), Ith(yB, 2), Ith(yB, 3)); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("tB0: %12.4e\n", tfinal); - printf("dG/dp: %12.4e %12.4e %12.4e\n", -Ith(qB, 1), -Ith(qB, 2), - -Ith(qB, 3)); - printf("lambda(t0): %12.4e %12.4e %12.4e\n", Ith(yB, 1), Ith(yB, 2), - Ith(yB, 3)); #else printf("tB0: %12.4e\n", tfinal); printf("dG/dp: %12.4e %12.4e %12.4e\n", -Ith(qB, 1), -Ith(qB, 2), diff --git a/examples/idas/serial/idasRoberts_FSA_dns.c b/examples/idas/serial/idasRoberts_FSA_dns.c index c33e0b24dd..2a7936af98 100644 --- a/examples/idas/serial/idasRoberts_FSA_dns.c +++ b/examples/idas/serial/idasRoberts_FSA_dns.c @@ -325,7 +325,9 @@ int main(int argc, char* argv[]) printf("\nQuadrature:\n"); IDAGetQuad(ida_mem, &t, yQ); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("G: %10.4Qe\n", Ith(yQ, 1)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("G: %10.4Le\n", Ith(yQ, 1)); #else printf("G: %10.4e\n", Ith(yQ, 1)); @@ -334,7 +336,12 @@ int main(int argc, char* argv[]) if (sensi) { IDAGetQuadSens(ida_mem, &t, yQS); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("\nSensitivities at t=%Qg:\n", t); + printf("dG/dp1: %11.4Qe\n", Ith(yQS[0], 1)); + printf("dG/dp1: %11.4Qe\n", Ith(yQS[1], 1)); + printf("dG/dp1: %11.4Qe\n", Ith(yQS[2], 1)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("\nSensitivities at t=%Lg:\n", t); printf("dG/dp1: %11.4Le\n", Ith(yQS[0], 1)); printf("dG/dp1: %11.4Le\n", Ith(yQS[1], 1)); @@ -549,7 +556,9 @@ static void PrintIC(N_Vector y, N_Vector yp) data = N_VGetArrayPointer(y); printf("\n\nConsistent IC:\n"); printf("\ty = "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe %12.4Qe \n", data[0], data[1], data[2]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le %12.4Le %12.4Le \n", data[0], data[1], data[2]); #elif defined(SUNDIALS_DOUBLE_PRECISION) printf("%12.4e %12.4e %12.4e \n", data[0], data[1], data[2]); @@ -559,7 +568,9 @@ static void PrintIC(N_Vector y, N_Vector yp) data = N_VGetArrayPointer(yp); printf("\typ= "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe %12.4Qe \n", data[0], data[1], data[2]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le %12.4Le %12.4Le \n", data[0], data[1], data[2]); #elif defined(SUNDIALS_DOUBLE_PRECISION) printf("%12.4e %12.4e %12.4e \n", data[0], data[1], data[2]); @@ -576,19 +587,19 @@ static void PrintSensIC(N_Vector y, N_Vector yp, N_Vector* yS, N_Vector* ypS) printf(" Sensitivity 1 "); printf("\n\ts1 = "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe %12.4Qe \n", sdata[0], sdata[1], sdata[2]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #else printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #endif sdata = N_VGetArrayPointer(ypS[0]); printf("\ts1'= "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe %12.4Qe \n", sdata[0], sdata[1], sdata[2]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #else printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #endif @@ -596,19 +607,19 @@ static void PrintSensIC(N_Vector y, N_Vector yp, N_Vector* yS, N_Vector* ypS) printf(" Sensitivity 2 "); sdata = N_VGetArrayPointer(yS[1]); printf("\n\ts2 = "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe %12.4Qe \n", sdata[0], sdata[1], sdata[2]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #else printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #endif sdata = N_VGetArrayPointer(ypS[1]); printf("\ts2'= "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe %12.4Qe \n", sdata[0], sdata[1], sdata[2]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #else printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #endif @@ -616,19 +627,19 @@ static void PrintSensIC(N_Vector y, N_Vector yp, N_Vector* yS, N_Vector* ypS) printf(" Sensitivity 3 "); sdata = N_VGetArrayPointer(yS[2]); printf("\n\ts3 = "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe %12.4Qe \n", sdata[0], sdata[1], sdata[2]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #else printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #endif sdata = N_VGetArrayPointer(ypS[2]); printf("\ts3'= "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe %12.4Qe \n", sdata[0], sdata[1], sdata[2]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #else printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #endif @@ -653,20 +664,20 @@ static void PrintOutput(void* ida_mem, sunrealtype t, N_Vector u) retval = IDAGetLastStep(ida_mem, &hu); check_retval(&retval, "IDAGetLastStep", 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%8.3Qe %2d %8.3Qe %5ld\n", t, qu, hu, nst); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%8.3Le %2d %8.3Le %5ld\n", t, qu, hu, nst); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%8.3e %2d %8.3e %5ld\n", t, qu, hu, nst); #else printf("%8.3e %2d %8.3e %5ld\n", t, qu, hu, nst); #endif printf(" Solution "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe %12.4Qe \n", udata[0], udata[1], udata[2]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le %12.4Le %12.4Le \n", udata[0], udata[1], udata[2]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e %12.4e \n", udata[0], udata[1], udata[2]); #else printf("%12.4e %12.4e %12.4e \n", udata[0], udata[1], udata[2]); #endif @@ -683,10 +694,10 @@ static void PrintSensOutput(N_Vector* uS) sdata = N_VGetArrayPointer(uS[0]); printf(" Sensitivity 1 "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe %12.4Qe \n", sdata[0], sdata[1], sdata[2]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #else printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #endif @@ -694,10 +705,10 @@ static void PrintSensOutput(N_Vector* uS) sdata = N_VGetArrayPointer(uS[1]); printf(" Sensitivity 2 "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe %12.4Qe \n", sdata[0], sdata[1], sdata[2]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #else printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #endif @@ -705,10 +716,10 @@ static void PrintSensOutput(N_Vector* uS) sdata = N_VGetArrayPointer(uS[2]); printf(" Sensitivity 3 "); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%12.4Qe %12.4Qe %12.4Qe \n", sdata[0], sdata[1], sdata[2]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #else printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]); #endif diff --git a/examples/idas/serial/idasRoberts_FSA_klu.c b/examples/idas/serial/idasRoberts_FSA_klu.c index 281c43275f..7d8c8f4074 100644 --- a/examples/idas/serial/idasRoberts_FSA_klu.c +++ b/examples/idas/serial/idasRoberts_FSA_klu.c @@ -334,7 +334,9 @@ int main(int argc, char* argv[]) printf("\nQuadrature:\n"); IDAGetQuad(ida_mem, &t, yQ); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("G: %10.4Qe\n", Ith(yQ, 1)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("G: %10.4Le\n", Ith(yQ, 1)); #else printf("G: %10.4e\n", Ith(yQ, 1)); @@ -343,7 +345,12 @@ int main(int argc, char* argv[]) if (sensi) { IDAGetQuadSens(ida_mem, &t, yQS); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("\nSensitivities at t=%Qg:\n", t); + printf("dG/dp1: %11.4Qe\n", Ith(yQS[0], 1)); + printf("dG/dp1: %11.4Qe\n", Ith(yQS[1], 1)); + printf("dG/dp1: %11.4Qe\n", Ith(yQS[2], 1)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("\nSensitivities at t=%Lg:\n", t); printf("dG/dp1: %11.4Le\n", Ith(yQS[0], 1)); printf("dG/dp1: %11.4Le\n", Ith(yQS[1], 1)); diff --git a/examples/idas/serial/idasRoberts_dns.c b/examples/idas/serial/idasRoberts_dns.c index 23ca06b6dc..1e09f73b1c 100644 --- a/examples/idas/serial/idasRoberts_dns.c +++ b/examples/idas/serial/idasRoberts_dns.c @@ -45,7 +45,9 @@ #include /* access to dense SUNMatrix */ #include /* access to Newton SUNNonlinearSolver */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #else #define GSYM "g" @@ -331,14 +333,14 @@ static void PrintHeader(sunrealtype rtol, N_Vector avtol, N_Vector y) "IDA.\n"); printf(" Three equation chemical kinetics problem.\n\n"); printf("Linear solver: DENSE, with user-supplied Jacobian.\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg %Qg %Qg \n", rtol, + atval[0], atval[1], atval[2]); + printf("Initial conditions y0 = (%Qg %Qg %Qg)\n", yval[0], yval[1], yval[2]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg %Lg %Lg \n", rtol, atval[0], atval[1], atval[2]); printf("Initial conditions y0 = (%Lg %Lg %Lg)\n", yval[0], yval[1], yval[2]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: rtol = %g atol = %g %g %g \n", rtol, - atval[0], atval[1], atval[2]); - printf("Initial conditions y0 = (%g %g %g)\n", yval[0], yval[1], yval[2]); #else printf("Tolerance parameters: rtol = %g atol = %g %g %g \n", rtol, atval[0], atval[1], atval[2]); @@ -372,11 +374,11 @@ static void PrintOutput(void* mem, sunrealtype t, N_Vector y) check_retval(&retval, "IDAGetNumSteps", 1); retval = IDAGetLastStep(mem, &hused); check_retval(&retval, "IDAGetLastStep", 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) - printf("%10.4Le %12.4Le %12.4Le %12.4Le | %3ld %1d %12.4Le\n", t, yval[0], +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%10.4Qe %12.4Qe %12.4Qe %12.4Qe | %3ld %1d %12.4Qe\n", t, yval[0], yval[1], yval[2], nst, kused, hused); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%10.4e %12.4e %12.4e %12.4e | %3ld %1d %12.4e\n", t, yval[0], +#elif defined(SUNDIALS_EXTENDED_PRECISION) + printf("%10.4Le %12.4Le %12.4Le %12.4Le | %3ld %1d %12.4Le\n", t, yval[0], yval[1], yval[2], nst, kused, hused); #else printf("%10.4e %12.4e %12.4e %12.4e | %3ld %1d %12.4e\n", t, yval[0], diff --git a/examples/idas/serial/idasRoberts_klu.c b/examples/idas/serial/idasRoberts_klu.c index 6fdf0a415d..61407f3a04 100644 --- a/examples/idas/serial/idasRoberts_klu.c +++ b/examples/idas/serial/idasRoberts_klu.c @@ -374,14 +374,14 @@ static void PrintHeader(sunrealtype rtol, N_Vector avtol, N_Vector y) "IDA.\n"); printf(" Three equation chemical kinetics problem.\n\n"); printf("Linear solver: KLU, with user-supplied Jacobian.\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg %Qg %Qg \n", rtol, + atval[0], atval[1], atval[2]); + printf("Initial conditions y0 = (%Qg %Qg %Qg)\n", yval[0], yval[1], yval[2]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg %Lg %Lg \n", rtol, atval[0], atval[1], atval[2]); printf("Initial conditions y0 = (%Lg %Lg %Lg)\n", yval[0], yval[1], yval[2]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: rtol = %g atol = %g %g %g \n", rtol, - atval[0], atval[1], atval[2]); - printf("Initial conditions y0 = (%g %g %g)\n", yval[0], yval[1], yval[2]); #else printf("Tolerance parameters: rtol = %g atol = %g %g %g \n", rtol, atval[0], atval[1], atval[2]); @@ -415,11 +415,11 @@ static void PrintOutput(void* mem, sunrealtype t, N_Vector y) check_retval(&retval, "IDAGetNumSteps", 1); retval = IDAGetLastStep(mem, &hused); check_retval(&retval, "IDAGetLastStep", 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) - printf("%10.4Le %12.4Le %12.4Le %12.4Le | %3ld %1d %12.4Le\n", t, yval[0], +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%10.4Qe %12.4Qe %12.4Qe %12.4Qe | %3ld %1d %12.4Qe\n", t, yval[0], yval[1], yval[2], nst, kused, hused); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%10.4e %12.4e %12.4e %12.4e | %3ld %1d %12.4e\n", t, yval[0], +#elif defined(SUNDIALS_EXTENDED_PRECISION) + printf("%10.4Le %12.4Le %12.4Le %12.4Le | %3ld %1d %12.4Le\n", t, yval[0], yval[1], yval[2], nst, kused, hused); #else printf("%10.4e %12.4e %12.4e %12.4e | %3ld %1d %12.4e\n", t, yval[0], diff --git a/examples/idas/serial/idasRoberts_sps.c b/examples/idas/serial/idasRoberts_sps.c index 1b524f6e99..42af284618 100644 --- a/examples/idas/serial/idasRoberts_sps.c +++ b/examples/idas/serial/idasRoberts_sps.c @@ -322,14 +322,14 @@ static void PrintHeader(sunrealtype rtol, N_Vector avtol, N_Vector y) "IDA.\n"); printf(" Three equation chemical kinetics problem.\n\n"); printf("Linear solver: SUPERLUMT, with user-supplied Jacobian.\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) - printf("Tolerance parameters: rtol = %Lg atol = %Lg %Lg %Lg \n", rtol, +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg %Qg %Qg \n", rtol, atval[0], atval[1], atval[2]); printf("Initial conditions y0 = (%Lg %Lg %Lg)\n", yval[0], yval[1], yval[2]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: rtol = %g atol = %g %g %g \n", rtol, +#elif defined(SUNDIALS_EXTENDED_PRECISION) + printf("Tolerance parameters: rtol = %Lg atol = %Lg %Lg %Lg \n", rtol, atval[0], atval[1], atval[2]); - printf("Initial conditions y0 = (%g %g %g)\n", yval[0], yval[1], yval[2]); + printf("Initial conditions y0 = (%Lg %Lg %Lg)\n", yval[0], yval[1], yval[2]); #else printf("Tolerance parameters: rtol = %g atol = %g %g %g \n", rtol, atval[0], atval[1], atval[2]); diff --git a/examples/idas/serial/idasSlCrank_FSA_dns.c b/examples/idas/serial/idasSlCrank_FSA_dns.c index 4f2fe39036..f1d9694958 100644 --- a/examples/idas/serial/idasSlCrank_FSA_dns.c +++ b/examples/idas/serial/idasSlCrank_FSA_dns.c @@ -129,15 +129,15 @@ int main(void) data = (UserData)malloc(sizeof *data); - data->a = 0.5; /* half-length of crank */ - data->J1 = 1.0; /* crank moment of inertia */ - data->m2 = 1.0; /* mass of connecting rod */ - data->m1 = 1.0; - data->J2 = 2.0; /* moment of inertia of connecting rod */ - data->params[0] = 1.0; /* spring constant */ - data->params[1] = 1.0; /* damper constant */ - data->l0 = 1.0; /* spring free length */ - data->F = 1.0; /* external constant force */ + data->a = SUN_RCONST(0.5); /* half-length of crank */ + data->J1 = SUN_RCONST(1.0); /* crank moment of inertia */ + data->m2 = SUN_RCONST(1.0); /* mass of connecting rod */ + data->m1 = SUN_RCONST(1.0); + data->J2 = SUN_RCONST(2.0); /* moment of inertia of connecting rod */ + data->params[0] = SUN_RCONST(1.0); /* spring constant */ + data->params[1] = SUN_RCONST(1.0); /* damper constant */ + data->l0 = SUN_RCONST(1.0); /* spring free length */ + data->F = SUN_RCONST(1.0); /* external constant force */ N_VConst(ONE, id); NV_Ith_S(id, 9) = ZERO; @@ -208,7 +208,9 @@ int main(void) IDAGetQuad(mem, &tret, q); printf("--------------------------------------------\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" G = %24.16Qf\n", Ith(q, 1)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" G = %24.16Lf\n", Ith(q, 1)); #else printf(" G = %24.16f\n", Ith(q, 1)); @@ -217,7 +219,9 @@ int main(void) IDAGetQuadSens(mem, &tret, qS); printf("-------------F O R W A R D------------------\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" dG/dp: %12.4Qe %12.4Qe\n", Ith(qS[0], 1), Ith(qS[1], 1)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" dG/dp: %12.4Le %12.4Le\n", Ith(qS[0], 1), Ith(qS[1], 1)); #else printf(" dG/dp: %12.4e %12.4e\n", Ith(qS[0], 1), Ith(qS[1], 1)); @@ -328,7 +332,9 @@ int main(void) printf("\n\n Checking using Finite Differences \n\n"); printf("---------------BACKWARD------------------\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" dG/dp: %12.4Qe %12.4Qe\n", (G - Gm[0]) / dp, (G - Gm[1]) / dp); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" dG/dp: %12.4Le %12.4Le\n", (G - Gm[0]) / dp, (G - Gm[1]) / dp); #else printf(" dG/dp: %12.4e %12.4e\n", (G - Gm[0]) / dp, (G - Gm[1]) / dp); @@ -336,7 +342,9 @@ int main(void) printf("-----------------------------------------\n\n"); printf("---------------FORWARD-------------------\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" dG/dp: %12.4Qe %12.4Qe\n", (Gp[0] - G) / dp, (Gp[1] - G) / dp); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" dG/dp: %12.4Le %12.4Le\n", (Gp[0] - G) / dp, (Gp[1] - G) / dp); #else printf(" dG/dp: %12.4e %12.4e\n", (Gp[0] - G) / dp, (Gp[1] - G) / dp); @@ -344,7 +352,10 @@ int main(void) printf("-----------------------------------------\n\n"); printf("--------------CENTERED-------------------\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" dG/dp: %12.4Qe %12.4Qe\n", (Gp[0] - Gm[0]) / (TWO * dp), + (Gp[1] - Gm[1]) / (TWO * dp)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" dG/dp: %12.4Le %12.4Le\n", (Gp[0] - Gm[0]) / (TWO * dp), (Gp[1] - Gm[1]) / (TWO * dp)); #else @@ -380,7 +391,7 @@ static void setIC(N_Vector yy, N_Vector yp, UserData data) N_VConst(ZERO, yy); N_VConst(ZERO, yp); - pi = FOUR * atan(ONE); + pi = FOUR * SUNRatan(ONE); a = data->a; J1 = data->J1; @@ -388,8 +399,8 @@ static void setIC(N_Vector yy, N_Vector yp, UserData data) J2 = data->J2; q = pi / TWO; - p = asin(-a); - x = cos(p); + p = SUNRasin(-a); + x = SUNRcos(p); NV_Ith_S(yy, 0) = q; NV_Ith_S(yy, 1) = x; @@ -425,15 +436,15 @@ static void force(N_Vector yy, sunrealtype* Q, UserData data) xd = NV_Ith_S(yy, 4); pd = NV_Ith_S(yy, 5); - s1 = sin(q); - c1 = cos(q); - s2 = sin(p); - c2 = cos(p); + s1 = SUNRsin(q); + c1 = SUNRcos(q); + s2 = SUNRsin(p); + c2 = SUNRcos(p); s21 = s2 * c1 - c2 * s1; c21 = c2 * c1 + s2 * s1; l2 = x * x - x * (c2 + a * c1) + (ONE + a * a) / FOUR + a * c21 / TWO; - l = sqrt(l2); + l = SUNRsqrt(l2); ld = TWO * x * xd - xd * (c2 + a * c1) + x * (s2 * pd + a * s1 * qd) - a * s21 * (pd - qd) / TWO; ld /= TWO * l; @@ -483,10 +494,10 @@ static int ressc(sunrealtype tres, N_Vector yy, N_Vector yp, N_Vector rr, mu1 = yval[8]; mu2 = yval[9]; - s1 = sin(q); - c1 = cos(q); - s2 = sin(p); - c2 = cos(p); + s1 = SUNRsin(q); + c1 = SUNRcos(q); + s2 = SUNRsin(p); + c2 = SUNRcos(p); force(yy, Q, data); diff --git a/examples/idas/serial/idasSlCrank_dns.c b/examples/idas/serial/idasSlCrank_dns.c index a71107cf09..4783d8bd6e 100644 --- a/examples/idas/serial/idasSlCrank_dns.c +++ b/examples/idas/serial/idasSlCrank_dns.c @@ -188,7 +188,9 @@ int main(void) IDAGetQuad(mem, &tret, q); printf("--------------------------------------------\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" G = %24.16Qf\n", Ith(q, 1)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" G = %24.16Lf\n", Ith(q, 1)); #else printf(" G = %24.16f\n", Ith(q, 1)); @@ -374,10 +376,10 @@ static void PrintHeader(sunrealtype rtol, sunrealtype avtol, N_Vector y) printf( "\nidasSlCrank_dns: Slider-Crank DAE serial example problem for IDAS\n"); printf("Linear solver: DENSE, Jacobian is computed by IDAS.\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: rtol = %Qg atol = %Qg\n", rtol, avtol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: rtol = %Lg atol = %Lg\n", rtol, avtol); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, avtol); #else printf("Tolerance parameters: rtol = %g atol = %g\n", rtol, avtol); #endif @@ -404,12 +406,12 @@ static void PrintOutput(void* mem, sunrealtype t, N_Vector y) check_retval(&retval, "IDAGetNumSteps", 1); retval = IDAGetLastStep(mem, &hused); check_retval(&retval, "IDAGetLastStep", 1); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%5.2Qf %12.4Qe %12.4Qe %12.4Qe | %3ld %1d %12.4Qe\n", t, yval[0], + yval[1], yval[2], nst, kused, hused); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%5.2Lf %12.4Le %12.4Le %12.4Le | %3ld %1d %12.4Le\n", t, yval[0], yval[1], yval[2], nst, kused, hused); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%5.2f %12.4e %12.4e %12.4e | %3ld %1d %12.4e\n", t, yval[0], yval[1], - yval[2], nst, kused, hused); #else printf("%5.2f %12.4e %12.4e %12.4e | %3ld %1d %12.4e\n", t, yval[0], yval[1], yval[2], nst, kused, hused); diff --git a/examples/kinsol/CUDA_mpi/kin_em_mpicuda.cu b/examples/kinsol/CUDA_mpi/kin_em_mpicuda.cu index 4f01719f84..35f14b74e3 100644 --- a/examples/kinsol/CUDA_mpi/kin_em_mpicuda.cu +++ b/examples/kinsol/CUDA_mpi/kin_em_mpicuda.cu @@ -896,7 +896,7 @@ static int OpenOutput(UserData* udata) udata->rout.open(fname.str()); udata->rout << scientific; - udata->rout << setprecision(numeric_limits::digits10); + udata->rout << setprecision(SUN_DIGITS10); // Open output stream for error fname.str(""); @@ -906,7 +906,7 @@ static int OpenOutput(UserData* udata) udata->eout.open(fname.str()); udata->eout << scientific; - udata->eout << setprecision(numeric_limits::digits10); + udata->eout << setprecision(SUN_DIGITS10); } return 0; diff --git a/examples/kinsol/CXX_parallel/kin_em_p.cpp b/examples/kinsol/CXX_parallel/kin_em_p.cpp index 41bba63d68..8695cb6ad9 100644 --- a/examples/kinsol/CXX_parallel/kin_em_p.cpp +++ b/examples/kinsol/CXX_parallel/kin_em_p.cpp @@ -360,7 +360,7 @@ static int FPFunction(N_Vector u, N_Vector f, void* user_data) static int SetupSamples(UserData* udata) { sunindextype i, j, start, end; - sunrealtype mean, val; + double mean, val; // Access problem data sunrealtype* samples_local = N_VGetArrayPointer(udata->samples_local); @@ -370,7 +370,7 @@ static int SetupSamples(UserData* udata) N_VGetArrayPointer(N_VGetLocalVector_MPIPlusX(udata->mu_true)); if (check_retval((void*)mu_host, "N_VGetArrayPointer", 0)) { return 1; } - sunrealtype std_dev = ONE; + double std_dev = 1.0; for (i = 0; i < 3; i++) { @@ -391,13 +391,13 @@ static int SetupSamples(UserData* udata) // Setup distribution parameters mean = mu_host[i]; std::default_random_engine generator; - std::normal_distribution distribution(mean, std_dev); + std::normal_distribution distribution(mean, std_dev); // Get samples for (j = start; j < end; j++) { val = distribution(generator); - samples_local[j] = val; + samples_local[j] = (sunrealtype)val; } } @@ -452,7 +452,7 @@ static int EM(N_Vector u, N_Vector f, void* user_data) // -------------- // Scale value for functions - sunrealtype scale = ONE / sqrt(TWO * PI); + sunrealtype scale = ONE / SUNRsqrt(TWO * PI); // Get input pointers sunrealtype* u_host = N_VGetArrayPointer(N_VGetLocalVector_MPIPlusX(u)); @@ -472,9 +472,9 @@ static int EM(N_Vector u, N_Vector f, void* user_data) val2 = x_host[i] - u_host[1]; val3 = x_host[i] - u_host[2]; - px_host[i] = a1 * scale * exp(-(val1 * val1) / TWO); - px_host[i] += a2 * scale * exp(-(val2 * val2) / TWO); - px_host[i] += a3 * scale * exp(-(val3 * val3) / TWO); + px_host[i] = a1 * scale * SUNRexp(-(val1 * val1) / TWO); + px_host[i] += a2 * scale * SUNRexp(-(val2 * val2) / TWO); + px_host[i] += a3 * scale * SUNRexp(-(val3 * val3) / TWO); } // -------------- @@ -503,9 +503,9 @@ static int EM(N_Vector u, N_Vector f, void* user_data) val2 = x_host[i] - u_host[1]; val3 = x_host[i] - u_host[2]; - frac1 = a1 * scale * exp(-(val1 * val1) / TWO) / px_host[i]; - frac2 = a2 * scale * exp(-(val2 * val2) / TWO) / px_host[i]; - frac3 = a3 * scale * exp(-(val3 * val3) / TWO) / px_host[i]; + frac1 = a1 * scale * SUNRexp(-(val1 * val1) / TWO) / px_host[i]; + frac2 = a2 * scale * SUNRexp(-(val2 * val2) / TWO) / px_host[i]; + frac3 = a3 * scale * SUNRexp(-(val3 * val3) / TWO) / px_host[i]; mut_host[0] += x_host[i] * frac1; mut_host[1] += x_host[i] * frac2; @@ -844,7 +844,7 @@ static int OpenOutput(UserData* udata) udata->rout.open(fname.str()); udata->rout << scientific; - udata->rout << setprecision(numeric_limits::digits10); + udata->rout << setprecision(SUN_DIGITS10); // Open output stream for error fname.str(""); @@ -854,7 +854,7 @@ static int OpenOutput(UserData* udata) udata->eout.open(fname.str()); udata->eout << scientific; - udata->eout << setprecision(numeric_limits::digits10); + udata->eout << setprecision(SUN_DIGITS10); } return 0; diff --git a/examples/kinsol/CXX_parallel/kin_em_p.hpp b/examples/kinsol/CXX_parallel/kin_em_p.hpp index 1c06df8359..a7190cab93 100644 --- a/examples/kinsol/CXX_parallel/kin_em_p.hpp +++ b/examples/kinsol/CXX_parallel/kin_em_p.hpp @@ -79,11 +79,11 @@ struct UserData int myid; // process ID in communicator // Fixed Point Solver settings - sunrealtype rtol; // relative tolerance - int maa; // m for Anderson Acceleration - double damping; // damping for Anderson Acceleration - int orthaa; // orthogonalization routine for AA - int maxits; // max number of fixed point iterations + sunrealtype rtol; // relative tolerance + int maa; // m for Anderson Acceleration + sunrealtype damping; // damping for Anderson Acceleration + int orthaa; // orthogonalization routine for AA + int maxits; // max number of fixed point iterations // Vectors to help with FPFunction definition and execution N_Vector samples_local; // vector containing distribution samples diff --git a/examples/kinsol/CXX_parallel/kin_heat2D_nonlin_p.cpp b/examples/kinsol/CXX_parallel/kin_heat2D_nonlin_p.cpp index ca8f564308..2b7716dfd2 100644 --- a/examples/kinsol/CXX_parallel/kin_heat2D_nonlin_p.cpp +++ b/examples/kinsol/CXX_parallel/kin_heat2D_nonlin_p.cpp @@ -247,7 +247,7 @@ int main(int argc, char* argv[]) if (outproc) { cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << " Max error = " << maxerr << endl; cout << endl; } @@ -730,11 +730,11 @@ static int SetupRHS(void* user_data) x = (udata->is + i) * udata->dx; y = (udata->js + j) * udata->dy; - sin_sqr_x = sin(PI * x) * sin(PI * x); - sin_sqr_y = sin(PI * y) * sin(PI * y); + sin_sqr_x = SUNRsin(PI * x) * SUNRsin(PI * x); + sin_sqr_y = SUNRsin(PI * y) * SUNRsin(PI * y); - cos_sqr_x = cos(PI * x) * cos(PI * x); - cos_sqr_y = cos(PI * y) * cos(PI * y); + cos_sqr_x = SUNRcos(PI * x) * SUNRcos(PI * x); + cos_sqr_y = SUNRcos(PI * y) * SUNRcos(PI * y); barray[IDX(i, j, nx_loc)] = bx * (cos_sqr_x - sin_sqr_x) * sin_sqr_y + by * (cos_sqr_y - sin_sqr_y) * sin_sqr_x; @@ -1269,8 +1269,8 @@ static int Solution(N_Vector u, UserData* udata) x = (udata->is + i) * udata->dx; y = (udata->js + j) * udata->dy; - sin_sqr_x = sin(PI * x) * sin(PI * x); - sin_sqr_y = sin(PI * y) * sin(PI * y); + sin_sqr_x = SUNRsin(PI * x) * SUNRsin(PI * x); + sin_sqr_y = SUNRsin(PI * y) * SUNRsin(PI * y); uarray[IDX(i, j, udata->nx_loc)] = sin_sqr_x * sin_sqr_y; } @@ -1448,7 +1448,7 @@ static int WriteSolution(N_Vector u, UserData* udata) udata->uout.open(fname.str()); udata->uout << scientific; - udata->uout << setprecision(numeric_limits::digits10); + udata->uout << setprecision(SUN_DIGITS10); // Write solution and error to disk sunrealtype* uarray = N_VGetArrayPointer(u); @@ -1482,7 +1482,7 @@ static int OpenOutput(UserData* udata) udata->rout.open(fname.str()); udata->rout << scientific; - udata->rout << setprecision(numeric_limits::digits10); + udata->rout << setprecision(SUN_DIGITS10); // Open output stream for error fname.str(""); @@ -1491,7 +1491,7 @@ static int OpenOutput(UserData* udata) udata->eout.open(fname.str()); udata->eout << scientific; - udata->eout << setprecision(numeric_limits::digits10); + udata->eout << setprecision(SUN_DIGITS10); } return 0; @@ -1515,11 +1515,11 @@ static int WriteOutput(N_Vector u, N_Vector f, UserData* udata) if (outproc) { // Output residual - udata->rout << sqrt(res); + udata->rout << SUNRsqrt(res); udata->rout << endl; // Output error - udata->eout << sqrt(err); + udata->eout << SUNRsqrt(err); udata->eout << endl; } diff --git a/examples/kinsol/CXX_parallel/kin_heat2D_nonlin_p.hpp b/examples/kinsol/CXX_parallel/kin_heat2D_nonlin_p.hpp index 14f8c8084a..b32ae85597 100644 --- a/examples/kinsol/CXX_parallel/kin_heat2D_nonlin_p.hpp +++ b/examples/kinsol/CXX_parallel/kin_heat2D_nonlin_p.hpp @@ -131,11 +131,11 @@ struct UserData MPI_Request reqSN; // Fixed Point Solver settings - sunrealtype rtol; // relative tolerance - int maa; // m for Anderson Acceleration - double damping; // damping for Anderson Acceleration - int orthaa; // orthogonalization routine for AA - int maxits; // max number of fixed point iterations + sunrealtype rtol; // relative tolerance + int maa; // m for Anderson Acceleration + sunrealtype damping; // damping for Anderson Acceleration + int orthaa; // orthogonalization routine for AA + int maxits; // max number of fixed point iterations // c(u) Function and integer for help setting cFn c; @@ -250,7 +250,7 @@ static sunrealtype c2(sunrealtype u_val) static sunrealtype c3(sunrealtype u_val) { return u_val - u_val * u_val; } // c(u) = e^u -static sunrealtype c4(sunrealtype u_val) { return exp(u_val); } +static sunrealtype c4(sunrealtype u_val) { return SUNRexp(u_val); } // c(u) = u^4 static sunrealtype c5(sunrealtype u_val) @@ -261,27 +261,28 @@ static sunrealtype c5(sunrealtype u_val) // c(u) = cos^2(u) - sin^2(u) static sunrealtype c6(sunrealtype u_val) { - return (cos(u_val) * cos(u_val)) - (sin(u_val) * sin(u_val)); + return (SUNRcos(u_val) * SUNRcos(u_val)) - (SUNRsin(u_val) * SUNRsin(u_val)); } // c(u) = cos^2(u) - sin^2(u) - e^u static sunrealtype c7(sunrealtype u_val) { - return (cos(u_val) * cos(u_val)) - (sin(u_val) * sin(u_val)) - exp(u_val); + return (SUNRcos(u_val) * SUNRcos(u_val)) - (SUNRsin(u_val) * SUNRsin(u_val)) - + SUNRexp(u_val); } // c(u) = e^u * u^4 - u * e^{cos(u)} static sunrealtype c8(sunrealtype u_val) { sunrealtype u2 = u_val * u_val; - return exp(u_val) * u2 * u2 - u_val * exp(cos(u_val)); + return SUNRexp(u_val) * u2 * u2 - u_val * SUNRexp(SUNRcos(u_val)); } // c(u) = e^(cos^2(u)) static sunrealtype c9(sunrealtype u_val) { - sunrealtype cos2u = cos(u_val) * cos(u_val); - return exp(cos2u); + sunrealtype cos2u = SUNRcos(u_val) * SUNRcos(u_val); + return SUNRexp(cos2u); } // c(u) = 10(u - u^2) @@ -301,7 +302,7 @@ static sunrealtype c11(sunrealtype u_val) // c(u) = sqrt(5) * (u - u^2) static sunrealtype c12(sunrealtype u_val) { - sunrealtype temp = sqrt(5); + sunrealtype temp = SUNRsqrt(5); sunrealtype u2 = u_val * u_val; return temp * (u_val - u2); } @@ -309,45 +310,45 @@ static sunrealtype c12(sunrealtype u_val) // c(u) = (u - e^u)^2 + (u + u * sin(u) - cos(u))^2 static sunrealtype c13(sunrealtype u_val) { - sunrealtype eu = u_val - exp(u_val); - sunrealtype usin = u_val * sin(u_val); - sunrealtype temp = (u_val + usin - cos(u_val)); + sunrealtype eu = u_val - SUNRexp(u_val); + sunrealtype usin = u_val * SUNRsin(u_val); + sunrealtype temp = (u_val + usin - SUNRcos(u_val)); return eu * eu + temp * temp; } // c(u) = u + ue^u + ue^{-u} static sunrealtype c14(sunrealtype u_val) { - sunrealtype ueu = u_val * exp(u_val); - sunrealtype ue_u = u_val * exp(-u_val); + sunrealtype ueu = u_val * SUNRexp(u_val); + sunrealtype ue_u = u_val * SUNRexp(-u_val); return u_val + ueu + ue_u; } // c(u) = u + ue^u + ue^{-u} + (u - e^u)^2 static sunrealtype c15(sunrealtype u_val) { - sunrealtype ueu = u_val * exp(u_val); - sunrealtype ue_u = u_val * exp(-u_val); - sunrealtype temp = u_val - exp(u_val); + sunrealtype ueu = u_val * SUNRexp(u_val); + sunrealtype ue_u = u_val * SUNRexp(-u_val); + sunrealtype temp = u_val - SUNRexp(u_val); return u_val + ueu + ue_u + (temp * temp); } // c(u) = u + ue^u + ue^{-u} + (u - e^u)^2 + (u + usin(u) - cos(u))^2 static sunrealtype c16(sunrealtype u_val) { - sunrealtype ueu = u_val * exp(u_val); - sunrealtype ue_u = u_val * exp(-u_val); - sunrealtype temp = u_val - exp(u_val); - sunrealtype temp2 = u_val + (u_val * sin(u_val)) - cos(u_val); + sunrealtype ueu = u_val * SUNRexp(u_val); + sunrealtype ue_u = u_val * SUNRexp(-u_val); + sunrealtype temp = u_val - SUNRexp(u_val); + sunrealtype temp2 = u_val + (u_val * SUNRsin(u_val)) - SUNRcos(u_val); return u_val + ueu + ue_u + (temp * temp) + (temp2 * temp2); } // c(u) = u + ue^{-u} + e^u*(u + sin(u) - cos(u))^3 static sunrealtype c17(sunrealtype u_val) { - sunrealtype ue_u = u_val * exp(-u_val); - sunrealtype eu = exp(u_val); - sunrealtype temp = u_val + sin(u_val) - cos(u_val); + sunrealtype ue_u = u_val * SUNRexp(-u_val); + sunrealtype eu = SUNRexp(u_val); + sunrealtype temp = u_val + SUNRsin(u_val) - SUNRcos(u_val); return u_val + ue_u + eu * (temp * temp * temp); } diff --git a/examples/kinsol/CXX_parhyp/kin_bratu2D_hypre_pfmg.cpp b/examples/kinsol/CXX_parhyp/kin_bratu2D_hypre_pfmg.cpp index 409f175201..e1ce3a2746 100644 --- a/examples/kinsol/CXX_parhyp/kin_bratu2D_hypre_pfmg.cpp +++ b/examples/kinsol/CXX_parhyp/kin_bratu2D_hypre_pfmg.cpp @@ -1676,7 +1676,7 @@ static int WriteSolution(N_Vector u, UserData* udata) udata->uout.open(fname.str()); udata->uout << scientific; - udata->uout << setprecision(numeric_limits::digits10); + udata->uout << setprecision(SUN_DIGITS10); // Write solution and error to disk sunrealtype* uarray = N_VGetArrayPointer(u); @@ -1709,7 +1709,7 @@ static int OpenResOutput(UserData* udata) udata->rout.open(fname.str()); udata->rout << scientific; - udata->rout << setprecision(numeric_limits::digits10); + udata->rout << setprecision(SUN_DIGITS10); } return 0; diff --git a/examples/kinsol/CXX_parhyp/kin_heat2D_nonlin_hypre_pfmg.cpp b/examples/kinsol/CXX_parhyp/kin_heat2D_nonlin_hypre_pfmg.cpp index 7e2960632e..0f29fbdd10 100644 --- a/examples/kinsol/CXX_parhyp/kin_heat2D_nonlin_hypre_pfmg.cpp +++ b/examples/kinsol/CXX_parhyp/kin_heat2D_nonlin_hypre_pfmg.cpp @@ -268,7 +268,7 @@ int main(int argc, char* argv[]) if (outproc) { cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << " Max error = " << maxerr << endl; } @@ -1945,7 +1945,7 @@ static int WriteSolution(N_Vector u, UserData* udata) udata->uout.open(fname.str()); udata->uout << scientific; - udata->uout << setprecision(numeric_limits::digits10); + udata->uout << setprecision(SUN_DIGITS10); // Write solution and error to disk sunrealtype* uarray = N_VGetArrayPointer(u); @@ -1978,7 +1978,7 @@ static int OpenOutput(UserData* udata) udata->rout.open(fname.str()); udata->rout << scientific; - udata->rout << setprecision(numeric_limits::digits10); + udata->rout << setprecision(SUN_DIGITS10); // Open output stream for error fname.str(""); @@ -1987,7 +1987,7 @@ static int OpenOutput(UserData* udata) udata->eout.open(fname.str()); udata->eout << scientific; - udata->eout << setprecision(numeric_limits::digits10); + udata->eout << setprecision(SUN_DIGITS10); } return 0; diff --git a/examples/kinsol/C_openmp/kinFoodWeb_kry_omp.c b/examples/kinsol/C_openmp/kinFoodWeb_kry_omp.c index 43f63f3142..eff8efaabf 100644 --- a/examples/kinsol/C_openmp/kinFoodWeb_kry_omp.c +++ b/examples/kinsol/C_openmp/kinFoodWeb_kry_omp.c @@ -726,11 +726,11 @@ static void PrintHeader(int globalstrategy, int maxl, int maxlrst, printf("Linear solver is SPGMR with maxl = %d, maxlrst = %d\n", maxl, maxlrst); printf("Preconditioning uses interaction-only block-diagonal matrix\n"); printf("Positivity constraints imposed on all components \n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) - printf("Tolerance parameters: fnormtol = %Lg scsteptol = %Lg\n", fnormtol, +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: fnormtol = %Qg scsteptol = %Qg\n", fnormtol, scsteptol); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: fnormtol = %g scsteptol = %g\n", fnormtol, +#elif defined(SUNDIALS_EXTENDED_PRECISION) + printf("Tolerance parameters: fnormtol = %Lg scsteptol = %Lg\n", fnormtol, scsteptol); #else printf("Tolerance parameters: fnormtol = %g scsteptol = %g\n", fnormtol, @@ -738,12 +738,12 @@ static void PrintHeader(int globalstrategy, int maxl, int maxlrst, #endif printf("\nInitial profile of concentration\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("At all mesh points: %Qg %Qg %Qg %Qg %Qg %Qg\n", PREYIN, PREYIN, + PREYIN, PREDIN, PREDIN, PREDIN); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("At all mesh points: %Lg %Lg %Lg %Lg %Lg %Lg\n", PREYIN, PREYIN, PREYIN, PREDIN, PREDIN, PREDIN); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("At all mesh points: %g %g %g %g %g %g\n", PREYIN, PREYIN, PREYIN, - PREDIN, PREDIN, PREDIN); #else printf("At all mesh points: %g %g %g %g %g %g\n", PREYIN, PREYIN, PREYIN, PREDIN, PREDIN, PREDIN); @@ -768,10 +768,10 @@ static void PrintOutput(N_Vector cc) for (is = 0; is < NUM_SPECIES; is++) { if ((is % 6) * 6 == is) { printf("\n"); } -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" %Qg", ct[is]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" %Lg", ct[is]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf(" %g", ct[is]); #else printf(" %g", ct[is]); #endif @@ -786,10 +786,10 @@ static void PrintOutput(N_Vector cc) for (is = 0; is < NUM_SPECIES; is++) { if ((is % 6) * 6 == is) { printf("\n"); } -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" %Qg", ct[is]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" %Lg", ct[is]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf(" %g", ct[is]); #else printf(" %g", ct[is]); #endif diff --git a/examples/kinsol/parallel/kinFoodWeb_kry_bbd_p.c b/examples/kinsol/parallel/kinFoodWeb_kry_bbd_p.c index ede81b4118..6ad8eb2194 100644 --- a/examples/kinsol/parallel/kinFoodWeb_kry_bbd_p.c +++ b/examples/kinsol/parallel/kinFoodWeb_kry_bbd_p.c @@ -100,6 +100,7 @@ #include /* access to BBD preconditioner */ #include /* access to MPI parallel N_Vector */ #include /* use generic dense solver in precond. */ +#include /* access to SUNMAX, SUNRabs, SUNRsqrt */ #include /* defs. of sunrealtype, sunindextype */ #include /* access to SPGMR SUNLinearSolver */ @@ -794,7 +795,10 @@ static void PrintHeader(int globalstrategy, int maxl, int maxlrst, (long int)mudq, (long int)mldq); printf(" Retained band block half-bandwidths: mukeep = %ld, mlkeep = %ld\n", (long int)mukeep, (long int)mlkeep); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: fnormtol = %Qg scsteptol = %Qg\n", fnormtol, + scsteptol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: fnormtol = %Lg scsteptol = %Lg\n", fnormtol, scsteptol); #else @@ -803,7 +807,10 @@ static void PrintHeader(int globalstrategy, int maxl, int maxlrst, #endif printf("\nInitial profile of concentration\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("At all mesh points: %Qg %Qg %Qg %Qg %Qg %Qg\n", PREYIN, PREYIN, + PREYIN, PREDIN, PREDIN, PREDIN); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("At all mesh points: %Lg %Lg %Lg %Lg %Lg %Lg\n", PREYIN, PREYIN, PREYIN, PREDIN, PREDIN, PREDIN); #else @@ -854,7 +861,9 @@ static void PrintOutput(int my_pe, MPI_Comm comm, N_Vector cc) for (is = 0; is < NUM_SPECIES; is++) { if ((is % 6) * 6 == is) { printf("\n"); } -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" %Qg", ct[is]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" %Lg", ct[is]); #else printf(" %g", ct[is]); @@ -865,7 +874,9 @@ static void PrintOutput(int my_pe, MPI_Comm comm, N_Vector cc) for (is = 0; is < NUM_SPECIES; is++) { if ((is % 6) * 6 == is) { printf("\n"); } -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" %Qg", tempc[is]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" %Lg", tempc[is]); #else printf(" %g", tempc[is]); diff --git a/examples/kinsol/parallel/kinFoodWeb_kry_p.c b/examples/kinsol/parallel/kinFoodWeb_kry_p.c index 2290ca375f..bb819ad840 100644 --- a/examples/kinsol/parallel/kinFoodWeb_kry_p.c +++ b/examples/kinsol/parallel/kinFoodWeb_kry_p.c @@ -98,20 +98,6 @@ #include /* defs. of sunrealtype, sunindextype */ #include /* access to SPGMR SUNLinearSolver */ -/* Math function macros */ - -#if defined(SUNDIALS_DOUBLE_PRECISION) -#define ABS(x) (fabs((x))) -#define SQRT(x) (sqrt((x))) -#elif defined(SUNDIALS_SINGLE_PRECISION) -#define ABS(x) (fabsf((x))) -#define SQRT(x) (sqrtf((x))) -#elif defined(SUNDIALS_EXTENDED_PRECISION) -#define ABS(x) (fabsl((x))) -#define SQRT(x) (sqrtl((x))) -#endif -#define MAX(A, B) ((A) > (B) ? (A) : (B)) - /* Problem Constants */ /* must equal 2*(number of prey or predators) @@ -472,7 +458,7 @@ static int PrecSetupBD(N_Vector cc, N_Vector cscale, N_Vector fval, for (j = 0; j < NUM_SPECIES; j++) { csave = cxy[j]; /* Save the j,jx,jy element of cc */ - r = MAX(sqruround * ABS(csave), r0 / scxy[j]); + r = SUNMAX(sqruround * SUNRabs(csave), r0 / scxy[j]); cxy[j] += r; /* Perturb the j,jx,jy element of cc */ fac = ONE / r; @@ -631,7 +617,7 @@ static void InitUserData(int my_pe, MPI_Comm comm, UserData data) data->dx = (data->ax) / (MX - 1); data->dy = (data->ay) / (MY - 1); data->uround = SUN_UNIT_ROUNDOFF; - data->sqruround = SQRT(data->uround); + data->sqruround = SUNRsqrt(data->uround); data->my_pe = my_pe; data->comm = comm; data->isuby = my_pe / NPEX; @@ -758,7 +744,10 @@ static void PrintHeader(int globalstrategy, int maxl, int maxlrst, printf("Flag globalstrategy = %d (0 = None, 1 = Linesearch)\n", globalstrategy); printf("Linear solver is SPGMR with maxl = %d, maxlrst = %d\n", maxl, maxlrst); printf("Preconditioning uses interaction-only block-diagonal matrix\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: fnormtol = %Qg scsteptol = %Qg\n", fnormtol, + scsteptol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: fnormtol = %Lg scsteptol = %Lg\n", fnormtol, scsteptol); #else @@ -767,7 +756,10 @@ static void PrintHeader(int globalstrategy, int maxl, int maxlrst, #endif printf("\nInitial profile of concentration\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("At all mesh points: %Qg %Qg %Qg %Qg %Qg %Qg\n", PREYIN, PREYIN, + PREYIN, PREDIN, PREDIN, PREDIN); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("At all mesh points: %Lg %Lg %Lg %Lg %Lg %Lg\n", PREYIN, PREYIN, PREYIN, PREDIN, PREDIN, PREDIN); #else @@ -818,7 +810,9 @@ static void PrintOutput(int my_pe, MPI_Comm comm, N_Vector cc) for (is = 0; is < NUM_SPECIES; is++) { if ((is % 6) * 6 == is) { printf("\n"); } -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" %Qg", ct[is]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" %Lg", ct[is]); #else printf(" %g", ct[is]); @@ -829,7 +823,9 @@ static void PrintOutput(int my_pe, MPI_Comm comm, N_Vector cc) for (is = 0; is < NUM_SPECIES; is++) { if ((is % 6) * 6 == is) { printf("\n"); } -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" %Qg", tempc[is]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" %Lg", tempc[is]); #else printf(" %g", tempc[is]); diff --git a/examples/kinsol/serial/kinAnalytic_fp.c b/examples/kinsol/serial/kinAnalytic_fp.c index 8a5a6083e5..0e5814c6b5 100644 --- a/examples/kinsol/serial/kinAnalytic_fp.c +++ b/examples/kinsol/serial/kinAnalytic_fp.c @@ -39,54 +39,36 @@ #include "nvector/nvector_serial.h" /* access to serial N_Vector */ /* precision specific formatting macros */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #else #define GSYM "g" #endif -/* precision specific math function macros */ -#if defined(SUNDIALS_DOUBLE_PRECISION) -#define ABS(x) (fabs((x))) -#define SQRT(x) (sqrt((x))) -#define EXP(x) (exp((x))) -#define SIN(x) (sin((x))) -#define COS(x) (cos((x))) -#elif defined(SUNDIALS_SINGLE_PRECISION) -#define ABS(x) (fabsf((x))) -#define SQRT(x) (sqrtf((x))) -#define EXP(x) (expf((x))) -#define SIN(x) (sinf((x))) -#define COS(x) (cosf((x))) -#elif defined(SUNDIALS_EXTENDED_PRECISION) -#define ABS(x) (fabsl((x))) -#define SQRT(x) (sqrtl((x))) -#define EXP(x) (expl((x))) -#define SIN(x) (sinl((x))) -#define COS(x) (cosl((x))) -#endif - /* problem constants */ #define NEQ 3 /* number of equations */ -#define ZERO SUN_RCONST(0.0) /* real 0.0 */ -#define PTONE SUN_RCONST(0.1) /* real 0.1 */ -#define HALF SUN_RCONST(0.5) /* real 0.5 */ -#define PTNINE SUN_RCONST(0.9) /* real 0.9 */ -#define ONE SUN_RCONST(1.0) /* real 1.0 */ -#define ONEPTZEROSIX SUN_RCONST(1.06) /* real 1.06 */ -#define THREE SUN_RCONST(3.0) /* real 3.0 */ -#define SIX SUN_RCONST(6.0) /* real 6.0 */ -#define NINE SUN_RCONST(9.0) /* real 9.0 */ -#define TEN SUN_RCONST(10.0) /* real 10.0 */ -#define TWENTY SUN_RCONST(20.0) /* real 20.0 */ -#define SIXTY SUN_RCONST(60.0) /* real 60.0 */ -#define PI SUN_RCONST(3.1415926535898) /* real pi */ +#define ZERO SUN_RCONST(0.0) /* real 0.0 */ +#define PTONE SUN_RCONST(0.1) /* real 0.1 */ +#define HALF SUN_RCONST(0.5) /* real 0.5 */ +#define PTNINE SUN_RCONST(0.9) /* real 0.9 */ +#define ONE SUN_RCONST(1.0) /* real 1.0 */ +#define ONEPTZEROSIX SUN_RCONST(1.06) /* real 1.06 */ +#define THREE SUN_RCONST(3.0) /* real 3.0 */ +#define SIX SUN_RCONST(6.0) /* real 6.0 */ +#define NINE SUN_RCONST(9.0) /* real 9.0 */ +#define TEN SUN_RCONST(10.0) /* real 10.0 */ +#define TWENTY SUN_RCONST(20.0) /* real 20.0 */ +#define SIXTY SUN_RCONST(60.0) /* real 60.0 */ +#define PI \ + SUN_RCONST(3.141592653589793238462643383279502884197169) /* real pi */ /* analytic solution */ #define XTRUE HALF #define YTRUE ONE -#define ZTRUE -PI / SIX +#define ZTRUE (-PI / SIX) /* problem options */ typedef struct @@ -344,9 +326,10 @@ int FPFunction(N_Vector u, N_Vector g, void* user_data) y = udata[1]; z = udata[2]; - gdata[0] = (ONE / THREE) * COS((y - ONE) * z) + (ONE / SIX); - gdata[1] = (ONE / NINE) * SQRT(x * x + SIN(z) + ONEPTZEROSIX) + PTNINE; - gdata[2] = -(ONE / TWENTY) * EXP(-x * (y - ONE)) - (TEN * PI - THREE) / SIXTY; + gdata[0] = (ONE / THREE) * SUNRcos((y - ONE) * z) + (ONE / SIX); + gdata[1] = (ONE / NINE) * SUNRsqrt(x * x + SUNRsin(z) + ONEPTZEROSIX) + PTNINE; + gdata[2] = -(ONE / TWENTY) * SUNRexp(-x * (y - ONE)) - + (TEN * PI - THREE) / SIXTY; return (0); } @@ -355,7 +338,7 @@ static int DampingFn(long int iter, N_Vector u_val, N_Vector g_val, sunrealtype* qt_fn, long int depth, void* user_data, sunrealtype* damping_factor) { - if (depth == 0) { *damping_factor = 0.5; } + if (depth == 0) { *damping_factor = SUN_RCONST(0.5); } else { /* Compute ||Q^T fn||^2 */ @@ -376,7 +359,7 @@ static int DampingFn(long int iter, N_Vector u_val, N_Vector g_val, /* Compute the gain = sqrt(1 - ||Q^T fn||^2 / ||fn||^2) */ sunrealtype gain = SUNRsqrt(ONE - qt_fn_norm_sqr / fn_norm_sqr); - *damping_factor = 0.9 - 0.5 * gain; + *damping_factor = SUN_RCONST(0.9) - SUN_RCONST(0.5) * gain; } return 0; @@ -412,9 +395,9 @@ static int check_ans(N_Vector u, sunrealtype tol) printf(" z = %" GSYM "\n", data[2]); /* solution error */ - ex = ABS(data[0] - XTRUE); - ey = ABS(data[1] - YTRUE); - ez = ABS(data[2] - ZTRUE); + ex = SUNRabs(data[0] - XTRUE); + ey = SUNRabs(data[1] - YTRUE); + ez = SUNRabs(data[2] - ZTRUE); /* print the solution error */ printf("Solution error:\n"); @@ -444,7 +427,7 @@ static int SetDefaults(UserOpt* uopt) if (*uopt == NULL) { return (-1); } /* Set default options values */ - (*uopt)->tol = 100 * SQRT(SUN_UNIT_ROUNDOFF); + (*uopt)->tol = 100 * SUNRsqrt(SUN_UNIT_ROUNDOFF); (*uopt)->maxiter = 30; (*uopt)->m_aa = 0; /* no acceleration */ (*uopt)->delay_aa = 0; /* no delay */ diff --git a/examples/kinsol/serial/kinFerTron_dns.c b/examples/kinsol/serial/kinFerTron_dns.c index cd5f72fd5f..67e32de090 100644 --- a/examples/kinsol/serial/kinFerTron_dns.c +++ b/examples/kinsol/serial/kinFerTron_dns.c @@ -62,16 +62,6 @@ #include /* access to dense SUNLinearSolver */ #include /* access to dense SUNMatrix */ -/* Precision specific math function macros */ - -#if defined(SUNDIALS_DOUBLE_PRECISION) -#define EXP(x) (exp((x))) -#elif defined(SUNDIALS_SINGLE_PRECISION) -#define EXP(x) (expf((x))) -#elif defined(SUNDIALS_EXTENDED_PRECISION) -#define EXP(x) (expl((x))) -#endif - /* Problem Constants */ #define NVAR 2 @@ -339,8 +329,9 @@ static int func(N_Vector u, N_Vector f, void* user_data) l2 = udata[4]; L2 = udata[5]; - fdata[0] = PT5 * sin(x1 * x2) - PT25 * x2 / PI - PT5 * x1; - fdata[1] = (ONE - PT25 / PI) * (EXP(TWO * x1) - E) + E * x2 / PI - TWO * E * x1; + fdata[0] = PT5 * SUNRsin(x1 * x2) - PT25 * x2 / PI - PT5 * x1; + fdata[1] = (ONE - PT25 / PI) * (SUNRexp(TWO * x1) - E) + E * x2 / PI - + TWO * E * x1; fdata[2] = l1 - x1 + lb[0]; fdata[3] = L1 - x1 + ub[0]; fdata[4] = l2 - x2 + lb[1]; @@ -417,10 +408,10 @@ static void PrintHeader(sunrealtype fnormtol, sunrealtype scsteptol) { printf("\nFerraris and Tronconi test problem\n"); printf("Tolerance parameters:\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" fnormtol = %10.6Qg\n scsteptol = %10.6Qg\n", fnormtol, scsteptol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" fnormtol = %10.6Lg\n scsteptol = %10.6Lg\n", fnormtol, scsteptol); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf(" fnormtol = %10.6g\n scsteptol = %10.6g\n", fnormtol, scsteptol); #else printf(" fnormtol = %10.6g\n scsteptol = %10.6g\n", fnormtol, scsteptol); #endif @@ -433,7 +424,9 @@ static void PrintHeader(sunrealtype fnormtol, sunrealtype scsteptol) static void PrintOutput(N_Vector u) { sunrealtype* udata = N_VGetArrayPointer(u); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" %8.6Qg %8.6Qg\n", udata[0], udata[1]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" %8.6Lg %8.6Lg\n", udata[0], udata[1]); #else printf(" %8.6g %8.6g\n", udata[0], udata[1]); diff --git a/examples/kinsol/serial/kinFerTron_klu.c b/examples/kinsol/serial/kinFerTron_klu.c index 981466b193..1623d49bc0 100644 --- a/examples/kinsol/serial/kinFerTron_klu.c +++ b/examples/kinsol/serial/kinFerTron_klu.c @@ -62,16 +62,6 @@ #include /* access to KLU SUNLinearSolver */ #include /* access to sparse SUNMatrix */ -/* Precision specific math function macros */ - -#if defined(SUNDIALS_DOUBLE_PRECISION) -#define EXP(x) (exp((x))) -#elif defined(SUNDIALS_SINGLE_PRECISION) -#define EXP(x) (expf((x))) -#elif defined(SUNDIALS_EXTENDED_PRECISION) -#define EXP(x) (expl((x))) -#endif - /* Problem Constants */ #define NVAR 2 @@ -347,8 +337,9 @@ static int func(N_Vector u, N_Vector f, void* user_data) l2 = udata[4]; L2 = udata[5]; - fdata[0] = PT5 * sin(x1 * x2) - PT25 * x2 / PI - PT5 * x1; - fdata[1] = (ONE - PT25 / PI) * (EXP(TWO * x1) - E) + E * x2 / PI - TWO * E * x1; + fdata[0] = PT5 * SUNRsin(x1 * x2) - PT25 * x2 / PI - PT5 * x1; + fdata[1] = (ONE - PT25 / PI) * (SUNRexp(TWO * x1) - E) + E * x2 / PI - + TWO * E * x1; fdata[2] = l1 - x1 + lb[0]; fdata[3] = L1 - x1 + ub[0]; fdata[4] = l2 - x2 + lb[1]; @@ -388,7 +379,7 @@ static int jac(N_Vector y, N_Vector f, SUNMatrix J, void* user_data, colvals[1] = 1; /* row 1: J(1,0) and J(1,1) */ - data[2] = TWO * (ONE - PT25 / PI) * (EXP(TWO * yd[0]) - E); + data[2] = TWO * (ONE - PT25 / PI) * (SUNRexp(TWO * yd[0]) - E); colvals[2] = 0; data[3] = E / PI; colvals[3] = 1; diff --git a/examples/kinsol/serial/kinFoodWeb_kry.c b/examples/kinsol/serial/kinFoodWeb_kry.c index cbc5e598a6..a52ec589b1 100644 --- a/examples/kinsol/serial/kinFoodWeb_kry.c +++ b/examples/kinsol/serial/kinFoodWeb_kry.c @@ -96,20 +96,6 @@ #include /* defs. of sunrealtype, sunindextype */ #include /* access to SPGMR SUNLinearSolver */ -/* Math function macros */ - -#if defined(SUNDIALS_DOUBLE_PRECISION) -#define ABS(x) (fabs((x))) -#define SQRT(x) (sqrt((x))) -#elif defined(SUNDIALS_SINGLE_PRECISION) -#define ABS(x) (fabsf((x))) -#define SQRT(x) (sqrtf((x))) -#elif defined(SUNDIALS_EXTENDED_PRECISION) -#define ABS(x) (fabsl((x))) -#define SQRT(x) (sqrtl((x))) -#endif -#define MAX(A, B) ((A) > (B) ? (A) : (B)) - /* Problem Constants */ /* must equal 2*(number of prey or predators) @@ -419,7 +405,7 @@ static int PrecSetupBD(N_Vector cc, N_Vector cscale, N_Vector fval, for (j = 0; j < NUM_SPECIES; j++) { csave = cxy[j]; /* Save the j,jx,jy element of cc */ - r = MAX(sqruround * ABS(csave), r0 / scxy[j]); + r = SUNMAX(sqruround * SUNRabs(csave), r0 / scxy[j]); cxy[j] += r; /* Perturb the j,jx,jy element of cc */ fac = ONE / r; @@ -578,7 +564,7 @@ static void InitUserData(UserData data) data->dx = (data->ax) / (MX - 1); data->dy = (data->ay) / (MY - 1); data->uround = SUN_UNIT_ROUNDOFF; - data->sqruround = SQRT(data->uround); + data->sqruround = SUNRsqrt(data->uround); /* Set up the coefficients a and b plus others found in the equations */ np = data->np; @@ -697,8 +683,11 @@ static void PrintHeader(int globalstrategy, int maxl, int maxlrst, printf("Flag globalstrategy = %d (0 = None, 1 = Linesearch)\n", globalstrategy); printf("Linear solver is SPGMR with maxl = %d, maxlrst = %d\n", maxl, maxlrst); printf("Preconditioning uses interaction-only block-diagonal matrix\n"); - printf("Positivity constraints imposed on all components\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) + printf("Positivity constraints imposed on all components \n"); +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: fnormtol = %Qg scsteptol = %Qg\n", fnormtol, + scsteptol); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("Tolerance parameters: fnormtol = %Lg scsteptol = %Lg\n", fnormtol, scsteptol); #else @@ -707,7 +696,10 @@ static void PrintHeader(int globalstrategy, int maxl, int maxlrst, #endif printf("\nInitial profile of concentration\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("At all mesh points: %Qg %Qg %Qg %Qg %Qg %Qg\n", PREYIN, PREYIN, + PREYIN, PREDIN, PREDIN, PREDIN); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("At all mesh points: %Lg %Lg %Lg %Lg %Lg %Lg\n", PREYIN, PREYIN, PREYIN, PREDIN, PREDIN, PREDIN); #else @@ -736,7 +728,9 @@ static void PrintOutput(N_Vector cc) for (is = 0; is < NUM_SPECIES; is++) { if ((is % 6) * 6 == is) { printf("\n"); } -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" %Qg", ct[is]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" %Lg", ct[is]); #else printf(" %g", ct[is]); @@ -752,7 +746,9 @@ static void PrintOutput(N_Vector cc) for (is = 0; is < NUM_SPECIES; is++) { if ((is % 6) * 6 == is) { printf("\n"); } -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" %Qg", ct[is]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" %Lg", ct[is]); #else printf(" %g", ct[is]); diff --git a/examples/kinsol/serial/kinKrylovDemo_ls.c b/examples/kinsol/serial/kinKrylovDemo_ls.c index 601d84fa78..d309beca64 100644 --- a/examples/kinsol/serial/kinKrylovDemo_ls.c +++ b/examples/kinsol/serial/kinKrylovDemo_ls.c @@ -663,7 +663,7 @@ static void InitUserData(UserData data) data->dx = (data->ax) / (MX - 1); data->dy = (data->ay) / (MY - 1); data->uround = SUN_UNIT_ROUNDOFF; - data->sqruround = sqrt(data->uround); + data->sqruround = SUNRsqrt(data->uround); /* Set up the coefficients a and b plus others found in the equations */ np = data->np; @@ -802,11 +802,11 @@ static void PrintHeader(int globalstrategy, int maxl, int maxlrst, printf("Preconditioning uses interaction-only block-diagonal matrix\n"); printf("Positivity constraints imposed on all components \n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) - printf("Tolerance parameters: fnormtol = %Lg scsteptol = %Lg\n", fnormtol, +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("Tolerance parameters: fnormtol = %Qg scsteptol = %Qg\n", fnormtol, scsteptol); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("Tolerance parameters: fnormtol = %g scsteptol = %g\n", fnormtol, +#elif defined(SUNDIALS_EXTENDED_PRECISION) + printf("Tolerance parameters: fnormtol = %Lg scsteptol = %Lg\n", fnormtol, scsteptol); #else printf("Tolerance parameters: fnormtol = %g scsteptol = %g\n", fnormtol, @@ -814,12 +814,12 @@ static void PrintHeader(int globalstrategy, int maxl, int maxlrst, #endif printf("\nInitial profile of concentration\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("At all mesh points: %Qg %Qg %Qg %Qg %Qg %Qg\n", PREYIN, PREYIN, + PREYIN, PREDIN, PREDIN, PREDIN); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("At all mesh points: %Lg %Lg %Lg %Lg %Lg %Lg\n", PREYIN, PREYIN, PREYIN, PREDIN, PREDIN, PREDIN); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("At all mesh points: %g %g %g %g %g %g\n", PREYIN, PREYIN, PREYIN, - PREDIN, PREDIN, PREDIN); #else printf("At all mesh points: %g %g %g %g %g %g\n", PREYIN, PREYIN, PREYIN, PREDIN, PREDIN, PREDIN); @@ -844,10 +844,10 @@ static void PrintOutput(N_Vector cc) for (is = 0; is < NUM_SPECIES; is++) { if ((is % 6) * 6 == is) { printf("\n"); } -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" %Qg", ct[is]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" %Lg", ct[is]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf(" %g", ct[is]); #else printf(" %g", ct[is]); #endif @@ -862,10 +862,10 @@ static void PrintOutput(N_Vector cc) for (is = 0; is < NUM_SPECIES; is++) { if ((is % 6) * 6 == is) { printf("\n"); } -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" %Qg", ct[is]); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf(" %Lg", ct[is]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf(" %g", ct[is]); #else printf(" %g", ct[is]); #endif diff --git a/examples/kinsol/serial/kinLaplace_bnd.c b/examples/kinsol/serial/kinLaplace_bnd.c index 6167008d7f..d247b9ea5c 100644 --- a/examples/kinsol/serial/kinLaplace_bnd.c +++ b/examples/kinsol/serial/kinLaplace_bnd.c @@ -203,7 +203,9 @@ int main(void) retval = KINGetFuncNorm(kmem, &fnorm); if (check_retval(&retval, "KINGetfuncNorm", 1)) { return (1); } -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("\nComputed solution (||F|| = %Qg):\n\n", fnorm); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("\nComputed solution (||F|| = %Lg):\n\n", fnorm); #else printf("\nComputed solution (||F|| = %g):\n\n", fnorm); @@ -272,7 +274,7 @@ static int func(N_Vector u, N_Vector f, void* user_data) /* Set residual at x_i, y_j */ - IJth(fdata, i, j) = hdiff + vdiff + uij - uij * uij * uij + 2.0; + IJth(fdata, i, j) = hdiff + vdiff + uij - uij * uij * uij + TWO; } } @@ -298,10 +300,10 @@ static void PrintOutput(N_Vector u) for (i = 1; i <= NX; i += SKIP) { x = i * dx; -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%-8.5Qf ", x); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%-8.5Lf ", x); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%-8.5f ", x); #else printf("%-8.5f ", x); #endif @@ -311,19 +313,19 @@ static void PrintOutput(N_Vector u) for (j = 1; j <= NY; j += SKIP) { y = j * dy; -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%-8.5Qf ", y); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%-8.5Lf ", y); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%-8.5f ", y); #else printf("%-8.5f ", y); #endif for (i = 1; i <= NX; i += SKIP) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%-8.5Qf ", IJth(udata, i, j)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%-8.5Lf ", IJth(udata, i, j)); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%-8.5f ", IJth(udata, i, j)); #else printf("%-8.5f ", IJth(udata, i, j)); #endif diff --git a/examples/kinsol/serial/kinLaplace_picard_bnd.c b/examples/kinsol/serial/kinLaplace_picard_bnd.c index 2b1bb5bd44..ac9018bafd 100644 --- a/examples/kinsol/serial/kinLaplace_picard_bnd.c +++ b/examples/kinsol/serial/kinLaplace_picard_bnd.c @@ -206,7 +206,9 @@ int main(void) retval = KINGetFuncNorm(kmem, &fnorm); if (check_retval(&retval, "KINGetfuncNorm", 1)) { return (1); } -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("\nComputed solution (||F|| = %Qg):\n\n", fnorm); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("\nComputed solution (||F|| = %Lg):\n\n", fnorm); #else printf("\nComputed solution (||F|| = %g):\n\n", fnorm); @@ -275,7 +277,7 @@ static int func(N_Vector u, N_Vector f, void* user_data) /* Set residual at x_i, y_j */ - IJth(fdata, i, j) = hdiff + vdiff + uij - uij * uij * uij + 2.0; + IJth(fdata, i, j) = hdiff + vdiff + uij - uij * uij * uij + TWO; } } @@ -321,7 +323,7 @@ static int jac(N_Vector u, N_Vector f, SUNMatrix J, void* user_data, k = i + j * NX; kthCol = SUNBandMatrix_Column(J, k); - SM_COLUMN_ELEMENT_B(kthCol, k, k) = -2.0 * hdc - 2.0 * vdc; + SM_COLUMN_ELEMENT_B(kthCol, k, k) = -TWO * hdc - TWO * vdc; if (i != (NX - 1)) { SM_COLUMN_ELEMENT_B(kthCol, k + 1, k) = hdc; } if (i != 0) { SM_COLUMN_ELEMENT_B(kthCol, k - 1, k) = hdc; } if (j != (NY - 1)) { SM_COLUMN_ELEMENT_B(kthCol, k + NX, k) = vdc; } @@ -351,10 +353,10 @@ static void PrintOutput(N_Vector u) for (i = 1; i <= NX; i += SKIP) { x = i * dx; -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%-8.5Qf ", x); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%-8.5Lf ", x); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%-8.5f ", x); #else printf("%-8.5f ", x); #endif @@ -364,19 +366,19 @@ static void PrintOutput(N_Vector u) for (j = 1; j <= NY; j += SKIP) { y = j * dy; -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%-8.5Qf ", y); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%-8.5Lf ", y); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%-8.5f ", y); #else printf("%-8.5f ", y); #endif for (i = 1; i <= NX; i += SKIP) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%-8.5Qf ", IJth(udata, i, j)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%-8.5Lf ", IJth(udata, i, j)); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%-8.5f ", IJth(udata, i, j)); #else printf("%-8.5f ", IJth(udata, i, j)); #endif diff --git a/examples/kinsol/serial/kinLaplace_picard_kry.c b/examples/kinsol/serial/kinLaplace_picard_kry.c index 172746ba18..8f8b67c818 100644 --- a/examples/kinsol/serial/kinLaplace_picard_kry.c +++ b/examples/kinsol/serial/kinLaplace_picard_kry.c @@ -202,7 +202,9 @@ int main(void) retval = KINGetFuncNorm(kmem, &fnorm); if (check_retval(&retval, "KINGetfuncNorm", 1)) { return (1); } -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("\nComputed solution (||F|| = %Qg):\n\n", fnorm); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("\nComputed solution (||F|| = %Lg):\n\n", fnorm); #else printf("\nComputed solution (||F|| = %g):\n\n", fnorm); @@ -270,7 +272,7 @@ static int func(N_Vector u, N_Vector f, void* user_data) /* Set residual at x_i, y_j */ - IJth(fdata, i, j) = hdiff + vdiff + uij - uij * uij * uij + 2.0; + IJth(fdata, i, j) = hdiff + vdiff + uij - uij * uij * uij + TWO; } } @@ -344,10 +346,10 @@ static void PrintOutput(N_Vector u) for (i = 1; i <= NX; i += SKIP) { x = i * dx; -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%-8.5Qf ", x); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%-8.5Lf ", x); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%-8.5f ", x); #else printf("%-8.5f ", x); #endif @@ -357,19 +359,19 @@ static void PrintOutput(N_Vector u) for (j = 1; j <= NY; j += SKIP) { y = j * dy; -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%-8.5Qf ", y); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%-8.5Lf ", y); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%-8.5f ", y); #else printf("%-8.5f ", y); #endif for (i = 1; i <= NX; i += SKIP) { -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("%-8.5Qf ", IJth(udata, i, j)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("%-8.5Lf ", IJth(udata, i, j)); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("%-8.5f ", IJth(udata, i, j)); #else printf("%-8.5f ", IJth(udata, i, j)); #endif diff --git a/examples/kinsol/serial/kinRoberts_fp.c b/examples/kinsol/serial/kinRoberts_fp.c index 9c7484c416..07cd4097da 100644 --- a/examples/kinsol/serial/kinRoberts_fp.c +++ b/examples/kinsol/serial/kinRoberts_fp.c @@ -38,7 +38,9 @@ #include #include /* defs. of sunrealtype, sunindextype */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #else #define GSYM "g" @@ -186,7 +188,9 @@ int main(int argc, char* argv[]) retval = KINGetFuncNorm(kmem, &fnorm); if (check_retval(&retval, "KINGetfuncNorm", 1)) { return (1); } -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("\nComputed solution (||F|| = %Qg):\n\n", fnorm); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("\nComputed solution (||F|| = %Lg):\n\n", fnorm); #else printf("\nComputed solution (||F|| = %g):\n\n", fnorm); @@ -251,10 +255,10 @@ static void PrintOutput(N_Vector y) y2 = Ith(y, 2); y3 = Ith(y, 3); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf("y =%14.6Qe %14.6Qe %14.6Qe\n", y1, y2, y3); +#elif defined(SUNDIALS_EXTENDED_PRECISION) printf("y =%14.6Le %14.6Le %14.6Le\n", y1, y2, y3); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf("y =%14.6e %14.6e %14.6e\n", y1, y2, y3); #else printf("y =%14.6e %14.6e %14.6e\n", y1, y2, y3); #endif diff --git a/examples/kinsol/serial/kinRoboKin_dns.c b/examples/kinsol/serial/kinRoboKin_dns.c index 3380e0d478..09d27bd2d6 100644 --- a/examples/kinsol/serial/kinRoboKin_dns.c +++ b/examples/kinsol/serial/kinRoboKin_dns.c @@ -235,38 +235,40 @@ static int func(N_Vector y, N_Vector f, void* user_data) /* Nonlinear equations */ - eq1 = -0.1238 * x1 + x7 - 0.001637 * x2 - 0.9338 * x4 + 0.004731 * x1 * x3 - - 0.3578 * x2 * x3 - 0.3571; - eq2 = 0.2638 * x1 - x7 - 0.07745 * x2 - 0.6734 * x4 + 0.2238 * x1 * x3 + - 0.7623 * x2 * x3 - 0.6022; - eq3 = 0.3578 * x1 + 0.004731 * x2 + x6 * x8; - eq4 = -0.7623 * x1 + 0.2238 * x2 + 0.3461; - eq5 = x1 * x1 + x2 * x2 - 1; - eq6 = x3 * x3 + x4 * x4 - 1; - eq7 = x5 * x5 + x6 * x6 - 1; - eq8 = x7 * x7 + x8 * x8 - 1; + eq1 = SUN_RCONST(-0.1238) * x1 + x7 - SUN_RCONST(0.001637) * x2 - + SUN_RCONST(0.9338) * x4 + SUN_RCONST(0.004731) * x1 * x3 - + SUN_RCONST(0.3578) * x2 * x3 - SUN_RCONST(0.3571); + eq2 = SUN_RCONST(0.2638) * x1 - x7 - SUN_RCONST(0.07745) * x2 - + SUN_RCONST(0.6734) * x4 + SUN_RCONST(0.2238) * x1 * x3 + + SUN_RCONST(0.7623) * x2 * x3 - SUN_RCONST(0.6022); + eq3 = SUN_RCONST(0.3578) * x1 + SUN_RCONST(0.004731) * x2 + x6 * x8; + eq4 = SUN_RCONST(-0.7623) * x1 + SUN_RCONST(0.2238) * x2 + SUN_RCONST(0.3461); + eq5 = x1 * x1 + x2 * x2 - SUN_RCONST(1.0); + eq6 = x3 * x3 + x4 * x4 - SUN_RCONST(1.0); + eq7 = x5 * x5 + x6 * x6 - SUN_RCONST(1.0); + eq8 = x7 * x7 + x8 * x8 - SUN_RCONST(1.0); /* Lower bounds ( l_i = 1 + x_i >= 0)*/ - lb1 = l1 - 1.0 - x1; - lb2 = l2 - 1.0 - x2; - lb3 = l3 - 1.0 - x3; - lb4 = l4 - 1.0 - x4; - lb5 = l5 - 1.0 - x5; - lb6 = l6 - 1.0 - x6; - lb7 = l7 - 1.0 - x7; - lb8 = l8 - 1.0 - x8; + lb1 = l1 - SUN_RCONST(1.0) - x1; + lb2 = l2 - SUN_RCONST(1.0) - x2; + lb3 = l3 - SUN_RCONST(1.0) - x3; + lb4 = l4 - SUN_RCONST(1.0) - x4; + lb5 = l5 - SUN_RCONST(1.0) - x5; + lb6 = l6 - SUN_RCONST(1.0) - x6; + lb7 = l7 - SUN_RCONST(1.0) - x7; + lb8 = l8 - SUN_RCONST(1.0) - x8; /* Upper bounds ( u_i = 1 - x_i >= 0)*/ - ub1 = u1 - 1.0 + x1; - ub2 = u2 - 1.0 + x2; - ub3 = u3 - 1.0 + x3; - ub4 = u4 - 1.0 + x4; - ub5 = u5 - 1.0 + x5; - ub6 = u6 - 1.0 + x6; - ub7 = u7 - 1.0 + x7; - ub8 = u8 - 1.0 + x8; + ub1 = u1 - SUN_RCONST(1.0) + x1; + ub2 = u2 - SUN_RCONST(1.0) + x2; + ub3 = u3 - SUN_RCONST(1.0) + x3; + ub4 = u4 - SUN_RCONST(1.0) + x4; + ub5 = u5 - SUN_RCONST(1.0) + x5; + ub6 = u6 - SUN_RCONST(1.0) + x6; + ub7 = u7 - SUN_RCONST(1.0) + x7; + ub8 = u8 - SUN_RCONST(1.0) + x8; fd[0] = eq1; fd[8] = lb1; @@ -324,59 +326,59 @@ static int jac(N_Vector y, N_Vector f, SUNMatrix J, void* user_data, - 0.1238*x1 + x7 - 0.001637*x2 - 0.9338*x4 + 0.004731*x1*x3 - 0.3578*x2*x3 - 0.3571 */ - IJth(J, 1, 1) = -0.1238 + 0.004731 * x3; - IJth(J, 1, 2) = -0.001637 - 0.3578 * x3; - IJth(J, 1, 3) = 0.004731 * x1 - 0.3578 * x2; - IJth(J, 1, 4) = -0.9338; - IJth(J, 1, 7) = 1.0; + IJth(J, 1, 1) = SUN_RCONST(-0.1238) + SUN_RCONST(0.004731) * x3; + IJth(J, 1, 2) = SUN_RCONST(-0.001637) - SUN_RCONST(0.3578) * x3; + IJth(J, 1, 3) = SUN_RCONST(0.004731) * x1 - SUN_RCONST(0.3578) * x2; + IJth(J, 1, 4) = SUN_RCONST(-0.9338); + IJth(J, 1, 7) = SUN_RCONST(1.0); /* 0.2638*x1 - x7 - 0.07745*x2 - 0.6734*x4 + 0.2238*x1*x3 + 0.7623*x2*x3 - 0.6022 */ - IJth(J, 2, 1) = 0.2638 + 0.2238 * x3; - IJth(J, 2, 2) = -0.07745 + 0.7623 * x3; - IJth(J, 2, 3) = 0.2238 * x1 + 0.7623 * x2; - IJth(J, 2, 4) = -0.6734; - IJth(J, 2, 7) = -1.0; + IJth(J, 2, 1) = SUN_RCONST(0.2638) + SUN_RCONST(0.2238) * x3; + IJth(J, 2, 2) = SUN_RCONST(-0.07745) + SUN_RCONST(0.7623) * x3; + IJth(J, 2, 3) = SUN_RCONST(0.2238) * x1 + SUN_RCONST(0.7623) * x2; + IJth(J, 2, 4) = SUN_RCONST(-0.6734); + IJth(J, 2, 7) = SUN_RCONST(-1.0); /* 0.3578*x1 + 0.004731*x2 + x6*x8 */ - IJth(J, 3, 1) = 0.3578; - IJth(J, 3, 2) = 0.004731; + IJth(J, 3, 1) = SUN_RCONST(0.3578); + IJth(J, 3, 2) = SUN_RCONST(0.004731); IJth(J, 3, 6) = x8; IJth(J, 3, 8) = x6; /* - 0.7623*x1 + 0.2238*x2 + 0.3461 */ - IJth(J, 4, 1) = -0.7623; - IJth(J, 4, 2) = 0.2238; + IJth(J, 4, 1) = SUN_RCONST(-0.7623); + IJth(J, 4, 2) = SUN_RCONST(0.2238); /* x1*x1 + x2*x2 - 1 */ - IJth(J, 5, 1) = 2.0 * x1; - IJth(J, 5, 2) = 2.0 * x2; + IJth(J, 5, 1) = SUN_RCONST(2.0) * x1; + IJth(J, 5, 2) = SUN_RCONST(2.0) * x2; /* x3*x3 + x4*x4 - 1 */ - IJth(J, 6, 3) = 2.0 * x3; - IJth(J, 6, 4) = 2.0 * x4; + IJth(J, 6, 3) = SUN_RCONST(2.0) * x3; + IJth(J, 6, 4) = SUN_RCONST(2.0) * x4; /* x5*x5 + x6*x6 - 1 */ - IJth(J, 7, 5) = 2.0 * x5; - IJth(J, 7, 6) = 2.0 * x6; + IJth(J, 7, 5) = SUN_RCONST(2.0) * x5; + IJth(J, 7, 6) = SUN_RCONST(2.0) * x6; /* x7*x7 + x8*x8 - 1 */ - IJth(J, 8, 7) = 2.0 * x7; - IJth(J, 8, 8) = 2.0 * x8; + IJth(J, 8, 7) = SUN_RCONST(2.0) * x7; + IJth(J, 8, 8) = SUN_RCONST(2.0) * x8; /* Lower bounds ( l_i = 1 + x_i >= 0) @@ -385,8 +387,8 @@ static int jac(N_Vector y, N_Vector f, SUNMatrix J, void* user_data, for (i = 1; i <= 8; i++) { - IJth(J, 8 + i, i) = -1.0; - IJth(J, 8 + i, 8 + i) = 1.0; + IJth(J, 8 + i, i) = SUN_RCONST(-1.0); + IJth(J, 8 + i, 8 + i) = SUN_RCONST(1.0); } /* @@ -396,8 +398,8 @@ static int jac(N_Vector y, N_Vector f, SUNMatrix J, void* user_data, for (i = 1; i <= 8; i++) { - IJth(J, 16 + i, i) = 1.0; - IJth(J, 16 + i, 16 + i) = 1.0; + IJth(J, 16 + i, i) = SUN_RCONST(1.0); + IJth(J, 16 + i, 16 + i) = SUN_RCONST(1.0); } return (0); @@ -416,11 +418,11 @@ static void PrintOutput(N_Vector y) for (i = 1; i <= NVAR; i++) { -#if defined(SUNDIALS_EXTENDED_PRECISION) - printf(" %10.6Lg %10.6Lg %10.6Lg\n", Ith(y, i + NVAR), Ith(y, i), +#if defined(SUNDIALS_FLOAT128_PRECISION) + printf(" %10.6Qg %10.6Qg %10.6Qg\n", Ith(y, i + NVAR), Ith(y, i), Ith(y, i + 2 * NVAR)); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - printf(" %10.6g %10.6g %10.6g\n", Ith(y, i + NVAR), Ith(y, i), +#elif defined(SUNDIALS_EXTENDED_PRECISION) + printf(" %10.6Lg %10.6Lg %10.6Lg\n", Ith(y, i + NVAR), Ith(y, i), Ith(y, i + 2 * NVAR)); #else printf(" %10.6g %10.6g %10.6g\n", Ith(y, i + NVAR), Ith(y, i), diff --git a/examples/utilities/example_utilities.hpp b/examples/utilities/example_utilities.hpp index 83735842e6..75c625d13c 100644 --- a/examples/utilities/example_utilities.hpp +++ b/examples/utilities/example_utilities.hpp @@ -76,6 +76,19 @@ inline void find_arg(std::vector& args, const std::string key, } } +#if defined(SUNDIALS_FLOAT128_PRECISION) +inline void find_arg(std::vector& args, const std::string key, + __float128& dest) +{ + auto it = std::find(args.cbegin(), args.cend(), key); + if (it != args.end()) + { + dest = __float128(stod(*(it + 1))); + args.erase(it, it + 2); + } +} +#endif + inline void find_arg(std::vector& args, const std::string key, long long& dest) { diff --git a/include/sundials/sundials_config.in b/include/sundials/sundials_config.in index 662807c61d..bf2c559181 100644 --- a/include/sundials/sundials_config.in +++ b/include/sundials/sundials_config.in @@ -69,6 +69,7 @@ * #define SUNDIALS_SINGLE_PRECISION 1 * #define SUNDIALS_DOUBLE_PRECISION 1 * #define SUNDIALS_EXTENDED_PRECISION 1 + * #define SUNDIALS_FLOAT128_PRECISION 1 */ @PRECISION_LEVEL@ diff --git a/include/sundials/sundials_context.hpp b/include/sundials/sundials_context.hpp index 7400579422..304d6078b9 100644 --- a/include/sundials/sundials_context.hpp +++ b/include/sundials/sundials_context.hpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include namespace sundials { diff --git a/include/sundials/sundials_math.h b/include/sundials/sundials_math.h index fdf71a0058..8642104631 100644 --- a/include/sundials/sundials_math.h +++ b/include/sundials/sundials_math.h @@ -31,7 +31,6 @@ #ifdef __cplusplus /* wrapper to enable C++ usage */ extern "C" { #endif - /* * ----------------------------------------------------------------- * Macros @@ -46,11 +45,35 @@ extern "C" { * * SUNRabs calls the appropriate version of abs * + * SUNRisnan calls the appropriate version of isnan + * * SUNRexp calls the appropriate version of exp * + * SUNRlog calls the appropriate version of log + * * SUNRceil calls the appropriate version of ceil * + * SUNRcopysign calls the appropriate version copysign + * + * SUNRpowerR calls the appropriate version pow + * * SUNRround calls the appropriate version of round + * + * SUNRsin calls the appropriate version of sin + * + * SUNRcos calls the appropriate version of cos + * + * SUNRasin calls the appropriate version of asin + * + * SUNRacos calls the appropriate version of acos + * + * SUNRsinh calls the appropriate version of sinh + * + * SUNRcosh calls the appropriate version of cosh + + * SUNRatan calls the appropriate version of atan + * + * SUNRpower calls the appropriate version of power * ----------------------------------------------------------------- */ @@ -85,6 +108,8 @@ extern "C" { #define SUNRsqrt(x) ((x) <= SUN_RCONST(0.0) ? (SUN_RCONST(0.0)) : (sqrtf((x)))) #elif defined(SUNDIALS_EXTENDED_PRECISION) #define SUNRsqrt(x) ((x) <= SUN_RCONST(0.0) ? (SUN_RCONST(0.0)) : (sqrtl((x)))) +#elif defined(SUNDIALS_FLOAT128_PRECISION) +#define SUNRsqrt(x) ((x) <= SUN_RCONST(0.0) ? (SUN_RCONST(0.0)) : (sqrtq((x)))) #else #error \ "SUNDIALS precision not defined, report to github.com/LLNL/sundials/issues" @@ -109,6 +134,34 @@ extern "C" { #define SUNRabs(x) (fabsf((x))) #elif defined(SUNDIALS_EXTENDED_PRECISION) #define SUNRabs(x) (fabsl((x))) +#elif defined(SUNDIALS_FLOAT128_PRECISION) +#define SUNRabs(x) (fabsq((x))) +#else +#error \ + "SUNDIALS precision not defined, report to github.com/LLNL/sundials/issues" +#endif +#endif + +/* + * ----------------------------------------------------------------- + * Function : SUNRisnan + * ----------------------------------------------------------------- + * Usage : sunrealtype isnan_x; + * isnan_x = SUNRisnan(x); + * ----------------------------------------------------------------- + * SUNRisnan(x) returns isnan_x. + * ----------------------------------------------------------------- + */ + +#ifndef SUNRisnan +#if defined(SUNDIALS_DOUBLE_PRECISION) +#define SUNRisnan(x) (isnan((x))) +#elif defined(SUNDIALS_SINGLE_PRECISION) +#define SUNRisnan(x) (isnanf((x))) +#elif defined(SUNDIALS_EXTENDED_PRECISION) +#define SUNRisnan(x) (isnanl((x))) +#elif defined(SUNDIALS_FLOAT128_PRECISION) +#define SUNRisnan(x) (isnanq((x))) #else #error \ "SUNDIALS precision not defined, report to github.com/LLNL/sundials/issues" @@ -133,6 +186,34 @@ extern "C" { #define SUNRexp(x) (expf((x))) #elif defined(SUNDIALS_EXTENDED_PRECISION) #define SUNRexp(x) (expl((x))) +#elif defined(SUNDIALS_FLOAT128_PRECISION) +#define SUNRexp(x) (expq((x))) +#else +#error \ + "SUNDIALS precision not defined, report to github.com/LLNL/sundials/issues" +#endif +#endif + +/* + * ----------------------------------------------------------------- + * Function : SUNRlog + * ----------------------------------------------------------------- + * Usage : sunrealtype log_x; + * log_x = SUNRlog(x); + * ----------------------------------------------------------------- + * SUNRlog(x) returns log_x. + * ----------------------------------------------------------------- + */ + +#ifndef SUNRlog +#if defined(SUNDIALS_DOUBLE_PRECISION) +#define SUNRlog(x) (log((x))) +#elif defined(SUNDIALS_SINGLE_PRECISION) +#define SUNRlog(x) (logf((x))) +#elif defined(SUNDIALS_EXTENDED_PRECISION) +#define SUNRlog(x) (logl((x))) +#elif defined(SUNDIALS_FLOAT128_PRECISION) +#define SUNRlog(x) (logq((x))) #else #error \ "SUNDIALS precision not defined, report to github.com/LLNL/sundials/issues" @@ -157,6 +238,8 @@ extern "C" { #define SUNRceil(x) (ceilf((x))) #elif defined(SUNDIALS_EXTENDED_PRECISION) #define SUNRceil(x) (ceill((x))) +#elif defined(SUNDIALS_FLOAT128_PRECISION) +#define SUNRceil(x) (ceilq((x))) #else #error \ "SUNDIALS precision not defined, report to github.com/LLNL/sundials/issues" @@ -181,6 +264,8 @@ extern "C" { #define SUNRcopysign(x, y) (copysignf((x), (y))) #elif defined(SUNDIALS_EXTENDED_PRECISION) #define SUNRcopysign(x, y) (copysignl((x), (y))) +#elif defined(SUNDIALS_FLOAT128_PRECISION) +#define SUNRcopysign(x, y) (copysignq((x), (y))) #else #error \ "SUNDIALS precision not defined, report to github.com/LLNL/sundials/issues" @@ -197,7 +282,7 @@ extern "C" { * SUNRsamesign(x, y) returns true if x and y share the same sign, * false otherwise * ----------------------------------------------------------------- - */ +*/ #ifndef SUNRsamesign #define SUNRsamesign(x, y) (signbit((x)) == signbit((y))) @@ -213,7 +298,7 @@ extern "C" { * SUNRdifferentsign(x) returns true if x and y have different * signs, false otherwise * ----------------------------------------------------------------- - */ +*/ #ifndef SUNRdifferentsign #define SUNRdifferentsign(x, y) (!SUNRsamesign((x), (y))) @@ -237,6 +322,8 @@ extern "C" { #define SUNRpowerR(base, exponent) (powf(base, exponent)) #elif defined(SUNDIALS_EXTENDED_PRECISION) #define SUNRpowerR(base, exponent) (powl(base, exponent)) +#elif defined(SUNDIALS_FLOAT128_PRECISION) +#define SUNRpowerR(base, exponent) (powq(base, exponent)) #else #error \ "SUNDIALS precision not defined, report to github.com/LLNL/sundials/issues" @@ -261,6 +348,190 @@ extern "C" { #define SUNRround(x) (roundf((x))) #elif defined(SUNDIALS_EXTENDED_PRECISION) #define SUNRround(x) (roundl((x))) +#elif defined(SUNDIALS_FLOAT128_PRECISION) +#define SUNRround(x) (roundq((x))) +#else +#error \ + "SUNDIALS precision not defined, report to github.com/LLNL/sundials/issues" +#endif +#endif + +/* + * ----------------------------------------------------------------- + * Function : SUNRsin + * ----------------------------------------------------------------- + * Usage : sunrealtype sin_x; + * sin_x = SUNRsin(x); + * ----------------------------------------------------------------- + * SUNRsin(x) returns the sin value of x. + * ----------------------------------------------------------------- + */ + +#ifndef SUNRsin +#if defined(SUNDIALS_DOUBLE_PRECISION) +#define SUNRsin(x) (sin((x))) +#elif defined(SUNDIALS_SINGLE_PRECISION) +#define SUNRsin(x) (sinf((x))) +#elif defined(SUNDIALS_EXTENDED_PRECISION) +#define SUNRsin(x) (sinl((x))) +#elif defined(SUNDIALS_FLOAT128_PRECISION) +#define SUNRsin(x) (sinq((x))) +#else +#error \ + "SUNDIALS precision not defined, report to github.com/LLNL/sundials/issues" +#endif +#endif + +/* + * ----------------------------------------------------------------- + * Function : SUNRcos + * ----------------------------------------------------------------- + * Usage : sunrealtype cos_x; + * cos_x = SUNRcos(x); + * ----------------------------------------------------------------- + * SUNRcos(x) returns the cos value of x. + * ----------------------------------------------------------------- + */ + +#ifndef SUNRcos +#if defined(SUNDIALS_DOUBLE_PRECISION) +#define SUNRcos(x) (cos((x))) +#elif defined(SUNDIALS_SINGLE_PRECISION) +#define SUNRcos(x) (cosf((x))) +#elif defined(SUNDIALS_EXTENDED_PRECISION) +#define SUNRcos(x) (cosl((x))) +#elif defined(SUNDIALS_FLOAT128_PRECISION) +#define SUNRcos(x) (cosq((x))) +#else +#error \ + "SUNDIALS precision not defined, report to github.com/LLNL/sundials/issues" +#endif +#endif + +/* + * ----------------------------------------------------------------- + * Function : SUNRasin + * ----------------------------------------------------------------- + * Usage : sunrealtype cos_x; + * asin_x = SUNRasin(x); + * ----------------------------------------------------------------- + * SUNRasin(x) returns the asin value of x. + * ----------------------------------------------------------------- + */ + +#ifndef SUNRasin +#if defined(SUNDIALS_DOUBLE_PRECISION) +#define SUNRasin(x) (asin((x))) +#elif defined(SUNDIALS_SINGLE_PRECISION) +#define SUNRasin(x) (asinf((x))) +#elif defined(SUNDIALS_EXTENDED_PRECISION) +#define SUNRasin(x) (asinl((x))) +#elif defined(SUNDIALS_FLOAT128_PRECISION) +#define SUNRasin(x) (asinq((x))) +#else +#error \ + "SUNDIALS precision not defined, report to github.com/LLNL/sundials/issues" +#endif +#endif + +/* + * ----------------------------------------------------------------- + * Function : SUNRacos + * ----------------------------------------------------------------- + * Usage : sunrealtype acos_x; + * acos_x = SUNRacos(x); + * ----------------------------------------------------------------- + * SUNRacos(x) returns the acos value of x. + * ----------------------------------------------------------------- + */ + +#ifndef SUNRacos +#if defined(SUNDIALS_DOUBLE_PRECISION) +#define SUNRacos(x) (acos((x))) +#elif defined(SUNDIALS_SINGLE_PRECISION) +#define SUNRacos(x) (acosf((x))) +#elif defined(SUNDIALS_EXTENDED_PRECISION) +#define SUNRacos(x) (acosl((x))) +#elif defined(SUNDIALS_FLOAT128_PRECISION) +#define SUNRacos(x) (acosq((x))) +#else +#error \ + "SUNDIALS precision not defined, report to github.com/LLNL/sundials/issues" +#endif +#endif + +/* + * ----------------------------------------------------------------- + * Function : SUNRsinh + * ----------------------------------------------------------------- + * Usage : sunrealtype sinh_x; + * sinh_x = SUNRsinh(x); + * ----------------------------------------------------------------- + * SUNRsinh(x) returns sinh(x) (the hyperbolic sine of x). + * ----------------------------------------------------------------- +*/ + +#ifndef SUNRsinh +#if defined(SUNDIALS_DOUBLE_PRECISION) +#define SUNRsinh(x) (sinh((x))) +#elif defined(SUNDIALS_SINGLE_PRECISION) +#define SUNRsinh(x) (sinhf((x))) +#elif defined(SUNDIALS_EXTENDED_PRECISION) +#define SUNRsinh(x) (sinhl((x))) +#elif defined(SUNDIALS_FLOAT128_PRECISION) +#define SUNRsinh(x) (sinhq((x))) +#else +#error \ + "SUNDIALS precision not defined, report to github.com/LLNL/sundials/issues" +#endif +#endif + +/* + * ----------------------------------------------------------------- + * Function : SUNRcosh + * ----------------------------------------------------------------- + * Usage : sunrealtype cosh_x; + * cosh_x = SUNRcosh(x); + * ----------------------------------------------------------------- + * SUNRcosh(x) returns cosh(x) (the hyperbolic cosine of x). + * ----------------------------------------------------------------- + */ + +#ifndef SUNRcosh +#if defined(SUNDIALS_DOUBLE_PRECISION) +#define SUNRcosh(x) (cosh((x))) +#elif defined(SUNDIALS_SINGLE_PRECISION) +#define SUNRcosh(x) (coshf((x))) +#elif defined(SUNDIALS_EXTENDED_PRECISION) +#define SUNRcosh(x) (coshl((x))) +#elif defined(SUNDIALS_FLOAT128_PRECISION) +#define SUNRcosh(x) (coshq((x))) +#else +#error \ + "SUNDIALS precision not defined, report to github.com/LLNL/sundials/issues" +#endif +#endif + +/* + * ----------------------------------------------------------------- + * Function : SUNRatan + * ----------------------------------------------------------------- + * Usage : sunrealtype cos_x; + * atan_x = SUNRatan(x); + * ----------------------------------------------------------------- + * SUNRatan(x) returns the atan value of x. + * ----------------------------------------------------------------- + */ + +#ifndef SUNRatan +#if defined(SUNDIALS_DOUBLE_PRECISION) +#define SUNRatan(x) (atan((x))) +#elif defined(SUNDIALS_SINGLE_PRECISION) +#define SUNRatan(x) (atanf((x))) +#elif defined(SUNDIALS_EXTENDED_PRECISION) +#define SUNRatan(x) (atanl((x))) +#elif defined(SUNDIALS_FLOAT128_PRECISION) +#define SUNRatan(x) (atanq((x))) #else #error \ "SUNDIALS precision not defined, report to github.com/LLNL/sundials/issues" @@ -305,10 +576,10 @@ SUNDIALS_EXPORT sunrealtype SUNRpowerI(sunrealtype base, int exponent); * isNotEqual = SUNRCompare(a, b); * ----------------------------------------------------------------- * SUNRCompareTol returns 0 if the relative difference of a and b is - * less than or equal to 10*machine epsilon. If the relative - * difference is greater than 10*machine epsilon, it returns 1. The - * function handles the case where a or b are near zero as well as - * the case where a or b are inf/nan. + * less than or equal to 10* or 100*(for __float128) machine epsilon. + * If the relative difference is greater than 10* or 100*machine + * epsilon, it returns 1. The function handles the case where a or b + * are near zero as well as the case where a or b are inf/nan. * ----------------------------------------------------------------- */ diff --git a/include/sundials/sundials_mpi_types.h b/include/sundials/sundials_mpi_types.h index c7db9509ad..981c73f262 100644 --- a/include/sundials/sundials_mpi_types.h +++ b/include/sundials/sundials_mpi_types.h @@ -30,6 +30,8 @@ #define MPI_SUNREALTYPE MPI_DOUBLE #elif defined(SUNDIALS_EXTENDED_PRECISION) #define MPI_SUNREALTYPE MPI_LONG_DOUBLE +#elif defined(SUNDIALS_FLOAT128_PRECISION) +#define MPI_SUNREALTYPE MPI_REAL16 #endif #if defined(SUNDIALS_INT64_T) diff --git a/include/sundials/sundials_types.h b/include/sundials/sundials_types.h index c11a2ddb99..82c3992806 100644 --- a/include/sundials/sundials_types.h +++ b/include/sundials/sundials_types.h @@ -97,6 +97,7 @@ typedef float sunrealtype; #define SUN_BIG_REAL FLT_MAX #define SUN_SMALL_REAL FLT_MIN #define SUN_UNIT_ROUNDOFF FLT_EPSILON +#define SUN_DIGITS10 FLT_DIG // TODO(SBR): In C11, FLT_DECIMAL_DIG may be a better choice #define SUN_FORMAT_E "% ." SUN_STRING(FLT_DIG) "e" #define SUN_FORMAT_G "%." SUN_STRING(FLT_DIG) "g" @@ -110,6 +111,7 @@ typedef double sunrealtype; #define SUN_BIG_REAL DBL_MAX #define SUN_SMALL_REAL DBL_MIN #define SUN_UNIT_ROUNDOFF DBL_EPSILON +#define SUN_DIGITS10 DBL_DIG #define SUN_FORMAT_E "% ." SUN_STRING(DBL_DIG) "e" #define SUN_FORMAT_G "%." SUN_STRING(DBL_DIG) "g" #define SUN_FORMAT_SG "%+." SUN_STRING(DBL_DIG) "g" @@ -121,10 +123,24 @@ typedef long double sunrealtype; #define SUN_BIG_REAL LDBL_MAX #define SUN_SMALL_REAL LDBL_MIN #define SUN_UNIT_ROUNDOFF LDBL_EPSILON +#define SUN_DIGITS10 LDBL_DIG #define SUN_FORMAT_E "% ." SUN_STRING(LDBL_DIG) "Le" #define SUN_FORMAT_G "%." SUN_STRING(LDBL_DIG) "Lg" #define SUN_FORMAT_SG "%+." SUN_STRING(LDBL_DIG) "Lg" +#elif defined(SUNDIALS_FLOAT128_PRECISION) + +#include +typedef __float128 sunrealtype; +#define SUN_RCONST(x) x##Q +#define SUN_BIG_REAL FLT128_MAX +#define SUN_SMALL_REAL FLT128_MIN +#define SUN_UNIT_ROUNDOFF FLT128_EPSILON +#define SUN_DIGITS10 FLT128_DIG +#define SUN_FORMAT_E "% ." SUN_STRING(FLT128_DIG) "Qe" +#define SUN_FORMAT_G "%." SUN_STRING(FLT128_DIG) "Qg" +#define SUN_FORMAT_SG "%+." SUN_STRING(FLT128_DIG) "Qg" + #endif /* diff --git a/include/sundials/sundials_types.hpp b/include/sundials/sundials_types.hpp new file mode 100644 index 0000000000..766ef7ba01 --- /dev/null +++ b/include/sundials/sundials_types.hpp @@ -0,0 +1,73 @@ +/* ----------------------------------------------------------------------------- + * Programmer(s): Cody J. Balos @ LLNL + * ----------------------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2025-2026, Lawrence Livermore National Security, + * University of Maryland Baltimore County, and the SUNDIALS contributors. + * Copyright (c) 2013-2025, Lawrence Livermore National Security + * and Southern Methodist University. + * Copyright (c) 2002-2013, Lawrence Livermore National Security. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------------------- + * C++ view of SUNDIALS SUNStepper + * ---------------------------------------------------------------------------*/ + +#ifndef _SUNDIALS_TYPES_HPP +#define _SUNDIALS_TYPES_HPP + +#include + +#ifdef SUNDIALS_FLOAT128_PRECISION + +#include +#include +#include +#include + +/* This defines an output stream operator for the `__float128` type.*/ +inline std::ostream& operator<<(std::ostream& os, __float128 value) +{ + // Get current stream formatting state + const long int width = os.width(); // Width set by std::setw + const long int precision = os.precision(); // Precision set by std::setprecision + const std::ios_base::fmtflags flags = + os.flags(); // Format flags (e.g., scientific notation) + + // Determine format specifier based on stream flags (e/f/g) + char format_specifier = 'g'; + if (flags & std::ios_base::scientific) { format_specifier = 'e'; } + else if (flags & std::ios_base::fixed) { format_specifier = 'f'; } + + // Dynamically generate format string (e.g., "%20.15Qe") + char format_buffer[64]; + std::snprintf(format_buffer, sizeof(format_buffer), + "%%%d.%dQ%c", // Format template: %[width].[precision]Q[e/f/g] + static_cast(width), // Width from setw + static_cast(precision), // Precision from setprecision + format_specifier); + + // Format __float128 to string + char value_buffer[128]; + const auto n = static_cast( + quadmath_snprintf(value_buffer, sizeof(value_buffer), + format_buffer, // Dynamically generated format (e.g., "%20.15Qe") + value)); + + // Write to output stream + if (n < sizeof(value_buffer)) { os << value_buffer; } + else { os << "[FORMAT ERROR]"; } + + // Reset stream width (setw has one-time effect) + os.width(0); + + return os; +} + +#endif + +#endif diff --git a/scripts/spack/packages/sundials/package.py b/scripts/spack/packages/sundials/package.py index a3d78d78c8..a9271c3ee8 100644 --- a/scripts/spack/packages/sundials/package.py +++ b/scripts/spack/packages/sundials/package.py @@ -101,7 +101,7 @@ class Sundials(CachedCMakePackage, CudaPackage, ROCmPackage): "precision", default="double", description="real type precision", - values=("single", "double", "extended"), + values=("single", "double", "extended", "float128"), multi=False, ) @@ -294,6 +294,14 @@ class Sundials(CachedCMakePackage, CudaPackage, ROCmPackage): conflicts("+superlu-dist") conflicts("+superlu-mt") + # External libraries incompatible with quadruple precision + with when("precision=float128"): + conflicts("+hypre", when="+hypre@:2.12.0") + conflicts("+klu") + conflicts("+lapack") + conflicts("+superlu-dist") + conflicts("+superlu-mt") + # SuperLU_MT interface requires lapack for external blas (before v3.0.0) conflicts("+superlu-mt", when="@:2.7.0 ~lapack") diff --git a/src/arkode/arkode_lsrkstep_impl.h b/src/arkode/arkode_lsrkstep_impl.h index 7dde8529bc..4b7a171883 100644 --- a/src/arkode/arkode_lsrkstep_impl.h +++ b/src/arkode/arkode_lsrkstep_impl.h @@ -36,89 +36,6 @@ extern "C" { #define DOM_EIG_NUM_WARMUPS_DEFAULT 0 #define DOM_EIG_NUM_INIT_WARMUPS_DEFAULT -1 /* use DEE's default value */ -/*=============================================================== - LSRK time step module private math function macros - =============================================================== - * SUNRlog calls the appropriate version of log - * - * SUNRsinh calls the appropriate version of sinh - * - * SUNRcosh calls the appropriate version of cosh - * ----------------------------------------------------------------- - */ - -/* - * ----------------------------------------------------------------- - * Function : SUNRlog - * ----------------------------------------------------------------- - * Usage : sunrealtype log_x; - * log_x = SUNRlog(x); - * ----------------------------------------------------------------- - * SUNRlog(x) returns log(x) (base-e logarithmic function). - * ----------------------------------------------------------------- - */ - -#ifndef SUNRlog -#if defined(SUNDIALS_DOUBLE_PRECISION) -#define SUNRlog(x) (log((x))) -#elif defined(SUNDIALS_SINGLE_PRECISION) -#define SUNRlog(x) (logf((x))) -#elif defined(SUNDIALS_EXTENDED_PRECISION) -#define SUNRlog(x) (logl((x))) -#else -#error \ - "SUNDIALS precision not defined, report to github.com/LLNL/sundials/issues" -#endif -#endif - -/* - * ----------------------------------------------------------------- - * Function : SUNRsinh - * ----------------------------------------------------------------- - * Usage : sunrealtype sinh_x; - * sinh_x = SUNRsinh(x); - * ----------------------------------------------------------------- - * SUNRsinh(x) returns sinh(x) (the hyperbolic sine of x). - * ----------------------------------------------------------------- - */ - -#ifndef SUNRsinh -#if defined(SUNDIALS_DOUBLE_PRECISION) -#define SUNRsinh(x) (sinh((x))) -#elif defined(SUNDIALS_SINGLE_PRECISION) -#define SUNRsinh(x) (sinhf((x))) -#elif defined(SUNDIALS_EXTENDED_PRECISION) -#define SUNRsinh(x) (sinhl((x))) -#else -#error \ - "SUNDIALS precision not defined, report to github.com/LLNL/sundials/issues" -#endif -#endif - -/* - * ----------------------------------------------------------------- - * Function : SUNRcosh - * ----------------------------------------------------------------- - * Usage : sunrealtype cosh_x; - * cosh_x = SUNRcosh(x); - * ----------------------------------------------------------------- - * SUNRcosh(x) returns cosh(x) (the hyperbolic cosine of x). - * ----------------------------------------------------------------- - */ - -#ifndef SUNRcosh -#if defined(SUNDIALS_DOUBLE_PRECISION) -#define SUNRcosh(x) (cosh((x))) -#elif defined(SUNDIALS_SINGLE_PRECISION) -#define SUNRcosh(x) (coshf((x))) -#elif defined(SUNDIALS_EXTENDED_PRECISION) -#define SUNRcosh(x) (coshl((x))) -#else -#error \ - "SUNDIALS precision not defined, report to github.com/LLNL/sundials/issues" -#endif -#endif - /*=============================================================== LSRK time step module data structure ===============================================================*/ diff --git a/src/nvector/parhyp/nvector_parhyp.c b/src/nvector/parhyp/nvector_parhyp.c index 79c6778bbb..cf7d6228d6 100644 --- a/src/nvector/parhyp/nvector_parhyp.c +++ b/src/nvector/parhyp/nvector_parhyp.c @@ -433,8 +433,7 @@ sunrealtype* N_VGetArrayPointer_ParHyp(SUNDIALS_MAYBE_UNUSED N_Vector v) */ void N_VSetArrayPointer_ParHyp(SUNDIALS_MAYBE_UNUSED sunrealtype* v_data, SUNDIALS_MAYBE_UNUSED N_Vector v) -{ - /* Not implemented for Hypre vector */ +{ /* Not implemented for Hypre vector */ } MPI_Comm N_VGetCommunicator_ParHyp(N_Vector v) { return (NV_COMM_PH(v)); } diff --git a/src/sundials/CMakeLists.txt b/src/sundials/CMakeLists.txt index 98c20d63fa..f0d427207d 100644 --- a/src/sundials/CMakeLists.txt +++ b/src/sundials/CMakeLists.txt @@ -65,6 +65,7 @@ set(sundials_HEADERS sundials_stepper.hpp sundials_types_deprecated.h sundials_types.h + sundials_types.hpp sundials_version.h) if(SUNDIALS_ENABLE_MPI) diff --git a/src/sundials/sundials_math.c b/src/sundials/sundials_math.c index 4136eed0c8..5269e7a4f6 100644 --- a/src/sundials/sundials_math.c +++ b/src/sundials/sundials_math.c @@ -48,7 +48,11 @@ sunrealtype SUNRpowerI(sunrealtype base, int exponent) sunbooleantype SUNRCompare(sunrealtype a, sunrealtype b) { +#if defined(SUNDIALS_FLOAT128_PRECISION) + return (SUNRCompareTol(a, b, 100 * SUN_UNIT_ROUNDOFF)); +#else return (SUNRCompareTol(a, b, 10 * SUN_UNIT_ROUNDOFF)); +#endif } sunbooleantype SUNRCompareTol(sunrealtype a, sunrealtype b, sunrealtype tol) @@ -64,14 +68,14 @@ sunbooleantype SUNRCompareTol(sunrealtype a, sunrealtype b, sunrealtype tol) diff = SUNRabs(a - b); norm = SUNMIN(SUNRabs(a + b), SUN_BIG_REAL); - /* When |a + b| is very small (less than 10*SUN_UNIT_ROUNDOFF) or zero, we use - * an absolute difference: + /* When |a + b| is very small (less than 10* or 100*SUN_UNIT_ROUNDOFF) + * or zero, we use an absolute difference: * |a - b| >= 10*SUN_UNIT_ROUNDOFF * Otherwise we use a relative difference: * |a - b| < tol * |a + b| * The choice to use |a + b| over max(a, b) is arbitrary, as is the choice to * use 10*SUN_UNIT_ROUNDOFF. - * + * * In order to handle NANs correctly without explicit checks of isnan or * isunordered (which throw warnings for some compilers and flags), we use * !isless. The seemingly equivalent >= can have undefined behavior for NANs. @@ -88,6 +92,8 @@ sunrealtype SUNStrToReal(const char* str) return strtod(str, &end); #elif defined(SUNDIALS_SINGLE_PRECISION) return strtof(str, &end); +#elif defined(SUNDIALS_FLOAT128_PRECISION) + return strtoflt128(str, &end); #else #error \ "SUNDIALS precision not defined, report to github.com/LLNL/sundials/issues" diff --git a/src/sunlinsol/onemkldense/sunlinsol_onemkldense.cpp b/src/sunlinsol/onemkldense/sunlinsol_onemkldense.cpp index c0536a584b..2db060f3c1 100644 --- a/src/sunlinsol/onemkldense/sunlinsol_onemkldense.cpp +++ b/src/sunlinsol/onemkldense/sunlinsol_onemkldense.cpp @@ -33,6 +33,8 @@ using namespace oneapi::mkl::lapack; // Check for a valid precision and index size #if defined(SUNDIALS_EXTENDED_PRECISION) #error "oneMLK unsupported precision" +#elif defined(SUNDIALS_FLOAT128_PRECISION) +#error "oneMLK unsupported precision" #endif #if defined(SUNDIALS_INT32_T) diff --git a/src/sunmatrix/onemkldense/sunmatrix_onemkldense.cpp b/src/sunmatrix/onemkldense/sunmatrix_onemkldense.cpp index 4c7e43de8d..5aecb312a8 100644 --- a/src/sunmatrix/onemkldense/sunmatrix_onemkldense.cpp +++ b/src/sunmatrix/onemkldense/sunmatrix_onemkldense.cpp @@ -35,6 +35,8 @@ // Check for a valid precision #if defined(SUNDIALS_EXTENDED_PRECISION) #error "oneMLK unsupported precision" +#elif defined(SUNDIALS_FLOAT128_PRECISION) +#error "oneMLK unsupported precision" #endif // Constants diff --git a/test/answers b/test/answers index d543e9bb80..4cedbfaf3c 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit d543e9bb801d354358f46354f533b5bafedcf7be +Subproject commit 4cedbfaf3c3eb9689475c7d9f03097a12e4829e1 diff --git a/test/config_cmake.py b/test/config_cmake.py index ec0fddc56a..05451f2aef 100644 --- a/test/config_cmake.py +++ b/test/config_cmake.py @@ -405,7 +405,7 @@ def main(): "double", "STRING", "real type precision", - choices=["single", "double", "extended"], + choices=["single", "double", "extended", "float128"], ) # monitoring diff --git a/test/env/docker.sh b/test/env/docker.sh index b26abc1cd1..8732ac1e11 100644 --- a/test/env/docker.sh +++ b/test/env/docker.sh @@ -45,7 +45,7 @@ compilerversion="${compiler##*@}" # ------------------------------------------------------------------------------ case "$SUNDIALS_PRECISION" in - single|double|extended) ;; + single|double|extended|float128) ;; *) echo "ERROR: Unknown real type option: $SUNDIALS_PRECISION" return 1 @@ -166,7 +166,10 @@ fi # Uncomment to override the default output file comparison precisions. The float # precision is number of digits to compare (0 = all digits) and the integer # precision is allowed percentage difference (0 = no difference). -if [ "$SUNDIALS_PRECISION" == "extended" ]; then +if [ "$SUNDIALS_PRECISION" == "float128" ]; then + export SUNDIALS_TEST_FLOAT_PRECISION=7 + export SUNDIALS_TEST_INTEGER_PRECISION=10 +elif [ "$SUNDIALS_PRECISION" == "extended" ]; then export SUNDIALS_TEST_FLOAT_PRECISION=7 export SUNDIALS_TEST_INTEGER_PRECISION=10 elif [ "$SUNDIALS_PRECISION" == "double" ]; then diff --git a/test/env/jenkins.sh b/test/env/jenkins.sh index d389271c27..ef6b3f8511 100644 --- a/test/env/jenkins.sh +++ b/test/env/jenkins.sh @@ -25,7 +25,7 @@ echo "./jenkins.sh $*" | tee -a setup_env.log # ------------------------------------------------------------------------------ case "$SUNDIALS_PRECISION" in - single|double|extended) ;; + single|double|extended|float128) ;; *) echo "ERROR: Unknown real type option: $SUNDIALS_PRECISION" return 1 @@ -163,7 +163,8 @@ export SUNDIALS_OPENMP_OFFLOAD=OFF # CUDA # ---- -if [ "$SUNDIALS_PRECISION" != "extended" ]; then +if [ "$SUNDIALS_PRECISION" != "extended" ] && \ + [ "$SUNDIALS_PRECISION" != "float128" ]; then export SUNDIALS_CUDA=ON export SUNDIALS_FUSED_KERNELS=ON else @@ -187,7 +188,8 @@ export MPIEXEC="${MPI_ROOT}/bin/mpirun" # LAPACK / BLAS # ------------- -if [ "$SUNDIALS_PRECISION" != "extended" ]; then +if [ "$SUNDIALS_PRECISION" != "extended" ] && \ + [ "$SUNDIALS_PRECISION" != "float128" ]; then export SUNDIALS_LAPACK=ON if [ "$SUNDIALS_INDEX_SIZE" == "32" ]; then LAPACK_ROOT="$(spack location -i openblas@0.3.27 ~ilp64)" @@ -224,7 +226,8 @@ fi # Ginkgo # ------ -if [ "$SUNDIALS_PRECISION" != "extended" ]; then +if [ "$SUNDIALS_PRECISION" != "extended" ] && \ + [ "$SUNDIALS_PRECISION" != "float128" ]; then if [ "$SUNDIALS_CUDA" == "ON" ]; then export SUNDIALS_GINKGO=ON export GINKGO_ROOT="$(spack location -i ginkgo@master +cuda)" @@ -269,6 +272,7 @@ fi # ----- if [ "$SUNDIALS_PRECISION" != "extended" ] && \ + [ "$SUNDIALS_PRECISION" != "float128" ] && \ [ "$SUNDIALS_INDEX_SIZE" == "32" ] && \ [ "$SUNDIALS_CUDA" == "ON" ]; then export SUNDIALS_MAGMA=ON @@ -284,7 +288,8 @@ fi # SuperLU_MT # ---------- -if [ "$SUNDIALS_PRECISION" != "extended" ]; then +if [ "$SUNDIALS_PRECISION" != "extended" ]&& \ + [ "$SUNDIALS_PRECISION" != "float128" ]; then export SUNDIALS_SUPERLU_MT=ON # Using @master (sha 9e23fe72652afc28c97829e69e7c6966050541a7) as it # additional fixes necessary for building with newer versions of GCC diff --git a/test/env/setup_env.sh b/test/env/setup_env.sh index 3aefc1a5b0..e0b54fef7d 100644 --- a/test/env/setup_env.sh +++ b/test/env/setup_env.sh @@ -24,6 +24,7 @@ # single : single (32-bit) precision # double : double (64-bit) precision # extended : extended (80-bit) precision +# float128 : quadruple (128-bit) precision # index size = SUNDIALS index size to build/test with: # 32 : 32-bit indices # 64 : 64-bit indices @@ -45,7 +46,7 @@ echo "./setup_env.sh $*" | tee -a setup_env.log # Check number of inputs if [ "$#" -lt 5 ]; then echo "ERROR: missing required inputs" - echo " 1) real type : [single|double|extended]" + echo " 1) real type : [single|double|extended|float128]" echo " 2) index size : [32|64]" echo " 3) library type : [static|shared|both]" echo " 4) TPL status : [ON|OFF]" diff --git a/test/test_driver.sh b/test/test_driver.sh index af3096867c..1b7fb9b907 100755 --- a/test/test_driver.sh +++ b/test/test_driver.sh @@ -72,6 +72,7 @@ help () double -- (default) use double precision single -- use single precision extended -- use extended precision + float128 -- use float128 precision --indexsize SIZE Index size to use in a custom test. SIZE must be one of: @@ -234,6 +235,9 @@ while [[ $# -gt 0 ]]; do EXTENDED|Extended|extended) sunrealtype=extended ;; + FLOAT128|Float128|float128) + sunrealtype=float128 + ;; *) echo "ERROR: Invalid real type option $sunrealtype" help @@ -433,7 +437,7 @@ case "$testtype" in done # Test configs - for rt in single double extended; do + for rt in single double extended float128; do for is in 32 64; do for lt in static shared; do args_realtypes+=("${rt}") diff --git a/test/unit_tests/arkode/CXX_parallel/ark_test_heat2D_mri.cpp b/test/unit_tests/arkode/CXX_parallel/ark_test_heat2D_mri.cpp index 33e734afd6..7eb273aacc 100644 --- a/test/unit_tests/arkode/CXX_parallel/ark_test_heat2D_mri.cpp +++ b/test/unit_tests/arkode/CXX_parallel/ark_test_heat2D_mri.cpp @@ -31,12 +31,12 @@ #include #include -#include "arkode/arkode_arkstep.h" // prototypes for ARKStep fcts., consts -#include "arkode/arkode_mristep.h" // prototypes for MRIStep fcts., consts -#include "mpi.h" // MPI header file -#include "nvector/nvector_parallel.h" // parallel N_Vector types, fcts., macros -#include "sundials/sundials_types.h" // def. of type 'sunrealtype' -#include "sunlinsol/sunlinsol_pcg.h" // access to PCG SUNLinearSolver +#include "arkode/arkode_arkstep.h" // prototypes for ARKStep fcts., consts +#include "arkode/arkode_mristep.h" // prototypes for MRIStep fcts., consts +#include "mpi.h" // MPI header file +#include "nvector/nvector_parallel.h" // parallel N_Vector types, fcts., macros +#include "sundials/sundials_types.hpp" // def. of type 'sunrealtype' +#include "sunlinsol/sunlinsol_pcg.h" // access to PCG SUNLinearSolver using namespace std; @@ -205,8 +205,9 @@ int main(int argc, char* argv[]) { for (i = 0; i < udata->nxl; i++) { - data[IDX(i, j, udata->nxl)] = sin(PI * (udata->is + i) * udata->dx) * - sin(TWO * PI * (udata->js + j) * udata->dy); + data[IDX(i, j, udata->nxl)] = + SUNRsin(PI * (udata->is + i) * udata->dx) * + SUNRsin(TWO * PI * (udata->js + j) * udata->dy); } } diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp index 2b98b2a64a..554edda81e 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp @@ -460,7 +460,7 @@ static int adaptive_run(void* arkode_mem, N_Vector y, sunrealtype T0, (abstol + rtols[irtol] * abs(yrefdata[2])); dsm[ipart] = rtols[irtol] * - sqrt((udsm * udsm + vdsm * vdsm + wdsm * wdsm) / SUN_RCONST(3.0)); + SUNRsqrt((udsm * udsm + vdsm * vdsm + wdsm * wdsm) / SUN_RCONST(3.0)); cout << " rtol " << rtols[irtol] << " rk_type " << rk_type << " order " << order << " acc " << accum_types[iaccum] << " t " << t << " dsm " << dsm[ipart] << " dsm_est " << dsm_est[ipart] @@ -555,8 +555,8 @@ static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, sunrealtype T (abstol + reltol * abs(yrefdata[1])); const sunrealtype wdsm = abs(ydata[2] - yrefdata[2]) / (abstol + reltol * abs(yrefdata[2])); - dsm[ipart] = reltol * sqrt((udsm * udsm + vdsm * vdsm + wdsm * wdsm) / - SUN_RCONST(3.0)); + dsm[ipart] = reltol * SUNRsqrt((udsm * udsm + vdsm * vdsm + wdsm * wdsm) / + SUN_RCONST(3.0)); cout << " h " << hvals[ih] << " rk_type " << rk_type << " order " << order << " acc " << accum_types[iaccum] << " t " << t << " dsm " << dsm[ipart] << " dsm_est " << dsm_est[ipart] @@ -638,8 +638,8 @@ static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, sunrealtype T (abstol + reltol * abs(yrefdata[1])); const sunrealtype wdsm = abs(ydata[2] - yrefdata[2]) / (abstol + reltol * abs(yrefdata[2])); - dsm[ipart] = reltol * sqrt((udsm * udsm + vdsm * vdsm + wdsm * wdsm) / - SUN_RCONST(3.0)); + dsm[ipart] = reltol * SUNRsqrt((udsm * udsm + vdsm * vdsm + wdsm * wdsm) / + SUN_RCONST(3.0)); cout << " h " << hvals[ih] << " rk_type " << rk_type << " order " << order << " acc " << 2 << " t " << t << " dsm " << dsm[ipart] << " dsm_est " << dsm_est[ipart] << " nsteps " << Nsteps[ipart] diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp index c75da8895f..0c91216288 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp @@ -413,7 +413,8 @@ static int adaptive_run(void* arkode_mem, N_Vector y, sunrealtype T0, (abstol + rtols[irtol] * abs(utrue(t))); sunrealtype vdsm = abs(ydata[1] - vtrue(t, udata)) / (abstol + rtols[irtol] * abs(vtrue(t, udata))); - dsm[ipart] = rtols[irtol] * sqrt(0.5 * (udsm * udsm + vdsm * vdsm)); + dsm[ipart] = rtols[irtol] * + SUNRsqrt(SUN_RCONST(0.5) * (udsm * udsm + vdsm * vdsm)); cout << " rtol " << rtols[irtol] << " rk_type " << rk_type << " order " << order << " acc " << accum_types[iaccum] << " t " << t << " dsm " << dsm[ipart] << " dsm_est " << dsm_est[ipart] @@ -524,7 +525,8 @@ static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, (abstol + reltol * abs(utrue(t))); sunrealtype vdsm = abs(ydata[1] - vtrue(t, udata)) / (abstol + reltol * abs(vtrue(t, udata))); - dsm[ipart] = reltol * sqrt(0.5 * (udsm * udsm + vdsm * vdsm)); + dsm[ipart] = reltol * + SUNRsqrt(SUN_RCONST(0.5) * (udsm * udsm + vdsm * vdsm)); cout << " h " << hvals[ih] << " rk_type " << rk_type << " order " << order << " acc " << accum_types[iaccum] << " t " << t << " dsm " << dsm[ipart] << " dsm_est " << dsm_est[ipart] @@ -618,7 +620,8 @@ static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, (abstol + reltol * abs(utrue(t))); sunrealtype vdsm = abs(ydata[1] - vtrue(t, udata)) / (abstol + reltol * abs(vtrue(t, udata))); - dsm[ipart] = reltol * sqrt(0.5 * (udsm * udsm + vdsm * vdsm)); + dsm[ipart] = reltol * + SUNRsqrt(SUN_RCONST(0.5) * (udsm * udsm + vdsm * vdsm)); cout << " h " << hvals[ih] << " rk_type " << rk_type << " order " << order << " acc " << 2 << " t " << t << " dsm " << dsm[ipart] << " dsm_est " << dsm_est[ipart] << " nsteps " << Nsteps[ipart] @@ -632,20 +635,21 @@ static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, return (0); } -static sunrealtype p(sunrealtype t) { return (cos(t)); } +static sunrealtype p(sunrealtype t) { return (SUNRcos(t)); } static sunrealtype q(sunrealtype t, UserData& udata) { - return (cos(udata.omega * t * (ONE + exp(-(t - 2) * (t - 2))))); + return (SUNRcos(udata.omega * t * (ONE + SUNRexp(-(t - TWO) * (t - TWO))))); } -static sunrealtype pdot(sunrealtype t) { return (-sin(t)); } +static sunrealtype pdot(sunrealtype t) { return (-SUNRsin(t)); } static sunrealtype qdot(sunrealtype t, UserData& udata) { - return (-sin(udata.omega * t * (ONE + exp(-(t - 2) * (t - 2)))) * udata.omega * - (ONE + exp(-(t - 2) * (t - 2)) - - t * 2 * (t - 2) * (exp(-(t - 2) * (t - 2))))); + return (-SUNRsin(udata.omega * t * (ONE + SUNRexp(-(t - TWO) * (t - TWO)))) * + udata.omega * + (ONE + SUNRexp(-(t - TWO) * (t - TWO)) - + t * TWO * (t - TWO) * (SUNRexp(-(t - TWO) * (t - TWO))))); } static sunrealtype utrue(sunrealtype t) { return (SUNRsqrt(TWO + p(t))); } diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_adjoint_ark.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_adjoint_ark.cpp index 0779c385fd..3cfe649647 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_adjoint_ark.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_adjoint_ark.cpp @@ -257,7 +257,7 @@ int main(int argc, char* argv[]) const sunrealtype dt = args.dt; sunrealtype t0 = SUN_RCONST(0.0); sunrealtype tf = args.tf; - const int nsteps = (int)ceil(((tf - t0) / dt)); + const int nsteps = (int)SUNRceil(((tf - t0) / dt)); const int order = args.order; void* arkode_mem = ARKStepCreate(ode_rhs, NULL, t0, u, sunctx); diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_adjoint_erk.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_adjoint_erk.cpp index 26b11c7c08..6292343a25 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_adjoint_erk.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_adjoint_erk.cpp @@ -257,7 +257,7 @@ int main(int argc, char* argv[]) const sunrealtype dt = args.dt; sunrealtype t0 = SUN_RCONST(0.0); sunrealtype tf = args.tf; - const int nsteps = (int)ceil(((tf - t0) / dt)); + const int nsteps = (int)SUNRceil(((tf - t0) / dt)); const int order = args.order; void* arkode_mem = ERKStepCreate(ode_rhs, t0, u, sunctx); diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_analytic_sys_mri.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_analytic_sys_mri.cpp index 4a3a99cb7c..c308aaaf31 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_analytic_sys_mri.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_analytic_sys_mri.cpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp index 01ca2572cd..ffe9f9ebc2 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp @@ -823,19 +823,19 @@ int main(int argc, char* argv[]) u = ydata[0]; v = ydata[1]; w = ydata[2]; - uerr = std::abs(yrefdata[0] - u); - verr = std::abs(yrefdata[1] - v); - werr = std::abs(yrefdata[2] - w); + uerr = SUNRabs(yrefdata[0] - u); + verr = SUNRabs(yrefdata[1] - v); + werr = SUNRabs(yrefdata[2] - w); uerrtot += uerr * uerr; verrtot += verr * verr; werrtot += werr * werr; errtot += uerr * uerr + verr * verr + werr * werr; accuracy = std::max(accuracy, - uerr / std::abs(opts.atol + opts.rtol * yrefdata[0])); + uerr / SUNRabs(opts.atol + opts.rtol * yrefdata[0])); accuracy = std::max(accuracy, - verr / std::abs(opts.atol + opts.rtol * yrefdata[1])); + verr / SUNRabs(opts.atol + opts.rtol * yrefdata[1])); accuracy = std::max(accuracy, - werr / std::abs(opts.atol + opts.rtol * yrefdata[2])); + werr / SUNRabs(opts.atol + opts.rtol * yrefdata[2])); // Periodically output current results to screen if (t >= tout) @@ -880,10 +880,10 @@ int main(int argc, char* argv[]) check_flag(retval, "ARKodeGetNumRhsEvals"); // Print some final statistics - uerrtot = std::sqrt(uerrtot / (sunrealtype)nsts); - verrtot = std::sqrt(verrtot / (sunrealtype)nsts); - werrtot = std::sqrt(werrtot / (sunrealtype)nsts); - errtot = std::sqrt(errtot / SUN_RCONST(3.0) / (sunrealtype)nsts); + uerrtot = SUNRsqrt(uerrtot / (sunrealtype)nsts); + verrtot = SUNRsqrt(verrtot / (sunrealtype)nsts); + werrtot = SUNRsqrt(werrtot / (sunrealtype)nsts); + errtot = SUNRsqrt(errtot / SUN_RCONST(3.0) / (sunrealtype)nsts); std::cout << "\nFinal Solver Statistics:\n"; std::cout << " Slow steps = " << nsts << " (attempts = " << natts << ", fails = " << netfs << ")\n"; diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_ark.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_ark.cpp index cae0f7c2a1..7eb2e4f6c8 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_ark.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_ark.cpp @@ -694,11 +694,11 @@ int get_method_properties(ARKodeButcherTable Be, ARKodeButcherTable Bi, explicit_first_stage = true; if (Bi) { - if (std::abs(Bi->A[0][0]) > ZERO) { explicit_first_stage = false; } + if (SUNRabs(Bi->A[0][0]) > ZERO) { explicit_first_stage = false; } } if (Be) { - if (std::abs(Be->A[0][0]) > ZERO) { explicit_first_stage = false; } + if (SUNRabs(Be->A[0][0]) > ZERO) { explicit_first_stage = false; } } // Check for stiffly accurate method @@ -896,7 +896,7 @@ int fe(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) if (prob_data->m_type == mass_matrix_type::fixed) { yd_data[0] *= TWO; } else if (prob_data->m_type == mass_matrix_type::time_dependent) { - yd_data[0] *= TWO + std::cos(t); + yd_data[0] *= TWO + SUNRcos(t); } return 0; @@ -914,7 +914,7 @@ int fi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) if (prob_data->m_type == mass_matrix_type::fixed) { yd_data[0] *= TWO; } else if (prob_data->m_type == mass_matrix_type::time_dependent) { - yd_data[0] *= TWO + std::cos(t); + yd_data[0] *= TWO + SUNRcos(t); } return 0; @@ -939,7 +939,7 @@ int MassMatrix(sunrealtype t, SUNMatrix M, void* user_data, N_Vector tmp1, ProblemData* prob_data = static_cast(user_data); if (prob_data->m_type == mass_matrix_type::fixed) { M_data[0] = TWO; } - else { M_data[0] = TWO + std::cos(t); } + else { M_data[0] = TWO + SUNRcos(t); } return 0; } diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_erk.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_erk.cpp index f1961e3c9f..425a0803ab 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_erk.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_erk.cpp @@ -143,8 +143,8 @@ int main(int argc, char* argv[]) ARKodeButcherTable Be = nullptr; - int stages, order; - bool explicit_first_stage, stiffly_accurate, fsal; + int stages, order = 1; + bool explicit_first_stage = true, stiffly_accurate = true, fsal = true; // -------- // Explicit @@ -198,8 +198,8 @@ int run_tests(ARKodeButcherTable Be, ProblemData& prob_data, int numfails = 0; // Get method properties - int stages, order; - bool explicit_first_stage, stiffly_accurate, fsal; + int stages, order = 1; + bool explicit_first_stage = true, stiffly_accurate = true, fsal = true; flag = get_method_properties(Be, stages, order, explicit_first_stage, stiffly_accurate, fsal); if (check_flag(&flag, "get_method_properties", 1)) { return 1; } @@ -385,7 +385,7 @@ int get_method_properties(ARKodeButcherTable Be, int& stages, int& order, // Check for explicit first stage explicit_first_stage = true; - if (std::abs(Be->A[0][0]) > ZERO) { explicit_first_stage = false; } + if (SUNRabs(Be->A[0][0]) > ZERO) { explicit_first_stage = false; } // Check for stiffly accurate method stiffly_accurate = ARKodeButcherTable_IsStifflyAccurate(Be); diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp index 15eb7deda8..88c7faa189 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp @@ -451,7 +451,7 @@ int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, { pow += prob_data.lambda_i; } - sunrealtype ytrue = exp(pow * t); + sunrealtype ytrue = SUNRexp(pow * t); sunrealtype* ydata = N_VGetArrayPointer(y); sunrealtype error = ytrue - ydata[0]; diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_getjac.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_getjac.cpp index 968072bbbb..5d6106c173 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_getjac.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_getjac.cpp @@ -61,24 +61,24 @@ // ----------------------------------------------------------------------------- // Compute r(t) -static sunrealtype r(sunrealtype t) { return HALF * cos(t); } +static sunrealtype r(sunrealtype t) { return HALF * SUNRcos(t); } // Compute the derivative of r(t) -static sunrealtype rdot(sunrealtype t) { return -HALF * sin(t); } +static sunrealtype rdot(sunrealtype t) { return -HALF * SUNRsin(t); } // Compute s(t) -static sunrealtype s(sunrealtype t) { return cos(TWENTY * t); } +static sunrealtype s(sunrealtype t) { return SUNRcos(TWENTY * t); } // Compute the derivative of s(t) -static sunrealtype sdot(sunrealtype t) { return -TWENTY * sin(TWENTY * t); } +static sunrealtype sdot(sunrealtype t) { return -TWENTY * SUNRsin(TWENTY * t); } // Compute the true solution static int ytrue(sunrealtype t, N_Vector y) { sunrealtype* ydata = N_VGetArrayPointer(y); - ydata[0] = sqrt(ONE + r(t)); - ydata[1] = sqrt(TWO + s(t)); + ydata[0] = SUNRsqrt(ONE + r(t)); + ydata[1] = SUNRsqrt(TWO + s(t)); return 0; } @@ -175,7 +175,7 @@ int main(int argc, char* argv[]) sundials::Context sunctx; // Comparison tolerance - sunrealtype tol = 100 * std::sqrt(SUN_UNIT_ROUNDOFF); + sunrealtype tol = 100 * SUNRsqrt(SUN_UNIT_ROUNDOFF); if (argc > 1) { #if defined(SUNDIALS_SINGLE_PRECISION) @@ -184,6 +184,8 @@ int main(int argc, char* argv[]) tol = std::stod(argv[1]); #elif defined(SUNDIALS_EXTENDED_PRECISION) tol = std::stold(argv[1]); +#elif defined(SUNDIALS_FLOAT128_PRECISION) + tol = strtoflt128(argv[1], NULL); #else #error "SUNDIALS precision macro not defined" #endif @@ -202,6 +204,8 @@ int main(int argc, char* argv[]) const sunrealtype rtol = SUN_RCONST(1.0e-6); #elif defined(SUNDIALS_EXTENDED_PRECISION) const sunrealtype rtol = SUN_RCONST(1.0e-9); +#elif defined(SUNDIALS_FLOAT128_PRECISION) + const sunrealtype rtol = SUN_RCONST(1.0e-9); #else #error "SUNDIALS precision macro not defined" #endif @@ -275,7 +279,11 @@ int main(int argc, char* argv[]) // Output Jacobian data std::cout << std::scientific; - std::cout << std::setprecision(std::numeric_limits::digits10); +#if defined(SUNDIALS_FLOAT128_PRECISION) + std::cout << std::setprecision(SUN_DIGITS10 / 2); +#else + std::cout << std::setprecision(SUN_DIGITS10); +#endif std::cout << "Jac nst = " << nst_Jdq << std::endl; std::cout << "Jac t = " << t_Jdq << std::endl; std::cout << std::endl; @@ -293,9 +301,9 @@ int main(int argc, char* argv[]) std::cout << std::setw(8) << std::right << i << std::setw(25) << std::right << Jdq_data[i] << std::setw(25) << std::right << Jtrue_data[i] << std::setw(25) << std::right - << std::abs(Jdq_data[i] - Jtrue_data[i]) << std::setw(25) + << SUNRabs(Jdq_data[i] - Jtrue_data[i]) << std::setw(25) << std::right - << std::abs(Jdq_data[i] - Jtrue_data[i]) / Jtrue_data[i] + << SUNRabs(Jdq_data[i] - Jtrue_data[i]) / Jtrue_data[i] << std::endl; result += SUNRCompareTol(Jdq_data[i], Jtrue_data[i], tol); } diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_getjac_mri.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_getjac_mri.cpp index f3a00baa85..3db67f34e7 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_getjac_mri.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_getjac_mri.cpp @@ -62,24 +62,24 @@ // ----------------------------------------------------------------------------- // Compute r(t) -static sunrealtype r(sunrealtype t) { return HALF * cos(t); } +static sunrealtype r(sunrealtype t) { return HALF * SUNRcos(t); } // Compute the derivative of r(t) -static sunrealtype rdot(sunrealtype t) { return -HALF * sin(t); } +static sunrealtype rdot(sunrealtype t) { return -HALF * SUNRsin(t); } // Compute s(t) -static sunrealtype s(sunrealtype t) { return cos(TWENTY * t); } +static sunrealtype s(sunrealtype t) { return SUNRcos(TWENTY * t); } // Compute the derivative of s(t) -static sunrealtype sdot(sunrealtype t) { return -TWENTY * sin(TWENTY * t); } +static sunrealtype sdot(sunrealtype t) { return -TWENTY * SUNRsin(TWENTY * t); } // Compute the true solution static int ytrue(sunrealtype t, N_Vector y) { sunrealtype* ydata = N_VGetArrayPointer(y); - ydata[0] = sqrt(ONE + r(t)); - ydata[1] = sqrt(TWO + s(t)); + ydata[0] = SUNRsqrt(ONE + r(t)); + ydata[1] = SUNRsqrt(TWO + s(t)); return 0; } @@ -185,18 +185,10 @@ int main(int argc, char* argv[]) sundials::Context sunctx; // Comparison tolerance - sunrealtype tol = 100 * std::sqrt(SUN_UNIT_ROUNDOFF); + sunrealtype tol = 100 * SUNRsqrt(SUN_UNIT_ROUNDOFF); if (argc > 1) { -#if defined(SUNDIALS_SINGLE_PRECISION) - tol = std::stof(argv[1]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - tol = std::stod(argv[1]); -#elif defined(SUNDIALS_EXTENDED_PRECISION) - tol = std::stold(argv[1]); -#else -#error "SUNDIALS precision macro not defined" -#endif + tol = SUNStrToReal(argv[1]); if (tol <= ZERO) { std::cerr << "ERROR: Invalid tolerance, tol = " << tol << std::endl; @@ -212,6 +204,8 @@ int main(int argc, char* argv[]) const sunrealtype rtol = SUN_RCONST(1.0e-6); #elif defined(SUNDIALS_EXTENDED_PRECISION) const sunrealtype rtol = SUN_RCONST(1.0e-9); +#elif defined(SUNDIALS_FLOAT128_PRECISION) + const sunrealtype rtol = SUN_RCONST(1.0e-12); #else #error "SUNDIALS precision macro not defined" #endif @@ -297,7 +291,11 @@ int main(int argc, char* argv[]) // Output Jacobian data std::cout << std::scientific; - std::cout << std::setprecision(std::numeric_limits::digits10); +#if defined(SUNDIALS_FLOAT128_PRECISION) + std::cout << std::setprecision(SUN_DIGITS10 / 2); +#else + std::cout << std::setprecision(SUN_DIGITS10); +#endif std::cout << "Jac nst = " << nst_Jdq << std::endl; std::cout << "Jac t = " << t_Jdq << std::endl; std::cout << std::endl; @@ -315,9 +313,9 @@ int main(int argc, char* argv[]) std::cout << std::setw(8) << std::right << i << std::setw(25) << std::right << Jdq_data[i] << std::setw(25) << std::right << Jtrue_data[i] << std::setw(25) << std::right - << std::abs(Jdq_data[i] - Jtrue_data[i]) << std::setw(25) + << SUNRabs(Jdq_data[i] - Jtrue_data[i]) << std::setw(25) << std::right - << std::abs(Jdq_data[i] - Jtrue_data[i]) / Jtrue_data[i] + << SUNRabs(Jdq_data[i] - Jtrue_data[i]) / Jtrue_data[i] << std::endl; result += SUNRCompareTol(Jdq_data[i], Jtrue_data[i], tol); } diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp index a34fb7bc39..762fff99b4 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp @@ -129,7 +129,10 @@ #include // dense matrix type, fcts., macros #include "../../utilities/test_utilities.hpp" // common utility functions -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define ESYM "Qe" +#define FSYM "Qf" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define ESYM "Le" #define FSYM "Lf" #else @@ -830,15 +833,15 @@ int main(int argc, char* argv[]) // access/print solution and error u = ydata[0]; v = ydata[1]; - uerr = std::abs(yrefdata[0] - u); - verr = std::abs(yrefdata[1] - v); + uerr = SUNRabs(yrefdata[0] - u); + verr = SUNRabs(yrefdata[1] - v); uerrtot += uerr * uerr; verrtot += verr * verr; errtot += uerr * uerr + verr * verr; accuracy = std::max(accuracy, - uerr / std::abs(opts.atol + opts.rtol * yrefdata[0])); + uerr / SUNRabs(opts.atol + opts.rtol * yrefdata[0])); accuracy = std::max(accuracy, - verr / std::abs(opts.atol + opts.rtol * yrefdata[1])); + verr / SUNRabs(opts.atol + opts.rtol * yrefdata[1])); // Periodically output current results to screen if (t >= tout) @@ -881,9 +884,9 @@ int main(int argc, char* argv[]) check_flag(retval, "ARKodeGetNumRhsEvals"); // Print some final statistics - uerrtot = std::sqrt(uerrtot / (sunrealtype)nsts); - verrtot = std::sqrt(verrtot / (sunrealtype)nsts); - errtot = std::sqrt(errtot / SUN_RCONST(2.0) / (sunrealtype)nsts); + uerrtot = SUNRsqrt(uerrtot / (sunrealtype)nsts); + verrtot = SUNRsqrt(verrtot / (sunrealtype)nsts); + errtot = SUNRsqrt(errtot / SUN_RCONST(2.0) / (sunrealtype)nsts); std::cout << "\nFinal Solver Statistics:\n"; std::cout << " Slow steps = " << nsts << " (attempts = " << natts << ", fails = " << netfs << ")\n"; @@ -1115,31 +1118,31 @@ static int Jn(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, // Private helper functions // ----------------------------- -static sunrealtype r(sunrealtype t, Options* opts) { return (cos(t)); } +static sunrealtype r(sunrealtype t, Options* opts) { return (SUNRcos(t)); } static sunrealtype s(sunrealtype t, Options* opts) { - return (cos(opts->w * t * (ONE + exp(-(t - TWO) * (t - TWO))))); + return (SUNRcos(opts->w * t * (ONE + SUNRexp(-(t - TWO) * (t - TWO))))); } -static sunrealtype rdot(sunrealtype t, Options* opts) { return (-sin(t)); } +static sunrealtype rdot(sunrealtype t, Options* opts) { return (-SUNRsin(t)); } static sunrealtype sdot(sunrealtype t, Options* opts) { const sunrealtype tTwo = t - TWO; - const sunrealtype eterm = exp(-tTwo * tTwo); - return (-sin(opts->w * t * (ONE + eterm)) * opts->w * + const sunrealtype eterm = SUNRexp(-tTwo * tTwo); + return (-SUNRsin(opts->w * t * (ONE + eterm)) * opts->w * (ONE + eterm * (ONE - TWO * t * tTwo))); } static sunrealtype utrue(sunrealtype t, Options* opts) { - return (std::sqrt(TWO + r(t, opts))); + return (SUNRsqrt(TWO + r(t, opts))); } static sunrealtype vtrue(sunrealtype t, Options* opts) { - return (std::sqrt(TWO + s(t, opts))); + return (SUNRsqrt(TWO + s(t, opts))); } static int Ytrue(sunrealtype t, N_Vector y, Options* opts) diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp index 70ab65646d..b51744b1e3 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp @@ -10,9 +10,6 @@ * All rights reserved. * * See the top-level LICENSE and NOTICE files for details. - * - * SPDX-License-Identifier: BSD-3-Clause - * SUNDIALS Copyright End *--------------------------------------------------------------- * Routine to test an MRI method's embedding-based error * estimate. Uses the "stiff Brusselator" test problem with 3 @@ -537,7 +534,7 @@ static int run_test(void* mristep_mem, void* arkode_ref, N_Vector y, sunrealtype wdsm = abs(ydata[2] - y2data[2]) / (abstol + reltol * abs(y2data[2])); dsm[iH][ipart] = - sqrt((udsm * udsm + vdsm * vdsm + wdsm * wdsm) / SUN_RCONST(3.0)); + SUNRsqrt((udsm * udsm + vdsm * vdsm + wdsm * wdsm) / SUN_RCONST(3.0)); cout << " H " << Hvals[iH] << " method " << method << " t " << t << " dsm " << dsm[iH][ipart] << " dsm_est " << dsm_est[iH][ipart] << endl; diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp index 167448cf87..276370948e 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp @@ -461,7 +461,7 @@ static int run_test(void* mristep_mem, N_Vector y, sunrealtype T0, (abstol + reltol * abs(utrue(t))); sunrealtype vdsm = abs(ydata[1] - vtrue(t, udata)) / (abstol + reltol * abs(vtrue(t, udata))); - dsm[iH][ipart] = sqrt(0.5 * (udsm * udsm + vdsm * vdsm)); + dsm[iH][ipart] = SUNRsqrt(SUN_RCONST(0.5) * (udsm * udsm + vdsm * vdsm)); cout << " H " << Hvals[iH] << " method " << method << " t " << t << " dsm " << dsm[iH][ipart] << " dsm_est " << dsm_est[iH][ipart] << endl; @@ -482,20 +482,21 @@ static int run_test(void* mristep_mem, N_Vector y, sunrealtype T0, return (0); } -static sunrealtype p(sunrealtype t) { return (cos(t)); } +static sunrealtype p(sunrealtype t) { return (SUNRcos(t)); } static sunrealtype q(sunrealtype t, UserData& udata) { - return (cos(udata.omega * t * (ONE + exp(-(t - 2) * (t - 2))))); + return (SUNRcos(udata.omega * t * (ONE + SUNRexp(-(t - TWO) * (t - TWO))))); } -static sunrealtype pdot(sunrealtype t) { return (-sin(t)); } +static sunrealtype pdot(sunrealtype t) { return (-SUNRsin(t)); } static sunrealtype qdot(sunrealtype t, UserData& udata) { - return (-sin(udata.omega * t * (ONE + exp(-(t - 2) * (t - 2)))) * udata.omega * - (ONE + exp(-(t - 2) * (t - 2)) - - t * 2 * (t - 2) * (exp(-(t - 2) * (t - 2))))); + return (-SUNRsin(udata.omega * t * (ONE + SUNRexp(-(t - TWO) * (t - TWO)))) * + udata.omega * + (ONE + SUNRexp(-(t - TWO) * (t - TWO)) - + t * TWO * (t - TWO) * (SUNRexp(-(t - TWO) * (t - TWO))))); } static sunrealtype utrue(sunrealtype t) { return (SUNRsqrt(TWO + p(t))); } diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_splittingstep.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_splittingstep.cpp index 24e2c8cb65..4094c40cd3 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_splittingstep.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_splittingstep.cpp @@ -62,8 +62,8 @@ static int test_forward(sundials::Context& ctx, int order, int partitions) { partition_mem[i] = ERKStepCreate(f, t0, y, ctx); /* The lambdas sum up to 1 */ - lambda[i] = std::pow(SUN_RCONST(2.0), i) / - (1 - std::pow(SUN_RCONST(2.0), partitions)); + lambda[i] = SUNRpowerI(SUN_RCONST(2.0), i) / + (SUN_RCONST(1.0) - SUNRpowerI(SUN_RCONST(2.0), partitions)); ARKodeSetUserData(partition_mem[i], &lambda[i]); ARKodeSStolerances(partition_mem[i], local_tol, local_tol); ARKodeCreateSUNStepper(partition_mem[i], &steppers[i]); @@ -76,7 +76,7 @@ static int test_forward(sundials::Context& ctx, int order, int partitions) ARKodeEvolve(arkode_mem, tf, y, &tret, ARK_NORMAL); /* Check that the solution matches the exact solution */ - auto exact_solution = std::exp(t0 - tf); + auto exact_solution = SUNRexp(t0 - tf); auto numerical_solution = N_VGetArrayPointer(y)[0]; auto err = numerical_solution - exact_solution; @@ -271,8 +271,8 @@ static int test_resize(const sundials::Context& ctx) ARKodeEvolve(arkode_mem, t2, y_new, &tret, ARK_NORMAL); auto err = N_VClone(y_new); - N_VGetArrayPointer(err)[0] = std::exp(t1 - t2); - N_VGetArrayPointer(err)[1] = std::exp(t0 - t2); + N_VGetArrayPointer(err)[0] = sunrealtype(SUNRexp(t1 - t2)); + N_VGetArrayPointer(err)[1] = SUNRexp(t0 - t2); N_VLinearSum(SUN_RCONST(1.0), err, -SUN_RCONST(1.0), y_new, err); auto max_err = N_VMaxNorm(err); @@ -342,7 +342,7 @@ static SUNStepper create_exp_stepper(const sundials::Context& ctx, [](SUNStepper s, sunrealtype tout, N_Vector vret, sunrealtype* tret) { auto& content = Content::from_stepper(s); - N_VScale(std::exp(content.lambda * (tout - content.t)), content.v, vret); + N_VScale(SUNRexp(content.lambda * (tout - content.t)), content.v, vret); *tret = tout; return 0; }; @@ -388,7 +388,7 @@ static int test_custom_stepper(const sundials::Context& ctx, int order) ARKodeEvolve(arkode_mem, tf, y, &tret, ARK_NORMAL); /* Check that the solution matches the exact solution */ - auto exact_solution = std::exp(t0 - tf); + auto exact_solution = SUNRexp(t0 - tf); auto numerical_solution = N_VGetArrayPointer(y)[0]; auto err = numerical_solution - exact_solution; diff --git a/test/unit_tests/arkode/C_serial/ark_test_arkstepsetforcing.c b/test/unit_tests/arkode/C_serial/ark_test_arkstepsetforcing.c index f11b5507dc..dcaa82c7ee 100644 --- a/test/unit_tests/arkode/C_serial/ark_test_arkstepsetforcing.c +++ b/test/unit_tests/arkode/C_serial/ark_test_arkstepsetforcing.c @@ -36,7 +36,10 @@ #include "sunlinsol/sunlinsol_dense.h" #include "sunmatrix/sunmatrix_dense.h" -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#define ESYM "Qe" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #define ESYM "Le" #else @@ -74,7 +77,7 @@ int main(int argc, char* argv[]) /* tolerances */ sunrealtype reltol = SUNRsqrt(SUN_UNIT_ROUNDOFF); - sunrealtype abstol = SUNRsqrt(SUN_UNIT_ROUNDOFF) / 100; + sunrealtype abstol = SUNRsqrt(SUN_UNIT_ROUNDOFF) / SUN_RCONST(100.0); /* general problem variables */ int flag; /* reusable error-checking flag */ @@ -400,7 +403,11 @@ int main(int argc, char* argv[]) printf("IMEX solution:\n"); N_VPrint_Serial(y); -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) + /* The 5th order case with float128 precision tends to slightly under solve + so we loosen the comparison tolerance by 10% */ + if (order == 5) { reltol *= SUN_RCONST(1.1); }; +#elif defined(SUNDIALS_EXTENDED_PRECISION) /* The 5th order case with extended precision tends to slightly under solve so we loosen the comparison tolerance by 5% */ if (order == 5) { reltol *= SUN_RCONST(1.05); }; diff --git a/test/unit_tests/arkode/C_serial/ark_test_forcingstep.c b/test/unit_tests/arkode/C_serial/ark_test_forcingstep.c index 4d2ad74406..b85a5b7eb7 100644 --- a/test/unit_tests/arkode/C_serial/ark_test_forcingstep.c +++ b/test/unit_tests/arkode/C_serial/ark_test_forcingstep.c @@ -22,7 +22,9 @@ #include #include -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #else #define GSYM "g" diff --git a/test/unit_tests/arkode/C_serial/ark_test_interp.c b/test/unit_tests/arkode/C_serial/ark_test_interp.c index 6d463a6048..9e9835639d 100644 --- a/test/unit_tests/arkode/C_serial/ark_test_interp.c +++ b/test/unit_tests/arkode/C_serial/ark_test_interp.c @@ -34,23 +34,19 @@ #include #include -#define NHVALS 9 - -/* Precision specific math function macros */ -#if defined(SUNDIALS_DOUBLE_PRECISION) -#define SIN(x) (sin((x))) -#define COS(x) (cos((x))) -#define SQRT(x) (sqrt((x))) -#elif defined(SUNDIALS_SINGLE_PRECISION) -#define SIN(x) (sinf((x))) -#define COS(x) (cosf((x))) -#define SQRT(x) (sqrtf((x))) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define FSYM "Qf" +#define ESYM "Qe" #elif defined(SUNDIALS_EXTENDED_PRECISION) -#define SIN(x) (sinl((x))) -#define COS(x) (cosl((x))) -#define SQRT(x) (sqrtl((x))) +#define FSYM "Lf" +#define ESYM "Le" +#else +#define FSYM "f" +#define ESYM "e" #endif +#define NHVALS 9 + /* User-supplied Functions Called by the Solver */ static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); @@ -105,7 +101,7 @@ int main(int argc, char* argv[]) /* if an argument supplied, set lambda (otherwise use -100) */ lambda = -SUN_RCONST(100.0); - if (argc > 1) { lambda = strtod(argv[1], NULL); } + if (argc > 1) { lambda = SUNStrToReal(argv[1]); } /* determine test configuration */ if (sizeof(sunrealtype) == 4) { rtype = 32; } @@ -274,50 +270,52 @@ int main(int argc, char* argv[]) /* set error values */ /* y */ NV_Ith_S(yerr, 0) = - SUNRabs(SIN(SUN_RCONST(2.0) * t_test) - NV_Ith_S(ytest, 0)); + SUNRabs(SUNRsin(SUN_RCONST(2.0) * t_test) - NV_Ith_S(ytest, 0)); NV_Ith_S(yerr, 1) = - SUNRabs(COS(SUN_RCONST(3.0) * t_test) - NV_Ith_S(ytest, 1)); + SUNRabs(SUNRcos(SUN_RCONST(3.0) * t_test) - NV_Ith_S(ytest, 1)); /* dy */ - NV_Ith_S(dyerr, 0) = SUNRabs( - SUN_RCONST(2.0) * COS(SUN_RCONST(2.0) * t_test) - NV_Ith_S(dytest, 0)); - NV_Ith_S(dyerr, 1) = SUNRabs( - -SUN_RCONST(3.0) * SIN(SUN_RCONST(3.0) * t_test) - NV_Ith_S(dytest, 1)); + NV_Ith_S(dyerr, 0) = + SUNRabs(SUN_RCONST(2.0) * SUNRcos(SUN_RCONST(2.0) * t_test) - + NV_Ith_S(dytest, 0)); + NV_Ith_S(dyerr, 1) = + SUNRabs(-SUN_RCONST(3.0) * SUNRsin(SUN_RCONST(3.0) * t_test) - + NV_Ith_S(dytest, 1)); /* d2y */ - NV_Ith_S(d2yerr, - 0) = SUNRabs(-SUN_RCONST(4.0) * SIN(SUN_RCONST(2.0) * t_test) - - NV_Ith_S(d2ytest, 0)); - NV_Ith_S(d2yerr, - 1) = SUNRabs(-SUN_RCONST(9.0) * COS(SUN_RCONST(3.0) * t_test) - - NV_Ith_S(d2ytest, 1)); + NV_Ith_S(d2yerr, 0) = + SUNRabs(-SUN_RCONST(4.0) * SUNRsin(SUN_RCONST(2.0) * t_test) - + NV_Ith_S(d2ytest, 0)); + NV_Ith_S(d2yerr, 1) = + SUNRabs(-SUN_RCONST(9.0) * SUNRcos(SUN_RCONST(3.0) * t_test) - + NV_Ith_S(d2ytest, 1)); /* d3y */ - NV_Ith_S(d3yerr, - 0) = SUNRabs(-SUN_RCONST(8.0) * COS(SUN_RCONST(2.0) * t_test) - - NV_Ith_S(d3ytest, 0)); - NV_Ith_S(d3yerr, - 1) = SUNRabs(SUN_RCONST(27.0) * SIN(SUN_RCONST(3.0) * t_test) - - NV_Ith_S(d3ytest, 1)); + NV_Ith_S(d3yerr, 0) = + SUNRabs(-SUN_RCONST(8.0) * SUNRcos(SUN_RCONST(2.0) * t_test) - + NV_Ith_S(d3ytest, 0)); + NV_Ith_S(d3yerr, 1) = + SUNRabs(SUN_RCONST(27.0) * SUNRsin(SUN_RCONST(3.0) * t_test) - + NV_Ith_S(d3ytest, 1)); /* d4y */ - NV_Ith_S(d4yerr, - 0) = SUNRabs(SUN_RCONST(16.0) * SIN(SUN_RCONST(2.0) * t_test) - - NV_Ith_S(d4ytest, 0)); - NV_Ith_S(d4yerr, - 1) = SUNRabs(SUN_RCONST(81.0) * COS(SUN_RCONST(3.0) * t_test) - - NV_Ith_S(d4ytest, 1)); + NV_Ith_S(d4yerr, 0) = + SUNRabs(SUN_RCONST(16.0) * SUNRsin(SUN_RCONST(2.0) * t_test) - + NV_Ith_S(d4ytest, 0)); + NV_Ith_S(d4yerr, 1) = + SUNRabs(SUN_RCONST(81.0) * SUNRcos(SUN_RCONST(3.0) * t_test) - + NV_Ith_S(d4ytest, 1)); /* d5y */ - NV_Ith_S(d5yerr, - 0) = SUNRabs(SUN_RCONST(32.0) * COS(SUN_RCONST(2.0) * t_test) - - NV_Ith_S(d5ytest, 0)); + NV_Ith_S(d5yerr, 0) = + SUNRabs(SUN_RCONST(32.0) * SUNRcos(SUN_RCONST(2.0) * t_test) - + NV_Ith_S(d5ytest, 0)); NV_Ith_S(d5yerr, 1) = - SUNRabs(-SUN_RCONST(243.0) * SIN(SUN_RCONST(3.0) * t_test) - + SUNRabs(-SUN_RCONST(243.0) * SUNRsin(SUN_RCONST(3.0) * t_test) - NV_Ith_S(d5ytest, 1)); /* compute error norms (2-norm per test, max-norm over interval) */ - yerrs[ih] = SUNMAX(yerrs[ih], SQRT(N_VDotProd(yerr, yerr))); - dyerrs[ih] = SUNMAX(dyerrs[ih], SQRT(N_VDotProd(dyerr, dyerr))); - d2yerrs[ih] = SUNMAX(d2yerrs[ih], SQRT(N_VDotProd(d2yerr, d2yerr))); - d3yerrs[ih] = SUNMAX(d3yerrs[ih], SQRT(N_VDotProd(d3yerr, d3yerr))); - d4yerrs[ih] = SUNMAX(d4yerrs[ih], SQRT(N_VDotProd(d4yerr, d4yerr))); - d5yerrs[ih] = SUNMAX(d5yerrs[ih], SQRT(N_VDotProd(d5yerr, d5yerr))); + yerrs[ih] = SUNMAX(yerrs[ih], SUNRsqrt(N_VDotProd(yerr, yerr))); + dyerrs[ih] = SUNMAX(dyerrs[ih], SUNRsqrt(N_VDotProd(dyerr, dyerr))); + d2yerrs[ih] = SUNMAX(d2yerrs[ih], SUNRsqrt(N_VDotProd(d2yerr, d2yerr))); + d3yerrs[ih] = SUNMAX(d3yerrs[ih], SUNRsqrt(N_VDotProd(d3yerr, d3yerr))); + d4yerrs[ih] = SUNMAX(d4yerrs[ih], SUNRsqrt(N_VDotProd(d4yerr, d4yerr))); + d5yerrs[ih] = SUNMAX(d5yerrs[ih], SUNRsqrt(N_VDotProd(d5yerr, d5yerr))); } /* end itest loop */ @@ -333,17 +331,17 @@ int main(int argc, char* argv[]) printf(" " "-------------------------------------------------------------------" "-----------\n"); - printf(" h yerr dyerr d2yerr d3yerr d4yerr " + printf(" h yerr dyerr d2yerr d3yerr d4yerr " "d5yerr\n"); printf(" " "-------------------------------------------------------------------" "-----------\n"); for (ih = 0; ih < NHVALS; ih++) { - printf(" %.1e %.2e %.2e %.2e %.2e %.2e %.2e\n", - (double)hvals[ih], (double)yerrs[ih], (double)dyerrs[ih], - (double)d2yerrs[ih], (double)d3yerrs[ih], (double)d4yerrs[ih], - (double)d5yerrs[ih]); + printf(" %.1" ESYM " %.2" ESYM " %.2" ESYM " %.2" ESYM + " %.2" ESYM " %.2" ESYM " %.2" ESYM "\n", + hvals[ih], yerrs[ih], dyerrs[ih], d2yerrs[ih], d3yerrs[ih], + d4yerrs[ih], d5yerrs[ih]); } printf(" " "-------------------------------------------------------------------" @@ -352,68 +350,68 @@ int main(int argc, char* argv[]) printf(" Estimated y convergence factors:\n "); for (ih = 1; ih < NHVALS; ih++) { - printf(" %.3f", - log(yerrs[ih] / yerrs[ih - 1]) / log(hvals[ih] / hvals[ih - 1])); + printf(" %.3" FSYM, SUNRlog(yerrs[ih] / yerrs[ih - 1]) / + SUNRlog(hvals[ih] / hvals[ih - 1])); } - yrate[ideg] = log(yerrs[NHVALS - 1] / yerrs[0]) / - log(hvals[NHVALS - 1] / hvals[0]); + yrate[ideg] = SUNRlog(yerrs[NHVALS - 1] / yerrs[0]) / + SUNRlog(hvals[NHVALS - 1] / hvals[0]); yferr[ideg] = yerrs[NHVALS - 1]; - printf(" (%.3f, %.0e)\n\n", (double)yrate[ideg], (double)yferr[ideg]); + printf(" (%.3" FSYM ", %.0" ESYM ")\n\n", yrate[ideg], yferr[ideg]); printf(" Estimated dy convergence factors:\n "); for (ih = 1; ih < NHVALS; ih++) { - printf(" %.3f", - log(dyerrs[ih] / dyerrs[ih - 1]) / log(hvals[ih] / hvals[ih - 1])); + printf(" %.3" FSYM, SUNRlog(dyerrs[ih] / dyerrs[ih - 1]) / + SUNRlog(hvals[ih] / hvals[ih - 1])); } - dyrate[ideg] = log(dyerrs[NHVALS - 1] / dyerrs[0]) / - log(hvals[NHVALS - 1] / hvals[0]); + dyrate[ideg] = SUNRlog(dyerrs[NHVALS - 1] / dyerrs[0]) / + SUNRlog(hvals[NHVALS - 1] / hvals[0]); dyferr[ideg] = dyerrs[NHVALS - 1]; - printf(" (%.3f, %.0e)\n\n", (double)dyrate[ideg], (double)dyferr[ideg]); + printf(" (%.3" FSYM ", %.0" ESYM ")\n\n", dyrate[ideg], dyferr[ideg]); printf(" Estimated d2y convergence factors:\n "); for (ih = 1; ih < NHVALS; ih++) { - printf(" %.3f", log(d2yerrs[ih] / d2yerrs[ih - 1]) / - log(hvals[ih] / hvals[ih - 1])); + printf(" %.3" ESYM, SUNRlog(d2yerrs[ih] / d2yerrs[ih - 1]) / + SUNRlog(hvals[ih] / hvals[ih - 1])); } - d2yrate[ideg] = log(d2yerrs[NHVALS - 1] / d2yerrs[0]) / - log(hvals[NHVALS - 1] / hvals[0]); + d2yrate[ideg] = SUNRlog(d2yerrs[NHVALS - 1] / d2yerrs[0]) / + SUNRlog(hvals[NHVALS - 1] / hvals[0]); d2yferr[ideg] = d2yerrs[NHVALS - 1]; - printf(" (%.3f, %.0e)\n\n", (double)d2yrate[ideg], (double)d2yferr[ideg]); + printf(" (%.3" FSYM ", %.0" ESYM ")\n\n", d2yrate[ideg], d2yferr[ideg]); printf(" Estimated d3y convergence factors:\n "); for (ih = 1; ih < NHVALS; ih++) { - printf(" %.3f", log(d3yerrs[ih] / d3yerrs[ih - 1]) / - log(hvals[ih] / hvals[ih - 1])); + printf(" %.3" FSYM, SUNRlog(d3yerrs[ih] / d3yerrs[ih - 1]) / + SUNRlog(hvals[ih] / hvals[ih - 1])); } - d3yrate[ideg] = log(d3yerrs[NHVALS - 1] / d3yerrs[0]) / - log(hvals[NHVALS - 1] / hvals[0]); + d3yrate[ideg] = SUNRlog(d3yerrs[NHVALS - 1] / d3yerrs[0]) / + SUNRlog(hvals[NHVALS - 1] / hvals[0]); d3yferr[ideg] = d3yerrs[NHVALS - 1]; - printf(" (%.3f, %.0e)\n\n", (double)d3yrate[ideg], (double)d3yferr[ideg]); + printf(" (%.3" FSYM ", %.0" ESYM ")\n\n", d3yrate[ideg], d3yferr[ideg]); printf(" Estimated d4y convergence factors:\n "); for (ih = 1; ih < NHVALS; ih++) { - printf(" %.3f", log(d4yerrs[ih] / d4yerrs[ih - 1]) / - log(hvals[ih] / hvals[ih - 1])); + printf(" %.3" FSYM, SUNRlog(d4yerrs[ih] / d4yerrs[ih - 1]) / + SUNRlog(hvals[ih] / hvals[ih - 1])); } - d4yrate[ideg] = log(d4yerrs[NHVALS - 1] / d4yerrs[0]) / - log(hvals[NHVALS - 1] / hvals[0]); + d4yrate[ideg] = SUNRlog(d4yerrs[NHVALS - 1] / d4yerrs[0]) / + SUNRlog(hvals[NHVALS - 1] / hvals[0]); d4yferr[ideg] = d4yerrs[NHVALS - 1]; - printf(" (%.3f, %.0e)\n\n", (double)d4yrate[ideg], (double)d4yferr[ideg]); + printf(" (%.3" FSYM ", %.0" ESYM ")\n\n", d4yrate[ideg], d4yferr[ideg]); printf(" Estimated d5y convergence factors:\n "); for (ih = 1; ih < NHVALS; ih++) { - printf(" %.3f", log(d5yerrs[ih] / d5yerrs[ih - 1]) / - log(hvals[ih] / hvals[ih - 1])); + printf(" %.3" FSYM, SUNRlog(d5yerrs[ih] / d5yerrs[ih - 1]) / + SUNRlog(hvals[ih] / hvals[ih - 1])); } - d5yrate[ideg] = log(d5yerrs[NHVALS - 1] / d5yerrs[0]) / - log(hvals[NHVALS - 1] / hvals[0]); + d5yrate[ideg] = SUNRlog(d5yerrs[NHVALS - 1] / d5yerrs[0]) / + SUNRlog(hvals[NHVALS - 1] / hvals[0]); d5yferr[ideg] = d5yerrs[NHVALS - 1]; - printf(" (%.3f, %.0e)\n\n", (double)d5yrate[ideg], (double)d5yferr[ideg]); + printf(" (%.3" FSYM ", %.0" ESYM ")\n\n", d5yrate[ideg], d5yferr[ideg]); } /* end ideg loop */ @@ -505,26 +503,28 @@ int main(int argc, char* argv[]) /* set error values */ /* y */ NV_Ith_S(yerr, 0) = - SUNRabs(SIN(SUN_RCONST(2.0) * t_test) - NV_Ith_S(ytest, 0)); + SUNRabs(SUNRsin(SUN_RCONST(2.0) * t_test) - NV_Ith_S(ytest, 0)); NV_Ith_S(yerr, 1) = - SUNRabs(COS(SUN_RCONST(3.0) * t_test) - NV_Ith_S(ytest, 1)); + SUNRabs(SUNRcos(SUN_RCONST(3.0) * t_test) - NV_Ith_S(ytest, 1)); /* dy */ - NV_Ith_S(dyerr, 0) = SUNRabs( - SUN_RCONST(2.0) * COS(SUN_RCONST(2.0) * t_test) - NV_Ith_S(dytest, 0)); - NV_Ith_S(dyerr, 1) = SUNRabs( - -SUN_RCONST(3.0) * SIN(SUN_RCONST(3.0) * t_test) - NV_Ith_S(dytest, 1)); + NV_Ith_S(dyerr, 0) = + SUNRabs(SUN_RCONST(2.0) * SUNRcos(SUN_RCONST(2.0) * t_test) - + NV_Ith_S(dytest, 0)); + NV_Ith_S(dyerr, 1) = + SUNRabs(-SUN_RCONST(3.0) * SUNRsin(SUN_RCONST(3.0) * t_test) - + NV_Ith_S(dytest, 1)); /* d2y */ - NV_Ith_S(d2yerr, - 0) = SUNRabs(-SUN_RCONST(4.0) * SIN(SUN_RCONST(2.0) * t_test) - - NV_Ith_S(d2ytest, 0)); - NV_Ith_S(d2yerr, - 1) = SUNRabs(-SUN_RCONST(9.0) * COS(SUN_RCONST(3.0) * t_test) - - NV_Ith_S(d2ytest, 1)); + NV_Ith_S(d2yerr, 0) = + SUNRabs(-SUN_RCONST(4.0) * SUNRsin(SUN_RCONST(2.0) * t_test) - + NV_Ith_S(d2ytest, 0)); + NV_Ith_S(d2yerr, 1) = + SUNRabs(-SUN_RCONST(9.0) * SUNRcos(SUN_RCONST(3.0) * t_test) - + NV_Ith_S(d2ytest, 1)); /* compute error norms (2-norm per test, max-norm over interval) */ - yerrs[ih] = SUNMAX(yerrs[ih], SQRT(N_VDotProd(yerr, yerr))); - dyerrs[ih] = SUNMAX(dyerrs[ih], SQRT(N_VDotProd(dyerr, dyerr))); - d2yerrs[ih] = SUNMAX(d2yerrs[ih], SQRT(N_VDotProd(d2yerr, d2yerr))); + yerrs[ih] = SUNMAX(yerrs[ih], SUNRsqrt(N_VDotProd(yerr, yerr))); + dyerrs[ih] = SUNMAX(dyerrs[ih], SUNRsqrt(N_VDotProd(dyerr, dyerr))); + d2yerrs[ih] = SUNMAX(d2yerrs[ih], SUNRsqrt(N_VDotProd(d2yerr, d2yerr))); } /* end itest loop */ @@ -542,43 +542,43 @@ int main(int argc, char* argv[]) printf(" ------------------------------------------\n"); for (ih = 0; ih < NHVALS; ih++) { - printf(" %.1e %.2e %.2e %.2e\n", (double)hvals[ih], - (double)yerrs[ih], (double)dyerrs[ih], (double)d2yerrs[ih]); + printf(" %.1" ESYM " %.2" ESYM " %.2" ESYM " %.2" ESYM "\n", + hvals[ih], yerrs[ih], dyerrs[ih], d2yerrs[ih]); } printf(" ------------------------------------------\n"); printf(" Estimated y convergence factors:\n "); for (ih = 1; ih < NHVALS; ih++) { - printf(" %.3f", - log(yerrs[ih] / yerrs[ih - 1]) / log(hvals[ih] / hvals[ih - 1])); + printf(" %.3" FSYM, SUNRlog(yerrs[ih] / yerrs[ih - 1]) / + SUNRlog(hvals[ih] / hvals[ih - 1])); } - yrate2[ideg] = log(yerrs[NHVALS - 1] / yerrs[0]) / - log(hvals[NHVALS - 1] / hvals[0]); + yrate2[ideg] = SUNRlog(yerrs[NHVALS - 1] / yerrs[0]) / + SUNRlog(hvals[NHVALS - 1] / hvals[0]); yferr2[ideg] = yerrs[NHVALS - 1]; - printf(" (%.3f, %.0e)\n\n", (double)yrate2[ideg], (double)yferr2[ideg]); + printf(" (%.3" FSYM ", %.0" ESYM ")\n\n", yrate2[ideg], yferr2[ideg]); printf(" Estimated dy convergence factors:\n "); for (ih = 1; ih < NHVALS; ih++) { - printf(" %.3f", - log(dyerrs[ih] / dyerrs[ih - 1]) / log(hvals[ih] / hvals[ih - 1])); + printf(" %.3" FSYM, SUNRlog(dyerrs[ih] / dyerrs[ih - 1]) / + SUNRlog(hvals[ih] / hvals[ih - 1])); } - dyrate2[ideg] = log(dyerrs[NHVALS - 1] / dyerrs[0]) / - log(hvals[NHVALS - 1] / hvals[0]); + dyrate2[ideg] = SUNRlog(dyerrs[NHVALS - 1] / dyerrs[0]) / + SUNRlog(hvals[NHVALS - 1] / hvals[0]); dyferr2[ideg] = dyerrs[NHVALS - 1]; - printf(" (%.3f, %.0e)\n\n", (double)dyrate2[ideg], (double)dyferr2[ideg]); + printf(" (%.3" FSYM ", %.0" ESYM ")\n\n", dyrate2[ideg], dyferr2[ideg]); printf(" Estimated d2y convergence factors:\n "); for (ih = 1; ih < NHVALS; ih++) { - printf(" %.3f", log(d2yerrs[ih] / d2yerrs[ih - 1]) / - log(hvals[ih] / hvals[ih - 1])); + printf(" %.3" FSYM, SUNRlog(d2yerrs[ih] / d2yerrs[ih - 1]) / + SUNRlog(hvals[ih] / hvals[ih - 1])); } - d2yrate2[ideg] = log(d2yerrs[NHVALS - 1] / d2yerrs[0]) / - log(hvals[NHVALS - 1] / hvals[0]); + d2yrate2[ideg] = SUNRlog(d2yerrs[NHVALS - 1] / d2yerrs[0]) / + SUNRlog(hvals[NHVALS - 1] / hvals[0]); d2yferr2[ideg] = d2yerrs[NHVALS - 1]; - printf(" (%.3f, %.0e)\n\n", (double)d2yrate2[ideg], (double)d2yferr2[ideg]); + printf(" (%.3" FSYM ", %.0" ESYM ")\n\n", d2yrate2[ideg], d2yferr2[ideg]); } /* end ideg loop */ @@ -596,12 +596,12 @@ int main(int argc, char* argv[]) "------------------------\n"); for (ideg = 0; ideg <= ARK_INTERP_MAX_DEGREE; ideg++) { - printf(" %1d | %.1f (%.0e) %.1f (%.0e) %.1f (%.0e) %.1f " - "(%.0e) %.1f (%.0e) %.1f (%.0e)\n", - ideg, (double)yrate[ideg], (double)yferr[ideg], (double)dyrate[ideg], - (double)dyferr[ideg], (double)d2yrate[ideg], (double)d2yferr[ideg], - (double)d3yrate[ideg], (double)d3yferr[ideg], (double)d4yrate[ideg], - (double)d4yferr[ideg], (double)d5yrate[ideg], (double)d5yferr[ideg]); + printf(" %1d | %.1" FSYM " (%.0" ESYM ") %.1" FSYM " (%.0" ESYM + ") %.1" FSYM " (%.0" ESYM ") %.1" FSYM "(%.0" ESYM ") %.1" FSYM + " (%.0" ESYM ") %.1" FSYM " (%.0" ESYM ")\n", + ideg, yrate[ideg], yferr[ideg], dyrate[ideg], dyferr[ideg], + d2yrate[ideg], d2yferr[ideg], d3yrate[ideg], d3yferr[ideg], + d4yrate[ideg], d4yferr[ideg], d5yrate[ideg], d5yferr[ideg]); } printf(" " "---------------------------------------------------------------------" @@ -613,9 +613,10 @@ int main(int argc, char* argv[]) printf(" ---------------------------------------------------\n"); for (ideg = 0; ideg <= ARK_INTERP_MAX_DEGREE; ideg++) { - printf(" %1d | %.1f (%.0e) %.1f (%.0e) %.1f (%.0e)\n", ideg, - (double)yrate2[ideg], (double)yferr2[ideg], (double)dyrate2[ideg], - (double)dyferr2[ideg], (double)d2yrate2[ideg], (double)d2yferr2[ideg]); + printf(" %1d | %.1" FSYM " (%.0" ESYM ") %.1" FSYM " (%.0" ESYM + ") %.1" FSYM " (%.0" ESYM ")\n", + ideg, yrate2[ideg], yferr2[ideg], dyrate2[ideg], dyferr2[ideg], + d2yrate2[ideg], d2yferr2[ideg]); } printf(" ---------------------------------------------------\n"); @@ -652,12 +653,13 @@ int main(int argc, char* argv[]) static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { sunrealtype* lambda = (sunrealtype*)user_data; - NV_Ith_S(ydot, 0) = (*lambda) * (NV_Ith_S(y, 0) - SIN(SUN_RCONST(2.0) * t)) + - NV_Ith_S(y, 1) - COS(SUN_RCONST(3.0) * t) + - SUN_RCONST(2.0) * COS(SUN_RCONST(2.0) * t); + NV_Ith_S(ydot, 0) = (*lambda) * (NV_Ith_S(y, 0) - SUNRsin(SUN_RCONST(2.0) * t)) + + NV_Ith_S(y, 1) - SUNRcos(SUN_RCONST(3.0) * t) + + SUN_RCONST(2.0) * SUNRcos(SUN_RCONST(2.0) * t); NV_Ith_S(ydot, 1) = NV_Ith_S(y, 0) - NV_Ith_S(y, 1) - - SIN(SUN_RCONST(2.0) * t) + COS(SUN_RCONST(3.0) * t) - - SUN_RCONST(3.0) * SIN(SUN_RCONST(3.0) * t); + SUNRsin(SUN_RCONST(2.0) * t) + + SUNRcos(SUN_RCONST(3.0) * t) - + SUN_RCONST(3.0) * SUNRsin(SUN_RCONST(3.0) * t); return 0; /* Return with success */ } diff --git a/test/unit_tests/arkode/C_serial/ark_test_reset.c b/test/unit_tests/arkode/C_serial/ark_test_reset.c index cad72a64d7..1515ead91f 100644 --- a/test/unit_tests/arkode/C_serial/ark_test_reset.c +++ b/test/unit_tests/arkode/C_serial/ark_test_reset.c @@ -45,7 +45,9 @@ #include #include -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #else #define GSYM "g" diff --git a/test/unit_tests/arkode/C_serial/ark_test_tstop.c b/test/unit_tests/arkode/C_serial/ark_test_tstop.c index 46e96c26ea..2a6d2f4ae2 100644 --- a/test/unit_tests/arkode/C_serial/ark_test_tstop.c +++ b/test/unit_tests/arkode/C_serial/ark_test_tstop.c @@ -27,7 +27,9 @@ #include "sunlinsol/sunlinsol_dense.h" #include "sunmatrix/sunmatrix_dense.h" -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #else #define GSYM "g" diff --git a/test/unit_tests/constraints/test_constraints_arkode.cpp b/test/unit_tests/constraints/test_constraints_arkode.cpp index 6d871e6b43..4aae478538 100644 --- a/test/unit_tests/constraints/test_constraints_arkode.cpp +++ b/test/unit_tests/constraints/test_constraints_arkode.cpp @@ -28,7 +28,7 @@ #include "sundials/sundials_math.h" #include "sundials/sundials_matrix.h" #include "sundials/sundials_nvector.h" -#include "sundials/sundials_types.h" +#include "sundials/sundials_types.hpp" #include "sunlinsol/sunlinsol_dense.h" #include "sunmatrix/sunmatrix_dense.h" diff --git a/test/unit_tests/constraints/test_constraints_cvode.cpp b/test/unit_tests/constraints/test_constraints_cvode.cpp index b494b42e08..c1fabad043 100644 --- a/test/unit_tests/constraints/test_constraints_cvode.cpp +++ b/test/unit_tests/constraints/test_constraints_cvode.cpp @@ -27,7 +27,7 @@ #include "sundials/sundials_math.h" #include "sundials/sundials_matrix.h" #include "sundials/sundials_nvector.h" -#include "sundials/sundials_types.h" +#include "sundials/sundials_types.hpp" #include "sunlinsol/sunlinsol_dense.h" #include "sunmatrix/sunmatrix_dense.h" diff --git a/test/unit_tests/constraints/test_constraints_cvodes.cpp b/test/unit_tests/constraints/test_constraints_cvodes.cpp index d25367fd90..3fd76952a1 100644 --- a/test/unit_tests/constraints/test_constraints_cvodes.cpp +++ b/test/unit_tests/constraints/test_constraints_cvodes.cpp @@ -27,7 +27,7 @@ #include "sundials/sundials_math.h" #include "sundials/sundials_matrix.h" #include "sundials/sundials_nvector.h" -#include "sundials/sundials_types.h" +#include "sundials/sundials_types.hpp" #include "sunlinsol/sunlinsol_dense.h" #include "sunmatrix/sunmatrix_dense.h" diff --git a/test/unit_tests/constraints/test_constraints_ida.cpp b/test/unit_tests/constraints/test_constraints_ida.cpp index 65b59dfd4c..6ca71736e4 100644 --- a/test/unit_tests/constraints/test_constraints_ida.cpp +++ b/test/unit_tests/constraints/test_constraints_ida.cpp @@ -27,7 +27,6 @@ #include "sundials/sundials_math.h" #include "sundials/sundials_matrix.h" #include "sundials/sundials_nvector.h" -#include "sundials/sundials_types.h" #include "sunlinsol/sunlinsol_dense.h" #include "sunmatrix/sunmatrix_dense.h" diff --git a/test/unit_tests/constraints/test_constraints_idas.cpp b/test/unit_tests/constraints/test_constraints_idas.cpp index fa5d0745cd..0957c7abe4 100644 --- a/test/unit_tests/constraints/test_constraints_idas.cpp +++ b/test/unit_tests/constraints/test_constraints_idas.cpp @@ -27,7 +27,6 @@ #include "sundials/sundials_math.h" #include "sundials/sundials_matrix.h" #include "sundials/sundials_nvector.h" -#include "sundials/sundials_types.h" #include "sunlinsol/sunlinsol_dense.h" #include "sunmatrix/sunmatrix_dense.h" diff --git a/test/unit_tests/cvode/CXX_serial/cv_test_getjac.cpp b/test/unit_tests/cvode/CXX_serial/cv_test_getjac.cpp index d0968ee604..9544fb38e9 100644 --- a/test/unit_tests/cvode/CXX_serial/cv_test_getjac.cpp +++ b/test/unit_tests/cvode/CXX_serial/cv_test_getjac.cpp @@ -61,24 +61,24 @@ // ----------------------------------------------------------------------------- // Compute r(t) -static sunrealtype r(sunrealtype t) { return HALF * cos(t); } +static sunrealtype r(sunrealtype t) { return HALF * SUNRcos(t); } // Compute the derivative of r(t) -static sunrealtype rdot(sunrealtype t) { return -HALF * sin(t); } +static sunrealtype rdot(sunrealtype t) { return -HALF * SUNRsin(t); } // Compute s(t) -static sunrealtype s(sunrealtype t) { return cos(TWENTY * t); } +static sunrealtype s(sunrealtype t) { return SUNRcos(TWENTY * t); } // Compute the derivative of s(t) -static sunrealtype sdot(sunrealtype t) { return -TWENTY * sin(TWENTY * t); } +static sunrealtype sdot(sunrealtype t) { return -TWENTY * SUNRsin(TWENTY * t); } // Compute the true solution static int ytrue(sunrealtype t, N_Vector y) { sunrealtype* ydata = N_VGetArrayPointer(y); - ydata[0] = sqrt(ONE + r(t)); - ydata[1] = sqrt(TWO + s(t)); + ydata[0] = SUNRsqrt(ONE + r(t)); + ydata[1] = SUNRsqrt(TWO + s(t)); return 0; } @@ -175,7 +175,7 @@ int main(int argc, char* argv[]) sundials::Context sunctx; // Comparison tolerance - sunrealtype tol = 100 * std::sqrt(SUN_UNIT_ROUNDOFF); + sunrealtype tol = 100 * SUNRsqrt(SUN_UNIT_ROUNDOFF); if (argc > 1) { #if defined(SUNDIALS_SINGLE_PRECISION) @@ -184,6 +184,8 @@ int main(int argc, char* argv[]) tol = std::stod(argv[1]); #elif defined(SUNDIALS_EXTENDED_PRECISION) tol = std::stold(argv[1]); +#elif defined(SUNDIALS_FLOAT128_PRECISION) + tol = strtoflt128(argv[1], NULL); #else #error "SUNDIALS precision macro not defined" #endif @@ -202,6 +204,8 @@ int main(int argc, char* argv[]) const sunrealtype rtol = SUN_RCONST(1.0e-6); #elif defined(SUNDIALS_EXTENDED_PRECISION) const sunrealtype rtol = SUN_RCONST(1.0e-9); +#elif defined(SUNDIALS_FLOAT128_PRECISION) + const sunrealtype rtol = SUN_RCONST(1.0e-9); #else #error "SUNDIALS precision macro not defined" #endif @@ -278,7 +282,11 @@ int main(int argc, char* argv[]) // Output Jacobian data std::cout << std::scientific; - std::cout << std::setprecision(std::numeric_limits::digits10); +#if defined(SUNDIALS_FLOAT128_PRECISION) + std::cout << std::setprecision(SUN_DIGITS10 / 2); +#else + std::cout << std::setprecision(SUN_DIGITS10); +#endif std::cout << "Jac nst = " << nst_Jdq << std::endl; std::cout << "Jac t = " << t_Jdq << std::endl; std::cout << std::endl; @@ -296,9 +304,9 @@ int main(int argc, char* argv[]) std::cout << std::setw(8) << std::right << i << std::setw(25) << std::right << Jdq_data[i] << std::setw(25) << std::right << Jtrue_data[i] << std::setw(25) << std::right - << std::abs(Jdq_data[i] - Jtrue_data[i]) << std::setw(25) + << SUNRabs(Jdq_data[i] - Jtrue_data[i]) << std::setw(25) << std::right - << std::abs(Jdq_data[i] - Jtrue_data[i]) / Jtrue_data[i] + << SUNRabs(Jdq_data[i] - Jtrue_data[i]) / Jtrue_data[i] << std::endl; result += SUNRCompareTol(Jdq_data[i], Jtrue_data[i], tol); } diff --git a/test/unit_tests/cvode/CXX_serial/cv_test_kpr.cpp b/test/unit_tests/cvode/CXX_serial/cv_test_kpr.cpp index 652989cde1..3a6e0edffe 100644 --- a/test/unit_tests/cvode/CXX_serial/cv_test_kpr.cpp +++ b/test/unit_tests/cvode/CXX_serial/cv_test_kpr.cpp @@ -125,7 +125,7 @@ int main(int argc, char* argv[]) // Output initial contion cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << " t "; cout << " u "; cout << " v "; diff --git a/test/unit_tests/cvode/CXX_serial/cv_test_kpr.hpp b/test/unit_tests/cvode/CXX_serial/cv_test_kpr.hpp index 2505f08a70..28890d47c6 100644 --- a/test/unit_tests/cvode/CXX_serial/cv_test_kpr.hpp +++ b/test/unit_tests/cvode/CXX_serial/cv_test_kpr.hpp @@ -107,22 +107,22 @@ int J(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, // ----------------------------------------------------------------------------- // Compute r(t) -static sunrealtype r(sunrealtype t) { return HALF * cos(t); } +static sunrealtype r(sunrealtype t) { return HALF * SUNRcos(t); } // Compute the derivative of r(t) -static sunrealtype rdot(sunrealtype t) { return -HALF * sin(t); } +static sunrealtype rdot(sunrealtype t) { return -HALF * SUNRsin(t); } // Compute s(t) -static sunrealtype s(sunrealtype t) { return cos(TWENTY * t); } +static sunrealtype s(sunrealtype t) { return SUNRcos(TWENTY * t); } // Compute the derivative of s(t) -static sunrealtype sdot(sunrealtype t) { return -TWENTY * sin(TWENTY * t); } +static sunrealtype sdot(sunrealtype t) { return -TWENTY * SUNRsin(TWENTY * t); } // Compute the true solution static int true_sol(sunrealtype t, sunrealtype* u, sunrealtype* v) { - *u = sqrt(ONE + r(t)); - *v = sqrt(TWO + s(t)); + *u = SUNRsqrt(ONE + r(t)); + *v = SUNRsqrt(TWO + s(t)); return 0; } diff --git a/test/unit_tests/cvode/CXX_serial/cv_test_resize_history.cpp b/test/unit_tests/cvode/CXX_serial/cv_test_resize_history.cpp index 03e21f799b..003c43900d 100644 --- a/test/unit_tests/cvode/CXX_serial/cv_test_resize_history.cpp +++ b/test/unit_tests/cvode/CXX_serial/cv_test_resize_history.cpp @@ -269,8 +269,7 @@ int main(int argc, char* argv[]) // Set output formatting cout << scientific; - cout << setprecision(16); - // cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << endl; // Output initial data diff --git a/test/unit_tests/cvodes/CXX_serial/cvs_test_getjac.cpp b/test/unit_tests/cvodes/CXX_serial/cvs_test_getjac.cpp index 5e03e796e7..115297a446 100644 --- a/test/unit_tests/cvodes/CXX_serial/cvs_test_getjac.cpp +++ b/test/unit_tests/cvodes/CXX_serial/cvs_test_getjac.cpp @@ -60,24 +60,24 @@ // ----------------------------------------------------------------------------- // Compute r(t) -static sunrealtype r(sunrealtype t) { return HALF * cos(t); } +static sunrealtype r(sunrealtype t) { return HALF * SUNRcos(t); } // Compute the derivative of r(t) -static sunrealtype rdot(sunrealtype t) { return -HALF * sin(t); } +static sunrealtype rdot(sunrealtype t) { return -HALF * SUNRsin(t); } // Compute s(t) -static sunrealtype s(sunrealtype t) { return cos(TWENTY * t); } +static sunrealtype s(sunrealtype t) { return SUNRcos(TWENTY * t); } // Compute the derivative of s(t) -static sunrealtype sdot(sunrealtype t) { return -TWENTY * sin(TWENTY * t); } +static sunrealtype sdot(sunrealtype t) { return -TWENTY * SUNRsin(TWENTY * t); } // Compute the true solution static int ytrue(sunrealtype t, N_Vector y) { sunrealtype* ydata = N_VGetArrayPointer(y); - ydata[0] = sqrt(ONE + r(t)); - ydata[1] = sqrt(TWO + s(t)); + ydata[0] = SUNRsqrt(ONE + r(t)); + ydata[1] = SUNRsqrt(TWO + s(t)); return 0; } @@ -174,7 +174,7 @@ int main(int argc, char* argv[]) sundials::Context sunctx; // Comparison tolerance - sunrealtype tol = 100 * std::sqrt(SUN_UNIT_ROUNDOFF); + sunrealtype tol = 100 * SUNRsqrt(SUN_UNIT_ROUNDOFF); if (argc > 1) { #if defined(SUNDIALS_SINGLE_PRECISION) @@ -183,6 +183,8 @@ int main(int argc, char* argv[]) tol = std::stod(argv[1]); #elif defined(SUNDIALS_EXTENDED_PRECISION) tol = std::stold(argv[1]); +#elif defined(SUNDIALS_FLOAT128_PRECISION) + tol = strtoflt128(argv[1], NULL); #else #error "SUNDIALS precision macro not defined" #endif @@ -201,6 +203,8 @@ int main(int argc, char* argv[]) const sunrealtype rtol = SUN_RCONST(1.0e-6); #elif defined(SUNDIALS_EXTENDED_PRECISION) const sunrealtype rtol = SUN_RCONST(1.0e-9); +#elif defined(SUNDIALS_FLOAT128_PRECISION) + const sunrealtype rtol = SUN_RCONST(1.0e-9); #else #error "SUNDIALS precision macro not defined" #endif @@ -277,7 +281,11 @@ int main(int argc, char* argv[]) // Output Jacobian data std::cout << std::scientific; - std::cout << std::setprecision(std::numeric_limits::digits10); +#if defined(SUNDIALS_FLOAT128_PRECISION) + std::cout << std::setprecision(SUN_DIGITS10 / 2); +#else + std::cout << std::setprecision(SUN_DIGITS10); +#endif std::cout << "Jac nst = " << nst_Jdq << std::endl; std::cout << "Jac t = " << t_Jdq << std::endl; std::cout << std::endl; @@ -295,9 +303,9 @@ int main(int argc, char* argv[]) std::cout << std::setw(8) << std::right << i << std::setw(25) << std::right << Jdq_data[i] << std::setw(25) << std::right << Jtrue_data[i] << std::setw(25) << std::right - << std::abs(Jdq_data[i] - Jtrue_data[i]) << std::setw(25) + << SUNRabs(Jdq_data[i] - Jtrue_data[i]) << std::setw(25) << std::right - << std::abs(Jdq_data[i] - Jtrue_data[i]) / Jtrue_data[i] + << SUNRabs(Jdq_data[i] - Jtrue_data[i]) / Jtrue_data[i] << std::endl; result += SUNRCompareTol(Jdq_data[i], Jtrue_data[i], tol); } diff --git a/test/unit_tests/cvodes/CXX_serial/cvs_test_kpr.cpp b/test/unit_tests/cvodes/CXX_serial/cvs_test_kpr.cpp index 47f569d488..c321a8d322 100644 --- a/test/unit_tests/cvodes/CXX_serial/cvs_test_kpr.cpp +++ b/test/unit_tests/cvodes/CXX_serial/cvs_test_kpr.cpp @@ -125,7 +125,7 @@ int main(int argc, char* argv[]) // Output initial contion cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << " t "; cout << " u "; cout << " v "; diff --git a/test/unit_tests/cvodes/CXX_serial/cvs_test_kpr.hpp b/test/unit_tests/cvodes/CXX_serial/cvs_test_kpr.hpp index 9c54ccd1ad..99b36a3bdc 100644 --- a/test/unit_tests/cvodes/CXX_serial/cvs_test_kpr.hpp +++ b/test/unit_tests/cvodes/CXX_serial/cvs_test_kpr.hpp @@ -107,22 +107,22 @@ int J(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, // ----------------------------------------------------------------------------- // Compute r(t) -static sunrealtype r(sunrealtype t) { return HALF * cos(t); } +static sunrealtype r(sunrealtype t) { return HALF * SUNRcos(t); } // Compute the derivative of r(t) -static sunrealtype rdot(sunrealtype t) { return -HALF * sin(t); } +static sunrealtype rdot(sunrealtype t) { return -HALF * SUNRsin(t); } // Compute s(t) -static sunrealtype s(sunrealtype t) { return cos(TWENTY * t); } +static sunrealtype s(sunrealtype t) { return SUNRcos(TWENTY * t); } // Compute the derivative of s(t) -static sunrealtype sdot(sunrealtype t) { return -TWENTY * sin(TWENTY * t); } +static sunrealtype sdot(sunrealtype t) { return -TWENTY * SUNRsin(TWENTY * t); } // Compute the true solution static int true_sol(sunrealtype t, sunrealtype* u, sunrealtype* v) { - *u = sqrt(ONE + r(t)); - *v = sqrt(TWO + s(t)); + *u = SUNRsqrt(ONE + r(t)); + *v = SUNRsqrt(TWO + s(t)); return 0; } @@ -159,6 +159,8 @@ inline void find_arg(vector& args, const string key, sunrealtype& dest) dest = stod(*(it + 1)); #elif defined(SUNDIALS_EXTENDED_PRECISION) dest = stold(*(it + 1)); +#elif defined(SUNDIALS_FLOAT128_PRECISION) + dest = sunrealtype(stod(*(it + 1))); #endif args.erase(it, it + 2); } diff --git a/test/unit_tests/cvodes/CXX_serial/cvs_test_resize_history.cpp b/test/unit_tests/cvodes/CXX_serial/cvs_test_resize_history.cpp index a1d662e5ee..11616310ae 100644 --- a/test/unit_tests/cvodes/CXX_serial/cvs_test_resize_history.cpp +++ b/test/unit_tests/cvodes/CXX_serial/cvs_test_resize_history.cpp @@ -269,8 +269,7 @@ int main(int argc, char* argv[]) // Set output formatting cout << scientific; - cout << setprecision(16); - // cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << endl; // Output initial data diff --git a/test/unit_tests/ida/CXX_serial/ida_test_getjac.cpp b/test/unit_tests/ida/CXX_serial/ida_test_getjac.cpp index 7045cefac5..d28c28ebc8 100644 --- a/test/unit_tests/ida/CXX_serial/ida_test_getjac.cpp +++ b/test/unit_tests/ida/CXX_serial/ida_test_getjac.cpp @@ -66,24 +66,24 @@ // ----------------------------------------------------------------------------- // Compute r(t) -static sunrealtype r(sunrealtype t) { return HALF * cos(t); } +static sunrealtype r(sunrealtype t) { return HALF * SUNRcos(t); } // Compute the derivative of r(t) -static sunrealtype rdot(sunrealtype t) { return -HALF * sin(t); } +static sunrealtype rdot(sunrealtype t) { return -HALF * SUNRsin(t); } // Compute s(t) -static sunrealtype s(sunrealtype t) { return cos(TWENTY * t); } +static sunrealtype s(sunrealtype t) { return SUNRcos(TWENTY * t); } // Compute the derivative of s(t) -static sunrealtype sdot(sunrealtype t) { return -TWENTY * sin(TWENTY * t); } +static sunrealtype sdot(sunrealtype t) { return -TWENTY * SUNRsin(TWENTY * t); } // Compute the true solution static int ytrue(sunrealtype t, N_Vector y) { sunrealtype* ydata = N_VGetArrayPointer(y); - ydata[0] = sqrt(ONE + r(t)); - ydata[1] = sqrt(TWO + s(t)); + ydata[0] = SUNRsqrt(ONE + r(t)); + ydata[1] = SUNRsqrt(TWO + s(t)); return 0; } @@ -93,8 +93,8 @@ static int yptrue(sunrealtype t, N_Vector yp) { sunrealtype* ypdata = N_VGetArrayPointer(yp); - ypdata[0] = HALF * rdot(t) / sqrt(ONE + r(t)); - ypdata[1] = HALF * sdot(t) / sqrt(TWO + s(t)); + ypdata[0] = HALF * rdot(t) / SUNRsqrt(ONE + r(t)); + ypdata[1] = HALF * sdot(t) / SUNRsqrt(TWO + s(t)); return 0; } @@ -228,7 +228,7 @@ int main(int argc, char* argv[]) sundials::Context sunctx; // Comparison tolerance - sunrealtype tol = 100 * std::sqrt(SUN_UNIT_ROUNDOFF); + sunrealtype tol = 100 * SUNRsqrt(SUN_UNIT_ROUNDOFF); if (argc > 1) { #if defined(SUNDIALS_SINGLE_PRECISION) @@ -237,6 +237,8 @@ int main(int argc, char* argv[]) tol = std::stod(argv[1]); #elif defined(SUNDIALS_EXTENDED_PRECISION) tol = std::stold(argv[1]); +#elif defined(SUNDIALS_FLOAT128_PRECISION) + tol = strtoflt128(argv[1], NULL); #else #error "SUNDIALS precision macro not defined" #endif @@ -255,6 +257,8 @@ int main(int argc, char* argv[]) const sunrealtype rtol = SUN_RCONST(1.0e-6); #elif defined(SUNDIALS_EXTENDED_PRECISION) const sunrealtype rtol = SUN_RCONST(1.0e-9); +#elif defined(SUNDIALS_FLOAT128_PRECISION) + const sunrealtype rtol = SUN_RCONST(1.0e-9); #else #error "SUNDIALS precision macro not defined" #endif @@ -349,7 +353,11 @@ int main(int argc, char* argv[]) // Output Jacobian data std::cout << std::scientific; - std::cout << std::setprecision(std::numeric_limits::digits10); +#if defined(SUNDIALS_FLOAT128_PRECISION) + std::cout << std::setprecision(SUN_DIGITS10 / 2); +#else + std::cout << std::setprecision(SUN_DIGITS10); +#endif std::cout << "Jac nst = " << nst_Jdq << std::endl; std::cout << "Jac t = " << t_Jdq << std::endl; std::cout << "Jac cj = " << cj_Jdq << std::endl; @@ -368,9 +376,9 @@ int main(int argc, char* argv[]) std::cout << std::setw(8) << std::right << i << std::setw(25) << std::right << Jdq_data[i] << std::setw(25) << std::right << Jtrue_data[i] << std::setw(25) << std::right - << std::abs(Jdq_data[i] - Jtrue_data[i]) << std::setw(25) + << SUNRabs(Jdq_data[i] - Jtrue_data[i]) << std::setw(25) << std::right - << std::abs(Jdq_data[i] - Jtrue_data[i]) / Jtrue_data[i] + << SUNRabs(Jdq_data[i] - Jtrue_data[i]) / Jtrue_data[i] << std::endl; result += SUNRCompareTol(Jdq_data[i], Jtrue_data[i], tol); } diff --git a/test/unit_tests/ida/CXX_serial/ida_test_kpr.cpp b/test/unit_tests/ida/CXX_serial/ida_test_kpr.cpp index 2b9d674309..23ade9f735 100644 --- a/test/unit_tests/ida/CXX_serial/ida_test_kpr.cpp +++ b/test/unit_tests/ida/CXX_serial/ida_test_kpr.cpp @@ -118,7 +118,7 @@ int main(int argc, char* argv[]) // Output initial contion cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << " t "; cout << " u "; cout << " v "; diff --git a/test/unit_tests/ida/CXX_serial/ida_test_kpr.hpp b/test/unit_tests/ida/CXX_serial/ida_test_kpr.hpp index 9e33b088f9..5713dccf45 100644 --- a/test/unit_tests/ida/CXX_serial/ida_test_kpr.hpp +++ b/test/unit_tests/ida/CXX_serial/ida_test_kpr.hpp @@ -92,22 +92,22 @@ int J(sunrealtype t, sunrealtype cj, N_Vector y, N_Vector yp, N_Vector rr, // ----------------------------------------------------------------------------- // Compute r(t) -static sunrealtype r(sunrealtype t) { return HALF * cos(t); } +static sunrealtype r(sunrealtype t) { return HALF * SUNRcos(t); } // Compute the derivative of r(t) -static sunrealtype rdot(sunrealtype t) { return -HALF * sin(t); } +static sunrealtype rdot(sunrealtype t) { return -HALF * SUNRsin(t); } // Compute s(t) -static sunrealtype s(sunrealtype t) { return cos(TWENTY * t); } +static sunrealtype s(sunrealtype t) { return SUNRcos(TWENTY * t); } // Compute the derivative of s(t) -static sunrealtype sdot(sunrealtype t) { return -TWENTY * sin(TWENTY * t); } +static sunrealtype sdot(sunrealtype t) { return -TWENTY * SUNRsin(TWENTY * t); } // Compute the true solution static int true_sol(sunrealtype t, sunrealtype* u, sunrealtype* v) { - *u = sqrt(ONE + r(t)); - *v = sqrt(TWO + s(t)); + *u = SUNRsqrt(ONE + r(t)); + *v = SUNRsqrt(TWO + s(t)); return 0; } @@ -115,8 +115,8 @@ static int true_sol(sunrealtype t, sunrealtype* u, sunrealtype* v) // Compute the true solution derivative static int true_sol_p(sunrealtype t, sunrealtype* up, sunrealtype* vp) { - *up = rdot(t) / (TWO * sqrt(ONE + r(t))); - *vp = sdot(t) / (TWO * sqrt(TWO + s(t))); + *up = rdot(t) / (TWO * SUNRsqrt(ONE + r(t))); + *vp = sdot(t) / (TWO * SUNRsqrt(TWO + s(t))); return 0; } diff --git a/test/unit_tests/idas/CXX_serial/idas_test_getjac.cpp b/test/unit_tests/idas/CXX_serial/idas_test_getjac.cpp index 4579f8e1c6..fa2c1ae78b 100644 --- a/test/unit_tests/idas/CXX_serial/idas_test_getjac.cpp +++ b/test/unit_tests/idas/CXX_serial/idas_test_getjac.cpp @@ -66,24 +66,24 @@ // ----------------------------------------------------------------------------- // Compute r(t) -static sunrealtype r(sunrealtype t) { return HALF * cos(t); } +static sunrealtype r(sunrealtype t) { return HALF * SUNRcos(t); } // Compute the derivative of r(t) -static sunrealtype rdot(sunrealtype t) { return -HALF * sin(t); } +static sunrealtype rdot(sunrealtype t) { return -HALF * SUNRsin(t); } // Compute s(t) -static sunrealtype s(sunrealtype t) { return cos(TWENTY * t); } +static sunrealtype s(sunrealtype t) { return SUNRcos(TWENTY * t); } // Compute the derivative of s(t) -static sunrealtype sdot(sunrealtype t) { return -TWENTY * sin(TWENTY * t); } +static sunrealtype sdot(sunrealtype t) { return -TWENTY * SUNRsin(TWENTY * t); } // Compute the true solution static int ytrue(sunrealtype t, N_Vector y) { sunrealtype* ydata = N_VGetArrayPointer(y); - ydata[0] = sqrt(ONE + r(t)); - ydata[1] = sqrt(TWO + s(t)); + ydata[0] = SUNRsqrt(ONE + r(t)); + ydata[1] = SUNRsqrt(TWO + s(t)); return 0; } @@ -93,8 +93,8 @@ static int yptrue(sunrealtype t, N_Vector yp) { sunrealtype* ypdata = N_VGetArrayPointer(yp); - ypdata[0] = HALF * rdot(t) / sqrt(ONE + r(t)); - ypdata[1] = HALF * sdot(t) / sqrt(TWO + s(t)); + ypdata[0] = HALF * rdot(t) / SUNRsqrt(ONE + r(t)); + ypdata[1] = HALF * sdot(t) / SUNRsqrt(TWO + s(t)); return 0; } @@ -228,7 +228,7 @@ int main(int argc, char* argv[]) sundials::Context sunctx; // Comparison tolerance - sunrealtype tol = 100 * std::sqrt(SUN_UNIT_ROUNDOFF); + sunrealtype tol = 100 * SUNRsqrt(SUN_UNIT_ROUNDOFF); if (argc > 1) { #if defined(SUNDIALS_SINGLE_PRECISION) @@ -237,6 +237,8 @@ int main(int argc, char* argv[]) tol = std::stod(argv[1]); #elif defined(SUNDIALS_EXTENDED_PRECISION) tol = std::stold(argv[1]); +#elif defined(SUNDIALS_FLOAT128_PRECISION) + tol = strtoflt128(argv[1], NULL); #else #error "SUNDIALS precision macro not defined" #endif @@ -255,6 +257,8 @@ int main(int argc, char* argv[]) const sunrealtype rtol = SUN_RCONST(1.0e-6); #elif defined(SUNDIALS_EXTENDED_PRECISION) const sunrealtype rtol = SUN_RCONST(1.0e-9); +#elif defined(SUNDIALS_FLOAT128_PRECISION) + const sunrealtype rtol = SUN_RCONST(1.0e-9); #else #error "SUNDIALS precision macro not defined" #endif @@ -349,7 +353,11 @@ int main(int argc, char* argv[]) // Output Jacobian data std::cout << std::scientific; - std::cout << std::setprecision(std::numeric_limits::digits10); +#if defined(SUNDIALS_FLOAT128_PRECISION) + std::cout << std::setprecision(SUN_DIGITS10 / 2); +#else + std::cout << std::setprecision(SUN_DIGITS10); +#endif std::cout << "Jac nst = " << nst_Jdq << std::endl; std::cout << "Jac t = " << t_Jdq << std::endl; std::cout << "Jac cj = " << cj_Jdq << std::endl; @@ -368,9 +376,9 @@ int main(int argc, char* argv[]) std::cout << std::setw(8) << std::right << i << std::setw(25) << std::right << Jdq_data[i] << std::setw(25) << std::right << Jtrue_data[i] << std::setw(25) << std::right - << std::abs(Jdq_data[i] - Jtrue_data[i]) << std::setw(25) + << SUNRabs(Jdq_data[i] - Jtrue_data[i]) << std::setw(25) << std::right - << std::abs(Jdq_data[i] - Jtrue_data[i]) / Jtrue_data[i] + << SUNRabs(Jdq_data[i] - Jtrue_data[i]) / Jtrue_data[i] << std::endl; result += SUNRCompareTol(Jdq_data[i], Jtrue_data[i], tol); } diff --git a/test/unit_tests/idas/CXX_serial/idas_test_kpr.cpp b/test/unit_tests/idas/CXX_serial/idas_test_kpr.cpp index 0151ffab81..a80b7c8b58 100644 --- a/test/unit_tests/idas/CXX_serial/idas_test_kpr.cpp +++ b/test/unit_tests/idas/CXX_serial/idas_test_kpr.cpp @@ -118,7 +118,7 @@ int main(int argc, char* argv[]) // Output initial contion cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << " t "; cout << " u "; cout << " v "; diff --git a/test/unit_tests/idas/CXX_serial/idas_test_kpr.hpp b/test/unit_tests/idas/CXX_serial/idas_test_kpr.hpp index c895819bf6..f903cf8323 100644 --- a/test/unit_tests/idas/CXX_serial/idas_test_kpr.hpp +++ b/test/unit_tests/idas/CXX_serial/idas_test_kpr.hpp @@ -92,22 +92,22 @@ int J(sunrealtype t, sunrealtype cj, N_Vector y, N_Vector yp, N_Vector rr, // ----------------------------------------------------------------------------- // Compute r(t) -static sunrealtype r(sunrealtype t) { return HALF * cos(t); } +static sunrealtype r(sunrealtype t) { return HALF * SUNRcos(t); } // Compute the derivative of r(t) -static sunrealtype rdot(sunrealtype t) { return -HALF * sin(t); } +static sunrealtype rdot(sunrealtype t) { return -HALF * SUNRsin(t); } // Compute s(t) -static sunrealtype s(sunrealtype t) { return cos(TWENTY * t); } +static sunrealtype s(sunrealtype t) { return SUNRcos(TWENTY * t); } // Compute the derivative of s(t) -static sunrealtype sdot(sunrealtype t) { return -TWENTY * sin(TWENTY * t); } +static sunrealtype sdot(sunrealtype t) { return -TWENTY * SUNRsin(TWENTY * t); } // Compute the true solution static int true_sol(sunrealtype t, sunrealtype* u, sunrealtype* v) { - *u = sqrt(ONE + r(t)); - *v = sqrt(TWO + s(t)); + *u = SUNRsqrt(ONE + r(t)); + *v = SUNRsqrt(TWO + s(t)); return 0; } @@ -115,8 +115,8 @@ static int true_sol(sunrealtype t, sunrealtype* u, sunrealtype* v) // Compute the true solution derivative static int true_sol_p(sunrealtype t, sunrealtype* up, sunrealtype* vp) { - *up = rdot(t) / (TWO * sqrt(ONE + r(t))); - *vp = sdot(t) / (TWO * sqrt(TWO + s(t))); + *up = rdot(t) / (TWO * SUNRsqrt(ONE + r(t))); + *vp = sdot(t) / (TWO * SUNRsqrt(TWO + s(t))); return 0; } diff --git a/test/unit_tests/idas/C_serial/idas_test_tstop.c b/test/unit_tests/idas/C_serial/idas_test_tstop.c index 0c6302ee68..a1862c0a24 100644 --- a/test/unit_tests/idas/C_serial/idas_test_tstop.c +++ b/test/unit_tests/idas/C_serial/idas_test_tstop.c @@ -27,7 +27,9 @@ #include "sunlinsol/sunlinsol_dense.h" #include "sunmatrix/sunmatrix_dense.h" -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #else #define GSYM "g" diff --git a/test/unit_tests/kinsol/CXX_serial/kin_test_getjac.cpp b/test/unit_tests/kinsol/CXX_serial/kin_test_getjac.cpp index dcec8a1424..2a433862e8 100644 --- a/test/unit_tests/kinsol/CXX_serial/kin_test_getjac.cpp +++ b/test/unit_tests/kinsol/CXX_serial/kin_test_getjac.cpp @@ -67,8 +67,6 @@ #define EIGHTYONE SUN_RCONST(81.0) #define PI SUN_RCONST(3.141592653589793238462643383279502884197169) -#define SQR(x) ((x) * (x)) - // ----------------------------------------------------------------------------- // Functions provided to the SUNDIALS solver // ----------------------------------------------------------------------------- @@ -90,9 +88,10 @@ static int res(N_Vector uu, N_Vector fuu, void* user_data) const sunrealtype y = udata[1]; const sunrealtype z = udata[2]; - fdata[0] = THREE * x - std::cos((y - ONE) * z) - HALF; - fdata[1] = SQR(x) - EIGHTYONE * SQR((y - PTNINE)) + std::sin(z) + ONEPTZEROSIX; - fdata[2] = std::exp(-x * (y - ONE)) + TWENTY * z + (TEN * PI - THREE) / THREE; + fdata[0] = THREE * x - SUNRcos((y - ONE) * z) - HALF; + fdata[1] = SUNSQR(x) - EIGHTYONE * SUNSQR((y - PTNINE)) + SUNRsin(z) + + ONEPTZEROSIX; + fdata[2] = SUNRexp(-x * (y - ONE)) + TWENTY * z + (TEN * PI - THREE) / THREE; return 0; } @@ -118,16 +117,16 @@ static int J(N_Vector uu, N_Vector fuu, SUNMatrix J, void* user_data, // First column Jdata[0] = THREE; Jdata[1] = TWO * x; - Jdata[2] = std::exp(-x * (y - ONE)) * (ONE - y); + Jdata[2] = SUNRexp(-x * (y - ONE)) * (ONE - y); // Second column - Jdata[3] = std::sin((y - ONE) * z) * z; + Jdata[3] = SUNRsin((y - ONE) * z) * z; Jdata[4] = -TWO * EIGHTYONE * (y - PTNINE); - Jdata[5] = -std::exp(-x * (y - ONE)) * x; + Jdata[5] = -SUNRexp(-x * (y - ONE)) * x; // Third column - Jdata[6] = std::sin((y - ONE) * z) * (y - ONE); - Jdata[7] = cos(z); + Jdata[6] = SUNRsin((y - ONE) * z) * (y - ONE); + Jdata[7] = SUNRcos(z); Jdata[8] = TWENTY; return 0; @@ -193,7 +192,7 @@ int main(int argc, char* argv[]) sundials::Context sunctx; // Comparison tolerance - sunrealtype tol = 100 * std::sqrt(SUN_UNIT_ROUNDOFF); + sunrealtype tol = 100 * SUNRsqrt(SUN_UNIT_ROUNDOFF); if (argc > 1) { #if defined(SUNDIALS_SINGLE_PRECISION) @@ -202,6 +201,8 @@ int main(int argc, char* argv[]) tol = std::stod(argv[1]); #elif defined(SUNDIALS_EXTENDED_PRECISION) tol = std::stold(argv[1]); +#elif defined(SUNDIALS_FLOAT128_PRECISION) + tol = strtoflt128(argv[1], NULL); #else #error "SUNDIALS precision macro not defined" #endif @@ -213,7 +214,7 @@ int main(int argc, char* argv[]) } // Integration tolerances - const sunrealtype ftol = 10 * std::sqrt(SUN_UNIT_ROUNDOFF); + const sunrealtype ftol = 10 * SUNRsqrt(SUN_UNIT_ROUNDOFF); // Create initial guess and scaling vectors N_Vector uu = N_VNew_Serial(3, sunctx); @@ -297,7 +298,11 @@ int main(int argc, char* argv[]) // Output Jacobian data std::cout << std::scientific; - std::cout << std::setprecision(std::numeric_limits::digits10); +#if defined(SUNDIALS_FLOAT128_PRECISION) + std::cout << std::setprecision(SUN_DIGITS10 / 2); +#else + std::cout << std::setprecision(SUN_DIGITS10); +#endif std::cout << "nni = " << nni << std::endl; std::cout << "Jac nni = " << nni_Jdq << std::endl; std::cout << std::endl; @@ -315,9 +320,9 @@ int main(int argc, char* argv[]) std::cout << std::setw(8) << std::right << i << std::setw(25) << std::right << Jdq_data[i] << std::setw(25) << std::right << Jtrue_data[i] << std::setw(25) << std::right - << std::abs(Jdq_data[i] - Jtrue_data[i]) << std::setw(25) + << SUNRabs(Jdq_data[i] - Jtrue_data[i]) << std::setw(25) << std::right - << std::abs(Jdq_data[i] - Jtrue_data[i]) / Jtrue_data[i] + << SUNRabs(Jdq_data[i] - Jtrue_data[i]) / Jtrue_data[i] << std::endl; result += SUNRCompareTol(Jdq_data[i], Jtrue_data[i], tol); } diff --git a/test/unit_tests/logging/test_logging_arkode_arkstep.cpp b/test/unit_tests/logging/test_logging_arkode_arkstep.cpp index 3acc47e40a..e69d806b22 100644 --- a/test/unit_tests/logging/test_logging_arkode_arkstep.cpp +++ b/test/unit_tests/logging/test_logging_arkode_arkstep.cpp @@ -176,7 +176,7 @@ int main(int argc, char* argv[]) // Output initial contion cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << " t "; cout << " u "; cout << " v "; diff --git a/test/unit_tests/logging/test_logging_arkode_erkstep.cpp b/test/unit_tests/logging/test_logging_arkode_erkstep.cpp index 8284eb66f9..ad220a1550 100644 --- a/test/unit_tests/logging/test_logging_arkode_erkstep.cpp +++ b/test/unit_tests/logging/test_logging_arkode_erkstep.cpp @@ -86,7 +86,7 @@ int main(int argc, char* argv[]) // Output initial contion cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << " t "; cout << " u "; cout << " v "; diff --git a/test/unit_tests/logging/test_logging_arkode_forcingstep.cpp b/test/unit_tests/logging/test_logging_arkode_forcingstep.cpp index 18d84e7b41..d0b32be4ad 100644 --- a/test/unit_tests/logging/test_logging_arkode_forcingstep.cpp +++ b/test/unit_tests/logging/test_logging_arkode_forcingstep.cpp @@ -109,11 +109,11 @@ int main(int argc, char* argv[]) sunrealtype tret = zero; sunrealtype tout = tret + dtout; - const int width = numeric_limits::digits10 + 8; + const int width = SUN_DIGITS10 + 8; // Output initial contion cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << setw(width) << " t"; cout << setw(width) << " y"; cout << setw(width) << " y err" << endl; diff --git a/test/unit_tests/logging/test_logging_arkode_lsrkstep.cpp b/test/unit_tests/logging/test_logging_arkode_lsrkstep.cpp index 48198a6f1d..eb5d123684 100644 --- a/test/unit_tests/logging/test_logging_arkode_lsrkstep.cpp +++ b/test/unit_tests/logging/test_logging_arkode_lsrkstep.cpp @@ -120,11 +120,11 @@ int main(int argc, char* argv[]) sunrealtype tret = zero; sunrealtype tout = tret + dtout; - const int width = numeric_limits::digits10 + 8; + const int width = SUN_DIGITS10 + 8; // Output initial contion cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << setw(width) << " t"; cout << setw(width) << " y"; cout << setw(width) << " y err" << endl; diff --git a/test/unit_tests/logging/test_logging_arkode_mristep.cpp b/test/unit_tests/logging/test_logging_arkode_mristep.cpp index 05531b198b..2f4a2b8084 100644 --- a/test/unit_tests/logging/test_logging_arkode_mristep.cpp +++ b/test/unit_tests/logging/test_logging_arkode_mristep.cpp @@ -267,7 +267,7 @@ int main(int argc, char* argv[]) // Output initial contion cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << " t "; cout << " u "; cout << " v "; diff --git a/test/unit_tests/logging/test_logging_arkode_splittingstep.cpp b/test/unit_tests/logging/test_logging_arkode_splittingstep.cpp index 07301d7034..985104f1b1 100644 --- a/test/unit_tests/logging/test_logging_arkode_splittingstep.cpp +++ b/test/unit_tests/logging/test_logging_arkode_splittingstep.cpp @@ -109,11 +109,11 @@ int main(int argc, char* argv[]) sunrealtype tret = zero; sunrealtype tout = tret + dtout; - const int width = numeric_limits::digits10 + 8; + const int width = SUN_DIGITS10 + 8; // Output initial contion cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << setw(width) << " t"; cout << setw(width) << " y"; cout << setw(width) << " y err" << endl; diff --git a/test/unit_tests/logging/test_logging_arkode_sprkstep.cpp b/test/unit_tests/logging/test_logging_arkode_sprkstep.cpp index 37828278f0..d37d9a9c44 100644 --- a/test/unit_tests/logging/test_logging_arkode_sprkstep.cpp +++ b/test/unit_tests/logging/test_logging_arkode_sprkstep.cpp @@ -88,7 +88,7 @@ int main(int argc, char* argv[]) if (check_ptr(y, "N_VGetArrayPointer")) { return 1; } cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << " t "; cout << " q1 "; cout << " q2 "; diff --git a/test/unit_tests/logging/test_logging_cvode.cpp b/test/unit_tests/logging/test_logging_cvode.cpp index cec92af8f3..206a410f65 100644 --- a/test/unit_tests/logging/test_logging_cvode.cpp +++ b/test/unit_tests/logging/test_logging_cvode.cpp @@ -148,7 +148,7 @@ int main(int argc, char* argv[]) // Output initial contion cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << " t "; cout << " u "; cout << " v "; diff --git a/test/unit_tests/logging/test_logging_cvodes.cpp b/test/unit_tests/logging/test_logging_cvodes.cpp index cc3db57893..d2dd84345f 100644 --- a/test/unit_tests/logging/test_logging_cvodes.cpp +++ b/test/unit_tests/logging/test_logging_cvodes.cpp @@ -148,7 +148,7 @@ int main(int argc, char* argv[]) // Output initial contion cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << " t "; cout << " u "; cout << " v "; diff --git a/test/unit_tests/logging/test_logging_ida.cpp b/test/unit_tests/logging/test_logging_ida.cpp index 7ac648799b..2b250374a2 100644 --- a/test/unit_tests/logging/test_logging_ida.cpp +++ b/test/unit_tests/logging/test_logging_ida.cpp @@ -141,7 +141,7 @@ int main(int argc, char* argv[]) // Output initial contion cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << " t "; cout << " u "; cout << " v "; diff --git a/test/unit_tests/logging/test_logging_idas.cpp b/test/unit_tests/logging/test_logging_idas.cpp index b8b5b03382..a1dcce9880 100644 --- a/test/unit_tests/logging/test_logging_idas.cpp +++ b/test/unit_tests/logging/test_logging_idas.cpp @@ -141,7 +141,7 @@ int main(int argc, char* argv[]) // Output initial contion cout << scientific; - cout << setprecision(numeric_limits::digits10); + cout << setprecision(SUN_DIGITS10); cout << " t "; cout << " u "; cout << " v "; diff --git a/test/unit_tests/nvector/openmpdev/test_nvector_openmpdev.c b/test/unit_tests/nvector/openmpdev/test_nvector_openmpdev.c index 1c34427abe..e70e302a66 100644 --- a/test/unit_tests/nvector/openmpdev/test_nvector_openmpdev.c +++ b/test/unit_tests/nvector/openmpdev/test_nvector_openmpdev.c @@ -256,7 +256,7 @@ int Test_N_VMake_OpenMPDEV(N_Vector X, sunindextype length, int myid) d_data = N_VGetDeviceArrayPointer_OpenMPDEV(X); /* Case 1: h_data and d_data are not null */ - Y = N_VMake_OpenMPDEV(length, h_data, d_data); + Y = N_VMake_OpenMPDEV(length, h_data, d_data, sunctx); if (Y == NULL) { printf(">>> FAILED test -- N_VMake_OpenMPDEV, Proc %d \n", myid); @@ -295,7 +295,7 @@ int Test_N_VMake_OpenMPDEV(N_Vector X, sunindextype length, int myid) N_VDestroy(Y); /* Case 2: data is null */ - Y = N_VMake_OpenMPDEV(length, NULL, NULL); + Y = N_VMake_OpenMPDEV(length, NULL, NULL, sunctx); if (Y != NULL) { printf(">>> FAILED test -- N_VMake_OpenMPDEV Case 2, Proc %d \n", myid); @@ -353,9 +353,8 @@ void set_element_range(N_Vector X, sunindextype is, sunindextype ie, /* set elements [is,ie] of the data array */ #pragma omp target map(to : is, ie, val) is_device_ptr(xdev) device(dev) #pragma omp teams distribute parallel for schedule(static, 1) - { - for (i = is; i <= ie; i++) { xdev[i] = val; } - } + + for (i = is; i <= ie; i++) { xdev[i] = val; } } sunrealtype get_element(N_Vector X, sunindextype i) diff --git a/test/unit_tests/nvector/test_nvector.c b/test/unit_tests/nvector/test_nvector.c index de27039a9e..3a6f98da2c 100644 --- a/test/unit_tests/nvector/test_nvector.c +++ b/test/unit_tests/nvector/test_nvector.c @@ -38,7 +38,9 @@ #include "test_nvector.h" -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define FSYM "Qf" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define FSYM "Lf" #else #define FSYM ".17f" diff --git a/test/unit_tests/problems/estep.hpp b/test/unit_tests/problems/estep.hpp index 6e355ec88e..d156ef0659 100644 --- a/test/unit_tests/problems/estep.hpp +++ b/test/unit_tests/problems/estep.hpp @@ -70,7 +70,7 @@ inline int true_solution(sunrealtype t, sunrealtype lambda, N_Vector y_vec) sunrealtype* y_data = N_VGetArrayPointer(y_vec); if (y_data == nullptr) { return 1; } - y_data[0] = lambda * y0 / (y0 - (y0 - lambda) * std::exp(lambda * t)); + y_data[0] = lambda * y0 / (y0 - (y0 - lambda) * SUNRexp(lambda * t)); return 0; } diff --git a/test/unit_tests/problems/kepler.hpp b/test/unit_tests/problems/kepler.hpp index 93b92cf60d..4119bc35ed 100644 --- a/test/unit_tests/problems/kepler.hpp +++ b/test/unit_tests/problems/kepler.hpp @@ -71,7 +71,7 @@ inline int initial_condition(N_Vector y_vec, sunrealtype ecc) y_data[0] = one - ecc; y_data[1] = zero; y_data[2] = zero; - y_data[3] = std::sqrt((one + ecc) / (one - ecc)); + y_data[3] = SUNRsqrt((one + ecc) / (one - ecc)); return 0; } @@ -91,7 +91,7 @@ inline int hamiltonian(N_Vector y_vec, sunrealtype* H) const sunrealtype qTq = q1 * q1 + q2 * q2; const sunrealtype pTp = p1 * p1 + p2 * p2; - *H = half * pTp - one / std::sqrt(qTq); + *H = half * pTp - one / SUNRsqrt(qTq); return 0; } @@ -143,10 +143,10 @@ inline int ode_rhs_force(sunrealtype t, N_Vector y_vec, N_Vector f_vec, const sunrealtype q1 = y_data[0]; const sunrealtype q2 = y_data[1]; - const sunrealtype sqrt_qTq = std::sqrt(q1 * q1 + q2 * q2); + const sunrealtype sqrt_qTq = SUNRsqrt(q1 * q1 + q2 * q2); - f_data[2] = -q1 / std::pow(sqrt_qTq, 3); - f_data[3] = -q2 / std::pow(sqrt_qTq, 3); + f_data[2] = -q1 / SUNRpowerI(sqrt_qTq, 3); + f_data[3] = -q2 / SUNRpowerI(sqrt_qTq, 3); return 0; } diff --git a/test/unit_tests/problems/kpr.hpp b/test/unit_tests/problems/kpr.hpp index ba7b9a90c7..7012231c21 100644 --- a/test/unit_tests/problems/kpr.hpp +++ b/test/unit_tests/problems/kpr.hpp @@ -60,25 +60,25 @@ sunrealtype problem_data[4] = {-two, half, half, -one}; // ----------------------------------------------------------------------------- // Compute rho(t) -inline sunrealtype rho(sunrealtype t) { return half * std::cos(t); } +inline sunrealtype rho(sunrealtype t) { return half * SUNRcos(t); } // Compute rho'(t) -inline sunrealtype rho_p(sunrealtype t) { return -half * std::sin(t); } +inline sunrealtype rho_p(sunrealtype t) { return -half * SUNRsin(t); } // Compute sigma(t) -inline sunrealtype sig(sunrealtype t) { return cos(twenty * t); } +inline sunrealtype sig(sunrealtype t) { return SUNRcos(twenty * t); } // Compute sigma'(t) inline sunrealtype sig_p(sunrealtype t) { - return -twenty * std::sin(twenty * t); + return -twenty * SUNRsin(twenty * t); } // Compute the true solution inline int true_sol(sunrealtype t, sunrealtype* u, sunrealtype* v) { - *u = std::sqrt(one + rho(t)); - *v = std::sqrt(two + sig(t)); + *u = SUNRsqrt(one + rho(t)); + *v = SUNRsqrt(two + sig(t)); return 0; } @@ -86,8 +86,8 @@ inline int true_sol(sunrealtype t, sunrealtype* u, sunrealtype* v) // Compute the true solution derivative inline int true_sol_p(sunrealtype t, sunrealtype* up, sunrealtype* vp) { - *up = rho_p(t) / (two * std::sqrt(one + rho(t))); - *vp = sig_p(t) / (two * std::sqrt(two + sig(t))); + *up = rho_p(t) / (two * SUNRsqrt(one + rho(t))); + *vp = sig_p(t) / (two * SUNRsqrt(two + sig(t))); return 0; } diff --git a/test/unit_tests/problems/pr.hpp b/test/unit_tests/problems/pr.hpp index 0358f034a3..a1d3a22a3e 100644 --- a/test/unit_tests/problems/pr.hpp +++ b/test/unit_tests/problems/pr.hpp @@ -42,7 +42,7 @@ namespace pr { // ----------------------------------------------------------------------------- // Compute phi(t) -inline sunrealtype phi(sunrealtype t) { return std::atan(t); } +inline sunrealtype phi(sunrealtype t) { return SUNRatan(t); } // Compute phi'(t) inline sunrealtype phi_prime(sunrealtype t) diff --git a/test/unit_tests/problems/prv.hpp b/test/unit_tests/problems/prv.hpp index e382df0915..42ec2e19c9 100644 --- a/test/unit_tests/problems/prv.hpp +++ b/test/unit_tests/problems/prv.hpp @@ -44,7 +44,7 @@ namespace problems { namespace prv { // Problem constants -static const sunrealtype pi = std::acos(SUN_RCONST(-1.0)); +static const sunrealtype pi = SUNRacos(SUN_RCONST(-1.0)); constexpr sunrealtype zero = SUN_RCONST(0.0); constexpr sunrealtype one = SUN_RCONST(1.0); @@ -60,11 +60,11 @@ sunrealtype problem_data[2] = {SUN_RCONST(-1000.0), SUN_RCONST(10.0)}; // Compute L(t) inline sunrealtype l_coef(sunrealtype t, sunrealtype c[2]) { - return c[0] - c[1] * std::cos((ten - t) / ten * pi); + return c[0] - c[1] * SUNRcos((ten - t) / ten * pi); } // Compute phi(t) -inline sunrealtype phi(sunrealtype t) { return std::atan(t); } +inline sunrealtype phi(sunrealtype t) { return SUNRatan(t); } // Compute phi'(t) inline sunrealtype phi_prime(sunrealtype t) { return one / (one + t * t); } diff --git a/test/unit_tests/sunlinsol/band/test_sunlinsol_band.c b/test/unit_tests/sunlinsol/band/test_sunlinsol_band.c index e7d395747b..d7c2c77f1c 100644 --- a/test/unit_tests/sunlinsol/band/test_sunlinsol_band.c +++ b/test/unit_tests/sunlinsol/band/test_sunlinsol_band.c @@ -30,7 +30,9 @@ #include "test_sunlinsol.h" -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #else #define GSYM "g" diff --git a/test/unit_tests/sunlinsol/dense/test_sunlinsol_dense.c b/test/unit_tests/sunlinsol/dense/test_sunlinsol_dense.c index 0bcd875c26..df6fc93ce1 100644 --- a/test/unit_tests/sunlinsol/dense/test_sunlinsol_dense.c +++ b/test/unit_tests/sunlinsol/dense/test_sunlinsol_dense.c @@ -30,7 +30,9 @@ #include "test_sunlinsol.h" -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #else #define GSYM "g" diff --git a/test/unit_tests/sunlinsol/pcg/parallel/test_sunlinsol_pcg_parallel.c b/test/unit_tests/sunlinsol/pcg/parallel/test_sunlinsol_pcg_parallel.c index 8be97cd809..11d7a3310c 100644 --- a/test/unit_tests/sunlinsol/pcg/parallel/test_sunlinsol_pcg_parallel.c +++ b/test/unit_tests/sunlinsol/pcg/parallel/test_sunlinsol_pcg_parallel.c @@ -31,7 +31,9 @@ #include "mpi.h" #include "test_sunlinsol.h" -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #else #define GSYM "g" diff --git a/test/unit_tests/sunlinsol/pcg/serial/test_sunlinsol_pcg_serial.c b/test/unit_tests/sunlinsol/pcg/serial/test_sunlinsol_pcg_serial.c index 1fc28da139..d58ab8c448 100644 --- a/test/unit_tests/sunlinsol/pcg/serial/test_sunlinsol_pcg_serial.c +++ b/test/unit_tests/sunlinsol/pcg/serial/test_sunlinsol_pcg_serial.c @@ -30,7 +30,9 @@ #include "test_sunlinsol.h" -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #else #define GSYM "g" diff --git a/test/unit_tests/sunlinsol/spbcgs/parallel/test_sunlinsol_spbcgs_parallel.c b/test/unit_tests/sunlinsol/spbcgs/parallel/test_sunlinsol_spbcgs_parallel.c index 8e3f660eaf..61d1ca233e 100644 --- a/test/unit_tests/sunlinsol/spbcgs/parallel/test_sunlinsol_spbcgs_parallel.c +++ b/test/unit_tests/sunlinsol/spbcgs/parallel/test_sunlinsol_spbcgs_parallel.c @@ -31,7 +31,9 @@ #include "mpi.h" #include "test_sunlinsol.h" -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #else #define GSYM "g" diff --git a/test/unit_tests/sunlinsol/spbcgs/serial/test_sunlinsol_spbcgs_serial.c b/test/unit_tests/sunlinsol/spbcgs/serial/test_sunlinsol_spbcgs_serial.c index 564f36efc2..4866228f3c 100644 --- a/test/unit_tests/sunlinsol/spbcgs/serial/test_sunlinsol_spbcgs_serial.c +++ b/test/unit_tests/sunlinsol/spbcgs/serial/test_sunlinsol_spbcgs_serial.c @@ -30,7 +30,9 @@ #include "test_sunlinsol.h" -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #else #define GSYM "g" diff --git a/test/unit_tests/sunlinsol/spfgmr/parallel/test_sunlinsol_spfgmr_parallel.c b/test/unit_tests/sunlinsol/spfgmr/parallel/test_sunlinsol_spfgmr_parallel.c index 6b9a681e0f..8e7b4504bd 100644 --- a/test/unit_tests/sunlinsol/spfgmr/parallel/test_sunlinsol_spfgmr_parallel.c +++ b/test/unit_tests/sunlinsol/spfgmr/parallel/test_sunlinsol_spfgmr_parallel.c @@ -31,7 +31,9 @@ #include "mpi.h" #include "test_sunlinsol.h" -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #else #define GSYM "g" diff --git a/test/unit_tests/sunlinsol/spfgmr/serial/test_sunlinsol_spfgmr_serial.c b/test/unit_tests/sunlinsol/spfgmr/serial/test_sunlinsol_spfgmr_serial.c index 93a453898c..f3205311e2 100644 --- a/test/unit_tests/sunlinsol/spfgmr/serial/test_sunlinsol_spfgmr_serial.c +++ b/test/unit_tests/sunlinsol/spfgmr/serial/test_sunlinsol_spfgmr_serial.c @@ -30,7 +30,9 @@ #include "test_sunlinsol.h" -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #else #define GSYM "g" diff --git a/test/unit_tests/sunlinsol/spgmr/parallel/test_sunlinsol_spgmr_parallel.c b/test/unit_tests/sunlinsol/spgmr/parallel/test_sunlinsol_spgmr_parallel.c index 30e34ca46b..8e709f7833 100644 --- a/test/unit_tests/sunlinsol/spgmr/parallel/test_sunlinsol_spgmr_parallel.c +++ b/test/unit_tests/sunlinsol/spgmr/parallel/test_sunlinsol_spgmr_parallel.c @@ -31,7 +31,9 @@ #include "mpi.h" #include "test_sunlinsol.h" -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #else #define GSYM "g" diff --git a/test/unit_tests/sunlinsol/spgmr/serial/test_sunlinsol_spgmr_serial.c b/test/unit_tests/sunlinsol/spgmr/serial/test_sunlinsol_spgmr_serial.c index c751f8f1b8..d0a6a95178 100644 --- a/test/unit_tests/sunlinsol/spgmr/serial/test_sunlinsol_spgmr_serial.c +++ b/test/unit_tests/sunlinsol/spgmr/serial/test_sunlinsol_spgmr_serial.c @@ -30,7 +30,9 @@ #include "test_sunlinsol.h" -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #else #define GSYM "g" diff --git a/test/unit_tests/sunlinsol/sptfqmr/parallel/test_sunlinsol_sptfqmr_parallel.c b/test/unit_tests/sunlinsol/sptfqmr/parallel/test_sunlinsol_sptfqmr_parallel.c index cbc96d969a..e59872e470 100644 --- a/test/unit_tests/sunlinsol/sptfqmr/parallel/test_sunlinsol_sptfqmr_parallel.c +++ b/test/unit_tests/sunlinsol/sptfqmr/parallel/test_sunlinsol_sptfqmr_parallel.c @@ -31,7 +31,9 @@ #include "mpi.h" #include "test_sunlinsol.h" -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #else #define GSYM "g" diff --git a/test/unit_tests/sunlinsol/sptfqmr/serial/test_sunlinsol_sptfqmr_serial.c b/test/unit_tests/sunlinsol/sptfqmr/serial/test_sunlinsol_sptfqmr_serial.c index a4908710fa..7b841b1293 100644 --- a/test/unit_tests/sunlinsol/sptfqmr/serial/test_sunlinsol_sptfqmr_serial.c +++ b/test/unit_tests/sunlinsol/sptfqmr/serial/test_sunlinsol_sptfqmr_serial.c @@ -30,7 +30,9 @@ #include "test_sunlinsol.h" -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #else #define GSYM "g" diff --git a/test/unit_tests/sunmatrix/band/test_sunmatrix_band.c b/test/unit_tests/sunmatrix/band/test_sunmatrix_band.c index 4d2b98c026..274394638a 100644 --- a/test/unit_tests/sunmatrix/band/test_sunmatrix_band.c +++ b/test/unit_tests/sunmatrix/band/test_sunmatrix_band.c @@ -31,7 +31,9 @@ #include "test_sunmatrix.h" -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #else #define GSYM "g" diff --git a/test/unit_tests/sunmatrix/dense/test_sunmatrix_dense.c b/test/unit_tests/sunmatrix/dense/test_sunmatrix_dense.c index f69e99074e..b7b15e44a8 100644 --- a/test/unit_tests/sunmatrix/dense/test_sunmatrix_dense.c +++ b/test/unit_tests/sunmatrix/dense/test_sunmatrix_dense.c @@ -30,7 +30,9 @@ #include "test_sunmatrix.h" -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #else #define GSYM "g" diff --git a/test/unit_tests/sunnonlinsol/fixedpoint/test_sunnonlinsol_fixedpoint.c b/test/unit_tests/sunnonlinsol/fixedpoint/test_sunnonlinsol_fixedpoint.c index 2986561b68..fdcac4a137 100644 --- a/test/unit_tests/sunnonlinsol/fixedpoint/test_sunnonlinsol_fixedpoint.c +++ b/test/unit_tests/sunnonlinsol/fixedpoint/test_sunnonlinsol_fixedpoint.c @@ -40,40 +40,31 @@ #include "sunnonlinsol/sunnonlinsol_fixedpoint.h" /* precision specific formatting macros */ -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #else #define GSYM "g" #endif -/* precision specific math function macros */ -#if defined(SUNDIALS_DOUBLE_PRECISION) -#define SUNRsin(x) (sin((x))) -#define SUNRcos(x) (cos((x))) -#elif defined(SUNDIALS_SINGLE_PRECISION) -#define SUNRsin(x) (sinf((x))) -#define SUNRcos(x) (cosf((x))) -#elif defined(SUNDIALS_EXTENDED_PRECISION) -#define SUNRsin(x) (sinl((x))) -#define SUNRcos(x) (cosl((x))) -#endif - /* problem constants */ #define NEQ 3 /* number of equations */ -#define ZERO SUN_RCONST(0.0) /* real 0.0 */ -#define PTONE SUN_RCONST(0.1) /* real 0.1 */ -#define HALF SUN_RCONST(0.5) /* real 0.5 */ -#define PTNINE SUN_RCONST(0.9) /* real 0.9 */ -#define ONE SUN_RCONST(1.0) /* real 1.0 */ -#define ONEPTZEROSIX SUN_RCONST(1.06) /* real 1.06 */ -#define THREE SUN_RCONST(3.0) /* real 3.0 */ -#define SIX SUN_RCONST(6.0) /* real 6.0 */ -#define NINE SUN_RCONST(9.0) /* real 9.0 */ -#define TEN SUN_RCONST(10.0) /* real 10.0 */ -#define TWENTY SUN_RCONST(20.0) /* real 20.0 */ -#define SIXTY SUN_RCONST(60.0) /* real 60.0 */ -#define PI SUN_RCONST(3.1415926535898) /* real pi */ +#define ZERO SUN_RCONST(0.0) /* real 0.0 */ +#define PTONE SUN_RCONST(0.1) /* real 0.1 */ +#define HALF SUN_RCONST(0.5) /* real 0.5 */ +#define PTNINE SUN_RCONST(0.9) /* real 0.9 */ +#define ONE SUN_RCONST(1.0) /* real 1.0 */ +#define ONEPTZEROSIX SUN_RCONST(1.06) /* real 1.06 */ +#define THREE SUN_RCONST(3.0) /* real 3.0 */ +#define SIX SUN_RCONST(6.0) /* real 6.0 */ +#define NINE SUN_RCONST(9.0) /* real 9.0 */ +#define TEN SUN_RCONST(10.0) /* real 10.0 */ +#define TWENTY SUN_RCONST(20.0) /* real 20.0 */ +#define SIXTY SUN_RCONST(60.0) /* real 60.0 */ +#define PI \ + SUN_RCONST(3.141592653589793238462643383279502884197169) /* real pi */ /* analytic solution */ #define XTRUE HALF diff --git a/test/unit_tests/sunnonlinsol/newton/test_sunnonlinsol_newton.c b/test/unit_tests/sunnonlinsol/newton/test_sunnonlinsol_newton.c index 2f785ab76e..9a0d0dacf0 100644 --- a/test/unit_tests/sunnonlinsol/newton/test_sunnonlinsol_newton.c +++ b/test/unit_tests/sunnonlinsol/newton/test_sunnonlinsol_newton.c @@ -26,7 +26,9 @@ #include "sunmatrix/sunmatrix_dense.h" #include "sunnonlinsol/sunnonlinsol_newton.h" -#if defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_FLOAT128_PRECISION) +#define GSYM "Qg" +#elif defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" #else #define GSYM "g" diff --git a/test/unit_tests/utilities/test_utilities.hpp b/test/unit_tests/utilities/test_utilities.hpp index dc53239e99..afcc06fc08 100644 --- a/test/unit_tests/utilities/test_utilities.hpp +++ b/test/unit_tests/utilities/test_utilities.hpp @@ -52,6 +52,8 @@ inline void find_arg(std::vector& args, const std::string key, dest = stod(*(it + 1)); #elif defined(SUNDIALS_EXTENDED_PRECISION) dest = stold(*(it + 1)); +#elif defined(SUNDIALS_FLOAT128_PRECISION) + dest = sunrealtype(stold(*(it + 1))); #endif args.erase(it, it + 2); }