Update Colvars to version 2020-02-27
This update contains several small new features or usability improvements.
Descriptions and authorship information can be accessed from the pull
requests listed below.
Allow setting sigma parameter directly for metadynamics
https://github.com/Colvars/colvars/pull/325
Remove default values for lowerWall and upperWall legacy keywords
https://github.com/Colvars/colvars/pull/324
biasActualColvar option to bypass extended-Lagragian for a bias
https://github.com/Colvars/colvars/pull/321
Flexible restart-reading
https://github.com/Colvars/colvars/pull/320
This commit is contained in:
@ -1284,7 +1284,7 @@ std::istream & colvarmodule::read_restart(std::istream &is)
|
||||
{
|
||||
// read global restart information
|
||||
std::string restart_conf;
|
||||
if (is >> colvarparse::read_block("configuration", restart_conf)) {
|
||||
if (is >> colvarparse::read_block("configuration", &restart_conf)) {
|
||||
|
||||
parse->get_keyval(restart_conf, "step",
|
||||
it_restart, static_cast<step_number>(0),
|
||||
@ -1329,30 +1329,84 @@ std::istream & colvarmodule::read_restart(std::istream &is)
|
||||
parse->clear_keyword_registry();
|
||||
}
|
||||
|
||||
// colvars restart
|
||||
cvm::increase_depth();
|
||||
for (std::vector<colvar *>::iterator cvi = colvars.begin();
|
||||
cvi != colvars.end();
|
||||
cvi++) {
|
||||
if ( !((*cvi)->read_restart(is)) ) {
|
||||
cvm::error("Error: in reading restart configuration for collective variable \""+
|
||||
(*cvi)->name+"\".\n",
|
||||
INPUT_ERROR);
|
||||
print_total_forces_errning(warn_total_forces);
|
||||
|
||||
read_objects_state(is);
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::istream & colvarmodule::read_objects_state(std::istream &is)
|
||||
{
|
||||
size_t pos = 0;
|
||||
std::string word;
|
||||
|
||||
while (is.good()) {
|
||||
pos = is.tellg();
|
||||
word.clear();
|
||||
is >> word;
|
||||
|
||||
if (word.size()) {
|
||||
|
||||
is.seekg(pos, std::ios::beg);
|
||||
|
||||
if (word == "colvar") {
|
||||
|
||||
cvm::increase_depth();
|
||||
for (std::vector<colvar *>::iterator cvi = colvars.begin();
|
||||
cvi != colvars.end();
|
||||
cvi++) {
|
||||
if ( !((*cvi)->read_state(is)) ) {
|
||||
// Here an error signals that the variable is a match, but the
|
||||
// state is corrupt; otherwise, the variable rewinds is silently
|
||||
cvm::error("Error: in reading restart configuration for "
|
||||
"collective variable \""+(*cvi)->name+"\".\n",
|
||||
INPUT_ERROR);
|
||||
}
|
||||
if (static_cast<size_t>(is.tellg()) > pos) break; // found it
|
||||
}
|
||||
cvm::decrease_depth();
|
||||
|
||||
} else {
|
||||
|
||||
cvm::increase_depth();
|
||||
for (std::vector<colvarbias *>::iterator bi = biases.begin();
|
||||
bi != biases.end();
|
||||
bi++) {
|
||||
if (((*bi)->state_keyword != word) && (*bi)->bias_type != word) {
|
||||
// Skip biases with different type; state_keyword is used to
|
||||
// support different versions of the state file format
|
||||
continue;
|
||||
}
|
||||
if (!((*bi)->read_state(is))) {
|
||||
// Same as above, an error means a match but the state is incorrect
|
||||
cvm::error("Error: in reading restart configuration for bias \""+
|
||||
(*bi)->name+"\".\n",
|
||||
INPUT_ERROR);
|
||||
}
|
||||
if (static_cast<size_t>(is.tellg()) > pos) break; // found it
|
||||
}
|
||||
cvm::decrease_depth();
|
||||
}
|
||||
}
|
||||
|
||||
if (static_cast<size_t>(is.tellg()) == pos) {
|
||||
// This block has not been read by any object: discard it and move on
|
||||
// to the next one
|
||||
is >> colvarparse::read_block(word, NULL);
|
||||
}
|
||||
|
||||
if (!is) break;
|
||||
}
|
||||
|
||||
// biases restart
|
||||
for (std::vector<colvarbias *>::iterator bi = biases.begin();
|
||||
bi != biases.end();
|
||||
bi++) {
|
||||
if (!((*bi)->read_state(is))) {
|
||||
cvm::error("Error: in reading restart configuration for bias \""+
|
||||
(*bi)->name+"\".\n",
|
||||
INPUT_ERROR);
|
||||
}
|
||||
}
|
||||
cvm::decrease_depth();
|
||||
return is;
|
||||
}
|
||||
|
||||
|
||||
int colvarmodule::print_total_forces_errning(bool warn_total_forces)
|
||||
{
|
||||
if (warn_total_forces) {
|
||||
cvm::log(cvm::line_marker);
|
||||
cvm::log("WARNING: The definition of system forces has changed. Please see:\n");
|
||||
@ -1367,10 +1421,11 @@ to:\n\
|
||||
and load it to continue this simulation.\n");
|
||||
output_prefix() = output_prefix()+".tmp";
|
||||
write_restart_file(output_prefix()+".colvars.state");
|
||||
cvm::error("Exiting with error until issue is addressed.\n", INPUT_ERROR);
|
||||
return cvm::error("Exiting with error until issue is addressed.\n",
|
||||
INPUT_ERROR);
|
||||
}
|
||||
|
||||
return is;
|
||||
return COLVARS_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -1499,7 +1554,7 @@ std::ostream & colvarmodule::write_restart(std::ostream &os)
|
||||
for (std::vector<colvar *>::iterator cvi = colvars.begin();
|
||||
cvi != colvars.end();
|
||||
cvi++) {
|
||||
(*cvi)->write_restart(os);
|
||||
(*cvi)->write_state(os);
|
||||
}
|
||||
|
||||
for (std::vector<colvarbias *>::iterator bi = biases.begin();
|
||||
|
||||
Reference in New Issue
Block a user