From: Alex Schmidt Date: Fri, 12 Oct 2012 11:13:20 +0000 (+0200) Subject: ... X-Git-Url: http://git.treefish.org/~alex/phys/latlib.git/commitdiff_plain/b57bffe30e8f531f21f0d50e4dc5f58275d8522e ... --- diff --git a/paraq.cpp b/paraq.cpp index 1bd57b3..b1e3292 100644 --- a/paraq.cpp +++ b/paraq.cpp @@ -3,6 +3,8 @@ #include #include #include +#include +#include using namespace std; @@ -15,8 +17,47 @@ paraq::paraq(int _nprocs, const int _rank) jobListInitialized = false; } +void paraq::addRange(const string& paraid, char *range) +{ + int nargs=0; + double goodrange[3]; + + for( int pos=0; pos >::iterator paraIt = rangeMap.begin(); paraIt != rangeMap.end(); ++paraIt ) + if( paraIt->second.size() > 0 ) + for( vector::iterator rangeIt = paraIt->second.begin(); rangeIt != paraIt->second.end(); ++rangeIt) + rangestring << "-" << paraIt->first << (*rangeIt)[0] << "_" << (*rangeIt)[1] << "_" << (*rangeIt)[2]; + + for( map::iterator defIt = defaultPara.begin(); defIt != defaultPara.end(); ++defIt ) + if( rangeMap.find(defIt->first) == rangeMap.end() ) + rangestring << "-" << defIt->first << defIt->second; + + return rangestring.str(); +} + void paraq::addRange(const string& paraid, double min, double max, double step) { + double *newrange = new double[3]; + newrange[0] = min; + newrange[1] = max; + newrange[2] = step; + rangeMap[paraid].push_back( newrange ); + for( double paraval = min; paraval <= max+0.5*step; paraval += step+(step==0) ) if( ! inParas(paraMap[paraid], paraval) ) paraMap[paraid].push_back( paraval ); } diff --git a/paraq.h b/paraq.h index 6f6a1a0..ef4376b 100644 --- a/paraq.h +++ b/paraq.h @@ -14,14 +14,17 @@ class paraq { int nextParas(); double& operator[] (string paraid); void addRange(const string& paraid, double range[3]) { addRange(paraid, range[0], range[1], range[2]); } + void addRange(const string& paraid, char *range); void setDefault(const string& paraid, double value) { defaultPara[paraid] = value; } int getTotalJobs(); + string rangeString(); private: int nprocs, rank; int thisjob; map defaultPara; map< string, vector > paraMap; + map< string, vector > rangeMap; vector< map > jobList; void initJobList(); bool inParas(vector& paraVec, double& tofind);