From 47a8a418ba1e5ae03095ee80e08c607b812ee3c6 Mon Sep 17 00:00:00 2001
From: Giovanni Bussi <giovanni.bussi@gmail.com>
Date: Fri, 25 Jan 2013 10:58:24 +0100
Subject: [PATCH] Fixed problem with log file

When the log file is chosen by name (cmd("setLogFile"...))
there was a problem due to an apparent double initialization
of log file. Now, logfile is open when cmd("setLogFile"...)
and, in case it is still not open when cmd("init") is called,
it is opened to stdout
---
 src/core/PlumedMain.cpp | 2 +-
 src/tools/FileBase.cpp  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/core/PlumedMain.cpp b/src/core/PlumedMain.cpp
index aac2c6c9d..bc3e0d7d3 100644
--- a/src/core/PlumedMain.cpp
+++ b/src/core/PlumedMain.cpp
@@ -70,7 +70,6 @@ PlumedMain::PlumedMain():
 {
   log.link(comm);
   log.setLinePrefix("PLUMED: ");
-  log.link(stdout);
   stopwatch.start();
   stopwatch.pause();
 }
@@ -340,6 +339,7 @@ void PlumedMain::init(){
 // check that initialization just happens once
   initialized=true;
   atoms.init();
+  if(!log.isOpen()) log.link(stdout);
   log<<"PLUMED is starting\n";
   log<<"PLUMED compiled on " __DATE__ " at " __TIME__ "\n";
   log<<"****  THIS IS AN EXPERIMENTAL VERSION ****\n";
diff --git a/src/tools/FileBase.cpp b/src/tools/FileBase.cpp
index 467d1a93a..f15bf9528 100644
--- a/src/tools/FileBase.cpp
+++ b/src/tools/FileBase.cpp
@@ -97,7 +97,7 @@ FileBase& FileBase::link(Action&action){
 }
 
 FileBase& FileBase::open(const std::string& path,const std::string& mode){
-  plumed_assert(!cloned);
+  plumed_massert(!cloned,"file "+path+" appears to be cloned");
   eof=false;
   err=false;
   fp=NULL;
-- 
GitLab