Skip to content

Commit 00e4cd9

Browse files
gtribelloGareth Aneurin Tribello
andauthored
Fixed bug with shortcuts and citation manager (plumed#1201)
When creating actions from shortcuts you need to use readInputWords rather than readInputLine as readInputLine prints and clears the bibliography after creating the action. In contrast readInputWords keeps the bibliography and only prints it at the end of the log one the whole plumed input is read Co-authored-by: Gareth Aneurin Tribello <garethtribello@Gareths-MacBook-Pro.local>
1 parent bba534c commit 00e4cd9

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

src/core/ActionShortcut.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,18 @@ void ActionShortcut::readInputLine( const std::string& input, bool saveline ) {
9292
founds=true;
9393
}
9494
if( found ) {
95-
std::string f_input = input;
9695
if( !founds && saveline ) {
9796
addToSavedInputLines( input );
9897
}
9998
if( keywords.exists("RESTART") ) {
10099
if( restart ) {
101-
f_input += " RESTART=YES";
100+
words.push_back("RESTART=YES");
102101
}
103102
if( !restart ) {
104-
f_input += " RESTART=NO";
103+
words.push_back("RESTART=NO");
105104
}
106105
}
107-
plumed.readInputLine( f_input );
106+
plumed.readInputWords( words, false);
108107
if( !founds ) {
109108
ActionWithValue* av=NULL;
110109
for(auto pp=plumed.getActionSet().rbegin(); pp!=plumed.getActionSet().rend(); ++pp) {

src/core/PlumedMain.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1067,6 +1067,9 @@ void PlumedMain::readInputLine(const std::string & str, const bool& before_init)
10671067
return;
10681068
}
10691069
std::vector<std::string> words=Tools::getWords(str);
1070+
if( before_init ) {
1071+
plumed_assert( citations.empty() );
1072+
}
10701073
citations.clear();
10711074
readInputWords(words,before_init);
10721075
if(!citations.empty()) {
@@ -1729,7 +1732,7 @@ bool PlumedMain::DeprecatedAtoms::usingNaturalUnits() const {
17291732
}
17301733

17311734
void PlumedMain::DeprecatedAtoms::setCollectEnergy(bool b) const {
1732-
plumed.readInputLine( plumed.MDEngine + "_energy: ENERGY" );
1735+
plumed.readInputWords( Tools::getWords(plumed.MDEngine + "_energy: ENERGY"), false );
17331736
plumed.setEnergyValue( plumed.MDEngine + "_energy" );
17341737
}
17351738

src/gridtools/KDE.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,20 +157,20 @@ KDE::KDE(const ActionOptions&ao):
157157
band += "," + bwidths[i];
158158
}
159159
}
160-
plumed.readInputLine( getLabel() + "_sigma: CONSTANT " + band );
161-
plumed.readInputLine( getLabel() + "_cov: CUSTOM ARG=" + getLabel() + "_sigma FUNC=x*x PERIODIC=NO" );
162-
plumed.readInputLine( getLabel() + "_icov: CUSTOM ARG=" + getLabel() + "_cov FUNC=1/x PERIODIC=NO" );
160+
plumed.readInputWords( Tools::getWords(getLabel() + "_sigma: CONSTANT " + band), false );
161+
plumed.readInputWords( Tools::getWords(getLabel() + "_cov: CUSTOM ARG=" + getLabel() + "_sigma FUNC=x*x PERIODIC=NO"), false );
162+
plumed.readInputWords( Tools::getWords(getLabel() + "_icov: CUSTOM ARG=" + getLabel() + "_cov FUNC=1/x PERIODIC=NO"), false );
163163
bandwidth = getLabel() + "_icov";
164164

165165
if( (kerneltype=="gaussian" || kerneltype=="GAUSSIAN") && weights_are_volumes ) {
166166
std::string pstr;
167167
Tools::convert( sqrt(pow(2*pi,bwidths.size())), pstr );
168-
plumed.readInputLine( getLabel() + "_bwprod: PRODUCT ARG=" + getLabel() + "_cov");
169-
plumed.readInputLine( getLabel() + "_vol: CUSTOM ARG=" + getLabel() + "_bwprod FUNC=(sqrt(x)*" + pstr + ") PERIODIC=NO");
168+
plumed.readInputWords( Tools::getWords(getLabel() + "_bwprod: PRODUCT ARG=" + getLabel() + "_cov"), false );
169+
plumed.readInputWords( Tools::getWords(getLabel() + "_vol: CUSTOM ARG=" + getLabel() + "_bwprod FUNC=(sqrt(x)*" + pstr + ") PERIODIC=NO"), false );
170170
if( hasheight ) {
171-
plumed.readInputLine( getLabel() + "_height: CUSTOM ARG=" + weight_str[0] + "," + getLabel() + "_vol FUNC=x/y PERIODIC=NO");
171+
plumed.readInputWords( Tools::getWords(getLabel() + "_height: CUSTOM ARG=" + weight_str[0] + "," + getLabel() + "_vol FUNC=x/y PERIODIC=NO"), false);
172172
} else {
173-
plumed.readInputLine( getLabel() + "_height: CUSTOM ARG=" + getLabel() + "_vol FUNC=1/x PERIODIC=NO");
173+
plumed.readInputWords( Tools::getWords(getLabel() + "_height: CUSTOM ARG=" + getLabel() + "_vol FUNC=1/x PERIODIC=NO"), false);
174174
}
175175
hasheight=true;
176176
weight_str.resize(1);

src/valtools/SelectWithMask.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,15 @@ SelectWithMask::SelectWithMask(const ActionOptions& ao):
110110
for(unsigned i=1; i<getPntrToArgument(0)->getShape()[1]; ++i) {
111111
con += ",0";
112112
}
113-
plumed.readInputLine( getLabel() + "_colmask: CONSTANT VALUES=" + con );
113+
plumed.readInputWords( Tools::getWords(getLabel() + "_colmask: CONSTANT VALUES=" + con), false );
114114
std::vector<std::string> labs(1, getLabel() + "_colmask");
115115
ActionWithArguments::interpretArgumentList( labs, plumed.getActionSet(), this, cmask );
116116
} else if( rmask.size()==0 ) {
117117
std::string con="0";
118118
for(unsigned i=1; i<getPntrToArgument(0)->getShape()[0]; ++i) {
119119
con += ",0";
120120
}
121-
plumed.readInputLine( getLabel() + "_rowmask: CONSTANT VALUES=" + con );
121+
plumed.readInputWords( Tools::getWords(getLabel() + "_rowmask: CONSTANT VALUES=" + con), false );
122122
std::vector<std::string> labs(1, getLabel() + "_rowmask");
123123
ActionWithArguments::interpretArgumentList( labs, plumed.getActionSet(), this, rmask );
124124
}

0 commit comments

Comments
 (0)