Vectors in history_t
authorJoe Jordan <ejjordan12@gmail.com>
Thu, 22 Apr 2021 13:19:47 +0000 (13:19 +0000)
committerAndrey Alekseenko <al42and@gmail.com>
Thu, 22 Apr 2021 13:19:47 +0000 (13:19 +0000)
src/gromacs/fileio/checkpoint.cpp
src/gromacs/listed_forces/disre.cpp
src/gromacs/listed_forces/orires.cpp
src/gromacs/mdtypes/state.cpp
src/gromacs/mdtypes/state.h

index 0bb84ea8039697627002d26780e17c49cba313a5..5b7a215af76cf376f82f620ed839cf274743b73c 100644 (file)
@@ -947,17 +947,6 @@ static int do_cpte_reals(XDR* xd, Enum ecpt, int sflags, int n, real** v, FILE*
             xd, ecpt, sflags, n, nullptr, v, nullptr, list, CptElementType::real);
 }
 
-/* This function does the same as do_cpte_reals,
- * except that on reading it ignores the passed value of *n
- * and stores the value read from the checkpoint file in *n.
- */
-template<typename Enum>
-static int do_cpte_n_reals(XDR* xd, Enum ecpt, int sflags, int* n, real** v, FILE* list)
-{
-    return doVectorLow<real, std::allocator<real>>(
-            xd, ecpt, sflags, -1, n, v, nullptr, list, CptElementType::real);
-}
-
 template<typename Enum>
 static int do_cpte_real(XDR* xd, Enum ecpt, int sflags, real* r, FILE* list)
 {
@@ -1425,15 +1414,13 @@ static int do_cpt_state(XDR* xd, int fflags, t_state* state, FILE* list)
                     ret = do_cpte_real(xd, *i, sflags, &state->hist.disre_initf, list);
                     break;
                 case StateEntry::DisreRm3Tav:
-                    ret = do_cpte_n_reals(
-                            xd, *i, sflags, &state->hist.ndisrepairs, &state->hist.disre_rm3tav, list);
+                    ret = doVector<real>(xd, *i, sflags, &state->hist.disre_rm3tav, list);
                     break;
                 case StateEntry::OrireInitF:
                     ret = do_cpte_real(xd, *i, sflags, &state->hist.orire_initf, list);
                     break;
                 case StateEntry::OrireDtav:
-                    ret = do_cpte_n_reals(
-                            xd, *i, sflags, &state->hist.norire_Dtav, &state->hist.orire_Dtav, list);
+                    ret = doVector<real>(xd, *i, sflags, &state->hist.orire_Dtav, list);
                     break;
                 case StateEntry::PullComPrevStep:
                     ret = doVector<double>(xd, *i, sflags, &state->pull_com_prev_step, list);
index 981cbefa47ef65c9fa2278c78e88a16b090d3a73..e22a49ba95bc847dfe3326525b8ea134f5cbbf62 100644 (file)
@@ -201,8 +201,7 @@ void init_disres(FILE*                 fplog,
         hist->disre_initf = 1.0;
         /* Allocate space for the r^-3 time averages */
         state->flags |= enumValueToBitMask(StateEntry::DisreRm3Tav);
-        hist->ndisrepairs = dd->npair;
-        snew(hist->disre_rm3tav, hist->ndisrepairs);
+        hist->disre_rm3tav.resize(dd->npair);
     }
     /* Allocate space for a copy of rm3tav,
      * so we can call do_force without modifying the state.
index 17bfa83b655a971f68fdf04c24cd1cc2d07f6c61..1ec9cef352005a8a2a7b866571c4482ab9a89f8d 100644 (file)
@@ -194,8 +194,7 @@ void init_orires(FILE*                 fplog,
         globalState->flags |= enumValueToBitMask(StateEntry::OrireInitF);
         globalState->hist.orire_initf = 1;
         globalState->flags |= enumValueToBitMask(StateEntry::OrireDtav);
-        globalState->hist.norire_Dtav = od->nr * 5;
-        snew(globalState->hist.orire_Dtav, globalState->hist.norire_Dtav);
+        globalState->hist.orire_Dtav.resize(od->nr * 5);
     }
 
     snew(od->oinsl, od->nr);
index 4722245ff8570a13f4ec7b342b11258929953689..9cca0564a995db5cdf1097c361476aec269b282f 100644 (file)
 /* The source code in this file should be thread-safe.
       Please keep it that way. */
 
-history_t::history_t() :
-    disre_initf(0),
-    ndisrepairs(0),
-    disre_rm3tav(nullptr),
-    orire_initf(0),
-    norire_Dtav(0),
-    orire_Dtav(nullptr)
-{
-}
+history_t::history_t() : disre_initf(0), orire_initf(0) {}
 
 ekinstate_t::ekinstate_t() :
     bUpToDate(FALSE),
index faa51d21a45082bfeb4553cfaeaf46ea12010352..0dacb69dba5356b9987821a5d1bf87419f7061bb 100644 (file)
@@ -151,12 +151,10 @@ class history_t
 public:
     history_t();
 
-    real  disre_initf;  //!< The scaling factor for initializing the time av.
-    int   ndisrepairs;  //!< The number of distance restraints
-    real* disre_rm3tav; //!< The r^-3 time averaged pair distances
-    real  orire_initf;  //!< The scaling factor for initializing the time av.
-    int   norire_Dtav;  //!< The number of matrix element in dtav (npair*5)
-    real* orire_Dtav;   //!< The time averaged orientation tensors
+    real              disre_initf;  //!< The scaling factor for initializing the time av.
+    std::vector<real> disre_rm3tav; //!< The r^-3 time averaged pair distances
+    real              orire_initf;  //!< The scaling factor for initializing the time av.
+    std::vector<real> orire_Dtav;   //!< The time averaged orientation tensors
 };
 
 /*! \libinternal \brief Struct used for checkpointing only