From f7abeaf69a15286e38df31ca1767428504350ea7 Mon Sep 17 00:00:00 2001 From: David Gardner Date: Thu, 30 May 2024 09:07:27 -0700 Subject: [PATCH] Maintenance: Add Maybe Unused Macro (#491) Add `SUNDIALS_MAYBE_UNUSED` macro to suppresses warnings on unused entities. --- .clang-format | 2 +- .github/workflows/macos-latest.yml | 10 +++-- .github/workflows/ubuntu-clang-latest.yml | 31 +++++++++++---- CHANGELOG.md | 5 +++ benchmarks/CMakeLists.txt | 6 +++ cmake/SundialsSetupCompilers.cmake | 15 ++++++- doc/shared/RecentChanges.rst | 7 +++- examples/CMakeLists.txt | 6 +++ .../fixedpoint/test_sunnonlinsol_fixedpoint.c | 4 +- include/nvector/nvector_parallel.h | 6 +-- include/nvector/nvector_parhyp.h | 8 +++- include/nvector/nvector_petsc.h | 9 +++-- include/nvector/nvector_serial.h | 6 +-- include/sundials/sundials_config.in | 1 + src/arkode/arkode.c | 19 +++++---- src/arkode/arkode_adapt.c | 2 +- src/arkode/arkode_adapt_impl.h | 2 +- src/arkode/arkode_arkstep.c | 9 +++-- src/arkode/arkode_arkstep_nls.c | 3 +- src/arkode/arkode_bandpre.c | 9 +++-- src/arkode/arkode_bbdpre.c | 12 ++++-- src/arkode/arkode_erkstep.c | 6 ++- src/arkode/arkode_impl.h | 4 +- src/arkode/arkode_ls.c | 5 ++- src/arkode/arkode_mristep.c | 20 ++++++---- src/arkode/arkode_mristep_nls.c | 3 +- src/arkode/arkode_relaxation.c | 3 +- src/arkode/arkode_relaxation_impl.h | 3 +- src/arkode/arkode_sprkstep.c | 9 +++-- src/arkode/arkode_user_controller.c | 14 +++---- src/arkode/xbraid/arkode_xbraid.c | 8 ++-- src/cvode/cvode_bandpre.c | 9 +++-- src/cvode/cvode_bbdpre.c | 16 +++++--- src/cvode/cvode_diag.c | 13 ++++--- src/cvode/cvode_fused_stubs.c | 10 +++-- src/cvode/cvode_impl.h | 3 +- src/cvode/cvode_io.c | 4 ++ src/cvode/cvode_ls.c | 5 ++- src/cvodes/cvodes.c | 10 ++--- src/cvodes/cvodes_bandpre.c | 9 +++-- src/cvodes/cvodes_bbdpre.c | 16 +++++--- src/cvodes/cvodes_diag.c | 13 ++++--- src/cvodes/cvodes_impl.h | 6 ++- src/cvodes/cvodes_io.c | 2 + src/cvodes/cvodes_ls.c | 13 ++++--- src/cvodes/cvodes_nls_stg1.c | 3 +- src/ida/ida_bbdpre.c | 13 +++++-- src/ida/ida_impl.h | 4 +- src/ida/ida_ls.c | 5 ++- src/ida/ida_nls.c | 6 ++- src/idas/idas.c | 13 ++++--- src/idas/idas_bbdpre.c | 13 +++++-- src/idas/idas_impl.h | 4 +- src/idas/idas_ls.c | 5 ++- src/idas/idas_nls.c | 6 ++- src/idas/idas_nls_sim.c | 7 ++-- src/idas/idas_nls_stg.c | 7 ++-- src/kinsol/kinsol.c | 8 ++-- src/kinsol/kinsol_bbdpre.c | 12 ++++-- src/kinsol/kinsol_impl.h | 4 +- src/kinsol/kinsol_ls.c | 8 ++-- src/nvector/manyvector/nvector_manyvector.c | 10 +++-- src/nvector/mpiplusx/nvector_mpiplusx.c | 6 +-- src/nvector/openmp/nvector_openmp.c | 13 +++++-- src/nvector/parallel/nvector_parallel.c | 17 ++++++-- src/nvector/parhyp/nvector_parhyp.c | 20 ++++++---- src/nvector/petsc/nvector_petsc.c | 24 ++++++++---- src/nvector/pthreads/nvector_pthreads.c | 11 +++--- src/nvector/serial/nvector_serial.c | 15 ++++++- src/nvector/trilinos/nvector_trilinos.cpp | 9 +++-- .../imexgus/sunadaptcontroller_imexgus.c | 9 +++-- .../soderlind/sunadaptcontroller_soderlind.c | 9 +++-- src/sundials/sundials_context.c | 9 ++++- src/sundials/sundials_errors.c | 18 +++++---- src/sundials/sundials_hashmap.c | 10 +++-- src/sundials/sundials_logger.c | 22 +++++++++-- src/sundials/sundials_macros.h | 39 +++++++++++++++++++ src/sundials/sundials_mpi_errors.c | 10 +++-- src/sundials/sundials_nvector.c | 8 +++- src/sundials/sundials_profiler.c | 25 ++++++------ src/sundials/sundials_utils.h | 2 +- src/sundials/sundials_xbraid.c | 26 +++++++------ src/sunlinsol/band/sunlinsol_band.c | 12 ++++-- src/sunlinsol/dense/sunlinsol_dense.c | 13 ++++--- src/sunlinsol/klu/sunlinsol_klu.c | 14 ++++--- .../lapackband/sunlinsol_lapackband.c | 9 +++-- .../lapackdense/sunlinsol_lapackdense.c | 9 +++-- src/sunlinsol/pcg/sunlinsol_pcg.c | 14 ++++--- src/sunlinsol/spbcgs/sunlinsol_spbcgs.c | 12 +++--- src/sunlinsol/spfgmr/sunlinsol_spfgmr.c | 12 +++--- src/sunlinsol/spgmr/sunlinsol_spgmr.c | 12 +++--- src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c | 12 +++--- .../superludist/sunlinsol_superludist.c | 20 ++++++---- src/sunlinsol/superlumt/sunlinsol_superlumt.c | 11 ++++-- src/sunmatrix/band/sunmatrix_band.c | 11 +++++- src/sunmatrix/dense/sunmatrix_dense.c | 11 +++++- src/sunmatrix/slunrloc/sunmatrix_slunrloc.c | 11 +++++- src/sunmatrix/sparse/sunmatrix_sparse.c | 11 +++++- src/sunmemory/system/sundials_system_memory.c | 24 ++++++------ .../fixedpoint/sunnonlinsol_fixedpoint.c | 11 ++++-- src/sunnonlinsol/newton/sunnonlinsol_newton.c | 8 +++- .../petscsnes/sunnonlinsol_petscsnes.c | 20 ++++++---- test/unit_tests/CMakeLists.txt | 6 +++ 103 files changed, 715 insertions(+), 354 deletions(-) create mode 100644 src/sundials/sundials_macros.h diff --git a/.clang-format b/.clang-format index 2ecb664e26..8f5802e45d 100644 --- a/.clang-format +++ b/.clang-format @@ -79,7 +79,7 @@ EmptyLineAfterAccessModifier : Never EmptyLineBeforeAccessModifier : Always ExperimentalAutoDetectBinPacking : false FixNamespaceComments : true -IncludeBlocks : Regroup +IncludeBlocks : Preserve IncludeCategories : - Regex : '^(<|"(gtest|gmock|isl|json)/)' Priority : 1 diff --git a/.github/workflows/macos-latest.yml b/.github/workflows/macos-latest.yml index 5b78697c81..1c60778d37 100644 --- a/.github/workflows/macos-latest.yml +++ b/.github/workflows/macos-latest.yml @@ -25,9 +25,13 @@ jobs: - uses: actions/checkout@v3 - name: Configure CMake - # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. - # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + # Configure CMake in a 'build' subdirectory. + run: | + cmake \ + -B ${{github.workspace}}/build \ + -D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ + -D ENABLE_ALL_WARNINGS=ON \ + -D ENABLE_WARNINGS_AS_ERRORS=ON - name: Build # Build your program with the given configuration diff --git a/.github/workflows/ubuntu-clang-latest.yml b/.github/workflows/ubuntu-clang-latest.yml index d2f3fcae0e..b78a7cb7cd 100644 --- a/.github/workflows/ubuntu-clang-latest.yml +++ b/.github/workflows/ubuntu-clang-latest.yml @@ -21,8 +21,9 @@ jobs: fail-fast: false max-parallel: 2 matrix: - # 2 is what all other builds use (its the default), so skip it here - logging_level: [0, 1, 3, 4, 5] + # Level 2 is also used in other builds (it's the default) but include it + # here to ensure it's tested with all warning flags + logging_level: [0, 1, 2, 3, 4, 5] steps: - name: Install LLVM and Clang @@ -33,9 +34,16 @@ jobs: - uses: actions/checkout@v3 - name: Configure CMake - # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. - # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_C_COMPILER=$(which clang) -DCMAKE_CXX_COMPILER=$(which clang++) -DSUNDIALS_LOGGING_LEVEL=${{matrix.logging_level}} + # Configure CMake in a 'build' subdirectory. + run: | + cmake \ + -B ${{github.workspace}}/build \ + -D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ + -D CMAKE_C_COMPILER=$(which clang) \ + -D CMAKE_CXX_COMPILER=$(which clang++) \ + -D SUNDIALS_LOGGING_LEVEL=${{matrix.logging_level}} \ + -D ENABLE_ALL_WARNINGS=ON \ + -D ENABLE_WARNINGS_AS_ERRORS=ON - name: Build # Build your program with the given configuration @@ -57,9 +65,16 @@ jobs: - uses: actions/checkout@v3 - name: Configure CMake - # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. - # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_C_COMPILER=$(which clang) -DCMAKE_CXX_COMPILER=$(which clang++) -DSUNDIALS_BUILD_WITH_PROFILING=${{matrix.profiling}} + # Configure CMake in a 'build' subdirectory. + run: | + cmake \ + -B ${{github.workspace}}/build \ + -D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ + -D CMAKE_C_COMPILER=$(which clang) \ + -D CMAKE_CXX_COMPILER=$(which clang++) \ + -D SUNDIALS_BUILD_WITH_PROFILING=${{matrix.profiling}} \ + -D ENABLE_ALL_WARNINGS=ON \ + -D ENABLE_WARNINGS_AS_ERRORS=ON - name: Build # Build your program with the given configuration diff --git a/CHANGELOG.md b/CHANGELOG.md index b6908a7af0..fbb107486f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -118,6 +118,11 @@ Deprecated the `ARKStepSetOptimalParams` function. Since this function does not ARKODE-wide equivalent, instructions have been added to the user guide for how to retain the current functionality using other user-callable functions. +The unsupported implementations of `N_VGetArrayPointer` and `N_VSetArrayPointer` +for the *hypre* and PETSc vectors are now deprecated. Users should access the +underlying wrapped external library vector objects instead with +`N_VGetVector_ParHyp` and `N_VGetVector_Petsc`, respectively. + ## Changes to SUNDIALS in release v7.0.0 ### Major Feature diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index a70315ea5b..980e1e230d 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -22,6 +22,12 @@ endif() sundials_option(BENCHMARK_NVECTOR BOOL "NVector benchmarks are on" ON) +# Disable some warnings for benchmarks +if(ENABLE_ALL_WARNINGS) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-parameter") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter") +endif() + #---------------------------------------- # Add specific benchmarks #---------------------------------------- diff --git a/cmake/SundialsSetupCompilers.cmake b/cmake/SundialsSetupCompilers.cmake index 59dea2d019..f4b226e96d 100644 --- a/cmake/SundialsSetupCompilers.cmake +++ b/cmake/SundialsSetupCompilers.cmake @@ -93,8 +93,8 @@ if(ENABLE_ALL_WARNINGS) 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_C_FLAGS "-Wall -Wpedantic -Wextra -Wshadow ${CMAKE_C_FLAGS}") + set(CMAKE_CXX_FLAGS "-Wall -Wpedantic -Wextra -Wshadow ${CMAKE_CXX_FLAGS}") # TODO(DJG): Add -fcheck=all,no-pointer,no-recursion once Jenkins is updated # to use gfortran > 5.5 which segfaults with -fcheck=array-temps,bounds,do,mem @@ -218,6 +218,17 @@ if(NOT (SUNDIALS_C_COMPILER_HAS_ATTRIBUTE_ASSUME OR SUNDIALS_C_COMPILER_HAS_BUIL " SUNDIALS_C_COMPILER_HAS_ASSUME) endif() +# --------------------------------------------------------------- +# Check for unused extension +# --------------------------------------------------------------- + +check_c_source_compiles(" + int main(void) { + __attribute__((unused)) double a = 0.0; + return 0; + } +" SUNDIALS_C_COMPILER_HAS_ATTRIBUTE_UNUSED) + # --------------------------------------------------------------- # Check for POSIX timers # --------------------------------------------------------------- diff --git a/doc/shared/RecentChanges.rst b/doc/shared/RecentChanges.rst index d11c3b24d4..68ac8d6c4c 100644 --- a/doc/shared/RecentChanges.rst +++ b/doc/shared/RecentChanges.rst @@ -115,4 +115,9 @@ ARKODE-wide functions. Deprecated the `ARKStepSetOptimalParams` function. Since this function does not have an ARKODE-wide equivalent, instructions have been added to the user guide for how -to retain the current functionality using other user-callable functions. \ No newline at end of file +to retain the current functionality using other user-callable functions. + +The unsupported implementations of ``N_VGetArrayPointer`` and +``N_VSetArrayPointer`` for the *hypre* and PETSc vectors are now deprecated. +Users should access the underlying wrapped external library vector objects +instead with ``N_VGetVector_ParHyp`` and ``N_VGetVector_Petsc``, respectively. diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index bb9df6250f..a342a109eb 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -31,6 +31,12 @@ foreach(lang ${_SUNDIALS_ENABLED_LANGS}) endif() endforeach() +# Disable some warnings for examples +if(ENABLE_ALL_WARNINGS) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-parameter") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter") +endif() + # Set variables used in generating CMake and Makefiles for examples if(EXAMPLES_INSTALL) diff --git a/examples/sunnonlinsol/fixedpoint/test_sunnonlinsol_fixedpoint.c b/examples/sunnonlinsol/fixedpoint/test_sunnonlinsol_fixedpoint.c index 511ca7a901..440739e147 100644 --- a/examples/sunnonlinsol/fixedpoint/test_sunnonlinsol_fixedpoint.c +++ b/examples/sunnonlinsol/fixedpoint/test_sunnonlinsol_fixedpoint.c @@ -123,8 +123,8 @@ int main(int argc, char* argv[]) sunrealtype* data = NULL; SUNContext sunctx = NULL; - /* Check if a acceleration/dampling values were provided */ - if (argc > 1) { maa = (long int)atoi(argv[1]); } + /* Check if a acceleration/damping values were provided */ + if (argc > 1) { maa = atoi(argv[1]); } if (argc > 2) { damping = (sunrealtype)atof(argv[2]); } /* Print problem description */ diff --git a/include/nvector/nvector_parallel.h b/include/nvector/nvector_parallel.h index e05e4c7ef8..385ca528ed 100644 --- a/include/nvector/nvector_parallel.h +++ b/include/nvector/nvector_parallel.h @@ -117,10 +117,8 @@ void N_VPrint_Parallel(N_Vector v); SUNDIALS_EXPORT void N_VPrintFile_Parallel(N_Vector v, FILE* outfile); -static inline N_Vector_ID N_VGetVectorID_Parallel(N_Vector v) -{ - return SUNDIALS_NVEC_PARALLEL; -} +SUNDIALS_EXPORT +N_Vector_ID N_VGetVectorID_Parallel(N_Vector v); SUNDIALS_EXPORT N_Vector N_VCloneEmpty_Parallel(N_Vector w); diff --git a/include/nvector/nvector_parhyp.h b/include/nvector/nvector_parhyp.h index a7c7ced8a1..b7f8271fb7 100644 --- a/include/nvector/nvector_parhyp.h +++ b/include/nvector/nvector_parhyp.h @@ -96,8 +96,6 @@ SUNDIALS_EXPORT N_Vector N_VClone_ParHyp(N_Vector w); SUNDIALS_EXPORT void N_VDestroy_ParHyp(N_Vector v); SUNDIALS_EXPORT void N_VSpace_ParHyp(N_Vector v, sunindextype* lrw, sunindextype* liw); -SUNDIALS_EXPORT sunrealtype* N_VGetArrayPointer_ParHyp(N_Vector v); -SUNDIALS_EXPORT void N_VSetArrayPointer_ParHyp(sunrealtype* v_data, N_Vector v); SUNDIALS_EXPORT MPI_Comm N_VGetCommunicator_ParHyp(N_Vector v); SUNDIALS_EXPORT sunindextype N_VGetLength_ParHyp(N_Vector v); @@ -214,6 +212,12 @@ SUNErrCode N_VEnableLinearCombinationVectorArray_ParHyp(N_Vector v, SUNDIALS_EXPORT SUNErrCode N_VEnableDotProdMultiLocal_ParHyp(N_Vector v, sunbooleantype tf); +SUNDIALS_DEPRECATED_EXPORT_MSG("Not supported, use N_VGetVector_ParHyp") +sunrealtype* N_VGetArrayPointer_ParHyp(N_Vector v); + +SUNDIALS_DEPRECATED_EXPORT_MSG("Not supported, use N_VGetVector_ParHyp") +void N_VSetArrayPointer_ParHyp(sunrealtype* v_data, N_Vector v); + #ifdef __cplusplus } #endif diff --git a/include/nvector/nvector_petsc.h b/include/nvector/nvector_petsc.h index 1fa3b536b2..8605cb130e 100644 --- a/include/nvector/nvector_petsc.h +++ b/include/nvector/nvector_petsc.h @@ -76,8 +76,6 @@ SUNDIALS_EXPORT N_Vector N_VNewEmpty_Petsc(MPI_Comm comm, SUNDIALS_EXPORT N_Vector N_VMake_Petsc(Vec v, SUNContext sunctx); -SUNDIALS_EXPORT sunrealtype* N_VGetArrayPointer_Petsc(N_Vector v); - SUNDIALS_EXPORT Vec N_VGetVector_Petsc(N_Vector v); SUNDIALS_EXPORT void N_VSetVector_Petsc(N_Vector v, Vec p); @@ -93,7 +91,6 @@ SUNDIALS_EXPORT N_Vector N_VClone_Petsc(N_Vector w); SUNDIALS_EXPORT void N_VDestroy_Petsc(N_Vector v); SUNDIALS_EXPORT void N_VSpace_Petsc(N_Vector v, sunindextype* lrw, sunindextype* liw); -SUNDIALS_EXPORT void N_VSetArrayPointer_Petsc(sunrealtype* v_data, N_Vector v); SUNDIALS_EXPORT MPI_Comm N_VGetCommunicator_Petsc(N_Vector v); SUNDIALS_EXPORT sunindextype N_VGetLength_Petsc(N_Vector v); @@ -208,6 +205,12 @@ SUNErrCode N_VEnableLinearCombinationVectorArray_Petsc(N_Vector v, SUNDIALS_EXPORT SUNErrCode N_VEnableDotProdMultiLocal_Petsc(N_Vector v, sunbooleantype tf); +SUNDIALS_DEPRECATED_EXPORT_MSG("Not supported, use N_VGetVector_Petsc") +sunrealtype* N_VGetArrayPointer_Petsc(N_Vector v); + +SUNDIALS_DEPRECATED_EXPORT_MSG("Not supported, use N_VGetVector_Petsc") +void N_VSetArrayPointer_Petsc(sunrealtype* v_data, N_Vector v); + #ifdef __cplusplus } #endif diff --git a/include/nvector/nvector_serial.h b/include/nvector/nvector_serial.h index bcbc995f2e..988e090af2 100644 --- a/include/nvector/nvector_serial.h +++ b/include/nvector/nvector_serial.h @@ -102,10 +102,8 @@ void N_VPrint_Serial(N_Vector v); SUNDIALS_EXPORT void N_VPrintFile_Serial(N_Vector v, FILE* outfile); -static inline N_Vector_ID N_VGetVectorID_Serial(N_Vector v) -{ - return SUNDIALS_NVEC_SERIAL; -} +SUNDIALS_EXPORT +N_Vector_ID N_VGetVectorID_Serial(N_Vector v); SUNDIALS_EXPORT N_Vector N_VCloneEmpty_Serial(N_Vector w); diff --git a/include/sundials/sundials_config.in b/include/sundials/sundials_config.in index 99923d1e81..def1a87414 100644 --- a/include/sundials/sundials_config.in +++ b/include/sundials/sundials_config.in @@ -60,6 +60,7 @@ #cmakedefine SUNDIALS_C_COMPILER_HAS_ATTRIBUTE_ASSUME #cmakedefine SUNDIALS_C_COMPILER_HAS_BUILTIN_ASSUME #cmakedefine SUNDIALS_C_COMPILER_HAS_ASSUME +#cmakedefine SUNDIALS_C_COMPILER_HAS_ATTRIBUTE_UNUSED /* Define precision of SUNDIALS data type 'sunrealtype' * Depending on the precision level, one of the following diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index bc7a449ef4..50735b32ea 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -642,10 +642,13 @@ int ARKodeEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, sunrealtype troundoff, nrm; sunbooleantype inactive_roots; sunrealtype dsm; - int nflag, attempts, ncf, nef, constrfails; + int nflag, ncf, nef, constrfails; int relax_fails; ARKodeMem ark_mem; + /* used only with debugging logging */ + SUNDIALS_MAYBE_UNUSED int attempts; + /* Check and process inputs */ /* Check if ark_mem exists */ @@ -897,7 +900,7 @@ int ARKodeEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, - on fatal error, returns negative error flag */ if (ark_mem->relax_enabled && (kflag == ARK_SUCCESS)) { - kflag = arkRelax(ark_mem, &relax_fails, &dsm, &nflag); + kflag = arkRelax(ark_mem, &relax_fails, &dsm); if (kflag < 0) { break; } } @@ -2751,7 +2754,8 @@ int arkEwtSetSV(N_Vector ycur, N_Vector weight, void* arkode_mem) a fixed step size to avoid a potential too much error return to the user. ---------------------------------------------------------------*/ -int arkEwtSetSmallReal(N_Vector ycur, N_Vector weight, void* arkode_mem) +int arkEwtSetSmallReal(SUNDIALS_MAYBE_UNUSED N_Vector ycur, N_Vector weight, + SUNDIALS_MAYBE_UNUSED void* arkode_mem) { N_VConst(SUN_SMALL_REAL, weight); return (ARK_SUCCESS); @@ -2804,7 +2808,9 @@ int arkRwtSetSV(ARKodeMem ark_mem, N_Vector My, N_Vector weight) /*--------------------------------------------------------------- arkExpStab is the default explicit stability estimation function ---------------------------------------------------------------*/ -int arkExpStab(N_Vector y, sunrealtype t, sunrealtype* hstab, void* data) +int arkExpStab(SUNDIALS_MAYBE_UNUSED N_Vector y, + SUNDIALS_MAYBE_UNUSED sunrealtype t, sunrealtype* hstab, + SUNDIALS_MAYBE_UNUSED void* data) { /* explicit stability not used by default, set to zero to disable */ @@ -3106,7 +3112,6 @@ int arkCheckTemporalError(ARKodeMem ark_mem, int* nflagPtr, int* nefPtr, { int retval; sunrealtype ttmp; - long int nsttmp; ARKodeHAdaptMem hadapt_mem; /* Access hadapt_mem structure */ @@ -3121,9 +3126,7 @@ int arkCheckTemporalError(ARKodeMem ark_mem, int* nflagPtr, int* nefPtr, /* consider change of step size for next step attempt (may be larger/smaller than current step, depending on dsm) */ ttmp = (dsm <= ONE) ? ark_mem->tn + ark_mem->h : ark_mem->tn; - nsttmp = (dsm <= ONE) ? ark_mem->nst + 1 : ark_mem->nst; - retval = arkAdapt(ark_mem, hadapt_mem, ark_mem->ycur, ttmp, ark_mem->h, dsm, - nsttmp); + retval = arkAdapt(ark_mem, hadapt_mem, ark_mem->ycur, ttmp, ark_mem->h, dsm); if (retval != ARK_SUCCESS) { return (ARK_ERR_FAILURE); } /* if we've made it here then no nonrecoverable failures occurred; someone above diff --git a/src/arkode/arkode_adapt.c b/src/arkode/arkode_adapt.c index 5d6896a46f..7fef0ec2ae 100644 --- a/src/arkode/arkode_adapt.c +++ b/src/arkode/arkode_adapt.c @@ -92,7 +92,7 @@ void arkPrintAdaptMem(ARKodeHAdaptMem hadapt_mem, FILE* outfile) data structure. ---------------------------------------------------------------*/ int arkAdapt(ARKodeMem ark_mem, ARKodeHAdaptMem hadapt_mem, N_Vector ycur, - sunrealtype tcur, sunrealtype hcur, sunrealtype dsm, long int nst) + sunrealtype tcur, sunrealtype hcur, sunrealtype dsm) { int retval; sunrealtype h_acc, h_cfl, int_dir; diff --git a/src/arkode/arkode_adapt_impl.h b/src/arkode/arkode_adapt_impl.h index 3d86d9e385..7dd9460a1e 100644 --- a/src/arkode/arkode_adapt_impl.h +++ b/src/arkode/arkode_adapt_impl.h @@ -109,7 +109,7 @@ typedef struct ARKodeHAdaptMemRec ARKodeHAdaptMem arkAdaptInit(void); void arkPrintAdaptMem(ARKodeHAdaptMem hadapt_mem, FILE* outfile); int arkAdapt(ARKodeMem ark_mem, ARKodeHAdaptMem hadapt_mem, N_Vector ycur, - sunrealtype tcur, sunrealtype hcur, sunrealtype dsm, long int nst); + sunrealtype tcur, sunrealtype hcur, sunrealtype dsm); #ifdef __cplusplus } diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index f5f61f5e38..1c1a7dc92f 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -387,8 +387,10 @@ int ARKStepCreateMRIStepInnerStepper(void* inner_arkode_mem, This routine resizes the memory within the ARKStep module. ---------------------------------------------------------------*/ -int arkStep_Resize(ARKodeMem ark_mem, N_Vector y0, sunrealtype hscale, - sunrealtype t0, ARKVecResizeFn resize, void* resize_data) +int arkStep_Resize(ARKodeMem ark_mem, N_Vector y0, + SUNDIALS_MAYBE_UNUSED sunrealtype hscale, + SUNDIALS_MAYBE_UNUSED sunrealtype t0, ARKVecResizeFn resize, + void* resize_data) { ARKodeARKStepMem step_mem; SUNNonlinearSolver NLS; @@ -3089,7 +3091,8 @@ int arkStep_ComputeSolutions_MassFixed(ARKodeMem ark_mem, sunrealtype* dsmPtr) ODE IVP. ----------------------------------------------------------------------------*/ -int arkStep_MRIStepInnerEvolve(MRIStepInnerStepper stepper, sunrealtype t0, +int arkStep_MRIStepInnerEvolve(MRIStepInnerStepper stepper, + SUNDIALS_MAYBE_UNUSED sunrealtype t0, sunrealtype tout, N_Vector y) { void* arkode_mem; /* arkode memory */ diff --git a/src/arkode/arkode_arkstep_nls.c b/src/arkode/arkode_arkstep_nls.c index 7cfe1f14f1..d11f69d518 100644 --- a/src/arkode/arkode_arkstep_nls.c +++ b/src/arkode/arkode_arkstep_nls.c @@ -872,7 +872,8 @@ int arkStep_NlsFPFunction_MassTDep(N_Vector zcor, N_Vector g, void* arkode_mem) implicit, then we just declare 'success' no matter what is provided. ---------------------------------------------------------------*/ -int arkStep_NlsConvTest(SUNNonlinearSolver NLS, N_Vector y, N_Vector del, +int arkStep_NlsConvTest(SUNNonlinearSolver NLS, + SUNDIALS_MAYBE_UNUSED N_Vector y, N_Vector del, sunrealtype tol, N_Vector ewt, void* arkode_mem) { /* temporary variables */ diff --git a/src/arkode/arkode_bandpre.c b/src/arkode/arkode_bandpre.c index ad1d72e2b1..5355311d98 100644 --- a/src/arkode/arkode_bandpre.c +++ b/src/arkode/arkode_bandpre.c @@ -410,9 +410,12 @@ static int ARKBandPrecSetup(sunrealtype t, N_Vector y, N_Vector fy, The value returned by the ARKBandPrecSolve function is always 0, indicating success. ---------------------------------------------------------------*/ -static int ARKBandPrecSolve(sunrealtype t, N_Vector y, N_Vector fy, N_Vector r, - N_Vector z, sunrealtype gamma, sunrealtype delta, - int lr, void* bp_data) +static int ARKBandPrecSolve(SUNDIALS_MAYBE_UNUSED sunrealtype t, + SUNDIALS_MAYBE_UNUSED N_Vector y, + SUNDIALS_MAYBE_UNUSED N_Vector fy, N_Vector r, + N_Vector z, SUNDIALS_MAYBE_UNUSED sunrealtype gamma, + SUNDIALS_MAYBE_UNUSED sunrealtype delta, + SUNDIALS_MAYBE_UNUSED int lr, void* bp_data) { ARKBandPrecData pdata; int retval; diff --git a/src/arkode/arkode_bbdpre.c b/src/arkode/arkode_bbdpre.c index aa2c2fb652..f6445c8ede 100644 --- a/src/arkode/arkode_bbdpre.c +++ b/src/arkode/arkode_bbdpre.c @@ -426,7 +426,8 @@ int ARKBBDPrecGetNumGfnEvals(void* arkode_mem, long int* ngevalsBBDP) 0 if successful, 1 for a recoverable error (step will be retried). ---------------------------------------------------------------*/ -static int ARKBBDPrecSetup(sunrealtype t, N_Vector y, N_Vector fy, +static int ARKBBDPrecSetup(sunrealtype t, N_Vector y, + SUNDIALS_MAYBE_UNUSED N_Vector fy, sunbooleantype jok, sunbooleantype* jcurPtr, sunrealtype gamma, void* bbd_data) { @@ -517,9 +518,12 @@ static int ARKBBDPrecSetup(sunrealtype t, N_Vector y, N_Vector fy, The value returned by the ARKBBDPrecSolve function is the same as the value returned from the linear solver object. ---------------------------------------------------------------*/ -static int ARKBBDPrecSolve(sunrealtype t, N_Vector y, N_Vector fy, N_Vector r, - N_Vector z, sunrealtype gamma, sunrealtype delta, - int lr, void* bbd_data) +static int ARKBBDPrecSolve(SUNDIALS_MAYBE_UNUSED sunrealtype t, + SUNDIALS_MAYBE_UNUSED N_Vector y, + SUNDIALS_MAYBE_UNUSED N_Vector fy, N_Vector r, + N_Vector z, SUNDIALS_MAYBE_UNUSED sunrealtype gamma, + SUNDIALS_MAYBE_UNUSED sunrealtype delta, + SUNDIALS_MAYBE_UNUSED int lr, void* bbd_data) { int retval; ARKBBDPrecData pdata; diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index 1da8125942..bb244a80a9 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -216,8 +216,10 @@ int ERKStepReInit(void* arkode_mem, ARKRhsFn f, sunrealtype t0, N_Vector y0) This routine resizes the memory within the ERKStep module. ---------------------------------------------------------------*/ -int erkStep_Resize(ARKodeMem ark_mem, N_Vector y0, sunrealtype hscale, - sunrealtype t0, ARKVecResizeFn resize, void* resize_data) +int erkStep_Resize(ARKodeMem ark_mem, N_Vector y0, + SUNDIALS_MAYBE_UNUSED sunrealtype hscale, + SUNDIALS_MAYBE_UNUSED sunrealtype t0, ARKVecResizeFn resize, + void* resize_data) { ARKodeERKStepMem step_mem; sunindextype lrw1, liw1, lrw_diff, liw_diff; diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h index f5a91d468c..80edfb6829 100644 --- a/src/arkode/arkode_impl.h +++ b/src/arkode/arkode_impl.h @@ -17,11 +17,12 @@ #ifndef _ARKODE_IMPL_H #define _ARKODE_IMPL_H +#include + #include #include #include #include -#include #include #include #include @@ -33,6 +34,7 @@ #include "arkode_root_impl.h" #include "arkode_types_impl.h" #include "sundials_logger_impl.h" +#include "sundials_macros.h" #ifdef __cplusplus /* wrapper to enable C++ usage */ extern "C" { diff --git a/src/arkode/arkode_ls.c b/src/arkode/arkode_ls.c index 7032f62e40..646b87ab6f 100644 --- a/src/arkode/arkode_ls.c +++ b/src/arkode/arkode_ls.c @@ -2547,7 +2547,8 @@ int arkLsMPSolve(void* arkode_mem, N_Vector r, N_Vector z, sunrealtype tol, int approximation routines. ---------------------------------------------------------------*/ int arkLsDQJac(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix Jac, - void* arkode_mem, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) + void* arkode_mem, N_Vector tmp1, N_Vector tmp2, + SUNDIALS_MAYBE_UNUSED N_Vector tmp3) { ARKodeMem ark_mem; ARKLsMem arkls_mem; @@ -2774,7 +2775,7 @@ int arkLsBandDQJac(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix Jac, } /* Evaluate f with incremented y */ - retval = fi(ark_mem->tcur, ytemp, ftemp, ark_mem->user_data); + retval = fi(t, ytemp, ftemp, ark_mem->user_data); arkls_mem->nfeDQ++; if (retval != 0) { break; } diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index ce77dde8d4..b4c727c506 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -347,8 +347,10 @@ int MRIStepReInit(void* arkode_mem, ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, This routine resizes the memory within the MRIStep module. ---------------------------------------------------------------*/ -int mriStep_Resize(ARKodeMem ark_mem, N_Vector y0, sunrealtype hscale, - sunrealtype t0, ARKVecResizeFn resize, void* resize_data) +int mriStep_Resize(ARKodeMem ark_mem, N_Vector y0, + SUNDIALS_MAYBE_UNUSED sunrealtype hscale, + SUNDIALS_MAYBE_UNUSED sunrealtype t0, ARKVecResizeFn resize, + void* resize_data) { ARKodeMRIStepMem step_mem; SUNNonlinearSolver NLS; @@ -743,7 +745,8 @@ void mriStep_PrintMem(ARKodeMem ark_mem, FILE* outfile) int mriStep_AttachLinsol(ARKodeMem ark_mem, ARKLinsolInitFn linit, ARKLinsolSetupFn lsetup, ARKLinsolSolveFn lsolve, ARKLinsolFreeFn lfree, - SUNLinearSolver_Type lsolve_type, void* lmem) + SUNDIALS_MAYBE_UNUSED SUNLinearSolver_Type lsolve_type, + void* lmem) { ARKodeMRIStepMem step_mem; int retval; @@ -2107,8 +2110,10 @@ int mriStep_StageERKNoFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, int is) and involves evolution of the fast time scale, in a fully-coupled fashion. ---------------------------------------------------------------*/ -int mriStep_StageDIRKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, int is, - int* nflagPtr) +int mriStep_StageDIRKFast(ARKodeMem ark_mem, + SUNDIALS_MAYBE_UNUSED ARKodeMRIStepMem step_mem, + SUNDIALS_MAYBE_UNUSED int is, + SUNDIALS_MAYBE_UNUSED int* nflagPtr) { #ifdef SUNDIALS_DEBUG printf(" MRIStep DIRK fast stage\n"); @@ -2239,8 +2244,9 @@ int mriStep_StageDIRKNoFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, ARK_SUCCESS -- successful evaluation ---------------------------------------------------------------*/ -int mriStep_ComputeInnerForcing(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, - int stage, sunrealtype cdiff) +int mriStep_ComputeInnerForcing(SUNDIALS_MAYBE_UNUSED ARKodeMem ark_mem, + ARKodeMRIStepMem step_mem, int stage, + sunrealtype cdiff) { sunrealtype rcdiff; int j, k, nmat, nstore, retval; diff --git a/src/arkode/arkode_mristep_nls.c b/src/arkode/arkode_mristep_nls.c index 4375806ade..39119403ad 100644 --- a/src/arkode/arkode_mristep_nls.c +++ b/src/arkode/arkode_mristep_nls.c @@ -556,7 +556,8 @@ int mriStep_NlsFPFunction(N_Vector zcor, N_Vector g, void* arkode_mem) implicit, then we just declare 'success' no matter what is provided. ---------------------------------------------------------------*/ -int mriStep_NlsConvTest(SUNNonlinearSolver NLS, N_Vector y, N_Vector del, +int mriStep_NlsConvTest(SUNNonlinearSolver NLS, + SUNDIALS_MAYBE_UNUSED N_Vector y, N_Vector del, sunrealtype tol, N_Vector ewt, void* arkode_mem) { /* temporary variables */ diff --git a/src/arkode/arkode_relaxation.c b/src/arkode/arkode_relaxation.c index b824bbfb9c..e2307448b9 100644 --- a/src/arkode/arkode_relaxation.c +++ b/src/arkode/arkode_relaxation.c @@ -857,8 +857,7 @@ int arkRelaxDestroy(ARKodeRelaxMem relax_mem) } /* Compute and apply relaxation, called by driver */ -int arkRelax(ARKodeMem ark_mem, int* relax_fails, sunrealtype* dsm_inout, - int* nflag_out) +int arkRelax(ARKodeMem ark_mem, int* relax_fails, sunrealtype* dsm_inout) { int retval; sunrealtype relax_val; diff --git a/src/arkode/arkode_relaxation_impl.h b/src/arkode/arkode_relaxation_impl.h index a8c9001ed0..57830d38ff 100644 --- a/src/arkode/arkode_relaxation_impl.h +++ b/src/arkode/arkode_relaxation_impl.h @@ -103,8 +103,7 @@ int arkRelaxCreate(ARKodeMem ark_mem, ARKRelaxFn relax_fn, ARKRelaxJacFn relax_jac_fn, ARKRelaxDeltaEFn delta_e_fn, ARKRelaxGetOrderFn get_order_fn); int arkRelaxDestroy(ARKodeRelaxMem relax_mem); -int arkRelax(ARKodeMem ark_mem, int* relax_fails, sunrealtype* dsm_inout, - int* nflag_out); +int arkRelax(ARKodeMem ark_mem, int* relax_fails, sunrealtype* dsm_inout); /* User Functions */ int arkRelaxPrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt); diff --git a/src/arkode/arkode_sprkstep.c b/src/arkode/arkode_sprkstep.c index b84bc328c1..0ae21c2741 100644 --- a/src/arkode/arkode_sprkstep.c +++ b/src/arkode/arkode_sprkstep.c @@ -246,8 +246,10 @@ int SPRKStepReInit(void* arkode_mem, ARKRhsFn f1, ARKRhsFn f2, sunrealtype t0, This routine resizes the memory within the SPRKStep module. ---------------------------------------------------------------*/ -int sprkStep_Resize(ARKodeMem ark_mem, N_Vector y0, sunrealtype hscale, - sunrealtype t0, ARKVecResizeFn resize, void* resize_data) +int sprkStep_Resize(ARKodeMem ark_mem, N_Vector y0, + SUNDIALS_MAYBE_UNUSED sunrealtype hscale, + SUNDIALS_MAYBE_UNUSED sunrealtype t0, ARKVecResizeFn resize, + void* resize_data) { ARKodeSPRKStepMem step_mem = NULL; sunindextype lrw1, liw1, lrw_diff, liw_diff; @@ -295,7 +297,8 @@ int sprkStep_Resize(ARKodeMem ark_mem, N_Vector y0, sunrealtype hscale, problem from the given time with the input state (all counter values are retained). ---------------------------------------------------------------*/ -int sprkStep_Reset(ARKodeMem ark_mem, sunrealtype tR, N_Vector yR) +int sprkStep_Reset(ARKodeMem ark_mem, SUNDIALS_MAYBE_UNUSED sunrealtype tR, + SUNDIALS_MAYBE_UNUSED N_Vector yR) { ARKodeSPRKStepMem step_mem = NULL; int retval = 0; diff --git a/src/arkode/arkode_user_controller.c b/src/arkode/arkode_user_controller.c index 29167a38cb..d10dbf923c 100644 --- a/src/arkode/arkode_user_controller.c +++ b/src/arkode/arkode_user_controller.c @@ -96,15 +96,14 @@ SUNAdaptController ARKUserControl(SUNContext sunctx, void* arkode_mem, * ----------------------------------------------------------------- */ SUNAdaptController_Type SUNAdaptController_GetType_ARKUserControl( - SUNAdaptController C) + SUNDIALS_MAYBE_UNUSED SUNAdaptController C) { return SUN_ADAPTCONTROLLER_H; } -SUNErrCode SUNAdaptController_EstimateStep_ARKUserControl(SUNAdaptController C, - sunrealtype h, int p, - sunrealtype dsm, - sunrealtype* hnew) +SUNErrCode SUNAdaptController_EstimateStep_ARKUserControl( + SUNAdaptController C, sunrealtype h, SUNDIALS_MAYBE_UNUSED int p, + sunrealtype dsm, sunrealtype* hnew) { /* call user-provided function to compute new step */ sunrealtype ttmp = (dsm <= ONE) ? SC_ARKMEM(C)->tn + SC_ARKMEM(C)->h @@ -155,9 +154,8 @@ SUNErrCode SUNAdaptController_UpdateH_ARKUserControl(SUNAdaptController C, return SUN_SUCCESS; } -SUNErrCode SUNAdaptController_Space_ARKUserControl(SUNAdaptController C, - long int* lenrw, - long int* leniw) +SUNErrCode SUNAdaptController_Space_ARKUserControl( + SUNDIALS_MAYBE_UNUSED SUNAdaptController C, long int* lenrw, long int* leniw) { *lenrw = 4; *leniw = 2; diff --git a/src/arkode/xbraid/arkode_xbraid.c b/src/arkode/xbraid/arkode_xbraid.c index 67e20edf1f..208c2c2888 100644 --- a/src/arkode/xbraid/arkode_xbraid.c +++ b/src/arkode/xbraid/arkode_xbraid.c @@ -283,8 +283,9 @@ int ARKBraid_GetSolution(braid_App app, sunrealtype* tout, N_Vector yout) * -------------------------- */ /* Take a time step */ -int ARKBraid_Step(braid_App app, braid_Vector ustop, braid_Vector fstop, - braid_Vector u, braid_StepStatus status) +int ARKBraid_Step(braid_App app, SUNDIALS_MAYBE_UNUSED braid_Vector ustop, + SUNDIALS_MAYBE_UNUSED braid_Vector fstop, braid_Vector u, + braid_StepStatus status) { braid_Int braid_flag; /* braid function return flag */ int ark_flag; /* arkode step return flag */ @@ -350,7 +351,8 @@ int ARKBraid_Step(braid_App app, braid_Vector ustop, braid_Vector fstop, } /* Create and initialize vectors */ -int ARKBraid_Init(braid_App app, sunrealtype t, braid_Vector* u_ptr) +int ARKBraid_Init(braid_App app, SUNDIALS_MAYBE_UNUSED sunrealtype t, + braid_Vector* u_ptr) { int flag; /* return flag */ N_Vector y; /* output N_Vector */ diff --git a/src/cvode/cvode_bandpre.c b/src/cvode/cvode_bandpre.c index f421257440..b19c32e1e5 100644 --- a/src/cvode/cvode_bandpre.c +++ b/src/cvode/cvode_bandpre.c @@ -435,9 +435,12 @@ static int CVBandPrecSetup(sunrealtype t, N_Vector y, N_Vector fy, The value returned by the CVBandPrecSolve function is always 0, indicating success. -----------------------------------------------------------------*/ -static int CVBandPrecSolve(sunrealtype t, N_Vector y, N_Vector fy, N_Vector r, - N_Vector z, sunrealtype gamma, sunrealtype delta, - int lr, void* bp_data) +static int CVBandPrecSolve(SUNDIALS_MAYBE_UNUSED sunrealtype t, + SUNDIALS_MAYBE_UNUSED N_Vector y, + SUNDIALS_MAYBE_UNUSED N_Vector fy, N_Vector r, + N_Vector z, SUNDIALS_MAYBE_UNUSED sunrealtype gamma, + SUNDIALS_MAYBE_UNUSED sunrealtype delta, + SUNDIALS_MAYBE_UNUSED int lr, void* bp_data) { CVBandPrecData pdata; int retval; diff --git a/src/cvode/cvode_bbdpre.c b/src/cvode/cvode_bbdpre.c index 6c8a28470b..4cdefc1c28 100644 --- a/src/cvode/cvode_bbdpre.c +++ b/src/cvode/cvode_bbdpre.c @@ -467,9 +467,10 @@ int CVBBDPrecGetNumGfnEvals(void* cvode_mem, long int* ngevalsBBDP) 0 if successful, 1 for a recoverable error (step will be retried). -----------------------------------------------------------------*/ -static int CVBBDPrecSetup(sunrealtype t, N_Vector y, N_Vector fy, - sunbooleantype jok, sunbooleantype* jcurPtr, - sunrealtype gamma, void* bbd_data) +static int CVBBDPrecSetup(sunrealtype t, N_Vector y, + SUNDIALS_MAYBE_UNUSED N_Vector fy, sunbooleantype jok, + sunbooleantype* jcurPtr, sunrealtype gamma, + void* bbd_data) { CVBBDPrecData pdata; CVodeMem cv_mem; @@ -556,9 +557,12 @@ static int CVBBDPrecSetup(sunrealtype t, N_Vector y, N_Vector fy, The value returned by the CVBBDPrecSolve function is always 0, indicating success. -----------------------------------------------------------------*/ -static int CVBBDPrecSolve(sunrealtype t, N_Vector y, N_Vector fy, N_Vector r, - N_Vector z, sunrealtype gamma, sunrealtype delta, - int lr, void* bbd_data) +static int CVBBDPrecSolve(SUNDIALS_MAYBE_UNUSED sunrealtype t, + SUNDIALS_MAYBE_UNUSED N_Vector y, + SUNDIALS_MAYBE_UNUSED N_Vector fy, N_Vector r, + N_Vector z, SUNDIALS_MAYBE_UNUSED sunrealtype gamma, + SUNDIALS_MAYBE_UNUSED sunrealtype delta, + SUNDIALS_MAYBE_UNUSED int lr, void* bbd_data) { int retval; CVBBDPrecData pdata; diff --git a/src/cvode/cvode_diag.c b/src/cvode/cvode_diag.c index ab73f5ac55..25af67fbe9 100644 --- a/src/cvode/cvode_diag.c +++ b/src/cvode/cvode_diag.c @@ -320,9 +320,10 @@ static int CVDiagInit(CVodeMem cv_mem) * ----------------------------------------------------------------- */ -static int CVDiagSetup(CVodeMem cv_mem, int convfail, N_Vector ypred, - N_Vector fpred, sunbooleantype* jcurPtr, N_Vector vtemp1, - N_Vector vtemp2, N_Vector vtemp3) +static int CVDiagSetup(CVodeMem cv_mem, SUNDIALS_MAYBE_UNUSED int convfail, + N_Vector ypred, N_Vector fpred, sunbooleantype* jcurPtr, + N_Vector vtemp1, N_Vector vtemp2, + SUNDIALS_MAYBE_UNUSED N_Vector vtemp3) { sunrealtype r; N_Vector ftemp, y; @@ -412,8 +413,10 @@ static int CVDiagSetup(CVodeMem cv_mem, int convfail, N_Vector ypred, * ----------------------------------------------------------------- */ -static int CVDiagSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight, - N_Vector ycur, N_Vector fcur) +static int CVDiagSolve(CVodeMem cv_mem, N_Vector b, + SUNDIALS_MAYBE_UNUSED N_Vector weight, + SUNDIALS_MAYBE_UNUSED N_Vector ycur, + SUNDIALS_MAYBE_UNUSED N_Vector fcur) { sunbooleantype invOK; sunrealtype r; diff --git a/src/cvode/cvode_fused_stubs.c b/src/cvode/cvode_fused_stubs.c index cd7aa6acd8..7bc41c5d6f 100644 --- a/src/cvode/cvode_fused_stubs.c +++ b/src/cvode/cvode_fused_stubs.c @@ -18,6 +18,7 @@ #include "cvode_diag_impl.h" #include "cvode_impl.h" +#include "sundials_macros.h" #define ZERO SUN_RCONST(0.0) #define PT1 SUN_RCONST(0.1) @@ -121,10 +122,11 @@ int cvDiagSetup_formY(const sunrealtype h, const sunrealtype r, * ----------------------------------------------------------------- */ -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 cvDiagSetup_buildM(SUNDIALS_MAYBE_UNUSED 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) { N_VLinearSum(ONE, M, -ONE, fpred, M); N_VLinearSum(FRACT, ftemp, -h, M, M); diff --git a/src/cvode/cvode_impl.h b/src/cvode/cvode_impl.h index c8d08a32fb..e2f3a36350 100644 --- a/src/cvode/cvode_impl.h +++ b/src/cvode/cvode_impl.h @@ -22,10 +22,11 @@ #include #include #include +#include #include "cvode_proj_impl.h" -#include "sundials/sundials_math.h" #include "sundials_logger_impl.h" +#include "sundials_macros.h" #ifdef __cplusplus /* wrapper to enable C++ usage */ extern "C" { diff --git a/src/cvode/cvode_io.c b/src/cvode/cvode_io.c index 1a545a0886..1f23b850c0 100644 --- a/src/cvode/cvode_io.c +++ b/src/cvode/cvode_io.c @@ -104,6 +104,8 @@ int CVodeSetMonitorFn(void* cvode_mem, CVMonitorFn fn) cv_mem->cv_monitorfun = fn; return (CV_SUCCESS); #else + /* silence warnings when monitoring is disabled */ + ((void)fn); cvProcessError(cv_mem, CV_ILL_INPUT, __LINE__, __func__, __FILE__, "SUNDIALS was not built with monitoring enabled."); return (CV_ILL_INPUT); @@ -1023,6 +1025,8 @@ int CVodeSetUseIntegratorFusedKernels(void* cvode_mem, sunbooleantype onoff) cv_mem->cv_usefused = onoff; return (CV_SUCCESS); #else + /* silence warnings when fused kernels are disabled */ + ((void)onoff); cvProcessError(cv_mem, CV_ILL_INPUT, __LINE__, __func__, __FILE__, "CVODE was not built with fused integrator kernels enabled"); return (CV_ILL_INPUT); diff --git a/src/cvode/cvode_ls.c b/src/cvode/cvode_ls.c index a51ef16132..50c60c6e8b 100644 --- a/src/cvode/cvode_ls.c +++ b/src/cvode/cvode_ls.c @@ -977,7 +977,8 @@ int cvLsPSolve(void* cvode_mem, N_Vector r, N_Vector z, sunrealtype tol, int lr) approximation routines. ---------------------------------------------------------------*/ int cvLsDQJac(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix Jac, - void* cvode_mem, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) + void* cvode_mem, N_Vector tmp1, N_Vector tmp2, + SUNDIALS_MAYBE_UNUSED N_Vector tmp3) { CVodeMem cv_mem; int retval; @@ -1213,7 +1214,7 @@ int cvLsBandDQJac(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix Jac, } /* Evaluate f with incremented y */ - retval = cv_mem->cv_f(cv_mem->cv_tn, ytemp, ftemp, cv_mem->cv_user_data); + retval = cv_mem->cv_f(t, ytemp, ftemp, cv_mem->cv_user_data); cvls_mem->nfeDQ++; if (retval != 0) { break; } diff --git a/src/cvodes/cvodes.c b/src/cvodes/cvodes.c index 4e2ac40d00..ad60c4e9e4 100644 --- a/src/cvodes/cvodes.c +++ b/src/cvodes/cvodes.c @@ -9402,8 +9402,8 @@ static int cvQuadSensEwtSetSV(CVodeMem cv_mem, N_Vector* yQScur, * Updates the norm old_nrm to account for all quadratures. */ -static sunrealtype cvQuadUpdateNorm(CVodeMem cv_mem, sunrealtype old_nrm, - N_Vector xQ, N_Vector wQ) +static sunrealtype cvQuadUpdateNorm(SUNDIALS_MAYBE_UNUSED CVodeMem cv_mem, + sunrealtype old_nrm, N_Vector xQ, N_Vector wQ) { sunrealtype qnrm; @@ -9620,9 +9620,9 @@ int cvSensRhsInternalDQ(int Ns, sunrealtype t, N_Vector y, N_Vector ydot, * non-zero return value from f(). */ -int cvSensRhs1InternalDQ(int Ns, sunrealtype t, N_Vector y, N_Vector ydot, - int is, N_Vector yS, N_Vector ySdot, void* cvode_mem, - N_Vector ytemp, N_Vector ftemp) +int cvSensRhs1InternalDQ(SUNDIALS_MAYBE_UNUSED int Ns, sunrealtype t, N_Vector y, + N_Vector ydot, int is, N_Vector yS, N_Vector ySdot, + void* cvode_mem, N_Vector ytemp, N_Vector ftemp) { CVodeMem cv_mem; int retval, method; diff --git a/src/cvodes/cvodes_bandpre.c b/src/cvodes/cvodes_bandpre.c index 98a9308759..55dbe1afbb 100644 --- a/src/cvodes/cvodes_bandpre.c +++ b/src/cvodes/cvodes_bandpre.c @@ -438,9 +438,12 @@ static int cvBandPrecSetup(sunrealtype t, N_Vector y, N_Vector fy, The value returned by the cvBandPrecSolve function is always 0, indicating success. -----------------------------------------------------------------*/ -static int cvBandPrecSolve(sunrealtype t, N_Vector y, N_Vector fy, N_Vector r, - N_Vector z, sunrealtype gamma, sunrealtype delta, - int lr, void* bp_data) +static int cvBandPrecSolve(SUNDIALS_MAYBE_UNUSED sunrealtype t, + SUNDIALS_MAYBE_UNUSED N_Vector y, + SUNDIALS_MAYBE_UNUSED N_Vector fy, N_Vector r, + N_Vector z, SUNDIALS_MAYBE_UNUSED sunrealtype gamma, + SUNDIALS_MAYBE_UNUSED sunrealtype delta, + SUNDIALS_MAYBE_UNUSED int lr, void* bp_data) { CVBandPrecData pdata; int retval; diff --git a/src/cvodes/cvodes_bbdpre.c b/src/cvodes/cvodes_bbdpre.c index af9cba7900..12eb1b7883 100644 --- a/src/cvodes/cvodes_bbdpre.c +++ b/src/cvodes/cvodes_bbdpre.c @@ -479,9 +479,10 @@ int CVBBDPrecGetNumGfnEvals(void* cvode_mem, long int* ngevalsBBDP) 0 if successful, 1 for a recoverable error (step will be retried). -----------------------------------------------------------------*/ -static int cvBBDPrecSetup(sunrealtype t, N_Vector y, N_Vector fy, - sunbooleantype jok, sunbooleantype* jcurPtr, - sunrealtype gamma, void* bbd_data) +static int cvBBDPrecSetup(sunrealtype t, N_Vector y, + SUNDIALS_MAYBE_UNUSED N_Vector fy, sunbooleantype jok, + sunbooleantype* jcurPtr, sunrealtype gamma, + void* bbd_data) { CVBBDPrecData pdata; CVodeMem cv_mem; @@ -568,9 +569,12 @@ static int cvBBDPrecSetup(sunrealtype t, N_Vector y, N_Vector fy, The value returned by the cvBBDPrecSolve function is always 0, indicating success. -----------------------------------------------------------------*/ -static int cvBBDPrecSolve(sunrealtype t, N_Vector y, N_Vector fy, N_Vector r, - N_Vector z, sunrealtype gamma, sunrealtype delta, - int lr, void* bbd_data) +static int cvBBDPrecSolve(SUNDIALS_MAYBE_UNUSED sunrealtype t, + SUNDIALS_MAYBE_UNUSED N_Vector y, + SUNDIALS_MAYBE_UNUSED N_Vector fy, N_Vector r, + N_Vector z, SUNDIALS_MAYBE_UNUSED sunrealtype gamma, + SUNDIALS_MAYBE_UNUSED sunrealtype delta, + SUNDIALS_MAYBE_UNUSED int lr, void* bbd_data) { int retval; CVBBDPrecData pdata; diff --git a/src/cvodes/cvodes_diag.c b/src/cvodes/cvodes_diag.c index b1db687e4b..857a81bf73 100644 --- a/src/cvodes/cvodes_diag.c +++ b/src/cvodes/cvodes_diag.c @@ -326,9 +326,10 @@ static int CVDiagInit(CVodeMem cv_mem) * ----------------------------------------------------------------- */ -static int CVDiagSetup(CVodeMem cv_mem, int convfail, N_Vector ypred, - N_Vector fpred, sunbooleantype* jcurPtr, N_Vector vtemp1, - N_Vector vtemp2, N_Vector vtemp3) +static int CVDiagSetup(CVodeMem cv_mem, SUNDIALS_MAYBE_UNUSED int convfail, + N_Vector ypred, N_Vector fpred, sunbooleantype* jcurPtr, + N_Vector vtemp1, N_Vector vtemp2, + SUNDIALS_MAYBE_UNUSED N_Vector vtemp3) { sunrealtype r; N_Vector ftemp, y; @@ -400,8 +401,10 @@ static int CVDiagSetup(CVodeMem cv_mem, int convfail, N_Vector ypred, * ----------------------------------------------------------------- */ -static int CVDiagSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight, - N_Vector ycur, N_Vector fcur) +static int CVDiagSolve(CVodeMem cv_mem, N_Vector b, + SUNDIALS_MAYBE_UNUSED N_Vector weight, + SUNDIALS_MAYBE_UNUSED N_Vector ycur, + SUNDIALS_MAYBE_UNUSED N_Vector fcur) { sunbooleantype invOK; sunrealtype r; diff --git a/src/cvodes/cvodes_impl.h b/src/cvodes/cvodes_impl.h index e98b88b371..c22d166359 100644 --- a/src/cvodes/cvodes_impl.h +++ b/src/cvodes/cvodes_impl.h @@ -18,12 +18,14 @@ #define _CVODES_IMPL_H #include + +#include #include +#include -#include "cvodes/cvodes.h" #include "cvodes_proj_impl.h" -#include "sundials/sundials_math.h" #include "sundials_logger_impl.h" +#include "sundials_macros.h" #ifdef __cplusplus /* wrapper to enable C++ usage */ extern "C" { diff --git a/src/cvodes/cvodes_io.c b/src/cvodes/cvodes_io.c index 4114259b23..e4599bd853 100644 --- a/src/cvodes/cvodes_io.c +++ b/src/cvodes/cvodes_io.c @@ -104,6 +104,8 @@ int CVodeSetMonitorFn(void* cvode_mem, CVMonitorFn fn) cv_mem->cv_monitorfun = fn; return (CV_SUCCESS); #else + /* silence warnings when monitoring is disabled */ + ((void)fn); cvProcessError(cv_mem, CV_ILL_INPUT, __LINE__, __func__, __FILE__, "SUNDIALS was not built with monitoring enabled."); return (CV_ILL_INPUT); diff --git a/src/cvodes/cvodes_ls.c b/src/cvodes/cvodes_ls.c index 6c7362d74b..539a69a1d4 100644 --- a/src/cvodes/cvodes_ls.c +++ b/src/cvodes/cvodes_ls.c @@ -1055,7 +1055,8 @@ int cvLsPSolve(void* cvode_mem, N_Vector r, N_Vector z, sunrealtype tol, int lr) approximation routines. ---------------------------------------------------------------*/ int cvLsDQJac(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix Jac, - void* cvode_mem, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) + void* cvode_mem, N_Vector tmp1, N_Vector tmp2, + SUNDIALS_MAYBE_UNUSED N_Vector tmp3) { CVodeMem cv_mem; int retval; @@ -1291,7 +1292,7 @@ int cvLsBandDQJac(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix Jac, } /* Evaluate f with incremented y */ - retval = cv_mem->cv_f(cv_mem->cv_tn, ytemp, ftemp, cv_mem->cv_user_data); + retval = cv_mem->cv_f(t, ytemp, ftemp, cv_mem->cv_user_data); cvls_mem->nfeDQ++; if (retval != 0) { break; } @@ -2884,7 +2885,7 @@ int cvLs_AccessLMemBCur(void* cvode_mem, const char* fname, CVodeMem* cv_mem, /* access CVodeMem structure */ if (cvode_mem == NULL) { - cvProcessError(NULL, CVLS_MEM_NULL, __LINE__, __func__, __FILE__, + cvProcessError(NULL, CVLS_MEM_NULL, __LINE__, fname, __FILE__, MSG_LS_CVMEM_NULL); return (CVLS_MEM_NULL); } @@ -2893,7 +2894,7 @@ int cvLs_AccessLMemBCur(void* cvode_mem, const char* fname, CVodeMem* cv_mem, /* access CVadjMem structure */ if ((*cv_mem)->cv_adjMallocDone == SUNFALSE) { - cvProcessError(*cv_mem, CVLS_NO_ADJ, __LINE__, __func__, __FILE__, + cvProcessError(*cv_mem, CVLS_NO_ADJ, __LINE__, fname, __FILE__, MSG_LS_NO_ADJ); return (CVLS_NO_ADJ); } @@ -2902,7 +2903,7 @@ int cvLs_AccessLMemBCur(void* cvode_mem, const char* fname, CVodeMem* cv_mem, /* get current backward problem */ if ((*ca_mem)->ca_bckpbCrt == NULL) { - cvProcessError(*cv_mem, CVLS_LMEMB_NULL, __LINE__, __func__, __FILE__, + cvProcessError(*cv_mem, CVLS_LMEMB_NULL, __LINE__, fname, __FILE__, MSG_LS_LMEMB_NULL); return (CVLS_LMEMB_NULL); } @@ -2911,7 +2912,7 @@ int cvLs_AccessLMemBCur(void* cvode_mem, const char* fname, CVodeMem* cv_mem, /* access CVLsMemB structure */ if ((*cvB_mem)->cv_lmem == NULL) { - cvProcessError(*cv_mem, CVLS_LMEMB_NULL, __LINE__, __func__, __FILE__, + cvProcessError(*cv_mem, CVLS_LMEMB_NULL, __LINE__, fname, __FILE__, MSG_LS_LMEMB_NULL); return (CVLS_LMEMB_NULL); } diff --git a/src/cvodes/cvodes_nls_stg1.c b/src/cvodes/cvodes_nls_stg1.c index a1b4fdc3d0..c292572b10 100644 --- a/src/cvodes/cvodes_nls_stg1.c +++ b/src/cvodes/cvodes_nls_stg1.c @@ -258,7 +258,8 @@ static int cvNlsLSolveSensStg1(N_Vector delta, void* cvode_mem) return (CV_SUCCESS); } -static int cvNlsConvTestSensStg1(SUNNonlinearSolver NLS, N_Vector ycor, +static int cvNlsConvTestSensStg1(SUNNonlinearSolver NLS, + SUNDIALS_MAYBE_UNUSED N_Vector ycor, N_Vector delta, sunrealtype tol, N_Vector ewt, void* cvode_mem) { diff --git a/src/ida/ida_bbdpre.c b/src/ida/ida_bbdpre.c index 2352ff3b64..8bce33eea7 100644 --- a/src/ida/ida_bbdpre.c +++ b/src/ida/ida_bbdpre.c @@ -455,7 +455,8 @@ int IDABBDPrecGetNumGfnEvals(void* ida_mem, long int* ngevalsBBDP) < 0 for a nonrecoverable error (step fails). ----------------------------------------------------------------*/ static int IDABBDPrecSetup(sunrealtype tt, N_Vector yy, N_Vector yp, - N_Vector rr, sunrealtype c_j, void* bbd_data) + SUNDIALS_MAYBE_UNUSED N_Vector rr, sunrealtype c_j, + void* bbd_data) { IBBDPrecData pdata; IDAMem IDA_mem; @@ -502,9 +503,13 @@ static int IDABBDPrecSetup(sunrealtype tt, N_Vector yy, N_Vector yp, IDABBDPrecSolve returns the value returned from the linear solver object. ---------------------------------------------------------------*/ -static int IDABBDPrecSolve(sunrealtype tt, N_Vector yy, N_Vector yp, - N_Vector rr, N_Vector rvec, N_Vector zvec, - sunrealtype c_j, sunrealtype delta, void* bbd_data) +static int IDABBDPrecSolve(SUNDIALS_MAYBE_UNUSED sunrealtype tt, + SUNDIALS_MAYBE_UNUSED N_Vector yy, + SUNDIALS_MAYBE_UNUSED N_Vector yp, + SUNDIALS_MAYBE_UNUSED N_Vector rr, N_Vector rvec, + N_Vector zvec, SUNDIALS_MAYBE_UNUSED sunrealtype c_j, + SUNDIALS_MAYBE_UNUSED sunrealtype delta, + void* bbd_data) { IBBDPrecData pdata; int retval; diff --git a/src/ida/ida_impl.h b/src/ida/ida_impl.h index b68debbccb..f61a79381e 100644 --- a/src/ida/ida_impl.h +++ b/src/ida/ida_impl.h @@ -20,10 +20,12 @@ #define _IDA_IMPL_H #include + +#include #include -#include "ida/ida.h" #include "sundials_logger_impl.h" +#include "sundials_macros.h" #ifdef __cplusplus /* wrapper to enable C++ usage */ extern "C" { diff --git a/src/ida/ida_ls.c b/src/ida/ida_ls.c index c0a0c73649..a8e2707208 100644 --- a/src/ida/ida_ls.c +++ b/src/ida/ida_ls.c @@ -860,7 +860,8 @@ int idaLsPSetup(void* ida_mem) is the only case in which the user's psolve routine is allowed to be NULL. ---------------------------------------------------------------*/ -int idaLsPSolve(void* ida_mem, N_Vector r, N_Vector z, sunrealtype tol, int lr) +int idaLsPSolve(void* ida_mem, N_Vector r, N_Vector z, sunrealtype tol, + SUNDIALS_MAYBE_UNUSED int lr) { IDAMem IDA_mem; IDALsMem idals_mem; @@ -1138,7 +1139,7 @@ int idaLsBandDQJac(sunrealtype tt, sunrealtype c_j, N_Vector yy, N_Vector yp, /* Increment yj and ypj. */ ytemp_data[j] += inc; - yptemp_data[j] += IDA_mem->ida_cj * inc; + yptemp_data[j] += c_j * inc; } /* Call res routine with incremented arguments. */ diff --git a/src/ida/ida_nls.c b/src/ida/ida_nls.c index 8873023638..160b817327 100644 --- a/src/ida/ida_nls.c +++ b/src/ida/ida_nls.c @@ -233,7 +233,8 @@ int idaNlsInit(IDAMem IDA_mem) return (IDA_SUCCESS); } -static int idaNlsLSetup(sunbooleantype jbad, sunbooleantype* jcur, void* ida_mem) +static int idaNlsLSetup(SUNDIALS_MAYBE_UNUSED sunbooleantype jbad, + sunbooleantype* jcur, void* ida_mem) { IDAMem IDA_mem; int retval; @@ -318,7 +319,8 @@ static int idaNlsResidual(N_Vector ycor, N_Vector res, void* ida_mem) return (IDA_SUCCESS); } -static int idaNlsConvTest(SUNNonlinearSolver NLS, N_Vector ycor, N_Vector del, +static int idaNlsConvTest(SUNNonlinearSolver NLS, + SUNDIALS_MAYBE_UNUSED N_Vector ycor, N_Vector del, sunrealtype tol, N_Vector ewt, void* ida_mem) { IDAMem IDA_mem; diff --git a/src/idas/idas.c b/src/idas/idas.c index 1cf688a5d0..3174660c12 100644 --- a/src/idas/idas.c +++ b/src/idas/idas.c @@ -7836,8 +7836,9 @@ static sunrealtype IDAQuadSensWrmsNorm(IDAMem IDA_mem, N_Vector* xQS, * Updates the norm old_nrm to account for all quadratures. */ -static sunrealtype IDAQuadWrmsNormUpdate(IDAMem IDA_mem, sunrealtype old_nrm, - N_Vector xQ, N_Vector wQ) +static sunrealtype IDAQuadWrmsNormUpdate(SUNDIALS_MAYBE_UNUSED IDAMem IDA_mem, + sunrealtype old_nrm, N_Vector xQ, + N_Vector wQ) { sunrealtype qnrm; @@ -8441,10 +8442,10 @@ int IDASensResDQ(int Ns, sunrealtype t, N_Vector yy, N_Vector yp, * (<0 if res fails unrecoverably, >0 if res has a recoverable error). */ -static int IDASensRes1DQ(int Ns, sunrealtype t, N_Vector yy, N_Vector yp, - N_Vector resval, int is, N_Vector yyS, N_Vector ypS, - N_Vector resvalS, void* user_dataS, N_Vector ytemp, - N_Vector yptemp, N_Vector restemp) +static int IDASensRes1DQ(SUNDIALS_MAYBE_UNUSED int Ns, sunrealtype t, N_Vector yy, + N_Vector yp, N_Vector resval, int is, N_Vector yyS, + N_Vector ypS, N_Vector resvalS, void* user_dataS, + N_Vector ytemp, N_Vector yptemp, N_Vector restemp) { IDAMem IDA_mem; int method; diff --git a/src/idas/idas_bbdpre.c b/src/idas/idas_bbdpre.c index a584499293..25521a90d1 100644 --- a/src/idas/idas_bbdpre.c +++ b/src/idas/idas_bbdpre.c @@ -469,7 +469,8 @@ int IDABBDPrecGetNumGfnEvals(void* ida_mem, long int* ngevalsBBDP) < 0 for a nonrecoverable error (step fails). ----------------------------------------------------------------*/ static int IDABBDPrecSetup(sunrealtype tt, N_Vector yy, N_Vector yp, - N_Vector rr, sunrealtype c_j, void* bbd_data) + SUNDIALS_MAYBE_UNUSED N_Vector rr, sunrealtype c_j, + void* bbd_data) { IBBDPrecData pdata; IDAMem IDA_mem; @@ -516,9 +517,13 @@ static int IDABBDPrecSetup(sunrealtype tt, N_Vector yy, N_Vector yp, IDABBDPrecSolve returns the value returned from the linear solver object. ---------------------------------------------------------------*/ -static int IDABBDPrecSolve(sunrealtype tt, N_Vector yy, N_Vector yp, - N_Vector rr, N_Vector rvec, N_Vector zvec, - sunrealtype c_j, sunrealtype delta, void* bbd_data) +static int IDABBDPrecSolve(SUNDIALS_MAYBE_UNUSED sunrealtype tt, + SUNDIALS_MAYBE_UNUSED N_Vector yy, + SUNDIALS_MAYBE_UNUSED N_Vector yp, + SUNDIALS_MAYBE_UNUSED N_Vector rr, N_Vector rvec, + N_Vector zvec, SUNDIALS_MAYBE_UNUSED sunrealtype c_j, + SUNDIALS_MAYBE_UNUSED sunrealtype delta, + void* bbd_data) { IBBDPrecData pdata; int retval; diff --git a/src/idas/idas_impl.h b/src/idas/idas_impl.h index 90abcbcf8d..e54b593bc5 100644 --- a/src/idas/idas_impl.h +++ b/src/idas/idas_impl.h @@ -19,10 +19,12 @@ #define _IDAS_IMPL_H #include + +#include #include -#include "idas/idas.h" #include "sundials_logger_impl.h" +#include "sundials_macros.h" #ifdef __cplusplus /* wrapper to enable C++ usage */ extern "C" { diff --git a/src/idas/idas_ls.c b/src/idas/idas_ls.c index dc0c0bab52..088bcbb015 100644 --- a/src/idas/idas_ls.c +++ b/src/idas/idas_ls.c @@ -901,7 +901,8 @@ int idaLsPSetup(void* ida_mem) is the only case in which the user's psolve routine is allowed to be NULL. ---------------------------------------------------------------*/ -int idaLsPSolve(void* ida_mem, N_Vector r, N_Vector z, sunrealtype tol, int lr) +int idaLsPSolve(void* ida_mem, N_Vector r, N_Vector z, sunrealtype tol, + SUNDIALS_MAYBE_UNUSED int lr) { IDAMem IDA_mem; IDALsMem idals_mem; @@ -1179,7 +1180,7 @@ int idaLsBandDQJac(sunrealtype tt, sunrealtype c_j, N_Vector yy, N_Vector yp, /* Increment yj and ypj. */ ytemp_data[j] += inc; - yptemp_data[j] += IDA_mem->ida_cj * inc; + yptemp_data[j] += c_j * inc; } /* Call res routine with incremented arguments. */ diff --git a/src/idas/idas_nls.c b/src/idas/idas_nls.c index 034f2c3612..17ba1e6b5d 100644 --- a/src/idas/idas_nls.c +++ b/src/idas/idas_nls.c @@ -233,7 +233,8 @@ int idaNlsInit(IDAMem IDA_mem) return (IDA_SUCCESS); } -static int idaNlsLSetup(sunbooleantype jbad, sunbooleantype* jcur, void* ida_mem) +static int idaNlsLSetup(SUNDIALS_MAYBE_UNUSED sunbooleantype jbad, + sunbooleantype* jcur, void* ida_mem) { IDAMem IDA_mem; int retval; @@ -321,7 +322,8 @@ static int idaNlsResidual(N_Vector ycor, N_Vector res, void* ida_mem) return (IDA_SUCCESS); } -static int idaNlsConvTest(SUNNonlinearSolver NLS, N_Vector ycor, N_Vector del, +static int idaNlsConvTest(SUNNonlinearSolver NLS, + SUNDIALS_MAYBE_UNUSED N_Vector ycor, N_Vector del, sunrealtype tol, N_Vector ewt, void* ida_mem) { IDAMem IDA_mem; diff --git a/src/idas/idas_nls_sim.c b/src/idas/idas_nls_sim.c index d23a6c2bf8..d527189905 100644 --- a/src/idas/idas_nls_sim.c +++ b/src/idas/idas_nls_sim.c @@ -277,8 +277,8 @@ int idaNlsInitSensSim(IDAMem IDA_mem) return (IDA_SUCCESS); } -static int idaNlsLSetupSensSim(sunbooleantype jbad, sunbooleantype* jcur, - void* ida_mem) +static int idaNlsLSetupSensSim(SUNDIALS_MAYBE_UNUSED sunbooleantype jbad, + sunbooleantype* jcur, void* ida_mem) { IDAMem IDA_mem; int retval; @@ -415,7 +415,8 @@ static int idaNlsResidualSensSim(N_Vector ycorSim, N_Vector resSim, void* ida_me return (IDA_SUCCESS); } -static int idaNlsConvTestSensSim(SUNNonlinearSolver NLS, N_Vector ycor, +static int idaNlsConvTestSensSim(SUNNonlinearSolver NLS, + SUNDIALS_MAYBE_UNUSED N_Vector ycor, N_Vector del, sunrealtype tol, N_Vector ewt, void* ida_mem) { diff --git a/src/idas/idas_nls_stg.c b/src/idas/idas_nls_stg.c index 6311cf659a..3e1590c780 100644 --- a/src/idas/idas_nls_stg.c +++ b/src/idas/idas_nls_stg.c @@ -232,8 +232,8 @@ int idaNlsInitSensStg(IDAMem IDA_mem) return (IDA_SUCCESS); } -static int idaNlsLSetupSensStg(sunbooleantype jbad, sunbooleantype* jcur, - void* ida_mem) +static int idaNlsLSetupSensStg(SUNDIALS_MAYBE_UNUSED sunbooleantype jbad, + sunbooleantype* jcur, void* ida_mem) { IDAMem IDA_mem; int retval; @@ -326,7 +326,8 @@ static int idaNlsResidualSensStg(N_Vector ycorStg, N_Vector resStg, void* ida_me return (IDA_SUCCESS); } -static int idaNlsConvTestSensStg(SUNNonlinearSolver NLS, N_Vector ycor, +static int idaNlsConvTestSensStg(SUNNonlinearSolver NLS, + SUNDIALS_MAYBE_UNUSED N_Vector ycor, N_Vector del, sunrealtype tol, N_Vector ewt, void* ida_mem) { diff --git a/src/kinsol/kinsol.c b/src/kinsol/kinsol.c index 982e9e9f2e..344451d5c0 100644 --- a/src/kinsol/kinsol.c +++ b/src/kinsol/kinsol.c @@ -2491,8 +2491,10 @@ static sunrealtype KINScSNorm(KINMem kin_mem, N_Vector v, N_Vector u) * passes it to the info handler function. */ -void KINPrintInfo(KINMem kin_mem, int info_code, const char* module, - const char* fname, const char* msgfmt, ...) +void KINPrintInfo(SUNDIALS_MAYBE_UNUSED KINMem kin_mem, int info_code, + SUNDIALS_MAYBE_UNUSED const char* module, + SUNDIALS_MAYBE_UNUSED const char* fname, const char* msgfmt, + ...) { va_list ap; char msg[256], msg1[40]; @@ -2540,7 +2542,7 @@ void KINPrintInfo(KINMem kin_mem, int info_code, const char* module, { /* Compose the message */ - vsprintf(msg, msgfmt, ap); + vsnprintf(msg, sizeof msg, msgfmt, ap); } #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO diff --git a/src/kinsol/kinsol_bbdpre.c b/src/kinsol/kinsol_bbdpre.c index 3cd8b78e5f..7025f38a82 100644 --- a/src/kinsol/kinsol_bbdpre.c +++ b/src/kinsol/kinsol_bbdpre.c @@ -399,8 +399,9 @@ int KINBBDPrecGetNumGfnEvals(void* kinmem, long int* ngevalsBBDP) 0 if successful, > 0 for a recoverable error - step will be retried. ------------------------------------------------------------------*/ -static int KINBBDPrecSetup(N_Vector uu, N_Vector uscale, N_Vector fval, - N_Vector fscale, void* bbd_data) +static int KINBBDPrecSetup(N_Vector uu, N_Vector uscale, + SUNDIALS_MAYBE_UNUSED N_Vector fval, + SUNDIALS_MAYBE_UNUSED N_Vector fscale, void* bbd_data) { KBBDPrecData pdata; KINMem kin_mem; @@ -463,8 +464,11 @@ static int KINBBDPrecSetup(N_Vector uu, N_Vector uscale, N_Vector fval, flag returned from the lienar solver object. ------------------------------------------------------------------*/ -static int KINBBDPrecSolve(N_Vector uu, N_Vector uscale, N_Vector fval, - N_Vector fscale, N_Vector vv, void* bbd_data) +static int KINBBDPrecSolve(SUNDIALS_MAYBE_UNUSED N_Vector uu, + SUNDIALS_MAYBE_UNUSED N_Vector uscale, + SUNDIALS_MAYBE_UNUSED N_Vector fval, + SUNDIALS_MAYBE_UNUSED N_Vector fscale, N_Vector vv, + void* bbd_data) { KBBDPrecData pdata; sunrealtype* vd; diff --git a/src/kinsol/kinsol_impl.h b/src/kinsol/kinsol_impl.h index 7122c076cc..117bf003f5 100644 --- a/src/kinsol/kinsol_impl.h +++ b/src/kinsol/kinsol_impl.h @@ -20,12 +20,14 @@ #ifndef _KINSOL_IMPL_H #define _KINSOL_IMPL_H -#include #include + +#include #include #include "sundials_iterative_impl.h" #include "sundials_logger_impl.h" +#include "sundials_macros.h" #ifdef __cplusplus /* wrapper to enable C++ usage */ extern "C" { diff --git a/src/kinsol/kinsol_ls.c b/src/kinsol/kinsol_ls.c index 684995a069..37c706e01d 100644 --- a/src/kinsol/kinsol_ls.c +++ b/src/kinsol/kinsol_ls.c @@ -678,7 +678,9 @@ int kinLsPSetup(void* kinmem) in the case in which preconditioning is not done. This is the only case in which the user's psolve routine is allowed to be NULL. ------------------------------------------------------------------*/ -int kinLsPSolve(void* kinmem, N_Vector r, N_Vector z, sunrealtype tol, int lr) +int kinLsPSolve(void* kinmem, N_Vector r, N_Vector z, + SUNDIALS_MAYBE_UNUSED sunrealtype tol, + SUNDIALS_MAYBE_UNUSED int lr) { KINMem kin_mem; KINLsMem kinls_mem; @@ -941,8 +943,8 @@ int kinLsBandDQJac(N_Vector u, N_Vector fu, SUNMatrix Jac, KINMem kin_mem, a recovery may still be possible even if the system function fails (recoverably). ------------------------------------------------------------------*/ -int kinLsDQJtimes(N_Vector v, N_Vector Jv, N_Vector u, sunbooleantype* new_u, - void* kinmem) +int kinLsDQJtimes(N_Vector v, N_Vector Jv, N_Vector u, + SUNDIALS_MAYBE_UNUSED sunbooleantype* new_u, void* kinmem) { sunrealtype sigma, sigma_inv, sutsv, sq1norm, sign, vtv; KINMem kin_mem; diff --git a/src/nvector/manyvector/nvector_manyvector.c b/src/nvector/manyvector/nvector_manyvector.c index d52cc4fee7..31c74c78da 100644 --- a/src/nvector/manyvector/nvector_manyvector.c +++ b/src/nvector/manyvector/nvector_manyvector.c @@ -18,9 +18,9 @@ #include #include -#include "sundials/priv/sundials_errors_impl.h" -#include "sundials/sundials_errors.h" -#include "sundials/sundials_types.h" +#include +#include +#include #ifdef MANYVECTOR_BUILD_WITH_MPI #include #include @@ -31,6 +31,8 @@ #include #include +#include "sundials_macros.h" + /* Macro to handle separate MPI-aware/unaware installations */ #ifdef MANYVECTOR_BUILD_WITH_MPI #define MVAPPEND(fun) fun##_MPIManyVector @@ -472,7 +474,7 @@ sunindextype MVAPPEND(N_VGetNumSubvectors)(N_Vector v) /* Returns vector type ID. Used to identify vector implementation from abstract N_Vector interface. */ -N_Vector_ID MVAPPEND(N_VGetVectorID)(N_Vector v) +N_Vector_ID MVAPPEND(N_VGetVectorID)(SUNDIALS_MAYBE_UNUSED N_Vector v) { #ifdef MANYVECTOR_BUILD_WITH_MPI return (SUNDIALS_NVEC_MPIMANYVECTOR); diff --git a/src/nvector/mpiplusx/nvector_mpiplusx.c b/src/nvector/mpiplusx/nvector_mpiplusx.c index e8be7eb0cd..a955dfcf09 100644 --- a/src/nvector/mpiplusx/nvector_mpiplusx.c +++ b/src/nvector/mpiplusx/nvector_mpiplusx.c @@ -18,9 +18,9 @@ #include #include #include +#include -#include "sundials/priv/sundials_errors_impl.h" -#include "sundials/sundials_errors.h" +#include "sundials_macros.h" #define MPIPLUSX_LOCAL_VECTOR(v) (N_VGetSubvector_MPIManyVector(v, 0)) @@ -49,7 +49,7 @@ N_Vector N_VMake_MPIPlusX(MPI_Comm comm, N_Vector X, SUNContext sunctx) return v; } -N_Vector_ID N_VGetVectorID_MPIPlusX(N_Vector v) +N_Vector_ID N_VGetVectorID_MPIPlusX(SUNDIALS_MAYBE_UNUSED N_Vector v) { return SUNDIALS_NVEC_MPIPLUSX; } diff --git a/src/nvector/openmp/nvector_openmp.c b/src/nvector/openmp/nvector_openmp.c index 649a27a6df..bcb1f6d6b6 100644 --- a/src/nvector/openmp/nvector_openmp.c +++ b/src/nvector/openmp/nvector_openmp.c @@ -20,16 +20,18 @@ * of the NVECTOR module. * -----------------------------------------------------------------*/ -#include #include #include #include + +#include #include #include +#include #include +#include -#include "sundials/sundials_context.h" -#include "sundials/sundials_errors.h" +#include "sundials_macros.h" #define ZERO SUN_RCONST(0.0) #define HALF SUN_RCONST(0.5) @@ -82,7 +84,10 @@ static void VaxpyVectorArray_OpenMP(int nvec, sunrealtype a, N_Vector* X, * Returns vector type ID. Used to identify vector implementation * from abstract N_Vector interface. */ -N_Vector_ID N_VGetVectorID_OpenMP(N_Vector v) { return SUNDIALS_NVEC_OPENMP; } +N_Vector_ID N_VGetVectorID_OpenMP(SUNDIALS_MAYBE_UNUSED N_Vector v) +{ + return SUNDIALS_NVEC_OPENMP; +} /* ---------------------------------------------------------------------------- * Function to create a new empty vector diff --git a/src/nvector/parallel/nvector_parallel.c b/src/nvector/parallel/nvector_parallel.c index a438b4eb29..eb278bc21d 100644 --- a/src/nvector/parallel/nvector_parallel.c +++ b/src/nvector/parallel/nvector_parallel.c @@ -16,14 +16,16 @@ * of the NVECTOR package. * -----------------------------------------------------------------*/ -#include #include #include + +#include #include #include +#include +#include -#include "sundials/sundials_errors.h" -#include "sundials/sundials_types.h" +#include "sundials_macros.h" #define ZERO SUN_RCONST(0.0) #define HALF SUN_RCONST(0.5) @@ -242,6 +244,15 @@ N_Vector N_VMake_Parallel(MPI_Comm comm, sunindextype local_length, return (v); } +/* ---------------------------------------------------------------- + * Returns vector type ID. Used to identify vector implementation + * from abstract N_Vector interface. + */ +N_Vector_ID N_VGetVectorID_Parallel(SUNDIALS_MAYBE_UNUSED N_Vector v) +{ + return SUNDIALS_NVEC_PARALLEL; +} + /* ---------------------------------------------------------------- * Function to return global vector length */ diff --git a/src/nvector/parhyp/nvector_parhyp.c b/src/nvector/parhyp/nvector_parhyp.c index 4e9ef4d50c..aee1f08450 100644 --- a/src/nvector/parhyp/nvector_parhyp.c +++ b/src/nvector/parhyp/nvector_parhyp.c @@ -18,13 +18,15 @@ * for the NVECTOR package. * -----------------------------------------------------------------*/ -#include #include #include + +#include +#include #include +#include -#include "sundials/sundials_errors.h" -#include "sundials/sundials_nvector.h" +#include "sundials_macros.h" #define ZERO SUN_RCONST(0.0) #define HALF SUN_RCONST(0.5) @@ -136,7 +138,10 @@ static void VLin2_ParHyp(sunrealtype a, N_Vector x, N_Vector y, N_Vector z); * Returns vector type ID. Used to identify vector implementation * from abstract N_Vector interface. */ -N_Vector_ID N_VGetVectorID_ParHyp(N_Vector v) { return SUNDIALS_NVEC_PARHYP; } +N_Vector_ID N_VGetVectorID_ParHyp(SUNDIALS_MAYBE_UNUSED N_Vector v) +{ + return SUNDIALS_NVEC_PARHYP; +} /* ---------------------------------------------------------------- * Function to create a new parhyp vector without underlying @@ -161,8 +166,6 @@ N_Vector N_VNewEmpty_ParHyp(MPI_Comm comm, sunindextype local_length, v->ops->nvcloneempty = N_VCloneEmpty_ParHyp; v->ops->nvdestroy = N_VDestroy_ParHyp; v->ops->nvspace = N_VSpace_ParHyp; - v->ops->nvgetarraypointer = N_VGetArrayPointer_ParHyp; - v->ops->nvsetarraypointer = N_VSetArrayPointer_ParHyp; v->ops->nvgetcommunicator = N_VGetCommunicator_ParHyp; v->ops->nvgetlength = N_VGetLength_ParHyp; @@ -426,7 +429,7 @@ void N_VSpace_ParHyp(N_Vector v, sunindextype* lrw, sunindextype* liw) * then use HYPRE functions to get pointer to raw data of the local HYPRE * vector. */ -sunrealtype* N_VGetArrayPointer_ParHyp(N_Vector v) +sunrealtype* N_VGetArrayPointer_ParHyp(SUNDIALS_MAYBE_UNUSED N_Vector v) { return NULL; /* ((sunrealtype *) NV_DATA_PH(v)); */ } @@ -435,7 +438,8 @@ sunrealtype* N_VGetArrayPointer_ParHyp(N_Vector v) * This method is not implemented for HYPRE vector wrapper. * TODO: Put error handler in the function body. */ -void N_VSetArrayPointer_ParHyp(sunrealtype* v_data, N_Vector v) +void N_VSetArrayPointer_ParHyp(SUNDIALS_MAYBE_UNUSED sunrealtype* v_data, + SUNDIALS_MAYBE_UNUSED N_Vector v) { /* Not implemented for Hypre vector */ } diff --git a/src/nvector/petsc/nvector_petsc.c b/src/nvector/petsc/nvector_petsc.c index 87960d839a..f3accf46bd 100644 --- a/src/nvector/petsc/nvector_petsc.c +++ b/src/nvector/petsc/nvector_petsc.c @@ -18,12 +18,14 @@ * of the NVECTOR package. * -----------------------------------------------------------------*/ -#include #include #include + +#include +#include #include -#include "sundials/sundials_errors.h" +#include "sundials_macros.h" #define ZERO SUN_RCONST(0.0) #define HALF SUN_RCONST(0.5) @@ -101,7 +103,10 @@ * Returns vector type ID. Used to identify vector implementation * from abstract N_Vector interface. */ -N_Vector_ID N_VGetVectorID_Petsc(N_Vector v) { return SUNDIALS_NVEC_PETSC; } +N_Vector_ID N_VGetVectorID_Petsc(SUNDIALS_MAYBE_UNUSED N_Vector v) +{ + return SUNDIALS_NVEC_PETSC; +} /* ---------------------------------------------------------------- * Function to create a new N_Vector wrapper with an empty (NULL) @@ -139,8 +144,6 @@ N_Vector N_VNewEmpty_Petsc(MPI_Comm comm, sunindextype local_length, v->ops->nvcloneempty = N_VCloneEmpty_Petsc; v->ops->nvdestroy = N_VDestroy_Petsc; v->ops->nvspace = N_VSpace_Petsc; - v->ops->nvgetarraypointer = N_VGetArrayPointer_Petsc; - v->ops->nvsetarraypointer = N_VSetArrayPointer_Petsc; v->ops->nvgetcommunicator = N_VGetCommunicator_Petsc; v->ops->nvgetlength = N_VGetLength_Petsc; @@ -397,12 +400,19 @@ void N_VSpace_Petsc(N_Vector v, sunindextype* lrw, sunindextype* liw) /* * Not implemented for PETSc wrapper. */ -sunrealtype* N_VGetArrayPointer_Petsc(N_Vector v) { return NULL; } +sunrealtype* N_VGetArrayPointer_Petsc(SUNDIALS_MAYBE_UNUSED N_Vector v) +{ + return NULL; +} /* * Not implemented for PETSc wrapper. */ -void N_VSetArrayPointer_Petsc(sunrealtype* v_data, N_Vector v) { return; } +void N_VSetArrayPointer_Petsc(SUNDIALS_MAYBE_UNUSED sunrealtype* v_data, + SUNDIALS_MAYBE_UNUSED N_Vector v) +{ + return; +} MPI_Comm N_VGetCommunicator_Petsc(N_Vector v) { return (NV_COMM_PTC(v)); } diff --git a/src/nvector/pthreads/nvector_pthreads.c b/src/nvector/pthreads/nvector_pthreads.c index 6938934059..5e5314afb3 100644 --- a/src/nvector/pthreads/nvector_pthreads.c +++ b/src/nvector/pthreads/nvector_pthreads.c @@ -21,16 +21,17 @@ * structures to pass data to threads. * -----------------------------------------------------------------*/ -#include /* define NAN */ -#include +#include #include #include + +#include #include #include #include +#include -#include "sundials/priv/sundials_errors_impl.h" -#include "sundials/sundials_errors.h" +#include "sundials_macros.h" #define ZERO SUN_RCONST(0.0) #define HALF SUN_RCONST(0.5) @@ -153,7 +154,7 @@ static void nvInitThreadData(Pthreads_Data* thread_data); * Returns vector type ID. Used to identify vector implementation * from abstract N_Vector interface. */ -N_Vector_ID N_VGetVectorID_Pthreads(N_Vector v) +N_Vector_ID N_VGetVectorID_Pthreads(SUNDIALS_MAYBE_UNUSED N_Vector v) { return SUNDIALS_NVEC_PTHREADS; } diff --git a/src/nvector/serial/nvector_serial.c b/src/nvector/serial/nvector_serial.c index a4a1bff95a..255aca3fb6 100644 --- a/src/nvector/serial/nvector_serial.c +++ b/src/nvector/serial/nvector_serial.c @@ -16,14 +16,16 @@ * of the NVECTOR package. * -----------------------------------------------------------------*/ -#include #include #include + +#include #include #include #include +#include -#include "sundials/sundials_errors.h" +#include "sundials_macros.h" #define ZERO SUN_RCONST(0.0) #define HALF SUN_RCONST(0.5) @@ -217,6 +219,15 @@ N_Vector N_VMake_Serial(sunindextype length, sunrealtype* v_data, return (v); } +/* ---------------------------------------------------------------- + * Returns vector type ID. Used to identify vector implementation + * from abstract N_Vector interface. + */ +N_Vector_ID N_VGetVectorID_Serial(SUNDIALS_MAYBE_UNUSED N_Vector v) +{ + return SUNDIALS_NVEC_SERIAL; +} + /* ---------------------------------------------------------------------------- * Function to return number of vector elements */ diff --git a/src/nvector/trilinos/nvector_trilinos.cpp b/src/nvector/trilinos/nvector_trilinos.cpp index fdb28b7ef5..880bb33c95 100644 --- a/src/nvector/trilinos/nvector_trilinos.cpp +++ b/src/nvector/trilinos/nvector_trilinos.cpp @@ -18,11 +18,14 @@ * of the NVECTOR package. * -----------------------------------------------------------------*/ +#include +#include + #include #include #include -#include -#include + +#include "sundials_macros.h" #define ZERO SUN_RCONST(0.0) #define HALF SUN_RCONST(0.5) @@ -55,7 +58,7 @@ typedef TpetraVectorInterface::vector_type vector_type; * Returns vector type ID. Used to identify vector implementation * from abstract N_Vector interface. */ -N_Vector_ID N_VGetVectorID_Trilinos(N_Vector v) +N_Vector_ID N_VGetVectorID_Trilinos(SUNDIALS_MAYBE_UNUSED N_Vector v) { return SUNDIALS_NVEC_TRILINOS; } diff --git a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c index 11075d477f..e4bb23e6dd 100644 --- a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c +++ b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c @@ -17,11 +17,13 @@ #include #include + #include +#include #include +#include -#include "sundials/priv/sundials_errors_impl.h" -#include "sundials/sundials_errors.h" +#include "sundials_macros.h" /* --------------- * Macro accessors @@ -113,7 +115,8 @@ SUNErrCode SUNAdaptController_SetParams_ImExGus(SUNAdaptController C, * implementation of controller operations * ----------------------------------------------------------------- */ -SUNAdaptController_Type SUNAdaptController_GetType_ImExGus(SUNAdaptController C) +SUNAdaptController_Type SUNAdaptController_GetType_ImExGus( + SUNDIALS_MAYBE_UNUSED SUNAdaptController C) { return SUN_ADAPTCONTROLLER_H; } diff --git a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c index da60d812f1..bca88252cb 100644 --- a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c +++ b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c @@ -17,11 +17,13 @@ #include #include + #include +#include #include +#include -#include "sundials/priv/sundials_errors_impl.h" -#include "sundials/sundials_errors.h" +#include "sundials_macros.h" /* --------------- * Macro accessors @@ -297,7 +299,8 @@ SUNErrCode SUNAdaptController_SetParams_ImpGus(SUNAdaptController C, * implementation of controller operations * ----------------------------------------------------------------- */ -SUNAdaptController_Type SUNAdaptController_GetType_Soderlind(SUNAdaptController C) +SUNAdaptController_Type SUNAdaptController_GetType_Soderlind( + SUNDIALS_MAYBE_UNUSED SUNAdaptController C) { return SUN_ADAPTCONTROLLER_H; } diff --git a/src/sundials/sundials_context.c b/src/sundials/sundials_context.c index b3c847e682..86b0a49c34 100644 --- a/src/sundials/sundials_context.c +++ b/src/sundials/sundials_context.c @@ -18,15 +18,17 @@ #include #include #include + #include #include #include +#include #include #include +#include -#include "sundials/sundials_errors.h" -#include "sundials/sundials_types.h" #include "sundials_adiak_metadata.h" +#include "sundials_macros.h" SUNErrCode SUNContext_Create(SUNComm comm, SUNContext* sunctx_out) { @@ -209,6 +211,9 @@ SUNErrCode SUNContext_SetProfiler(SUNContext sunctx, SUNProfiler profiler) /* set profiler */ sunctx->profiler = profiler; sunctx->own_profiler = SUNFALSE; +#else + /* silence warnings when profiling is disabled */ + ((void)profiler); #endif return SUN_SUCCESS; diff --git a/src/sundials/sundials_errors.c b/src/sundials/sundials_errors.c index 667a3a4e07..acc3a0e5bc 100644 --- a/src/sundials/sundials_errors.c +++ b/src/sundials/sundials_errors.c @@ -10,17 +10,18 @@ * SUNDIALS Copyright End * -----------------------------------------------------------------*/ -#include "sundials/sundials_errors.h" - #include #include #include + #include #include +#include +#include +#include -#include "sundials/sundials_logger.h" -#include "sundials/sundials_types.h" #include "sundials_logger_impl.h" +#include "sundials_macros.h" #include "sundials_utils.h" SUNErrCode SUNErrHandler_Create(SUNErrHandlerFn eh_fn, void* eh_data, @@ -62,7 +63,8 @@ const char* SUNGetErrMsg(SUNErrCode code) void SUNLogErrHandlerFn(int line, const char* func, const char* file, const char* msg, SUNErrCode err_code, - void* err_user_data, SUNContext sunctx) + SUNDIALS_MAYBE_UNUSED void* err_user_data, + SUNContext sunctx) { char* file_and_line = sunCombineFileAndLine(line, file); if (msg == NULL) { msg = SUNGetErrMsg(err_code); } @@ -72,8 +74,10 @@ void SUNLogErrHandlerFn(int line, const char* func, const char* file, } void SUNAbortErrHandlerFn(int line, const char* func, const char* file, - const char* msg, SUNErrCode err_code, - void* err_user_data, SUNContext sunctx) + SUNDIALS_MAYBE_UNUSED const char* msg, + SUNDIALS_MAYBE_UNUSED SUNErrCode err_code, + SUNDIALS_MAYBE_UNUSED void* err_user_data, + SUNContext sunctx) { char* file_and_line = sunCombineFileAndLine(line, file); SUNLogger_QueueMsg(sunctx->logger, SUN_LOGLEVEL_ERROR, file_and_line, func, diff --git a/src/sundials/sundials_hashmap.c b/src/sundials/sundials_hashmap.c index a2a2fc3764..acf1c12c8d 100644 --- a/src/sundials/sundials_hashmap.c +++ b/src/sundials/sundials_hashmap.c @@ -21,9 +21,11 @@ #include #include -#include "sundials/sundials_errors.h" -#include "sundials/sundials_types.h" +#include +#include + #include "sundials_hashmap_impl.h" +#include "sundials_macros.h" static const uint64_t HASH_PRIME = 14695981039346656037U; static const uint64_t HASH_OFFSET_BASIS = 1099511628211U; @@ -33,7 +35,7 @@ static const uint64_t HASH_OFFSET_BASIS = 1099511628211U; https://softwareengineering.stackexchange.com/questions/49550/which-hashing-algorithm-is-best-for-uniqueness-and-speed/145633#145633 This is a 64-bit implementation of the 'a' modification of the - Fowler–Noll–Vo hash (i.e., FNV1-a). + Fowler-Noll-Vo hash (i.e., FNV1-a). */ static uint64_t fnv1a_hash(const char* str) { @@ -161,7 +163,7 @@ int SUNHashMap_Iterate(SUNHashMap map, int start, } static int sunHashMapLinearProbeInsert(int idx, SUNHashMapKeyValue kv, - const void* ctx) + SUNDIALS_MAYBE_UNUSED const void* ctx) { /* find the next open spot */ if (kv == NULL) { return (idx); /* open spot found at idx */ } diff --git a/src/sundials/sundials_logger.c b/src/sundials/sundials_logger.c index 2b109f677b..bc4d6869ae 100644 --- a/src/sundials/sundials_logger.c +++ b/src/sundials/sundials_logger.c @@ -16,18 +16,19 @@ #include #include #include + #include #include +#include #include - -#include "sundials/sundials_errors.h" -#include "sundials/sundials_types.h" +#include #if SUNDIALS_MPI_ENABLED #include #endif #include "sundials_logger_impl.h" +#include "sundials_macros.h" #include "sundials_utils.h" /* max number of files that can be opened */ @@ -65,6 +66,7 @@ void sunCreateLogMessage(SUNLogLevel lvl, int rank, const char* scope, free(formatted_txt); } +#if SUNDIALS_LOGGING_LEVEL > 0 static FILE* sunOpenLogFile(const char* fname, const char* mode) { FILE* fp = NULL; @@ -78,13 +80,15 @@ static FILE* sunOpenLogFile(const char* fname, const char* mode) return fp; } +#endif static void sunCloseLogFile(void* fp) { if (fp && fp != stdout && fp != stderr) { fclose((FILE*)fp); } } -static sunbooleantype sunLoggerIsOutputRank(SUNLogger logger, int* rank_ref) +static sunbooleantype sunLoggerIsOutputRank(SUNDIALS_MAYBE_UNUSED SUNLogger logger, + int* rank_ref) { sunbooleantype retval; @@ -371,6 +375,13 @@ SUNErrCode SUNLogger_QueueMsg(SUNLogger logger, SUNLogLevel lvl, va_end(args); } +#else + /* silence warnings when all logging is disabled */ + ((void)logger); + ((void)lvl); + ((void)scope); + ((void)label); + ((void)msg_txt); #endif return retval; @@ -417,6 +428,9 @@ SUNErrCode SUNLogger_Flush(SUNLogger logger, SUNLogLevel lvl) } } } +#else + /* silence warnings when all logging is disabled */ + ((void)lvl); #endif return retval; diff --git a/src/sundials/sundials_macros.h b/src/sundials/sundials_macros.h new file mode 100644 index 0000000000..4bf007e507 --- /dev/null +++ b/src/sundials/sundials_macros.h @@ -0,0 +1,39 @@ +/* ----------------------------------------------------------------------------- + * Programmer(s): David J. Gardner @ LLNL + * ----------------------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2024, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------------------- + * SUNDIALS macros + * ---------------------------------------------------------------------------*/ + +#ifndef _SUNDIALS_MACROS_H +#define _SUNDIALS_MACROS_H + +#include "sundials/sundials_config.h" + +/* ----------------------------------------------------------------------------- + * SUNDIALS_MAYBE_UNUSED + * + * This maps to an attribute that can be used to silence warnings about unused + * classes, typedefs, variables, functions, or methods when the entity cannot be + * removed. For example, functions or variables that are only used when error + * checks or profiling is enabled. + * ---------------------------------------------------------------------------*/ + +#if __cplusplus >= 201703L || __STDC_VERSION__ > 201710L +#define SUNDIALS_MAYBE_UNUSED [[maybe_unused]] +#elif defined(SUNDIALS_C_COMPILER_HAS_ATTRIBUTE_UNUSED) +#define SUNDIALS_MAYBE_UNUSED __attribute__((unused)) +#else +#define SUNDIALS_MAYBE_UNUSED +#endif + +#endif /* _SUNDIALS_MACROS_H */ diff --git a/src/sundials/sundials_mpi_errors.c b/src/sundials/sundials_mpi_errors.c index ac9f56680c..60ed704a07 100644 --- a/src/sundials/sundials_mpi_errors.c +++ b/src/sundials/sundials_mpi_errors.c @@ -13,16 +13,20 @@ #include #include #include +#include + #include #include #include -#include +#include "sundials_macros.h" #include "sundials_utils.h" void SUNMPIAbortErrHandlerFn(int line, const char* func, const char* file, - const char* msg, SUNErrCode err_code, - void* err_user_data, SUNContext sunctx) + SUNDIALS_MAYBE_UNUSED const char* msg, + SUNErrCode err_code, + SUNDIALS_MAYBE_UNUSED void* err_user_data, + SUNContext sunctx) { char* file_and_line = sunCombineFileAndLine(line, file); SUNLogger_QueueMsg(sunctx->logger, SUN_LOGLEVEL_ERROR, file_and_line, func, diff --git a/src/sundials/sundials_nvector.c b/src/sundials/sundials_nvector.c index a6549d81b5..46791fa66c 100644 --- a/src/sundials/sundials_nvector.c +++ b/src/sundials/sundials_nvector.c @@ -335,7 +335,11 @@ void N_VSpace(N_Vector v, sunindextype* lrw, sunindextype* liw) sunrealtype* N_VGetArrayPointer(N_Vector v) { - return ((sunrealtype*)v->ops->nvgetarraypointer(v)); + if (v->ops->nvgetarraypointer) + { + return (sunrealtype*)v->ops->nvgetarraypointer(v); + } + else { return NULL; } } sunrealtype* N_VGetDeviceArrayPointer(N_Vector v) @@ -349,7 +353,7 @@ sunrealtype* N_VGetDeviceArrayPointer(N_Vector v) void N_VSetArrayPointer(sunrealtype* v_data, N_Vector v) { - v->ops->nvsetarraypointer(v_data, v); + if (v->ops->nvsetarraypointer) { v->ops->nvsetarraypointer(v_data, v); } return; } diff --git a/src/sundials/sundials_profiler.c b/src/sundials/sundials_profiler.c index 1ac2b30aee..c85244817c 100644 --- a/src/sundials/sundials_profiler.c +++ b/src/sundials/sundials_profiler.c @@ -12,12 +12,16 @@ * SUNDIALS Copyright End * -----------------------------------------------------------------*/ +#include +#include #include + #include #include - -#include "sundials/sundials_errors.h" -#include "sundials/sundials_types.h" +#include +#include +#include +#include #if SUNDIALS_MPI_ENABLED #include @@ -33,14 +37,9 @@ #error SUNProfiler needs POSIX or Windows timers #endif -#include -#include -#include -#include -#include - #include "sundials_debug.h" #include "sundials_hashmap_impl.h" +#include "sundials_macros.h" #define SUNDIALS_ROOT_TIMER ((const char*)"From profiler epoch") @@ -58,7 +57,7 @@ typedef struct _sunTimespec #if SUNDIALS_MPI_ENABLED static SUNErrCode sunCollectTimers(SUNProfiler p); #endif -static void sunPrintTimers(int idx, SUNHashMapKeyValue kv, FILE* fp, void* pvoid); +static void sunPrintTimer(SUNHashMapKeyValue kv, FILE* fp, void* pvoid); static int sunCompareTimes(const void* l, const void* r); static int sunclock_gettime_monotonic(sunTimespec* tp); @@ -420,7 +419,7 @@ SUNErrCode SUNProfiler_Print(SUNProfiler p, FILE* fp) /* Print all the other timers out */ for (i = 0; i < p->map->size; i++) { - if (sorted[i]) { sunPrintTimers(i, sorted[i], fp, (void*)p); } + if (sorted[i]) { sunPrintTimer(sorted[i], fp, (void*)p); } } free(sorted); } @@ -443,7 +442,7 @@ SUNErrCode SUNProfiler_Print(SUNProfiler p, FILE* fp) #if SUNDIALS_MPI_ENABLED static void sunTimerStructReduceMaxAndSum(void* a, void* b, int* len, - MPI_Datatype* dType) + SUNDIALS_MAYBE_UNUSED MPI_Datatype* dType) { sunTimerStruct* a_ts = (sunTimerStruct*)a; sunTimerStruct* b_ts = (sunTimerStruct*)b; @@ -523,7 +522,7 @@ SUNErrCode sunCollectTimers(SUNProfiler p) /* Print out the: timer name, percentage of exec time (based on the max), max across ranks, average across ranks, and the timer counter. */ -void sunPrintTimers(int idx, SUNHashMapKeyValue kv, FILE* fp, void* pvoid) +void sunPrintTimer(SUNHashMapKeyValue kv, FILE* fp, void* pvoid) { SUNProfiler p = (SUNProfiler)pvoid; sunTimerStruct* ts = (sunTimerStruct*)kv->value; diff --git a/src/sundials/sundials_utils.h b/src/sundials/sundials_utils.h index 6866ffac2c..44ce2a7d4b 100644 --- a/src/sundials/sundials_utils.h +++ b/src/sundials/sundials_utils.h @@ -71,7 +71,7 @@ static inline int sunvasnprintf(char** str, const char* fmt, va_list args) *str = (char*)malloc(size + 1); if (NULL == *str) { return -1; } - size = vsprintf(*str, fmt, args); + size = vsnprintf(*str, size + 1, fmt, args); return size; } diff --git a/src/sundials/sundials_xbraid.c b/src/sundials/sundials_xbraid.c index 6368d5ca5a..95016e10bd 100644 --- a/src/sundials/sundials_xbraid.c +++ b/src/sundials/sundials_xbraid.c @@ -14,9 +14,10 @@ * This is the implementation file for the SUNDIALS + XBraid interface. * -------------------------------------------------------------------------- */ -#include "sundials/sundials_xbraid.h" +#include +#include -#include "sundials/sundials_math.h" +#include "sundials_macros.h" #define ONE SUN_RCONST(1.0) @@ -114,7 +115,8 @@ int SUNBraidVector_GetNVector(SUNBraidVector u, N_Vector* y) } /* Create clone of an existing vector */ -int SUNBraidVector_Clone(braid_App app, braid_Vector u, braid_Vector* v_ptr) +int SUNBraidVector_Clone(SUNDIALS_MAYBE_UNUSED braid_App app, braid_Vector u, + braid_Vector* v_ptr) { int flag; N_Vector vy; @@ -138,7 +140,7 @@ int SUNBraidVector_Clone(braid_App app, braid_Vector u, braid_Vector* v_ptr) } /* Free vector */ -int SUNBraidVector_Free(braid_App app, braid_Vector u) +int SUNBraidVector_Free(SUNDIALS_MAYBE_UNUSED braid_App app, braid_Vector u) { /* Check for valid input */ if (u == NULL) { return SUNBRAID_SUCCESS; } @@ -158,8 +160,8 @@ int SUNBraidVector_Free(braid_App app, braid_Vector u) } /* Compute alpha x + beta y -> y */ -int SUNBraidVector_Sum(braid_App app, braid_Real alpha, braid_Vector x, - braid_Real beta, braid_Vector y) +int SUNBraidVector_Sum(SUNDIALS_MAYBE_UNUSED braid_App app, braid_Real alpha, + braid_Vector x, braid_Real beta, braid_Vector y) { /* Check for valid wrappers */ if (x == NULL || y == NULL) { return SUNBRAID_ILLINPUT; } @@ -171,7 +173,8 @@ int SUNBraidVector_Sum(braid_App app, braid_Real alpha, braid_Vector x, } /* Compute L2 norm */ -int SUNBraidVector_SpatialNorm(braid_App app, braid_Vector u, braid_Real* norm_ptr) +int SUNBraidVector_SpatialNorm(SUNDIALS_MAYBE_UNUSED braid_App app, + braid_Vector u, braid_Real* norm_ptr) { /* Check for valid wrapper */ if (u == NULL) { return SUNBRAID_ILLINPUT; } @@ -185,7 +188,7 @@ int SUNBraidVector_SpatialNorm(braid_App app, braid_Vector u, braid_Real* norm_p /* Compute message buffer size */ int SUNBraidVector_BufSize(braid_App app, braid_Int* size_ptr, - braid_BufferStatus bstatus) + SUNDIALS_MAYBE_UNUSED braid_BufferStatus bstatus) { int flag; /* return flag */ N_Vector ytmpl; /* template vector */ @@ -202,8 +205,9 @@ int SUNBraidVector_BufSize(braid_App app, braid_Int* size_ptr, } /* Pack message buffer */ -int SUNBraidVector_BufPack(braid_App app, braid_Vector u, void* buffer, - braid_BufferStatus bstatus) +int SUNBraidVector_BufPack(SUNDIALS_MAYBE_UNUSED braid_App app, braid_Vector u, + void* buffer, + SUNDIALS_MAYBE_UNUSED braid_BufferStatus bstatus) { int flag; /* return flag */ @@ -220,7 +224,7 @@ int SUNBraidVector_BufPack(braid_App app, braid_Vector u, void* buffer, /* Unpack message buffer */ int SUNBraidVector_BufUnpack(braid_App app, void* buffer, braid_Vector* u_ptr, - braid_BufferStatus bstatus) + SUNDIALS_MAYBE_UNUSED braid_BufferStatus bstatus) { int flag; /* return flag */ N_Vector ytmpl; /* template vector */ diff --git a/src/sunlinsol/band/sunlinsol_band.c b/src/sunlinsol/band/sunlinsol_band.c index 775466bd28..d72e37af1c 100644 --- a/src/sunlinsol/band/sunlinsol_band.c +++ b/src/sunlinsol/band/sunlinsol_band.c @@ -17,11 +17,14 @@ #include #include + #include #include #include #include +#include "sundials_macros.h" + #define ZERO SUN_RCONST(0.0) #define ONE SUN_RCONST(1.0) #define ROW(i, j, smu) (i - j + smu) @@ -46,7 +49,8 @@ * Function to create a new band linear solver */ -SUNLinearSolver SUNLinSol_Band(N_Vector y, SUNMatrix A, SUNContext sunctx) +SUNLinearSolver SUNLinSol_Band(SUNDIALS_MAYBE_UNUSED N_Vector y, SUNMatrix A, + SUNContext sunctx) { SUNFunctionBegin(sunctx); SUNLinearSolver S; @@ -107,12 +111,12 @@ SUNLinearSolver SUNLinSol_Band(N_Vector y, SUNMatrix A, SUNContext sunctx) * ----------------------------------------------------------------- */ -SUNLinearSolver_Type SUNLinSolGetType_Band(SUNLinearSolver S) +SUNLinearSolver_Type SUNLinSolGetType_Band(SUNDIALS_MAYBE_UNUSED SUNLinearSolver S) { return (SUNLINEARSOLVER_DIRECT); } -SUNLinearSolver_ID SUNLinSolGetID_Band(SUNLinearSolver S) +SUNLinearSolver_ID SUNLinSolGetID_Band(SUNDIALS_MAYBE_UNUSED SUNLinearSolver S) { return (SUNLINEARSOLVER_BAND); } @@ -156,7 +160,7 @@ int SUNLinSolSetup_Band(SUNLinearSolver S, SUNMatrix A) } int SUNLinSolSolve_Band(SUNLinearSolver S, SUNMatrix A, N_Vector x, N_Vector b, - sunrealtype tol) + SUNDIALS_MAYBE_UNUSED sunrealtype tol) { SUNFunctionBegin(S->sunctx); sunrealtype **A_cols, *xdata; diff --git a/src/sunlinsol/dense/sunlinsol_dense.c b/src/sunlinsol/dense/sunlinsol_dense.c index 13a1fa9dbd..41e6a1bb61 100644 --- a/src/sunlinsol/dense/sunlinsol_dense.c +++ b/src/sunlinsol/dense/sunlinsol_dense.c @@ -17,12 +17,14 @@ #include #include + #include +#include #include #include -#include "sundials/sundials_errors.h" #include "sundials_logger_impl.h" +#include "sundials_macros.h" #define ONE SUN_RCONST(1.0) @@ -46,7 +48,8 @@ * Function to create a new dense linear solver */ -SUNLinearSolver SUNLinSol_Dense(N_Vector y, SUNMatrix A, SUNContext sunctx) +SUNLinearSolver SUNLinSol_Dense(SUNDIALS_MAYBE_UNUSED N_Vector y, SUNMatrix A, + SUNContext sunctx) { SUNFunctionBegin(sunctx); SUNLinearSolver S; @@ -102,12 +105,12 @@ SUNLinearSolver SUNLinSol_Dense(N_Vector y, SUNMatrix A, SUNContext sunctx) * ----------------------------------------------------------------- */ -SUNLinearSolver_Type SUNLinSolGetType_Dense(SUNLinearSolver S) +SUNLinearSolver_Type SUNLinSolGetType_Dense(SUNDIALS_MAYBE_UNUSED SUNLinearSolver S) { return (SUNLINEARSOLVER_DIRECT); } -SUNLinearSolver_ID SUNLinSolGetID_Dense(SUNLinearSolver S) +SUNLinearSolver_ID SUNLinSolGetID_Dense(SUNDIALS_MAYBE_UNUSED SUNLinearSolver S) { return (SUNLINEARSOLVER_DENSE); } @@ -146,7 +149,7 @@ int SUNLinSolSetup_Dense(SUNLinearSolver S, SUNMatrix A) } int SUNLinSolSolve_Dense(SUNLinearSolver S, SUNMatrix A, N_Vector x, N_Vector b, - sunrealtype tol) + SUNDIALS_MAYBE_UNUSED sunrealtype tol) { SUNFunctionBegin(S->sunctx); sunrealtype **A_cols, *xdata; diff --git a/src/sunlinsol/klu/sunlinsol_klu.c b/src/sunlinsol/klu/sunlinsol_klu.c index 3594b24f4f..b2a1f290e2 100644 --- a/src/sunlinsol/klu/sunlinsol_klu.c +++ b/src/sunlinsol/klu/sunlinsol_klu.c @@ -19,10 +19,12 @@ #include #include #include + +#include #include #include -#include "sundials/sundials_errors.h" +#include "sundials_macros.h" #define ZERO SUN_RCONST(0.0) #define ONE SUN_RCONST(1.0) @@ -216,12 +218,12 @@ sun_klu_common* SUNLinSol_KLUGetCommon(SUNLinearSolver S) * ----------------------------------------------------------------- */ -SUNLinearSolver_Type SUNLinSolGetType_KLU(SUNLinearSolver S) +SUNLinearSolver_Type SUNLinSolGetType_KLU(SUNDIALS_MAYBE_UNUSED SUNLinearSolver S) { return (SUNLINEARSOLVER_DIRECT); } -SUNLinearSolver_ID SUNLinSolGetID_KLU(SUNLinearSolver S) +SUNLinearSolver_ID SUNLinSolGetID_KLU(SUNDIALS_MAYBE_UNUSED SUNLinearSolver S) { return (SUNLINEARSOLVER_KLU); } @@ -340,7 +342,7 @@ int SUNLinSolSetup_KLU(SUNLinearSolver S, SUNMatrix A) } int SUNLinSolSolve_KLU(SUNLinearSolver S, SUNMatrix A, N_Vector x, N_Vector b, - sunrealtype tol) + SUNDIALS_MAYBE_UNUSED sunrealtype tol) { int flag; sunrealtype* xdata; @@ -377,8 +379,8 @@ int SUNLinSolSolve_KLU(SUNLinearSolver S, SUNMatrix A, N_Vector x, N_Vector b, sunindextype SUNLinSolLastFlag_KLU(SUNLinearSolver S) { return (LASTFLAG(S)); } -SUNErrCode SUNLinSolSpace_KLU(SUNLinearSolver S, long int* lenrwLS, - long int* leniwLS) +SUNErrCode SUNLinSolSpace_KLU(SUNDIALS_MAYBE_UNUSED SUNLinearSolver S, + long int* lenrwLS, long int* leniwLS) { /* since the klu structures are opaque objects, we omit those from these results */ diff --git a/src/sunlinsol/lapackband/sunlinsol_lapackband.c b/src/sunlinsol/lapackband/sunlinsol_lapackband.c index cce85657d5..ce26bb6951 100644 --- a/src/sunlinsol/lapackband/sunlinsol_lapackband.c +++ b/src/sunlinsol/lapackband/sunlinsol_lapackband.c @@ -18,10 +18,12 @@ #include #include + #include #include #include "sundials_lapack_defs.h" +#include "sundials_macros.h" /* Interfaces to match 'sunrealtype' with the correct LAPACK functions */ #if defined(SUNDIALS_DOUBLE_PRECISION) @@ -127,12 +129,13 @@ SUNLinearSolver SUNLinSol_LapackBand(N_Vector y, SUNMatrix A, SUNContext sunctx) * ----------------------------------------------------------------- */ -SUNLinearSolver_Type SUNLinSolGetType_LapackBand(SUNLinearSolver S) +SUNLinearSolver_Type SUNLinSolGetType_LapackBand( + SUNDIALS_MAYBE_UNUSED SUNLinearSolver S) { return (SUNLINEARSOLVER_DIRECT); } -SUNLinearSolver_ID SUNLinSolGetID_LapackBand(SUNLinearSolver S) +SUNLinearSolver_ID SUNLinSolGetID_LapackBand(SUNDIALS_MAYBE_UNUSED SUNLinearSolver S) { return (SUNLINEARSOLVER_LAPACKBAND); } @@ -173,7 +176,7 @@ int SUNLinSolSetup_LapackBand(SUNLinearSolver S, SUNMatrix A) } int SUNLinSolSolve_LapackBand(SUNLinearSolver S, SUNMatrix A, N_Vector x, - N_Vector b, sunrealtype tol) + N_Vector b, SUNDIALS_MAYBE_UNUSED sunrealtype tol) { sunindextype n, ml, mu, ldim, one, ier; sunrealtype* xdata; diff --git a/src/sunlinsol/lapackdense/sunlinsol_lapackdense.c b/src/sunlinsol/lapackdense/sunlinsol_lapackdense.c index 09a17910cc..a13460b035 100644 --- a/src/sunlinsol/lapackdense/sunlinsol_lapackdense.c +++ b/src/sunlinsol/lapackdense/sunlinsol_lapackdense.c @@ -18,10 +18,12 @@ #include #include + #include #include #include "sundials_lapack_defs.h" +#include "sundials_macros.h" /* Interfaces to match 'sunrealtype' with the correct LAPACK functions */ #if defined(SUNDIALS_DOUBLE_PRECISION) @@ -128,12 +130,13 @@ SUNLinearSolver SUNLinSol_LapackDense(N_Vector y, SUNMatrix A, SUNContext sunctx * ----------------------------------------------------------------- */ -SUNLinearSolver_Type SUNLinSolGetType_LapackDense(SUNLinearSolver S) +SUNLinearSolver_Type SUNLinSolGetType_LapackDense( + SUNDIALS_MAYBE_UNUSED SUNLinearSolver S) { return (SUNLINEARSOLVER_DIRECT); } -SUNLinearSolver_ID SUNLinSolGetID_LapackDense(SUNLinearSolver S) +SUNLinearSolver_ID SUNLinSolGetID_LapackDense(SUNDIALS_MAYBE_UNUSED SUNLinearSolver S) { return (SUNLINEARSOLVER_LAPACKDENSE); } @@ -170,7 +173,7 @@ int SUNLinSolSetup_LapackDense(SUNLinearSolver S, SUNMatrix A) } int SUNLinSolSolve_LapackDense(SUNLinearSolver S, SUNMatrix A, N_Vector x, - N_Vector b, sunrealtype tol) + N_Vector b, SUNDIALS_MAYBE_UNUSED sunrealtype tol) { sunindextype n, one, ier; sunrealtype* xdata; diff --git a/src/sunlinsol/pcg/sunlinsol_pcg.c b/src/sunlinsol/pcg/sunlinsol_pcg.c index 1504a744dc..100183e82c 100644 --- a/src/sunlinsol/pcg/sunlinsol_pcg.c +++ b/src/sunlinsol/pcg/sunlinsol_pcg.c @@ -18,11 +18,13 @@ #include #include + #include #include #include #include "sundials_logger_impl.h" +#include "sundials_macros.h" #define ZERO SUN_RCONST(0.0) #define ONE SUN_RCONST(1.0) @@ -162,12 +164,12 @@ SUNErrCode SUNLinSol_PCGSetMaxl(SUNLinearSolver S, int maxl) * ----------------------------------------------------------------- */ -SUNLinearSolver_Type SUNLinSolGetType_PCG(SUNLinearSolver S) +SUNLinearSolver_Type SUNLinSolGetType_PCG(SUNDIALS_MAYBE_UNUSED SUNLinearSolver S) { return (SUNLINEARSOLVER_ITERATIVE); } -SUNLinearSolver_ID SUNLinSolGetID_PCG(SUNLinearSolver S) +SUNLinearSolver_ID SUNLinSolGetID_PCG(SUNDIALS_MAYBE_UNUSED SUNLinearSolver S) { return (SUNLINEARSOLVER_PCG); } @@ -216,7 +218,7 @@ SUNErrCode SUNLinSolSetPreconditioner_PCG(SUNLinearSolver S, void* PData, } SUNErrCode SUNLinSolSetScalingVectors_PCG(SUNLinearSolver S, N_Vector s, - N_Vector nul) + SUNDIALS_MAYBE_UNUSED N_Vector nul) { /* set N_Vector pointer to integrator-supplied scaling vector (only use the first one), and return with success */ @@ -231,7 +233,7 @@ SUNErrCode SUNLinSolSetZeroGuess_PCG(SUNLinearSolver S, sunbooleantype onoff) return SUN_SUCCESS; } -int SUNLinSolSetup_PCG(SUNLinearSolver S, SUNMatrix nul) +int SUNLinSolSetup_PCG(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix nul) { SUNFunctionBegin(S->sunctx); @@ -260,8 +262,8 @@ int SUNLinSolSetup_PCG(SUNLinearSolver S, SUNMatrix nul) return SUN_SUCCESS; } -int SUNLinSolSolve_PCG(SUNLinearSolver S, SUNMatrix nul, N_Vector x, N_Vector b, - sunrealtype delta) +int SUNLinSolSolve_PCG(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix nul, + N_Vector x, N_Vector b, sunrealtype delta) { SUNFunctionBegin(S->sunctx); diff --git a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c index 168e554176..67df9bcdfe 100644 --- a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c +++ b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c @@ -19,12 +19,14 @@ #include #include + #include #include #include #include "sundials/sundials_errors.h" #include "sundials_logger_impl.h" +#include "sundials_macros.h" #define ZERO SUN_RCONST(0.0) #define ONE SUN_RCONST(1.0) @@ -186,12 +188,12 @@ SUNErrCode SUNLinSol_SPBCGSSetMaxl(SUNLinearSolver S, int maxl) * ----------------------------------------------------------------- */ -SUNLinearSolver_Type SUNLinSolGetType_SPBCGS(SUNLinearSolver S) +SUNLinearSolver_Type SUNLinSolGetType_SPBCGS(SUNDIALS_MAYBE_UNUSED SUNLinearSolver S) { return (SUNLINEARSOLVER_ITERATIVE); } -SUNLinearSolver_ID SUNLinSolGetID_SPBCGS(SUNLinearSolver S) +SUNLinearSolver_ID SUNLinSolGetID_SPBCGS(SUNDIALS_MAYBE_UNUSED SUNLinearSolver S) { return (SUNLINEARSOLVER_SPBCGS); } @@ -265,7 +267,7 @@ SUNErrCode SUNLinSolSetZeroGuess_SPBCGS(SUNLinearSolver S, sunbooleantype onoff) return SUN_SUCCESS; } -int SUNLinSolSetup_SPBCGS(SUNLinearSolver S, SUNMatrix A) +int SUNLinSolSetup_SPBCGS(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A) { SUNFunctionBegin(S->sunctx); @@ -294,8 +296,8 @@ int SUNLinSolSetup_SPBCGS(SUNLinearSolver S, SUNMatrix A) return (LASTFLAG(S)); } -int SUNLinSolSolve_SPBCGS(SUNLinearSolver S, SUNMatrix A, N_Vector x, - N_Vector b, sunrealtype delta) +int SUNLinSolSolve_SPBCGS(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, + N_Vector x, N_Vector b, sunrealtype delta) { SUNFunctionBegin(S->sunctx); diff --git a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c index 4e726e2d7e..a1d3ea27ad 100644 --- a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c +++ b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c @@ -19,11 +19,13 @@ #include #include + #include #include #include #include "sundials_logger_impl.h" +#include "sundials_macros.h" #define ZERO SUN_RCONST(0.0) #define ONE SUN_RCONST(1.0) @@ -190,12 +192,12 @@ SUNErrCode SUNLinSol_SPFGMRSetMaxRestarts(SUNLinearSolver S, int maxrs) * ----------------------------------------------------------------- */ -SUNLinearSolver_Type SUNLinSolGetType_SPFGMR(SUNLinearSolver S) +SUNLinearSolver_Type SUNLinSolGetType_SPFGMR(SUNDIALS_MAYBE_UNUSED SUNLinearSolver S) { return (SUNLINEARSOLVER_ITERATIVE); } -SUNLinearSolver_ID SUNLinSolGetID_SPFGMR(SUNLinearSolver S) +SUNLinearSolver_ID SUNLinSolGetID_SPFGMR(SUNDIALS_MAYBE_UNUSED SUNLinearSolver S) { return (SUNLINEARSOLVER_SPFGMR); } @@ -330,7 +332,7 @@ SUNErrCode SUNLinSolSetZeroGuess_SPFGMR(SUNLinearSolver S, sunbooleantype onoff) return SUN_SUCCESS; } -int SUNLinSolSetup_SPFGMR(SUNLinearSolver S, SUNMatrix A) +int SUNLinSolSetup_SPFGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A) { SUNFunctionBegin(S->sunctx); @@ -359,8 +361,8 @@ int SUNLinSolSetup_SPFGMR(SUNLinearSolver S, SUNMatrix A) return SUN_SUCCESS; } -int SUNLinSolSolve_SPFGMR(SUNLinearSolver S, SUNMatrix A, N_Vector x, - N_Vector b, sunrealtype delta) +int SUNLinSolSolve_SPFGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, + N_Vector x, N_Vector b, sunrealtype delta) { SUNFunctionBegin(S->sunctx); diff --git a/src/sunlinsol/spgmr/sunlinsol_spgmr.c b/src/sunlinsol/spgmr/sunlinsol_spgmr.c index c1e10b3629..6ef57661ae 100644 --- a/src/sunlinsol/spgmr/sunlinsol_spgmr.c +++ b/src/sunlinsol/spgmr/sunlinsol_spgmr.c @@ -19,11 +19,13 @@ #include #include + #include #include #include #include "sundials_logger_impl.h" +#include "sundials_macros.h" #define ZERO SUN_RCONST(0.0) #define ONE SUN_RCONST(1.0) @@ -185,12 +187,12 @@ SUNErrCode SUNLinSol_SPGMRSetMaxRestarts(SUNLinearSolver S, int maxrs) * ----------------------------------------------------------------- */ -SUNLinearSolver_Type SUNLinSolGetType_SPGMR(SUNLinearSolver S) +SUNLinearSolver_Type SUNLinSolGetType_SPGMR(SUNDIALS_MAYBE_UNUSED SUNLinearSolver S) { return (SUNLINEARSOLVER_ITERATIVE); } -SUNLinearSolver_ID SUNLinSolGetID_SPGMR(SUNLinearSolver S) +SUNLinearSolver_ID SUNLinSolGetID_SPGMR(SUNDIALS_MAYBE_UNUSED SUNLinearSolver S) { return (SUNLINEARSOLVER_SPGMR); } @@ -317,7 +319,7 @@ SUNErrCode SUNLinSolSetZeroGuess_SPGMR(SUNLinearSolver S, sunbooleantype onff) return SUN_SUCCESS; } -int SUNLinSolSetup_SPGMR(SUNLinearSolver S, SUNMatrix A) +int SUNLinSolSetup_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A) { SUNFunctionBegin(S->sunctx); @@ -344,8 +346,8 @@ int SUNLinSolSetup_SPGMR(SUNLinearSolver S, SUNMatrix A) return SUN_SUCCESS; } -int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNMatrix A, N_Vector x, N_Vector b, - sunrealtype delta) +int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, + N_Vector x, N_Vector b, sunrealtype delta) { SUNFunctionBegin(S->sunctx); diff --git a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c index 6f09ccc1db..28ad1ef883 100644 --- a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c +++ b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c @@ -18,11 +18,13 @@ #include #include + #include #include #include #include "sundials_logger_impl.h" +#include "sundials_macros.h" #define ZERO SUN_RCONST(0.0) #define ONE SUN_RCONST(1.0) @@ -184,12 +186,12 @@ SUNErrCode SUNLinSol_SPTFQMRSetMaxl(SUNLinearSolver S, int maxl) * ----------------------------------------------------------------- */ -SUNLinearSolver_Type SUNLinSolGetType_SPTFQMR(SUNLinearSolver S) +SUNLinearSolver_Type SUNLinSolGetType_SPTFQMR(SUNDIALS_MAYBE_UNUSED SUNLinearSolver S) { return (SUNLINEARSOLVER_ITERATIVE); } -SUNLinearSolver_ID SUNLinSolGetID_SPTFQMR(SUNLinearSolver S) +SUNLinearSolver_ID SUNLinSolGetID_SPTFQMR(SUNDIALS_MAYBE_UNUSED SUNLinearSolver S) { return (SUNLINEARSOLVER_SPTFQMR); } @@ -260,7 +262,7 @@ SUNErrCode SUNLinSolSetZeroGuess_SPTFQMR(SUNLinearSolver S, sunbooleantype onoff return SUN_SUCCESS; } -int SUNLinSolSetup_SPTFQMR(SUNLinearSolver S, SUNMatrix A) +int SUNLinSolSetup_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A) { SUNFunctionBegin(S->sunctx); @@ -289,8 +291,8 @@ int SUNLinSolSetup_SPTFQMR(SUNLinearSolver S, SUNMatrix A) return SUN_SUCCESS; } -int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNMatrix A, N_Vector x, - N_Vector b, sunrealtype delta) +int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, + N_Vector x, N_Vector b, sunrealtype delta) { SUNFunctionBegin(S->sunctx); diff --git a/src/sunlinsol/superludist/sunlinsol_superludist.c b/src/sunlinsol/superludist/sunlinsol_superludist.c index 55df80aeba..8b58d1d22b 100644 --- a/src/sunlinsol/superludist/sunlinsol_superludist.c +++ b/src/sunlinsol/superludist/sunlinsol_superludist.c @@ -17,10 +17,14 @@ #include #include + +#include + #include #include #include -#include + +#include "sundials_macros.h" #define ZERO SUN_RCONST(0.0) #define ONE SUN_RCONST(1.0) @@ -166,12 +170,13 @@ SuperLUStat_t* SUNLinSol_SuperLUDIST_GetSuperLUStat(SUNLinearSolver LS) * ----------------------------------------------------------------- */ -SUNLinearSolver_Type SUNLinSolGetType_SuperLUDIST(SUNLinearSolver S) +SUNLinearSolver_Type SUNLinSolGetType_SuperLUDIST( + SUNDIALS_MAYBE_UNUSED SUNLinearSolver S) { return (SUNLINEARSOLVER_DIRECT); } -SUNLinearSolver_ID SUNLinSolGetID_SuperLUDIST(SUNLinearSolver S) +SUNLinearSolver_ID SUNLinSolGetID_SuperLUDIST(SUNDIALS_MAYBE_UNUSED SUNLinearSolver S) { return (SUNLINEARSOLVER_SUPERLUDIST); } @@ -184,7 +189,8 @@ SUNErrCode SUNLinSolInitialize_SuperLUDIST(SUNLinearSolver S) return (SLU_LASTFLAG(S)); } -int SUNLinSolSetup_SuperLUDIST(SUNLinearSolver S, SUNMatrix A) +int SUNLinSolSetup_SuperLUDIST(SUNLinearSolver S, + SUNDIALS_MAYBE_UNUSED SUNMatrix A) { if (SLU_FIRSTFACTORIZE(S)) { @@ -210,7 +216,7 @@ int SUNLinSolSetup_SuperLUDIST(SUNLinearSolver S, SUNMatrix A) } int SUNLinSolSolve_SuperLUDIST(SUNLinearSolver S, SUNMatrix A, N_Vector x, - N_Vector b, sunrealtype tol) + N_Vector b, SUNDIALS_MAYBE_UNUSED sunrealtype tol) { int retval; sunrealtype* xdata; @@ -296,8 +302,8 @@ SUNErrCode SUNLinSolFree_SuperLUDIST(SUNLinearSolver S) return SUN_SUCCESS; } -SUNErrCode SUNLinSolSpace_SuperLUDIST(SUNLinearSolver S, long int* leniwLS, - long int* lenrwLS) +SUNErrCode SUNLinSolSpace_SuperLUDIST(SUNDIALS_MAYBE_UNUSED SUNLinearSolver S, + long int* leniwLS, long int* lenrwLS) { /* since the SuperLU_DIST structures are opaque objects, we omit those from these results */ diff --git a/src/sunlinsol/superlumt/sunlinsol_superlumt.c b/src/sunlinsol/superlumt/sunlinsol_superlumt.c index 609243d5a3..439a948fed 100644 --- a/src/sunlinsol/superlumt/sunlinsol_superlumt.c +++ b/src/sunlinsol/superlumt/sunlinsol_superlumt.c @@ -20,10 +20,12 @@ #include #include + +#include #include #include -#include "sundials/sundials_errors.h" +#include "sundials_macros.h" #define ZERO SUN_RCONST(0.0) #define ONE SUN_RCONST(1.0) @@ -229,12 +231,13 @@ SUNErrCode SUNLinSol_SuperLUMTSetOrdering(SUNLinearSolver S, int ordering_choice * ----------------------------------------------------------------- */ -SUNLinearSolver_Type SUNLinSolGetType_SuperLUMT(SUNLinearSolver S) +SUNLinearSolver_Type SUNLinSolGetType_SuperLUMT( + SUNDIALS_MAYBE_UNUSED SUNLinearSolver S) { return SUNLINEARSOLVER_DIRECT; } -SUNLinearSolver_ID SUNLinSolGetID_SuperLUMT(SUNLinearSolver S) +SUNLinearSolver_ID SUNLinSolGetID_SuperLUMT(SUNDIALS_MAYBE_UNUSED SUNLinearSolver S) { return SUNLINEARSOLVER_SUPERLUMT; } @@ -319,7 +322,7 @@ int SUNLinSolSetup_SuperLUMT(SUNLinearSolver S, SUNMatrix A) } int SUNLinSolSolve_SuperLUMT(SUNLinearSolver S, SUNMatrix A, N_Vector x, - N_Vector b, sunrealtype tol) + N_Vector b, SUNDIALS_MAYBE_UNUSED sunrealtype tol) { int_t retval; sunrealtype* xdata; diff --git a/src/sunmatrix/band/sunmatrix_band.c b/src/sunmatrix/band/sunmatrix_band.c index 238450443e..f3d06c730b 100644 --- a/src/sunmatrix/band/sunmatrix_band.c +++ b/src/sunmatrix/band/sunmatrix_band.c @@ -22,11 +22,13 @@ #include #include + #include +#include #include #include -#include "sundials/sundials_errors.h" +#include "sundials_macros.h" #define ZERO SUN_RCONST(0.0) #define ONE SUN_RCONST(1.0) @@ -230,7 +232,10 @@ sunrealtype* SUNBandMatrix_Column(SUNMatrix A, sunindextype j) * ----------------------------------------------------------------- */ -SUNMatrix_ID SUNMatGetID_Band(SUNMatrix A) { return SUNMATRIX_BAND; } +SUNMatrix_ID SUNMatGetID_Band(SUNDIALS_MAYBE_UNUSED SUNMatrix A) +{ + return SUNMATRIX_BAND; +} SUNMatrix SUNMatClone_Band(SUNMatrix A) { @@ -428,6 +433,7 @@ SUNErrCode SUNMatSpace_Band(SUNMatrix A, long int* lenrw, long int* leniw) * ----------------------------------------------------------------- */ +SUNDIALS_MAYBE_UNUSED static sunbooleantype compatibleMatrices(SUNMatrix A, SUNMatrix B) { /* both matrices must have the same number of columns @@ -437,6 +443,7 @@ static sunbooleantype compatibleMatrices(SUNMatrix A, SUNMatrix B) return SUNTRUE; } +SUNDIALS_MAYBE_UNUSED static sunbooleantype compatibleMatrixAndVectors(SUNMatrix A, N_Vector x, N_Vector y) { diff --git a/src/sunmatrix/dense/sunmatrix_dense.c b/src/sunmatrix/dense/sunmatrix_dense.c index 5067379fd5..c1250a9eaa 100644 --- a/src/sunmatrix/dense/sunmatrix_dense.c +++ b/src/sunmatrix/dense/sunmatrix_dense.c @@ -20,10 +20,12 @@ #include #include + #include +#include #include -#include "sundials/sundials_errors.h" +#include "sundials_macros.h" #define ZERO SUN_RCONST(0.0) #define ONE SUN_RCONST(1.0) @@ -178,7 +180,10 @@ sunrealtype* SUNDenseMatrix_Column(SUNMatrix A, sunindextype j) * ----------------------------------------------------------------- */ -SUNMatrix_ID SUNMatGetID_Dense(SUNMatrix A) { return SUNMATRIX_DENSE; } +SUNMatrix_ID SUNMatGetID_Dense(SUNDIALS_MAYBE_UNUSED SUNMatrix A) +{ + return SUNMATRIX_DENSE; +} SUNMatrix SUNMatClone_Dense(SUNMatrix A) { @@ -346,6 +351,7 @@ SUNErrCode SUNMatSpace_Dense(SUNMatrix A, long int* lenrw, long int* leniw) * ----------------------------------------------------------------- */ +SUNDIALS_MAYBE_UNUSED static sunbooleantype compatibleMatrices(SUNMatrix A, SUNMatrix B) { /* both matrices must have the same shape */ @@ -357,6 +363,7 @@ static sunbooleantype compatibleMatrices(SUNMatrix A, SUNMatrix B) return SUNTRUE; } +SUNDIALS_MAYBE_UNUSED static sunbooleantype compatibleMatrixAndVectors(SUNMatrix A, N_Vector x, N_Vector y) { diff --git a/src/sunmatrix/slunrloc/sunmatrix_slunrloc.c b/src/sunmatrix/slunrloc/sunmatrix_slunrloc.c index a17ab753d9..5c84fc3b76 100644 --- a/src/sunmatrix/slunrloc/sunmatrix_slunrloc.c +++ b/src/sunmatrix/slunrloc/sunmatrix_slunrloc.c @@ -20,10 +20,14 @@ #include #include #include + +#include + #include #include #include -#include + +#include "sundials_macros.h" /* * ---------------------------------------------------------------------------- @@ -171,7 +175,10 @@ sunbooleantype SUNMatrix_SLUNRloc_OwnData(SUNMatrix A) * ---------------------------------------------------------------------------- */ -SUNMatrix_ID SUNMatGetID_SLUNRloc(SUNMatrix A) { return (SUNMATRIX_SLUNRLOC); } +SUNMatrix_ID SUNMatGetID_SLUNRloc(SUNDIALS_MAYBE_UNUSED SUNMatrix A) +{ + return (SUNMATRIX_SLUNRLOC); +} SUNMatrix SUNMatClone_SLUNRloc(SUNMatrix A) { diff --git a/src/sunmatrix/sparse/sunmatrix_sparse.c b/src/sunmatrix/sparse/sunmatrix_sparse.c index 18d644dba5..bbdbc344d2 100644 --- a/src/sunmatrix/sparse/sunmatrix_sparse.c +++ b/src/sunmatrix/sparse/sunmatrix_sparse.c @@ -22,13 +22,15 @@ #include #include + #include +#include #include #include #include #include -#include "sundials/sundials_errors.h" +#include "sundials_macros.h" #define ZERO SUN_RCONST(0.0) #define ONE SUN_RCONST(1.0) @@ -497,7 +499,10 @@ sunindextype* SUNSparseMatrix_IndexPointers(SUNMatrix A) * ----------------------------------------------------------------- */ -SUNMatrix_ID SUNMatGetID_Sparse(SUNMatrix A) { return SUNMATRIX_SPARSE; } +SUNMatrix_ID SUNMatGetID_Sparse(SUNDIALS_MAYBE_UNUSED SUNMatrix A) +{ + return SUNMATRIX_SPARSE; +} SUNMatrix SUNMatClone_Sparse(SUNMatrix A) { @@ -1120,6 +1125,7 @@ SUNErrCode SUNMatSpace_Sparse(SUNMatrix A, long int* lenrw, long int* leniw) * Function to check compatibility of two sparse SUNMatrix objects */ +SUNDIALS_MAYBE_UNUSED static sunbooleantype compatibleMatrices(SUNMatrix A, SUNMatrix B) { /* both matrices must have the same shape and sparsity type */ @@ -1138,6 +1144,7 @@ static sunbooleantype compatibleMatrices(SUNMatrix A, SUNMatrix B) * N_Vectors (A*x = b) */ +SUNDIALS_MAYBE_UNUSED static sunbooleantype compatibleMatrixAndVectors(SUNMatrix A, N_Vector x, N_Vector y) { diff --git a/src/sunmemory/system/sundials_system_memory.c b/src/sunmemory/system/sundials_system_memory.c index 00839c6d59..8b34d7f137 100644 --- a/src/sunmemory/system/sundials_system_memory.c +++ b/src/sunmemory/system/sundials_system_memory.c @@ -17,13 +17,15 @@ #include #include + +#include +#include #include +#include #include -#include "sundials/priv/sundials_errors_impl.h" -#include "sundials/sundials_errors.h" -#include "sundials/sundials_memory.h" #include "sundials_debug.h" +#include "sundials_macros.h" struct SUNMemoryHelper_Content_Sys_ { @@ -70,7 +72,7 @@ SUNMemoryHelper SUNMemoryHelper_Sys(SUNContext sunctx) SUNErrCode SUNMemoryHelper_Alloc_Sys(SUNMemoryHelper helper, SUNMemory* memptr, size_t mem_size, SUNMemoryType mem_type, - void* queue) + SUNDIALS_MAYBE_UNUSED void* queue) { SUNFunctionBegin(helper->sunctx); @@ -100,7 +102,7 @@ SUNErrCode SUNMemoryHelper_Alloc_Sys(SUNMemoryHelper helper, SUNMemory* memptr, } SUNErrCode SUNMemoryHelper_Dealloc_Sys(SUNMemoryHelper helper, SUNMemory mem, - void* queue) + SUNDIALS_MAYBE_UNUSED void* queue) { SUNFunctionBegin(helper->sunctx); @@ -125,7 +127,7 @@ SUNErrCode SUNMemoryHelper_Dealloc_Sys(SUNMemoryHelper helper, SUNMemory mem, SUNErrCode SUNMemoryHelper_Copy_Sys(SUNMemoryHelper helper, SUNMemory dst, SUNMemory src, size_t memory_size, - void* queue) + SUNDIALS_MAYBE_UNUSED void* queue) { SUNFunctionBegin(helper->sunctx); SUNAssert(src->type == SUNMEMTYPE_HOST, SUN_ERR_ARG_INCOMPATIBLE); @@ -134,12 +136,10 @@ SUNErrCode SUNMemoryHelper_Copy_Sys(SUNMemoryHelper helper, SUNMemory dst, return SUN_SUCCESS; } -SUNErrCode SUNMemoryHelper_GetAllocStats_Sys(SUNMemoryHelper helper, - SUNMemoryType mem_type, - unsigned long* num_allocations, - unsigned long* num_deallocations, - size_t* bytes_allocated, - size_t* bytes_high_watermark) +SUNErrCode SUNMemoryHelper_GetAllocStats_Sys( + SUNMemoryHelper helper, SUNDIALS_MAYBE_UNUSED SUNMemoryType mem_type, + unsigned long* num_allocations, unsigned long* num_deallocations, + size_t* bytes_allocated, size_t* bytes_high_watermark) { SUNFunctionBegin(helper->sunctx); SUNAssert(mem_type == SUNMEMTYPE_HOST, SUN_ERR_ARG_INCOMPATIBLE); diff --git a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c index 1ec228965e..ff1d45a2c9 100644 --- a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c +++ b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c @@ -18,11 +18,13 @@ #include #include #include + #include #include #include #include "sundials_logger_impl.h" +#include "sundials_macros.h" /* Internal utility routines */ static SUNErrCode AndersonAccelerate(SUNNonlinearSolver NLS, N_Vector gval, @@ -129,7 +131,8 @@ SUNNonlinearSolver SUNNonlinSol_FixedPointSens(int count, N_Vector y, int m, GetType, Initialize, Setup, Solve, and Free operations ============================================================================*/ -SUNNonlinearSolver_Type SUNNonlinSolGetType_FixedPoint(SUNNonlinearSolver NLS) +SUNNonlinearSolver_Type SUNNonlinSolGetType_FixedPoint( + SUNDIALS_MAYBE_UNUSED SUNNonlinearSolver NLS) { return (SUNNONLINEARSOLVER_FIXEDPOINT); } @@ -165,9 +168,11 @@ SUNErrCode SUNNonlinSolInitialize_FixedPoint(SUNNonlinearSolver NLS) by the Sys function provided to the nonlinear solver. ---------------------------------------------------------------------------*/ -int SUNNonlinSolSolve_FixedPoint(SUNNonlinearSolver NLS, N_Vector y0, +int SUNNonlinSolSolve_FixedPoint(SUNNonlinearSolver NLS, + SUNDIALS_MAYBE_UNUSED N_Vector y0, N_Vector ycor, N_Vector w, sunrealtype tol, - sunbooleantype callSetup, void* mem) + SUNDIALS_MAYBE_UNUSED sunbooleantype callSetup, + void* mem) { SUNFunctionBegin(NLS->sunctx); /* local variables */ diff --git a/src/sunnonlinsol/newton/sunnonlinsol_newton.c b/src/sunnonlinsol/newton/sunnonlinsol_newton.c index c796171ad3..090f91a7a3 100644 --- a/src/sunnonlinsol/newton/sunnonlinsol_newton.c +++ b/src/sunnonlinsol/newton/sunnonlinsol_newton.c @@ -18,12 +18,14 @@ #include #include #include + #include #include #include #include #include "sundials_logger_impl.h" +#include "sundials_macros.h" /* Content structure accessibility macros */ #define NEWTON_CONTENT(S) ((SUNNonlinearSolverContent_Newton)(S->content)) @@ -126,7 +128,8 @@ SUNNonlinearSolver SUNNonlinSol_NewtonSens(int count, N_Vector y, GetType, Initialize, Setup, Solve, and Free operations ============================================================================*/ -SUNNonlinearSolver_Type SUNNonlinSolGetType_Newton(SUNNonlinearSolver NLS) +SUNNonlinearSolver_Type SUNNonlinSolGetType_Newton( + SUNDIALS_MAYBE_UNUSED SUNNonlinearSolver NLS) { return (SUNNONLINEARSOLVER_ROOTFIND); } @@ -170,7 +173,8 @@ SUNErrCode SUNNonlinSolInitialize_Newton(SUNNonlinearSolver NLS) Note return values beginning with * are package specific values returned by the Sys, LSetup, and LSolve functions provided to the nonlinear solver. ----------------------------------------------------------------------------*/ -int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, N_Vector y0, N_Vector ycor, +int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, + SUNDIALS_MAYBE_UNUSED N_Vector y0, N_Vector ycor, N_Vector w, sunrealtype tol, sunbooleantype callLSetup, void* mem) { diff --git a/src/sunnonlinsol/petscsnes/sunnonlinsol_petscsnes.c b/src/sunnonlinsol/petscsnes/sunnonlinsol_petscsnes.c index 7001c35257..e932c386ef 100644 --- a/src/sunnonlinsol/petscsnes/sunnonlinsol_petscsnes.c +++ b/src/sunnonlinsol/petscsnes/sunnonlinsol_petscsnes.c @@ -15,15 +15,18 @@ * implementation that interfaces to the PETSc SNES nonlinear solvers. * ---------------------------------------------------------------------------*/ -#include -#include #include #include #include + +#include + +#include +#include #include #include -#include "sundials/sundials_errors.h" +#include "sundials_macros.h" #define SUNNLS_SNES_CONTENT(NLS) \ ((SUNNonlinearSolverContent_PetscSNES)(NLS->content)) @@ -128,7 +131,8 @@ SUNNonlinearSolver SUNNonlinSol_PetscSNES(N_Vector y, SNES snes, SUNContext sunc ============================================================================*/ /* get the type of SUNNonlinearSolver */ -SUNNonlinearSolver_Type SUNNonlinSolGetType_PetscSNES(SUNNonlinearSolver NLS) +SUNNonlinearSolver_Type SUNNonlinSolGetType_PetscSNES( + SUNDIALS_MAYBE_UNUSED SUNNonlinearSolver NLS) { return (SUNNONLINEARSOLVER_ROOTFIND); } @@ -168,8 +172,9 @@ SUNErrCode SUNNonlinSolInitialize_PetscSNES(SUNNonlinearSolver NLS) the Sys function provided to the nonlinear solver. ----------------------------------------------------------------------------*/ int SUNNonlinSolSolve_PetscSNES(SUNNonlinearSolver NLS, N_Vector y0, N_Vector y, - N_Vector w, sunrealtype tol, - sunbooleantype callLSetup, void* mem) + N_Vector w, SUNDIALS_MAYBE_UNUSED sunrealtype tol, + SUNDIALS_MAYBE_UNUSED sunbooleantype callLSetup, + void* mem) { /* local variables */ PetscErrorCode ierr; @@ -370,7 +375,8 @@ SUNErrCode SUNNonlinSolGetNumConvFails_PetscSNES(SUNNonlinearSolver NLS, Private functions ============================================================================*/ -static PetscErrorCode PetscSysFn(SNES snes, Vec x, Vec f, void* ctx) +static PetscErrorCode PetscSysFn(SUNDIALS_MAYBE_UNUSED SNES snes, Vec x, Vec f, + void* ctx) { int retval; SUNNonlinearSolver NLS = (SUNNonlinearSolver)ctx; diff --git a/test/unit_tests/CMakeLists.txt b/test/unit_tests/CMakeLists.txt index 3ca5c3aa28..29e3a74114 100644 --- a/test/unit_tests/CMakeLists.txt +++ b/test/unit_tests/CMakeLists.txt @@ -16,6 +16,12 @@ message("Adding units tests") +# Disable some warnings for tests +if(ENABLE_ALL_WARNINGS) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-parameter") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter") +endif() + add_subdirectory(sundials) if(BUILD_ARKODE)