Update Colvars to version 2019-08-01

One new feature (geometric path variables) and bugfixes.

Minimize occurrence of file-read errors in multiple-walker metadynamics
https://github.com/Colvars/colvars/pull/276

Better error messages for RMSD
https://github.com/Colvars/colvars/pull/272

Ensemble-biased metadynamics documentation
https://github.com/Colvars/colvars/pull/261

Fix bug on multiple walkers metadynamics, pmf included twice
https://github.com/Colvars/colvars/pull/259

Implementation of the geometric path collective variables (C++11-only feature)
https://github.com/Colvars/colvars/pull/249
This commit is contained in:
Giacomo Fiorin
2019-08-01 15:12:42 -04:00
parent 7f342b1cd0
commit 52e2db44a1
21 changed files with 1687 additions and 136 deletions

View File

@ -7,8 +7,14 @@
// If you wish to distribute your changes, please submit them to the
// Colvars repository at GitHub.
#if !defined(WIN32) || defined(__CYGWIN__)
#include <unistd.h>
#endif
#include <cerrno>
#include <sstream>
#include <cstring>
#include <cstdio>
#if defined(_OPENMP)
#include <omp.h>
@ -704,6 +710,27 @@ std::ostream * colvarproxy_io::output_stream(std::string const &output_name,
if (cvm::debug()) {
cvm::log("Using colvarproxy::output_stream()\n");
}
std::ostream *os = get_output_stream(output_name);
if (os != NULL) return os;
if (!(mode & (std::ios_base::app | std::ios_base::ate))) {
backup_file(output_name);
}
std::ofstream *osf = new std::ofstream(output_name.c_str(), mode);
if (!osf->is_open()) {
cvm::error("Error: cannot write to file/channel \""+output_name+"\".\n",
FILE_ERROR);
return NULL;
}
output_stream_names.push_back(output_name);
output_files.push_back(osf);
return osf;
}
std::ostream *colvarproxy_io::get_output_stream(std::string const &output_name)
{
std::list<std::ostream *>::iterator osi = output_files.begin();
std::list<std::string>::iterator osni = output_stream_names.begin();
for ( ; osi != output_files.end(); osi++, osni++) {
@ -711,21 +738,11 @@ std::ostream * colvarproxy_io::output_stream(std::string const &output_name,
return *osi;
}
}
if (!(mode & (std::ios_base::app | std::ios_base::ate))) {
backup_file(output_name);
}
std::ofstream *os = new std::ofstream(output_name.c_str(), mode);
if (!os->is_open()) {
cvm::error("Error: cannot write to file/channel \""+output_name+"\".\n",
FILE_ERROR);
return NULL;
}
output_stream_names.push_back(output_name);
output_files.push_back(os);
return os;
return NULL;
}
int colvarproxy_io::flush_output_stream(std::ostream *os)
{
std::list<std::ostream *>::iterator osi = output_files.begin();
@ -761,10 +778,45 @@ int colvarproxy_io::close_output_stream(std::string const &output_name)
int colvarproxy_io::backup_file(char const *filename)
{
// TODO implement this using rename_file()
return COLVARS_NOT_IMPLEMENTED;
}
int colvarproxy_io::remove_file(char const *filename)
{
if (std::remove(filename)) {
if (errno != ENOENT) {
return cvm::error("Error: in removing file \""+std::string(filename)+
"\".\n.",
FILE_ERROR);
}
}
return COLVARS_OK;
}
int colvarproxy_io::rename_file(char const *filename, char const *newfilename)
{
int error_code = COLVARS_OK;
#if defined(WIN32) && !defined(__CYGWIN__)
// On straight Windows, must remove the destination before renaming it
error_code |= remove_file(newfilename);
#endif
int rename_exit_code = 0;
while ((rename_exit_code = std::rename(filename, newfilename)) != 0) {
if (errno == EINTR) continue;
// Call log() instead of error to allow the next try
cvm::log("Error: in renaming file \""+std::string(filename)+"\" to \""+
std::string(newfilename)+"\".\n.");
error_code |= FILE_ERROR;
if (errno == EXDEV) continue;
break;
}
return rename_exit_code ? error_code : COLVARS_OK;
}
colvarproxy::colvarproxy()
{
@ -826,4 +878,3 @@ int colvarproxy::get_version_from_string(char const *version_string)
is >> newint;
return newint;
}