| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -179,6 +179,15 @@ void Input::ParseCommandLine(int argc, char **argv) { | |||
| 179 | 179 | this->inputFileName = std::string(argv[i]); | |
| 180 | 180 | } else if(std::string(argv[i]) == "-autotune") { | |
| 181 | 181 | 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)); | ||
| 182 | 191 | } else { | |
| 183 | 192 | msg << "Unknown option " << argv[i]; | |
| 184 | 193 | IDEFIX_ERROR(msg); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -49,6 +49,8 @@ class Input { | |||
| 49 | 49 | ||
| 50 | 50 | bool tuningRequested{false}; //< whether the user has asked for loop-tuning | |
| 51 | 51 | ||
| 52 | + int maxCycles{-1}; //< whether we should perform a maximum number of cycles | ||
| 53 | + | ||
| 52 | 54 | private: | |
| 53 | 55 | std::string inputFileName; | |
| 54 | 56 | IdefixInputContainer inputParameters; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -127,10 +127,16 @@ int main( int argc, char* argv[] ) { | |||
| 127 | 127 | Tint.Cycle(data); | |
| 128 | 128 | output.CheckForWrites(data); | |
| 129 | 129 | 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; | ||
| 131 | 131 | output.ForceWrite(data); | |
| 132 | 132 | break; | |
| 133 | 133 | } | |
| 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 | + } | ||
| 134 | 140 | } | |
| 135 | 141 | ||
| 136 | 142 | int n_days{0}, n_hours{0}, n_minutes{0}, n_seconds{0}; | |
@@ -144,7 +150,7 @@ int main( int argc, char* argv[] ) { | |||
| 144 | 150 | n_seconds = divres.rem; | |
| 145 | 151 | ||
| 146 | 152 | 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(); | ||
| 148 | 154 | ||
| 149 | 155 | idfx::cout << "Main: Reached t=" << data.t << std::endl; | |
| 150 | 156 | idfx::cout << "Main: Completed in "; | |
@@ -174,8 +180,8 @@ int main( int argc, char* argv[] ) { | |||
| 174 | 180 | idfx::cout << "s"; | |
| 175 | 181 | } | |
| 176 | 182 | 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) { | ||
| 179 | 185 | idfx::cout << "s"; | |
| 180 | 186 | } | |
| 181 | 187 | idfx::cout << std::endl; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -337,7 +337,7 @@ void TimeIntegrator::Cycle(DataBlock &data) { | |||
| 337 | 337 | ||
| 338 | 338 | ||
| 339 | 339 | ||
| 340 | - int64_t TimeIntegrator::getNcycles() { | ||
| 340 | + int64_t TimeIntegrator::GetNCycles() { | ||
| 341 | 341 | return(ncycles); | |
| 342 | 342 | } | |
| 343 | 343 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,7 +16,7 @@ | |||
| 16 | 16 | ||
| 17 | 17 | class TimeIntegrator { | |
| 18 | 18 | public: | |
| 19 | - int64_t getNcycles(); // Get current number of cycles | ||
| 19 | + int64_t GetNCycles(); // Get current number of cycles | ||
| 20 | 20 | ||
| 21 | 21 | // Constructor from input and given datablock | |
| 22 | 22 | TimeIntegrator(Input &, DataBlock &); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -41,7 +41,7 @@ double testLoopType(DataBlock &data, Setup &setup, Input &input, | |||
| 41 | 41 | } | |
| 42 | 42 | ||
| 43 | 43 | 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(); | ||
| 45 | 45 | ||
| 46 | 46 | //idfx::cout << "Perfs are " << 1/tintegration << " cell updates/second" << std::endl; | |
| 47 | 47 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments