44 if ((counter_file=fopen(
"COUNTER_DONOTDEL",
"r+"))==NULL)
47 if ((counter_file=fopen(
"COUNTER_DONOTDEL",
"w"))==NULL)
50 fprintf(stderr,
"\n\n\tERROR :: Counter File NOT found, please re-create\n\n");
55 fprintf(counter_file,
"1");
56 fprintf(stderr,
"Counter File created\n");
62 if (fscanf(counter_file,
"%d",&counter)!=1)
65 fprintf(stderr,
"\n\n\tERROR :: Counter File found, but something went wrong with reading it\n\n");
102 std::fstream counter_file, counter_file2;
105 counter_file.open(
"COUNTER_DONOTDEL",std::ios::in);
106 if (counter_file.fail())
108 fprintf(stderr,
"\n\n\tERROR :: Counter File NOT found, please re-create\n\n");
109 counter_file.close();
113 counter_file >> temp_counter;
114 counter_file.close();
120 counter_file2.open(
"COUNTER_DONOTDEL",std::ios::out);
121 if (counter_file2.fail())
123 fprintf(stderr,
"\n\n\tERROR :: Counter File NOT found, please re-create2\n\n");
124 counter_file2.close();
130 counter_file2 << temp_counter;
132 counter_file2.close();
144 std::stringstream filename;
147 filename <<
"info." <<
counter;
150 file.open((filename.str()).c_str(),std::ios::out);
152 std::streambuf *temp = std::cout.rdbuf();
153 std::cout.rdbuf(file.rdbuf());
157 std::cout.rdbuf(temp);
165 struct stat stFileInfo;
171 intStat = stat(strFilename.c_str(),&stFileInfo);
196 std::vector<int> temp(3);
200 int study_size = size_x*size_y;
202 int study_num=(counter-1)/study_size;
204 counter=counter-study_size*study_num;
205 int i=((counter-1)%size_x)+1;
206 int j=(counter-i)/size_x+1;
207 std::cout<<
"Counter: "<<counter<<
" i: "<<i<<
" j: "<<j<<std::endl;
221 std::stringstream com(
"");
225 com <<
"../sc/run " << name <<
" &";
229 com <<
"../sc/run " << name <<
" &";
233 return system(com.str().c_str());
void set_counter(int new_counter)
This set the counter, overriding the defaults.
void save_info_to_disk()
Saves the information generated by info to disk in a file.
int counter
The stores the run number for saving.
bool FileExists(std::string strFilename)
Function to check if a file exists, is used to check if a run has already need done.
virtual void info()
Set up a virtual info this will be provided from the inhertiance.
std::vector< int > get_numbers(int size_x, int size_y)
This turns a counter into two indexs for doing parmater studies. The indexs run from 1:size_x and 1:s...
int read_run_num_from_file()
Read rom the counter file the counter.
int launch_new(const char *name, bool quick=false)
This launch a code from within this code. Please pass the name of the code to run.
void set_counter_from_file()
Sets the counter based on the current number stored in the counter file.
int get_counter()
This returns the current value of the counter.
void inc_counter_in_file()
Increament the counter value stored in the file_counter by 1 and store the new value.