diff --git a/.travis.yml b/.travis.yml index 93244b392..1235ca5be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -54,6 +54,7 @@ script: # run unit tests - cd tests - ctest + - cat ./Testing/Temporary/* - cd $SWMM_HOME - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then pip install --src build/packages -r tools/requirements.txt ; diff --git a/docs/modules_toolkit.dox b/docs/modules_toolkit.dox index e39a66e74..9ddda1cec 100644 --- a/docs/modules_toolkit.dox +++ b/docs/modules_toolkit.dox @@ -5,7 +5,8 @@ @addtogroup tkfuncs @{ -@fn int swmm_getCurrentDateTimeStr(char *dtimestr) +@fn int swmm_getCurrentDateTime(int *year, int *month, int *day, + int *hour, int *minute, int *second) @fn int swmm_getNodeResult (int index, int type, double *result) @fn int swmm_getLinkResult (int index, int type, double *result) @fn int swmm_getSubcatchResult (int index, int type, double *result) @@ -16,11 +17,12 @@ @fn int swmm_freeOutfallStats (SM_OutfallStats *outfallStats) @fn int swmm_getLinkStats (int index, SM_LinkStats *linkStats) @fn int swmm_getPumpStats (int index, SM_PumpStats *pumpStats) -@fn int swmm_getSubcatchStats (int index, SM_SubcatchStats *subcatchStats) +@fn int swmm_getSubcatchStats (int index, SM_SubcatchStats **subcatchStats) @fn int swmm_getSystemRoutingStats (SM_RoutingTotals *routingTot) @fn int swmm_getSystemRunoffStats (SM_RunoffTotals *runoffTot) @fn int swmm_setLinkSetting (int index, double setting) @fn int swmm_setNodeInflow (int index, double flowrate) @fn int swmm_setOutfallStage (int index, double stage) +@fm int swmm_setGagePrecip(int index, double total_precip) @} */ \ No newline at end of file diff --git a/include/toolkitAPI.h b/include/toolkitAPI.h index 3ef8f831c..0c8eacdd9 100644 --- a/include/toolkitAPI.h +++ b/include/toolkitAPI.h @@ -601,6 +601,7 @@ typedef struct double pctError; } SM_RunoffTotals; + /** @brief Get the text of an error code. @param errcode The error code @@ -911,6 +912,9 @@ int DLLEXPORT swmm_setSimulationDateTime(int timetype, int year, int month, int day, int hour, int minute, int second); +//------------------------------- +// Active Simulation Results API +//------------------------------- /** @brief Get the current simulation datetime information. @param[out] year The year @@ -1093,6 +1097,12 @@ int DLLEXPORT swmm_setOutfallStage(int index, double stage); */ int DLLEXPORT swmm_setGagePrecip(int index, double total_precip); +/** + @brief Save hotstart file during simulation + @param hsfile The file name of the hotstart file that user would like to save +*/ +int DLLEXPORT swmm_saveHotstart(char *hsfile); + /** @brief Helper function to free memory array allocated in SWMM. @param array The pointer to the array diff --git a/src/funcs.h b/src/funcs.h index 6dc5c932a..77d36022d 100644 --- a/src/funcs.h +++ b/src/funcs.h @@ -84,7 +84,7 @@ void report_writeSysStats(TSysStats* sysStats); void report_writeErrorMsg(int code, char* msg); void report_writeErrorCode(void); void report_writeInputErrorMsg(int k, int sect, char* line, long lineCount); -void report_writeWarningMsg(char* msg, char* id); +void report_writeWarningMsg(char* msg, char* id); void report_writeTseriesErrorMsg(int code, TTable *tseries); void inputrpt_writeInput(void); @@ -273,7 +273,7 @@ void stats_report(void); void stats_updateCriticalTimeCount(int node, int link); void stats_updateFlowStats(double tStep, DateTime aDate, int stepCount, int steadyState); -void stats_updateSubcatchStats(int subcatch, double rainVol, +void stats_updateSubcatchStats(int subcatch, double rainVol, double runonVol, double evapVol, double infilVol, double impervVol, double pervVol, double runoffVol, double runoff); //(5.1.013) void stats_updateGwaterStats(int j, double infil, double evap, @@ -357,12 +357,12 @@ void node_getResults(int node, double wt, float x[]); int inflow_readExtInflow(char* tok[], int ntoks); int inflow_readDwfInflow(char* tok[], int ntoks); int inflow_readDwfPattern(char* tok[], int ntoks); -int inflow_setExtInflow(int j, int param, int type, - int tSeries, int basePat, double cf, +int inflow_setExtInflow(int j, int param, int type, + int tSeries, int basePat, double cf, double baseline, double sf); -int inflow_validate(int param, int type, int tSeries, - int basePat, double *cf); - +int inflow_validate(int param, int type, int tSeries, + int basePat, double *cf); + void inflow_initDwfInflow(TDwfInflow* inflow); void inflow_initDwfPattern(int pattern); @@ -389,7 +389,10 @@ void iface_saveOutletResults(DateTime reportDate, FILE* file); // Hot Start File Methods //----------------------------------------------------------------------------- int hotstart_open(void); -void hotstart_close(void); +void hotstart_close(TFile hsfile); +int openHotstartFile2(TFile hsfile); +int saveRunoff(TFile hsfile); +int saveRouting(TFile hsfile); //----------------------------------------------------------------------------- // Conveyance System Link Methods @@ -472,7 +475,7 @@ int shape_validate(TShape *shape, TTable *curve); int controls_create(int n); void controls_delete(void); int controls_addRuleClause(int rule, int keyword, char* Tok[], int nTokens); -int controls_evaluate(DateTime currentTime, DateTime elapsedTime, +int controls_evaluate(DateTime currentTime, DateTime elapsedTime, double tStep); //----------------------------------------------------------------------------- diff --git a/src/hotstart.c b/src/hotstart.c index be81670bd..848355a52 100644 --- a/src/hotstart.c +++ b/src/hotstart.c @@ -16,8 +16,8 @@ // a simulation has been run, allowing it to be used to initialize // a subsequent simulation that picks up where the previous run ended. // -// An abridged version of the hot start file (version 2) is available -// that contains only variables that appear in the binary output file +// An abridged version of the hot start file (version 2) is available +// that contains only variables that appear in the binary output file // (groundwater upper moisture and water table elevation, node depth, // lateral inflow, and quality, and link flow, depth, setting and quality). // @@ -35,7 +35,7 @@ // - Array indexing bug when reading snowpack state from file fixed. // // Build 5.1.011: -// - Link control setting bug when reading a hot start file fixed. +// - Link control setting bug when reading a hot start file fixed. // //----------------------------------------------------------------------------- #define _CRT_SECURE_NO_DEPRECATE @@ -60,12 +60,9 @@ static int fileVersion; //----------------------------------------------------------------------------- // Function declarations //----------------------------------------------------------------------------- -static int openHotstartFile1(void); -static int openHotstartFile2(void); +static int openHotstartFile1(void); static void readRunoff(void); -static void saveRunoff(void); static void readRouting(void); -static void saveRouting(void); static int readFloat(float *x, FILE* f); static int readDouble(double* x, FILE* f); @@ -75,19 +72,27 @@ int hotstart_open() { // --- open hot start files if ( !openHotstartFile1() ) return FALSE; //input hot start file - if ( !openHotstartFile2() ) return FALSE; //output hot start file + if ( !openHotstartFile2(Fhotstart2) ) return FALSE; //output hot start file + + //// Following lines removed. //// //(5.1.005) + //if ( Fhotstart1.file ) + //{ + // readRunoff(); + // readRouting(); + // fclose(Fhotstart1.file); + //} + return TRUE; } //============================================================================= -void hotstart_close() +void hotstart_close(TFile hsfile) { - if ( Fhotstart2.file ) + if (hsfile.mode != NO_FILE) { - saveRunoff(); - saveRouting(); - fclose(Fhotstart2.file); + saveRunoff(hsfile); + saveRouting(hsfile); } } @@ -145,7 +150,7 @@ int openHotstartFile1() nLandUses = -1; flowUnits = -1; if ( fileVersion >= 2 ) - { + { fread(&nSubcatch, sizeof(int), 1, Fhotstart1.file); } else nSubcatch = Nobjects[SUBCATCH]; @@ -158,7 +163,7 @@ int openHotstartFile1() fread(&nLinks, sizeof(int), 1, Fhotstart1.file); fread(&nPollut, sizeof(int), 1, Fhotstart1.file); fread(&flowUnits, sizeof(int), 1, Fhotstart1.file); - if ( nSubcatch != Nobjects[SUBCATCH] + if ( nSubcatch != Nobjects[SUBCATCH] || nLandUses != Nobjects[LANDUSE] || nNodes != Nobjects[NODE] || nLinks != Nobjects[LINK] @@ -179,7 +184,7 @@ int openHotstartFile1() //============================================================================= -int openHotstartFile2() +int openHotstartFile2(TFile hsfile) // // Input: none // Output: none @@ -195,10 +200,10 @@ int openHotstartFile2() char fileStamp[] = "SWMM5-HOTSTART4"; // --- try to open file - if ( Fhotstart2.mode != SAVE_FILE ) return TRUE; - if ( (Fhotstart2.file = fopen(Fhotstart2.name, "w+b")) == NULL) + if ( hsfile.mode != SAVE_FILE ) return TRUE; + if ( (hsfile.file = fopen(hsfile.name, "w+b")) == NULL) { - report_writeErrorMsg(ERR_HOTSTART_FILE_OPEN, Fhotstart2.name); + report_writeErrorMsg(ERR_HOTSTART_FILE_OPEN, hsfile.name); return FALSE; } @@ -209,25 +214,32 @@ int openHotstartFile2() nLinks = Nobjects[LINK]; nPollut = Nobjects[POLLUT]; flowUnits = FlowUnits; - fwrite(fileStamp, sizeof(char), strlen(fileStamp), Fhotstart2.file); - fwrite(&nSubcatch, sizeof(int), 1, Fhotstart2.file); - fwrite(&nLandUses, sizeof(int), 1, Fhotstart2.file); - fwrite(&nNodes, sizeof(int), 1, Fhotstart2.file); - fwrite(&nLinks, sizeof(int), 1, Fhotstart2.file); - fwrite(&nPollut, sizeof(int), 1, Fhotstart2.file); - fwrite(&flowUnits, sizeof(int), 1, Fhotstart2.file); + fwrite(fileStamp, sizeof(char), strlen(fileStamp), hsfile.file); + fwrite(&nSubcatch, sizeof(int), 1, hsfile.file); + fwrite(&nLandUses, sizeof(int), 1, hsfile.file); + fwrite(&nNodes, sizeof(int), 1, hsfile.file); + fwrite(&nLinks, sizeof(int), 1, hsfile.file); + fwrite(&nPollut, sizeof(int), 1, hsfile.file); + fwrite(&flowUnits, sizeof(int), 1, hsfile.file); + fclose(hsfile.file); return TRUE; } //============================================================================= -void saveRouting() +int saveRouting(TFile hsfile) // // Input: none // Output: none // Purpose: saves current state of all nodes and links to hotstart file. // { + if ( (hsfile.file = fopen(hsfile.name, "a+b")) == NULL) + { + report_writeErrorMsg(ERR_HOTSTART_FILE_OPEN, hsfile.name); + return FALSE; + } + int i, j; float x[3]; @@ -235,19 +247,19 @@ void saveRouting() { x[0] = (float)Node[i].newDepth; x[1] = (float)Node[i].newLatFlow; - fwrite(x, sizeof(float), 2, Fhotstart2.file); + fwrite(x, sizeof(float), 2, hsfile.file); if ( Node[i].type == STORAGE ) { j = Node[i].subIndex; x[0] = (float)Storage[j].hrt; - fwrite(&x[0], sizeof(float), 1, Fhotstart2.file); + fwrite(&x[0], sizeof(float), 1, hsfile.file); } for (j = 0; j < Nobjects[POLLUT]; j++) { x[0] = (float)Node[i].newQual[j]; - fwrite(&x[0], sizeof(float), 1, Fhotstart2.file); + fwrite(&x[0], sizeof(float), 1, hsfile.file); } } for (i = 0; i < Nobjects[LINK]; i++) @@ -255,20 +267,22 @@ void saveRouting() x[0] = (float)Link[i].newFlow; x[1] = (float)Link[i].newDepth; x[2] = (float)Link[i].setting; - fwrite(x, sizeof(float), 3, Fhotstart2.file); + fwrite(x, sizeof(float), 3, hsfile.file); for (j = 0; j < Nobjects[POLLUT]; j++) { x[0] = (float)Link[i].newQual[j]; - fwrite(&x[0], sizeof(float), 1, Fhotstart2.file); + fwrite(&x[0], sizeof(float), 1, hsfile.file); } } + fclose(hsfile.file); + return TRUE; } //============================================================================= void readRouting() // -// Input: none +// Input: none // Output: none // Purpose: reads initial state of all nodes, links and groundwater objects // from hotstart file. @@ -339,7 +353,7 @@ void readRouting() if ( !readFloat(&x, f) ) return; Link[i].setting = x; - // --- set link's target setting to saved setting + // --- set link's target setting to saved setting Link[i].targetSetting = x; link_setTargetSetting(i); link_setSetting(i, 0.0); @@ -355,16 +369,21 @@ void readRouting() //============================================================================= -void saveRunoff(void) +int saveRunoff(TFile hsfile) // // Input: none // Output: none // Purpose: saves current state of all subcatchments to hotstart file. // { + if ( (hsfile.file = fopen(hsfile.name, "a+b")) == NULL) + { + report_writeErrorMsg(ERR_HOTSTART_FILE_OPEN, hsfile.name); + return FALSE; + } + int i, j, k, sizeX; double* x; - FILE* f = Fhotstart2.file; sizeX = MAX(6, Nobjects[POLLUT]+1); x = (double *) calloc(sizeX, sizeof(double)); @@ -374,18 +393,19 @@ void saveRunoff(void) // Ponded depths for each sub-area & total runoff (4 elements) for (j = 0; j < 3; j++) x[j] = Subcatch[i].subArea[j].depth; x[3] = Subcatch[i].newRunoff; - fwrite(x, sizeof(double), 4, f); + /*printf("%d", x[3]);*/ + fwrite(x, sizeof(double), 4, hsfile.file); // Infiltration state (max. of 6 elements) for (j=0; j 0 ) + if ( Nobjects[POLLUT] > 0 ) { // Runoff quality for (j=0; j ft/sec) {12.0, 304.8 }, // RAINDEPTH (in, mm --> ft) @@ -138,7 +138,7 @@ const double Ucf[10][2] = extern const double Qcf[6] = // Flow Conversion Factors: #else const double Qcf[6] = // Flow Conversion Factors: -#endif +#endif {1.0, 448.831, 0.64632, // cfs, gpm, mgd --> cfs 0.02832, 28.317, 2.4466 }; // cms, lps, mld --> cfs @@ -303,7 +303,7 @@ int DLLEXPORT swmm_open(char* f1, char* f2, char* f3) int DLLEXPORT swmm_start(int saveResults) // -// Input: saveResults = TRUE if simulation results saved to binary file +// Input: saveResults = TRUE if simulation results saved to binary file // Output: returns an error code // Purpose: starts a SWMM simulation. // @@ -372,7 +372,7 @@ int DLLEXPORT swmm_start(int saveResults) massbal_open(); stats_open(); - // --- write project options to report file + // --- write project options to report file report_writeOptions(); if ( RptFlags.controls ) report_writeControlActionsHeading(); } @@ -519,7 +519,7 @@ void execRouting() // --- if no runoff analysis, update climate state (for evaporation) else climate_setState(getDateTime(NewRoutingTime)); - + // --- route flows & pollutants through drainage system // (while updating NewRoutingTime) if ( DoRouting ) routing_execute(RouteModel, routingStep); @@ -572,7 +572,7 @@ int DLLEXPORT swmm_end(void) if ( !IgnoreRainfall ) rain_close(); if ( DoRunoff ) runoff_close(); if ( DoRouting ) routing_close(RouteModel); - hotstart_close(); + hotstart_close(Fhotstart2); IsStartedFlag = FALSE; } return error_getCode(ErrorCode); @@ -658,7 +658,7 @@ int DLLEXPORT swmm_getVersion(void) // y = minor version number, and zzz = build number. // // NOTE: Each New Release should be updated in consts.h -// THIS FUNCTION WILL EVENTUALLY BE DEPRECATED +// THIS FUNCTION WILL EVENTUALLY BE DEPRECATED { return VERSION; } @@ -667,7 +667,7 @@ void DLLEXPORT swmm_getSemVersion(char* semver) // // Output: Returns Semantic Version // Purpose: retrieves the current semantic version -// +// // NOTE: Each New Release should be updated in consts.h { getSemVersion(semver); @@ -677,7 +677,7 @@ void DLLEXPORT swmm_getVersionInfo(char* major, char* minor, char* patch) // // Output: Returns Semantic Version Info // Purpose: retrieves the current semantic version -// +// // NOTE: Each New Release should be updated in consts.h { strncpy(major, SEMVERSION_MAJOR, sizeof SEMVERSION_MAJOR); @@ -965,10 +965,10 @@ void getSemVersion(char* semver) // // Output: Returns Semantic Version // Purpose: retrieves the current semantic version -// +// // NOTE: Each New Release should be updated in consts.h { - snprintf(semver, SEMVERSION_LEN, "%s.%s.%s", + snprintf(semver, SEMVERSION_LEN, "%s.%s.%s", SEMVERSION_MAJOR, SEMVERSION_MINOR, SEMVERSION_PATCH); } //============================================================================= diff --git a/src/toolkitAPI.c b/src/toolkitAPI.c index c78f5876b..8c576ae5a 100644 --- a/src/toolkitAPI.c +++ b/src/toolkitAPI.c @@ -2659,6 +2659,46 @@ int DLLEXPORT swmm_setGagePrecip(int index, double total_precip) return error_getCode(error_code_index); } +int DLLEXPORT swmm_saveHotstart(char *hsfile) +// +// Input: hsfile = path of filename to save hotstart data to (e.g., 'myhotstart.hsf') +// Output: None +// Purpose: save a hotstart file at any point in simulation +{ + int error_code_index = 0; + // Check if Open + if(swmm_IsOpenFlag() == FALSE) + { + error_code_index = ERR_API_INPUTNOTOPEN; + } + // Check if Simulation is Running + else if (swmm_IsStartedFlag() == FALSE) + { + error_code_index = ERR_API_SIM_NRUNNING; + } + else + { + // make a new instance of a TFile struct, Fhotstart_custom + TFile Fhotstart_custom; + // set the 'mode' attribute of new TFile struct to 'SAVE_FILE' as done in normal run in + // ... iface.c + Fhotstart_custom.mode = SAVE_FILE; + // set the 'name' attribute of Fhotstart_custom to char array passed as function parameter + sstrncpy(Fhotstart_custom.name, hsfile, MAXFNAME); + // call openHotstartFile2 from hotstart.c to open custom hotstart file for writing + openHotstartFile2(Fhotstart_custom); + // check to make sure there is the file + if (Fhotstart_custom.file) + { + // write the runoff states to the hotstart file + saveRunoff(Fhotstart_custom); + // write the routing states to the hotstart file (file is closed in saveRouting) + saveRouting(Fhotstart_custom); + } + } + return error_getCode(error_code_index); +} + //------------------------------- // Utility Functions //------------------------------- diff --git a/tests/data/hotstart/swmm_api_test_19980101_014000.inp b/tests/data/hotstart/swmm_api_test_19980101_014000.inp new file mode 100644 index 000000000..33cfa6ffc --- /dev/null +++ b/tests/data/hotstart/swmm_api_test_19980101_014000.inp @@ -0,0 +1,332 @@ +[TITLE] +;;Project Title/Notes +Example 1 + +[OPTIONS] +;;Option Value +FLOW_UNITS CFS +INFILTRATION HORTON +FLOW_ROUTING KINWAVE +LINK_OFFSETS DEPTH +MIN_SLOPE 0 +ALLOW_PONDING NO +SKIP_STEADY_STATE NO + +START_DATE 01/01/1998 +START_TIME 00:00:00 +REPORT_START_DATE 01/01/1998 +REPORT_START_TIME 00:00:00 +END_DATE 01/02/1998 +END_TIME 12:00:00 +SWEEP_START 1/1 +SWEEP_END 12/31 +DRY_DAYS 5 +REPORT_STEP 01:00:00 +WET_STEP 00:15:00 +DRY_STEP 01:00:00 +ROUTING_STEP 0:01:00 + +INERTIAL_DAMPING PARTIAL +NORMAL_FLOW_LIMITED BOTH +FORCE_MAIN_EQUATION H-W +VARIABLE_STEP 0.75 +LENGTHENING_STEP 0 +MIN_SURFAREA 0 +MAX_TRIALS 0 +HEAD_TOLERANCE 0 +SYS_FLOW_TOL 5 +LAT_FLOW_TOL 5 +;MINIMUM_STEP 0.5 +THREADS 1 + +[FILES] +SAVE HOTSTART hotstart/TestHSF_19980101_014000.hsf + +[EVAPORATION] +;;Data Source Parameters +;;-------------- ---------------- +CONSTANT 0.0 +DRY_ONLY NO + +[RAINGAGES] +;;Name Format Interval SCF Source +;;-------------- --------- ------ ------ ---------- +RG1 INTENSITY 1:00 1.0 TIMESERIES TS1 + +[SUBCATCHMENTS] +;;Name Rain Gage Outlet Area %Imperv Width %Slope CurbLen SnowPack +;;-------------- ---------------- ---------------- -------- -------- -------- -------- -------- ---------------- +1 RG1 9 10 50 500 0.01 0 +2 RG1 10 10 50 500 0.01 0 +3 RG1 13 5 50 500 0.01 0 +4 RG1 22 5 50 500 0.01 0 +5 RG1 15 15 50 500 0.01 0 +6 RG1 23 12 10 500 0.01 0 +7 RG1 19 4 10 500 0.01 0 +8 RG1 18 10 10 500 0.01 0 + +[SUBAREAS] +;;Subcatchment N-Imperv N-Perv S-Imperv S-Perv PctZero RouteTo PctRouted +;;-------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- +1 0.001 0.10 0.05 0.05 25 OUTLET +2 0.001 0.10 0.05 0.05 25 OUTLET +3 0.001 0.10 0.05 0.05 25 OUTLET +4 0.001 0.10 0.05 0.05 25 OUTLET +5 0.001 0.10 0.05 0.05 25 OUTLET +6 0.001 0.10 0.05 0.05 25 OUTLET +7 0.001 0.10 0.05 0.05 25 OUTLET +8 0.001 0.10 0.05 0.05 25 OUTLET + +[INFILTRATION] +;;Subcatchment MaxRate MinRate Decay DryTime MaxInfil +;;-------------- ---------- ---------- ---------- ---------- ---------- +1 0.35 0.25 4.14 0.50 0 +2 0.7 0.3 4.14 0.50 0 +3 0.7 0.3 4.14 0.50 0 +4 0.7 0.3 4.14 0.50 0 +5 0.7 0.3 4.14 0.50 0 +6 0.7 0.3 4.14 0.50 0 +7 0.7 0.3 4.14 0.50 0 +8 0.7 0.3 4.14 0.50 0 + +[JUNCTIONS] +;;Name Elevation MaxDepth InitDepth SurDepth Aponded +;;-------------- ---------- ---------- ---------- ---------- ---------- +9 1000 3 0 0 0 +10 995 3 0 0 0 +13 995 3 0 0 0 +14 990 3 0 0 0 +15 987 3 0 0 0 +16 985 3 0 0 0 +17 980 3 0 0 0 +19 1010 3 0 0 0 +20 1005 3 0 0 0 +21 990 3 0 0 0 +22 987 3 0 0 0 +23 990 3 0 0 0 +24 984 3 0 0 0 + +[OUTFALLS] +;;Name Elevation Type Stage Data Gated Route To +;;-------------- ---------- ---------- ---------------- -------- ---------------- +18 975 FREE NO + +[CONDUITS] +;;Name From Node To Node Length Roughness InOffset OutOffset InitFlow MaxFlow +;;-------------- ---------------- ---------------- ---------- ---------- ---------- ---------- ---------- ---------- +1 9 10 400 0.01 0 0 0 0 +4 19 20 200 0.01 0 0 0 0 +5 20 21 200 0.01 0 0 0 0 +6 10 21 400 0.01 0 1 0 0 +7 21 22 300 0.01 1 1 0 0 +8 22 16 300 0.01 0 0 0 0 +10 17 18 400 0.01 0 0 0 0 +11 13 14 400 0.01 0 0 0 0 +12 14 15 400 0.01 0 0 0 0 +13 15 16 400 0.01 0 0 0 0 +14 23 24 400 0.01 0 0 0 0 +15 16 24 100 0.01 0 0 0 0 +16 24 17 400 0.01 0 0 0 0 + +[XSECTIONS] +;;Link Shape Geom1 Geom2 Geom3 Geom4 Barrels Culvert +;;-------------- ------------ ---------------- ---------- ---------- ---------- ---------- ---------- +1 CIRCULAR 1.5 0 0 0 1 +4 CIRCULAR 1 0 0 0 1 +5 CIRCULAR 1 0 0 0 1 +6 CIRCULAR 1 0 0 0 1 +7 CIRCULAR 2 0 0 0 1 +8 CIRCULAR 2 0 0 0 1 +10 CIRCULAR 2 0 0 0 1 +11 CIRCULAR 1.5 0 0 0 1 +12 CIRCULAR 1.5 0 0 0 1 +13 CIRCULAR 1.5 0 0 0 1 +14 CIRCULAR 1 0 0 0 1 +15 CIRCULAR 2 0 0 0 1 +16 CIRCULAR 2 0 0 0 1 + +[POLLUTANTS] +;;Name Units Crain Cgw Crdii Kdecay SnowOnly Co-Pollutant Co-Frac Cdwf Cinit +;;-------------- ------ ---------- ---------- ---------- ---------- ---------- ---------------- ---------- ---------- ---------- +TSS MG/L 0.0 0.0 0 0.0 NO * 0.0 0 0 +Lead UG/L 0.0 0.0 0 0.0 NO TSS 0.2 0 0 + +[LANDUSES] +;; Sweeping Fraction Last +;;Name Interval Available Swept +;;-------------- ---------- ---------- ---------- +Residential +Undeveloped + +[COVERAGES] +;;Subcatchment Land Use Percent +;;-------------- ---------------- ---------- +1 Residential 100.00 +2 Residential 50.00 +2 Undeveloped 50.00 +3 Residential 100.00 +4 Residential 50.00 +4 Undeveloped 50.00 +5 Residential 100.00 +6 Undeveloped 100.00 +7 Undeveloped 100.00 +8 Undeveloped 100.00 + +[LOADINGS] +;;Subcatchment Pollutant Buildup +;;-------------- ---------------- ---------- + +[BUILDUP] +;;Land Use Pollutant Function Coeff1 Coeff2 Coeff3 Per Unit +;;-------------- ---------------- ---------- ---------- ---------- ---------- ---------- +Residential TSS SAT 50 0 2 AREA +Residential Lead NONE 0 0 0 AREA +Undeveloped TSS SAT 100 0 3 AREA +Undeveloped Lead NONE 0 0 0 AREA + +[WASHOFF] +;;Land Use Pollutant Function Coeff1 Coeff2 SweepRmvl BmpRmvl +;;-------------- ---------------- ---------- ---------- ---------- ---------- ---------- +Residential TSS EXP 0.1 1 0 0 +Residential Lead EMC 0 0 0 0 +Undeveloped TSS EXP 0.1 0.7 0 0 +Undeveloped Lead EMC 0 0 0 0 + +[TIMESERIES] +;;Name Date Time Value +;;-------------- ---------- ---------- ---------- +;RAINFALL +TS1 0:00 0.0 +TS1 1:00 0.25 +TS1 2:00 0.5 +TS1 3:00 0.8 +TS1 4:00 0.4 +TS1 5:00 0.1 +TS1 6:00 0.0 +TS1 27:00 0.0 +TS1 28:00 0.4 +TS1 29:00 0.2 +TS1 30:00 0.0 + +[REPORT] +;;Reporting Options +INPUT NO +CONTROLS NO +SUBCATCHMENTS ALL +NODES ALL +LINKS ALL + +[TAGS] + +[MAP] +DIMENSIONS 0.000 0.000 10000.000 10000.000 +Units None + +[COORDINATES] +;;Node X-Coord Y-Coord +;;-------------- ------------------ ------------------ +9 4042.110 9600.000 +10 4105.260 6947.370 +13 2336.840 4357.890 +14 3157.890 4294.740 +15 3221.050 3242.110 +16 4821.050 3326.320 +17 6252.630 2147.370 +19 7768.420 6736.840 +20 5957.890 6589.470 +21 4926.320 6105.260 +22 4421.050 4715.790 +23 6484.210 3978.950 +24 5389.470 3031.580 +18 6631.580 505.260 + +[VERTICES] +;;Link X-Coord Y-Coord +;;-------------- ------------------ ------------------ +10 6673.680 1368.420 + +[Polygons] +;;Subcatchment X-Coord Y-Coord +;;-------------- ------------------ ------------------ +1 3936.840 6905.260 +1 3494.740 6252.630 +1 273.680 6336.840 +1 252.630 8526.320 +1 463.160 9200.000 +1 1157.890 9726.320 +1 4000.000 9705.260 +2 7600.000 9663.160 +2 7705.260 6736.840 +2 5915.790 6694.740 +2 4926.320 6294.740 +2 4189.470 7200.000 +2 4126.320 9621.050 +3 2357.890 6021.050 +3 2400.000 4336.840 +3 3031.580 4252.630 +3 2989.470 3389.470 +3 315.790 3410.530 +3 294.740 6000.000 +4 3473.680 6105.260 +4 3915.790 6421.050 +4 4168.420 6694.740 +4 4463.160 6463.160 +4 4821.050 6063.160 +4 4400.000 5263.160 +4 4357.890 4442.110 +4 4547.370 3705.260 +4 4000.000 3431.580 +4 3326.320 3368.420 +4 3242.110 3536.840 +4 3136.840 5157.890 +4 2589.470 5178.950 +4 2589.470 6063.160 +4 3284.210 6063.160 +4 3705.260 6231.580 +4 4126.320 6715.790 +5 2568.420 3200.000 +5 4905.260 3136.840 +5 5221.050 2842.110 +5 5747.370 2421.050 +5 6463.160 1578.950 +5 6610.530 968.420 +5 6589.470 505.260 +5 1305.260 484.210 +5 968.420 336.840 +5 315.790 778.950 +5 315.790 3115.790 +6 9052.630 4147.370 +6 7894.740 4189.470 +6 6442.110 4105.260 +6 5915.790 3642.110 +6 5326.320 3221.050 +6 4631.580 4231.580 +6 4568.420 5010.530 +6 4884.210 5768.420 +6 5368.420 6294.740 +6 6042.110 6568.420 +6 8968.420 6526.320 +7 8736.840 9642.110 +7 9010.530 9389.470 +7 9010.530 8631.580 +7 9052.630 6778.950 +7 7789.470 6800.000 +7 7726.320 9642.110 +8 9073.680 2063.160 +8 9052.630 778.950 +8 8505.260 336.840 +8 7431.580 315.790 +8 7410.530 484.210 +8 6842.110 505.260 +8 6842.110 589.470 +8 6821.050 1178.950 +8 6547.370 1831.580 +8 6147.370 2378.950 +8 5600.000 3073.680 +8 6589.470 3894.740 +8 8863.160 3978.950 + +[SYMBOLS] +;;Gage X-Coord Y-Coord +;;-------------- ------------------ ------------------ +RG1 10084.210 8210.530 diff --git a/tests/data/hotstart/swmm_api_test_use_hotstart.inp b/tests/data/hotstart/swmm_api_test_use_hotstart.inp new file mode 100644 index 000000000..9bcab21fe --- /dev/null +++ b/tests/data/hotstart/swmm_api_test_use_hotstart.inp @@ -0,0 +1,332 @@ +[TITLE] +;;Project Title/Notes +Example 1 + +[OPTIONS] +;;Option Value +FLOW_UNITS CFS +INFILTRATION HORTON +FLOW_ROUTING KINWAVE +LINK_OFFSETS DEPTH +MIN_SLOPE 0 +ALLOW_PONDING NO +SKIP_STEADY_STATE NO + +START_DATE 01/01/1998 +START_TIME 00:00:00 +REPORT_START_DATE 01/01/1998 +REPORT_START_TIME 00:00:00 +END_DATE 01/02/1998 +END_TIME 12:00:00 +SWEEP_START 1/1 +SWEEP_END 12/31 +DRY_DAYS 5 +REPORT_STEP 01:00:00 +WET_STEP 00:15:00 +DRY_STEP 01:00:00 +ROUTING_STEP 0:01:00 + +INERTIAL_DAMPING PARTIAL +NORMAL_FLOW_LIMITED BOTH +FORCE_MAIN_EQUATION H-W +VARIABLE_STEP 0.75 +LENGTHENING_STEP 0 +MIN_SURFAREA 0 +MAX_TRIALS 0 +HEAD_TOLERANCE 0 +SYS_FLOW_TOL 5 +LAT_FLOW_TOL 5 +;MINIMUM_STEP 0.5 +THREADS 1 + +[FILES] +USE HOTSTART hotstart/swmm_api_test.hsf + +[EVAPORATION] +;;Data Source Parameters +;;-------------- ---------------- +CONSTANT 0.0 +DRY_ONLY NO + +[RAINGAGES] +;;Name Format Interval SCF Source +;;-------------- --------- ------ ------ ---------- +RG1 INTENSITY 1:00 1.0 TIMESERIES TS1 + +[SUBCATCHMENTS] +;;Name Rain Gage Outlet Area %Imperv Width %Slope CurbLen SnowPack +;;-------------- ---------------- ---------------- -------- -------- -------- -------- -------- ---------------- +1 RG1 9 10 50 500 0.01 0 +2 RG1 10 10 50 500 0.01 0 +3 RG1 13 5 50 500 0.01 0 +4 RG1 22 5 50 500 0.01 0 +5 RG1 15 15 50 500 0.01 0 +6 RG1 23 12 10 500 0.01 0 +7 RG1 19 4 10 500 0.01 0 +8 RG1 18 10 10 500 0.01 0 + +[SUBAREAS] +;;Subcatchment N-Imperv N-Perv S-Imperv S-Perv PctZero RouteTo PctRouted +;;-------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- +1 0.001 0.10 0.05 0.05 25 OUTLET +2 0.001 0.10 0.05 0.05 25 OUTLET +3 0.001 0.10 0.05 0.05 25 OUTLET +4 0.001 0.10 0.05 0.05 25 OUTLET +5 0.001 0.10 0.05 0.05 25 OUTLET +6 0.001 0.10 0.05 0.05 25 OUTLET +7 0.001 0.10 0.05 0.05 25 OUTLET +8 0.001 0.10 0.05 0.05 25 OUTLET + +[INFILTRATION] +;;Subcatchment MaxRate MinRate Decay DryTime MaxInfil +;;-------------- ---------- ---------- ---------- ---------- ---------- +1 0.35 0.25 4.14 0.50 0 +2 0.7 0.3 4.14 0.50 0 +3 0.7 0.3 4.14 0.50 0 +4 0.7 0.3 4.14 0.50 0 +5 0.7 0.3 4.14 0.50 0 +6 0.7 0.3 4.14 0.50 0 +7 0.7 0.3 4.14 0.50 0 +8 0.7 0.3 4.14 0.50 0 + +[JUNCTIONS] +;;Name Elevation MaxDepth InitDepth SurDepth Aponded +;;-------------- ---------- ---------- ---------- ---------- ---------- +9 1000 3 0 0 0 +10 995 3 0 0 0 +13 995 3 0 0 0 +14 990 3 0 0 0 +15 987 3 0 0 0 +16 985 3 0 0 0 +17 980 3 0 0 0 +19 1010 3 0 0 0 +20 1005 3 0 0 0 +21 990 3 0 0 0 +22 987 3 0 0 0 +23 990 3 0 0 0 +24 984 3 0 0 0 + +[OUTFALLS] +;;Name Elevation Type Stage Data Gated Route To +;;-------------- ---------- ---------- ---------------- -------- ---------------- +18 975 FREE NO + +[CONDUITS] +;;Name From Node To Node Length Roughness InOffset OutOffset InitFlow MaxFlow +;;-------------- ---------------- ---------------- ---------- ---------- ---------- ---------- ---------- ---------- +1 9 10 400 0.01 0 0 0 0 +4 19 20 200 0.01 0 0 0 0 +5 20 21 200 0.01 0 0 0 0 +6 10 21 400 0.01 0 1 0 0 +7 21 22 300 0.01 1 1 0 0 +8 22 16 300 0.01 0 0 0 0 +10 17 18 400 0.01 0 0 0 0 +11 13 14 400 0.01 0 0 0 0 +12 14 15 400 0.01 0 0 0 0 +13 15 16 400 0.01 0 0 0 0 +14 23 24 400 0.01 0 0 0 0 +15 16 24 100 0.01 0 0 0 0 +16 24 17 400 0.01 0 0 0 0 + +[XSECTIONS] +;;Link Shape Geom1 Geom2 Geom3 Geom4 Barrels Culvert +;;-------------- ------------ ---------------- ---------- ---------- ---------- ---------- ---------- +1 CIRCULAR 1.5 0 0 0 1 +4 CIRCULAR 1 0 0 0 1 +5 CIRCULAR 1 0 0 0 1 +6 CIRCULAR 1 0 0 0 1 +7 CIRCULAR 2 0 0 0 1 +8 CIRCULAR 2 0 0 0 1 +10 CIRCULAR 2 0 0 0 1 +11 CIRCULAR 1.5 0 0 0 1 +12 CIRCULAR 1.5 0 0 0 1 +13 CIRCULAR 1.5 0 0 0 1 +14 CIRCULAR 1 0 0 0 1 +15 CIRCULAR 2 0 0 0 1 +16 CIRCULAR 2 0 0 0 1 + +[POLLUTANTS] +;;Name Units Crain Cgw Crdii Kdecay SnowOnly Co-Pollutant Co-Frac Cdwf Cinit +;;-------------- ------ ---------- ---------- ---------- ---------- ---------- ---------------- ---------- ---------- ---------- +TSS MG/L 0.0 0.0 0 0.0 NO * 0.0 0 0 +Lead UG/L 0.0 0.0 0 0.0 NO TSS 0.2 0 0 + +[LANDUSES] +;; Sweeping Fraction Last +;;Name Interval Available Swept +;;-------------- ---------- ---------- ---------- +Residential +Undeveloped + +[COVERAGES] +;;Subcatchment Land Use Percent +;;-------------- ---------------- ---------- +1 Residential 100.00 +2 Residential 50.00 +2 Undeveloped 50.00 +3 Residential 100.00 +4 Residential 50.00 +4 Undeveloped 50.00 +5 Residential 100.00 +6 Undeveloped 100.00 +7 Undeveloped 100.00 +8 Undeveloped 100.00 + +[LOADINGS] +;;Subcatchment Pollutant Buildup +;;-------------- ---------------- ---------- + +[BUILDUP] +;;Land Use Pollutant Function Coeff1 Coeff2 Coeff3 Per Unit +;;-------------- ---------------- ---------- ---------- ---------- ---------- ---------- +Residential TSS SAT 50 0 2 AREA +Residential Lead NONE 0 0 0 AREA +Undeveloped TSS SAT 100 0 3 AREA +Undeveloped Lead NONE 0 0 0 AREA + +[WASHOFF] +;;Land Use Pollutant Function Coeff1 Coeff2 SweepRmvl BmpRmvl +;;-------------- ---------------- ---------- ---------- ---------- ---------- ---------- +Residential TSS EXP 0.1 1 0 0 +Residential Lead EMC 0 0 0 0 +Undeveloped TSS EXP 0.1 0.7 0 0 +Undeveloped Lead EMC 0 0 0 0 + +[TIMESERIES] +;;Name Date Time Value +;;-------------- ---------- ---------- ---------- +;RAINFALL +TS1 0:00 0.0 +TS1 1:00 0.25 +TS1 2:00 0.5 +TS1 3:00 0.8 +TS1 4:00 0.4 +TS1 5:00 0.1 +TS1 6:00 0.0 +TS1 27:00 0.0 +TS1 28:00 0.4 +TS1 29:00 0.2 +TS1 30:00 0.0 + +[REPORT] +;;Reporting Options +INPUT NO +CONTROLS NO +SUBCATCHMENTS ALL +NODES ALL +LINKS ALL + +[TAGS] + +[MAP] +DIMENSIONS 0.000 0.000 10000.000 10000.000 +Units None + +[COORDINATES] +;;Node X-Coord Y-Coord +;;-------------- ------------------ ------------------ +9 4042.110 9600.000 +10 4105.260 6947.370 +13 2336.840 4357.890 +14 3157.890 4294.740 +15 3221.050 3242.110 +16 4821.050 3326.320 +17 6252.630 2147.370 +19 7768.420 6736.840 +20 5957.890 6589.470 +21 4926.320 6105.260 +22 4421.050 4715.790 +23 6484.210 3978.950 +24 5389.470 3031.580 +18 6631.580 505.260 + +[VERTICES] +;;Link X-Coord Y-Coord +;;-------------- ------------------ ------------------ +10 6673.680 1368.420 + +[Polygons] +;;Subcatchment X-Coord Y-Coord +;;-------------- ------------------ ------------------ +1 3936.840 6905.260 +1 3494.740 6252.630 +1 273.680 6336.840 +1 252.630 8526.320 +1 463.160 9200.000 +1 1157.890 9726.320 +1 4000.000 9705.260 +2 7600.000 9663.160 +2 7705.260 6736.840 +2 5915.790 6694.740 +2 4926.320 6294.740 +2 4189.470 7200.000 +2 4126.320 9621.050 +3 2357.890 6021.050 +3 2400.000 4336.840 +3 3031.580 4252.630 +3 2989.470 3389.470 +3 315.790 3410.530 +3 294.740 6000.000 +4 3473.680 6105.260 +4 3915.790 6421.050 +4 4168.420 6694.740 +4 4463.160 6463.160 +4 4821.050 6063.160 +4 4400.000 5263.160 +4 4357.890 4442.110 +4 4547.370 3705.260 +4 4000.000 3431.580 +4 3326.320 3368.420 +4 3242.110 3536.840 +4 3136.840 5157.890 +4 2589.470 5178.950 +4 2589.470 6063.160 +4 3284.210 6063.160 +4 3705.260 6231.580 +4 4126.320 6715.790 +5 2568.420 3200.000 +5 4905.260 3136.840 +5 5221.050 2842.110 +5 5747.370 2421.050 +5 6463.160 1578.950 +5 6610.530 968.420 +5 6589.470 505.260 +5 1305.260 484.210 +5 968.420 336.840 +5 315.790 778.950 +5 315.790 3115.790 +6 9052.630 4147.370 +6 7894.740 4189.470 +6 6442.110 4105.260 +6 5915.790 3642.110 +6 5326.320 3221.050 +6 4631.580 4231.580 +6 4568.420 5010.530 +6 4884.210 5768.420 +6 5368.420 6294.740 +6 6042.110 6568.420 +6 8968.420 6526.320 +7 8736.840 9642.110 +7 9010.530 9389.470 +7 9010.530 8631.580 +7 9052.630 6778.950 +7 7789.470 6800.000 +7 7726.320 9642.110 +8 9073.680 2063.160 +8 9052.630 778.950 +8 8505.260 336.840 +8 7431.580 315.790 +8 7410.530 484.210 +8 6842.110 505.260 +8 6842.110 589.470 +8 6821.050 1178.950 +8 6547.370 1831.580 +8 6147.370 2378.950 +8 5600.000 3073.680 +8 6589.470 3894.740 +8 8863.160 3978.950 + +[SYMBOLS] +;;Gage X-Coord Y-Coord +;;-------------- ------------------ ------------------ +RG1 10084.210 8210.530 diff --git a/tests/data/swmm_api_test.inp b/tests/data/swmm_api_test.inp index 4e54ae698..3ac834438 100644 --- a/tests/data/swmm_api_test.inp +++ b/tests/data/swmm_api_test.inp @@ -39,6 +39,10 @@ LAT_FLOW_TOL 5 ;MINIMUM_STEP 0.5 THREADS 1 +[FILES] +SAVE HOTSTART hotstart/TestHSF.hsf + + [EVAPORATION] ;;Data Source Parameters ;;-------------- ---------------- diff --git a/tests/test_toolkitapi_hotstart.cpp b/tests/test_toolkitapi_hotstart.cpp new file mode 100644 index 000000000..d04e32b88 --- /dev/null +++ b/tests/test_toolkitapi_hotstart.cpp @@ -0,0 +1,157 @@ +/* + * test_toolkitAPI_hotstart.cpp + * + * Created: 07/29/2019 + * Author: Bryant E. McDonnell + * EmNet, a Xylem Brand + * + * Unit testing mechanics for the hotstart API using Boost Test. + */ + +// NOTE: Travis installs libboost test version 1.5.4 +//#define BOOST_TEST_DYN_LINK + +#define BOOST_TEST_MODULE "test_save_hotstart" +#include "test_toolkitapi.hpp" +#include +#include + +//#define BENCHMARK_HOTSTART "./hotstart/benchmark_hotstart.hsf" +#define HOTSTART_SWMM_SAVE_NORMAL "./hotstart/TestHSF.hsf" +#define HOTSTART_API_SAVE "./hotstart/swmm_api_test.hsf" +#define HOTSTART_SWMM_SAVE_19980101_014000 "./hotstart/TestHSF_19980101_014000.hsf" +#define HOTSTART_API_SAVE_19980101_014000 "./hotstart/swmm_api_test_19980101_014000.hsf" + +#define ERR_NONE 0 + + +BOOST_AUTO_TEST_SUITE(test_save_hotstart) + +// Testing Run Simulation and Generate Hot Start File using Model (as normal) +// and save a hot start file using the API swmm_saveHotstart() +BOOST_AUTO_TEST_CASE(save_hotstart_file){ + int error, step_ind; + int y, m, d, h, mn, s; + double value; + double elapsedTime = 0.0; + + // Cleanup files if they exist + if (FILE *fl_check = fopen(HOTSTART_API_SAVE, "r")) + { + fclose(fl_check); + remove(HOTSTART_API_SAVE); + } + if (FILE *fl_check = fopen(HOTSTART_SWMM_SAVE_NORMAL, "r")) + { + fclose(fl_check); + remove(HOTSTART_SWMM_SAVE_NORMAL); + } + if (FILE *fl_check = fopen(HOTSTART_SWMM_SAVE_19980101_014000, "r")) + { + fclose(fl_check); + remove(HOTSTART_SWMM_SAVE_19980101_014000); + } + if (FILE *fl_check = fopen(HOTSTART_API_SAVE_19980101_014000, "r")) + { + fclose(fl_check); + remove(HOTSTART_API_SAVE_19980101_014000); + } + + // Start simulation + swmm_open((char *)DATA_PATH_INP, (char *)DATA_PATH_RPT, (char *)DATA_PATH_OUT); + swmm_start(0); + step_ind = 0; + do + { + error = swmm_step(&elapsedTime); + step_ind += 1; + if (step_ind == 100) + { + swmm_getCurrentDateTime(&y, &m, &d, &h, &mn, &s); + //char *output_time = (char*)malloc(30*sizeof(char)); + //sprintf(output_time, "%d/%d/%d %d:%d:%d",y,m,d,h,mn,s); + //BOOST_TEST(1 == 0, output_time); + swmm_saveHotstart((char *) HOTSTART_API_SAVE_19980101_014000); + } + + }while (elapsedTime != 0 && !error); + BOOST_CHECK_EQUAL(0, error); + // Save New Hotstart File at the End of the Simulation + error = swmm_saveHotstart((char *) HOTSTART_API_SAVE); + BOOST_CHECK_EQUAL(0, error); + + swmm_end(); + swmm_close(); + + + // Start simulation 2 + swmm_open((char *)"hotstart/swmm_api_test_19980101_014000.inp", + (char *)"hotstart/swmm_api_test_19980101_014000.rpt", + (char *)"hotstart/swmm_api_test_19980101_014000.out"); + swmm_start(0); + step_ind = 0; + elapsedTime = 0.0; + do + { + error = swmm_step(&elapsedTime); + step_ind += 1; + }while (step_ind != 100 && !error); + BOOST_CHECK_EQUAL(0, error); + //swmm_getCurrentDateTime(&y, &m, &d, &h, &mn, &s); + //char *output_time = (char*)malloc(30*sizeof(char)); + //sprintf(output_time, "%d/%d/%d %d:%d:%d",y,m,d,h,mn,s); + //BOOST_TEST(1 == 0, output_time); + swmm_end(); + swmm_close(); + + // Diff the three hot start files that come from the model. + //std::ifstream ifsbench1(BENCHMARK_HOTSTART); + //std::ifstream ifsbench2(BENCHMARK_HOTSTART); + std::ifstream ifsbench_1998(HOTSTART_SWMM_SAVE_19980101_014000); + std::ifstream ifs1(HOTSTART_SWMM_SAVE_NORMAL); + std::ifstream ifs2(HOTSTART_API_SAVE); + std::ifstream ifs1_1998(HOTSTART_API_SAVE_19980101_014000); + + //std::istream_iterator bbench(ifsbench1), ebench; + //std::istream_iterator bbench2(ifsbench2), ebench2; + std::istream_iterator bench_1998(ifsbench_1998), ebench_1998; + std::istream_iterator b1(ifs1), e1; + std::istream_iterator b2(ifs2), e2; + std::istream_iterator b_1998(ifs1_1998), e_1998; + + // iterate over hotstart files and check all of them + //BOOST_CHECK_EQUAL_COLLECTIONS(bbench, ebench, b1, e1); + //BOOST_CHECK_EQUAL_COLLECTIONS(bbench2, ebench2, b2, e2); + BOOST_CHECK_EQUAL_COLLECTIONS(b1, e1, b2, e2); + BOOST_CHECK_EQUAL_COLLECTIONS(bench_1998, ebench_1998, b_1998, e_1998); + + + // Testing USE the new generated hotstart file + // Start simulation 2 + swmm_open((char *)"hotstart/swmm_api_test_use_hotstart.inp", + (char *)"hotstart/swmm_api_test_use_hotstart.rpt", + (char *)"hotstart/swmm_api_test_use_hotstart.out"); + swmm_start(0); + step_ind = 0; + elapsedTime = 0.0; + do + { + if(step_ind == 0) + { + error = swmm_getNodeResult(0, SM_FULLDEPTH, &value); + BOOST_CHECK_EQUAL(0, error); + BOOST_CHECK_SMALL(value - 0.0012, 0.0002); + } + error = swmm_step(&elapsedTime); + step_ind += 1; + }while (step_ind != 1 && !error); + BOOST_CHECK_EQUAL(0, error); + //swmm_getCurrentDateTime(&y, &m, &d, &h, &mn, &s); + //char *output_time = (char*)malloc(30*sizeof(char)); + //sprintf(output_time, "%d/%d/%d %d:%d:%d",y,m,d,h,mn,s); + //BOOST_TEST(1 == 0, output_time); + swmm_end(); + swmm_close(); +} + +BOOST_AUTO_TEST_SUITE_END()