FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

add -maxcycles to the list of runtime options · idefix-code/idefix@6ff99f8 · GitHub

Repository navigation

Commit 6ff99f8

Browse files
committed
add -maxcycles to the list of runtime options
1 parent 60374de commit 6ff99f8

6 files changed

Lines changed: 24 additions & 7 deletions

File tree

‎src/input.cpp‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,15 @@ void Input::ParseCommandLine(int argc, char **argv) {
179179
this->inputFileName = std::string(argv[i]);
180180
} else if(std::string(argv[i]) == "-autotune") {
181181
this->tuningRequested = true;
182+
} else if(std::string(argv[i]) == "-maxcycles") {
183+
if((i+1)>= argc) {
184+
IDEFIX_ERROR("-maxcycles requires an additional integer parameter");
185+
} else if(std::isdigit(argv[i+1][0]) == 0) {
186+
// next argiment is another parameter (does not start with a number)
187+
IDEFIX_ERROR("-maxcycles requires an additional integer paramater");
188+
}
189+
this->maxCycles = std::stoi(std::string(argv[++i]));
190+
inputParameters["CommandLine"]["maxCycles"].push_back(std::to_string(maxCycles));
182191
} else {
183192
msg << "Unknown option " << argv[i];
184193
IDEFIX_ERROR(msg);

‎src/input.hpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ class Input {
4949

5050
bool tuningRequested{false}; //< whether the user has asked for loop-tuning
5151

52+
int maxCycles{-1}; //< whether we should perform a maximum number of cycles
53+
5254
private:
5355
std::string inputFileName;
5456
IdefixInputContainer inputParameters;

‎src/main.cpp‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,16 @@ int main( int argc, char* argv[] ) {
127127
Tint.Cycle(data);
128128
output.CheckForWrites(data);
129129
if(input.CheckForAbort() || Tint.CheckForMaxRuntime() ) {
130-
idfx::cout << "Main: Saving current state and aborting calculation" << std::endl;
130+
idfx::cout << "Main: Saving current state and aborting calculation." << std::endl;
131131
output.ForceWrite(data);
132132
break;
133133
}
134+
if(input.maxCycles>=0) {
135+
if(Tint.GetNCycles() >= input.maxCycles) {
136+
idfx::cout << "Main: Reached maximum number of integration cycles." << std::endl;
137+
break;
138+
}
139+
}
134140
}
135141

136142
int n_days{0}, n_hours{0}, n_minutes{0}, n_seconds{0};
@@ -144,7 +150,7 @@ int main( int argc, char* argv[] ) {
144150
n_seconds = divres.rem;
145151

146152
double tintegration = timer.seconds() / grid.np_int[IDIR] / grid.np_int[JDIR]
147-
/ grid.np_int[KDIR] / Tint.getNcycles();
153+
/ grid.np_int[KDIR] / Tint.GetNCycles();
148154

149155
idfx::cout << "Main: Reached t=" << data.t << std::endl;
150156
idfx::cout << "Main: Completed in ";
@@ -174,8 +180,8 @@ int main( int argc, char* argv[] ) {
174180
idfx::cout << "s";
175181
}
176182
idfx::cout << " ";
177-
idfx::cout << "and " << Tint.getNcycles() << " cycle";
178-
if (Tint.getNcycles() != 1) {
183+
idfx::cout << "and " << Tint.GetNCycles() << " cycle";
184+
if (Tint.GetNCycles() != 1) {
179185
idfx::cout << "s";
180186
}
181187
idfx::cout << std::endl;

‎src/timeIntegrator.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ void TimeIntegrator::Cycle(DataBlock &data) {
337337

338338

339339

340-
int64_t TimeIntegrator::getNcycles() {
340+
int64_t TimeIntegrator::GetNCycles() {
341341
return(ncycles);
342342
}
343343

‎src/timeIntegrator.hpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
class TimeIntegrator {
1818
public:
19-
int64_t getNcycles(); // Get current number of cycles
19+
int64_t GetNCycles(); // Get current number of cycles
2020

2121
// Constructor from input and given datablock
2222
TimeIntegrator(Input &, DataBlock &);

‎src/tuner.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ double testLoopType(DataBlock &data, Setup &setup, Input &input,
4141
}
4242

4343
double tintegration = timer.seconds() / data.mygrid->np_int[IDIR] / data.mygrid->np_int[JDIR]
44-
/ data.mygrid->np_int[KDIR] / tint.getNcycles();
44+
/ data.mygrid->np_int[KDIR] / tint.GetNCycles();
4545

4646
//idfx::cout << "Perfs are " << 1/tintegration << " cell updates/second" << std::endl;
4747

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL