Also moved a flag into forcerec and fixed documentation.
tmp.append(line);
get_estr(inp, tmp.c_str(), nullptr);
}
+
void setStringEntry(std::vector<t_inpfile>* inp, const char* name, char* newName, const char* def)
{
+ GMX_RELEASE_ASSERT(newName != nullptr, "Need a valid char buffer");
+
const char* found = nullptr;
found = get_estr(inp, name, def);
if (found != nullptr)
std::strcpy(newName, found);
}
}
+
+std::string setStringEntry(std::vector<t_inpfile>* inp, const std::string& name, const std::string& def)
+{
+ GMX_RELEASE_ASSERT(!name.empty(), "Need a valid string");
+
+ return get_estr(inp, name.c_str(), def.c_str());
+}
//! Replace for macro STYPE, checks for existing string entry and if possible replaces it
void setStringEntry(std::vector<t_inpfile>* inp, const char* name, char* newName, const char* def);
+/*! Returns a string value and sets the value in \p inp
+ *
+ * The value is either from \p inp when \p name is found or \p def otherwise.
+ *
+ * \note this is a wrapper function for g_estr()
+ */
+std::string setStringEntry(std::vector<t_inpfile>* inp, const std::string& name, const std::string& def);
+
#endif
"interpret the output messages before attempting to bypass them with",
"this option."
};
- t_gromppopts* opts;
std::vector<MoleculeInformation> mi;
std::unique_ptr<MoleculeInformation> intermolecular_interactions;
int nvsite, comb;
gmx::MDModules mdModules;
t_inputrec irInstance;
t_inputrec* ir = &irInstance;
- snew(opts, 1);
+ t_gromppopts optsInstance;
+ t_gromppopts* opts = &optsInstance;
snew(opts->include, STRLEN);
snew(opts->define, STRLEN);
- snew(opts->mtsLevel2Forces, STRLEN);
gmx::LoggerBuilder builder;
builder.addTargetStream(gmx::MDLogger::LogLevel::Info, &gmx::TextOutputFile::standardOutput());
sfree(opts->wall_atomtype[0]);
sfree(opts->wall_atomtype[1]);
sfree(opts->include);
- sfree(opts->mtsLevel2Forces);
- sfree(opts);
for (auto& mol : mi)
{
// Some of the contents of molinfo have been stolen, so
opts->numMtsLevels = get_eint(&inp, "mts-levels", 2, wi);
ir->mtsLevels.resize(2);
gmx::MtsLevel& mtsLevel = ir->mtsLevels[1];
- setStringEntry(&inp, "mts-level2-forces", opts->mtsLevel2Forces,
- "longrange-nonbonded nonbonded pair dihedral");
- mtsLevel.stepFactor = get_eint(&inp, "mts-level2-factor", 2, wi);
+ opts->mtsLevel2Forces = setStringEntry(&inp, "mts-level2-forces",
+ "longrange-nonbonded nonbonded pair dihedral");
+ mtsLevel.stepFactor = get_eint(&inp, "mts-level2-factor", 2, wi);
// We clear after reading without dynamics to not force the user to remove MTS mdp options
if (!EI_DYNAMICS(ir->eI))
#ifndef GMX_GMXPREPROCESS_READIR_H
#define GMX_GMXPREPROCESS_READIR_H
+#include <string>
+
#include "gromacs/fileio/readinp.h"
#include "gromacs/math/vectypes.h"
#include "gromacs/utility/real.h"
struct t_gromppopts
{
- int warnings;
- int nshake;
- char* include;
- char* define;
- bool bGenVel;
- bool bGenPairs;
- real tempi;
- int seed;
- int numMtsLevels;
- char* mtsLevel2Forces;
- bool bOrire;
- bool bMorse;
- char* wall_atomtype[2];
- char* couple_moltype;
- int couple_lam0;
- int couple_lam1;
- bool bCoupleIntra;
+ int warnings = 0;
+ int nshake = 0;
+ char* include = nullptr;
+ char* define = nullptr;
+ bool bGenVel = false;
+ bool bGenPairs = false;
+ real tempi = 0;
+ int seed = 0;
+ int numMtsLevels = 0;
+ std::string mtsLevel2Forces;
+ bool bOrire = false;
+ bool bMorse = false;
+ char* wall_atomtype[2] = { nullptr, nullptr };
+ char* couple_moltype = nullptr;
+ int couple_lam0 = 0;
+ int couple_lam1 = 0;
+ bool bCoupleIntra = false;
};
/*! \brief Initialise object to hold strings parsed from an .mdp file */
class GetIrTest : public ::testing::Test
{
public:
- GetIrTest() : opts_(), wi_(init_warning(FALSE, 0)), wiGuard_(wi_)
-
+ GetIrTest() : wi_(init_warning(FALSE, 0)), wiGuard_(wi_)
{
snew(opts_.include, STRLEN);
snew(opts_.define, STRLEN);