#ifndef GLM_INPUT_FILES_H_ #define GLM_INPUT_FILES_H_ #include "config.h" #include "zone.h" #include "gridded_input.h" namespace glm { inline size_t modulo(int a, int b) { if (a<0) { return b+a; } else { return a%b; } }; class GridCell; class GridInfo; class InputFiles { GridInfo* grid_; Config* config_; int whFileID; int whFirstYear; int fwFileID; int fwFirstYear; int nfFileID; int nfFirstYear; int fertFileID; int irrigFileID; int tillFileID; int tillFirstYear; int fertFirstYear; int irrigFirstYear; int cftFileID; int cftFirstYear; int cropRotFileID; int cropRotFirstYear; int cbioFileID; int cbioFirstYear; double availLand[NY][NX]; double availSpace[AGG_NY][AGG_NX]; double availSpaceForested[AGG_NY][AGG_NX]; double availSpaceForestedInc[AGG_NY][AGG_NX]; double availSpaceForestedDec[AGG_NY][AGG_NX]; double landSpace[AGG_NY][AGG_NX]; double cropSpace[AGG_NY][AGG_NX]; double pastSpace[AGG_NY][AGG_NX]; double deltaquartercrop[NY][NX]; double IAM_forest_diff[AGG_NY][AGG_NX]; double unmetForestDiff[AGG_NY][AGG_NX]; double GLMForestDiff[AGG_NY][AGG_NX]; double origCrop[NY][NX]; double origPast[NY][NX]; double origUrbn[NY][NX]; double prot[NY][NX]; double protPrev[NY][NX]; double prot2deg[AGG_NY][AGG_NX]; double prot2degPrev[AGG_NY][AGG_NX]; double quarterCropDec[NY][NX]; double quarterCropInc[NY][NX]; double unmetCrop0[AGG_NY][AGG_NX]; double unmetCrop1[AGG_NY][AGG_NX]; double unmetCropLand[AGG_NY][AGG_NX]; double unmetCropTotal[AGG_NY][AGG_NX]; double unmetPast0[AGG_NY][AGG_NX]; double unmetPast1[AGG_NY][AGG_NX]; double unmetPastLand[AGG_NY][AGG_NX]; double unmetPastTotal[AGG_NY][AGG_NX]; double unmetUrbn0[AGG_NY][AGG_NX]; double unmetUrbn1[AGG_NY][AGG_NX]; double unmetUrbnLand[AGG_NY][AGG_NX]; double unmetUrbnTotal[AGG_NY][AGG_NX]; void openWoodHarvestFile (const char* filename); void openFuelWoodFile (const char* filename); void openNationalFloodedFile (const char* filename); void closeWoodHarvestFile (); void closeFuelWoodFile (); void closeNationalFloodedFile (); void openFertScalefactorFile (const char* filename); void closeFertScalefactorFile (); void openNationalFertDataFile (const char* filename); void openNationalIrrigDataFile (const char* filename); void openNationalTillageDataFile (const char* filename); void openCropRotationDataFile (const char* filename); void openCropBiofuelDataFile (const char* filename); void closeCropBiofuelDataFile(); void closeNationalFertDataFile (); void closeNationalIrrigDataFile (); void loadHarvestProbabilities (const char* filename); void harmonize(); void dissaggregateAndInterpolate (); public: GriddedInput* cropFile_; GriddedInput* pstrFile_; GriddedInput* othrFile_; GriddedInput* urbnFile_; GriddedInput* mpstFile_; GriddedInput* rangFile_; GriddedInput* irrgFile_; GriddedInput* riceFile_; GriddedInput* shftFile_; GriddedInput* protFile_; GriddedInput* iamFloodFile_; GriddedInput* c4pFile_; GriddedInput* c3pFile_; GriddedInput* c3aFile_; GriddedInput* c4aFile_; GriddedInput* c3nFile_; GriddedInput* iamC3AFertValsFile_; GriddedInput* iamC3PFertValsFile_; GriddedInput* iamC4AFertValsFile_; GriddedInput* iamC4PFertValsFile_; GriddedInput* iamC3NFertValsFile_; GriddedInput* iamC3AIrrigValsFile_; GriddedInput* iamC3PIrrigValsFile_; GriddedInput* iamC4AIrrigValsFile_; GriddedInput* iamC4PIrrigValsFile_; GriddedInput* iamC3NIrrigValsFile_; GriddedInput* iamFutureCropBiofuelFile_; GriddedInput* iamC3PBiofuelFile_; GriddedInput* iamC4PBiofuelFile_; double harvProbabilities[N_PROB]; double fertScaleFactor; void init (GridInfo* grid, Config& config); void loadNextStates (int year); void loadWoodHarvestData (int year, std::vector& countries); void loadFuelWoodData (int year, std::vector& countries); void loadNationalFloodedData (int year, std::vector& countries); void loadFertScalefactorData (int year); void loadTillageData (int year, std::vector& countries); void loadFertData (int year, std::vector& countries, Config& config); void loadIrrigData (int year, std::vector& countries, Config& config); void loadCropRotationsData (int year, std::vector& countries); void loadCropBiofuelData (int year, std::vector& countries); void openCFTFractionFile (const char* filename); void loadCFTFractionData (int year, std::vector& countries); void closeCFTFractionFile (); }; } #endif // GLM_INPUT_FILES_H_