6 |
#include "stochasticdata.h" |
#include "stochasticdata.h" |
7 |
#include "interrupthandler.h" |
#include "interrupthandler.h" |
8 |
#include "global.h" |
#include "global.h" |
9 |
|
#ifdef _OPENMP |
10 |
|
#include <omp.h> |
11 |
|
#endif |
12 |
|
|
13 |
Ecosystem* EcoSystem; |
Ecosystem* EcoSystem; |
14 |
|
StochasticData* data = 0; |
15 |
|
Ecosystem** EcoSystems; |
16 |
|
|
17 |
|
volatile int interrupted = 0; |
18 |
|
volatile int interrupted_print = 0; |
19 |
|
|
20 |
|
|
21 |
int main(int aNumber, char* const aVector[]) { |
int main(int aNumber, char* const aVector[]) { |
22 |
|
|
23 |
MainInfo main; |
MainInfo main; |
24 |
StochasticData* data = 0; |
|
25 |
|
// omp_set_num_threads(4); |
26 |
|
|
27 |
int check = 0; |
int check = 0; |
28 |
|
|
29 |
//Initialise random number generator with system time [MNAA 02.02.26] |
//Initialise random number generator with system time [MNAA 02.02.26] |
63 |
#ifdef INTERRUPT_HANDLER |
#ifdef INTERRUPT_HANDLER |
64 |
//JMB dont register interrupt if doing a network run |
//JMB dont register interrupt if doing a network run |
65 |
if (!(main.runNetwork())) |
if (!(main.runNetwork())) |
66 |
registerInterrupts(&EcoSystem->interrupted); |
registerInterrupts(&interrupted); |
67 |
#endif |
#endif |
68 |
|
|
69 |
if (chdir(workingdir) != 0) |
if (chdir(workingdir) != 0) |
143 |
|
|
144 |
EcoSystem->Update(data); |
EcoSystem->Update(data); |
145 |
EcoSystem->checkBounds(); |
EcoSystem->checkBounds(); |
|
delete data; |
|
146 |
} else |
} else |
147 |
handle.logMessage(LOGFAIL, "Error - no parameter input file specified"); |
handle.logMessage(LOGFAIL, "Error - no parameter input file specified"); |
148 |
|
|
152 |
EcoSystem->writeStatus(main.getPrintInitialFile()); |
EcoSystem->writeStatus(main.getPrintInitialFile()); |
153 |
} |
} |
154 |
|
|
155 |
|
#ifdef _OPENMP |
156 |
|
int numThr = omp_get_max_threads ( ); |
157 |
|
EcoSystems = new Ecosystem*[numThr]; |
158 |
|
int i; |
159 |
|
for (i=0; i<numThr; i++) |
160 |
|
{ |
161 |
|
EcoSystems[i] = new Ecosystem(main); |
162 |
|
EcoSystems[i]->Update(data); |
163 |
|
EcoSystems[i]->Initialise(); |
164 |
|
} |
165 |
|
#endif |
166 |
EcoSystem->Optimise(); |
EcoSystem->Optimise(); |
167 |
|
delete data; |
168 |
if (main.getForcePrint()) |
if (main.getForcePrint()) |
169 |
EcoSystem->Simulate(main.getForcePrint()); |
EcoSystem->Simulate(main.getForcePrint()); |
170 |
} |
} |