24 #include "core/Action.h"
25 #include "core/PlumedMain.h"
26 #include "core/Value.h"
40 pof.
printf(
"%s\n",
"test1");
42 pof.
printf(
"%s\n",
"test2");
54 pif.
getline(s); std::printf(
"%s\n",s.c_str());
55 pif.
getline(s); std::printf(
"%s\n",s.c_str());
59 std::cout<<
"CHECK "<<x1<<
" "<<x2<<
" "<<x3<<
"\n";
74 fp=std::fopen(const_cast<char*>(
path.c_str()),
"a");
80 plumed_massert(!
fp,
"cannot link an already open file");
86 plumed_massert(!
fp,
"cannot link an already open file");
93 plumed_massert(!
fp,
"cannot link an already open file");
100 plumed_massert(!
cloned,
"file "+path+
" appears to be cloned");
105 this->path=path+
plumed->getSuffix();
106 fp=std::fopen(const_cast<char*>(this->path.c_str()),const_cast<char*>(mode.c_str()));
110 fp=std::fopen(const_cast<char*>(this->path.c_str()),const_cast<char*>(mode.c_str()));
113 plumed_massert(
fp,
"file " + path +
"cannot be found");
122 this->path=path+
plumed->getSuffix();
123 ff=std::fopen(const_cast<char*>(this->path.c_str()),
"r");
127 ff=std::fopen(const_cast<char*>(this->path.c_str()),
"r");
129 if(ff) {do_exist=
true; fclose(ff);}
166 FileBase::operator bool()
const{
std::string path
path of the opened file
IFile & getline(std::string &)
Get a full line as a string.
Action * action
pointer to corresponding action. NULL if not linked
FileBase & link(FILE *)
Link to an already open filed.
virtual ~FileBase()
Virtual destructor (allows inheritance)
Class containing wrappers to MPI.
static void test()
Runs a small testcase.
OFile & addConstantField(const std::string &)
FileBase & flush()
Flushes the file to disk.
Communicator * comm
communicator. NULL if not set
IFile & open(const std::string &name)
Opens the file.
bool heavyFlush
Set to true if you want flush to be heavy (close/reopen)
FileBase()
Private constructor.
int printf(const char *fmt,...)
Formatted output with explicit format - a la printf.
bool eof
Set to true when end of file is encountered.
void close()
Closes the file Should be used only for explicitely opened files.
Base class for all the input Actions.
bool isOpen()
Check if a file is open.
FileBase & open(const std::string &name, const std::string &mode)
Opens the file (without auto-backup)
bool cloned
Control closing on destructor.
Communicator & comm
Communicator for plumed.
PlumedMain & plumed
Reference to main plumed object.
IFile & scanField(const std::string &, double &)
Read a double field.
bool FileExist(const std::string &path)
Check if the file exists.
bool err
Set to true when error is encountered.
OFile & printField(const std::string &, double)
Set the value of a double precision field.
void Barrier() const
Wrapper to MPI_Barrier.
Base class for dealing with files.
PlumedMain * plumed
pointer to main plumed object. NULL if not linked
OFile & setLinePrefix(const std::string &)
Set the prefix for output.
OFile & open(const std::string &name)
Opens the file using automatic append/backup.