4 |
#include "gadget.h" |
#include "gadget.h" |
5 |
|
|
6 |
extern Ecosystem* EcoSystem; |
extern Ecosystem* EcoSystem; |
7 |
|
extern volatile int interrupted; |
8 |
|
#ifdef _OPENMP |
9 |
|
extern Ecosystem** EcoSystems; |
10 |
|
extern MainInfo _main; |
11 |
|
#endif |
12 |
|
|
13 |
void InterruptInterface::printMenu() { |
void InterruptInterface::printMenu() { |
14 |
if (EcoSystem->getFuncEval() != 0) |
if (EcoSystem->getFuncEval() != 0) |
15 |
cout << "\nInterrupted after " << EcoSystem->getFuncEval() << " iterations ..."; |
{ |
16 |
|
int iters = EcoSystem->getFuncEval(); |
17 |
|
#ifdef _OPENMP |
18 |
|
if (_main.runParallel()){ |
19 |
|
int numThr = omp_get_max_threads ( ); |
20 |
|
for (int i = 0; i < numThr; i++) |
21 |
|
iters += EcoSystems[i]->getFuncEval(); |
22 |
|
} |
23 |
|
#endif |
24 |
|
cout << "\nInterrupted after a total of " << iters << " iterations ..."; |
25 |
|
} |
26 |
cout << "\nInterrupted at year " << EcoSystem->getCurrentYear() << ", step " |
cout << "\nInterrupted at year " << EcoSystem->getCurrentYear() << ", step " |
27 |
<< EcoSystem->getCurrentStep() << " (" << EcoSystem->getCurrentTime() |
<< EcoSystem->getCurrentStep() << " (" << EcoSystem->getCurrentTime() |
28 |
<< " of " << EcoSystem->numTotalSteps() << " timesteps)\n" |
<< " of " << EcoSystem->numTotalSteps() << " timesteps)\n" |
34 |
} |
} |
35 |
|
|
36 |
int InterruptInterface::menu() { |
int InterruptInterface::menu() { |
37 |
|
interrupted = 0; |
38 |
char userinput[MaxStrLength]; |
char userinput[MaxStrLength]; |
39 |
char interruptfile[MaxStrLength]; |
char interruptfile[MaxStrLength]; |
40 |
strncpy(userinput, "", MaxStrLength); |
strncpy(userinput, "", MaxStrLength); |