42 logger(
DEBUG,
"FilesAndRunNumber::FilesAndRunNumber() finished");
52 logger(
DEBUG,
"FilesAndRunNumber::FilesAndRunNumber(FilesAndRunNumber& other) finished");
60 logger(
DEBUG,
"FilesAndRunNumber::~FilesAndRunNumber() finished");
89 if ((counter_file = fopen(
"COUNTER_DONOTDEL",
"r+")) ==
nullptr)
92 if ((counter_file = fopen(
"COUNTER_DONOTDEL",
"w")) ==
nullptr)
95 fprintf(stderr,
"\n\n\tERROR :: Counter File NOT found, please re-create\n\n");
102 fprintf(counter_file,
"1");
103 fprintf(stderr,
"Counter File created\n");
104 fclose(counter_file);
111 if (fscanf(counter_file,
"%d", &counter) != 1)
114 fprintf(stderr,
"\n\n\tERROR :: Counter File found, but something went wrong with reading it\n\n");
115 fclose(counter_file);
120 fclose(counter_file);
151 std::fstream counter_file, counter_file2;
154 counter_file.open(
"COUNTER_DONOTDEL", std::ios::in);
155 if (counter_file.fail())
157 fprintf(stderr,
"\n\n\tERROR :: Counter File NOT found, please re-create\n\n");
158 counter_file.close();
162 counter_file >> temp_counter;
163 counter_file.close();
167 counter_file2.open(
"COUNTER_DONOTDEL", std::ios::out);
168 if (counter_file2.fail())
170 fprintf(stderr,
"\n\n\tERROR :: Counter File NOT found, please re-create2\n\n");
171 counter_file2.close();
175 counter_file2 << temp_counter;
177 counter_file2.close();
190 std::vector<int> temp(3);
194 int study_size = size_x * size_y;
196 int study_num = (counter - 1) / study_size;
198 counter = counter - study_size * study_num;
199 int i = ((counter - 1) % size_x) + 1;
200 int j = (counter - i) / size_x + 1;
201 std::cout <<
"Counter: " << counter <<
" i: " << i <<
" j: " << j << std::endl;
217 std::stringstream com(
"");
219 return system(com.str().c_str());
229 if (is.peek() ==
'r')
Every simulation requires data files to store all the information necessary for visualisation and ana...
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
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_)