From 968281667841a26152e8121e4b312f5140931e42 Mon Sep 17 00:00:00 2001 From: David Gardner Date: Mon, 20 May 2024 18:42:33 -0500 Subject: [PATCH] CI: Update Compiler Warnings, Enable Warnings as Errors (#484) * Additional warning flags from #481, #482, and #483 * Remove `-Wno-deprecated-declarations` * Enable warnings as errors in GitHub actions --- .../kokkos/ParallelGrid.hpp | 36 +++++++++++------ .../kokkos/advection_reaction_3D.cpp | 25 ++++++------ .../kokkos/advection_reaction_3D.hpp | 16 ++++---- .../kokkos/arkode_driver.cpp | 31 +++++++------- .../kokkos/ida_driver.cpp | 2 +- benchmarks/diffusion_2D/diffusion_2D.cpp | 8 ++-- benchmarks/diffusion_2D/diffusion_2D.hpp | 4 +- .../diffusion_2D/mpi_serial/buffers.cpp | 2 +- .../diffusion_2D/mpi_serial/diffusion.cpp | 15 +++---- benchmarks/nvector/test_nvector_performance.c | 12 +++--- cmake/SundialsSetupCompilers.cmake | 21 +++++++++- examples/arkode/CXX_parallel/ark_heat2D_p.cpp | 4 +- .../arkode/CXX_parhyp/ark_heat2D_hypre_ls.cpp | 32 +++------------ .../CXX_parhyp/ark_heat2D_hypre_pfmg.cpp | 4 +- .../ark_advection_diffusion_reaction.hpp | 33 +++++++-------- examples/cvode/CXX_parallel/cv_heat2D_p.cpp | 4 +- .../cvode/CXX_parhyp/cv_heat2D_hypre_ls.cpp | 6 +-- .../cvode/CXX_parhyp/cv_heat2D_hypre_pfmg.cpp | 6 +-- examples/cvode/CXX_serial/cv_heat2D.hpp | 16 ++++---- examples/cvode/CXX_serial/cv_kpr.hpp | 5 ++- examples/cvode/ginkgo/cv_heat2D_ginkgo.hpp | 16 ++++---- examples/cvode/ginkgo/cv_kpr_ginkgo.hpp | 4 +- examples/cvode/petsc/cv_petsc_ex7.c | 2 +- .../ida/trilinos/idaHeat2D_kry_tpetra.cpp | 6 +-- .../CXX_parallel/kin_heat2D_nonlin_p.hpp | 40 +++++++++++-------- .../kin_heat2D_nonlin_hypre_pfmg.hpp | 40 +++++++++++-------- .../ginkgo/test_sunlinsol_ginkgo.cpp | 38 +++++++++++++----- .../kokkos/test_sunlinsol_kokkosdense.cpp | 2 +- examples/sunmatrix/dreadrb.c | 2 + .../ginkgo/test_sunmatrix_ginkgo.cpp | 31 +++++++------- .../kokkos/test_sunmatrix_kokkosdense.cpp | 2 +- examples/utilities/example_utilities.hpp | 4 +- .../trilinos/SundialsTpetraVectorKernels.hpp | 8 +--- include/sunlinsol/sunlinsol_ginkgo.hpp | 8 ++++ include/sunlinsol/sunlinsol_kokkosdense.hpp | 4 +- include/sunmatrix/sunmatrix_kokkosdense.hpp | 2 +- src/arkode/fmod/farkode_arkstep_mod.f90 | 2 + src/arkode/fmod/farkode_erkstep_mod.f90 | 1 + src/cvode/CMakeLists.txt | 2 +- src/cvode/cvode.c | 15 ------- src/cvode/cvode_diag.c | 14 ------- src/cvode/cvode_impl.h | 28 +++++++++++++ src/cvode/cvode_nls.c | 6 --- src/sundials/fmod/fsundials_core_mod.c | 8 ++++ src/sundials/fmod/fsundials_core_mod.f90 | 16 ++++++++ src/sundials/sundials_futils.c | 1 + test/env/default.sh | 5 --- test/env/docker.sh | 3 -- .../arkode/CXX_serial/ark_test_getjac.cpp | 10 ++--- .../arkode/CXX_serial/ark_test_getjac_mri.cpp | 12 +++--- .../arkode/C_serial/ark_test_innerstepper.c | 6 +-- .../arkode/C_serial/ark_test_mass.c | 5 ++- .../arkode/C_serial/ark_test_tstop.c | 7 ++-- .../cvode/CXX_serial/cv_test_getjac.cpp | 10 ++--- .../cvode/CXX_serial/cv_test_kpr.hpp | 8 ++-- .../unit_tests/cvode/C_serial/cv_test_tstop.c | 7 ++-- test/unit_tests/cvode/gtest/CMakeLists.txt | 5 +++ .../cvodes/CXX_serial/cvs_test_getjac.cpp | 10 ++--- .../cvodes/CXX_serial/cvs_test_kpr.hpp | 8 ++-- .../cvodes/C_serial/cvs_test_tstop.c | 7 ++-- .../ida/CXX_serial/ida_test_getjac.cpp | 16 ++++---- .../ida/CXX_serial/ida_test_kpr.hpp | 8 ++-- test/unit_tests/ida/C_serial/ida_test_tstop.c | 10 ++--- .../idas/CXX_serial/idas_test_getjac.cpp | 16 ++++---- .../idas/CXX_serial/idas_test_kpr.hpp | 8 ++-- .../idas/C_serial/idas_test_tstop.c | 10 ++--- .../kinsol/CXX_serial/kin_test_getjac.cpp | 14 +++---- test/unit_tests/profiling/test_profiling.cpp | 4 +- .../reductions/test_reduction_operators.cpp | 12 +++--- .../sunmemory/sys/test_sunmemory_sys.cpp | 4 +- test/unit_tests/utilities/dumpstderr.hpp | 2 +- 71 files changed, 431 insertions(+), 360 deletions(-) diff --git a/benchmarks/advection_reaction_3D/kokkos/ParallelGrid.hpp b/benchmarks/advection_reaction_3D/kokkos/ParallelGrid.hpp index 2eed892ee5..7bbf8743a7 100644 --- a/benchmarks/advection_reaction_3D/kokkos/ParallelGrid.hpp +++ b/benchmarks/advection_reaction_3D/kokkos/ParallelGrid.hpp @@ -82,9 +82,9 @@ class ParallelGrid // [in] npxyz - the number of processors in each dimension; defaults to 0 which means MPI will choose // [in] reorder - should MPI_Cart_create do process reordering to optimize or not; defaults to false (some MPI implementations ignore this) ParallelGrid(MPI_Comm* comm, const sunrealtype a[], const sunrealtype b[], - const GLOBALINT npts[], int dof, BoundaryType bc, StencilType st, - const sunrealtype c, const int npxyz[] = nullptr, - bool reorder = false) + const GLOBALINT npts[], int dof_, BoundaryType bc_, + StencilType st_, const sunrealtype c, + const int npxyz[] = nullptr, bool reorder = false) : nx(1), ny(1), nz(1), @@ -103,12 +103,12 @@ class ParallelGrid bx(0.0), by(0.0), bz(0.0), - dof(dof), + dof(dof_), + upwindRight(true), dims{0, 0, 0}, coords{0, 0, 0}, - bc(bc), - st(st), - upwindRight(true) + bc(bc_), + st(st_) { assert(st == StencilType::UPWIND); @@ -121,6 +121,10 @@ class ParallelGrid } int retval, nprocs; +#ifdef NDEBUG + // Suppress unused variable warning + ((void)retval); +#endif MPI_Comm_size(*comm, &nprocs); retval = MPI_Dims_create(nprocs, 3, dims); assert(retval == MPI_SUCCESS); @@ -181,6 +185,12 @@ class ParallelGrid // For all faces: allocate upwind exchange buffers. void AllocateBuffersUpwind() { + int retval; +#ifdef NDEBUG + // Suppress unused variable warning + ((void)retval); +#endif + /* Allocate send/receive buffers and determine ID for communication West */ if (upwindRight) { @@ -196,7 +206,7 @@ class ParallelGrid if ((coords[0] > 0) || (bc == BoundaryType::PERIODIC)) { int nbcoords[] = {coords[0] - 1, coords[1], coords[2]}; - int retval = MPI_Cart_rank(cart_comm, nbcoords, &ipW); + retval = MPI_Cart_rank(cart_comm, nbcoords, &ipW); assert(retval == MPI_SUCCESS); } @@ -215,7 +225,7 @@ class ParallelGrid if ((coords[0] < dims[0] - 1) || (bc == BoundaryType::PERIODIC)) { int nbcoords[] = {coords[0] + 1, coords[1], coords[2]}; - int retval = MPI_Cart_rank(cart_comm, nbcoords, &ipE); + retval = MPI_Cart_rank(cart_comm, nbcoords, &ipE); assert(retval == MPI_SUCCESS); } @@ -234,7 +244,7 @@ class ParallelGrid if ((coords[1] > 0) || (bc == BoundaryType::PERIODIC)) { int nbcoords[] = {coords[0], coords[1] - 1, coords[2]}; - int retval = MPI_Cart_rank(cart_comm, nbcoords, &ipS); + retval = MPI_Cart_rank(cart_comm, nbcoords, &ipS); assert(retval == MPI_SUCCESS); } @@ -253,7 +263,7 @@ class ParallelGrid if ((coords[1] < dims[1] - 1) || (bc == BoundaryType::PERIODIC)) { int nbcoords[] = {coords[0], coords[1] + 1, coords[2]}; - int retval = MPI_Cart_rank(cart_comm, nbcoords, &ipN); + retval = MPI_Cart_rank(cart_comm, nbcoords, &ipN); assert(retval == MPI_SUCCESS); } @@ -272,7 +282,7 @@ class ParallelGrid if ((coords[2] > 0) || (bc == BoundaryType::PERIODIC)) { int nbcoords[] = {coords[0], coords[1], coords[2] - 1}; - int retval = MPI_Cart_rank(cart_comm, nbcoords, &ipB); + retval = MPI_Cart_rank(cart_comm, nbcoords, &ipB); assert(retval == MPI_SUCCESS); } @@ -291,7 +301,7 @@ class ParallelGrid if ((coords[2] < dims[2] - 1) || (bc == BoundaryType::PERIODIC)) { int nbcoords[] = {coords[0], coords[1], coords[2] + 1}; - int retval = MPI_Cart_rank(cart_comm, nbcoords, &ipF); + retval = MPI_Cart_rank(cart_comm, nbcoords, &ipF); assert(retval == MPI_SUCCESS); } } diff --git a/benchmarks/advection_reaction_3D/kokkos/advection_reaction_3D.cpp b/benchmarks/advection_reaction_3D/kokkos/advection_reaction_3D.cpp index 5f72a5b085..1bca75cbcc 100644 --- a/benchmarks/advection_reaction_3D/kokkos/advection_reaction_3D.cpp +++ b/benchmarks/advection_reaction_3D/kokkos/advection_reaction_3D.cpp @@ -107,7 +107,7 @@ int main(int argc, char* argv[]) if (udata.myid == 0 && uopt.nout > 0) { char fname[MXSTR]; - snprintf(fname, MXSTR, "%s/mesh.txt", uopt.outputdir); + snprintf(fname, MXSTR, "%s/mesh.txt", uopt.outputdir.c_str()); udata.grid->MeshToFile(fname); } @@ -259,7 +259,7 @@ int FillSendBuffers(N_Vector y, UserData* udata) * --------------------------------------------------------------*/ /* Parses the CLI arguments */ -int ParseArgs(int argc, char* argv[], UserData* udata, UserOptions* uopt) +static int ParseArgs(int argc, char* argv[], UserData* udata, UserOptions* uopt) { /* check for input args */ if (argc > 1) @@ -449,7 +449,7 @@ int SetupProblem(int argc, char* argv[], UserData* udata, UserOptions* uopt, uopt->fused = 0; /* use fused vector ops */ uopt->save = 1; /* save solution to disk */ uopt->nout = 10; /* number of output times */ - uopt->outputdir = (char*)"."; /* output directory */ + uopt->outputdir = "."; /* output directory */ /* Parse CLI args and set udata/uopt appropriately */ int retval = ParseArgs(argc, argv, udata, uopt); @@ -493,17 +493,17 @@ int SetupProblem(int argc, char* argv[], UserData* udata, UserOptions* uopt, char fname[MXSTR]; if (udata->myid == 0) { - sprintf(fname, "%s/t.%06d.txt", uopt->outputdir, udata->myid); + sprintf(fname, "%s/t.%06d.txt", uopt->outputdir.c_str(), udata->myid); udata->TFID = fopen(fname, "w"); } - sprintf(fname, "%s/u.%06d.txt", uopt->outputdir, udata->myid); + sprintf(fname, "%s/u.%06d.txt", uopt->outputdir.c_str(), udata->myid); udata->UFID = fopen(fname, "w"); - sprintf(fname, "%s/v.%06d.txt", uopt->outputdir, udata->myid); + sprintf(fname, "%s/v.%06d.txt", uopt->outputdir.c_str(), udata->myid); udata->VFID = fopen(fname, "w"); - sprintf(fname, "%s/w.%06d.txt", uopt->outputdir, udata->myid); + sprintf(fname, "%s/w.%06d.txt", uopt->outputdir.c_str(), udata->myid); udata->WFID = fopen(fname, "w"); } @@ -540,7 +540,7 @@ int SetupProblem(int argc, char* argv[], UserData* udata, UserOptions* uopt, printf(" reltol = %.1e\n", uopt->rtol); printf(" abstol = %.1e\n", uopt->atol); printf(" nout = %d\n", uopt->nout); - printf("Output directory: %s\n", uopt->outputdir); + printf("Output directory: %s\n", uopt->outputdir.c_str()); } /* return success */ @@ -549,7 +549,8 @@ int SetupProblem(int argc, char* argv[], UserData* udata, UserOptions* uopt, /* Compute the 3D Gaussian function. */ KOKKOS_FUNCTION -void Gaussian3D(sunrealtype& x, sunrealtype& y, sunrealtype& z, sunrealtype xmax) +static void Gaussian3D(sunrealtype& x, sunrealtype& y, sunrealtype& z, + sunrealtype xmax) { /* Gaussian distribution defaults */ const sunrealtype alpha = 0.1; @@ -567,7 +568,7 @@ void Gaussian3D(sunrealtype& x, sunrealtype& y, sunrealtype& z, sunrealtype xmax } /* Initial condition function */ -int SetIC(N_Vector y, UserData* udata) +int SetIC(N_Vector yvec, UserData* udata) { SUNDIALS_CXX_MARK_FUNCTION(udata->prof); @@ -596,8 +597,8 @@ int SetIC(N_Vector y, UserData* udata) const sunrealtype ws = 3.0; /* Create 4D view of y */ - Vec4D yview(N_VGetDeviceArrayPointer(N_VGetLocalVector_MPIPlusX(y)), nxl, nyl, - nzl, dof); + Vec4D yview(N_VGetDeviceArrayPointer(N_VGetLocalVector_MPIPlusX(yvec)), nxl, + nyl, nzl, dof); /* Gaussian perturbation of the steady state solution */ Kokkos::parallel_for( diff --git a/benchmarks/advection_reaction_3D/kokkos/advection_reaction_3D.hpp b/benchmarks/advection_reaction_3D/kokkos/advection_reaction_3D.hpp index fc4717fefe..ed594b0828 100644 --- a/benchmarks/advection_reaction_3D/kokkos/advection_reaction_3D.hpp +++ b/benchmarks/advection_reaction_3D/kokkos/advection_reaction_3D.hpp @@ -59,7 +59,7 @@ struct UserOptions int fused; /* use fused vector ops */ int nout; /* number of outputs */ int save; /* save solution to disk */ - char* outputdir; + string outputdir; }; /* @@ -113,16 +113,16 @@ struct UserData UserOptions* uopt; /* Constructor that takes the context */ - UserData(SUNContext ctx) - : ctx(ctx), - umask(nullptr), - vmask(nullptr), - wmask(nullptr), - uopt(nullptr), + UserData(SUNContext ctx_) + : ctx(ctx_), TFID(nullptr), UFID(nullptr), VFID(nullptr), - WFID(nullptr) + WFID(nullptr), + umask(nullptr), + vmask(nullptr), + wmask(nullptr), + uopt(nullptr) { SUNContext_GetProfiler(ctx, &prof); } diff --git a/benchmarks/advection_reaction_3D/kokkos/arkode_driver.cpp b/benchmarks/advection_reaction_3D/kokkos/arkode_driver.cpp index 49dcc6d8cf..2001c2736a 100644 --- a/benchmarks/advection_reaction_3D/kokkos/arkode_driver.cpp +++ b/benchmarks/advection_reaction_3D/kokkos/arkode_driver.cpp @@ -58,7 +58,6 @@ int EvolveProblemDIRK(N_Vector y, UserData* udata, UserOptions* uopt) long int nfe, nfi; /* RHS stats */ long int nni, ncnf; /* nonlinear solver stats */ long int nli, npsol; /* linear solver stats */ - char fname[MXSTR]; /* Additively split methods should not add the advection and reaction terms */ udata->add_reactions = true; @@ -246,7 +245,6 @@ int EvolveProblemIMEX(N_Vector y, UserData* udata, UserOptions* uopt) long int nfe, nfi; /* RHS stats */ long int nni, ncnf; /* nonlinear solver stats */ long int nli, npsol; /* linear solver stats */ - char fname[MXSTR]; /* Additively split methods should not add the advection and reaction terms */ udata->add_reactions = false; @@ -445,7 +443,6 @@ int EvolveProblemExplicit(N_Vector y, UserData* udata, UserOptions* uopt) int iout; /* output counter */ long int nst, nst_a, netf; /* step stats */ long int nfe; /* RHS stats */ - char fname[MXSTR]; /* Additively split methods should not add the advection and reaction terms */ udata->add_reactions = true; @@ -544,7 +541,7 @@ int EvolveProblemExplicit(N_Vector y, UserData* udata, UserOptions* uopt) * (Non)linear system functions * --------------------------------------------------------------*/ -int TaskLocalNlsResidual(N_Vector ycor, N_Vector F, void* arkode_mem) +static int TaskLocalNlsResidual(N_Vector ycor, N_Vector F, void* arkode_mem) { /* temporary variables */ UserData* udata; @@ -586,7 +583,7 @@ int TaskLocalNlsResidual(N_Vector ycor, N_Vector F, void* arkode_mem) return (0); } -int TaskLocalLSolve(N_Vector delta, void* arkode_mem) +static int TaskLocalLSolve(N_Vector delta, void* arkode_mem) { /* local variables */ UserData* udata = NULL; @@ -609,12 +606,12 @@ int TaskLocalLSolve(N_Vector delta, void* arkode_mem) return (retval); } -SUNNonlinearSolver_Type TaskLocalNewton_GetType(SUNNonlinearSolver NLS) +static SUNNonlinearSolver_Type TaskLocalNewton_GetType(SUNNonlinearSolver NLS) { return SUNNONLINEARSOLVER_ROOTFIND; } -int TaskLocalNewton_Initialize(SUNNonlinearSolver NLS) +static int TaskLocalNewton_Initialize(SUNNonlinearSolver NLS) { /* check that the nonlinear solver is non-null */ if (NLS == NULL) { return SUN_ERR_ARG_CORRUPT; } @@ -626,9 +623,9 @@ int TaskLocalNewton_Initialize(SUNNonlinearSolver NLS) return (SUNNonlinSolInitialize(LOCAL_NLS(NLS))); } -int TaskLocalNewton_Solve(SUNNonlinearSolver NLS, N_Vector y0, N_Vector ycor, - N_Vector w, sunrealtype tol, - sunbooleantype callLSetup, void* mem) +static int TaskLocalNewton_Solve(SUNNonlinearSolver NLS, N_Vector y0, + N_Vector ycor, N_Vector w, sunrealtype tol, + sunbooleantype callLSetup, void* mem) { /* local variables */ MPI_Comm comm; @@ -662,7 +659,7 @@ int TaskLocalNewton_Solve(SUNNonlinearSolver NLS, N_Vector y0, N_Vector ycor, return recover; } -int TaskLocalNewton_Free(SUNNonlinearSolver NLS) +static int TaskLocalNewton_Free(SUNNonlinearSolver NLS) { /* return if NLS is already free */ if (NLS == NULL) { return SUN_SUCCESS; } @@ -688,7 +685,8 @@ int TaskLocalNewton_Free(SUNNonlinearSolver NLS) return SUN_SUCCESS; } -int TaskLocalNewton_SetSysFn(SUNNonlinearSolver NLS, SUNNonlinSolSysFn SysFn) +static int TaskLocalNewton_SetSysFn(SUNNonlinearSolver NLS, + SUNNonlinSolSysFn SysFn) { /* check that the nonlinear solver is non-null */ if (NLS == NULL) { return SUN_ERR_ARG_CORRUPT; } @@ -696,9 +694,9 @@ int TaskLocalNewton_SetSysFn(SUNNonlinearSolver NLS, SUNNonlinSolSysFn SysFn) return (SUNNonlinSolSetSysFn(LOCAL_NLS(NLS), SysFn)); } -int TaskLocalNewton_SetConvTestFn(SUNNonlinearSolver NLS, - SUNNonlinSolConvTestFn CTestFn, - void* ctest_data) +static int TaskLocalNewton_SetConvTestFn(SUNNonlinearSolver NLS, + SUNNonlinSolConvTestFn CTestFn, + void* ctest_data) { /* check that the nonlinear solver is non-null */ if (NLS == NULL) { return SUN_ERR_ARG_CORRUPT; } @@ -706,7 +704,8 @@ int TaskLocalNewton_SetConvTestFn(SUNNonlinearSolver NLS, return (SUNNonlinSolSetConvTestFn(LOCAL_NLS(NLS), CTestFn, ctest_data)); } -int TaskLocalNewton_GetNumConvFails(SUNNonlinearSolver NLS, long int* nconvfails) +static int TaskLocalNewton_GetNumConvFails(SUNNonlinearSolver NLS, + long int* nconvfails) { /* check that the nonlinear solver is non-null */ if (NLS == NULL) { return SUN_ERR_ARG_CORRUPT; } diff --git a/benchmarks/advection_reaction_3D/kokkos/ida_driver.cpp b/benchmarks/advection_reaction_3D/kokkos/ida_driver.cpp index b85c7a3fb6..d029f8c34e 100644 --- a/benchmarks/advection_reaction_3D/kokkos/ida_driver.cpp +++ b/benchmarks/advection_reaction_3D/kokkos/ida_driver.cpp @@ -20,7 +20,7 @@ #include "sunnonlinsol/sunnonlinsol_newton.h" /* Initial condition function */ -int SetICDot(N_Vector y, N_Vector yp, UserData* udata) +static int SetICDot(N_Vector y, N_Vector yp, UserData* udata) { int retval; diff --git a/benchmarks/diffusion_2D/diffusion_2D.cpp b/benchmarks/diffusion_2D/diffusion_2D.cpp index e5d3ece986..bd18cf1dfb 100644 --- a/benchmarks/diffusion_2D/diffusion_2D.cpp +++ b/benchmarks/diffusion_2D/diffusion_2D.cpp @@ -775,8 +775,8 @@ int UserOutput::open(UserData* udata) int UserOutput::write(sunrealtype t, N_Vector u, UserData* udata) { int flag; - sunrealtype max; - bool outproc = (udata->myid_c == 0); + sunrealtype max = ZERO; + bool outproc = (udata->myid_c == 0); if (output > 0) { @@ -900,7 +900,7 @@ int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData* udata) } // Check function return value -int check_flag(void* flagvalue, const string funcname, int opt) +int check_flag(const void* flagvalue, const string funcname, int opt) { // Check if the function returned a NULL pointer if (opt == 0) @@ -916,7 +916,7 @@ int check_flag(void* flagvalue, const string funcname, int opt) // Check the function return flag value else if (opt == 1 || opt == 2) { - int errflag = *((int*)flagvalue); + const int errflag = *((const int*)flagvalue); if ((opt == 1 && errflag < 0) || (opt == 2 && errflag != 0)) { cerr << endl diff --git a/benchmarks/diffusion_2D/diffusion_2D.hpp b/benchmarks/diffusion_2D/diffusion_2D.hpp index 11e0b350e8..1ebb3394aa 100644 --- a/benchmarks/diffusion_2D/diffusion_2D.hpp +++ b/benchmarks/diffusion_2D/diffusion_2D.hpp @@ -168,7 +168,7 @@ struct UserData // Inverse of Jacobian diagonal for preconditioner N_Vector diag = NULL; - UserData(SUNProfiler prof) : prof(prof) {} + UserData(SUNProfiler prof_) : prof(prof_) {} ~UserData(); @@ -280,6 +280,6 @@ int SolutionDerivative(sunrealtype t, N_Vector up, UserData* udata); int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData* udata); // Check function return values -int check_flag(void* flagvalue, const string funcname, int opt); +int check_flag(const void* flagvalue, const string funcname, int opt); #endif diff --git a/benchmarks/diffusion_2D/mpi_serial/buffers.cpp b/benchmarks/diffusion_2D/mpi_serial/buffers.cpp index 13a35dbffb..a5448b8939 100644 --- a/benchmarks/diffusion_2D/mpi_serial/buffers.cpp +++ b/benchmarks/diffusion_2D/mpi_serial/buffers.cpp @@ -21,7 +21,7 @@ int UserData::pack_buffers(const N_Vector u) { // Access data array const sunrealtype* uarray = N_VGetArrayPointer(u); - if (check_flag((void*)uarray, "N_VGetArrayPointer", 0)) return -1; + if (check_flag(uarray, "N_VGetArrayPointer", 0)) return -1; if (HaveNbrW) for (sunindextype i = 0; i < ny_loc; i++) diff --git a/benchmarks/diffusion_2D/mpi_serial/diffusion.cpp b/benchmarks/diffusion_2D/mpi_serial/diffusion.cpp index 9be04d0cde..277267993b 100644 --- a/benchmarks/diffusion_2D/mpi_serial/diffusion.cpp +++ b/benchmarks/diffusion_2D/mpi_serial/diffusion.cpp @@ -207,8 +207,8 @@ int laplacian(sunrealtype t, N_Vector u, N_Vector f, UserData* udata) // j -- local y index // x -- x processor coordinate // y -- y processor coordinate -sunindextype global_index(sunindextype i, sunindextype j, int x, int y, - UserData* udata) +static sunindextype global_index(sunindextype i, sunindextype j, int x, int y, + UserData* udata) { SUNDIALS_CXX_MARK_FUNCTION(udata->prof); @@ -253,12 +253,13 @@ sunindextype global_index(sunindextype i, sunindextype j, int x, int y, // x -- x processor coordinate // y -- y processor coordinate #if defined(BENCHMARK_ODE) -int matrix_row(sunindextype i, sunindextype j, int x, int y, UserData* udata, - sunrealtype* vals, sunindextype* col_idx, sunindextype* row_nnz) +static int matrix_row(sunindextype i, sunindextype j, int x, int y, + UserData* udata, sunrealtype* vals, sunindextype* col_idx, + sunindextype* row_nnz) #else -int matrix_row(sunindextype i, sunindextype j, int x, int y, UserData* udata, - sunrealtype cj, sunrealtype* vals, sunindextype* col_idx, - sunindextype* row_nnz) +static int matrix_row(sunindextype i, sunindextype j, int x, int y, + UserData* udata, sunrealtype cj, sunrealtype* vals, + sunindextype* col_idx, sunindextype* row_nnz) #endif { SUNDIALS_CXX_MARK_FUNCTION(udata->prof); diff --git a/benchmarks/nvector/test_nvector_performance.c b/benchmarks/nvector/test_nvector_performance.c index d522349e3f..36224a9c38 100644 --- a/benchmarks/nvector/test_nvector_performance.c +++ b/benchmarks/nvector/test_nvector_performance.c @@ -2826,23 +2826,23 @@ static double get_time(void) /* ---------------------------------------------------------------------- * compute average, standard deviation, max, and min * --------------------------------------------------------------------*/ -static void time_stats(N_Vector X, double* times, int nwarmups, int ntests, +static void time_stats(N_Vector X, double* times, int num_warmups, int ntests, double* avg, double* sdev, double* min, double* max) { int i, ntotal; /* total number of times collected */ - ntotal = nwarmups + ntests; + ntotal = num_warmups + ntests; /* if running in parallel collect data from all processes */ collect_times(X, times, ntotal); /* compute timing stats */ *avg = 0.0; - *min = times[nwarmups]; - *max = times[nwarmups]; + *min = times[num_warmups]; + *max = times[num_warmups]; - for (i = nwarmups; i < ntotal; i++) + for (i = num_warmups; i < ntotal; i++) { *avg += times[i]; if (times[i] < *min) { *min = times[i]; } @@ -2853,7 +2853,7 @@ static void time_stats(N_Vector X, double* times, int nwarmups, int ntests, *sdev = 0.0; if (ntests > 1) { - for (i = nwarmups; i < ntotal; i++) + for (i = num_warmups; i < ntotal; i++) { *sdev += (times[i] - *avg) * (times[i] - *avg); } diff --git a/cmake/SundialsSetupCompilers.cmake b/cmake/SundialsSetupCompilers.cmake index 36f10b44c1..065f39e1b2 100644 --- a/cmake/SundialsSetupCompilers.cmake +++ b/cmake/SundialsSetupCompilers.cmake @@ -76,8 +76,25 @@ endif() if(ENABLE_ALL_WARNINGS) message(STATUS "Enabling all compiler warnings") - set(CMAKE_C_FLAGS "-Wall -Wpedantic -Wextra -Wno-unused-parameter -Wno-deprecated-declarations -Wno-unused-function ${CMAKE_C_FLAGS}") - set(CMAKE_CXX_FLAGS "-Wall -Wpedantic -Wextra -Wno-unused-parameter -Wno-deprecated-declarations -Wno-unused-function ${CMAKE_CXX_FLAGS}") + # Avoid numerous warnings from printf + if(SUNDIALS_PRECISION MATCHES "EXTENDED") + set(CMAKE_C_FLAGS "-Wdouble-promotion ${CMAKE_C_FLAGS}") + set(CMAKE_CXX_FLAGS "-Wdouble-promotion ${CMAKE_CXX_FLAGS}") + endif() + + if((SUNDIALS_PRECISION MATCHES "DOUBLE") AND (SUNDIALS_INDEX_SIZE MATCHES "32")) + set(CMAKE_C_FLAGS "-Wconversion -Wno-sign-conversion ${CMAKE_C_FLAGS}") + set(CMAKE_CXX_FLAGS "-Wconversion -Wno-sign-conversion ${CMAKE_CXX_FLAGS}") + endif() + + # Avoid numerous warnings from SWIG generated functions + if(NOT BUILD_FORTRAN_MODULE_INTERFACE) + set(CMAKE_C_FLAGS "-Wmissing-declarations -Wcast-qual ${CMAKE_C_FLAGS}") + set(CMAKE_CXX_FLAGS "-Wmissing-declarations -Wcast-qual ${CMAKE_CXX_FLAGS}") + endif() + + set(CMAKE_C_FLAGS "-Wall -Wpedantic -Wextra -Wshadow -Wno-unused-parameter -Wno-unused-function ${CMAKE_C_FLAGS}") + set(CMAKE_CXX_FLAGS "-Wall -Wpedantic -Wextra -Wshadow -Wno-unused-parameter -Wno-unused-function ${CMAKE_CXX_FLAGS}") set(CMAKE_Fortran_FLAGS "-Wall -Wpedantic -Wno-unused-dummy-argument -Wno-c-binding-type -ffpe-summary=none ${CMAKE_Fortran_FLAGS}") endif() diff --git a/examples/arkode/CXX_parallel/ark_heat2D_p.cpp b/examples/arkode/CXX_parallel/ark_heat2D_p.cpp index 78a25fa210..566a7a4b41 100644 --- a/examples/arkode/CXX_parallel/ark_heat2D_p.cpp +++ b/examples/arkode/CXX_parallel/ark_heat2D_p.cpp @@ -1720,8 +1720,8 @@ static int OpenOutput(UserData* udata) static int WriteOutput(sunrealtype t, N_Vector u, UserData* udata) { int flag; - sunrealtype max; - bool outproc = (udata->myid_c == 0); + sunrealtype max = ZERO; + bool outproc = (udata->myid_c == 0); if (udata->output > 0) { diff --git a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_ls.cpp b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_ls.cpp index 09e95bc328..d5cb124652 100644 --- a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_ls.cpp +++ b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_ls.cpp @@ -470,31 +470,9 @@ int main(int argc, char* argv[]) flag = ARKodeSetEpsLin(arkode_mem, udata->epslin); if (check_flag(&flag, "ARKodeSetEpsLin", 1)) { return 1; } - // Select method order - if (udata->order > 1) - { - // Use an ARKode provided table - flag = ARKodeSetOrder(arkode_mem, udata->order); - if (check_flag(&flag, "ARKodeSetOrder", 1)) { return 1; } - } - else - { - // Use implicit Euler (requires fixed step size) - sunrealtype c[1], A[1], b[1]; - ARKodeButcherTable B = NULL; - - // Create implicit Euler Butcher table - c[0] = A[0] = b[0] = ONE; - B = ARKodeButcherTable_Create(1, 1, 0, c, A, b, NULL); - if (check_flag((void*)B, "ARKodeButcherTable_Create", 0)) { return 1; } - - // Attach the Butcher table - flag = ARKStepSetTables(arkode_mem, 1, 0, B, NULL); - if (check_flag(&flag, "ARKStepSetTables", 1)) { return 1; } - - // Free the Butcher table - ARKodeButcherTable_Free(B); - } + // Use an ARKode provided table + flag = ARKodeSetOrder(arkode_mem, udata->order); + if (check_flag(&flag, "ARKodeSetOrder", 1)) { return 1; } // Set fixed step size or adaptivity method if (udata->hfixed > ZERO) @@ -2020,8 +1998,8 @@ static int OpenOutput(UserData* udata) static int WriteOutput(sunrealtype t, N_Vector u, UserData* udata) { int flag; - sunrealtype max; - bool outproc = (udata->myid_c == 0); + sunrealtype max = ZERO; + bool outproc = (udata->myid_c == 0); if (udata->output > 0) { diff --git a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg.cpp b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg.cpp index bb541e41d6..2582758ef7 100644 --- a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg.cpp +++ b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg.cpp @@ -2534,8 +2534,8 @@ static int OpenOutput(UserData* udata) static int WriteOutput(sunrealtype t, N_Vector u, UserData* udata) { int flag; - sunrealtype max; - bool outproc = (udata->myid_c == 0); + sunrealtype max = ZERO; + bool outproc = (udata->myid_c == 0); if (udata->output > 0) { diff --git a/examples/arkode/CXX_serial/ark_advection_diffusion_reaction.hpp b/examples/arkode/CXX_serial/ark_advection_diffusion_reaction.hpp index 6d0bc8a09d..bdf4102903 100644 --- a/examples/arkode/CXX_serial/ark_advection_diffusion_reaction.hpp +++ b/examples/arkode/CXX_serial/ark_advection_diffusion_reaction.hpp @@ -266,7 +266,7 @@ int SetIC(N_Vector y, UserData& udata); // ----------------------------------------------------------------------------- // Check function return flag -int check_flag(int flag, const string funcname) +static int check_flag(int flag, const string funcname) { if (flag < 0) { @@ -277,7 +277,7 @@ int check_flag(int flag, const string funcname) } // Check if a function returned a NULL pointer -int check_ptr(void* ptr, const string funcname) +static int check_ptr(void* ptr, const string funcname) { if (ptr) { return 0; } cerr << "ERROR: " << funcname << " returned NULL" << endl; @@ -285,7 +285,7 @@ int check_ptr(void* ptr, const string funcname) } // Print ERK integrator statistics -int OutputStatsERK(void* arkode_mem, UserData& udata) +static int OutputStatsERK(void* arkode_mem, UserData& udata) { int flag; @@ -309,7 +309,7 @@ int OutputStatsERK(void* arkode_mem, UserData& udata) } // Print ARK integrator statistics -int OutputStatsARK(void* arkode_mem, UserData& udata) +static int OutputStatsARK(void* arkode_mem, UserData& udata) { int flag; @@ -362,8 +362,8 @@ int OutputStatsARK(void* arkode_mem, UserData& udata) } // Print MRI integrator statistics -int OutputStatsMRIARK(void* arkode_mem, MRIStepInnerStepper fast_mem, - UserData& udata) +static int OutputStatsMRIARK(void* arkode_mem, MRIStepInnerStepper fast_mem, + UserData& udata) { int flag; @@ -461,7 +461,7 @@ int OutputStatsMRIARK(void* arkode_mem, MRIStepInnerStepper fast_mem, } // Save current stats -int UpdateCVodeStats(CVodeInnerStepperContent* content) +static int UpdateCVodeStats(CVodeInnerStepperContent* content) { int flag; long int nst, netf, nfe, nni, nncf, nsetups, nje; @@ -498,8 +498,8 @@ int UpdateCVodeStats(CVodeInnerStepperContent* content) } // Print MRI integrator statistics -int OutputStatsMRICVODE(void* arkode_mem, MRIStepInnerStepper fast_mem, - UserData& udata) +static int OutputStatsMRICVODE(void* arkode_mem, MRIStepInnerStepper fast_mem, + UserData& udata) { int flag; @@ -570,7 +570,7 @@ int OutputStatsMRICVODE(void* arkode_mem, MRIStepInnerStepper fast_mem, } // Print command line options -void InputHelp() +static void InputHelp() { cout << endl; cout << "Command line options:" << endl; @@ -662,8 +662,8 @@ inline void find_arg(vector& args, const string key, bool& dest, } } -int ReadInputs(vector& args, UserData& udata, UserOptions& uopts, - SUNContext ctx) +static int ReadInputs(vector& args, UserData& udata, UserOptions& uopts, + SUNContext ctx) { if (find(args.begin(), args.end(), "--help") != args.end()) { @@ -785,7 +785,7 @@ int ReadInputs(vector& args, UserData& udata, UserOptions& uopts, } // Print user data -int PrintSetup(UserData& udata, UserOptions& uopts) +static int PrintSetup(UserData& udata, UserOptions& uopts) { cout << endl; cout << "Problem parameters and options:" << endl; @@ -1147,7 +1147,7 @@ int PrintSetup(UserData& udata, UserOptions& uopts) } // Initialize output -int OpenOutput(UserData& udata, UserOptions& uopts) +static int OpenOutput(UserData& udata, UserOptions& uopts) { // Header for status output if (uopts.output) @@ -1183,7 +1183,8 @@ int OpenOutput(UserData& udata, UserOptions& uopts) } // Write output -int WriteOutput(sunrealtype t, N_Vector y, UserData& udata, UserOptions& uopts) +static int WriteOutput(sunrealtype t, N_Vector y, UserData& udata, + UserOptions& uopts) { if (uopts.output) { @@ -1212,7 +1213,7 @@ int WriteOutput(sunrealtype t, N_Vector y, UserData& udata, UserOptions& uopts) } // Finalize output -int CloseOutput(UserOptions& uopts) +static int CloseOutput(UserOptions& uopts) { // Footer for status output if (uopts.output) diff --git a/examples/cvode/CXX_parallel/cv_heat2D_p.cpp b/examples/cvode/CXX_parallel/cv_heat2D_p.cpp index 068d59993d..aabfef2e64 100644 --- a/examples/cvode/CXX_parallel/cv_heat2D_p.cpp +++ b/examples/cvode/CXX_parallel/cv_heat2D_p.cpp @@ -1620,8 +1620,8 @@ static int OpenOutput(UserData* udata) static int WriteOutput(sunrealtype t, N_Vector u, UserData* udata) { int flag; - sunrealtype max; - bool outproc = (udata->myid_c == 0); + sunrealtype max = ZERO; + bool outproc = (udata->myid_c == 0); if (udata->output > 0) { diff --git a/examples/cvode/CXX_parhyp/cv_heat2D_hypre_ls.cpp b/examples/cvode/CXX_parhyp/cv_heat2D_hypre_ls.cpp index 77af0d8b03..c213aeaca2 100644 --- a/examples/cvode/CXX_parhyp/cv_heat2D_hypre_ls.cpp +++ b/examples/cvode/CXX_parhyp/cv_heat2D_hypre_ls.cpp @@ -1498,7 +1498,7 @@ static int WaitRecv(UserData* udata) // ----------------------------------------------------------------------------- // Initialize memory allocated within Userdata -UserData::UserData(sundials::Context& sunctx) : sunctx(sunctx) +UserData::UserData(sundials::Context& ctx) : sunctx(ctx) { // Diffusion coefficient kx = ONE; @@ -1932,8 +1932,8 @@ static int OpenOutput(UserData* udata) static int WriteOutput(sunrealtype t, N_Vector u, UserData* udata) { int flag; - sunrealtype max; - bool outproc = (udata->myid_c == 0); + sunrealtype max = ZERO; + bool outproc = (udata->myid_c == 0); if (udata->output > 0) { diff --git a/examples/cvode/CXX_parhyp/cv_heat2D_hypre_pfmg.cpp b/examples/cvode/CXX_parhyp/cv_heat2D_hypre_pfmg.cpp index 762d36e973..5d74df7818 100644 --- a/examples/cvode/CXX_parhyp/cv_heat2D_hypre_pfmg.cpp +++ b/examples/cvode/CXX_parhyp/cv_heat2D_hypre_pfmg.cpp @@ -1970,7 +1970,7 @@ static int WaitRecv(UserData* udata) // ----------------------------------------------------------------------------- // Initialize memory allocated within Userdata -UserData::UserData(sundials::Context& sunctx) : sunctx(sunctx) +UserData::UserData(sundials::Context& ctx) : sunctx(ctx) { // Diffusion coefficient kx = ONE; @@ -2446,8 +2446,8 @@ static int OpenOutput(UserData* udata) static int WriteOutput(sunrealtype t, N_Vector u, UserData* udata) { int flag; - sunrealtype max; - bool outproc = (udata->myid_c == 0); + sunrealtype max = ZERO; + bool outproc = (udata->myid_c == 0); if (udata->output > 0) { diff --git a/examples/cvode/CXX_serial/cv_heat2D.hpp b/examples/cvode/CXX_serial/cv_heat2D.hpp index 0488247e7c..35bfa1ef84 100644 --- a/examples/cvode/CXX_serial/cv_heat2D.hpp +++ b/examples/cvode/CXX_serial/cv_heat2D.hpp @@ -107,7 +107,7 @@ UserData::~UserData() // ----------------------------------------------------------------------------- // Compute the exact solution -int Solution(sunrealtype t, N_Vector u, UserData& udata) +static int Solution(sunrealtype t, N_Vector u, UserData& udata) { auto uarray = N_VGetArrayPointer(u); if (check_ptr(uarray, "N_VGetArrayPointer")) { return -1; } @@ -137,7 +137,7 @@ int Solution(sunrealtype t, N_Vector u, UserData& udata) } // Compute the solution error -int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData& udata) +static int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData& udata) { // Compute true solution auto flag = Solution(t, e, udata); @@ -151,7 +151,7 @@ int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData& udata) } // Print command line options -void InputHelp() +static void InputHelp() { std::cout << std::endl << "Command line options:\n" @@ -176,7 +176,7 @@ void InputHelp() } // Read command line inputs -int ReadInputs(std::vector& args, UserData& udata) +static int ReadInputs(std::vector& args, UserData& udata) { if (find(args.begin(), args.end(), "--help") != args.end()) { @@ -212,7 +212,7 @@ int ReadInputs(std::vector& args, UserData& udata) } // Print user data -void PrintUserData(UserData& udata) +static void PrintUserData(UserData& udata) { std::cout << std::endl << "2D Heat problem:\n" @@ -243,7 +243,7 @@ void PrintUserData(UserData& udata) } // Initialize output -int OpenOutput(UserData& udata) +static int OpenOutput(UserData& udata) { // Header for status output std::cout << std::scientific @@ -280,7 +280,7 @@ int OpenOutput(UserData& udata) } // Write output -int WriteOutput(sunrealtype t, N_Vector u, N_Vector e, UserData& udata) +static int WriteOutput(sunrealtype t, N_Vector u, N_Vector e, UserData& udata) { // Compute the error auto flag = SolutionError(t, u, e, udata); @@ -325,7 +325,7 @@ int WriteOutput(sunrealtype t, N_Vector u, N_Vector e, UserData& udata) } // Finalize output -int CloseOutput(UserData& udata) +static int CloseOutput(UserData& udata) { // Footer for status output std::cout << " ----------------------------------------------" diff --git a/examples/cvode/CXX_serial/cv_kpr.hpp b/examples/cvode/CXX_serial/cv_kpr.hpp index aa258668d7..5d4d0e10b4 100644 --- a/examples/cvode/CXX_serial/cv_kpr.hpp +++ b/examples/cvode/CXX_serial/cv_kpr.hpp @@ -86,7 +86,7 @@ inline int true_sol(sunrealtype t, sunrealtype* u, sunrealtype* v) // ----------------------------------------------------------------------------- // Print command line options -void InputHelp() +static void InputHelp() { std::cout << std::endl; std::cout << "Command line options:" << std::endl; @@ -98,7 +98,8 @@ void InputHelp() std::cout << " --nout : number of outputs\n"; } -int ReadInputs(std::vector& args, Options& opts, SUNContext ctx) +static int ReadInputs(std::vector& args, Options& opts, + SUNContext ctx) { if (find(args.begin(), args.end(), "--help") != args.end()) { diff --git a/examples/cvode/ginkgo/cv_heat2D_ginkgo.hpp b/examples/cvode/ginkgo/cv_heat2D_ginkgo.hpp index f64ec2c1b7..a2d170a3cd 100644 --- a/examples/cvode/ginkgo/cv_heat2D_ginkgo.hpp +++ b/examples/cvode/ginkgo/cv_heat2D_ginkgo.hpp @@ -124,7 +124,7 @@ __global__ void solution_kernel(const sunindextype nx, const sunindextype ny, #endif // Compute the exact solution -int Solution(sunrealtype t, N_Vector u, UserData& udata) +static int Solution(sunrealtype t, N_Vector u, UserData& udata) { // Access problem data and set shortcuts const auto nx = udata.nx; @@ -206,7 +206,7 @@ int Solution(sunrealtype t, N_Vector u, UserData& udata) } // Compute the solution error -int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData& udata) +static int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData& udata) { // Compute true solution int flag = Solution(t, e, udata); @@ -220,7 +220,7 @@ int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData& udata) } // Print command line options -void InputHelp() +static void InputHelp() { std::cout << std::endl << "Command line options:\n" @@ -243,7 +243,7 @@ void InputHelp() } // Read command line inputs -int ReadInputs(std::vector& args, UserData& udata) +static int ReadInputs(std::vector& args, UserData& udata) { if (find(args.begin(), args.end(), "--help") != args.end()) { @@ -276,7 +276,7 @@ int ReadInputs(std::vector& args, UserData& udata) } // Print user data -void PrintUserData(UserData& udata) +static void PrintUserData(UserData& udata) { std::cout << std::endl << "2D Heat problem:\n" @@ -303,7 +303,7 @@ void PrintUserData(UserData& udata) } // Initialize output -int OpenOutput(UserData& udata) +static int OpenOutput(UserData& udata) { // Header for status output std::cout << std::scientific @@ -340,7 +340,7 @@ int OpenOutput(UserData& udata) } // Write output -int WriteOutput(sunrealtype t, N_Vector u, N_Vector e, UserData& udata) +static int WriteOutput(sunrealtype t, N_Vector u, N_Vector e, UserData& udata) { // Compute the error int flag = SolutionError(t, u, e, udata); @@ -398,7 +398,7 @@ int WriteOutput(sunrealtype t, N_Vector u, N_Vector e, UserData& udata) } // Finalize output -int CloseOutput(UserData& udata) +static int CloseOutput(UserData& udata) { // Footer for status output std::cout << " ----------------------------------------------" diff --git a/examples/cvode/ginkgo/cv_kpr_ginkgo.hpp b/examples/cvode/ginkgo/cv_kpr_ginkgo.hpp index 557b544885..6186d73f95 100644 --- a/examples/cvode/ginkgo/cv_kpr_ginkgo.hpp +++ b/examples/cvode/ginkgo/cv_kpr_ginkgo.hpp @@ -83,7 +83,7 @@ inline int true_sol(sunrealtype t, sunrealtype* u, sunrealtype* v) // ----------------------------------------------------------------------------- // Print command line options -void InputHelp() +static void InputHelp() { std::cout << std::endl; std::cout << "Command line options:" << std::endl; @@ -94,7 +94,7 @@ void InputHelp() std::cout << " --nout : number of outputs\n"; } -int ReadInputs(std::vector& args, Options& opts) +static int ReadInputs(std::vector& args, Options& opts) { if (find(args.begin(), args.end(), "--help") != args.end()) { diff --git a/examples/cvode/petsc/cv_petsc_ex7.c b/examples/cvode/petsc/cv_petsc_ex7.c index f2a72da5c3..3e9d0b6acb 100644 --- a/examples/cvode/petsc/cv_petsc_ex7.c +++ b/examples/cvode/petsc/cv_petsc_ex7.c @@ -396,7 +396,7 @@ PetscErrorCode MyCVodeMonitor(long int step, PetscReal ptime, Vec v, void* ctx) PetscFunctionBeginUser; ierr = VecNorm(v, NORM_2, &norm); CHKERRQ(ierr); - ierr = PetscPrintf(PETSC_COMM_WORLD, "timestep %D time %g norm %g\n", step, + ierr = PetscPrintf(PETSC_COMM_WORLD, "timestep %ld time %g norm %g\n", step, (double)ptime, (double)norm); CHKERRQ(ierr); PetscFunctionReturn(0); diff --git a/examples/ida/trilinos/idaHeat2D_kry_tpetra.cpp b/examples/ida/trilinos/idaHeat2D_kry_tpetra.cpp index 2b67775408..d3f5cbf27b 100644 --- a/examples/ida/trilinos/idaHeat2D_kry_tpetra.cpp +++ b/examples/ida/trilinos/idaHeat2D_kry_tpetra.cpp @@ -493,7 +493,7 @@ int PsolveHeat(sunrealtype tt, N_Vector uu, N_Vector up, N_Vector rr, static int SetInitialProfile(UserData* data, N_Vector uu, N_Vector up, N_Vector res) { - sunindextype mm, mm1, i, j; + sunindextype mm, mm1; sunrealtype xfact, yfact; mm = data->mm; @@ -513,10 +513,10 @@ static int SetInitialProfile(UserData* data, N_Vector uu, N_Vector up, #endif /* Initialize uu on all grid points. */ - for (j = 0; j < mm; j++) + for (sunindextype j = 0; j < mm; j++) { yfact = data->dx * j; - for (i = 0; i < mm; i++) + for (sunindextype i = 0; i < mm; i++) { xfact = data->dx * i; u_1d(mm * j + i) = SUN_RCONST(16.0) * xfact * (ONE - xfact) * yfact * diff --git a/examples/kinsol/CXX_parallel/kin_heat2D_nonlin_p.hpp b/examples/kinsol/CXX_parallel/kin_heat2D_nonlin_p.hpp index cdd0c6b72c..35de74bfff 100644 --- a/examples/kinsol/CXX_parallel/kin_heat2D_nonlin_p.hpp +++ b/examples/kinsol/CXX_parallel/kin_heat2D_nonlin_p.hpp @@ -236,62 +236,68 @@ static int check_retval(void* flagvalue, const string funcname, int opt); // ----------------------------------------------------------------------------- // c(u) = u -sunrealtype c1(sunrealtype u_val) { return u_val; } +static sunrealtype c1(sunrealtype u_val) { return u_val; } // c(u) = u^3 - u -sunrealtype c2(sunrealtype u_val) { return u_val * u_val * u_val - u_val; } +static sunrealtype c2(sunrealtype u_val) +{ + return u_val * u_val * u_val - u_val; +} // c(u) = u - u^2 -sunrealtype c3(sunrealtype u_val) { return u_val - u_val * u_val; } +static sunrealtype c3(sunrealtype u_val) { return u_val - u_val * u_val; } // c(u) = e^u -sunrealtype c4(sunrealtype u_val) { return exp(u_val); } +static sunrealtype c4(sunrealtype u_val) { return exp(u_val); } // c(u) = u^4 -sunrealtype c5(sunrealtype u_val) { return u_val * u_val * u_val * u_val; } +static sunrealtype c5(sunrealtype u_val) +{ + return u_val * u_val * u_val * u_val; +} // c(u) = cos^2(u) - sin^2(u) -sunrealtype c6(sunrealtype u_val) +static sunrealtype c6(sunrealtype u_val) { return (cos(u_val) * cos(u_val)) - (sin(u_val) * sin(u_val)); } // c(u) = cos^2(u) - sin^2(u) - e^u -sunrealtype c7(sunrealtype u_val) +static sunrealtype c7(sunrealtype u_val) { return (cos(u_val) * cos(u_val)) - (sin(u_val) * sin(u_val)) - exp(u_val); } // c(u) = e^u * u^4 - u * e^{cos(u)} -sunrealtype c8(sunrealtype u_val) +static sunrealtype c8(sunrealtype u_val) { sunrealtype u2 = u_val * u_val; return exp(u_val) * u2 * u2 - u_val * exp(cos(u_val)); } // c(u) = e^(cos^2(u)) -sunrealtype c9(sunrealtype u_val) +static sunrealtype c9(sunrealtype u_val) { sunrealtype cos2u = cos(u_val) * cos(u_val); return exp(cos2u); } // c(u) = 10(u - u^2) -sunrealtype c10(sunrealtype u_val) +static sunrealtype c10(sunrealtype u_val) { sunrealtype u2 = u_val * u_val; return 10.0 * (u_val - u2); } // c(u) = -13 + u + ((5-u)u - 2)u -sunrealtype c11(sunrealtype u_val) +static sunrealtype c11(sunrealtype u_val) { sunrealtype temp = ((5.0 - u_val) * u_val) - 2.0; return -13.0 + u_val + temp * u_val; } // c(u) = sqrt(5) * (u - u^2) -sunrealtype c12(sunrealtype u_val) +static sunrealtype c12(sunrealtype u_val) { sunrealtype temp = sqrt(5); sunrealtype u2 = u_val * u_val; @@ -299,7 +305,7 @@ sunrealtype c12(sunrealtype u_val) } // c(u) = (u - e^u)^2 + (u + u * sin(u) - cos(u))^2 -sunrealtype c13(sunrealtype u_val) +static sunrealtype c13(sunrealtype u_val) { sunrealtype eu = u_val - exp(u_val); sunrealtype usin = u_val * sin(u_val); @@ -308,7 +314,7 @@ sunrealtype c13(sunrealtype u_val) } // c(u) = u + ue^u + ue^{-u} -sunrealtype c14(sunrealtype u_val) +static sunrealtype c14(sunrealtype u_val) { sunrealtype ueu = u_val * exp(u_val); sunrealtype ue_u = u_val * exp(-u_val); @@ -316,7 +322,7 @@ sunrealtype c14(sunrealtype u_val) } // c(u) = u + ue^u + ue^{-u} + (u - e^u)^2 -sunrealtype c15(sunrealtype u_val) +static sunrealtype c15(sunrealtype u_val) { sunrealtype ueu = u_val * exp(u_val); sunrealtype ue_u = u_val * exp(-u_val); @@ -325,7 +331,7 @@ sunrealtype c15(sunrealtype u_val) } // c(u) = u + ue^u + ue^{-u} + (u - e^u)^2 + (u + usin(u) - cos(u))^2 -sunrealtype c16(sunrealtype u_val) +static sunrealtype c16(sunrealtype u_val) { sunrealtype ueu = u_val * exp(u_val); sunrealtype ue_u = u_val * exp(-u_val); @@ -335,7 +341,7 @@ sunrealtype c16(sunrealtype u_val) } // c(u) = u + ue^{-u} + e^u*(u + sin(u) - cos(u))^3 -sunrealtype c17(sunrealtype u_val) +static sunrealtype c17(sunrealtype u_val) { sunrealtype ue_u = u_val * exp(-u_val); sunrealtype eu = exp(u_val); diff --git a/examples/kinsol/CXX_parhyp/kin_heat2D_nonlin_hypre_pfmg.hpp b/examples/kinsol/CXX_parhyp/kin_heat2D_nonlin_hypre_pfmg.hpp index f14c6871c5..05d6f6d09c 100644 --- a/examples/kinsol/CXX_parhyp/kin_heat2D_nonlin_hypre_pfmg.hpp +++ b/examples/kinsol/CXX_parhyp/kin_heat2D_nonlin_hypre_pfmg.hpp @@ -293,62 +293,68 @@ static int check_retval(void* flagvalue, const string funcname, int opt); // ----------------------------------------------------------------------------- // c(u) = u -sunrealtype c1(sunrealtype u_val) { return u_val; } +static sunrealtype c1(sunrealtype u_val) { return u_val; } // c(u) = u^3 - u -sunrealtype c2(sunrealtype u_val) { return u_val * u_val * u_val - u_val; } +static sunrealtype c2(sunrealtype u_val) +{ + return u_val * u_val * u_val - u_val; +} // c(u) = u - u^2 -sunrealtype c3(sunrealtype u_val) { return u_val - u_val * u_val; } +static sunrealtype c3(sunrealtype u_val) { return u_val - u_val * u_val; } // c(u) = e^u -sunrealtype c4(sunrealtype u_val) { return exp(u_val); } +static sunrealtype c4(sunrealtype u_val) { return exp(u_val); } // c(u) = u^4 -sunrealtype c5(sunrealtype u_val) { return u_val * u_val * u_val * u_val; } +static sunrealtype c5(sunrealtype u_val) +{ + return u_val * u_val * u_val * u_val; +} // c(u) = cos^2(u) - sin^2(u) -sunrealtype c6(sunrealtype u_val) +static sunrealtype c6(sunrealtype u_val) { return (cos(u_val) * cos(u_val)) - (sin(u_val) * sin(u_val)); } // c(u) = cos^2(u) - sin^2(u) - e^u -sunrealtype c7(sunrealtype u_val) +static sunrealtype c7(sunrealtype u_val) { return (cos(u_val) * cos(u_val)) - (sin(u_val) * sin(u_val)) - exp(u_val); } // c(u) = e^u * u^4 - u * e^{cos(u)} -sunrealtype c8(sunrealtype u_val) +static sunrealtype c8(sunrealtype u_val) { sunrealtype u2 = u_val * u_val; return exp(u_val) * u2 * u2 - u_val * exp(cos(u_val)); } // c(u) = e^(cos^2(u)) -sunrealtype c9(sunrealtype u_val) +static sunrealtype c9(sunrealtype u_val) { sunrealtype cos2u = cos(u_val) * cos(u_val); return exp(cos2u); } // c(u) = 10(u - u^2) -sunrealtype c10(sunrealtype u_val) +static sunrealtype c10(sunrealtype u_val) { sunrealtype u2 = u_val * u_val; return 10.0 * (u_val - u2); } // c(u) = -13 + u + ((5-u)u - 2)u -sunrealtype c11(sunrealtype u_val) +static sunrealtype c11(sunrealtype u_val) { sunrealtype temp = ((5.0 - u_val) * u_val) - 2.0; return -13.0 + u_val + temp * u_val; } // c(u) = sqrt(5) * (u - u^2) -sunrealtype c12(sunrealtype u_val) +static sunrealtype c12(sunrealtype u_val) { sunrealtype temp = sqrt(5); sunrealtype u2 = u_val * u_val; @@ -356,7 +362,7 @@ sunrealtype c12(sunrealtype u_val) } // c(u) = (u - e^u)^2 + (u + u * sin(u) - cos(u))^2 -sunrealtype c13(sunrealtype u_val) +static sunrealtype c13(sunrealtype u_val) { sunrealtype eu = u_val - exp(u_val); sunrealtype usin = u_val * sin(u_val); @@ -365,7 +371,7 @@ sunrealtype c13(sunrealtype u_val) } // c(u) = u + ue^u + ue^{-u} -sunrealtype c14(sunrealtype u_val) +static sunrealtype c14(sunrealtype u_val) { sunrealtype ueu = u_val * exp(u_val); sunrealtype ue_u = u_val * exp(-u_val); @@ -373,7 +379,7 @@ sunrealtype c14(sunrealtype u_val) } // c(u) = u + ue^u + ue^{-u} + (u - e^u)^2 -sunrealtype c15(sunrealtype u_val) +static sunrealtype c15(sunrealtype u_val) { sunrealtype ueu = u_val * exp(u_val); sunrealtype ue_u = u_val * exp(-u_val); @@ -382,7 +388,7 @@ sunrealtype c15(sunrealtype u_val) } // c(u) = u + ue^u + ue^{-u} + (u - e^u)^2 + (u + usin(u) - cos(u))^2 -sunrealtype c16(sunrealtype u_val) +static sunrealtype c16(sunrealtype u_val) { sunrealtype ueu = u_val * exp(u_val); sunrealtype ue_u = u_val * exp(-u_val); @@ -392,7 +398,7 @@ sunrealtype c16(sunrealtype u_val) } // c(u) = u + ue^{-u} + e^u*(u + sin(u) - cos(u))^3 -sunrealtype c17(sunrealtype u_val) +static sunrealtype c17(sunrealtype u_val) { sunrealtype ue_u = u_val * exp(-u_val); sunrealtype eu = exp(u_val); diff --git a/examples/sunlinsol/ginkgo/test_sunlinsol_ginkgo.cpp b/examples/sunlinsol/ginkgo/test_sunlinsol_ginkgo.cpp index a1b00950c0..cddc307c5e 100644 --- a/examples/sunlinsol/ginkgo/test_sunlinsol_ginkgo.cpp +++ b/examples/sunlinsol/ginkgo/test_sunlinsol_ginkgo.cpp @@ -143,10 +143,15 @@ __global__ void fill_kernel(sunindextype mat_rows, sunindextype mat_cols, } #endif -void fill_matrix(gko::matrix::Csr* matrix) +#if (GKO_VERSION_MAJOR == 1) && (GKO_VERSION_MINOR < 6) +static void fill_matrix(gko::matrix::Csr* matrix) +#else +static void fill_matrix( + std::shared_ptr> matrix) +#endif { - sunindextype mat_rows = matrix->get_size()[0]; - sunindextype mat_cols = matrix->get_size()[1]; + sunindextype mat_rows = static_cast(matrix->get_size()[0]); + sunindextype mat_cols = static_cast(matrix->get_size()[1]); sunindextype* row_ptrs = matrix->get_row_ptrs(); sunindextype* col_idxs = matrix->get_col_idxs(); sunrealtype* mat_data = matrix->get_values(); @@ -229,10 +234,14 @@ void fill_matrix(gko::matrix::Csr* matrix) #endif } -void fill_matrix(gko::matrix::Dense* matrix) +#if (GKO_VERSION_MAJOR == 1) && (GKO_VERSION_MINOR < 6) +static void fill_matrix(gko::matrix::Dense* matrix) +#else +static void fill_matrix(std::shared_ptr> matrix) +#endif { - sunindextype mat_rows = matrix->get_size()[0]; - sunindextype mat_cols = matrix->get_size()[1]; + sunindextype mat_rows = static_cast(matrix->get_size()[0]); + sunindextype mat_cols = static_cast(matrix->get_size()[1]); sunrealtype* mat_data = matrix->get_values(); #if defined(USE_CUDA) || defined(USE_HIP) @@ -471,7 +480,7 @@ int main(int argc, char* argv[]) auto gko_matrix = gko::share(GkoMatrixType::create(gko_exec, matrix_dim, matrix_nnz)); - if (matcond) + if (matcond > 0) { auto gko_matdata{gko::matrix_data< sunrealtype, sunindextype>::cond(matrows, @@ -480,7 +489,14 @@ int main(int argc, char* argv[]) gko_matdata.remove_zeros(); gko_matrix->read(gko_matdata); } - else { fill_matrix(gko::lend(gko_matrix)); } + else + { +#if (GKO_VERSION_MAJOR == 1) && (GKO_VERSION_MINOR < 6) + fill_matrix(gko::lend(gko_matrix)); +#else + fill_matrix(gko_matrix); +#endif + } A = std::make_unique>(std::move( gko_matrix), sunctx); @@ -489,7 +505,7 @@ int main(int argc, char* argv[]) { using GkoMatrixType = gko::matrix::Dense; auto gko_matrix = gko::share(GkoMatrixType::create(gko_exec, matrix_dim)); - if (matcond) + if (matcond > 0) { auto gko_matdata{gko::matrix_data< sunrealtype, sunindextype>::cond(matrows, @@ -501,7 +517,11 @@ int main(int argc, char* argv[]) else { gko_matrix->fill(0.0); +#if (GKO_VERSION_MAJOR == 1) && (GKO_VERSION_MINOR < 6) fill_matrix(gko::lend(gko_matrix)); +#else + fill_matrix(gko_matrix); +#endif } A = std::make_unique>(std::move( gko_matrix), diff --git a/examples/sunlinsol/kokkos/test_sunlinsol_kokkosdense.cpp b/examples/sunlinsol/kokkos/test_sunlinsol_kokkosdense.cpp index cc42870024..5099ff8044 100644 --- a/examples/sunlinsol/kokkos/test_sunlinsol_kokkosdense.cpp +++ b/examples/sunlinsol/kokkos/test_sunlinsol_kokkosdense.cpp @@ -164,7 +164,7 @@ int main(int argc, char* argv[]) * ---------------------------------------------------------------------------*/ KOKKOS_FUNCTION -int CompareTol(sunrealtype a, sunrealtype b, sunrealtype tol) +static int CompareTol(sunrealtype a, sunrealtype b, sunrealtype tol) { if (a == b) { return 0; } if (std::isnan(a) || std::isnan(b)) { return 1; } diff --git a/examples/sunmatrix/dreadrb.c b/examples/sunmatrix/dreadrb.c index 86ab792353..9d24da993a 100644 --- a/examples/sunmatrix/dreadrb.c +++ b/examples/sunmatrix/dreadrb.c @@ -120,6 +120,8 @@ * */ +#include "dreadrb.h" + #include #include #include diff --git a/examples/sunmatrix/ginkgo/test_sunmatrix_ginkgo.cpp b/examples/sunmatrix/ginkgo/test_sunmatrix_ginkgo.cpp index f7381b7f17..4c7bb27f3c 100644 --- a/examples/sunmatrix/ginkgo/test_sunmatrix_ginkgo.cpp +++ b/examples/sunmatrix/ginkgo/test_sunmatrix_ginkgo.cpp @@ -213,7 +213,8 @@ int main(int argc, char* argv[]) auto Arowptrs{gko_matrix->get_const_row_ptrs()}; auto Acolidxs{gko_matrix->get_const_col_idxs()}; auto Avalues{gko_matrix->get_const_values()}; - for (auto irow = 0; irow < gko_matrix->get_size()[0]; irow++) + for (sunindextype irow = 0; + irow < static_cast(gko_matrix->get_size()[0]); irow++) { for (auto inz = gko_exec->copy_val_to_host(Arowptrs + irow); inz < gko_exec->copy_val_to_host(Arowptrs + irow + 1); inz++) @@ -299,7 +300,7 @@ int main(int argc, char* argv[]) /* ---------------------------------------------------------------------- * Check matrix * --------------------------------------------------------------------*/ -int check_matrix_csr(SUNMatrix A, SUNMatrix B, sunrealtype tol) +static int check_matrix_csr(SUNMatrix A, SUNMatrix B, sunrealtype tol) { int failure{0}; auto Amat{ @@ -309,10 +310,7 @@ int check_matrix_csr(SUNMatrix A, SUNMatrix B, sunrealtype tol) auto Amat_ref = Amat->clone(Amat->get_executor()->get_master()); auto Bmat_ref = Bmat->clone(Bmat->get_executor()->get_master()); auto Arowptrs{Amat_ref->get_const_row_ptrs()}; - auto Acolidxs{Amat_ref->get_const_col_idxs()}; auto Avalues{Amat_ref->get_const_values()}; - auto Browptrs{Bmat_ref->get_const_row_ptrs()}; - auto Bcolidxs{Bmat_ref->get_const_col_idxs()}; auto Bvalues{Bmat_ref->get_const_values()}; /* check lengths */ @@ -323,7 +321,8 @@ int check_matrix_csr(SUNMatrix A, SUNMatrix B, sunrealtype tol) } /* compare data */ - for (sunindextype irow = 0; irow < Amat_ref->get_size()[0]; irow++) + for (sunindextype irow = 0; + irow < static_cast(Amat_ref->get_size()[0]); irow++) { for (sunindextype inz = Arowptrs[irow]; inz < Arowptrs[irow + 1]; inz++) { @@ -334,7 +333,7 @@ int check_matrix_csr(SUNMatrix A, SUNMatrix B, sunrealtype tol) return failure > 0; } -int check_matrix_dense(SUNMatrix A, SUNMatrix B, sunrealtype tol) +static int check_matrix_dense(SUNMatrix A, SUNMatrix B, sunrealtype tol) { int failure{0}; auto Amat{ @@ -354,9 +353,9 @@ int check_matrix_dense(SUNMatrix A, SUNMatrix B, sunrealtype tol) } /* compare data */ - for (sunindextype i = 0; i < rows; i++) + for (sunindextype i = 0; i < static_cast(rows); i++) { - for (sunindextype j = 0; j < cols; j++) + for (sunindextype j = 0; j < static_cast(cols); j++) { failure += SUNRCompareTol(Amat_ref->at(i, j), Bmat_ref->at(i, j), tol); } @@ -372,18 +371,18 @@ extern "C" int check_matrix(SUNMatrix A, SUNMatrix B, sunrealtype tol) else { return 1; } } -int check_matrix_entry_csr(SUNMatrix A, sunrealtype val, sunrealtype tol) +static int check_matrix_entry_csr(SUNMatrix A, sunrealtype val, sunrealtype tol) { int failure{0}; auto Amat{ static_cast*>(A->content)->GkoMtx()}; auto Amat_ref = Amat->clone(Amat->get_executor()->get_master()); auto Arowptrs{Amat_ref->get_const_row_ptrs()}; - auto Acolidxs{Amat_ref->get_const_col_idxs()}; auto Avalues{Amat_ref->get_const_values()}; /* compare data */ - for (sunindextype irow = 0; irow < Amat_ref->get_size()[0]; irow++) + for (sunindextype irow = 0; + irow < static_cast(Amat_ref->get_size()[0]); irow++) { for (sunindextype inz = Arowptrs[irow]; inz < Arowptrs[irow + 1]; inz++) { @@ -400,7 +399,7 @@ int check_matrix_entry_csr(SUNMatrix A, sunrealtype val, sunrealtype tol) return failure > 0; } -int check_matrix_entry_dense(SUNMatrix A, sunrealtype val, sunrealtype tol) +static int check_matrix_entry_dense(SUNMatrix A, sunrealtype val, sunrealtype tol) { int failure{0}; auto Amat{ @@ -410,9 +409,9 @@ int check_matrix_entry_dense(SUNMatrix A, sunrealtype val, sunrealtype tol) auto Amat_ref = Amat->clone(Amat->get_executor()->get_master()); /* compare data */ - for (sunindextype i = 0; i < rows; i++) + for (sunindextype i = 0; i < static_cast(rows); i++) { - for (sunindextype j = 0; j < cols; j++) + for (sunindextype j = 0; j < static_cast(cols); j++) { int check = SUNRCompareTol(Amat_ref->at(i, j), val, tol); if (check) @@ -537,4 +536,4 @@ extern "C" void sync_device(SUNMatrix A) ->GkoExec() ->synchronize(); } -} \ No newline at end of file +} diff --git a/examples/sunmatrix/kokkos/test_sunmatrix_kokkosdense.cpp b/examples/sunmatrix/kokkos/test_sunmatrix_kokkosdense.cpp index 17fbf4d8a6..cb0d3374f2 100644 --- a/examples/sunmatrix/kokkos/test_sunmatrix_kokkosdense.cpp +++ b/examples/sunmatrix/kokkos/test_sunmatrix_kokkosdense.cpp @@ -174,7 +174,7 @@ int main(int argc, char* argv[]) * ---------------------------------------------------------------------------*/ KOKKOS_FUNCTION -int CompareTol(sunrealtype a, sunrealtype b, sunrealtype tol) +static int CompareTol(sunrealtype a, sunrealtype b, sunrealtype tol) { if (a == b) { return 0; } if (std::isnan(a) || std::isnan(b)) { return 1; } diff --git a/examples/utilities/example_utilities.hpp b/examples/utilities/example_utilities.hpp index e21c762126..00b4d843fc 100644 --- a/examples/utilities/example_utilities.hpp +++ b/examples/utilities/example_utilities.hpp @@ -21,7 +21,7 @@ #include // Check for an unrecoverable (negative) return value from a SUNDIALS function -int check_flag(const int flag, const std::string funcname) +static int check_flag(const int flag, const std::string funcname) { if (flag < 0) { @@ -32,7 +32,7 @@ int check_flag(const int flag, const std::string funcname) } // Check if a function returned a NULL pointer -int check_ptr(const void* ptr, const std::string funcname) +static int check_ptr(const void* ptr, const std::string funcname) { if (ptr) { return 0; } std::cerr << "ERROR: " << funcname << " returned NULL" << std::endl; diff --git a/include/nvector/trilinos/SundialsTpetraVectorKernels.hpp b/include/nvector/trilinos/SundialsTpetraVectorKernels.hpp index 02779a18e3..8b2d68eb08 100644 --- a/include/nvector/trilinos/SundialsTpetraVectorKernels.hpp +++ b/include/nvector/trilinos/SundialsTpetraVectorKernels.hpp @@ -54,8 +54,8 @@ static constexpr scalar_type one = 1.0; static constexpr scalar_type onept5 = 1.5; /*---------------------------------------------------------------- - * Streaming vector kernels - *---------------------------------------------------------------*/ + * Streaming vector kernels + *---------------------------------------------------------------*/ /// Divide: z(i) = x(i)/y(i) forall i inline void elementWiseDivide(const vector_type& x, const vector_type& y, @@ -339,8 +339,6 @@ inline bool invTest(const vector_type& x, vector_type& z) Kokkos::parallel_reduce( "invTest", Kokkos::RangePolicy(0, N), KOKKOS_LAMBDA(const local_ordinal_type& i, scalar_type& local_min) { - static constexpr scalar_type zero = 0; - static constexpr scalar_type one = 1.0; if (x_1d(i) == zero) { min_reducer.join(local_min, zero); } else { z_1d(i) = one / x_1d(i); } }, @@ -665,8 +663,6 @@ inline bool invTestLocal(const vector_type& x, vector_type& z) Kokkos::parallel_reduce( "invTestLocal", Kokkos::RangePolicy(0, N), KOKKOS_LAMBDA(const local_ordinal_type& i, scalar_type& local_min) { - static constexpr scalar_type zero = 0; - static constexpr scalar_type one = 1.0; if (x_1d(i) == zero) { min_reducer.join(local_min, zero); } else { z_1d(i) = one / x_1d(i); } }, diff --git a/include/sunlinsol/sunlinsol_ginkgo.hpp b/include/sunlinsol/sunlinsol_ginkgo.hpp index d801cb1da9..2817d426a9 100644 --- a/include/sunlinsol/sunlinsol_ginkgo.hpp +++ b/include/sunlinsol/sunlinsol_ginkgo.hpp @@ -332,11 +332,19 @@ class LinearSolver : public ConvertibleTo } iter_count_ = static_cast(logger->get_num_iterations()); +#if (GKO_VERSION_MAJOR == 1) && (GKO_VERSION_MINOR < 6) GkoExec()->get_master()->copy_from(gko::lend(GkoExec()), 1, gko::as( logger->get_residual_norm()) ->get_const_values(), &res_norm_); +#else + GkoExec()->get_master()->copy_from(GkoExec(), 1, + gko::as( + logger->get_residual_norm()) + ->get_const_values(), + &res_norm_); +#endif return result; } diff --git a/include/sunlinsol/sunlinsol_kokkosdense.hpp b/include/sunlinsol/sunlinsol_kokkosdense.hpp index ba109bb2be..2fbda953bd 100644 --- a/include/sunlinsol/sunlinsol_kokkosdense.hpp +++ b/include/sunlinsol/sunlinsol_kokkosdense.hpp @@ -40,12 +40,12 @@ class DenseLinearSolver; namespace impl { -SUNLinearSolver_Type SUNLinSolGetType_KokkosDense(SUNLinearSolver S) +static SUNLinearSolver_Type SUNLinSolGetType_KokkosDense(SUNLinearSolver S) { return SUNLINEARSOLVER_DIRECT; } -SUNLinearSolver_ID SUNLinSolGetID_KokkosDense(SUNLinearSolver S) +static SUNLinearSolver_ID SUNLinSolGetID_KokkosDense(SUNLinearSolver S) { return SUNLINEARSOLVER_KOKKOSDENSE; } diff --git a/include/sunmatrix/sunmatrix_kokkosdense.hpp b/include/sunmatrix/sunmatrix_kokkosdense.hpp index d172ba73df..15bf696dee 100644 --- a/include/sunmatrix/sunmatrix_kokkosdense.hpp +++ b/include/sunmatrix/sunmatrix_kokkosdense.hpp @@ -46,7 +46,7 @@ inline MatrixType* GetDenseMat(SUNMatrix A) namespace impl { -SUNMatrix_ID SUNMatGetID_KokkosDense(SUNMatrix A) +static SUNMatrix_ID SUNMatGetID_KokkosDense(SUNMatrix A) { return SUNMATRIX_KOKKOSDENSE; } diff --git a/src/arkode/fmod/farkode_arkstep_mod.f90 b/src/arkode/fmod/farkode_arkstep_mod.f90 index 165149355b..cc0373f1eb 100644 --- a/src/arkode/fmod/farkode_arkstep_mod.f90 +++ b/src/arkode/fmod/farkode_arkstep_mod.f90 @@ -26,6 +26,7 @@ module farkode_arkstep_mod private ! DECLARATION CONSTRUCTS + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_1 = ARKODE_FORWARD_EULER_1_1 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_2 = ARKODE_HEUN_EULER_2_1_2 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_3 = ARKODE_BOGACKI_SHAMPINE_4_2_3 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_4 = ARKODE_ZONNEVELD_5_3_4 @@ -34,6 +35,7 @@ module farkode_arkstep_mod integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_7 = ARKODE_VERNER_10_6_7 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_8 = ARKODE_FEHLBERG_13_7_8 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_9 = ARKODE_VERNER_16_8_9 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_1 = ARKODE_BACKWARD_EULER_1_1 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_2 = ARKODE_SDIRK_2_1_2 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_3 = ARKODE_ARK324L2SA_DIRK_4_2_3 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_4 = ARKODE_SDIRK_5_3_4 diff --git a/src/arkode/fmod/farkode_erkstep_mod.f90 b/src/arkode/fmod/farkode_erkstep_mod.f90 index 797d0ca9ff..291dc643d5 100644 --- a/src/arkode/fmod/farkode_erkstep_mod.f90 +++ b/src/arkode/fmod/farkode_erkstep_mod.f90 @@ -26,6 +26,7 @@ module farkode_erkstep_mod private ! DECLARATION CONSTRUCTS + integer(C_INT), parameter, public :: ERKSTEP_DEFAULT_1 = ARKODE_FORWARD_EULER_1_1 integer(C_INT), parameter, public :: ERKSTEP_DEFAULT_2 = ARKODE_HEUN_EULER_2_1_2 integer(C_INT), parameter, public :: ERKSTEP_DEFAULT_3 = ARKODE_BOGACKI_SHAMPINE_4_2_3 integer(C_INT), parameter, public :: ERKSTEP_DEFAULT_4 = ARKODE_ZONNEVELD_5_3_4 diff --git a/src/cvode/CMakeLists.txt b/src/cvode/CMakeLists.txt index 7c30d3538c..ca1e745b98 100644 --- a/src/cvode/CMakeLists.txt +++ b/src/cvode/CMakeLists.txt @@ -89,7 +89,7 @@ if(SUNDIALS_BUILD_PACKAGE_FUSED_KERNELS) SOURCES cvode_fused_stubs.c LINK_LIBRARIES - PUBLIC sundials_core + PUBLIC sundials_core OUTPUT_NAME sundials_cvode_fused_stubs VERSION diff --git a/src/cvode/cvode.c b/src/cvode/cvode.c index 379c0fa0c2..368db3e53f 100644 --- a/src/cvode/cvode.c +++ b/src/cvode/cvode.c @@ -138,16 +138,6 @@ static void cvFreeVectors(CVodeMem cv_mem); static int cvEwtSetSS(CVodeMem cv_mem, N_Vector ycur, N_Vector weight); static int cvEwtSetSV(CVodeMem cv_mem, N_Vector ycur, N_Vector weight); -#ifdef SUNDIALS_BUILD_PACKAGE_FUSED_KERNELS -extern int cvEwtSetSS_fused(const sunbooleantype atolmin0, - const sunrealtype reltol, const sunrealtype Sabstol, - const N_Vector ycur, N_Vector tempv, N_Vector weight); - -extern int cvEwtSetSV_fused(const sunbooleantype atolmin0, - const sunrealtype reltol, const N_Vector Vabstol, - const N_Vector ycur, N_Vector tempv, N_Vector weight); -#endif - /* Initial stepsize calculation */ static int cvHin(CVodeMem cv_mem, sunrealtype tout); @@ -183,11 +173,6 @@ static void cvSetTqBDF(CVodeMem cv_mem, sunrealtype hsum, sunrealtype alpha0, static int cvNls(CVodeMem cv_mem, int nflag); static int cvCheckConstraints(CVodeMem cv_mem); -#ifdef SUNDIALS_BUILD_PACKAGE_FUSED_KERNELS -extern int cvCheckConstraints_fused(const N_Vector c, const N_Vector ewt, - const N_Vector y, const N_Vector mm, - N_Vector tempv); -#endif static int cvHandleNFlag(CVodeMem cv_mem, int* nflagPtr, sunrealtype saved_t, int* ncfPtr); diff --git a/src/cvode/cvode_diag.c b/src/cvode/cvode_diag.c index e24592c827..ab73f5ac55 100644 --- a/src/cvode/cvode_diag.c +++ b/src/cvode/cvode_diag.c @@ -23,20 +23,6 @@ #include "cvode_diag_impl.h" #include "cvode_impl.h" -#ifdef SUNDIALS_BUILD_PACKAGE_FUSED_KERNELS -extern int cvDiagSetup_formY(const sunrealtype h, const sunrealtype r, - const N_Vector fpred, const N_Vector zn1, - const N_Vector ypred, N_Vector ftemp, N_Vector y); - -extern int cvDiagSetup_buildM(const sunrealtype fract, const sunrealtype uround, - const sunrealtype h, const N_Vector ftemp, - const N_Vector fpred, const N_Vector ewt, - N_Vector bit, N_Vector bitcomp, N_Vector y, - N_Vector M); - -int cvDiagSolve_updateM(const sunrealtype r, N_Vector M); -#endif - /* Other Constants */ #define FRACT SUN_RCONST(0.1) diff --git a/src/cvode/cvode_impl.h b/src/cvode/cvode_impl.h index d7d9d08823..c8d08a32fb 100644 --- a/src/cvode/cvode_impl.h +++ b/src/cvode/cvode_impl.h @@ -634,6 +634,34 @@ void cvRestore(CVodeMem cv_mem, sunrealtype saved_t); void cvRescale(CVodeMem cv_mem); +#ifdef SUNDIALS_BUILD_PACKAGE_FUSED_KERNELS +int cvEwtSetSS_fused(const sunbooleantype atolmin0, const sunrealtype reltol, + const sunrealtype Sabstol, const N_Vector ycur, + N_Vector tempv, N_Vector weight); + +int cvEwtSetSV_fused(const sunbooleantype atolmin0, const sunrealtype reltol, + const N_Vector Vabstol, const N_Vector ycur, + N_Vector tempv, N_Vector weight); + +int cvCheckConstraints_fused(const N_Vector c, const N_Vector ewt, + const N_Vector y, const N_Vector mm, N_Vector tempv); + +int cvNlsResid_fused(const sunrealtype rl1, const sunrealtype ngamma, + const N_Vector zn1, const N_Vector ycor, + const N_Vector ftemp, N_Vector res); + +int cvDiagSetup_formY(const sunrealtype h, const sunrealtype r, + const N_Vector fpred, const N_Vector zn1, + const N_Vector ypred, N_Vector ftemp, N_Vector y); + +int cvDiagSetup_buildM(const sunrealtype fract, const sunrealtype uround, + const sunrealtype h, const N_Vector ftemp, + const N_Vector fpred, const N_Vector ewt, N_Vector bit, + N_Vector bitcomp, N_Vector y, N_Vector M); + +int cvDiagSolve_updateM(const sunrealtype r, N_Vector M); +#endif + /* * ================================================================= * E R R O R M E S S A G E S diff --git a/src/cvode/cvode_nls.c b/src/cvode/cvode_nls.c index ade248a1b9..7821bd976a 100644 --- a/src/cvode/cvode_nls.c +++ b/src/cvode/cvode_nls.c @@ -40,12 +40,6 @@ static int cvNlsLSolve(N_Vector delta, void* cvode_mem); static int cvNlsConvTest(SUNNonlinearSolver NLS, N_Vector ycor, N_Vector del, sunrealtype tol, N_Vector ewt, void* cvode_mem); -#ifdef SUNDIALS_BUILD_PACKAGE_FUSED_KERNELS -int cvNlsResid_fused(const sunrealtype rl1, const sunrealtype ngamma, - const N_Vector zn1, const N_Vector ycor, - const N_Vector ftemp, N_Vector res); -#endif - /* ----------------------------------------------------------------------------- * Exported functions * ---------------------------------------------------------------------------*/ diff --git a/src/sundials/fmod/fsundials_core_mod.c b/src/sundials/fmod/fsundials_core_mod.c index 4af16b91a4..c369799cce 100644 --- a/src/sundials/fmod/fsundials_core_mod.c +++ b/src/sundials/fmod/fsundials_core_mod.c @@ -2516,6 +2516,14 @@ SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_NewEmpty(void *farg1) { } +SWIGEXPORT void _wrap_FSUNAdaptController_DestroyEmpty(SUNAdaptController farg1) { + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + + arg1 = (SUNAdaptController)(farg1); + SUNAdaptController_DestroyEmpty(arg1); +} + + SWIGEXPORT int _wrap_FSUNAdaptController_GetType(SUNAdaptController farg1) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sundials/fmod/fsundials_core_mod.f90 b/src/sundials/fmod/fsundials_core_mod.f90 index 4334dfe0d3..c51487dd30 100644 --- a/src/sundials/fmod/fsundials_core_mod.f90 +++ b/src/sundials/fmod/fsundials_core_mod.f90 @@ -536,6 +536,7 @@ module fsundials_core_mod type(C_PTR), public :: sunctx end type SUNAdaptController public :: FSUNAdaptController_NewEmpty + public :: FSUNAdaptController_DestroyEmpty public :: FSUNAdaptController_GetType public :: FSUNAdaptController_Destroy public :: FSUNAdaptController_EstimateStep @@ -1955,6 +1956,12 @@ function swigc_FSUNAdaptController_NewEmpty(farg1) & type(C_PTR) :: fresult end function +subroutine swigc_FSUNAdaptController_DestroyEmpty(farg1) & +bind(C, name="_wrap_FSUNAdaptController_DestroyEmpty") +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +end subroutine + function swigc_FSUNAdaptController_GetType(farg1) & bind(C, name="_wrap_FSUNAdaptController_GetType") & result(fresult) @@ -4622,6 +4629,15 @@ function FSUNAdaptController_NewEmpty(sunctx) & call c_f_pointer(fresult, swig_result) end function +subroutine FSUNAdaptController_DestroyEmpty(c) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptController), target, intent(inout) :: c +type(C_PTR) :: farg1 + +farg1 = c_loc(c) +call swigc_FSUNAdaptController_DestroyEmpty(farg1) +end subroutine + function FSUNAdaptController_GetType(c) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sundials/sundials_futils.c b/src/sundials/sundials_futils.c index e494fe7447..3a0d0f27d1 100644 --- a/src/sundials/sundials_futils.c +++ b/src/sundials/sundials_futils.c @@ -17,6 +17,7 @@ #include #include #include +#include /* Create a file pointer with the given file name and mode. */ SUNErrCode SUNDIALSFileOpen(const char* filename, const char* mode, FILE** fp_out) diff --git a/test/env/default.sh b/test/env/default.sh index fb6ed34802..3085490055 100644 --- a/test/env/default.sh +++ b/test/env/default.sh @@ -139,11 +139,6 @@ if [ "$compilername" == "gcc" ]; then export CUDAFLAGS="-g -O3" fi - # append additional warning flags - if [[ "$SUNDIALS_PRECISION" == "double" && "$SUNDIALS_INDEX_SIZE" == "32" ]]; then - export CFLAGS="${CFLAGS} -Wconversion -Wno-sign-conversion" - export CXXFLAGS="${CXXFLAGS} -Wconversion -Wno-sign-conversion" - fi # TODO(CJB): add this back after we upgrade the GNU compiler stack on the Jenkins box # Currently this causes the compiler to segfault on many of the Fortran example codes. # export FFLAGS="${FFLAGS} -fbounds-check" diff --git a/test/env/docker.sh b/test/env/docker.sh index 2ab9b50410..2f9359af0d 100644 --- a/test/env/docker.sh +++ b/test/env/docker.sh @@ -178,9 +178,6 @@ else # single export SUNDIALS_TEST_INTEGER_PRECISION=10 fi -# FindMPI fails with this ON -export SUNDIALS_ENABLE_WARNINGS_AS_ERRORS=OFF - # ------------------------------------------------------------------------------ # Third party libraries # ------------------------------------------------------------------------------ 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 7b3598451d..9b53b9083b 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_getjac.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_getjac.cpp @@ -89,7 +89,7 @@ static int ytrue(sunrealtype t, N_Vector y) * [a b] * [ (-1 + u^2 - r(t)) / (2*u) ] + [ r'(t) / (2u) ] * [c d] [ (-2 + v^2 - s(t)) / (2*v) ] [ s'(t) / (2v) ] * ---------------------------------------------------------------------------*/ -int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { sunrealtype* udata = (sunrealtype*)user_data; const sunrealtype a = udata[0]; @@ -117,8 +117,8 @@ int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) * [a/2 + (a(1+r(t))-rdot(t))/(2u^2) b/2 + b*(2+s(t))/(2*v^2) ] * [c/2 + c(1+r(t))/(2u^2) d/2 + (d(2+s(t))-sdot(t))/(2u^2) ] * ---------------------------------------------------------------------------*/ -int J(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, - N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) +static int J(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { sunrealtype* udata = (sunrealtype*)user_data; const sunrealtype a = udata[0]; @@ -145,7 +145,7 @@ int J(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, // ----------------------------------------------------------------------------- // Check function return flag -int check_flag(int flag, const std::string funcname) +static int check_flag(int flag, const std::string funcname) { if (!flag) { return 0; } if (flag < 0) { std::cerr << "ERROR: "; } @@ -155,7 +155,7 @@ int check_flag(int flag, const std::string funcname) } // Check if a function returned a NULL pointer -int check_ptr(void* ptr, const std::string funcname) +static int check_ptr(void* ptr, const std::string funcname) { if (ptr) { return 0; } std::cerr << "ERROR: " << funcname << " returned NULL" << std::endl; 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 af9168d5fd..4737434ff6 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 @@ -90,7 +90,7 @@ static int ytrue(sunrealtype t, N_Vector y) * [a b] * [ (-1 + u^2 - r(t)) / (2*u) ] + [ r'(t) / (2u) ] * [c d] [ (-2 + v^2 - s(t)) / (2*v) ] [ s'(t) / (2v) ] * ---------------------------------------------------------------------------*/ -int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { sunrealtype* udata = (sunrealtype*)user_data; const sunrealtype a = udata[0]; @@ -116,7 +116,7 @@ int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) /* ----------------------------------------------------------------------------- * Compute the fast ODE RHS function * ---------------------------------------------------------------------------*/ -int f0(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +static int f0(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { N_VConst(ZERO, ydot); return 0; @@ -127,8 +127,8 @@ int f0(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) * [a/2 + (a(1+r(t))-rdot(t))/(2u^2) b/2 + b*(2+s(t))/(2*v^2) ] * [c/2 + c(1+r(t))/(2u^2) d/2 + (d(2+s(t))-sdot(t))/(2u^2) ] * ---------------------------------------------------------------------------*/ -int J(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, - N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) +static int J(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { sunrealtype* udata = (sunrealtype*)user_data; const sunrealtype a = udata[0]; @@ -155,7 +155,7 @@ int J(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, // ----------------------------------------------------------------------------- // Check function return flag -int check_flag(int flag, const std::string funcname) +static int check_flag(int flag, const std::string funcname) { if (!flag) { return 0; } if (flag < 0) { std::cerr << "ERROR: "; } @@ -165,7 +165,7 @@ int check_flag(int flag, const std::string funcname) } // Check if a function returned a NULL pointer -int check_ptr(void* ptr, const std::string funcname) +static int check_ptr(void* ptr, const std::string funcname) { if (ptr) { return 0; } std::cerr << "ERROR: " << funcname << " returned NULL" << std::endl; diff --git a/test/unit_tests/arkode/C_serial/ark_test_innerstepper.c b/test/unit_tests/arkode/C_serial/ark_test_innerstepper.c index f79566aa6f..7e16e77946 100644 --- a/test/unit_tests/arkode/C_serial/ark_test_innerstepper.c +++ b/test/unit_tests/arkode/C_serial/ark_test_innerstepper.c @@ -32,7 +32,7 @@ #define ZERO SUN_RCONST(0.0) #define ONE SUN_RCONST(1.0) -int ode_slow_rhs(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +static int ode_slow_rhs(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { sunrealtype* y_data = N_VGetArrayPointer(ydot); sunrealtype* ydot_data = N_VGetArrayPointer(ydot); @@ -40,8 +40,8 @@ int ode_slow_rhs(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) return 0; } -int fast_evolve(MRIStepInnerStepper fast_mem, sunrealtype t0, sunrealtype tf, - N_Vector y) +static int fast_evolve(MRIStepInnerStepper fast_mem, sunrealtype t0, + sunrealtype tf, N_Vector y) { int i = 0; sunrealtype h_fast = (t0 - tf) / SUN_RCONST(10.0); diff --git a/test/unit_tests/arkode/C_serial/ark_test_mass.c b/test/unit_tests/arkode/C_serial/ark_test_mass.c index c011d11209..d50eed86c0 100644 --- a/test/unit_tests/arkode/C_serial/ark_test_mass.c +++ b/test/unit_tests/arkode/C_serial/ark_test_mass.c @@ -92,8 +92,9 @@ static int check_retval(void* flagvalue, const char* funcname, int opt) return 0; } -int solve(const char* im, const char* ex, int steps, sunbooleantype time_dep, - sunbooleantype deduce_implicit_rhs, long int expected_mass_solves) +static int solve(const char* im, const char* ex, int steps, + sunbooleantype time_dep, sunbooleantype deduce_implicit_rhs, + long int expected_mass_solves) { int retval = 0; int s; 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 7498e251bb..80cb6b9e2f 100644 --- a/test/unit_tests/arkode/C_serial/ark_test_tstop.c +++ b/test/unit_tests/arkode/C_serial/ark_test_tstop.c @@ -33,15 +33,16 @@ #define ZERO SUN_RCONST(0.0) #define ONE SUN_RCONST(1.0) -int ode_rhs(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +static int ode_rhs(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { sunrealtype* ydot_data = N_VGetArrayPointer(ydot); ydot_data[0] = ONE; return 0; } -int ode_jac(sunrealtype t, N_Vector y, N_Vector f, SUNMatrix J, void* user_data, - N_Vector tempv1, N_Vector tempv2, N_Vector tempv3) +static int ode_jac(sunrealtype t, N_Vector y, N_Vector f, SUNMatrix J, + void* user_data, N_Vector tempv1, N_Vector tempv2, + N_Vector tempv3) { sunrealtype* J_data = SUNDenseMatrix_Data(J); J_data[0] = ZERO; 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 b671ad3911..4475159260 100644 --- a/test/unit_tests/cvode/CXX_serial/cv_test_getjac.cpp +++ b/test/unit_tests/cvode/CXX_serial/cv_test_getjac.cpp @@ -89,7 +89,7 @@ static int ytrue(sunrealtype t, N_Vector y) * [a b] * [ (-1 + u^2 - r(t)) / (2*u) ] + [ r'(t) / (2u) ] * [c d] [ (-2 + v^2 - s(t)) / (2*v) ] [ s'(t) / (2v) ] * ---------------------------------------------------------------------------*/ -int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { sunrealtype* udata = (sunrealtype*)user_data; const sunrealtype a = udata[0]; @@ -117,8 +117,8 @@ int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) * [a/2 + (a(1+r(t))-rdot(t))/(2u^2) b/2 + b*(2+s(t))/(2*v^2) ] * [c/2 + c(1+r(t))/(2u^2) d/2 + (d(2+s(t))-sdot(t))/(2u^2) ] * ---------------------------------------------------------------------------*/ -int J(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, - N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) +static int J(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { sunrealtype* udata = (sunrealtype*)user_data; const sunrealtype a = udata[0]; @@ -145,7 +145,7 @@ int J(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, // ----------------------------------------------------------------------------- // Check function return flag -int check_flag(int flag, const std::string funcname) +static int check_flag(int flag, const std::string funcname) { if (!flag) { return 0; } if (flag < 0) { std::cerr << "ERROR: "; } @@ -155,7 +155,7 @@ int check_flag(int flag, const std::string funcname) } // Check if a function returned a NULL pointer -int check_ptr(void* ptr, const std::string funcname) +static int check_ptr(void* ptr, const std::string funcname) { if (ptr) { return 0; } std::cerr << "ERROR: " << funcname << " returned NULL" << std::endl; 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 e4d8cd1884..1a0675efbb 100644 --- a/test/unit_tests/cvode/CXX_serial/cv_test_kpr.hpp +++ b/test/unit_tests/cvode/CXX_serial/cv_test_kpr.hpp @@ -129,7 +129,7 @@ static int true_sol(sunrealtype t, sunrealtype* u, sunrealtype* v) // ----------------------------------------------------------------------------- // Check function return flag -int check_flag(int flag, const string funcname) +static int check_flag(int flag, const string funcname) { if (!flag) { return 0; } if (flag < 0) { cerr << "ERROR: "; } @@ -138,7 +138,7 @@ int check_flag(int flag, const string funcname) } // Check if a function returned a NULL pointer -int check_ptr(void* ptr, const string funcname) +static int check_ptr(void* ptr, const string funcname) { if (ptr) { return 0; } cerr << "ERROR: " << funcname << " returned NULL" << endl; @@ -193,7 +193,7 @@ inline void find_arg(vector& args, const string key, bool& dest, } // Print command line options -void InputHelp() +static void InputHelp() { cout << endl; cout << "Command line options:" << endl; @@ -217,7 +217,7 @@ void InputHelp() cout << " --nout : number of outputs\n"; } -int ReadInputs(vector& args, TestOptions& opts, SUNContext ctx) +static int ReadInputs(vector& args, TestOptions& opts, SUNContext ctx) { if (find(args.begin(), args.end(), "--help") != args.end()) { diff --git a/test/unit_tests/cvode/C_serial/cv_test_tstop.c b/test/unit_tests/cvode/C_serial/cv_test_tstop.c index 33a5a2bcc6..f8809e2c19 100644 --- a/test/unit_tests/cvode/C_serial/cv_test_tstop.c +++ b/test/unit_tests/cvode/C_serial/cv_test_tstop.c @@ -33,15 +33,16 @@ #define ZERO SUN_RCONST(0.0) #define ONE SUN_RCONST(1.0) -int ode_rhs(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +static int ode_rhs(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { sunrealtype* ydot_data = N_VGetArrayPointer(ydot); ydot_data[0] = ONE; return 0; } -int ode_jac(sunrealtype t, N_Vector y, N_Vector f, SUNMatrix J, void* user_data, - N_Vector tempv1, N_Vector tempv2, N_Vector tempv3) +static int ode_jac(sunrealtype t, N_Vector y, N_Vector f, SUNMatrix J, + void* user_data, N_Vector tempv1, N_Vector tempv2, + N_Vector tempv3) { sunrealtype* J_data = SUNDenseMatrix_Data(J); J_data[0] = ZERO; diff --git a/test/unit_tests/cvode/gtest/CMakeLists.txt b/test/unit_tests/cvode/gtest/CMakeLists.txt index 997358abdb..df16114295 100644 --- a/test/unit_tests/cvode/gtest/CMakeLists.txt +++ b/test/unit_tests/cvode/gtest/CMakeLists.txt @@ -20,12 +20,17 @@ target_include_directories(test_cvode_error_handling ${CMAKE_SOURCE_DIR}/src ) +if(SUNDIALS_BUILD_PACKAGE_FUSED_KERNELS) + set(_fused_link_lib sundials_cvode_fused_stubs_obj) +endif() + # We explicitly choose which object libraries to link to and link in the # cvode objects so that we have access to private functions w/o changing # their visibility in the installed libraries. target_link_libraries(test_cvode_error_handling PRIVATE $ + ${_fused_link_lib} sundials_sunmemsys_obj sundials_nvecserial_obj sundials_sunlinsolband_obj 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 0b805b419b..6c26d1bf3d 100644 --- a/test/unit_tests/cvodes/CXX_serial/cvs_test_getjac.cpp +++ b/test/unit_tests/cvodes/CXX_serial/cvs_test_getjac.cpp @@ -88,7 +88,7 @@ static int ytrue(sunrealtype t, N_Vector y) * [a b] * [ (-1 + u^2 - r(t)) / (2*u) ] + [ r'(t) / (2u) ] * [c d] [ (-2 + v^2 - s(t)) / (2*v) ] [ s'(t) / (2v) ] * ---------------------------------------------------------------------------*/ -int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { sunrealtype* udata = (sunrealtype*)user_data; const sunrealtype a = udata[0]; @@ -116,8 +116,8 @@ int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) * [a/2 + (a(1+r(t))-rdot(t))/(2u^2) b/2 + b*(2+s(t))/(2*v^2) ] * [c/2 + c(1+r(t))/(2u^2) d/2 + (d(2+s(t))-sdot(t))/(2u^2) ] * ---------------------------------------------------------------------------*/ -int J(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, - N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) +static int J(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { sunrealtype* udata = (sunrealtype*)user_data; const sunrealtype a = udata[0]; @@ -144,7 +144,7 @@ int J(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, // ----------------------------------------------------------------------------- // Check function return flag -int check_flag(int flag, const std::string funcname) +static int check_flag(int flag, const std::string funcname) { if (!flag) { return 0; } if (flag < 0) { std::cerr << "ERROR: "; } @@ -154,7 +154,7 @@ int check_flag(int flag, const std::string funcname) } // Check if a function returned a NULL pointer -int check_ptr(void* ptr, const std::string funcname) +static int check_ptr(void* ptr, const std::string funcname) { if (ptr) { return 0; } std::cerr << "ERROR: " << funcname << " returned NULL" << std::endl; 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 a669dd9b1b..6142b566c9 100644 --- a/test/unit_tests/cvodes/CXX_serial/cvs_test_kpr.hpp +++ b/test/unit_tests/cvodes/CXX_serial/cvs_test_kpr.hpp @@ -129,7 +129,7 @@ static int true_sol(sunrealtype t, sunrealtype* u, sunrealtype* v) // ----------------------------------------------------------------------------- // Check function return flag -int check_flag(int flag, const string funcname) +static int check_flag(int flag, const string funcname) { if (!flag) { return 0; } if (flag < 0) { cerr << "ERROR: "; } @@ -138,7 +138,7 @@ int check_flag(int flag, const string funcname) } // Check if a function returned a NULL pointer -int check_ptr(void* ptr, const string funcname) +static int check_ptr(void* ptr, const string funcname) { if (ptr) { return 0; } cerr << "ERROR: " << funcname << " returned NULL" << endl; @@ -193,7 +193,7 @@ inline void find_arg(vector& args, const string key, bool& dest, } // Print command line options -void InputHelp() +static void InputHelp() { cout << endl; cout << "Command line options:" << endl; @@ -217,7 +217,7 @@ void InputHelp() cout << " --nout : number of outputs\n"; } -int ReadInputs(vector& args, TestOptions& opts, SUNContext ctx) +static int ReadInputs(vector& args, TestOptions& opts, SUNContext ctx) { if (find(args.begin(), args.end(), "--help") != args.end()) { diff --git a/test/unit_tests/cvodes/C_serial/cvs_test_tstop.c b/test/unit_tests/cvodes/C_serial/cvs_test_tstop.c index a465618540..ede859ef67 100644 --- a/test/unit_tests/cvodes/C_serial/cvs_test_tstop.c +++ b/test/unit_tests/cvodes/C_serial/cvs_test_tstop.c @@ -33,15 +33,16 @@ #define ZERO SUN_RCONST(0.0) #define ONE SUN_RCONST(1.0) -int ode_rhs(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +static int ode_rhs(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { sunrealtype* ydot_data = N_VGetArrayPointer(ydot); ydot_data[0] = ONE; return 0; } -int ode_jac(sunrealtype t, N_Vector y, N_Vector f, SUNMatrix J, void* user_data, - N_Vector tempv1, N_Vector tempv2, N_Vector tempv3) +static int ode_jac(sunrealtype t, N_Vector y, N_Vector f, SUNMatrix J, + void* user_data, N_Vector tempv1, N_Vector tempv2, + N_Vector tempv3) { sunrealtype* J_data = SUNDenseMatrix_Data(J); J_data[0] = ZERO; 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 72e2b48b25..aa372836e3 100644 --- a/test/unit_tests/ida/CXX_serial/ida_test_getjac.cpp +++ b/test/unit_tests/ida/CXX_serial/ida_test_getjac.cpp @@ -105,7 +105,8 @@ static int yptrue(sunrealtype t, N_Vector yp) * [a b] * [ (-1 + u^2 - r(t)) ] + [ r'(t) ] - [ 2 u u'] = 0 * [c d] [ (-2 + v^2 - s(t)) ] [ s'(t) ] - [ 2 v v'] = 0 * ---------------------------------------------------------------------------*/ -int res(sunrealtype t, N_Vector y, N_Vector yp, N_Vector res, void* user_data) +static int res(sunrealtype t, N_Vector y, N_Vector yp, N_Vector res, + void* user_data) { sunrealtype* udata = (sunrealtype*)user_data; const sunrealtype a = udata[0]; @@ -137,8 +138,9 @@ int res(sunrealtype t, N_Vector y, N_Vector yp, N_Vector res, void* user_data) * [2 a u - 2 u' - 2 cj u 2 b v ] * [2 c u 2 d v - 2 v' - 2 cj v ] * ---------------------------------------------------------------------------*/ -int J(sunrealtype t, sunrealtype cj, N_Vector y, N_Vector yp, N_Vector res, - SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) +static int J(sunrealtype t, sunrealtype cj, N_Vector y, N_Vector yp, + N_Vector res, SUNMatrix J, void* user_data, N_Vector tmp1, + N_Vector tmp2, N_Vector tmp3) { sunrealtype* udata = (sunrealtype*)user_data; const sunrealtype a = udata[0]; @@ -167,8 +169,8 @@ int J(sunrealtype t, sunrealtype cj, N_Vector y, N_Vector yp, N_Vector res, // Custom linear solver solve function // ----------------------------------------------------------------------------- -int DenseSetupAndSolve(SUNLinearSolver S, SUNMatrix A, N_Vector x, N_Vector b, - sunrealtype tol) +static int DenseSetupAndSolve(SUNLinearSolver S, SUNMatrix A, N_Vector x, + N_Vector b, sunrealtype tol) { // Create a copy of the matrix for factorization SUNMatrix Acpy = SUNMatClone(A); @@ -196,7 +198,7 @@ int DenseSetupAndSolve(SUNLinearSolver S, SUNMatrix A, N_Vector x, N_Vector b, // ----------------------------------------------------------------------------- // Check function return flag -int check_flag(int flag, const std::string funcname) +static int check_flag(int flag, const std::string funcname) { if (!flag) { return 0; } if (flag < 0) { std::cerr << "ERROR: "; } @@ -206,7 +208,7 @@ int check_flag(int flag, const std::string funcname) } // Check if a function returned a NULL pointer -int check_ptr(void* ptr, const std::string funcname) +static int check_ptr(void* ptr, const std::string funcname) { if (ptr) { return 0; } std::cerr << "ERROR: " << funcname << " returned NULL" << std::endl; 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 ab5573b882..b7088929e3 100644 --- a/test/unit_tests/ida/CXX_serial/ida_test_kpr.hpp +++ b/test/unit_tests/ida/CXX_serial/ida_test_kpr.hpp @@ -123,7 +123,7 @@ static int true_sol_p(sunrealtype t, sunrealtype* up, sunrealtype* vp) // ----------------------------------------------------------------------------- // Check function return flag -int check_flag(int flag, const string funcname) +static int check_flag(int flag, const string funcname) { if (!flag) { return 0; } if (flag < 0) { cerr << "ERROR: "; } @@ -132,7 +132,7 @@ int check_flag(int flag, const string funcname) } // Check if a function returned a NULL pointer -int check_ptr(void* ptr, const string funcname) +static int check_ptr(void* ptr, const string funcname) { if (ptr) { return 0; } cerr << "ERROR: " << funcname << " returned NULL" << endl; @@ -187,7 +187,7 @@ inline void find_arg(vector& args, const string key, bool& dest, } // Print command line options -void InputHelp() +static void InputHelp() { cout << endl; cout << "Command line options:" << endl; @@ -205,7 +205,7 @@ void InputHelp() cout << " --nout : number of outputs\n"; } -int ReadInputs(vector& args, TestOptions& opts, SUNContext ctx) +static int ReadInputs(vector& args, TestOptions& opts, SUNContext ctx) { if (find(args.begin(), args.end(), "--help") != args.end()) { diff --git a/test/unit_tests/ida/C_serial/ida_test_tstop.c b/test/unit_tests/ida/C_serial/ida_test_tstop.c index 180fe263a8..27fffde375 100644 --- a/test/unit_tests/ida/C_serial/ida_test_tstop.c +++ b/test/unit_tests/ida/C_serial/ida_test_tstop.c @@ -33,8 +33,8 @@ #define ZERO SUN_RCONST(0.0) #define ONE SUN_RCONST(1.0) -int dae_res(sunrealtype t, N_Vector y, N_Vector ydot, N_Vector res, - void* user_data) +static int dae_res(sunrealtype t, N_Vector y, N_Vector ydot, N_Vector res, + void* user_data) { sunrealtype* ydot_data = N_VGetArrayPointer(ydot); sunrealtype* res_data = N_VGetArrayPointer(res); @@ -42,9 +42,9 @@ int dae_res(sunrealtype t, N_Vector y, N_Vector ydot, N_Vector res, return 0; } -int dae_jac(sunrealtype t, sunrealtype cj, N_Vector y, N_Vector yp, N_Vector rr, - SUNMatrix J, void* user_data, N_Vector tempv1, N_Vector tempv2, - N_Vector tempv3) +static int dae_jac(sunrealtype t, sunrealtype cj, N_Vector y, N_Vector yp, + N_Vector rr, SUNMatrix J, void* user_data, N_Vector tempv1, + N_Vector tempv2, N_Vector tempv3) { sunrealtype* J_data = SUNDenseMatrix_Data(J); J_data[0] = ONE; 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 7c50f7f5da..0775840110 100644 --- a/test/unit_tests/idas/CXX_serial/idas_test_getjac.cpp +++ b/test/unit_tests/idas/CXX_serial/idas_test_getjac.cpp @@ -105,7 +105,8 @@ static int yptrue(sunrealtype t, N_Vector yp) * [a b] * [ (-1 + u^2 - r(t)) ] + [ r'(t) ] - [ 2 u u'] = 0 * [c d] [ (-2 + v^2 - s(t)) ] [ s'(t) ] - [ 2 v v'] = 0 * ---------------------------------------------------------------------------*/ -int res(sunrealtype t, N_Vector y, N_Vector yp, N_Vector res, void* user_data) +static int res(sunrealtype t, N_Vector y, N_Vector yp, N_Vector res, + void* user_data) { sunrealtype* udata = (sunrealtype*)user_data; const sunrealtype a = udata[0]; @@ -137,8 +138,9 @@ int res(sunrealtype t, N_Vector y, N_Vector yp, N_Vector res, void* user_data) * [2 a u - 2 u' - 2 cj u 2 b v ] * [2 c u 2 d v - 2 v' - 2 cj v ] * ---------------------------------------------------------------------------*/ -int J(sunrealtype t, sunrealtype cj, N_Vector y, N_Vector yp, N_Vector res, - SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) +static int J(sunrealtype t, sunrealtype cj, N_Vector y, N_Vector yp, + N_Vector res, SUNMatrix J, void* user_data, N_Vector tmp1, + N_Vector tmp2, N_Vector tmp3) { sunrealtype* udata = (sunrealtype*)user_data; const sunrealtype a = udata[0]; @@ -167,8 +169,8 @@ int J(sunrealtype t, sunrealtype cj, N_Vector y, N_Vector yp, N_Vector res, // Custom linear solver solve function // ----------------------------------------------------------------------------- -int DenseSetupAndSolve(SUNLinearSolver S, SUNMatrix A, N_Vector x, N_Vector b, - sunrealtype tol) +static int DenseSetupAndSolve(SUNLinearSolver S, SUNMatrix A, N_Vector x, + N_Vector b, sunrealtype tol) { // Create a copy of the matrix for factorization SUNMatrix Acpy = SUNMatClone(A); @@ -196,7 +198,7 @@ int DenseSetupAndSolve(SUNLinearSolver S, SUNMatrix A, N_Vector x, N_Vector b, // ----------------------------------------------------------------------------- // Check function return flag -int check_flag(int flag, const std::string funcname) +static int check_flag(int flag, const std::string funcname) { if (!flag) { return 0; } if (flag < 0) { std::cerr << "ERROR: "; } @@ -206,7 +208,7 @@ int check_flag(int flag, const std::string funcname) } // Check if a function returned a NULL pointer -int check_ptr(void* ptr, const std::string funcname) +static int check_ptr(void* ptr, const std::string funcname) { if (ptr) { return 0; } std::cerr << "ERROR: " << funcname << " returned NULL" << std::endl; 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 2860e2e511..95f91c331d 100644 --- a/test/unit_tests/idas/CXX_serial/idas_test_kpr.hpp +++ b/test/unit_tests/idas/CXX_serial/idas_test_kpr.hpp @@ -123,7 +123,7 @@ static int true_sol_p(sunrealtype t, sunrealtype* up, sunrealtype* vp) // ----------------------------------------------------------------------------- // Check function return flag -int check_flag(int flag, const string funcname) +static int check_flag(int flag, const string funcname) { if (!flag) { return 0; } if (flag < 0) { cerr << "ERROR: "; } @@ -132,7 +132,7 @@ int check_flag(int flag, const string funcname) } // Check if a function returned a NULL pointer -int check_ptr(void* ptr, const string funcname) +static int check_ptr(void* ptr, const string funcname) { if (ptr) { return 0; } cerr << "ERROR: " << funcname << " returned NULL" << endl; @@ -187,7 +187,7 @@ inline void find_arg(vector& args, const string key, bool& dest, } // Print command line options -void InputHelp() +static void InputHelp() { cout << endl; cout << "Command line options:" << endl; @@ -205,7 +205,7 @@ void InputHelp() cout << " --nout : number of outputs\n"; } -int ReadInputs(vector& args, TestOptions& opts, SUNContext ctx) +static int ReadInputs(vector& args, TestOptions& opts, SUNContext ctx) { if (find(args.begin(), args.end(), "--help") != args.end()) { 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 b647c9fd8e..3303a390a8 100644 --- a/test/unit_tests/idas/C_serial/idas_test_tstop.c +++ b/test/unit_tests/idas/C_serial/idas_test_tstop.c @@ -33,8 +33,8 @@ #define ZERO SUN_RCONST(0.0) #define ONE SUN_RCONST(1.0) -int dae_res(sunrealtype t, N_Vector y, N_Vector ydot, N_Vector res, - void* user_data) +static int dae_res(sunrealtype t, N_Vector y, N_Vector ydot, N_Vector res, + void* user_data) { sunrealtype* ydot_data = N_VGetArrayPointer(ydot); sunrealtype* res_data = N_VGetArrayPointer(res); @@ -42,9 +42,9 @@ int dae_res(sunrealtype t, N_Vector y, N_Vector ydot, N_Vector res, return 0; } -int dae_jac(sunrealtype t, sunrealtype cj, N_Vector y, N_Vector yp, N_Vector rr, - SUNMatrix J, void* user_data, N_Vector tempv1, N_Vector tempv2, - N_Vector tempv3) +static int dae_jac(sunrealtype t, sunrealtype cj, N_Vector y, N_Vector yp, + N_Vector rr, SUNMatrix J, void* user_data, N_Vector tempv1, + N_Vector tempv2, N_Vector tempv3) { sunrealtype* J_data = SUNDenseMatrix_Data(J); J_data[0] = ONE; 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 67185076a6..cb3abe9da2 100644 --- a/test/unit_tests/kinsol/CXX_serial/kin_test_getjac.cpp +++ b/test/unit_tests/kinsol/CXX_serial/kin_test_getjac.cpp @@ -83,7 +83,7 @@ * x^2 - 81(y-0.9)^2 + sin(z) + 1.06 = 0 * exp(-x(y-1)) + 20z + (10 pi - 3)/3 = 0 * ---------------------------------------------------------------------------*/ -int res(N_Vector uu, N_Vector fuu, void* user_data) +static int res(N_Vector uu, N_Vector fuu, void* user_data) { /* Get vector data arrays */ sunrealtype* udata = N_VGetArrayPointer(uu); @@ -108,8 +108,8 @@ int res(N_Vector uu, N_Vector fuu, void* user_data) * [ exp(-x(y-1))(1-y) -exp(-x(y-1))x 20 ] * ---------------------------------------------------------------------------*/ -int J(N_Vector uu, N_Vector fuu, SUNMatrix J, void* user_data, N_Vector tmp1, - N_Vector tmp2) +static int J(N_Vector uu, N_Vector fuu, SUNMatrix J, void* user_data, + N_Vector tmp1, N_Vector tmp2) { sunrealtype* udata = N_VGetArrayPointer(uu); sunrealtype* Jdata = SUNDenseMatrix_Data(J); @@ -140,8 +140,8 @@ int J(N_Vector uu, N_Vector fuu, SUNMatrix J, void* user_data, N_Vector tmp1, // Custom linear solver solve function // ----------------------------------------------------------------------------- -int DenseSetupAndSolve(SUNLinearSolver S, SUNMatrix A, N_Vector x, N_Vector b, - sunrealtype tol) +static int DenseSetupAndSolve(SUNLinearSolver S, SUNMatrix A, N_Vector x, + N_Vector b, sunrealtype tol) { // Create a copy of the matrix for factorization SUNMatrix Acpy = SUNMatClone(A); @@ -169,7 +169,7 @@ int DenseSetupAndSolve(SUNLinearSolver S, SUNMatrix A, N_Vector x, N_Vector b, // ----------------------------------------------------------------------------- // Check function return flag -int check_flag(int flag, const std::string funcname) +static int check_flag(int flag, const std::string funcname) { if (!flag) { return 0; } if (flag < 0) { std::cerr << "ERROR: "; } @@ -179,7 +179,7 @@ int check_flag(int flag, const std::string funcname) } // Check if a function returned a NULL pointer -int check_ptr(void* ptr, const std::string funcname) +static int check_ptr(void* ptr, const std::string funcname) { if (ptr) { return 0; } std::cerr << "ERROR: " << funcname << " returned NULL" << std::endl; diff --git a/test/unit_tests/profiling/test_profiling.cpp b/test/unit_tests/profiling/test_profiling.cpp index 8b4bcfc820..0db4c3e101 100644 --- a/test/unit_tests/profiling/test_profiling.cpp +++ b/test/unit_tests/profiling/test_profiling.cpp @@ -23,7 +23,7 @@ #include "sundials/sundials_profiler.h" #include "sundials/sundials_types.h" -int sleep(SUNProfiler prof, int sec, double* chrono) +static int sleep(SUNProfiler prof, int sec, double* chrono) { auto begin = std::chrono::steady_clock::now(); @@ -43,7 +43,7 @@ int sleep(SUNProfiler prof, int sec, double* chrono) return 0; } -int print_timings(SUNProfiler prof) +static int print_timings(SUNProfiler prof) { // Output timing in default (table) format int flag = SUNProfiler_Print(prof, stdout); diff --git a/test/unit_tests/sundials/reductions/test_reduction_operators.cpp b/test/unit_tests/sundials/reductions/test_reduction_operators.cpp index 4e7601def4..bda983b0dc 100644 --- a/test/unit_tests/sundials/reductions/test_reduction_operators.cpp +++ b/test/unit_tests/sundials/reductions/test_reduction_operators.cpp @@ -22,7 +22,7 @@ using namespace sundials::reductions; using namespace sundials::reductions::impl; -int testPlusWithInts() +static int testPlusWithInts() { const std::string testStr = "Running testPlusWithInts"; @@ -41,7 +41,7 @@ int testPlusWithInts() return !pass; } -int testPlusWithDoubles() +static int testPlusWithDoubles() { const std::string testStr = "Running testPlusWithDoubles"; @@ -60,7 +60,7 @@ int testPlusWithDoubles() return !pass; } -int testMaximumWithInts() +static int testMaximumWithInts() { const std::string testStr = "Running testMaximumWithInts"; @@ -83,7 +83,7 @@ int testMaximumWithInts() return !pass; } -int testMaximumWithDoubles() +static int testMaximumWithDoubles() { const std::string testStr = "Running testMaximumWithDoubles"; @@ -106,7 +106,7 @@ int testMaximumWithDoubles() return !pass; } -int testMinimumWithInts() +static int testMinimumWithInts() { const std::string testStr = "Running testMinimumWithInts"; @@ -129,7 +129,7 @@ int testMinimumWithInts() return !pass; } -int testMinimumWithDoubles() +static int testMinimumWithDoubles() { const std::string testStr = "Running testMinimumWithDoubles"; diff --git a/test/unit_tests/sunmemory/sys/test_sunmemory_sys.cpp b/test/unit_tests/sunmemory/sys/test_sunmemory_sys.cpp index 4fab019e00..2abba4d927 100644 --- a/test/unit_tests/sunmemory/sys/test_sunmemory_sys.cpp +++ b/test/unit_tests/sunmemory/sys/test_sunmemory_sys.cpp @@ -14,8 +14,8 @@ #include #include -int test_instance(SUNMemoryHelper helper, SUNMemoryType mem_type, - bool print_test_status) +static int test_instance(SUNMemoryHelper helper, SUNMemoryType mem_type, + bool print_test_status) { // Try and allocate some memory int N = 8; diff --git a/test/unit_tests/utilities/dumpstderr.hpp b/test/unit_tests/utilities/dumpstderr.hpp index 4df2e660f7..9d57384fcc 100644 --- a/test/unit_tests/utilities/dumpstderr.hpp +++ b/test/unit_tests/utilities/dumpstderr.hpp @@ -17,7 +17,7 @@ #include #include -std::string dumpstderr(SUNContext sunctx, const std::string& errfile) +static std::string dumpstderr(SUNContext sunctx, const std::string& errfile) { SUNLogger logger = NULL; SUNContext_GetLogger(sunctx, &logger);