From e2f6925b4e2a5141622b7713c274c9a1d8cd4c5e Mon Sep 17 00:00:00 2001 From: Giovanni Bussi <giovanni.bussi@gmail.com> Date: Mon, 22 Jul 2013 09:04:43 +0200 Subject: [PATCH] Fixed opening of Files Removed explicit open mode, so that auto backup/auto restart is used also for DUMPPROJECTIONS, DUMPDERIVATIVES and DUMPFORCES. Regtests has been added with backup files. I also removed some unnecessary c_str(). --- regtest/basic/rt1/bck.0.der2.reference | 1 + regtest/basic/rt1/der2 | 1 + regtest/basic/rt18/bck.0.projections.reference | 1 + regtest/basic/rt18/projections | 1 + regtest/basic/rt8/bck.0.ff.reference | 1 + regtest/basic/rt8/ff | 1 + src/bias/MetaD.cpp | 3 +-- src/generic/DumpAtoms.cpp | 2 +- src/generic/DumpDerivatives.cpp | 2 +- src/generic/DumpForces.cpp | 2 +- src/generic/DumpProjections.cpp | 2 +- src/generic/Print.cpp | 2 +- 12 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 regtest/basic/rt1/bck.0.der2.reference create mode 100644 regtest/basic/rt1/der2 create mode 100644 regtest/basic/rt18/bck.0.projections.reference create mode 100644 regtest/basic/rt18/projections create mode 100644 regtest/basic/rt8/bck.0.ff.reference create mode 100644 regtest/basic/rt8/ff diff --git a/regtest/basic/rt1/bck.0.der2.reference b/regtest/basic/rt1/bck.0.der2.reference new file mode 100644 index 000000000..c7900cb65 --- /dev/null +++ b/regtest/basic/rt1/bck.0.der2.reference @@ -0,0 +1 @@ +fake file just to test backup diff --git a/regtest/basic/rt1/der2 b/regtest/basic/rt1/der2 new file mode 100644 index 000000000..c7900cb65 --- /dev/null +++ b/regtest/basic/rt1/der2 @@ -0,0 +1 @@ +fake file just to test backup diff --git a/regtest/basic/rt18/bck.0.projections.reference b/regtest/basic/rt18/bck.0.projections.reference new file mode 100644 index 000000000..c7900cb65 --- /dev/null +++ b/regtest/basic/rt18/bck.0.projections.reference @@ -0,0 +1 @@ +fake file just to test backup diff --git a/regtest/basic/rt18/projections b/regtest/basic/rt18/projections new file mode 100644 index 000000000..c7900cb65 --- /dev/null +++ b/regtest/basic/rt18/projections @@ -0,0 +1 @@ +fake file just to test backup diff --git a/regtest/basic/rt8/bck.0.ff.reference b/regtest/basic/rt8/bck.0.ff.reference new file mode 100644 index 000000000..c7900cb65 --- /dev/null +++ b/regtest/basic/rt8/bck.0.ff.reference @@ -0,0 +1 @@ +fake file just to test backup diff --git a/regtest/basic/rt8/ff b/regtest/basic/rt8/ff new file mode 100644 index 000000000..c7900cb65 --- /dev/null +++ b/regtest/basic/rt8/ff @@ -0,0 +1 @@ +fake file just to test backup diff --git a/src/bias/MetaD.cpp b/src/bias/MetaD.cpp index a0a13bcd3..01ae2c74a 100644 --- a/src/bias/MetaD.cpp +++ b/src/bias/MetaD.cpp @@ -475,8 +475,7 @@ isFirstStep(true) // open hills file for writing hillsOfile_.link(*this); - if(plumed.getRestart()) hillsOfile_.open(ifilesnames[mw_id_],"aw"); - else hillsOfile_.open(ifilesnames[mw_id_]); + hillsOfile_.open(ifilesnames[mw_id_]); if(fmt.length()>0) hillsOfile_.fmtField(fmt); hillsOfile_.addConstantField("multivariate"); hillsOfile_.setHeavyFlush(); diff --git a/src/generic/DumpAtoms.cpp b/src/generic/DumpAtoms.cpp index e6929f85d..48bb7a0b2 100644 --- a/src/generic/DumpAtoms.cpp +++ b/src/generic/DumpAtoms.cpp @@ -153,7 +153,7 @@ DumpAtoms::DumpAtoms(const ActionOptions&ao): checkRead(); of.link(*this); - of.open(file.c_str()); + of.open(file); log.printf(" printing the following atoms in %s :", unitname.c_str() ); for(unsigned i=0;i<atoms.size();++i) log.printf(" %d",atoms[i].serial() ); log.printf("\n"); diff --git a/src/generic/DumpDerivatives.cpp b/src/generic/DumpDerivatives.cpp index 72e73e8a8..b4a0f52a2 100644 --- a/src/generic/DumpDerivatives.cpp +++ b/src/generic/DumpDerivatives.cpp @@ -91,7 +91,7 @@ fmt("%15.10f") parse("FMT",fmt); fmt=" "+fmt; of.link(*this); - of.open(file,"wa"); + of.open(file); log.printf(" on file %s\n",file.c_str()); log.printf(" with format %s\n",fmt.c_str()); unsigned nargs=getNumberOfArguments(); diff --git a/src/generic/DumpForces.cpp b/src/generic/DumpForces.cpp index 696af62d7..4dfdfd566 100644 --- a/src/generic/DumpForces.cpp +++ b/src/generic/DumpForces.cpp @@ -87,7 +87,7 @@ ActionWithArguments(ao) parse("FILE",file); if( file.length()==0 ) error("name of file was not specified"); of.link(*this); - of.open(file,"wa"); + of.open(file); log.printf(" on file %s\n",file.c_str()); if( getNumberOfArguments()==0 ) error("no arguments have been specified"); checkRead(); diff --git a/src/generic/DumpProjections.cpp b/src/generic/DumpProjections.cpp index 3c3b8968f..6f622e1f7 100644 --- a/src/generic/DumpProjections.cpp +++ b/src/generic/DumpProjections.cpp @@ -75,7 +75,7 @@ fmt("%15.10f") if( file.length()==0 ) error("filename not specified"); parse("FMT",fmt); fmt=" "+fmt; - of.open(file.c_str(),"wa"); + of.open(file); log.printf(" on file %s\n",file.c_str()); log.printf(" with format %s\n",fmt.c_str()); checkRead(); diff --git a/src/generic/Print.cpp b/src/generic/Print.cpp index 28484a84f..9fec9e43e 100644 --- a/src/generic/Print.cpp +++ b/src/generic/Print.cpp @@ -101,7 +101,7 @@ rotate(0) ofile.link(*this); parse("FILE",file); if(file.length()>0){ - ofile.open(file.c_str()); + ofile.open(file); log.printf(" on file %s\n",file.c_str()); } else { log.printf(" on plumed log file\n"); -- GitLab