--- trunk/gadget/gadget.cc 2015/10/13 11:29:01 16 +++ trunk/gadget/gadget.cc 2017/04/07 09:20:55 20 @@ -14,6 +14,9 @@ StochasticData* data = 0; Ecosystem** EcoSystems; +volatile int interrupted = 0; +volatile int interrupted_print = 0; + int main(int aNumber, char* const aVector[]) { @@ -60,7 +63,7 @@ #ifdef INTERRUPT_HANDLER //JMB dont register interrupt if doing a network run if (!(main.runNetwork())) - registerInterrupts(&EcoSystem->interrupted); + registerInterrupts(&interrupted); #endif if (chdir(workingdir) != 0) @@ -150,15 +153,23 @@ } #ifdef _OPENMP - int numThr = omp_get_max_threads ( ); - EcoSystems = new Ecosystem*[numThr]; - int i; - for (i=0; iUpdate(data); - EcoSystems[i]->Initialise(); - } + if (main.runParallel()){ + int numThr = omp_get_max_threads ( ); + handle.logMessage(LOGINFO, "Info - initialise ", numThr," EcoSystems "); + EcoSystems = new Ecosystem*[numThr]; + int i; +#pragma omp parallel for shared(EcoSystems,main,data,handle) + for (i=0; iUpdate(data); + EcoSystems[i]->checkBounds(); + } + EcoSystems[i]->Initialise(); + } + } #endif EcoSystem->Optimise(); delete data;