diff --git a/.clang-tidy b/.clang-tidy index 16fdbb2c7d..132457337c 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -6,7 +6,6 @@ Checks: > clang-diagnostic-*, cppcoreguidelines-*, -cppcoreguidelines-avoid-c-arrays, - -cppcoreguidelines-avoid-goto, -cppcoreguidelines-avoid-magic-numbers, -cppcoreguidelines-avoid-non-const-global-variables, -cppcoreguidelines-init-variables, @@ -16,11 +15,19 @@ Checks: > -cppcoreguidelines-non-private-member-variables-in-classes, -cppcoreguidelines-owning-memory, -cppcoreguidelines-pro-*, + misc-*, + -misc-const-correctness, + -misc-include-cleaner, + -misc-non-private-member-variables-in-classes, + -misc-no-recursion, + -misc-use-anonymous-namespace, modernize-*, -modernize-avoid-c-arrays, -modernize-use-trailing-return-type, -modernize-use-using, performance-*, + -performance-avoid-endl, + portability-*, readability-*, -readability-avoid-const-params-in-decls, -readability-braces-around-statements, diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000000..019b628435 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,16 @@ +# Dependabot configuration +# ref: https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + target-branch: "development" + + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "weekly" + target-branch: "development" + diff --git a/.github/workflows/castro-development.yml b/.github/workflows/castro-development.yml index e48d5d4614..451f4c2037 100644 --- a/.github/workflows/castro-development.yml +++ b/.github/workflows/castro-development.yml @@ -29,7 +29,7 @@ jobs: .github/workflows/dependencies/dependencies.sh .github/workflows/dependencies/dependencies_ccache.sh - name: Set Up Cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.cache/ccache key: ccache-${{ github.workflow }}-${{ github.job }}-git-${{ github.sha }} @@ -78,7 +78,7 @@ jobs: PR_NUMBER: ${{ github.event.number }} run: | echo $PR_NUMBER > pr_number.txt - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: pr_number path: pr_number.txt diff --git a/.github/workflows/castro.yml b/.github/workflows/castro.yml index 61f0e6c257..0ea9864aca 100644 --- a/.github/workflows/castro.yml +++ b/.github/workflows/castro.yml @@ -33,7 +33,7 @@ jobs: .github/workflows/dependencies/dependencies.sh .github/workflows/dependencies/dependencies_ccache.sh - name: Set Up Cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.cache/ccache key: ccache-${{ github.workflow }}-${{ github.job }}-git-${{ github.sha }} @@ -82,7 +82,7 @@ jobs: PR_NUMBER: ${{ github.event.number }} run: | echo $PR_NUMBER > pr_number.txt - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: pr_number path: pr_number.txt diff --git a/.github/workflows/check_powi.yml b/.github/workflows/check_powi.yml index 019730dbef..019c6b96b8 100644 --- a/.github/workflows/check_powi.yml +++ b/.github/workflows/check_powi.yml @@ -14,17 +14,17 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '3.10' - name: Cache pip - uses: actions/cache@v3 + uses: actions/cache@v4 with: # this path is specific to Ubuntu path: ~/.cache/pip diff --git a/CHANGES.md b/CHANGES.md index f26c39ffb7..c99c064f13 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,21 @@ +# 24.02 + + * Lots of general code cleaning from coverity and clang-tidy + (#1450, #1452, #1453, #1460, #1459, #1457, #1458) + + * Fixed a bug in the VODE pivoting when a cached Jacobian is used + (#1456) + + * Added reverse rates to CNO_extras (#1445) + + * Sync networks up with pynucastro to get constexpr mion/bion + (#1437) + + * NSE+SDC improvements (#1431) + + * Start of moving the runtime parameters from globals to structs + (#1422) + # 24.01 * The quantum corrections for the Chabrier screening are diff --git a/EOS/breakout/actual_eos.H b/EOS/breakout/actual_eos.H index 25067019c8..cae836ae0b 100644 --- a/EOS/breakout/actual_eos.H +++ b/EOS/breakout/actual_eos.H @@ -29,7 +29,7 @@ template AMREX_GPU_HOST_DEVICE AMREX_INLINE bool is_input_valid (I input) { - static_assert(std::is_same::value, "input must be an eos_input_t"); + static_assert(std::is_same_v, "input must be an eos_input_t"); bool valid = true; @@ -48,7 +48,7 @@ template AMREX_GPU_HOST_DEVICE AMREX_INLINE void actual_eos (I input, T& state) { - static_assert(std::is_same::value, "input must be an eos_input_t"); + static_assert(std::is_same_v, "input must be an eos_input_t"); const Real R = C::k_B * C::n_A; diff --git a/EOS/gamma_law/actual_eos.H b/EOS/gamma_law/actual_eos.H index 1ca36e5b70..dc075b67c9 100644 --- a/EOS/gamma_law/actual_eos.H +++ b/EOS/gamma_law/actual_eos.H @@ -34,7 +34,7 @@ template AMREX_GPU_HOST_DEVICE AMREX_INLINE bool is_input_valid (I input) { - static_assert(std::is_same::value, "input must be an eos_input_t"); + static_assert(std::is_same_v, "input must be an eos_input_t"); bool valid = true; @@ -50,7 +50,7 @@ template AMREX_GPU_HOST_DEVICE AMREX_INLINE void actual_eos (I input, T& state) { - static_assert(std::is_same::value, "input must be an eos_input_t"); + static_assert(std::is_same_v, "input must be an eos_input_t"); // Get the mass of a nucleon from m_u. const Real m_nucleon = C::m_u; diff --git a/EOS/helmholtz/actual_eos.H b/EOS/helmholtz/actual_eos.H index b6e83e1fc6..205e1a6097 100644 --- a/EOS/helmholtz/actual_eos.H +++ b/EOS/helmholtz/actual_eos.H @@ -1238,7 +1238,7 @@ template AMREX_GPU_HOST_DEVICE AMREX_INLINE void actual_eos (I input, T& state) { - static_assert(std::is_same::value, "input must be an eos_input_t"); + static_assert(std::is_same_v, "input must be an eos_input_t"); using namespace helmholtz; @@ -1489,7 +1489,7 @@ bool is_input_valid (I input) { amrex::ignore_unused(input); - static_assert(std::is_same::value, "input must be an eos_input_t"); + static_assert(std::is_same_v, "input must be an eos_input_t"); bool valid = true; diff --git a/EOS/multigamma/actual_eos.H b/EOS/multigamma/actual_eos.H index 2ba69b2a1b..8508b284d5 100644 --- a/EOS/multigamma/actual_eos.H +++ b/EOS/multigamma/actual_eos.H @@ -53,7 +53,7 @@ template AMREX_GPU_HOST_DEVICE AMREX_INLINE bool is_input_valid (I input) { - static_assert(std::is_same::value, "input must be an eos_input_t"); + static_assert(std::is_same_v, "input must be an eos_input_t"); bool valid = true; @@ -70,7 +70,7 @@ template AMREX_GPU_HOST_DEVICE AMREX_INLINE void actual_eos (I input, T& state) { - static_assert(std::is_same::value, "input must be an eos_input_t"); + static_assert(std::is_same_v, "input must be an eos_input_t"); // Get the mass of a nucleon from Avogadro's number. const Real m_nucleon = 1.0_rt / C::n_A; diff --git a/EOS/polytrope/actual_eos.H b/EOS/polytrope/actual_eos.H index 8de4617635..f517b9dc7a 100644 --- a/EOS/polytrope/actual_eos.H +++ b/EOS/polytrope/actual_eos.H @@ -79,7 +79,7 @@ template AMREX_GPU_HOST_DEVICE AMREX_INLINE bool is_input_valid (I input) { - static_assert(std::is_same::value, "input must be an eos_input_t"); + static_assert(std::is_same_v, "input must be an eos_input_t"); bool valid = true; @@ -122,7 +122,7 @@ template AMREX_GPU_HOST_DEVICE AMREX_INLINE void actual_eos (I input, T& state) { - static_assert(std::is_same::value, "input must be an eos_input_t"); + static_assert(std::is_same_v, "input must be an eos_input_t"); Real dens = state.rho; Real temp = state.T; diff --git a/EOS/primordial_chem/actual_eos.H b/EOS/primordial_chem/actual_eos.H index b5cbf1e400..e03733076d 100644 --- a/EOS/primordial_chem/actual_eos.H +++ b/EOS/primordial_chem/actual_eos.H @@ -120,7 +120,7 @@ template AMREX_GPU_HOST_DEVICE AMREX_INLINE bool is_input_valid (I input) { - static_assert(std::is_same::value, "input must be either eos_input_rt or eos_input_re"); + static_assert(std::is_same_v, "input must be either eos_input_rt or eos_input_re"); bool valid = false; @@ -137,7 +137,7 @@ template AMREX_GPU_HOST_DEVICE AMREX_INLINE void actual_eos (I input, T& state) { - static_assert(std::is_same::value, "input must be either eos_input_rt or eos_input_re"); + static_assert(std::is_same_v, "input must be either eos_input_rt or eos_input_re"); const Real gasconstant = C::n_A * C::k_B; const Real protonmass = C::m_p; diff --git a/EOS/rad_power_law/actual_eos.H b/EOS/rad_power_law/actual_eos.H index e101f01694..5a1fabbca6 100644 --- a/EOS/rad_power_law/actual_eos.H +++ b/EOS/rad_power_law/actual_eos.H @@ -49,7 +49,7 @@ template AMREX_GPU_HOST_DEVICE AMREX_INLINE bool is_input_valid (I input) { - static_assert(std::is_same::value, "input must be an eos_input_t"); + static_assert(std::is_same_v, "input must be an eos_input_t"); bool valid = true; @@ -70,7 +70,7 @@ template AMREX_GPU_HOST_DEVICE AMREX_INLINE void actual_eos (I input, T& state) { - static_assert(std::is_same::value, "input must be an eos_input_t"); + static_assert(std::is_same_v, "input must be an eos_input_t"); switch (input) { diff --git a/EOS/tillotson/actual_eos.H b/EOS/tillotson/actual_eos.H index 5b784145ca..653416d4f7 100644 --- a/EOS/tillotson/actual_eos.H +++ b/EOS/tillotson/actual_eos.H @@ -27,7 +27,7 @@ template AMREX_GPU_HOST_DEVICE AMREX_INLINE bool is_input_valid (I input) { - static_assert(std::is_same::value, "input must be an eos_input_t"); + static_assert(std::is_same_v, "input must be an eos_input_t"); bool valid = false; @@ -47,7 +47,7 @@ template AMREX_GPU_HOST_DEVICE AMREX_INLINE void actual_eos (I input, T& state) { - static_assert(std::is_same::value, "input must be an eos_input_t"); + static_assert(std::is_same_v, "input must be an eos_input_t"); // First make T and e consistent with each other. // We assume a simple relationship between energy and temperature. diff --git a/EOS/ztwd/actual_eos.H b/EOS/ztwd/actual_eos.H index bd1bfa3985..1835fa68fb 100644 --- a/EOS/ztwd/actual_eos.H +++ b/EOS/ztwd/actual_eos.H @@ -42,7 +42,7 @@ template AMREX_GPU_HOST_DEVICE AMREX_INLINE bool is_input_valid (I input) { - static_assert(std::is_same::value, "input must be an eos_input_t"); + static_assert(std::is_same_v, "input must be an eos_input_t"); bool valid = true; @@ -129,7 +129,7 @@ template AMREX_GPU_HOST_DEVICE AMREX_INLINE void actual_eos (I input, T& state) { - static_assert(std::is_same::value, "input must be an eos_input_t"); + static_assert(std::is_same_v, "input must be an eos_input_t"); Real dens = state.rho; Real temp = state.T; diff --git a/integration/VODE/actual_integrator.H b/integration/VODE/actual_integrator.H index 64208a1489..e60a82655e 100644 --- a/integration/VODE/actual_integrator.H +++ b/integration/VODE/actual_integrator.H @@ -91,9 +91,9 @@ void actual_integrator (BurnT& state, Real dt, bool is_retry=false) for (int n = 0; n < NumSpec; ++n) { xn_in[n] = state.xn[n]; } - Real T_in = state.T; + const Real T_in = state.T; #endif - Real e_in = state.e; + const Real e_in = state.e; // Call the integration routine. @@ -185,14 +185,14 @@ void actual_integrator (BurnT& state, Real dt, bool is_retry=false) std::cout << "dt = " << std::setprecision(16) << dt << std::endl; std::cout << "temp start = " << std::setprecision(16) << T_in << std::endl; std::cout << "xn start = "; - for (double x : xn_in) { + for (const double x : xn_in) { std::cout << std::setprecision(16) << x << " "; } std::cout << std::endl; std::cout << "dens current = " << std::setprecision(16) << state.rho << std::endl; std::cout << "temp current = " << std::setprecision(16) << state.T << std::endl; std::cout << "xn current = "; - for (double x : state.xn) { + for (const double x : state.xn) { std::cout << std::setprecision(16) << x << " "; } std::cout << std::endl; diff --git a/integration/VODE/vode_dvhin.H b/integration/VODE/vode_dvhin.H index fbf6bbc1c5..8fbd460aa3 100644 --- a/integration/VODE/vode_dvhin.H +++ b/integration/VODE/vode_dvhin.H @@ -26,8 +26,8 @@ void dvhin (BurnT& state, DvodeT& vstate, Real& H0, int& NITER, int& IER) const Real PT1 = 0.1e0_rt; NITER = 0; - Real TDIST = std::abs(vstate.tout - vstate.t); - Real TROUND = UROUND * amrex::max(std::abs(vstate.t), std::abs(vstate.tout)); + const Real TDIST = std::abs(vstate.tout - vstate.t); + const Real TROUND = UROUND * amrex::max(std::abs(vstate.t), std::abs(vstate.tout)); if (TDIST < 2.0_rt * TROUND) { // Error return for vstate.tout - vstate.t too small. @@ -36,15 +36,15 @@ void dvhin (BurnT& state, DvodeT& vstate, Real& H0, int& NITER, int& IER) } // Set a lower bound on h based on the roundoff level in vstate.t and vstate.tout. - Real HLB = 100.0_rt * TROUND; + const Real HLB = 100.0_rt * TROUND; // Set an upper bound on h based on vstate.tout-vstate.t and the initial Y and YDOT. Real HUB = PT1 * TDIST; for (int i = 1; i <= int_neqs; ++i) { - Real atol = i <= NumSpec ? vstate.atol_spec : vstate.atol_enuc; - Real DELYI = PT1 * std::abs(vstate.yh(i,1)) + atol; - Real AFI = std::abs(vstate.yh(i,2)); + const Real atol = i <= NumSpec ? vstate.atol_spec : vstate.atol_enuc; + const Real DELYI = PT1 * std::abs(vstate.yh(i,1)) + atol; + const Real AFI = std::abs(vstate.yh(i,2)); if (AFI * HUB > DELYI) { HUB = DELYI / AFI; } @@ -61,14 +61,14 @@ void dvhin (BurnT& state, DvodeT& vstate, Real& H0, int& NITER, int& IER) do_iterations = false; } - Real hnew; + Real hnew{}; if (do_iterations) { while (true) { // Estimate the second derivative as a difference quotient in f. - Real H = std::copysign(HG, vstate.tout - vstate.t); + const Real H = std::copysign(HG, vstate.tout - vstate.t); for (int i = 1; i <= int_neqs; ++i) { vstate.y(i) = vstate.yh(i,1) + H * vstate.yh(i,2); } @@ -106,7 +106,7 @@ void dvhin (BurnT& state, DvodeT& vstate, Real& H0, int& NITER, int& IER) break; } - Real HRAT = hnew / HG; + const Real HRAT = hnew / HG; if ((HRAT > 0.5_rt) && (HRAT < 2.0_rt)) { break; } diff --git a/integration/VODE/vode_dvjac.H b/integration/VODE/vode_dvjac.H index 35113e8c5c..482bce1b8c 100644 --- a/integration/VODE/vode_dvjac.H +++ b/integration/VODE/vode_dvjac.H @@ -12,9 +12,9 @@ #include #endif -template +template AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE -void dvjac (IArray1D& pivot, int& IERPJ, BurnT& state, DvodeT& vstate) +void dvjac (int& IERPJ, BurnT& state, DvodeT& vstate) { // dvjac is called by dvnlsd to compute and process the matrix // P = I - h*rl1*J , where J is an approximation to the Jacobian @@ -116,11 +116,11 @@ void dvjac (IArray1D& pivot, int& IERPJ, BurnT& state, DvodeT& vstate) R0 = 1.0_rt; } - bool in_jacobian = true; + const bool in_jacobian = true; for (int j = 1; j <= int_neqs; ++j) { - Real yj = vstate.y(j); + const Real yj = vstate.y(j); - Real R = amrex::max(std::sqrt(UROUND) * std::abs(yj), R0 / vstate.ewt(j)); + const Real R = amrex::max(std::sqrt(UROUND) * std::abs(yj), R0 / vstate.ewt(j)); vstate.y(j) += R; fac = 1.0_rt / R; @@ -160,20 +160,19 @@ void dvjac (IArray1D& pivot, int& IERPJ, BurnT& state, DvodeT& vstate) // Multiply Jacobian by a scalar, add the identity matrix // (along the diagonal), and do LU decomposition. - Real hrl1 = vstate.H * vstate.RL1; - Real con = -hrl1; + const Real hrl1 = vstate.H * vstate.RL1; + const Real con = -hrl1; vstate.jac.mul(con); vstate.jac.add_identity(); - int IER; + int IER{}; #ifdef NEW_NETWORK_IMPLEMENTATION - amrex::ignore_unused(pivot); RHS::dgefa(vstate.jac); IER = 0; #else - dgefa(vstate.jac, pivot, IER); + dgefa(vstate.jac, vstate.pivot, IER); #endif if (IER != 0) { diff --git a/integration/VODE/vode_dvjust.H b/integration/VODE/vode_dvjust.H index dcbc0ff568..d408f6aa12 100644 --- a/integration/VODE/vode_dvjust.H +++ b/integration/VODE/vode_dvjust.H @@ -21,10 +21,10 @@ void dvjust (int IORD, BurnT& state, DvodeT& vstate) return; } - int NQM1 = vstate.NQ - 1; - int NQM2 = vstate.NQ - 2; + const int NQM1 = vstate.NQ - 1; + const int NQM2 = vstate.NQ - 2; - Real HSUM, XI, ALPH0, ALPH1, PROD, XIOLD, T1; + Real HSUM{}, XI{}, ALPH0{}, ALPH1{}, PROD{}, XIOLD{}, T1{}; // Check to see if the order is being increased or decreased. @@ -41,7 +41,7 @@ void dvjust (int IORD, BurnT& state, DvodeT& vstate) HSUM += vstate.tau(j); XI = HSUM / vstate.HSCAL; for (int iback = 1; iback <= j+1; ++iback) { - int i = (j + 4) - iback; + const int i = (j + 4) - iback; vstate.el(i) = vstate.el(i) * XI + vstate.el(i-1); } } diff --git a/integration/VODE/vode_dvnlsd.H b/integration/VODE/vode_dvnlsd.H index 5237b96fdf..c3a4ba8e86 100644 --- a/integration/VODE/vode_dvnlsd.H +++ b/integration/VODE/vode_dvnlsd.H @@ -7,9 +7,9 @@ #endif #include -template +template AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE -Real dvnlsd (IArray1D& pivot, int& NFLAG, BurnT& state, DvodeT& vstate) +Real dvnlsd (int& NFLAG, BurnT& state, DvodeT& vstate) { constexpr int int_neqs = integrator_neqs(); @@ -26,8 +26,8 @@ Real dvnlsd (IArray1D& pivot, int& NFLAG, BurnT& state, DvodeT& vstate) const int MAXCOR = 3; const int MSBP = 20; - Real DEL; - int M; + Real DEL{}; + int M{}; // On the first step, on a change of method order, or after a // nonlinear convergence failure with NFLAG = -2, set IPUP = 1 @@ -75,8 +75,9 @@ Real dvnlsd (IArray1D& pivot, int& NFLAG, BurnT& state, DvodeT& vstate) // preprocessed before starting the corrector iteration. IPUP is set // to 0 as an indicator that this has been done. - int IERPJ; - dvjac(pivot, IERPJ, state, vstate); + int IERPJ{}; + dvjac(IERPJ, state, vstate); + vstate.IPUP = 0; vstate.RC = 1.0_rt; vstate.DRC = 0.0_rt; @@ -114,11 +115,11 @@ Real dvnlsd (IArray1D& pivot, int& NFLAG, BurnT& state, DvodeT& vstate) #ifdef NEW_NETWORK_IMPLEMENTATION RHS::dgesl(vstate.jac, vstate.y); #else - dgesl(vstate.jac, pivot, vstate.y); + dgesl(vstate.jac, vstate.pivot, vstate.y); #endif if (vstate.RC != 1.0_rt) { - Real CSCALE = 2.0_rt / (1.0_rt + vstate.RC); + const Real CSCALE = 2.0_rt / (1.0_rt + vstate.RC); for (int i = 1; i <= int_neqs; ++i) { vstate.y(i) *= CSCALE; } @@ -145,7 +146,7 @@ Real dvnlsd (IArray1D& pivot, int& NFLAG, BurnT& state, DvodeT& vstate) vstate.CRATE = amrex::max(CRDOWN * vstate.CRATE, DEL / DELP); } - Real DCON = DEL * amrex::min(1.0_rt, vstate.CRATE) / vstate.tq(4); + const Real DCON = DEL * amrex::min(1.0_rt, vstate.CRATE) / vstate.tq(4); if (DCON <= 1.0_rt) { // we converged, exit the outer loop converged = true; diff --git a/integration/VODE/vode_dvode.H b/integration/VODE/vode_dvode.H index 279634cac4..505f08af48 100644 --- a/integration/VODE/vode_dvode.H +++ b/integration/VODE/vode_dvode.H @@ -24,8 +24,8 @@ int dvode (BurnT& state, DvodeT& vstate) constexpr int int_neqs = integrator_neqs(); // Local variables - Real H0, S; - int IER, NITER; + Real H0{}, S{}; + int IER{}, NITER{}; // Flag determining if we were successful. @@ -259,7 +259,7 @@ int dvode (BurnT& state, DvodeT& vstate) S = (vstate.tout - vstate.tn) / vstate.H; for (int jb = 1; jb <= vstate.NQ; ++jb) { - int j = vstate.NQ - jb; + const int j = vstate.NQ - jb; for (int i = 1; i <= int_neqs; ++i) { vstate.y(i) = vstate.yh(i,j+1) + S * vstate.y(i); } diff --git a/integration/VODE/vode_dvset.H b/integration/VODE/vode_dvset.H index de43cc8523..237b3a1b32 100644 --- a/integration/VODE/vode_dvset.H +++ b/integration/VODE/vode_dvset.H @@ -22,9 +22,9 @@ void dvset (DvodeT& vstate) const Real CORTES = 0.1e0_rt; - Real FLOTL = vstate.L; - int NQM1 = vstate.NQ - 1; - int NQM2 = vstate.NQ - 2; + const Real FLOTL = vstate.L; + const int NQM1 = vstate.NQ - 1; + const int NQM2 = vstate.NQ - 2; for (int i = 3; i <= vstate.L; ++i) { vstate.el(i) = 0.0_rt; @@ -45,7 +45,7 @@ void dvset (DvodeT& vstate) RXI = vstate.H / HSUM; ALPH0 -= 1.0_rt / (j+1); for (int iback = 1; iback <= j+1; ++iback) { - int i = (j + 3) - iback; + const int i = (j + 3) - iback; vstate.el(i) += vstate.el(i-1) * RXI; } } @@ -56,26 +56,26 @@ void dvset (DvodeT& vstate) RXI = vstate.H / HSUM; AHATN0 = -vstate.el(2) - RXI; for (int iback = 1; iback <= vstate.NQ; ++iback) { - int i = (vstate.NQ + 2) - iback; + const int i = (vstate.NQ + 2) - iback; vstate.el(i) += vstate.el(i-1) * RXIS; } } - Real T1 = 1.0_rt - AHATN0 + ALPH0; - Real T2 = 1.0_rt + vstate.NQ * T1; + const Real T1 = 1.0_rt - AHATN0 + ALPH0; + const Real T2 = 1.0_rt + vstate.NQ * T1; vstate.tq(2) = std::abs(ALPH0 * T2 / T1); vstate.tq(5) = std::abs(T2 / (vstate.el(vstate.L) * RXI / RXIS)); if (vstate.NQWAIT == 1) { - Real CNQM1 = RXIS / vstate.el(vstate.L); - Real T3 = ALPH0 + 1.0_rt / vstate.NQ; - Real T4 = AHATN0 + RXI; + const Real CNQM1 = RXIS / vstate.el(vstate.L); + const Real T3 = ALPH0 + 1.0_rt / vstate.NQ; + const Real T4 = AHATN0 + RXI; Real ELP = T3 / (1.0_rt - T4 + T3); vstate.tq(1) = std::abs(ELP / CNQM1); HSUM += vstate.tau(vstate.NQ); RXI = vstate.H / HSUM; - Real T5 = ALPH0 - 1.0_rt / (vstate.NQ+1); - Real T6 = AHATN0 - RXI; + const Real T5 = ALPH0 - 1.0_rt / (vstate.NQ+1); + const Real T6 = AHATN0 - RXI; ELP = T2 / (1.0_rt - T6 + T5); vstate.tq(3) = std::abs(ELP * RXI * (FLOTL + 1.0_rt) * T5); } diff --git a/integration/VODE/vode_dvstep.H b/integration/VODE/vode_dvstep.H index 6a77bc94e5..39134ec3f6 100644 --- a/integration/VODE/vode_dvstep.H +++ b/integration/VODE/vode_dvstep.H @@ -82,9 +82,9 @@ int dvstep (BurnT& state, DvodeT& vstate) const Real ONEPSM = 1.00001e0_rt; const Real THRESH = 1.5e0_rt; - Real CNQUOT, DDN, DSM, DUP, TOLD; - Real FLOTL, R; - int NCF, NFLAG; + Real CNQUOT{}, DDN{}, DSM{}, DUP{}, TOLD{}; + Real FLOTL{}, R{}; + int NCF{}, NFLAG{}; constexpr int int_neqs = integrator_neqs(); @@ -132,8 +132,6 @@ int dvstep (BurnT& state, DvodeT& vstate) } - Array1D pivot; - // Compute the predicted values by effectively // multiplying the yh array by the Pascal triangle matrix. // dvset is called to calculate all integration coefficients. @@ -174,7 +172,7 @@ int dvstep (BurnT& state, DvodeT& vstate) // Call the nonlinear system solver. - Real ACNRM = dvnlsd(pivot, NFLAG, state, vstate); + const Real ACNRM = dvnlsd(NFLAG, state, vstate); if (NFLAG != 0) { @@ -323,7 +321,7 @@ int dvstep (BurnT& state, DvodeT& vstate) kflag = 0; vstate.NST += 1; for (int iback = 1; iback <= vstate.NQ; ++iback) { - int i = vstate.L - iback; + const int i = vstate.L - iback; vstate.tau(i+1) = vstate.tau(i); } @@ -479,7 +477,7 @@ int dvstep (BurnT& state, DvodeT& vstate) // Compute ratio of new H to current H at the current order. FLOTL = vstate.L; - Real ETAQ = 1.0_rt / (std::pow(BIAS2 * DSM, 1.0_rt / FLOTL) + ADDON); + const Real ETAQ = 1.0_rt / (std::pow(BIAS2 * DSM, 1.0_rt / FLOTL) + ADDON); if (vstate.NQWAIT == 0) { vstate.NQWAIT = 2; diff --git a/integration/VODE/vode_type.H b/integration/VODE/vode_type.H index e785b237f7..b8bea3e57a 100644 --- a/integration/VODE/vode_type.H +++ b/integration/VODE/vode_type.H @@ -159,6 +159,8 @@ struct dvode_t Array1D ewt, savf; + Array1D pivot; + // Array of size NEQ used for the accumulated corrections on each // step, scaled in the output to represent the estimated local // error in Y on the last step. This is the vector e in the diff --git a/interfaces/burn_type.H b/interfaces/burn_type.H index 338d542653..5618c52e7f 100644 --- a/interfaces/burn_type.H +++ b/interfaces/burn_type.H @@ -65,37 +65,37 @@ struct burn_t // on exit, this will be set to the integration time we achieved - Real time; + Real time{}; // this first group are the quantities the network RHS uses - Real rho; - Real T; - Real e; - Real xn[NumSpec]; + Real rho{}; + Real T{}; + Real e{}; + Real xn[NumSpec]{}; #if NAUX_NET > 0 - Real aux[NumAux]; + Real aux[NumAux]{}; #endif // scaling used to make e we integrate dimensionless - Real e_scale; + Real e_scale{}; // derivatives needed for calling the EOS - Real dedr; - Real dedT; - Real dedA; - Real dedZ; + Real dedr{}; + Real dedT{}; + Real dedA{}; + Real dedZ{}; // for diagnostics / error reporting - int i; - int j; - int k; + int i{}; + int j{}; + int k{}; #ifdef NONAKA_PLOT - int level; - Real reference_time; + int level{}; + Real reference_time{}; #ifdef STRANG - int strang_half; + int strang_half{}; #endif #endif @@ -104,20 +104,20 @@ struct burn_t // y is the input conserved state. We will keep this state updated // in time as we integrate, such that upon output it will be the // final conserved state. - Real y[SVAR]; + Real y[SVAR]{}; // we need to store a copy of the original state as well so we can // handle the non-evolved state evolution - Real rho_orig; + Real rho_orig{}; - Real rhoe_orig; + Real rhoe_orig{}; // ydot_a are the advective terms that will modify the state y due // to hydrodynamics over the timestep. - Real ydot_a[SVAR]; + Real ydot_a[SVAR]{}; - int sdc_iter; - int num_sdc_iters; + int sdc_iter{}; + int num_sdc_iters{}; // for drive_initial_convection, we will fix T during the // integration to a passed in value. We will interpret a positive @@ -126,35 +126,35 @@ struct burn_t // all coupling types need the specific heats to transform the // reaction Jacobian elements from T to e - Real cv; + Real cv{}; // dx is useful for estimating timescales for equilibriation - Real dx; + Real dx{}; - Real mu; - Real mu_e; - Real y_e; - Real eta; - Real abar; - Real zbar; + Real mu{}; + Real mu_e{}; + Real y_e{}; + Real eta{}; + Real abar{}; + Real zbar{}; #ifdef NSE_NET - Real mu_p; - Real mu_n; + Real mu_p{}; + Real mu_n{}; #endif #ifdef NSE - bool nse; + bool nse{}; #endif // diagnostics - int n_rhs, n_jac, n_step; + int n_rhs{}, n_jac{}, n_step{}; // Was the burn successful? - bool success; + bool success{}; // integrator error code - short error_code; + short error_code{}; }; diff --git a/interfaces/eos.H b/interfaces/eos.H index 82ba53b485..850f55b394 100644 --- a/interfaces/eos.H +++ b/interfaces/eos.H @@ -397,7 +397,7 @@ template AMREX_GPU_HOST_DEVICE AMREX_INLINE void eos (const I input, T& state, bool use_raw_inputs = false) { - static_assert(std::is_same::value, "input must be an eos_input_t"); + static_assert(std::is_same_v, "input must be an eos_input_t"); // Input arguments diff --git a/networks/general_null/Make.package b/networks/general_null/Make.package index 73f3700505..6a8170d3a7 100644 --- a/networks/general_null/Make.package +++ b/networks/general_null/Make.package @@ -8,8 +8,6 @@ ifeq ($(USE_REACT),TRUE) CEXE_headers += actual_rhs.H endif -$(NETWORK_OUTPUT_PATH)/actual_network.F90: $(NETWORK_OUTPUT_PATH)/network_properties.H - NAUX := $(shell $(MICROPHYSICS_HOME)/networks/general_null/get_naux.py --defines "$(DEFINES)" $(GENERAL_NET_INPUTS)) DEFINES += "-DNAUX_NET=$(NAUX)" diff --git a/networks/general_null/network.template b/networks/general_null/network.template deleted file mode 100644 index 5a07f4c0e9..0000000000 --- a/networks/general_null/network.template +++ /dev/null @@ -1,74 +0,0 @@ -! An automatically generated "null" network. This provides the properties -! of a set of non-reacting species. -! -! nspec -- the number of species -! naux -- the number of auxiliary variables -! -! aion -- atomic number -! zion -- proton number -! -! spec_names -- the name of the isotope -! short_spec_names -- an abbreviated form of the species name -! -! aux_names -- the name of the auxiliary variable -! short_aux_names -- an abbreviated form of the auxiliary variable - - -module actual_network - - use amrex_fort_module, only: rt => amrex_real - - implicit none - - integer, parameter :: nspec = @@NSPEC@@ - integer, parameter :: naux = @@NAUX@@ - - character (len=16), save :: spec_names(nspec) - character (len= 5), save :: short_spec_names(nspec) - character (len=16), save :: aux_names(naux) - character (len= 5), save :: short_aux_names(naux) - - real(rt), allocatable, save :: aion(:), aion_inv(:), zion(:) - - integer, parameter :: nrates = 0 - integer, parameter :: num_rate_groups = 0 - - character (len=32), parameter :: network_name = "aprox13" - -contains - - subroutine actual_network_init - - @@SPEC_NAMES@@ - - @@SHORT_SPEC_NAMES@@ - - allocate(aion(nspec)) - allocate(aion_inv(nspec)) - allocate(zion(nspec)) - - @@AION@@ - - @@AION_INV@@ - - @@ZION@@ - - @@AUX_NAMES@@ - - @@SHORT_AUX_NAMES@@ - - end subroutine actual_network_init - - - - subroutine actual_network_finalize - - implicit none - - deallocate(aion) - deallocate(aion_inv) - deallocate(zion) - - end subroutine actual_network_finalize - -end module actual_network diff --git a/neutrinos/sneut5.H b/neutrinos/sneut5.H index 4463243503..210cbe1c51 100644 --- a/neutrinos/sneut5.H +++ b/neutrinos/sneut5.H @@ -307,7 +307,7 @@ sneutf_t get_sneut_factors(Real den, Real temp, Real abar, Real zbar) { constexpr Real con1 = 1.0e0_rt/5.9302e0_rt; - sneutf_t sf; + sneutf_t sf{}; sf.den = den; sf.temp = temp; diff --git a/nse_tabular/nse_table_check.H b/nse_tabular/nse_table_check.H index e5721cabcb..6642847372 100644 --- a/nse_tabular/nse_table_check.H +++ b/nse_tabular/nse_table_check.H @@ -40,7 +40,7 @@ bool in_nse(T& state, const bool relax = false) { Real O_group{}; Real Si_group{}; - if constexpr (std::is_same::value) { + if constexpr (std::is_same_v) { // for a burn_t, we need to use a different field // depending on whether we are strang of simplified-SDC diff --git a/unit_test/burn_cell/burn_cell.H b/unit_test/burn_cell/burn_cell.H index 21f1f0046f..014507299b 100644 --- a/unit_test/burn_cell/burn_cell.H +++ b/unit_test/burn_cell/burn_cell.H @@ -66,6 +66,7 @@ void burn_cell_c() burn_state.j = 0; burn_state.k = 0; burn_state.T_fixed = -1.0_rt; + burn_state.time = 0.0; // normalize -- just in case diff --git a/unit_test/write_job_info.cpp b/unit_test/write_job_info.cpp index 2da75b6ee7..7f8499ef8a 100644 --- a/unit_test/write_job_info.cpp +++ b/unit_test/write_job_info.cpp @@ -46,11 +46,11 @@ void write_job_info(const std::string& dir) { jobInfoFile << " Plotfile Information\n"; jobInfoFile << PrettyLine; - time_t now = time(nullptr); - - // Convert now to tm struct for local timezone - tm* localtm = localtime(&now); - jobInfoFile << "output date / time: " << asctime(localtm); + const std::time_t now = time(nullptr); + char buf[64]; + if (strftime(buf, sizeof buf, "%c\n", std::localtime(&now))) { + jobInfoFile << "output date / time: " << buf << "\n"; + } char currentDir[FILENAME_MAX]; if (getcwd(currentDir, FILENAME_MAX)) { diff --git a/util/linpack.H b/util/linpack.H index 5fc8c8baf1..03eecbd806 100644 --- a/util/linpack.H +++ b/util/linpack.H @@ -76,7 +76,7 @@ void dgefa (RArray2D& a, IArray1D& pivot, int& info) } } - pivot(k) = l; + pivot(k) = static_cast(l); // zero pivot implies this column already triangularized if (a(l,k) != 0.0e0_rt) { @@ -116,7 +116,7 @@ void dgefa (RArray2D& a, IArray1D& pivot, int& info) } - pivot(num_eqs) = num_eqs; + pivot(num_eqs) = static_cast(num_eqs); if (a(num_eqs,num_eqs) == 0.0e0_rt) { info = num_eqs;