41 #ifdef DEBUG_CONSTRUCTOR
42 std::cout <<
"FilesAndRunNumber::FilesAndRunNumber() finished" << std::endl;
53 #ifdef DEBUG_CONSTRUCTOR
54 std::cout <<
"FilesAndRunNumber::FilesAndRunNumber(FilesAndRunNumber& other) finished" << std::endl;
63 #ifdef DEBUG_CONSTRUCTOR
64 std::cout <<
"FilesAndRunNumber::~FilesAndRunNumber() finished" << std::endl;
94 if ((counter_file = fopen(
"COUNTER_DONOTDEL",
"r+")) ==
nullptr)
97 if ((counter_file = fopen(
"COUNTER_DONOTDEL",
"w")) ==
nullptr)
100 fprintf(stderr,
"\n\n\tERROR :: Counter File NOT found, please re-create\n\n");
101 fclose(counter_file);
107 fprintf(counter_file,
"1");
108 fprintf(stderr,
"Counter File created\n");
109 fclose(counter_file);
116 if (fscanf(counter_file,
"%d", &counter) != 1)
119 fprintf(stderr,
"\n\n\tERROR :: Counter File found, but something went wrong with reading it\n\n");
120 fclose(counter_file);
125 fclose(counter_file);
156 std::fstream counter_file, counter_file2;
159 counter_file.open(
"COUNTER_DONOTDEL", std::ios::in);
160 if (counter_file.fail())
162 fprintf(stderr,
"\n\n\tERROR :: Counter File NOT found, please re-create\n\n");
163 counter_file.close();
167 counter_file >> temp_counter;
168 counter_file.close();
172 counter_file2.open(
"COUNTER_DONOTDEL", std::ios::out);
173 if (counter_file2.fail())
175 fprintf(stderr,
"\n\n\tERROR :: Counter File NOT found, please re-create2\n\n");
176 counter_file2.close();
180 counter_file2 << temp_counter;
182 counter_file2.close();
195 std::vector<int> temp(3);
199 int study_size = size_x * size_y;
201 int study_num = (counter - 1) / study_size;
203 counter = counter - study_size * study_num;
204 int i = ((counter - 1) % size_x) + 1;
205 int j = (counter - i) / size_x + 1;
206 std::cout <<
"Counter: " << counter <<
" i: " << i <<
" j: " << j << std::endl;
222 std::stringstream com(
"");
224 return system(com.str().c_str());
234 if (is.peek() ==
'r')
Every simulation requires data files to store all the information necessary for visualisation and ana...
int readRunNumberFromFile()
Read the run number or the counter from the counter file (COUNTER_DONOTDEL)
virtual ~FilesAndRunNumber()
Constructor.
void write(std::ostream &os) const
Accepts an output stream read function, which accepts an input stream std::ostream.
void setRunNumber(int runNumber)
This sets the counter/Run number, overriding the defaults.
void constructor()
a function called by the FilesAndRunNumber() (constructor)
int runNumber_
This stores the run number for saving.
void read(std::istream &is)
Accepts an input stream std::istream.
FilesAndRunNumber()
Constructor.
void autoNumber()
The autoNumber() function is the trigger. It calls three functions. setRunNumber(), readRunNumberFromFile() and incrementRunNumberInFile().
void write(std::ostream &os) const
Writes data into a file from the member variables name_, restartFile, dataFile etc.
void read(std::istream &is)
Extracts data from the input stream (which is basically a file you want to read from) into name_...
std::vector< int > get2DParametersFromRunNumber(int size_x, int size_y)
This turns a counter into two indices which is an amazing feature for doing two dimensional parameter...
It is publicly inherited from class Files. It defines an awesome feature that is ideal when doing a p...
void incrementRunNumberInFile()
Increment the run Number (counter value) stored in the file_counter (COUNTER_DONOTDEL) by 1 and store...
int launchNewRun(const char *name, bool quick=false)
This launches a code from within this code. Please pass the name of the code to run.
int getRunNumber() const
This returns the current value of the counter (runNumber_)