From: Alexander B. Schmidt Date: Thu, 11 Oct 2012 13:59:42 +0000 (+0200) Subject: ... X-Git-Url: http://git.treefish.org/~alex/phys/latlib.git/commitdiff_plain/03a0d20d92b54e75ac862b9e41ede061b1918498 ... --- diff --git a/paraq.cpp b/paraq.cpp index e66f138..1bd57b3 100644 --- a/paraq.cpp +++ b/paraq.cpp @@ -12,6 +12,7 @@ paraq::paraq(int _nprocs, const int _rank) nprocs = _nprocs; rank = _rank; masterdefault = 0; + jobListInitialized = false; } void paraq::addRange(const string& paraid, double min, double max, double step) @@ -27,12 +28,12 @@ bool paraq::inParas( vector& paraVec, double& tofind ) return false; } -int paraq::nextParas() +void paraq::initJobList() { - if( thisjob == -1 ) { + if( ! jobListInitialized ) { map jobZero; jobList.push_back( jobZero ); - + for( map< string, vector< double > >::iterator paraIt = paraMap.begin(); paraIt != paraMap.end(); ++paraIt ) while( jobList.begin()->find(paraIt->first) == jobList.begin()->end() ) { for( vector::iterator valIt = paraIt->second.begin(); valIt != paraIt->second.end(); ++valIt ) { @@ -41,12 +42,21 @@ int paraq::nextParas() } jobList.erase( jobList.begin() ); } + jobListInitialized = true; + } +} +int paraq::nextParas() +{ + if( thisjob == -1 ) { + initJobList(); thisjob = rank; } else thisjob += nprocs; + if( jobList.begin()->size() == 0 ) return 0; + if( thisjob < jobList.size() ) return 1; else return 0; @@ -63,3 +73,8 @@ double& paraq::operator[] (string paraid) { return masterdefault; } + +int paraq::getTotalJobs() { + initJobList(); + return jobList.size(); +} diff --git a/paraq.h b/paraq.h index 7108974..6f6a1a0 100644 --- a/paraq.h +++ b/paraq.h @@ -15,6 +15,7 @@ class paraq { double& operator[] (string paraid); void addRange(const string& paraid, double range[3]) { addRange(paraid, range[0], range[1], range[2]); } void setDefault(const string& paraid, double value) { defaultPara[paraid] = value; } + int getTotalJobs(); private: int nprocs, rank; @@ -22,8 +23,10 @@ class paraq { map defaultPara; map< string, vector > paraMap; vector< map > jobList; + void initJobList(); bool inParas(vector& paraVec, double& tofind); double masterdefault; + bool jobListInitialized; }; #endif