#ifndef GLM_CONTROL_H_ #define GLM_CONTROL_H_ #include #include #include "config.h" #include "grid_cell.h" #include "input_files.h" #include "outputter.h" #include "zone.h" namespace glm { inline double fround(double n, unsigned d){ return floor(n*pow(10., d) + .5) / pow(10., d); } inline bool resetNegativeToZero (double &val, bool warn=false, const char* warnStr=NULL, const char* prefix=NULL) { bool warned = false; if (val < 0.0) { if (warn) { if (prefix != NULL) { std::cerr << prefix << " "; } std::cerr << warnStr << " " << val << "<0 -- resetting to 0" << std::endl; warned = true; } val = 0.0; } return warned; } class GridInfo; class Controller { typedef std::vector::iterator ZoneIterator; typedef std::vector::iterator CellIterator; public: struct Continent { double unmet; double availBiomass; }; Continent europe; public: struct Regions { double unmet; double availBiomass; }; Regions futureReg[NREG]; void sanity_checks(); void initialize(char* name=NULL, const char* confFileName=NULL); void step (int year, GridInfo& grid); void runModel (); void finalize(); private: Config config; InputFiles* inputs; GridInfo* grid; Outputter outputter; size_t now; size_t next; void optionSettings (GridInfo& grid); void updateZDistance (); void updateLDistance (int year); void combineZLDistances (int year); std::vector countries; std::vector cells; char zdis[NY][NX]; char Ldis[NY][NX]; }; } #endif // GLM_CONTROL_H_