From cbf7869d2e5307b4a499f4dabbbd3edc126175c2 Mon Sep 17 00:00:00 2001 From: Abhi Date: Sat, 27 Jan 2018 12:39:00 -0500 Subject: [PATCH 01/57] Rainfall API 0.00.00 --- src/gage.c | 1 + src/objects.h | 1 + src/runoff.c | 10 +++++++-- src/toolkitAPI.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 64 insertions(+), 3 deletions(-) diff --git a/src/gage.c b/src/gage.c index d45a0a9b7..14e1af0c5 100644 --- a/src/gage.c +++ b/src/gage.c @@ -266,6 +266,7 @@ void gage_initState(int j) Gage[j].isUsed = FALSE; Gage[j].rainfall = 0.0; Gage[j].reportRainfall = 0.0; + Gage[j].external_rain = 0; // Default uses rainfall from inp file (rainAPI) if ( IgnoreRainfall ) return; // --- for gage with file data: diff --git a/src/objects.h b/src/objects.h index 9ade1359d..54ec12157 100644 --- a/src/objects.h +++ b/src/objects.h @@ -100,6 +100,7 @@ typedef struct typedef struct { char* ID; // raingage name + int external_rain; // rainfall input from external data source (rainAPI) int dataSource; // data from time series or file int tSeries; // rainfall data time series index char fname[MAXFNAME+1]; // name of rainfall data file diff --git a/src/runoff.c b/src/runoff.c index 872e3b731..4e3a9bed5 100644 --- a/src/runoff.c +++ b/src/runoff.c @@ -194,7 +194,13 @@ void runoff_execute() IsRaining = FALSE; for (j = 0; j < Nobjects[GAGE]; j++) { - gage_setState(j, currentDate); + // Check if rain is input though external data source (rainAPI) + if (Gage[j].external_rain == 0) + { + gage_setState(j, currentDate); + } + // TODO Ensure check that nothing else happnes ! + if ( Gage[j].rainfall > 0.0 ) IsRaining = TRUE; } @@ -523,4 +529,4 @@ void runoff_getOutfallRunon(double tStep) Outfall[i].wRouted[p] = 0.0; } } -} \ No newline at end of file +} diff --git a/src/toolkitAPI.c b/src/toolkitAPI.c index 1556599cd..bf2abae46 100644 --- a/src/toolkitAPI.c +++ b/src/toolkitAPI.c @@ -1090,6 +1090,59 @@ int DLLEXPORT swmm_getSystemRunoffStats(TRunoffTotals *runoffTot) return(errorcode); } +int DLLEXPORT swmm_getGageParam(int index, int Param, double *value) +// +// Input: index = Index of desired ID +// param = Parameter desired (Perhaps define enum) +// Output: value = value to be output +// Return: API Error +// Purpose: Gets Gage Parameter +{ + // Check if Open + if(swmm_IsOpenFlag() == FALSE) return(ERR_API_INPUTNOTOPEN); + // Check if object index is within bounds + if (index < 0 || index >= Nobjects[GAGE]) return(ERR_API_OBJECT_INDEX); + + switch(Param) + { + // raintype + case 0: *value = Gage[index].rainType; break; + // rainfall value + case 1: *value = Gage[index].rainfall / UCF(RAINFALL); break; + // control data source + case 2: *value = Gage[index].external_rain; break; + default: return(ERR_API_OUTBOUNDS); + } + return(0); +} + +int DLLEXPORT swmm_setGageParam(int index, int Param, double value) +// +// Input: index = Index of desired ID +// param = Parameter desired (Perhaps define enum ) +// value = value to be output +// Return: API Error +// Purpose: Sets Gage Parameter +{ + // Check if Open + if(swmm_IsOpenFlag() == FALSE) return(ERR_API_INPUTNOTOPEN); + // Check if Simulation is Running + //if(swmm_IsStartedFlag() == TRUE) return(ERR_API_SIM_NRUNNING); + // Start check disabled to change the source before simulation. + // Check if object index is within bounds + if (index < 0 || index >= Nobjects[GAGE]) return(ERR_API_OBJECT_INDEX); + switch(Param) + { + // rainfall from the data + case 0: Gage[index].rainfall = value * UCF(RAINFALL); break; + // control step wise rain + case 1: Gage[index].external_rain = value; break; + // Type not available + default: return(ERR_API_OUTBOUNDS); + } + return(0); +} + //------------------------------- // Setters API @@ -1232,4 +1285,4 @@ int DLLEXPORT swmm_setOutfallStage(int index, double stage) Outfall[k].outfallStage = stage / UCF(LENGTH); } return(errcode); -} \ No newline at end of file +} From fcf6917fd4a2405d8fbbfbc536bbcb51c007c0e2 Mon Sep 17 00:00:00 2001 From: Abhi Date: Wed, 14 Feb 2018 12:26:50 -0500 Subject: [PATCH 02/57] Updated rain API with the suggested changes *NOT TESTED* --- src/enums.h | 3 ++- src/gage.c | 11 +++++++++-- src/objects.h | 2 +- src/runoff.c | 8 +------- src/toolkitAPI.c | 6 +++--- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/enums.h b/src/enums.h index 142ab8be9..40937ac1f 100644 --- a/src/enums.h +++ b/src/enums.h @@ -102,7 +102,8 @@ //------------------------------------- enum GageDataType { RAIN_TSERIES, // rainfall from user-supplied time series - RAIN_FILE}; // rainfall from external file + RAIN_FILE, // rainfall from external file + RAIN_API}; // rainfall from API(Modify rainfall mid simulation) //------------------------------------- // Cross section shape types diff --git a/src/gage.c b/src/gage.c index 14e1af0c5..60a109c61 100644 --- a/src/gage.c +++ b/src/gage.c @@ -266,7 +266,8 @@ void gage_initState(int j) Gage[j].isUsed = FALSE; Gage[j].rainfall = 0.0; Gage[j].reportRainfall = 0.0; - Gage[j].external_rain = 0; // Default uses rainfall from inp file (rainAPI) + // Rainfall API sets external rainfall rate + Gage[j].externalRain = 0.0; if ( IgnoreRainfall ) return; // --- for gage with file data: @@ -546,7 +547,7 @@ int getNextRainfall(int j) else return 0; } - else + else if (Gage[j].dataSource == RAIN_TSERIES) { k = Gage[j].tSeries; if ( k >= 0 ) @@ -557,6 +558,12 @@ int getNextRainfall(int j) } else return 0; } + + else + { + rNext = Gage[j].externalRain; // Rainfall API + } + } while (rNext == 0.0); Gage[j].nextRainfall = rNext; return 1; diff --git a/src/objects.h b/src/objects.h index 54ec12157..98c444148 100644 --- a/src/objects.h +++ b/src/objects.h @@ -100,7 +100,7 @@ typedef struct typedef struct { char* ID; // raingage name - int external_rain; // rainfall input from external data source (rainAPI) + int externalRain; // rainfall-rate injected RAIN API int dataSource; // data from time series or file int tSeries; // rainfall data time series index char fname[MAXFNAME+1]; // name of rainfall data file diff --git a/src/runoff.c b/src/runoff.c index 4e3a9bed5..fb3b70dca 100644 --- a/src/runoff.c +++ b/src/runoff.c @@ -194,13 +194,7 @@ void runoff_execute() IsRaining = FALSE; for (j = 0; j < Nobjects[GAGE]; j++) { - // Check if rain is input though external data source (rainAPI) - if (Gage[j].external_rain == 0) - { - gage_setState(j, currentDate); - } - // TODO Ensure check that nothing else happnes ! - + gage_setState(j, currentDate); if ( Gage[j].rainfall > 0.0 ) IsRaining = TRUE; } diff --git a/src/toolkitAPI.c b/src/toolkitAPI.c index bf2abae46..495d36c15 100644 --- a/src/toolkitAPI.c +++ b/src/toolkitAPI.c @@ -1110,7 +1110,7 @@ int DLLEXPORT swmm_getGageParam(int index, int Param, double *value) // rainfall value case 1: *value = Gage[index].rainfall / UCF(RAINFALL); break; // control data source - case 2: *value = Gage[index].external_rain; break; + case 2: *value = Gage[index].dataSource; break; default: return(ERR_API_OUTBOUNDS); } return(0); @@ -1134,9 +1134,9 @@ int DLLEXPORT swmm_setGageParam(int index, int Param, double value) switch(Param) { // rainfall from the data - case 0: Gage[index].rainfall = value * UCF(RAINFALL); break; + case 0: Gage[index].dataSource = value; break; // control step wise rain - case 1: Gage[index].external_rain = value; break; + case 1: Gage[index].externalRain = value * UCF(RAINFALL); break; // Type not available default: return(ERR_API_OUTBOUNDS); } From 5cbee29d751a046d3b49443acc1877e72d1f5354 Mon Sep 17 00:00:00 2001 From: Abhi Date: Fri, 16 Feb 2018 12:31:19 -0500 Subject: [PATCH 03/57] Updated toolkitAPI functions *NOT FULLY TESTED* --- src/toolkitAPI.c | 64 ++++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/toolkitAPI.c b/src/toolkitAPI.c index 495d36c15..791f67e45 100644 --- a/src/toolkitAPI.c +++ b/src/toolkitAPI.c @@ -1090,57 +1090,57 @@ int DLLEXPORT swmm_getSystemRunoffStats(TRunoffTotals *runoffTot) return(errorcode); } -int DLLEXPORT swmm_getGageParam(int index, int Param, double *value) +int DLLEXPORT swmm_getGagePrecip(int index, double *value) // // Input: index = Index of desired ID -// param = Parameter desired (Perhaps define enum) // Output: value = value to be output // Return: API Error -// Purpose: Gets Gage Parameter +// Purpose: Gets the precipitaion value in the gage. { + int errcode = 0; // Check if Open - if(swmm_IsOpenFlag() == FALSE) return(ERR_API_INPUTNOTOPEN); - // Check if object index is within bounds - if (index < 0 || index >= Nobjects[GAGE]) return(ERR_API_OBJECT_INDEX); - - switch(Param) + if(swmm_IsOpenFlag() == FALSE) { - // raintype - case 0: *value = Gage[index].rainType; break; - // rainfall value - case 1: *value = Gage[index].rainfall / UCF(RAINFALL); break; - // control data source - case 2: *value = Gage[index].dataSource; break; - default: return(ERR_API_OUTBOUNDS); + errcode = ERR_API_INPUTNOTOPEN; } - return(0); + // Check if object index is within bounds + else if (index < 0 || index >= Nobjects[GAGE]) + { + errcode = ERR_API_OBJECT_INDEX; + } + // Read the rainfall value + else + { + *value = Gage[index].rainfall / UCF(RAINFALL); + } + return(errcode); } -int DLLEXPORT swmm_setGageParam(int index, int Param, double value) +int DLLEXPORT swmm_setGagePrecip(int index, double value) // // Input: index = Index of desired ID -// param = Parameter desired (Perhaps define enum ) // value = value to be output // Return: API Error -// Purpose: Sets Gage Parameter +// Purpose: Sets the precipitation in from the external database { + int errcode = 0; // Check if Open - if(swmm_IsOpenFlag() == FALSE) return(ERR_API_INPUTNOTOPEN); - // Check if Simulation is Running - //if(swmm_IsStartedFlag() == TRUE) return(ERR_API_SIM_NRUNNING); - // Start check disabled to change the source before simulation. + if(swmm_IsOpenFlag() == FALSE) + { + errcode = ERR_API_INPUTNOTOPEN; + } // Check if object index is within bounds - if (index < 0 || index >= Nobjects[GAGE]) return(ERR_API_OBJECT_INDEX); - switch(Param) + else if (index < 0 || index >= Nobjects[GAGE]) { - // rainfall from the data - case 0: Gage[index].dataSource = value; break; - // control step wise rain - case 1: Gage[index].externalRain = value * UCF(RAINFALL); break; - // Type not available - default: return(ERR_API_OUTBOUNDS); + errcode = ERR_API_OBJECT_INDEX; } - return(0); + // Read the rainfall value + else + { + Gage[index].dataSource = RAIN_API; + Gage[index].externalRain = value * UCF(RAINFALL); + } + return(errcode); } From a858f5f1b051e4b138f9851bad43af589cec98f0 Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Fri, 23 Feb 2018 14:15:48 -0500 Subject: [PATCH 04/57] Initial commit of swmm unit testing --- CMakeLists.txt | 1 + tests/CMakeLists.txt | 46 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 tests/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index f55c1f8ce..4362575cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required (VERSION 3.0) project(SWMM) +add_subdirectory(tests) set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 000000000..a22bbffd9 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,46 @@ +# +# CMakeLists.txt - CMake configuration file for swmm/tests +# +# Created: February 23, 2018 +# Author: Constantin Savtchenko +# Ref: http://neyasystems.com/an-engineers-guide-to-unit-testing-cmake-and-boost-unit-tests/ +# +# Modified by: Michael E. Tryby +# US EPA ORD/NRMRL +# + +#Setup CMake to run tests +enable_testing() + +if(UNIX) + set(CMAKE_CXX_FLAGS "-std=c++11") +endif(UNIX) + +#Prep ourselves for compiling boost +find_package(Boost COMPONENTS unit_test_framework REQUIRED) +include_directories (${Boost_INCLUDE_DIRS} ../include ../tools/swmm-output/src) + +#I like to keep test files in a separate source directory called test +file(GLOB TEST_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} test_*.cpp) + +#Run through each source +foreach(testSrc ${TEST_SRCS}) + #Extract the filename without an extension (NAME_WE) + get_filename_component(testName ${testSrc} NAME_WE) + + #Add compile target + add_executable(${testName} ${testSrc}) + + #link to Boost libraries AND your targets and dependencies + target_link_libraries(${testName} ${Boost_LIBRARIES} swmm5 swmm-output) + + #I like to move testing binaries into a testBin directory + set_target_properties(${testName} PROPERTIES + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) + + #Finally add it to test execution - + #Notice the WORKING_DIRECTORY and COMMAND + add_test(NAME ${testName} + COMMAND ${CMAKE_BINARY_DIR}/bin/${testName} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data) +endforeach(testSrc) From d7ae3ef565ed6001c26e2576c63ac34b565b7397 Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Fri, 23 Feb 2018 16:32:47 -0500 Subject: [PATCH 05/57] Initial commit of unit test for swmm-output lib --- CMakeLists.txt | 15 +- .../test => tests}/data/Example1.out | Bin tests/test_output.cpp | 320 ++++++++++++++++++ tools/swmm-output/src/swmm_output.c | 6 +- tools/swmm-output/test/data/__init__.py | 14 - tools/swmm-output/test/test_swmm_output.cpp | 258 -------------- 6 files changed, 335 insertions(+), 278 deletions(-) rename {tools/swmm-output/test => tests}/data/Example1.out (100%) create mode 100644 tests/test_output.cpp delete mode 100644 tools/swmm-output/test/data/__init__.py delete mode 100644 tools/swmm-output/test/test_swmm_output.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 4362575cf..0c9b429ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ project(SWMM) add_subdirectory(tests) set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) -set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib) +set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) set(CMAKE_POSITION_INDEPENDENT_CODE ON) if(MSVC) @@ -37,6 +37,11 @@ if(APPLE) set(CMAKE_BUILD_WITH_INSTALL_RPATH ON) endif(APPLE) +# configure file groups +set(SWMM_OUT_SOURCES tools/swmm-output/src/swmm_output.c + tools/swmm-output/src/errormanager.c) +set(SWMM_OUT_HEADER tools/swmm-output/src/swmm_output.h) + # includes and source files file(GLOB_RECURSE SWMM_HEADERS include/*.h src/*.h) file(GLOB SWMM_SOURCES src/*.c) @@ -56,6 +61,10 @@ else(WIN32) target_link_libraries(run-swmm m pthread) endif(WIN32) +# the binary output file API +add_library(swmm-output SHARED ${SWMM_OUT_SOURCES} ${SWMM_OUT_HEADERS}) +#set_target_properties(swmm-output PROPERTIES EXCLUDE_FROM_ALL TRUE) + # install -install(TARGETS run-swmm DESTINATION bin) -install(TARGETS swmm5 DESTINATION lib) \ No newline at end of file +#install(TARGETS run-swmm DESTINATION bin) +#install(TARGETS swmm5 DESTINATION lib) \ No newline at end of file diff --git a/tools/swmm-output/test/data/Example1.out b/tests/data/Example1.out similarity index 100% rename from tools/swmm-output/test/data/Example1.out rename to tests/data/Example1.out diff --git a/tests/test_output.cpp b/tests/test_output.cpp new file mode 100644 index 000000000..f8ac771af --- /dev/null +++ b/tests/test_output.cpp @@ -0,0 +1,320 @@ +/* + * test_output.cpp + * + * Created: 11/2/2017 + * Author: Michael E. Tryby + * US EPA - ORD/NRMRL + * + * Unit testing for SWMM outputapi using Boost Test. + */ + +// NOTE: Travis installs libboost test version 1.5.4 +#define BOOST_TEST_DYN_LINK + +#define BOOST_TEST_MODULE "output" +#include + +#include +#include +#include +#include + +#include "swmm_output.h" + + +// NOTE: Project Home needs to be updated to run unit test +//#define PROJECT_HOME "C:/Users/mtryby/Workspace/GitRepo/michaeltryby/Stormwater-Management-Model" +// NOTE: Reference data for the unit tests is currently tied to SWMM 5.1.7 +#define DATA_PATH "./Example1.out" + +using namespace std; + +// Custom test to check the minimum number of correct decimal digits between +// the test and the ref vectors. +boost::test_tools::predicate_result check_cdd(std::vector& test, + std::vector& ref, long cdd_tol) +{ + float tmp, min_cdd = 100.0; + + // TODO: What is the vectors aren't the same length? + + std::vector::iterator test_it; + std::vector::iterator ref_it; + + for (test_it = test.begin(); test_it < test.end(); ++test_it) { + for (ref_it = ref.begin(); ref_it < ref.end(); ++ref_it) { + + if (*test_it != *ref_it) { + tmp = - log10f(abs(*test_it - *ref_it)); + if (tmp < min_cdd) min_cdd = tmp; + } + } + } + + if (min_cdd == 100.0) + return true; + else + return std::lround(min_cdd) <= cdd_tol; +} + +boost::test_tools::predicate_result check_string(std::string test, std::string ref) +{ + if (ref.compare(test) == 0) + return true; + else + return false; +} + +BOOST_AUTO_TEST_SUITE (test_output_auto) + +BOOST_AUTO_TEST_CASE(InitTest) { + SMO_Handle p_handle = NULL; + + int error = SMO_init(&p_handle); + BOOST_REQUIRE(error == 0); + BOOST_CHECK(p_handle != NULL); +} + +BOOST_AUTO_TEST_CASE(OpenTest) { + std::string path = std::string(DATA_PATH); + SMO_Handle p_handle = NULL; + SMO_init(&p_handle); + + int error = SMO_open(p_handle, path.c_str()); + BOOST_REQUIRE(error == 0); + + SMO_close(&p_handle); +} + +BOOST_AUTO_TEST_CASE(CloseTest) { + SMO_Handle p_handle = NULL; + int error = SMO_init(&p_handle); + + error = SMO_close(&p_handle); + BOOST_REQUIRE(error == -1); + BOOST_CHECK(p_handle != NULL); +} + +BOOST_AUTO_TEST_SUITE_END() + +struct Fixture{ + Fixture() { + std::string path = std::string(DATA_PATH); + + error = SMO_init(&p_handle); + SMO_clearError(p_handle); + error = SMO_open(p_handle, path.c_str()); + } + ~Fixture() { + SMO_free((void**)&array); + error = SMO_close(&p_handle); + } + + std::string path; + int error = 0; + SMO_Handle p_handle = NULL; + + float* array = NULL; + int array_dim = 0; +}; + +BOOST_AUTO_TEST_SUITE(test_output_fixture) + +BOOST_FIXTURE_TEST_CASE(test_getVersion, Fixture) { + int version; + + error = SMO_getVersion(p_handle, &version); + BOOST_REQUIRE(error == 0); + + BOOST_CHECK_EQUAL(51000, version); +} + +BOOST_FIXTURE_TEST_CASE(test_getProjectSize, Fixture) { + int* i_array = NULL; + + error = SMO_getProjectSize(p_handle, &i_array, &array_dim); + BOOST_REQUIRE(error == 0); + + std::vector test; + test.assign(i_array, i_array + array_dim); + // subcatchs, nodes, links, pollutants + std::vector ref({8,14,13,2}); + + BOOST_CHECK_EQUAL_COLLECTIONS(ref.begin(), ref.end(), test.begin(), test.end()); + + SMO_free((void**)&i_array); +} + +BOOST_FIXTURE_TEST_CASE(test_getFlowUnits, Fixture) { + int units = -1; + + error = SMO_getFlowUnits(p_handle, &units); + BOOST_REQUIRE(error == 0); + BOOST_CHECK_EQUAL(0, units); +} + +BOOST_FIXTURE_TEST_CASE(test_getPollutantUnits, Fixture) { + int* i_array = NULL; + + error = SMO_getPollutantUnits(p_handle, &i_array, &array_dim); + BOOST_REQUIRE(error == 0); + + std::vector test; + test.assign(i_array, i_array + array_dim); + std::vector ref({0, 1}); + + BOOST_CHECK_EQUAL_COLLECTIONS(ref.begin(), ref.end(), test.begin(), test.end()); + + SMO_free((void**)&i_array); +} + +BOOST_FIXTURE_TEST_CASE(test_getStartDate, Fixture) { + double date = -1; + + error = SMO_getStartDate(p_handle, &date); + BOOST_REQUIRE(error == 0); + + BOOST_CHECK_EQUAL(35796., date); +} + +BOOST_FIXTURE_TEST_CASE(test_getTimes, Fixture) { + int time = -1; + + error = SMO_getTimes(p_handle, SMO_reportStep, &time); + BOOST_REQUIRE(error == 0); + + BOOST_CHECK_EQUAL(3600, time); + + error = SMO_getTimes(p_handle, SMO_numPeriods, &time); + BOOST_REQUIRE(error == 0); + + BOOST_CHECK_EQUAL(36, time); +} + +BOOST_FIXTURE_TEST_CASE(test_getElementName, Fixture) { + char* c_array = NULL; + int index = 1; + + error = SMO_getElementName(p_handle, SMO_node, index, &c_array, &array_dim); + BOOST_REQUIRE(error == 0); + + std::string test(c_array); + std::string ref("10"); + BOOST_CHECK(check_string(test, ref)); + + SMO_free((void**)&c_array); + +} + +BOOST_FIXTURE_TEST_CASE(test_getSubcatchSeries, Fixture) { + + error = SMO_getSubcatchSeries(p_handle, 1, SMO_runoff_rate, 0, 10, &array, &array_dim); + BOOST_REQUIRE(error == 0); + + std::vector ref_vec({0.0, + 1.2438242, + 2.5639679, + 4.524055, + 2.5115132, + 0.69808137, + 0.040894926, + 0.011605669, + 0.00509294, + 0.0027438672, + 10.0}); + + + std::vector test_vec; + test_vec.assign(array, array + array_dim); + + BOOST_CHECK(check_cdd(test_vec, ref_vec, 3)); +} + +BOOST_FIXTURE_TEST_CASE(test_getSubcatchResult, Fixture) { + + error = SMO_getSubcatchResult(p_handle, 1, 1, &array, &array_dim); + BOOST_REQUIRE(error == 0); + + std::vector ref_vec({0.5, + 0.0, + 0.0, + 0.125, + 1.2438242, + 0.0, + 0.0, + 0.0, + 33.481991, + 6.6963983}); + + std::vector test_vec; + test_vec.assign(array, array + array_dim); + + BOOST_CHECK(check_cdd(test_vec, ref_vec, 3)); +} + +BOOST_FIXTURE_TEST_CASE(test_getNodeResult, Fixture) { + + error = SMO_getNodeResult(p_handle, 2, 2, &array, &array_dim); + BOOST_REQUIRE(error == 0); + + std::vector ref_vec({0.296234, + 995.296204, + 0.0, + 1.302650, + 1.302650, + 0.0, + 15.361463, + 3.072293}); + + std::vector test_vec; + test_vec.assign(array, array + array_dim); + + BOOST_CHECK(check_cdd(test_vec, ref_vec, 3)); +} + +BOOST_FIXTURE_TEST_CASE(test_getLinkResult, Fixture) { + + error = SMO_getLinkResult(p_handle, 3, 3, &array, &array_dim); + BOOST_REQUIRE(error == 0); + + std::vector ref_vec({4.631762, + 1.0, + 5.8973422, + 314.15927, + 1.0, + 19.070757, + 3.8141515}); + + std::vector test_vec; + test_vec.assign(array, array + array_dim); + + BOOST_CHECK(check_cdd(test_vec, ref_vec, 3)); +} + +BOOST_FIXTURE_TEST_CASE(test_getSystemResult, Fixture) { + + error = SMO_getSystemResult(p_handle, 4, 4, &array, &array_dim); + BOOST_REQUIRE(error == 0); + + std::vector ref_vec({70.0, + 0.1, + 0.0, + 0.19042271, + 14.172027, + 0.0, + 0.0, + 0.0, + 0.0, + 14.172027, + 0.55517411, + 13.622702, + 2913.0793, + 0.0}); + + std::vector test_vec; + test_vec.assign(array, array + array_dim); + + BOOST_CHECK(check_cdd(test_vec, ref_vec, 3)); +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/tools/swmm-output/src/swmm_output.c b/tools/swmm-output/src/swmm_output.c index 40b6f6ca1..fb7e4eb12 100644 --- a/tools/swmm-output/src/swmm_output.c +++ b/tools/swmm-output/src/swmm_output.c @@ -1073,7 +1073,7 @@ int _fopen(FILE **f, const char *name, const char *mode) { // Note: fopen_s is part of C++11 standard // int ret = 0; -#ifdef _WIN32 +#ifdef _MSC_VER ret = (int)fopen_s(f, name, mode); #else *f = fopen(name, mode); @@ -1088,7 +1088,7 @@ int _fseek(FILE* stream, F_OFF offset, int whence) // Purpose: Selects platform fseek() for large file support // { -#ifdef _WIN32 +#ifdef _MSC_VER #define FSEEK64 _fseeki64 #else #define FSEEK64 fseeko @@ -1102,7 +1102,7 @@ F_OFF _ftell(FILE* stream) // Purpose: Selects platform ftell() for large file support // { -#ifdef _WIN32 +#ifdef _MSC_VER #define FTELL64 _ftelli64 #else #define FTELL64 ftello diff --git a/tools/swmm-output/test/data/__init__.py b/tools/swmm-output/test/data/__init__.py deleted file mode 100644 index 3cede7346..000000000 --- a/tools/swmm-output/test/data/__init__.py +++ /dev/null @@ -1,14 +0,0 @@ -# -*- coding: utf-8 -*- - -# __init__.py -# -# Created: 11/8/2017 -# Author: Michael E. Tryby -# US EPA - ORD/NRMRL -# - -import os - -DATA_PATH = os.path.abspath(os.path.dirname(__file__)) - -OUTPUT_FILE_EXAMPLE1 = os.path.join(DATA_PATH, 'Example1.out') diff --git a/tools/swmm-output/test/test_swmm_output.cpp b/tools/swmm-output/test/test_swmm_output.cpp deleted file mode 100644 index 09ac65278..000000000 --- a/tools/swmm-output/test/test_swmm_output.cpp +++ /dev/null @@ -1,258 +0,0 @@ -/* - * test_swmm_output.cpp - * - * Created: 11/2/2017 - * Author: Michael E. Tryby - * US EPA - ORD/NRMRL - * - * Unit testing for SWMM outputapi using Google Test. - */ - -#include -#include -#include -#include "gtest/gtest.h" -#include "../src/swmm_output.h" - - -// NOTE: Project Home needs to be updated to run unit test -#define PROJECT_HOME "C:/Users/mtryby/Workspace/GitRepo/michaeltryby/Stormwater-Management-Model" -// NOTE: Reference data for the unit tests is currently tied to SWMM 5.1.7 -#define DATA_PATH "/tools/swmm-output/test/data/Example1.out" - -namespace { - -TEST(SMO_init, InitTest) { - SMO_Handle p_handle = NULL; - - int error = SMO_init(&p_handle); - ASSERT_EQ(0, error); - ASSERT_TRUE(p_handle != NULL); -} - -TEST(SMO_open, OpenTest) { - std::string path = std::string(PROJECT_HOME) + std::string(DATA_PATH); - SMO_Handle p_handle = NULL; - SMO_init(&p_handle); - - int error = SMO_open(p_handle, path.c_str()); - ASSERT_EQ(0, error); - SMO_close(&p_handle); -} - -class SWMM_OutputFixture : public testing::Test { -protected: - // SetUp for OutputapiTest fixture - virtual void SetUp() { - std::string path = std::string(PROJECT_HOME) + std::string(DATA_PATH); - - error = SMO_init(&p_handle); - SMO_clearError(p_handle); - error = SMO_open(p_handle, path.c_str()); - } - - // TearDown for OutputapiTest fixture - virtual void TearDown() { - SMO_free((void**)&array); - error = SMO_close(&p_handle); - } - - int error = 0; - SMO_Handle p_handle = NULL; - - float* array = NULL; - int array_dim = 0; -}; - -TEST_F(SWMM_OutputFixture, getVersionTest) { - int version; - - error = SMO_getVersion(p_handle, &version); - ASSERT_EQ(0, error); - - EXPECT_EQ(51000, version); -} - -TEST_F(SWMM_OutputFixture, getProjectSizeTest) { - int* i_array = NULL; - // subcatchs, nodes, links, pollutants - int ref_array[4] = {8,14,13,2}; - - error = SMO_getProjectSize(p_handle, &i_array, &array_dim); - ASSERT_EQ(0, error); - - EXPECT_EQ(4, array_dim); - for (int i = 0; i < array_dim; i++) - EXPECT_EQ(ref_array[i], i_array[i]); - - SMO_free((void**)&i_array); -} - -TEST_F(SWMM_OutputFixture, getFlowUnitsTest) { - int units = -1; - - error = SMO_getFlowUnits(p_handle, &units); - ASSERT_EQ(0, error); - EXPECT_EQ(0, units); -} - -TEST_F(SWMM_OutputFixture, getPollutantUnitsTest) { - int* i_array = NULL; - int ref_array[2] = {0, 1}; - - error = SMO_getPollutantUnits(p_handle, &i_array, &array_dim); - ASSERT_EQ(0, error); - - EXPECT_EQ(2, array_dim); - for (int i = 0; i < array_dim; i++) - EXPECT_EQ(ref_array[i], i_array[i]); - - SMO_free((void**)&i_array); -} - -TEST_F(SWMM_OutputFixture, getStartDateTest) { - double date = -1; - - error = SMO_getStartDate(p_handle, &date); - ASSERT_EQ(0, error); - - EXPECT_EQ(35796., date); -} - -TEST_F(SWMM_OutputFixture, getTimesTest) { - int time = -1; - - error = SMO_getTimes(p_handle, SMO_reportStep, &time); - ASSERT_EQ(0, error); - - EXPECT_EQ(3600, time); - - error = SMO_getTimes(p_handle, SMO_numPeriods, &time); - ASSERT_EQ(0, error); - - EXPECT_EQ(36, time); -} - -TEST_F(SWMM_OutputFixture, getElementNameTest) { - char* c_array = NULL; - int index = 1; - - error = SMO_getElementName(p_handle, SMO_node, index, &c_array, &array_dim); - ASSERT_EQ(0, error); - - EXPECT_STREQ("10", c_array); - EXPECT_EQ(2, array_dim); - - SMO_free((void**)&c_array); - -} - -//TEST_F(OutputapiTest, getSubcatchSeriesTest) { -// float ref_array[11] = {0.0, -// 1.2438242, -// 2.5639679, -// 4.524055, -// 2.5115132, -// 0.69808137, -// 0.040894926, -// 0.011605669, -// 0.00509294, -// 0.0027438672, -// 10}; -// -// error = SMO_getSubcatchSeries(p_handle, 1, runoff_rate, 0, 10, &array, &array_dim); -// ASSERT_EQ(0, error); -// -// EXPECT_EQ(11, array_dim); -// for (int i = 0; i < array_dim; i++) -// EXPECT_FLOAT_EQ(ref_array[i], array[i]); -//} - -TEST_F(SWMM_OutputFixture, getSubcatchResultTest) { - float ref_array[10] = {0.5, - 0.0, - 0.0, - 0.125, - 1.2438242, - 0.0, - 0.0, - 0.0, - 33.481991, - 6.6963983}; - - error = SMO_getSubcatchResult(p_handle, 1, 1, &array, &array_dim); - ASSERT_EQ(0, error); - - EXPECT_EQ(10, array_dim); - for (int i = 0; i < array_dim; i++) - EXPECT_FLOAT_EQ(ref_array[i], array[i]); -} - -TEST_F(SWMM_OutputFixture, getNodeResultTest) { - float ref_array[8] = {0.296234, - 995.296204, - 0.0, - 1.302650, - 1.302650, - 0.0, - 15.361463, - 3.072293}; - - error = SMO_getNodeResult(p_handle, 2, 2, &array, &array_dim); - ASSERT_EQ(0, error); - - EXPECT_EQ(8, array_dim); - for (int i = 0; i < array_dim; i++) - EXPECT_FLOAT_EQ(ref_array[i], array[i]); -} - -TEST_F(SWMM_OutputFixture, getLinkResultTest) { - float ref_array[7] = {4.631762, - 1.0, - 5.8973422, - 314.15927, - 1.0, - 19.070757, - 3.8141515}; - - error = SMO_getLinkResult(p_handle, 3, 3, &array, &array_dim); - ASSERT_EQ(0, error); - - EXPECT_EQ(7, array_dim); - for (int i = 0; i < array_dim; i++) - EXPECT_FLOAT_EQ(ref_array[i], array[i]); -} - -TEST_F(SWMM_OutputFixture, getSystemResultTest) { - float ref_array[14] = {70.0, - 0.1, - 0.0, - 0.19042271, - 14.172027, - 0.0, - 0.0, - 0.0, - 0.0, - 14.172027, - 0.55517411, - 13.622702, - 2913.0793, - 0.0}; - - error = SMO_getSystemResult(p_handle, 4, 4, &array, &array_dim); - ASSERT_EQ(0, error); - - EXPECT_EQ(14, array_dim); - for (int i = 0; i < array_dim; i++) - EXPECT_FLOAT_EQ(ref_array[i], array[i]); -} -} - - -int main(int argc, char **argv) { - SWMM_OutputFixture::SetUpTestCase(); - printf("Running main() from gtest_main.cc\n"); - testing::InitGoogleTest(&argc, argv); - - return RUN_ALL_TESTS(); -} From 4db1285e280ae905f6b9d7ab34e29ed4a4edc159 Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Fri, 23 Feb 2018 17:10:03 -0500 Subject: [PATCH 06/57] Adding libboost to travis build --- .travis.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4b350d657..36342e024 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ env: before_install: - sudo apt-get -qq update + - sudo apt-get install -y libboost-test-dev - sudo apt-get install -y swig install: @@ -19,7 +20,11 @@ before_script: - cmake .. script: - - make + - cmake --build . + # run unit tests + - cd tests + - ctest + # run regression tests - cd $SWMM_HOME - tools/gen-config.sh $SWMM_HOME/$BUILD_HOME/bin > $TEST_HOME/apps/swmm-$TRAVIS_COMMIT.json - tools/run-nrtest.sh $TEST_HOME $TRAVIS_COMMIT From a6ffa5431483bbe7cd3630d54c76e792c32e1592 Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Fri, 23 Feb 2018 17:42:23 -0500 Subject: [PATCH 07/57] Debugging travis build --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c9b429ed..fbdc0274f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ if(MSVC) endif(MSVC) if(UNIX) - set(CMAKE_C_FLAGS "-std=c99 -fopenmp") + set(CMAKE_C_FLAGS "-fopenmp") set(CMAKE_CXX_FLAGS "-std=c++11 -fopenmp -Wno-write-strings") # add_definitions(-std=c99) endif(UNIX) From b7a846b6e2638e3d2d4c982f5da253c91e14a4ec Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Fri, 23 Feb 2018 18:12:00 -0500 Subject: [PATCH 08/57] Debugging appveyor build --- appveyor.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 7bd173adf..6cc4ac637 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -18,10 +18,14 @@ environment: VS_VERSION: "10 2010" ARCH: Win32 GROUP: "SUPPORTED" + BOOST_ROOT: C:/Libraries/boost_1_58_0 + BOOST_LIBDIR: C:/Libraries/boost_1_58_0/lib32-msvc-10.0 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 VS_VERSION: "10 2010" ARCH: Win64 GROUP: "EXPERIMENTAL" + BOOST_ROOT: C:/Libraries/boost_1_58_0 + BOOST_LIBDIR: C:/Libraries/boost_1_58_0/lib64-msvc-10.0 # Python 3.5 and 3.6 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 VS_VERSION: "14 2015" From 75464bc44e944472a8270971b83a719fa2395de2 Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Fri, 23 Feb 2018 18:17:54 -0500 Subject: [PATCH 09/57] Debugging appveyor build --- appveyor.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 6cc4ac637..d7f75605b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -85,7 +85,11 @@ install: - python -m pip install --src %BUILD_HOME%\packages -r tools\requirements.txt before_build: - - cmake -G %GENERATOR% -DCMAKE_INSTALL_PREFIX:PATH=%BUILD_HOME% -DCMAKE_BUILD_TYPE:STRING=Release + - cmake -G %GENERATOR% + -DBOOST_ROOT=%BOOST_ROOT% + -DBOOST_LIBDIR=%BOOST_LIBDIR% + -DCMAKE_INSTALL_PREFIX:PATH=%BUILD_HOME% + -DCMAKE_BUILD_TYPE:STRING=Release build_script: - cmake --build . --target run-swmm --config Release From ba716c2a799ee3b6bd6b7361cbb9e9583b83f96a Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Fri, 23 Feb 2018 18:27:51 -0500 Subject: [PATCH 10/57] Debugging appveyor build --- appveyor.yml | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index d7f75605b..06ba27fe9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -18,32 +18,32 @@ environment: VS_VERSION: "10 2010" ARCH: Win32 GROUP: "SUPPORTED" - BOOST_ROOT: C:/Libraries/boost_1_58_0 - BOOST_LIBDIR: C:/Libraries/boost_1_58_0/lib32-msvc-10.0 - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 - VS_VERSION: "10 2010" - ARCH: Win64 - GROUP: "EXPERIMENTAL" - BOOST_ROOT: C:/Libraries/boost_1_58_0 - BOOST_LIBDIR: C:/Libraries/boost_1_58_0/lib64-msvc-10.0 + BOOST_ROOT: C:/Libraries/boost + # BOOST_LIBDIR: C:/Libraries/boost/lib32-msvc-12.0 + #- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 + # VS_VERSION: "10 2010" + # ARCH: Win64 + # GROUP: "EXPERIMENTAL" + # BOOST_ROOT: C:/Libraries/boost_1_58_0 + # BOOST_LIBDIR: C:/Libraries/boost_1_58_0/lib64-msvc-10.0 # Python 3.5 and 3.6 - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - VS_VERSION: "14 2015" - ARCH: Win32 - GROUP: "EXPERIMENTAL" - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - VS_VERSION: "14 2015" - ARCH: Win64 - GROUP: "EXPERIMENTAL" + #- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + # VS_VERSION: "14 2015" + # ARCH: Win32 + # GROUP: "EXPERIMENTAL" + #- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + # VS_VERSION: "14 2015" + # ARCH: Win64 + # GROUP: "EXPERIMENTAL" # Python 2.7 - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 - VS_VERSION: "9 2008" - ARCH: Win32 - GROUP: "EXPERIMENTAL" - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 - VS_VERSION: "9 2008" - ARCH: Win64 - GROUP: "EXPERIMENTAL" + #- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 + # VS_VERSION: "9 2008" + # ARCH: Win32 + # GROUP: "EXPERIMENTAL" + #- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 + # VS_VERSION: "9 2008" + # ARCH: Win64 + # GROUP: "EXPERIMENTAL" # Not used as a python compiler #- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 # VS_VERSION: "12 2013" From e49ccebcdda557b3b908f80776b88431a6c4183b Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Fri, 23 Feb 2018 18:31:14 -0500 Subject: [PATCH 11/57] Debugging appveyor build --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 06ba27fe9..842d382be 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -19,7 +19,7 @@ environment: ARCH: Win32 GROUP: "SUPPORTED" BOOST_ROOT: C:/Libraries/boost - # BOOST_LIBDIR: C:/Libraries/boost/lib32-msvc-12.0 + BOOST_LIBDIR: C:/Libraries/boost/lib32-msvc-12.0 #- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 # VS_VERSION: "10 2010" # ARCH: Win64 @@ -87,7 +87,7 @@ install: before_build: - cmake -G %GENERATOR% -DBOOST_ROOT=%BOOST_ROOT% - -DBOOST_LIBDIR=%BOOST_LIBDIR% + -DBOOST_LIBRARYDIR=%BOOST_LIBDIR% -DCMAKE_INSTALL_PREFIX:PATH=%BUILD_HOME% -DCMAKE_BUILD_TYPE:STRING=Release From 09cebb6432d220c72b66a95723f5efeea1b7f51f Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Fri, 23 Feb 2018 18:42:40 -0500 Subject: [PATCH 12/57] Debugging appveyor build --- appveyor.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 842d382be..af9b80fc0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -19,7 +19,7 @@ environment: ARCH: Win32 GROUP: "SUPPORTED" BOOST_ROOT: C:/Libraries/boost - BOOST_LIBDIR: C:/Libraries/boost/lib32-msvc-12.0 + BOOST_LIB: C:/Libraries/boost/lib32-msvc-12.0 #- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 # VS_VERSION: "10 2010" # ARCH: Win64 @@ -74,7 +74,8 @@ init: - echo %APPVEYOR_BUILD_WORKER_IMAGE% - echo %ARCH% - echo %GENERATOR% - + - echo %BOOST_ROOT% + - echo %BOOST_LIB% install: # Install SWIG using chocolatey - choco install swig @@ -87,7 +88,7 @@ install: before_build: - cmake -G %GENERATOR% -DBOOST_ROOT=%BOOST_ROOT% - -DBOOST_LIBRARYDIR=%BOOST_LIBDIR% + -DBOOST_LIBRARYDIR=%BOOST_LIB% -DCMAKE_INSTALL_PREFIX:PATH=%BUILD_HOME% -DCMAKE_BUILD_TYPE:STRING=Release From 414e50d8f756cad7e96a445759f77a5a4110d925 Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Fri, 23 Feb 2018 18:46:23 -0500 Subject: [PATCH 13/57] Debugging appveyor build --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index af9b80fc0..3e53e36a3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -18,8 +18,8 @@ environment: VS_VERSION: "10 2010" ARCH: Win32 GROUP: "SUPPORTED" - BOOST_ROOT: C:/Libraries/boost - BOOST_LIB: C:/Libraries/boost/lib32-msvc-12.0 + BOOST_ROOT: C:\Libraries\boost + BOOST_LIB: C:\Libraries\boost\lib32-msvc-12.0 #- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 # VS_VERSION: "10 2010" # ARCH: Win64 From 52f32b2263a7ec405adaa4b8078d578531d9e6cd Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Fri, 23 Feb 2018 18:53:03 -0500 Subject: [PATCH 14/57] Debugging appveyor build --- appveyor.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 3e53e36a3..00c449f85 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -18,8 +18,8 @@ environment: VS_VERSION: "10 2010" ARCH: Win32 GROUP: "SUPPORTED" - BOOST_ROOT: C:\Libraries\boost - BOOST_LIB: C:\Libraries\boost\lib32-msvc-12.0 + BOOST_ROOT: "C:\\Libraries\\boost" + BOOST_LIB: "C:\\Libraries\\boost\\lib32-msvc-12.0" #- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 # VS_VERSION: "10 2010" # ARCH: Win64 @@ -87,8 +87,8 @@ install: before_build: - cmake -G %GENERATOR% - -DBOOST_ROOT=%BOOST_ROOT% - -DBOOST_LIBRARYDIR=%BOOST_LIB% + -DBOOST_ROOT="%BOOST_ROOT%" + -DBOOST_LIBRARYDIR="%BOOST_LIB%" -DCMAKE_INSTALL_PREFIX:PATH=%BUILD_HOME% -DCMAKE_BUILD_TYPE:STRING=Release From 05c5c718f16d811a40e6e4e0c005834400df4dae Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Sat, 24 Feb 2018 11:44:04 -0500 Subject: [PATCH 15/57] Trying to find boost on Appveyor build --- tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a22bbffd9..b5d0b4bbf 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -17,7 +17,7 @@ if(UNIX) endif(UNIX) #Prep ourselves for compiling boost -find_package(Boost COMPONENTS unit_test_framework REQUIRED) +find_package(Boost REQUIRED) include_directories (${Boost_INCLUDE_DIRS} ../include ../tools/swmm-output/src) #I like to keep test files in a separate source directory called test From c03a2499da64ce547fb6cf9da6ce27c5797dd57e Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Sat, 24 Feb 2018 11:49:01 -0500 Subject: [PATCH 16/57] Changing so that all targets get built. --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 00c449f85..0464f6b45 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -93,7 +93,7 @@ before_build: -DCMAKE_BUILD_TYPE:STRING=Release build_script: - - cmake --build . --target run-swmm --config Release + - cmake --build . --config Release before_test: - cd %SWMM_HOME% From 56a14c1b590d5d337694b5ab3e1e33b981f8db70 Mon Sep 17 00:00:00 2001 From: Abhi Date: Sun, 25 Feb 2018 13:14:49 -0500 Subject: [PATCH 17/57] Updated implementation to work with rain_api flag --- src/gage.c | 101 +++++++++++++++++++++++++++------------------------- src/swmm5.c | 2 +- 2 files changed, 54 insertions(+), 49 deletions(-) diff --git a/src/gage.c b/src/gage.c index 60a109c61..692753a3c 100644 --- a/src/gage.c +++ b/src/gage.c @@ -271,7 +271,7 @@ void gage_initState(int j) if ( IgnoreRainfall ) return; // --- for gage with file data: - if ( Gage[j].dataSource == RAIN_FILE ) + if ( Gage[j].dataSource == RAIN_FILE || Gage[j].dataSource == RAIN_API ) { // --- set current file position to start of period of record Gage[j].currentFilePos = Gage[j].startFilePos; @@ -335,50 +335,59 @@ void gage_setState(int j, DateTime t) return; } - // --- otherwise march through rainfall record until date t is bracketed - t += OneSecond; - for (;;) + if (Gage[j].dataSource == RAIN_API) { - // --- no rainfall if no interval start date - if ( Gage[j].startDate == NO_DATE ) - { - Gage[j].rainfall = 0.0; - return; - } - - // --- no rainfall if time is before interval start date - if ( t < Gage[j].startDate ) - { - Gage[j].rainfall = 0.0; - return; - } - - // --- use current rainfall if time is before interval end date - if ( t < Gage[j].endDate ) - { - return; - } - - // --- no rainfall if t >= interval end date & no next interval exists - if ( Gage[j].nextDate == NO_DATE ) - { - Gage[j].rainfall = 0.0; - return; - } - - // --- no rainfall if t > interval end date & < next interval date - if ( t < Gage[j].nextDate ) - { - Gage[j].rainfall = 0.0; - return; - } - - // --- otherwise update next rainfall interval date - Gage[j].startDate = Gage[j].nextDate; - Gage[j].endDate = datetime_addSeconds(Gage[j].startDate, - Gage[j].rainInterval); - Gage[j].rainfall = Gage[j].nextRainfall; - if ( !getNextRainfall(j) ) Gage[j].nextDate = NO_DATE; + Gage[j].rainfall = Gage[j].externalRain; + return; + } + else + { + // --- otherwise march through rainfall record until date t is bracketed + t += OneSecond; + for (;;) + { + // --- no rainfall if no interval start date + if ( Gage[j].startDate == NO_DATE ) + { + Gage[j].rainfall = 0.0; + return; + } + + // --- no rainfall if time is before interval start date + if ( t < Gage[j].startDate ) + { + Gage[j].rainfall = 0.0; + return; + } + + // --- use current rainfall if time is before interval end date + if ( t < Gage[j].endDate ) + { + return; + } + + // --- no rainfall if t >= interval end date & no next interval exists + if ( Gage[j].nextDate == NO_DATE) + { + Gage[j].rainfall = 0.0; + return; + } + + // --- no rainfall if t > interval end date & < next interval date + if ( t < Gage[j].nextDate ) + { + Gage[j].rainfall = 0.0; + return; + } + + // --- otherwise update next rainfall interval date + Gage[j].startDate = Gage[j].nextDate; + Gage[j].endDate = datetime_addSeconds(Gage[j].startDate, + Gage[j].rainInterval); + Gage[j].rainfall = Gage[j].nextRainfall; + + if ( !getNextRainfall(j) ) Gage[j].nextDate = NO_DATE; + } } } @@ -559,10 +568,6 @@ int getNextRainfall(int j) else return 0; } - else - { - rNext = Gage[j].externalRain; // Rainfall API - } } while (rNext == 0.0); Gage[j].nextRainfall = rNext; diff --git a/src/swmm5.c b/src/swmm5.c index b050beddd..3cb75d461 100644 --- a/src/swmm5.c +++ b/src/swmm5.c @@ -1062,4 +1062,4 @@ void getSemVersion(char* semver) SEMVERSION_MAJOR, SEMVERSION_MINOR, SEMVERSION_PATCH); } -//============================================================================= \ No newline at end of file +//============================================================================= From 5bfe54de96a926eb2b71aa7c3d6ce4289c3f376b Mon Sep 17 00:00:00 2001 From: Abhi Date: Sun, 25 Feb 2018 14:02:32 -0500 Subject: [PATCH 18/57] Updated with line correction --- src/swmm5.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/swmm5.c b/src/swmm5.c index 3cb75d461..2b3b2b41d 100644 --- a/src/swmm5.c +++ b/src/swmm5.c @@ -1061,5 +1061,4 @@ void getSemVersion(char* semver) snprintf(semver, SEMVERSION_LEN, "%s.%s.%s", SEMVERSION_MAJOR, SEMVERSION_MINOR, SEMVERSION_PATCH); } - //============================================================================= From 79d567e02f7f3c357a15f370154945a56e0e250a Mon Sep 17 00:00:00 2001 From: Abhi Date: Sun, 25 Feb 2018 14:08:29 -0500 Subject: [PATCH 19/57] Updated with APIFLAG --- src/gage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gage.c b/src/gage.c index 692753a3c..694c01955 100644 --- a/src/gage.c +++ b/src/gage.c @@ -271,7 +271,7 @@ void gage_initState(int j) if ( IgnoreRainfall ) return; // --- for gage with file data: - if ( Gage[j].dataSource == RAIN_FILE || Gage[j].dataSource == RAIN_API ) + if ( Gage[j].dataSource == RAIN_FILE) { // --- set current file position to start of period of record Gage[j].currentFilePos = Gage[j].startFilePos; From ef0957164c564d0dfd410e9ca290aae00b5e5b07 Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Mon, 26 Feb 2018 14:09:12 -0500 Subject: [PATCH 20/57] Changing boost use static lib --- appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.yml b/appveyor.yml index 0464f6b45..d523f9d1b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -89,6 +89,7 @@ before_build: - cmake -G %GENERATOR% -DBOOST_ROOT="%BOOST_ROOT%" -DBOOST_LIBRARYDIR="%BOOST_LIB%" + -DBoost_USE_STATIC_LIBS="ON" -DCMAKE_INSTALL_PREFIX:PATH=%BUILD_HOME% -DCMAKE_BUILD_TYPE:STRING=Release From b949d77ab312ec3ed4cfd78407b6432badc54b13 Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Mon, 26 Feb 2018 14:46:41 -0500 Subject: [PATCH 21/57] Refactoring Fixture do to compilation issues on MSVC --- tests/test_output.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/test_output.cpp b/tests/test_output.cpp index f8ac771af..58d50ee0d 100644 --- a/tests/test_output.cpp +++ b/tests/test_output.cpp @@ -104,6 +104,9 @@ struct Fixture{ error = SMO_init(&p_handle); SMO_clearError(p_handle); error = SMO_open(p_handle, path.c_str()); + + array = NULL; + array_dim = 0; } ~Fixture() { SMO_free((void**)&array); @@ -111,11 +114,11 @@ struct Fixture{ } std::string path; - int error = 0; - SMO_Handle p_handle = NULL; + int error; + SMO_Handle p_handle; - float* array = NULL; - int array_dim = 0; + float* array; + int array_dim; }; BOOST_AUTO_TEST_SUITE(test_output_fixture) From 8c2325db1bbad86ef9b18462e6bda19b3dd31cf1 Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Mon, 26 Feb 2018 15:22:35 -0500 Subject: [PATCH 22/57] Refactoring Fixture do to compilation issues on MSVC --- tests/test_output.cpp | 57 +++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/tests/test_output.cpp b/tests/test_output.cpp index 58d50ee0d..918d51a66 100644 --- a/tests/test_output.cpp +++ b/tests/test_output.cpp @@ -214,17 +214,19 @@ BOOST_FIXTURE_TEST_CASE(test_getSubcatchSeries, Fixture) { error = SMO_getSubcatchSeries(p_handle, 1, SMO_runoff_rate, 0, 10, &array, &array_dim); BOOST_REQUIRE(error == 0); - std::vector ref_vec({0.0, - 1.2438242, - 2.5639679, - 4.524055, - 2.5115132, - 0.69808137, - 0.040894926, - 0.011605669, - 0.00509294, - 0.0027438672, - 10.0}); + int ref_dim = 10; + float ref_array[ref_dim] = {0.0, + 1.2438242, + 2.5639679, + 4.524055, + 2.5115132, + 0.69808137, + 0.040894926, + 0.011605669, + 0.00509294, + 0.0027438672}; + std::vector ref_vec; + ref_vec.assign(ref_array, ref_array + ref_dim); std::vector test_vec; @@ -237,8 +239,9 @@ BOOST_FIXTURE_TEST_CASE(test_getSubcatchResult, Fixture) { error = SMO_getSubcatchResult(p_handle, 1, 1, &array, &array_dim); BOOST_REQUIRE(error == 0); - - std::vector ref_vec({0.5, + + int ref_dim = 10; + float ref_array[ref_dim] = {0.5, 0.0, 0.0, 0.125, @@ -247,7 +250,9 @@ BOOST_FIXTURE_TEST_CASE(test_getSubcatchResult, Fixture) { 0.0, 0.0, 33.481991, - 6.6963983}); + 6.6963983}; + std::vector ref_vec; + ref_vec.assign(ref_array, ref_array + ref_dim); std::vector test_vec; test_vec.assign(array, array + array_dim); @@ -260,14 +265,17 @@ BOOST_FIXTURE_TEST_CASE(test_getNodeResult, Fixture) { error = SMO_getNodeResult(p_handle, 2, 2, &array, &array_dim); BOOST_REQUIRE(error == 0); - std::vector ref_vec({0.296234, + int ref_dim = 8; + float ref_array[ref_dim] = {0.296234, 995.296204, 0.0, 1.302650, 1.302650, 0.0, 15.361463, - 3.072293}); + 3.072293}; + std::vector ref_vec; + ref_vec.assign(ref_array, ref_array + ref_dim); std::vector test_vec; test_vec.assign(array, array + array_dim); @@ -276,17 +284,21 @@ BOOST_FIXTURE_TEST_CASE(test_getNodeResult, Fixture) { } BOOST_FIXTURE_TEST_CASE(test_getLinkResult, Fixture) { - + error = SMO_getLinkResult(p_handle, 3, 3, &array, &array_dim); BOOST_REQUIRE(error == 0); - std::vector ref_vec({4.631762, + + int ref_dim = 7; + float ref_array[ref_dim] = {4.631762, 1.0, 5.8973422, 314.15927, 1.0, 19.070757, - 3.8141515}); + 3.8141515}; + std::vector ref_vec; + ref_vec.assign(ref_array, ref_array + ref_dim); std::vector test_vec; test_vec.assign(array, array + array_dim); @@ -299,7 +311,8 @@ BOOST_FIXTURE_TEST_CASE(test_getSystemResult, Fixture) { error = SMO_getSystemResult(p_handle, 4, 4, &array, &array_dim); BOOST_REQUIRE(error == 0); - std::vector ref_vec({70.0, + int ref_dim = 7; + float ref_array[ref_dim] = {70.0, 0.1, 0.0, 0.19042271, @@ -312,7 +325,9 @@ BOOST_FIXTURE_TEST_CASE(test_getSystemResult, Fixture) { 0.55517411, 13.622702, 2913.0793, - 0.0}); + 0.0}; + std::vector ref_vec; + ref_vec.assign(ref_array, ref_array + ref_dim); std::vector test_vec; test_vec.assign(array, array + array_dim); From e0af30bce99e039bc605f799bcd35dfab7ac916d Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Mon, 26 Feb 2018 15:32:09 -0500 Subject: [PATCH 23/57] Refactoring vector initialization do to compilation issues on MSVC --- tests/test_output.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/test_output.cpp b/tests/test_output.cpp index 918d51a66..c555e23ec 100644 --- a/tests/test_output.cpp +++ b/tests/test_output.cpp @@ -140,9 +140,14 @@ BOOST_FIXTURE_TEST_CASE(test_getProjectSize, Fixture) { std::vector test; test.assign(i_array, i_array + array_dim); + // subcatchs, nodes, links, pollutants - std::vector ref({8,14,13,2}); - + int ref_dim = 4; + int ref_array[ref_dim] = {8,14,13,2}; + + std::vector ref; + ref.assign(ref_array, ref_array + ref_dim); + BOOST_CHECK_EQUAL_COLLECTIONS(ref.begin(), ref.end(), test.begin(), test.end()); SMO_free((void**)&i_array); @@ -164,7 +169,12 @@ BOOST_FIXTURE_TEST_CASE(test_getPollutantUnits, Fixture) { std::vector test; test.assign(i_array, i_array + array_dim); - std::vector ref({0, 1}); + + int ref_dim = 2; + int ref_array[ref_dim] = {0, 1}; + + std::vector ref; + ref.assign(ref_array, ref_array + ref_dim); BOOST_CHECK_EQUAL_COLLECTIONS(ref.begin(), ref.end(), test.begin(), test.end()); From 0c1929bfac1609455c379791ed298a9f0bcb3e31 Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Mon, 26 Feb 2018 15:47:46 -0500 Subject: [PATCH 24/57] Refactoring vector initialization do to compilation issues on MSVC --- tests/test_output.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/test_output.cpp b/tests/test_output.cpp index c555e23ec..fe7542826 100644 --- a/tests/test_output.cpp +++ b/tests/test_output.cpp @@ -142,7 +142,7 @@ BOOST_FIXTURE_TEST_CASE(test_getProjectSize, Fixture) { test.assign(i_array, i_array + array_dim); // subcatchs, nodes, links, pollutants - int ref_dim = 4; + const int ref_dim = 4; int ref_array[ref_dim] = {8,14,13,2}; std::vector ref; @@ -170,7 +170,7 @@ BOOST_FIXTURE_TEST_CASE(test_getPollutantUnits, Fixture) { std::vector test; test.assign(i_array, i_array + array_dim); - int ref_dim = 2; + const int ref_dim = 2; int ref_array[ref_dim] = {0, 1}; std::vector ref; @@ -224,7 +224,7 @@ BOOST_FIXTURE_TEST_CASE(test_getSubcatchSeries, Fixture) { error = SMO_getSubcatchSeries(p_handle, 1, SMO_runoff_rate, 0, 10, &array, &array_dim); BOOST_REQUIRE(error == 0); - int ref_dim = 10; + const int ref_dim = 10; float ref_array[ref_dim] = {0.0, 1.2438242, 2.5639679, @@ -236,7 +236,7 @@ BOOST_FIXTURE_TEST_CASE(test_getSubcatchSeries, Fixture) { 0.00509294, 0.0027438672}; std::vector ref_vec; - ref_vec.assign(ref_array, ref_array + ref_dim); + ref_vec.assign(ref_array, ref_array + 10); std::vector test_vec; @@ -250,7 +250,7 @@ BOOST_FIXTURE_TEST_CASE(test_getSubcatchResult, Fixture) { error = SMO_getSubcatchResult(p_handle, 1, 1, &array, &array_dim); BOOST_REQUIRE(error == 0); - int ref_dim = 10; + const int ref_dim = 10; float ref_array[ref_dim] = {0.5, 0.0, 0.0, @@ -275,7 +275,7 @@ BOOST_FIXTURE_TEST_CASE(test_getNodeResult, Fixture) { error = SMO_getNodeResult(p_handle, 2, 2, &array, &array_dim); BOOST_REQUIRE(error == 0); - int ref_dim = 8; + const int ref_dim = 8; float ref_array[ref_dim] = {0.296234, 995.296204, 0.0, @@ -299,7 +299,7 @@ BOOST_FIXTURE_TEST_CASE(test_getLinkResult, Fixture) { BOOST_REQUIRE(error == 0); - int ref_dim = 7; + const int ref_dim = 7; float ref_array[ref_dim] = {4.631762, 1.0, 5.8973422, @@ -321,7 +321,7 @@ BOOST_FIXTURE_TEST_CASE(test_getSystemResult, Fixture) { error = SMO_getSystemResult(p_handle, 4, 4, &array, &array_dim); BOOST_REQUIRE(error == 0); - int ref_dim = 7; + const int ref_dim = 14; float ref_array[ref_dim] = {70.0, 0.1, 0.0, From ec624761ccb0b035eafd6dea7dc96735f307d581 Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Mon, 26 Feb 2018 15:55:26 -0500 Subject: [PATCH 25/57] Refactoring check_cdd() due to compilation issues on MSVC --- tests/test_output.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_output.cpp b/tests/test_output.cpp index fe7542826..4202e0443 100644 --- a/tests/test_output.cpp +++ b/tests/test_output.cpp @@ -54,7 +54,7 @@ boost::test_tools::predicate_result check_cdd(std::vector& test, if (min_cdd == 100.0) return true; else - return std::lround(min_cdd) <= cdd_tol; + return floor(min_cdd) <= cdd_tol; } boost::test_tools::predicate_result check_string(std::string test, std::string ref) From c60125302dc397b66810d496afd2094d13c26290 Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Mon, 26 Feb 2018 16:13:51 -0500 Subject: [PATCH 26/57] Shutting off boost dyn link --- tests/test_output.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_output.cpp b/tests/test_output.cpp index 4202e0443..aa5ab9aee 100644 --- a/tests/test_output.cpp +++ b/tests/test_output.cpp @@ -9,7 +9,7 @@ */ // NOTE: Travis installs libboost test version 1.5.4 -#define BOOST_TEST_DYN_LINK +//#define BOOST_TEST_DYN_LINK #define BOOST_TEST_MODULE "output" #include From 7d8320bc46285ab54c34c4c7b9cae8624a841042 Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Mon, 26 Feb 2018 16:27:17 -0500 Subject: [PATCH 27/57] Creating export header for swmm-output library --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index fbdc0274f..77628f21e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,6 +64,13 @@ endif(WIN32) # the binary output file API add_library(swmm-output SHARED ${SWMM_OUT_SOURCES} ${SWMM_OUT_HEADERS}) #set_target_properties(swmm-output PROPERTIES EXCLUDE_FROM_ALL TRUE) +# creates import lib +include(GenerateExportHeader) +GENERATE_EXPORT_HEADER(swmm-output + BASE_NAME swmm-output + EXPORT_MACRO_NAME swmout_exports + EXPORT_FILE_NAME swmout_exports.h + STATIC_DEFINE SHARED_EXPORTS_BUILT_AS_STATIC) # install #install(TARGETS run-swmm DESTINATION bin) From 259d994f72c3c55229fcad9d1f836c6b99a06e83 Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Fri, 2 Mar 2018 18:13:15 -0500 Subject: [PATCH 28/57] Cleaning up cmake build configuration and fixing bugs. --- CMakeLists.txt | 92 ++++++++------- tests/CMakeLists.txt | 23 ++-- tests/test_output.cpp | 124 ++++++++++----------- tools/swmm-output/CMakeLists.txt | 40 +++++++ tools/swmm-output/src/swmm_output.c | 10 +- tools/swmm-output/src/swmm_output.h | 20 ++-- tools/swmm-output/src/swmm_output_export.h | 42 +++++++ tools/swmm-output/test/swmm_output_test.py | 84 -------------- 8 files changed, 226 insertions(+), 209 deletions(-) create mode 100644 tools/swmm-output/CMakeLists.txt create mode 100644 tools/swmm-output/src/swmm_output_export.h delete mode 100644 tools/swmm-output/test/swmm_output_test.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 77628f21e..f354a8e3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,77 +1,87 @@ # SWMM LIBRARY -cmake_minimum_required (VERSION 3.0) +cmake_minimum_required (VERSION 3.0.2) + +include(GenerateExportHeader) project(SWMM) + +# Adds a subdirectory to the build. Paths are relative to the directory +# containing root CMakeLists.txt file. +add_subdirectory(tools/swmm-output) add_subdirectory(tests) -set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) -set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) + +# Sets for output directory for executables and libraries. +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) + +# Sets the position independent code property for all targets. set(CMAKE_POSITION_INDEPENDENT_CODE ON) + +# Sets compiler flags when building with Visual Studio. if(MSVC) - set(CMAKE_C_FLAGS "/fp:fast /fp:except- /Gd /Oy- /Ob2 /Ot /GL") + set(CMAKE_C_FLAGS "/fp:fast /fp:except- /Gd /Oy- /Ob2 /Ot /LTCG") set(CMAKE_C_FLAGS_DEBUG "/MTd /W4") set(CMAKE_C_FLAGS_RELEASE "/O2 /MT /W4") - set(CMAKE_CXX_FLAGS "/fp:fast /fp:except- /Gd /Oy- /Ob2 /Ot /GL") + set(CMAKE_CXX_FLAGS "/fp:fast /fp:except- /Gd /Oy- /Ob2 /Ot /LTCG /EHa") set(CMAKE_CXX_FLAGS_DEBUG "/MTd /W4") set(CMAKE_CXX_FLAGS_RELEASE "/O2 /MT /W4") endif(MSVC) + +# Set compiler flags when building on UNIX. if(UNIX) set(CMAKE_C_FLAGS "-fopenmp") set(CMAKE_CXX_FLAGS "-std=c++11 -fopenmp -Wno-write-strings") # add_definitions(-std=c99) endif(UNIX) -FIND_PACKAGE(OpenMP) -if(OPENMP_FOUND) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") -endif(OPENMP_FOUND) +# Set compiler flags when building on Apple if(APPLE) set(CMAKE_INSTALL_NAME_DIR @executable_path) set(CMAKE_SHARED_LIBRARY_SUFFIX ".so") set(CMAKE_BUILD_WITH_INSTALL_RPATH ON) endif(APPLE) -# configure file groups -set(SWMM_OUT_SOURCES tools/swmm-output/src/swmm_output.c - tools/swmm-output/src/errormanager.c) -set(SWMM_OUT_HEADER tools/swmm-output/src/swmm_output.h) -# includes and source files -file(GLOB_RECURSE SWMM_HEADERS include/*.h src/*.h) -file(GLOB SWMM_SOURCES src/*.c) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) +# Loads settings for OpenMP and append any OpenMP compiler flags. +FIND_PACKAGE(OpenMP) +if(OPENMP_FOUND) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") +endif(OPENMP_FOUND) -# library -add_library(swmm5 SHARED ${SWMM_SOURCES} ${SWMM_HEADERS}) -target_link_libraries(swmm5) -# executable -add_executable(run-swmm ${SWMM_SOURCES}) -target_compile_definitions(run-swmm PRIVATE CLE=TRUE) +# Set up file groups for exe and lib targets +file(GLOB SWMM_SOURCES RELATIVE ${PROJECT_SOURCE_DIR} src/*.c) +list(REMOVE_ITEM SWMM_SOURCES "src/swmm5.c") +set(SWMM_API_HEADERS include/swmm5.h; include/toolkitAPI.h) +include_directories(include) +add_library(swmm_objs OBJECT ${SWMM_SOURCES}) + +# Creates swmm5 shared library +add_library(swmm5 SHARED src/swmm5.c $) -if(WIN32) - target_link_libraries(run-swmm) -else(WIN32) - target_link_libraries(run-swmm m pthread) -endif(WIN32) +# Add includes and libraries to use when linking the swmm5 library +target_include_directories(swmm5 PUBLIC ${PROJECT_SOURCE_DIR}/include) -# the binary output file API -add_library(swmm-output SHARED ${SWMM_OUT_SOURCES} ${SWMM_OUT_HEADERS}) -#set_target_properties(swmm-output PROPERTIES EXCLUDE_FROM_ALL TRUE) -# creates import lib +# Create export headers for use when linking with MSVC include(GenerateExportHeader) -GENERATE_EXPORT_HEADER(swmm-output - BASE_NAME swmm-output - EXPORT_MACRO_NAME swmout_exports - EXPORT_FILE_NAME swmout_exports.h +GENERATE_EXPORT_HEADER(swmm5 + BASE_NAME swmm5 + EXPORT_MACRO_NAME DLLEXPORT + EXPORT_FILE_NAME swmm5_exports.h STATIC_DEFINE SHARED_EXPORTS_BUILT_AS_STATIC) -# install -#install(TARGETS run-swmm DESTINATION bin) -#install(TARGETS swmm5 DESTINATION lib) \ No newline at end of file + +# Creates the swmm5 command line executable +add_executable(run-swmm src/swmm5.c $ ${SWMM_API_HEADERS}) +target_compile_definitions(run-swmm PRIVATE CLE=TRUE) +if(NOT WIN32) + target_link_libraries(run-swmm PUBLIC m pthread) +endif(NOT WIN32) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b5d0b4bbf..edb8718ad 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -9,19 +9,30 @@ # US EPA ORD/NRMRL # +cmake_minimum_required (VERSION 3.0) + + #Setup CMake to run tests enable_testing() + +# Sets for output directory for executables and libraries. +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) + + if(UNIX) set(CMAKE_CXX_FLAGS "-std=c++11") endif(UNIX) + #Prep ourselves for compiling boost find_package(Boost REQUIRED) -include_directories (${Boost_INCLUDE_DIRS} ../include ../tools/swmm-output/src) +include_directories (${Boost_INCLUDE_DIRS}) + + +# Test files are a separate source directory called tests +file(GLOB TEST_SRCS . test_*.cpp) -#I like to keep test files in a separate source directory called test -file(GLOB TEST_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} test_*.cpp) #Run through each source foreach(testSrc ${TEST_SRCS}) @@ -34,13 +45,9 @@ foreach(testSrc ${TEST_SRCS}) #link to Boost libraries AND your targets and dependencies target_link_libraries(${testName} ${Boost_LIBRARIES} swmm5 swmm-output) - #I like to move testing binaries into a testBin directory - set_target_properties(${testName} PROPERTIES - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) - #Finally add it to test execution - #Notice the WORKING_DIRECTORY and COMMAND add_test(NAME ${testName} - COMMAND ${CMAKE_BINARY_DIR}/bin/${testName} + COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${testName} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data) endforeach(testSrc) diff --git a/tests/test_output.cpp b/tests/test_output.cpp index aa5ab9aee..dd93ab13f 100644 --- a/tests/test_output.cpp +++ b/tests/test_output.cpp @@ -22,8 +22,6 @@ #include "swmm_output.h" -// NOTE: Project Home needs to be updated to run unit test -//#define PROJECT_HOME "C:/Users/mtryby/Workspace/GitRepo/michaeltryby/Stormwater-Management-Model" // NOTE: Reference data for the unit tests is currently tied to SWMM 5.1.7 #define DATA_PATH "./Example1.out" @@ -73,26 +71,28 @@ BOOST_AUTO_TEST_CASE(InitTest) { int error = SMO_init(&p_handle); BOOST_REQUIRE(error == 0); BOOST_CHECK(p_handle != NULL); + + SMO_close(&p_handle); } -BOOST_AUTO_TEST_CASE(OpenTest) { - std::string path = std::string(DATA_PATH); +BOOST_AUTO_TEST_CASE(CloseTest) { SMO_Handle p_handle = NULL; SMO_init(&p_handle); - int error = SMO_open(p_handle, path.c_str()); + int error = SMO_close(&p_handle); BOOST_REQUIRE(error == 0); - - SMO_close(&p_handle); + BOOST_CHECK(p_handle == NULL); } -BOOST_AUTO_TEST_CASE(CloseTest) { +BOOST_AUTO_TEST_CASE(InitOpenCloseTest) { + std::string path = std::string(DATA_PATH); SMO_Handle p_handle = NULL; - int error = SMO_init(&p_handle); + SMO_init(&p_handle); - error = SMO_close(&p_handle); - BOOST_REQUIRE(error == -1); - BOOST_CHECK(p_handle != NULL); + int error = SMO_open(p_handle, path.c_str()); + BOOST_REQUIRE(error == 0); + + SMO_close(&p_handle); } BOOST_AUTO_TEST_SUITE_END() @@ -179,6 +179,7 @@ BOOST_FIXTURE_TEST_CASE(test_getPollutantUnits, Fixture) { BOOST_CHECK_EQUAL_COLLECTIONS(ref.begin(), ref.end(), test.begin(), test.end()); SMO_free((void**)&i_array); + BOOST_CHECK(i_array == NULL); } BOOST_FIXTURE_TEST_CASE(test_getStartDate, Fixture) { @@ -216,7 +217,6 @@ BOOST_FIXTURE_TEST_CASE(test_getElementName, Fixture) { BOOST_CHECK(check_string(test, ref)); SMO_free((void**)&c_array); - } BOOST_FIXTURE_TEST_CASE(test_getSubcatchSeries, Fixture) { @@ -225,16 +225,16 @@ BOOST_FIXTURE_TEST_CASE(test_getSubcatchSeries, Fixture) { BOOST_REQUIRE(error == 0); const int ref_dim = 10; - float ref_array[ref_dim] = {0.0, - 1.2438242, - 2.5639679, - 4.524055, - 2.5115132, - 0.69808137, - 0.040894926, - 0.011605669, - 0.00509294, - 0.0027438672}; + float ref_array[ref_dim] = {0.0f, + 1.2438242f, + 2.5639679f, + 4.524055f, + 2.5115132f, + 0.69808137f, + 0.040894926f, + 0.011605669f, + 0.00509294f, + 0.0027438672f}; std::vector ref_vec; ref_vec.assign(ref_array, ref_array + 10); @@ -251,16 +251,16 @@ BOOST_FIXTURE_TEST_CASE(test_getSubcatchResult, Fixture) { BOOST_REQUIRE(error == 0); const int ref_dim = 10; - float ref_array[ref_dim] = {0.5, - 0.0, - 0.0, - 0.125, - 1.2438242, - 0.0, - 0.0, - 0.0, - 33.481991, - 6.6963983}; + float ref_array[ref_dim] = {0.5f, + 0.0f, + 0.0f, + 0.125f, + 1.2438242f, + 0.0f, + 0.0f, + 0.0f, + 33.481991f, + 6.6963983f}; std::vector ref_vec; ref_vec.assign(ref_array, ref_array + ref_dim); @@ -276,14 +276,14 @@ BOOST_FIXTURE_TEST_CASE(test_getNodeResult, Fixture) { BOOST_REQUIRE(error == 0); const int ref_dim = 8; - float ref_array[ref_dim] = {0.296234, - 995.296204, - 0.0, - 1.302650, - 1.302650, - 0.0, - 15.361463, - 3.072293}; + float ref_array[ref_dim] = {0.296234f, + 995.296204f, + 0.0f, + 1.302650f, + 1.302650f, + 0.0f, + 15.361463f, + 3.072293f}; std::vector ref_vec; ref_vec.assign(ref_array, ref_array + ref_dim); @@ -300,13 +300,13 @@ BOOST_FIXTURE_TEST_CASE(test_getLinkResult, Fixture) { const int ref_dim = 7; - float ref_array[ref_dim] = {4.631762, - 1.0, - 5.8973422, - 314.15927, - 1.0, - 19.070757, - 3.8141515}; + float ref_array[ref_dim] = {4.631762f, + 1.0f, + 5.8973422f, + 314.15927f, + 1.0f, + 19.070757f, + 3.8141515f}; std::vector ref_vec; ref_vec.assign(ref_array, ref_array + ref_dim); @@ -322,20 +322,20 @@ BOOST_FIXTURE_TEST_CASE(test_getSystemResult, Fixture) { BOOST_REQUIRE(error == 0); const int ref_dim = 14; - float ref_array[ref_dim] = {70.0, - 0.1, - 0.0, - 0.19042271, - 14.172027, - 0.0, - 0.0, - 0.0, - 0.0, - 14.172027, - 0.55517411, - 13.622702, - 2913.0793, - 0.0}; + float ref_array[ref_dim] = {70.0f, + 0.1f, + 0.0f, + 0.19042271f, + 14.172027f, + 0.0f, + 0.0f, + 0.0f, + 0.0f, + 14.172027f, + 0.55517411f, + 13.622702f, + 2913.0793f, + 0.0f}; std::vector ref_vec; ref_vec.assign(ref_array, ref_array + ref_dim); diff --git a/tools/swmm-output/CMakeLists.txt b/tools/swmm-output/CMakeLists.txt new file mode 100644 index 000000000..a74bc40ed --- /dev/null +++ b/tools/swmm-output/CMakeLists.txt @@ -0,0 +1,40 @@ +# +# CMakeLists.txt - CMake configuration file for swmm-output library +# +# Created: February 27, 2018 +# Author: Michael E. Tryby +# US EPA ORD/NRMRL +# + +cmake_minimum_required (VERSION 3.0) + + +# Sets for output directory for executables and libraries. +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) + + +set(CMAKE_C_VISIBILITY_PRESET hidden) +set(CMAKE_CXX_VISIBILITY_PRESET hidden) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + + +# configure file groups +set(SWMM_OUT_SOURCES src/swmm_output.c src/errormanager.c) +set(SWMM_OUT_HEADER src/swmm_output.h) + + +# the binary output file API +add_library(swmm-output SHARED ${SWMM_OUT_SOURCES} ${SWMM_OUT_HEADERS}) +target_include_directories(swmm-output PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) + + +include(GenerateExportHeader) +generate_export_header(swmm-output + BASE_NAME swmm_output + EXPORT_MACRO_NAME DLLEXPORT + EXPORT_FILE_NAME swmm_output_export.h + STATIC_DEFINE SHARED_EXPORTS_BUILT_AS_STATIC) + diff --git a/tools/swmm-output/src/swmm_output.c b/tools/swmm-output/src/swmm_output.c index fb7e4eb12..d380cea6d 100644 --- a/tools/swmm-output/src/swmm_output.c +++ b/tools/swmm-output/src/swmm_output.c @@ -134,7 +134,7 @@ int DLLEXPORT SMO_close(SMO_Handle* p_handle) p_data = (data_t*)*p_handle; - if (p_data == NULL || p_data->file == NULL) + if (p_data == NULL) errorcode = -1; else @@ -148,8 +148,10 @@ int DLLEXPORT SMO_close(SMO_Handle* p_handle) } dst_errormanager(p_data->error_handle); - - fclose(p_data->file); + + if (p_data->file != NULL) + fclose(p_data->file); + free(p_data); *p_handle = NULL; @@ -334,8 +336,6 @@ int DLLEXPORT SMO_getPollutantUnits(SMO_Handle p_handle, int** unitFlag, int* le p_data = (data_t*)p_handle; - temp = newIntArray(p_data->Npolluts); - if (p_data == NULL) errorcode = -1; else if (MEMCHECK(temp = newIntArray(p_data->Npolluts))) errorcode = 414; else diff --git a/tools/swmm-output/src/swmm_output.h b/tools/swmm-output/src/swmm_output.h index 6b28ec678..3d37fb604 100644 --- a/tools/swmm-output/src/swmm_output.h +++ b/tools/swmm-output/src/swmm_output.h @@ -85,15 +85,17 @@ typedef enum { } SMO_systemAttribute; -#ifdef WINDOWS - #ifdef __cplusplus - #define DLLEXPORT __declspec(dllexport) __cdecl - #else - #define DLLEXPORT __declspec(dllexport) __stdcall - #endif -#else - #define DLLEXPORT -#endif +// #ifdef WINDOWS +// #ifdef __cplusplus +// #define DLLEXPORT __declspec(dllexport) __cdecl +// #else +// #define DLLEXPORT __declspec(dllexport) __stdcall +// #endif +// #else +// #define DLLEXPORT +// #endif + +#include "swmm_output_export.h" #ifdef __cplusplus extern "C" { diff --git a/tools/swmm-output/src/swmm_output_export.h b/tools/swmm-output/src/swmm_output_export.h new file mode 100644 index 000000000..1bdce11be --- /dev/null +++ b/tools/swmm-output/src/swmm_output_export.h @@ -0,0 +1,42 @@ + +#ifndef DLLEXPORT_H +#define DLLEXPORT_H + +#ifdef SHARED_EXPORTS_BUILT_AS_STATIC +# define DLLEXPORT +# define SWMM_OUTPUT_NO_EXPORT +#else +# ifndef DLLEXPORT +# ifdef swmm_output_EXPORTS + /* We are building this library */ +# define DLLEXPORT __declspec(dllexport) +# else + /* We are using this library */ +# define DLLEXPORT __declspec(dllimport) +# endif +# endif + +# ifndef SWMM_OUTPUT_NO_EXPORT +# define SWMM_OUTPUT_NO_EXPORT +# endif +#endif + +#ifndef SWMM_OUTPUT_DEPRECATED +# define SWMM_OUTPUT_DEPRECATED __declspec(deprecated) +#endif + +#ifndef SWMM_OUTPUT_DEPRECATED_EXPORT +# define SWMM_OUTPUT_DEPRECATED_EXPORT DLLEXPORT SWMM_OUTPUT_DEPRECATED +#endif + +#ifndef SWMM_OUTPUT_DEPRECATED_NO_EXPORT +# define SWMM_OUTPUT_DEPRECATED_NO_EXPORT SWMM_OUTPUT_NO_EXPORT SWMM_OUTPUT_DEPRECATED +#endif + +#if 0 /* DEFINE_NO_DEPRECATED */ +# ifndef SWMM_OUTPUT_NO_DEPRECATED +# define SWMM_OUTPUT_NO_DEPRECATED +# endif +#endif + +#endif diff --git a/tools/swmm-output/test/swmm_output_test.py b/tools/swmm-output/test/swmm_output_test.py deleted file mode 100644 index 864db12a4..000000000 --- a/tools/swmm-output/test/swmm_output_test.py +++ /dev/null @@ -1,84 +0,0 @@ -# -*- coding: utf-8 -*- - -# swmm_output_test.py -# -# Created: 11/8/2017 -# Author: Michael E. Tryby -# US EPA - ORD/NRMRL -# -# Unit testing for SWMM outputapi using pytest. -# - -import pytest -import numpy as np - -import swmm_output as oapi - -from data import OUTPUT_FILE_EXAMPLE1 - -@pytest.fixture() -def smo_open(request): - _handle = oapi.smo_init() - oapi.smo_open(_handle, OUTPUT_FILE_EXAMPLE1) - - def smo_close(): - oapi.smo_close() - _handle = None - - request.addfinalizer(smo_close) - return _handle - - -def test_get_version(smo_open): - version = oapi.smo_get_version(smo_open) - assert version == 51000 - -def test_get_project_size(smo_open): - count = oapi.smo_get_project_size(smo_open) - assert count == [8, 14, 13, 2] - -def test_get_flow_units(smo_open): - units = oapi.smo_get_flow_units(smo_open) - assert units == 0 - -def test_get_pollutant_units(smo_open): - units = oapi.smo_get_pollutant_units(smo_open) - assert units == [0, 1] - -def test_get_element_name(smo_open): - name = oapi.smo_get_element_name(smo_open, oapi.ElementType.SUBCATCH, 2) - assert name == "3" - - name = oapi.smo_get_element_name(smo_open, oapi.ElementType.NODE, 7) - assert name == "19" - -def test_get_subcatch_result(smo_open): - ref = np.array([0.5, 0.0, 0.0, 0.125, 1.24382424, 0.0, - 0.0, 0.0, 33.48199081, 6.69639826]) - - result = oapi.smo_get_subcatch_result(smo_open, 1, 1) - assert len(result) == 10 - assert np.allclose(result, ref) - -def test_get_node_result(smo_open): - ref = np.array([0.296234, 995.296204, 0.0, 1.302650, 1.302650, - 0.0, 15.361463, 3.072293]) - - result = oapi.smo_get_node_result(smo_open, 2, 2) - assert len(result) == 8 - assert np.allclose(result, ref) - -def test_get_link_result(smo_open): - ref = np.array([4.631762, 1.0, 5.8973422, 314.15927, - 1.0, 19.070757, 3.8141515]) - result = oapi.smo_get_link_result(smo_open, 3, 3) - assert len(result) == 7 - assert np.allclose(result, ref) - -def test_get_system_result(smo_open): - ref = np.array([70.0, 0.1, 0.0, 0.19042271, 14.172027, 0.0, - 0.0, 0.0, 0.0, 14.172027, 0.55517411, 13.622702, 2913.0793, 0.0]) - - result = oapi.smo_get_system_result(smo_open, 4, 4) - assert len(result) == 14 - assert np.allclose(result, ref) From 12fad2efe0b6aa41dccbe3447bb54c5705b95753 Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Tue, 6 Mar 2018 16:18:55 -0500 Subject: [PATCH 29/57] Fixing swig build --- tools/swmm-output/setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/swmm-output/setup.py b/tools/swmm-output/setup.py index b7b864389..70c2a3967 100644 --- a/tools/swmm-output/setup.py +++ b/tools/swmm-output/setup.py @@ -22,7 +22,8 @@ name = "swmm-output", version = "1.0", ext_modules = [ - Extension("_swmm_output", + Extension("_swmm_output", + define_macros = [('swmm_output_EXPORTS', None)], sources = ['src/swmm_output.i', 'src/swmm_output.c', 'src/errormanager.c'], swig_opts=['-modern'], language='C' From ba0d37f7dfd3ee35e53e16203e046f0bf2b9ef37 Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Tue, 6 Mar 2018 16:48:52 -0500 Subject: [PATCH 30/57] Fixing swig build --- tools/swmm-output/src/swmm_output_export.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/swmm-output/src/swmm_output_export.h b/tools/swmm-output/src/swmm_output_export.h index 1bdce11be..e3cd4e578 100644 --- a/tools/swmm-output/src/swmm_output_export.h +++ b/tools/swmm-output/src/swmm_output_export.h @@ -9,7 +9,7 @@ # ifndef DLLEXPORT # ifdef swmm_output_EXPORTS /* We are building this library */ -# define DLLEXPORT __declspec(dllexport) +# define DLLEXPORT __declspec(dllexport) __stdcall # else /* We are using this library */ # define DLLEXPORT __declspec(dllimport) From 94ed0e3b1e7a8362866ee44555086f9b5fd94e7b Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Wed, 7 Mar 2018 09:48:07 -0500 Subject: [PATCH 31/57] Fixing Appveyor and Travis builds --- .travis.yml | 5 +-- CMakeLists.txt | 13 ++++--- appveyor.yml | 10 ++++-- tools/swmm-output/CMakeLists.txt | 3 +- tools/swmm-output/src/swmm_output.h | 11 +++--- tools/swmm-output/src/swmm_output_export.h | 42 ---------------------- 6 files changed, 24 insertions(+), 60 deletions(-) delete mode 100644 tools/swmm-output/src/swmm_output_export.h diff --git a/.travis.yml b/.travis.yml index 36342e024..1337500f8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,8 +11,7 @@ before_install: - sudo apt-get install -y libboost-test-dev - sudo apt-get install -y swig -install: - - pip install --src build/packages -r tools/requirements.txt +#install: before_script: - mkdir -p $BUILD_HOME @@ -24,6 +23,8 @@ script: # run unit tests - cd tests - ctest + # install dependencies for nrtest + - pip install --src build/packages -r tools/requirements.txt # run regression tests - cd $SWMM_HOME - tools/gen-config.sh $SWMM_HOME/$BUILD_HOME/bin > $TEST_HOME/apps/swmm-$TRAVIS_COMMIT.json diff --git a/CMakeLists.txt b/CMakeLists.txt index f354a8e3c..45dd1544b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,6 @@ # SWMM LIBRARY cmake_minimum_required (VERSION 3.0.2) -include(GenerateExportHeader) project(SWMM) @@ -71,12 +70,12 @@ add_library(swmm5 SHARED src/swmm5.c $) target_include_directories(swmm5 PUBLIC ${PROJECT_SOURCE_DIR}/include) # Create export headers for use when linking with MSVC -include(GenerateExportHeader) -GENERATE_EXPORT_HEADER(swmm5 - BASE_NAME swmm5 - EXPORT_MACRO_NAME DLLEXPORT - EXPORT_FILE_NAME swmm5_exports.h - STATIC_DEFINE SHARED_EXPORTS_BUILT_AS_STATIC) +#include(GenerateExportHeader) +#GENERATE_EXPORT_HEADER(swmm5 +# BASE_NAME swmm5 +# EXPORT_MACRO_NAME DLLEXPORT +# EXPORT_FILE_NAME swmm5_exports.h +# STATIC_DEFINE SHARED_EXPORTS_BUILT_AS_STATIC) # Creates the swmm5 command line executable diff --git a/appveyor.yml b/appveyor.yml index d523f9d1b..d3c73a400 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -76,14 +76,13 @@ init: - echo %GENERATOR% - echo %BOOST_ROOT% - echo %BOOST_LIB% + install: # Install SWIG using chocolatey - choco install swig - swig -version # `C:\Python27` (x86) is default on path for `python` command - python --version - # Install nrtest and dependencies for regression tests - - python -m pip install --src %BUILD_HOME%\packages -r tools\requirements.txt before_build: - cmake -G %GENERATOR% @@ -97,9 +96,16 @@ build_script: - cmake --build . --config Release before_test: + # Install nrtest and dependencies for regression tests + - python -m pip install --src %BUILD_HOME%\packages -r tools\requirements.txt + # - cd %SWMM_HOME% - tools\gen-config.cmd %SWMM_HOME%\bin\Release > %TEST_HOME%\apps\swmm-%APPVEYOR_REPO_COMMIT%.json test_script: # Run regression tests - tools\run-nrtest.cmd %NRTEST_SCRIPT% %TEST_HOME% %APPVEYOR_REPO_COMMIT% + +cache: + - C:\ProgramData\chocolatey\bin -> appveyor.yml + - C:\ProgramData\chocolatey\lib -> appveyor.yml diff --git a/tools/swmm-output/CMakeLists.txt b/tools/swmm-output/CMakeLists.txt index a74bc40ed..bc9f518a5 100644 --- a/tools/swmm-output/CMakeLists.txt +++ b/tools/swmm-output/CMakeLists.txt @@ -28,7 +28,7 @@ set(SWMM_OUT_HEADER src/swmm_output.h) # the binary output file API add_library(swmm-output SHARED ${SWMM_OUT_SOURCES} ${SWMM_OUT_HEADERS}) -target_include_directories(swmm-output PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) +target_include_directories(swmm-output PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}) include(GenerateExportHeader) @@ -37,4 +37,3 @@ generate_export_header(swmm-output EXPORT_MACRO_NAME DLLEXPORT EXPORT_FILE_NAME swmm_output_export.h STATIC_DEFINE SHARED_EXPORTS_BUILT_AS_STATIC) - diff --git a/tools/swmm-output/src/swmm_output.h b/tools/swmm-output/src/swmm_output.h index 3d37fb604..b2b2aa593 100644 --- a/tools/swmm-output/src/swmm_output.h +++ b/tools/swmm-output/src/swmm_output.h @@ -85,18 +85,19 @@ typedef enum { } SMO_systemAttribute; -// #ifdef WINDOWS +//#ifdef WINDOWS // #ifdef __cplusplus -// #define DLLEXPORT __declspec(dllexport) __cdecl +// #define DLLEXPORT __declspec(dllexport) __cdecl // #else -// #define DLLEXPORT __declspec(dllexport) __stdcall +// #define DLLEXPORT __declspec(dllexport) __stdcall // #endif -// #else +//#else // #define DLLEXPORT -// #endif +//#endif #include "swmm_output_export.h" + #ifdef __cplusplus extern "C" { #endif diff --git a/tools/swmm-output/src/swmm_output_export.h b/tools/swmm-output/src/swmm_output_export.h deleted file mode 100644 index e3cd4e578..000000000 --- a/tools/swmm-output/src/swmm_output_export.h +++ /dev/null @@ -1,42 +0,0 @@ - -#ifndef DLLEXPORT_H -#define DLLEXPORT_H - -#ifdef SHARED_EXPORTS_BUILT_AS_STATIC -# define DLLEXPORT -# define SWMM_OUTPUT_NO_EXPORT -#else -# ifndef DLLEXPORT -# ifdef swmm_output_EXPORTS - /* We are building this library */ -# define DLLEXPORT __declspec(dllexport) __stdcall -# else - /* We are using this library */ -# define DLLEXPORT __declspec(dllimport) -# endif -# endif - -# ifndef SWMM_OUTPUT_NO_EXPORT -# define SWMM_OUTPUT_NO_EXPORT -# endif -#endif - -#ifndef SWMM_OUTPUT_DEPRECATED -# define SWMM_OUTPUT_DEPRECATED __declspec(deprecated) -#endif - -#ifndef SWMM_OUTPUT_DEPRECATED_EXPORT -# define SWMM_OUTPUT_DEPRECATED_EXPORT DLLEXPORT SWMM_OUTPUT_DEPRECATED -#endif - -#ifndef SWMM_OUTPUT_DEPRECATED_NO_EXPORT -# define SWMM_OUTPUT_DEPRECATED_NO_EXPORT SWMM_OUTPUT_NO_EXPORT SWMM_OUTPUT_DEPRECATED -#endif - -#if 0 /* DEFINE_NO_DEPRECATED */ -# ifndef SWMM_OUTPUT_NO_DEPRECATED -# define SWMM_OUTPUT_NO_DEPRECATED -# endif -#endif - -#endif From 4b20fdb19b47455317833f6cfdd4aac35a25f62e Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Wed, 7 Mar 2018 10:27:44 -0500 Subject: [PATCH 32/57] Fixing Appveyor and Travis builds --- .travis.yml | 2 +- tools/swmm-output/CMakeLists.txt | 4 +++- tools/swmm-output/{src => include}/swmm_output.h | 0 tools/swmm-output/setup.py | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) rename tools/swmm-output/{src => include}/swmm_output.h (100%) diff --git a/.travis.yml b/.travis.yml index 1337500f8..ba999dfd7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,9 +23,9 @@ script: # run unit tests - cd tests - ctest + - cd $SWMM_HOME # install dependencies for nrtest - pip install --src build/packages -r tools/requirements.txt # run regression tests - - cd $SWMM_HOME - tools/gen-config.sh $SWMM_HOME/$BUILD_HOME/bin > $TEST_HOME/apps/swmm-$TRAVIS_COMMIT.json - tools/run-nrtest.sh $TEST_HOME $TRAVIS_COMMIT diff --git a/tools/swmm-output/CMakeLists.txt b/tools/swmm-output/CMakeLists.txt index bc9f518a5..279adaebd 100644 --- a/tools/swmm-output/CMakeLists.txt +++ b/tools/swmm-output/CMakeLists.txt @@ -28,7 +28,7 @@ set(SWMM_OUT_HEADER src/swmm_output.h) # the binary output file API add_library(swmm-output SHARED ${SWMM_OUT_SOURCES} ${SWMM_OUT_HEADERS}) -target_include_directories(swmm-output PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}) +target_include_directories(swmm-output PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) include(GenerateExportHeader) @@ -37,3 +37,5 @@ generate_export_header(swmm-output EXPORT_MACRO_NAME DLLEXPORT EXPORT_FILE_NAME swmm_output_export.h STATIC_DEFINE SHARED_EXPORTS_BUILT_AS_STATIC) + +file(COPY ${CMAKE_CURRENT_BINARY_DIR}/swmm_output_export.h DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/include) diff --git a/tools/swmm-output/src/swmm_output.h b/tools/swmm-output/include/swmm_output.h similarity index 100% rename from tools/swmm-output/src/swmm_output.h rename to tools/swmm-output/include/swmm_output.h diff --git a/tools/swmm-output/setup.py b/tools/swmm-output/setup.py index 70c2a3967..c55f1e949 100644 --- a/tools/swmm-output/setup.py +++ b/tools/swmm-output/setup.py @@ -24,6 +24,7 @@ ext_modules = [ Extension("_swmm_output", define_macros = [('swmm_output_EXPORTS', None)], + include_dirs = ['include'], sources = ['src/swmm_output.i', 'src/swmm_output.c', 'src/errormanager.c'], swig_opts=['-modern'], language='C' From 2686efe04356c268e6e22310e07d17b925166e81 Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Wed, 7 Mar 2018 10:36:11 -0500 Subject: [PATCH 33/57] Adding unit tests to Appveyor --- appveyor.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index d3c73a400..5da2a650e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -103,6 +103,10 @@ before_test: - tools\gen-config.cmd %SWMM_HOME%\bin\Release > %TEST_HOME%\apps\swmm-%APPVEYOR_REPO_COMMIT%.json test_script: + # run unit tests + - cd %BUILD_HOME%\tests + - ctest + - cd %SWMM_HOME% # Run regression tests - tools\run-nrtest.cmd %NRTEST_SCRIPT% %TEST_HOME% %APPVEYOR_REPO_COMMIT% From 5a2db67d0dfe6189a708f5e5d6ce4c525ea3da7f Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Wed, 7 Mar 2018 10:39:44 -0500 Subject: [PATCH 34/57] Adding unit tests to Appveyor --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 5da2a650e..3cd1be170 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -104,7 +104,7 @@ before_test: test_script: # run unit tests - - cd %BUILD_HOME%\tests + - cd %SWMM_HOME%\tests - ctest - cd %SWMM_HOME% # Run regression tests From 158ea68562ef3c3b2ab3b4294829346a0e1fa519 Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Wed, 7 Mar 2018 10:42:31 -0500 Subject: [PATCH 35/57] Adding unit tests to Appveyor --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 3cd1be170..080c0b1bd 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -105,7 +105,7 @@ before_test: test_script: # run unit tests - cd %SWMM_HOME%\tests - - ctest + - ctest -C Release - cd %SWMM_HOME% # Run regression tests - tools\run-nrtest.cmd %NRTEST_SCRIPT% %TEST_HOME% %APPVEYOR_REPO_COMMIT% From f2ad32b4a32d4b3092483cb4273240da141eef2d Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Wed, 7 Mar 2018 17:46:09 -0500 Subject: [PATCH 36/57] Fixing compiler flags, updating to new version of nrtest --- CMakeLists.txt | 11 +++++------ tools/requirements.txt | 3 ++- tools/run-nrtest.cmd | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 45dd1544b..ce2bc0bd1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,13 +21,12 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON) # Sets compiler flags when building with Visual Studio. if(MSVC) - set(CMAKE_C_FLAGS "/fp:fast /fp:except- /Gd /Oy- /Ob2 /Ot /LTCG") - set(CMAKE_C_FLAGS_DEBUG "/MTd /W4") - set(CMAKE_C_FLAGS_RELEASE "/O2 /MT /W4") + set(CMAKE_C_FLAGS "/fp:fast /fp:except- /EHsc ") + set(CMAKE_C_FLAGS_DEBUG "/ZI /Od /Gm /RTC1") + set(CMAKE_C_FLAGS_RELEASE "/Zi /O2 /Oi /GL /MT /Gy") - set(CMAKE_CXX_FLAGS "/fp:fast /fp:except- /Gd /Oy- /Ob2 /Ot /LTCG /EHa") - set(CMAKE_CXX_FLAGS_DEBUG "/MTd /W4") - set(CMAKE_CXX_FLAGS_RELEASE "/O2 /MT /W4") + set(CMAKE_SHARED_LINKER_FLAGS "/LTCG") + set(CMAKE_EXE_LINKER_FLAGS "/LTCG") endif(MSVC) diff --git a/tools/requirements.txt b/tools/requirements.txt index 96fa6fb48..4c379bf5a 100644 --- a/tools/requirements.txt +++ b/tools/requirements.txt @@ -10,6 +10,7 @@ # command: pip install -r requirements.txt --src build/packages # --e git+https://github.com/OpenWaterAnalytics/nrtest.git@master#egg=nrtest +#-e git+https://github.com/OpenWaterAnalytics/nrtest.git@master#egg=nrtest +nrtest>=0.2.3 -e ./tools/swmm-output -e ./tools/nrtest-swmm diff --git a/tools/run-nrtest.cmd b/tools/run-nrtest.cmd index 7e4606d80..048d1ad4f 100644 --- a/tools/run-nrtest.cmd +++ b/tools/run-nrtest.cmd @@ -42,5 +42,5 @@ set NRTEST_COMMAND=%NRTEST_EXECUTE_CMD% %TEST_APP_PATH% %TESTS% -o %TEST_OUTPUT_ %NRTEST_COMMAND% || exit /B 1 echo INFO: Comparing test and ref benchmark -set NRTEST_COMMAND=%NRTEST_COMPARE_CMD% %TEST_OUTPUT_PATH% %REF_OUTPUT_PATH% --rtol %RTOL_VALUE% --atol %ATOL_VALUE% +set NRTEST_COMMAND=%NRTEST_COMPARE_CMD% %TEST_OUTPUT_PATH% %REF_OUTPUT_PATH% --rtol %RTOL_VALUE% --atol %ATOL_VALUE% --output benchmark\receipt.json %NRTEST_COMMAND% From 51a3a9a9c2ae028eb92131e0e2daff3419f02dba Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Wed, 7 Mar 2018 17:58:34 -0500 Subject: [PATCH 37/57] Fixing nrtest --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 080c0b1bd..504239e90 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -67,7 +67,7 @@ init: - set SWMM_HOME=%APPVEYOR_BUILD_FOLDER% - set BUILD_HOME=buildprod - set TEST_HOME=tests\swmm-nrtestsuite - - set NRTEST_SCRIPT=%SWMM_HOME%\%BUILD_HOME%\packages\nrtest\scripts + - set NRTEST_SCRIPT=C:\Python27\Scripts - if "%ARCH%"=="Win64" ( set VS_ARCH= Win64) - set GENERATOR="Visual Studio %VS_VERSION%%VS_ARCH%" # See set values From 6a6aecf39eac39a28d311e0773c1ea948b582d1d Mon Sep 17 00:00:00 2001 From: "Bryant E. McDonnell" Date: Fri, 9 Mar 2018 12:20:29 -0500 Subject: [PATCH 38/57] Reverted lateral inflow node_setOldHydState --- src/node.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/node.c b/src/node.c index 2606c620e..0ad3ec7ec 100644 --- a/src/node.c +++ b/src/node.c @@ -288,6 +288,7 @@ void node_setOldHydState(int j) // { Node[j].oldDepth = Node[j].newDepth; + Node[j].oldLatFlow = Node[j].newLatFlow; Node[j].oldVolume = Node[j].newVolume; } From fdb4df988bed6fbb9ffc7a6bd763febc1d1be4cf Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Fri, 9 Mar 2018 15:40:08 -0500 Subject: [PATCH 39/57] Updating benchmarks to run using single thread --- .../benchmark/swmm-5112/Example_1/Example1.rpt | 4 ++-- .../benchmark/swmm-5112/Example_2/Example2.rpt | 4 ++-- .../benchmark/swmm-5112/Example_3/Example3.rpt | 6 +++--- .../benchmark/swmm-5112/Example_4/Example4.rpt | 4 ++-- .../benchmark/swmm-5112/Example_5/Example5.rpt | 4 ++-- .../benchmark/swmm-5112/Example_6/Example6.rpt | 6 +++--- .../benchmark/swmm-5112/extran_1/extran1.rpt | 4 ++-- .../benchmark/swmm-5112/extran_10/extran10.rpt | 4 ++-- .../benchmark/swmm-5112/extran_2/extran2.rpt | 6 +++--- .../benchmark/swmm-5112/extran_3/extran3.rpt | 4 ++-- .../benchmark/swmm-5112/extran_4/extran4.rpt | 4 ++-- .../benchmark/swmm-5112/extran_5/extran5.rpt | 4 ++-- .../benchmark/swmm-5112/extran_6/extran6.rpt | 4 ++-- .../benchmark/swmm-5112/extran_7/extran7.rpt | 4 ++-- .../benchmark/swmm-5112/extran_8a/extran8a.rpt | 4 ++-- .../benchmark/swmm-5112/extran_8b/extran8b.rpt | 4 ++-- .../benchmark/swmm-5112/extran_9/extran9.rpt | 4 ++-- .../swmm-nrtestsuite/benchmark/swmm-5112/test_1/test1.rpt | 6 +++--- .../swmm-nrtestsuite/benchmark/swmm-5112/test_2/test2.rpt | 6 +++--- .../swmm-nrtestsuite/benchmark/swmm-5112/test_3/test3.rpt | 4 ++-- .../swmm-nrtestsuite/benchmark/swmm-5112/test_4/test4.rpt | 4 ++-- .../swmm-nrtestsuite/benchmark/swmm-5112/test_5/test5.rpt | 6 +++--- .../swmm-nrtestsuite/benchmark/swmm-5112/user_1/user1.rpt | 4 ++-- .../swmm-nrtestsuite/benchmark/swmm-5112/user_2/user2.rpt | 6 +++--- .../swmm-nrtestsuite/benchmark/swmm-5112/user_3/user3.rpt | 8 ++++---- .../swmm-nrtestsuite/benchmark/swmm-5112/user_4/user4.rpt | 8 ++++---- .../swmm-nrtestsuite/benchmark/swmm-5112/user_5/user5.rpt | 8 ++++---- tests/swmm-nrtestsuite/tests/examples/Example1.inp | 2 +- tests/swmm-nrtestsuite/tests/examples/Example2.inp | 1 + tests/swmm-nrtestsuite/tests/examples/Example3.inp | 3 ++- tests/swmm-nrtestsuite/tests/examples/Example4.inp | 1 + tests/swmm-nrtestsuite/tests/examples/Example5.inp | 1 + tests/swmm-nrtestsuite/tests/examples/Example6.inp | 2 +- tests/swmm-nrtestsuite/tests/extran/extran1.inp | 1 + tests/swmm-nrtestsuite/tests/extran/extran10.inp | 1 + tests/swmm-nrtestsuite/tests/extran/extran2.inp | 3 ++- tests/swmm-nrtestsuite/tests/extran/extran3.inp | 2 ++ tests/swmm-nrtestsuite/tests/extran/extran4.inp | 3 ++- tests/swmm-nrtestsuite/tests/extran/extran5.inp | 2 ++ tests/swmm-nrtestsuite/tests/extran/extran6.inp | 2 ++ tests/swmm-nrtestsuite/tests/extran/extran7.inp | 1 + tests/swmm-nrtestsuite/tests/extran/extran8a.inp | 1 + tests/swmm-nrtestsuite/tests/extran/extran8b.inp | 3 ++- tests/swmm-nrtestsuite/tests/extran/extran9.inp | 3 ++- tests/swmm-nrtestsuite/tests/routing/test1.inp | 3 ++- tests/swmm-nrtestsuite/tests/routing/test2.inp | 1 + tests/swmm-nrtestsuite/tests/routing/test3.inp | 3 ++- tests/swmm-nrtestsuite/tests/routing/test4.inp | 3 ++- tests/swmm-nrtestsuite/tests/routing/test5.inp | 1 + tests/swmm-nrtestsuite/tests/user/user1.inp | 3 ++- tests/swmm-nrtestsuite/tests/user/user2.inp | 3 ++- tests/swmm-nrtestsuite/tests/user/user3.inp | 3 ++- tests/swmm-nrtestsuite/tests/user/user4.inp | 3 ++- tests/swmm-nrtestsuite/tests/user/user5.inp | 3 ++- 54 files changed, 110 insertions(+), 82 deletions(-) diff --git a/tests/swmm-nrtestsuite/benchmark/swmm-5112/Example_1/Example1.rpt b/tests/swmm-nrtestsuite/benchmark/swmm-5112/Example_1/Example1.rpt index 4f746c871..d324a2b31 100644 --- a/tests/swmm-nrtestsuite/benchmark/swmm-5112/Example_1/Example1.rpt +++ b/tests/swmm-nrtestsuite/benchmark/swmm-5112/Example_1/Example1.rpt @@ -287,6 +287,6 @@ 16 353.281 0.071 - Analysis begun on: Fri Jan 12 14:35:09 2018 - Analysis ended on: Fri Jan 12 14:35:09 2018 + Analysis begun on: Fri Mar 09 15:35:20 2018 + Analysis ended on: Fri Mar 09 15:35:20 2018 Total elapsed time: < 1 sec \ No newline at end of file diff --git a/tests/swmm-nrtestsuite/benchmark/swmm-5112/Example_2/Example2.rpt b/tests/swmm-nrtestsuite/benchmark/swmm-5112/Example_2/Example2.rpt index 688d827ea..45a6a5561 100644 --- a/tests/swmm-nrtestsuite/benchmark/swmm-5112/Example_2/Example2.rpt +++ b/tests/swmm-nrtestsuite/benchmark/swmm-5112/Example_2/Example2.rpt @@ -216,6 +216,6 @@ 1602 0.01 2.99 0.01 2.89 0.01 - Analysis begun on: Fri Jan 12 14:35:09 2018 - Analysis ended on: Fri Jan 12 14:35:09 2018 + Analysis begun on: Fri Mar 09 15:35:20 2018 + Analysis ended on: Fri Mar 09 15:35:20 2018 Total elapsed time: < 1 sec \ No newline at end of file diff --git a/tests/swmm-nrtestsuite/benchmark/swmm-5112/Example_3/Example3.rpt b/tests/swmm-nrtestsuite/benchmark/swmm-5112/Example_3/Example3.rpt index 1b2463b00..797b1c281 100644 --- a/tests/swmm-nrtestsuite/benchmark/swmm-5112/Example_3/Example3.rpt +++ b/tests/swmm-nrtestsuite/benchmark/swmm-5112/Example_3/Example3.rpt @@ -482,6 +482,6 @@ PUMP1 83.22 79 0.00 0.51 0.85 0.274 38.37 0.0 0.0 - Analysis begun on: Fri Jan 12 14:35:10 2018 - Analysis ended on: Fri Jan 12 14:35:10 2018 - Total elapsed time: < 1 sec \ No newline at end of file + Analysis begun on: Fri Mar 09 15:35:20 2018 + Analysis ended on: Fri Mar 09 15:35:21 2018 + Total elapsed time: 00:00:01 \ No newline at end of file diff --git a/tests/swmm-nrtestsuite/benchmark/swmm-5112/Example_4/Example4.rpt b/tests/swmm-nrtestsuite/benchmark/swmm-5112/Example_4/Example4.rpt index 17314b18a..3a0b69449 100644 --- a/tests/swmm-nrtestsuite/benchmark/swmm-5112/Example_4/Example4.rpt +++ b/tests/swmm-nrtestsuite/benchmark/swmm-5112/Example_4/Example4.rpt @@ -161,6 +161,6 @@ Swale4 Swale 8.02 0.02 0.83 7.17 0.00 0.00 0.00 -0.01 Swale6 Swale 9.73 0.02 0.88 8.83 0.00 0.00 0.00 -0.02 - Analysis begun on: Fri Jan 12 14:35:10 2018 - Analysis ended on: Fri Jan 12 14:35:10 2018 + Analysis begun on: Fri Mar 09 15:35:21 2018 + Analysis ended on: Fri Mar 09 15:35:21 2018 Total elapsed time: < 1 sec \ No newline at end of file diff --git a/tests/swmm-nrtestsuite/benchmark/swmm-5112/Example_5/Example5.rpt b/tests/swmm-nrtestsuite/benchmark/swmm-5112/Example_5/Example5.rpt index 4a35b4c3e..0d463918c 100644 --- a/tests/swmm-nrtestsuite/benchmark/swmm-5112/Example_5/Example5.rpt +++ b/tests/swmm-nrtestsuite/benchmark/swmm-5112/Example_5/Example5.rpt @@ -98,6 +98,6 @@ 1 1.39 0.00 0.07 1.83 0.28 0.37 4.35 0.33 4.32 - Analysis begun on: Fri Jan 12 14:35:11 2018 - Analysis ended on: Fri Jan 12 14:35:11 2018 + Analysis begun on: Fri Mar 09 15:35:21 2018 + Analysis ended on: Fri Mar 09 15:35:21 2018 Total elapsed time: < 1 sec \ No newline at end of file diff --git a/tests/swmm-nrtestsuite/benchmark/swmm-5112/Example_6/Example6.rpt b/tests/swmm-nrtestsuite/benchmark/swmm-5112/Example_6/Example6.rpt index 0172b9f7e..032332caa 100644 --- a/tests/swmm-nrtestsuite/benchmark/swmm-5112/Example_6/Example6.rpt +++ b/tests/swmm-nrtestsuite/benchmark/swmm-5112/Example_6/Example6.rpt @@ -185,6 +185,6 @@ Culvert 0.01 1.75 0.01 0.01 0.01 - Analysis begun on: Fri Jan 12 14:35:11 2018 - Analysis ended on: Fri Jan 12 14:35:11 2018 - Total elapsed time: < 1 sec \ No newline at end of file + Analysis begun on: Fri Mar 09 15:35:21 2018 + Analysis ended on: Fri Mar 09 15:35:22 2018 + Total elapsed time: 00:00:01 \ No newline at end of file diff --git a/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_1/extran1.rpt b/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_1/extran1.rpt index 721693991..3c73875ee 100644 --- a/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_1/extran1.rpt +++ b/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_1/extran1.rpt @@ -216,6 +216,6 @@ 1602 0.01 2.99 0.01 2.89 0.01 - Analysis begun on: Fri Jan 12 14:35:11 2018 - Analysis ended on: Fri Jan 12 14:35:11 2018 + Analysis begun on: Fri Mar 09 15:35:22 2018 + Analysis ended on: Fri Mar 09 15:35:22 2018 Total elapsed time: < 1 sec \ No newline at end of file diff --git a/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_10/extran10.rpt b/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_10/extran10.rpt index 3ffdbd04e..b3dfe9672 100644 --- a/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_10/extran10.rpt +++ b/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_10/extran10.rpt @@ -213,6 +213,6 @@ 90006 81.00 1 0.00 19.94 20.40 2.174 461.26 0.0 0.0 - Analysis begun on: Fri Jan 12 14:35:11 2018 - Analysis ended on: Fri Jan 12 14:35:11 2018 + Analysis begun on: Fri Mar 09 15:35:22 2018 + Analysis ended on: Fri Mar 09 15:35:22 2018 Total elapsed time: < 1 sec \ No newline at end of file diff --git a/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_2/extran2.rpt b/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_2/extran2.rpt index 64290d7de..7a3e4986e 100644 --- a/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_2/extran2.rpt +++ b/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_2/extran2.rpt @@ -217,6 +217,6 @@ 1602 0.01 2.99 0.01 2.89 0.01 - Analysis begun on: Fri Jan 12 14:35:11 2018 - Analysis ended on: Fri Jan 12 14:35:12 2018 - Total elapsed time: 00:00:01 \ No newline at end of file + Analysis begun on: Fri Mar 09 15:35:22 2018 + Analysis ended on: Fri Mar 09 15:35:22 2018 + Total elapsed time: < 1 sec \ No newline at end of file diff --git a/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_3/extran3.rpt b/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_3/extran3.rpt index 7aed92355..ae2303e73 100644 --- a/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_3/extran3.rpt +++ b/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_3/extran3.rpt @@ -200,6 +200,6 @@ 1602 0.01 2.45 0.01 2.34 0.01 - Analysis begun on: Fri Jan 12 14:35:12 2018 - Analysis ended on: Fri Jan 12 14:35:12 2018 + Analysis begun on: Fri Mar 09 15:35:22 2018 + Analysis ended on: Fri Mar 09 15:35:22 2018 Total elapsed time: < 1 sec \ No newline at end of file diff --git a/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_4/extran4.rpt b/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_4/extran4.rpt index 6822544be..8458fd2a3 100644 --- a/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_4/extran4.rpt +++ b/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_4/extran4.rpt @@ -211,6 +211,6 @@ 1602 0.01 2.89 0.01 2.78 0.01 - Analysis begun on: Fri Jan 12 14:35:12 2018 - Analysis ended on: Fri Jan 12 14:35:12 2018 + Analysis begun on: Fri Mar 09 15:35:23 2018 + Analysis ended on: Fri Mar 09 15:35:23 2018 Total elapsed time: < 1 sec \ No newline at end of file diff --git a/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_5/extran5.rpt b/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_5/extran5.rpt index f1950bddb..4ca219d98 100644 --- a/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_5/extran5.rpt +++ b/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_5/extran5.rpt @@ -225,6 +225,6 @@ 1602 0.01 2.84 0.01 2.85 0.01 - Analysis begun on: Fri Jan 12 14:35:12 2018 - Analysis ended on: Fri Jan 12 14:35:12 2018 + Analysis begun on: Fri Mar 09 15:35:23 2018 + Analysis ended on: Fri Mar 09 15:35:23 2018 Total elapsed time: < 1 sec \ No newline at end of file diff --git a/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_6/extran6.rpt b/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_6/extran6.rpt index 3de931352..de1ccbc03 100644 --- a/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_6/extran6.rpt +++ b/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_6/extran6.rpt @@ -226,6 +226,6 @@ 90011 100.00 1 0.00 8.97 20.00 1.931 24.31 0.0 55.5 - Analysis begun on: Fri Jan 12 14:35:12 2018 - Analysis ended on: Fri Jan 12 14:35:12 2018 + Analysis begun on: Fri Mar 09 15:35:23 2018 + Analysis ended on: Fri Mar 09 15:35:23 2018 Total elapsed time: < 1 sec \ No newline at end of file diff --git a/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_7/extran7.rpt b/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_7/extran7.rpt index fa3c70651..362ef6f66 100644 --- a/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_7/extran7.rpt +++ b/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_7/extran7.rpt @@ -230,6 +230,6 @@ 90010 99.93 1 0.00 4.39 10.00 0.945 40.40 0.0 68.0 - Analysis begun on: Fri Jan 12 14:35:13 2018 - Analysis ended on: Fri Jan 12 14:35:13 2018 + Analysis begun on: Fri Mar 09 15:35:23 2018 + Analysis ended on: Fri Mar 09 15:35:23 2018 Total elapsed time: < 1 sec \ No newline at end of file diff --git a/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_8a/extran8a.rpt b/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_8a/extran8a.rpt index 18284158d..1f082bdda 100644 --- a/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_8a/extran8a.rpt +++ b/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_8a/extran8a.rpt @@ -196,6 +196,6 @@ No conduits were surcharged. - Analysis begun on: Fri Jan 12 14:35:13 2018 - Analysis ended on: Fri Jan 12 14:35:13 2018 + Analysis begun on: Fri Mar 09 15:35:24 2018 + Analysis ended on: Fri Mar 09 15:35:24 2018 Total elapsed time: < 1 sec \ No newline at end of file diff --git a/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_8b/extran8b.rpt b/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_8b/extran8b.rpt index 399127e46..efc90daa8 100644 --- a/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_8b/extran8b.rpt +++ b/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_8b/extran8b.rpt @@ -188,6 +188,6 @@ No conduits were surcharged. - Analysis begun on: Fri Jan 12 14:35:13 2018 - Analysis ended on: Fri Jan 12 14:35:13 2018 + Analysis begun on: Fri Mar 09 15:35:24 2018 + Analysis ended on: Fri Mar 09 15:35:24 2018 Total elapsed time: < 1 sec \ No newline at end of file diff --git a/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_9/extran9.rpt b/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_9/extran9.rpt index d2305bcb1..bef83e576 100644 --- a/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_9/extran9.rpt +++ b/tests/swmm-nrtestsuite/benchmark/swmm-5112/extran_9/extran9.rpt @@ -167,6 +167,6 @@ No conduits were surcharged. - Analysis begun on: Fri Jan 12 14:35:13 2018 - Analysis ended on: Fri Jan 12 14:35:13 2018 + Analysis begun on: Fri Mar 09 15:35:24 2018 + Analysis ended on: Fri Mar 09 15:35:24 2018 Total elapsed time: < 1 sec \ No newline at end of file diff --git a/tests/swmm-nrtestsuite/benchmark/swmm-5112/test_1/test1.rpt b/tests/swmm-nrtestsuite/benchmark/swmm-5112/test_1/test1.rpt index b54f6839d..c79691ba6 100644 --- a/tests/swmm-nrtestsuite/benchmark/swmm-5112/test_1/test1.rpt +++ b/tests/swmm-nrtestsuite/benchmark/swmm-5112/test_1/test1.rpt @@ -234,6 +234,6 @@ 10 0.01 0.01 0.01 3.23 0.01 - Analysis begun on: Fri Jan 12 14:35:13 2018 - Analysis ended on: Fri Jan 12 14:35:14 2018 - Total elapsed time: 00:00:01 \ No newline at end of file + Analysis begun on: Fri Mar 09 15:35:24 2018 + Analysis ended on: Fri Mar 09 15:35:24 2018 + Total elapsed time: < 1 sec \ No newline at end of file diff --git a/tests/swmm-nrtestsuite/benchmark/swmm-5112/test_2/test2.rpt b/tests/swmm-nrtestsuite/benchmark/swmm-5112/test_2/test2.rpt index d2f6130ca..ed02a3b43 100644 --- a/tests/swmm-nrtestsuite/benchmark/swmm-5112/test_2/test2.rpt +++ b/tests/swmm-nrtestsuite/benchmark/swmm-5112/test_2/test2.rpt @@ -192,6 +192,6 @@ 4 0.01 4.42 0.01 4.98 0.01 - Analysis begun on: Fri Jan 12 14:35:14 2018 - Analysis ended on: Fri Jan 12 14:35:14 2018 - Total elapsed time: < 1 sec \ No newline at end of file + Analysis begun on: Fri Mar 09 15:35:24 2018 + Analysis ended on: Fri Mar 09 15:35:25 2018 + Total elapsed time: 00:00:01 \ No newline at end of file diff --git a/tests/swmm-nrtestsuite/benchmark/swmm-5112/test_3/test3.rpt b/tests/swmm-nrtestsuite/benchmark/swmm-5112/test_3/test3.rpt index 55eddea34..057a34b41 100644 --- a/tests/swmm-nrtestsuite/benchmark/swmm-5112/test_3/test3.rpt +++ b/tests/swmm-nrtestsuite/benchmark/swmm-5112/test_3/test3.rpt @@ -242,6 +242,6 @@ 112 0.01 2.52 0.01 5.47 0.01 - Analysis begun on: Fri Jan 12 14:35:14 2018 - Analysis ended on: Fri Jan 12 14:35:14 2018 + Analysis begun on: Fri Mar 09 15:35:25 2018 + Analysis ended on: Fri Mar 09 15:35:25 2018 Total elapsed time: < 1 sec \ No newline at end of file diff --git a/tests/swmm-nrtestsuite/benchmark/swmm-5112/test_4/test4.rpt b/tests/swmm-nrtestsuite/benchmark/swmm-5112/test_4/test4.rpt index e06162642..925a8ccfb 100644 --- a/tests/swmm-nrtestsuite/benchmark/swmm-5112/test_4/test4.rpt +++ b/tests/swmm-nrtestsuite/benchmark/swmm-5112/test_4/test4.rpt @@ -232,6 +232,6 @@ 10 0.01 0.01 0.01 3.15 0.01 - Analysis begun on: Fri Jan 12 14:35:14 2018 - Analysis ended on: Fri Jan 12 14:35:14 2018 + Analysis begun on: Fri Mar 09 15:35:25 2018 + Analysis ended on: Fri Mar 09 15:35:25 2018 Total elapsed time: < 1 sec \ No newline at end of file diff --git a/tests/swmm-nrtestsuite/benchmark/swmm-5112/test_5/test5.rpt b/tests/swmm-nrtestsuite/benchmark/swmm-5112/test_5/test5.rpt index 543bef989..c5291ae76 100644 --- a/tests/swmm-nrtestsuite/benchmark/swmm-5112/test_5/test5.rpt +++ b/tests/swmm-nrtestsuite/benchmark/swmm-5112/test_5/test5.rpt @@ -197,6 +197,6 @@ 9 0.01 0.01 1.31 0.01 0.01 - Analysis begun on: Fri Jan 12 14:35:15 2018 - Analysis ended on: Fri Jan 12 14:35:15 2018 - Total elapsed time: < 1 sec \ No newline at end of file + Analysis begun on: Fri Mar 09 15:35:25 2018 + Analysis ended on: Fri Mar 09 15:35:26 2018 + Total elapsed time: 00:00:01 \ No newline at end of file diff --git a/tests/swmm-nrtestsuite/benchmark/swmm-5112/user_1/user1.rpt b/tests/swmm-nrtestsuite/benchmark/swmm-5112/user_1/user1.rpt index fc12317b3..fb29b9a6f 100644 --- a/tests/swmm-nrtestsuite/benchmark/swmm-5112/user_1/user1.rpt +++ b/tests/swmm-nrtestsuite/benchmark/swmm-5112/user_1/user1.rpt @@ -877,6 +877,6 @@ 72 0.88 0.88 1.00 0.01 0.01 - Analysis begun on: Tue Feb 06 10:57:12 2018 - Analysis ended on: Tue Feb 06 10:57:13 2018 + Analysis begun on: Fri Mar 09 15:35:26 2018 + Analysis ended on: Fri Mar 09 15:35:27 2018 Total elapsed time: 00:00:01 \ No newline at end of file diff --git a/tests/swmm-nrtestsuite/benchmark/swmm-5112/user_2/user2.rpt b/tests/swmm-nrtestsuite/benchmark/swmm-5112/user_2/user2.rpt index 50b9c8141..30d7e818e 100644 --- a/tests/swmm-nrtestsuite/benchmark/swmm-5112/user_2/user2.rpt +++ b/tests/swmm-nrtestsuite/benchmark/swmm-5112/user_2/user2.rpt @@ -2443,6 +2443,6 @@ TW09011 0.40 0.47 0.57 0.05 0.08 - Analysis begun on: Tue Feb 06 10:57:13 2018 - Analysis ended on: Tue Feb 06 10:57:19 2018 - Total elapsed time: 00:00:06 \ No newline at end of file + Analysis begun on: Fri Mar 09 15:35:28 2018 + Analysis ended on: Fri Mar 09 15:35:33 2018 + Total elapsed time: 00:00:05 \ No newline at end of file diff --git a/tests/swmm-nrtestsuite/benchmark/swmm-5112/user_3/user3.rpt b/tests/swmm-nrtestsuite/benchmark/swmm-5112/user_3/user3.rpt index 0439f88d4..4339cbef8 100644 --- a/tests/swmm-nrtestsuite/benchmark/swmm-5112/user_3/user3.rpt +++ b/tests/swmm-nrtestsuite/benchmark/swmm-5112/user_3/user3.rpt @@ -34,7 +34,7 @@ Routing Time Step ........ 0.50 sec Variable Time Step ....... NO Maximum Trials ........... 8 - Number of Threads ........ 32 + Number of Threads ........ 1 Head Tolerance ........... 0.001524 m @@ -1256,6 +1256,6 @@ PUMP5@CMRYCOR-I-CMRYCSO 95.73 1 0.00 0.31 1.35 6.335 6.69 0.0 0.0 - Analysis begun on: Tue Feb 06 10:57:19 2018 - Analysis ended on: Tue Feb 06 10:57:29 2018 - Total elapsed time: 00:00:10 \ No newline at end of file + Analysis begun on: Fri Mar 09 15:35:34 2018 + Analysis ended on: Fri Mar 09 15:35:49 2018 + Total elapsed time: 00:00:15 \ No newline at end of file diff --git a/tests/swmm-nrtestsuite/benchmark/swmm-5112/user_4/user4.rpt b/tests/swmm-nrtestsuite/benchmark/swmm-5112/user_4/user4.rpt index 2e839e9b0..805ba61e1 100644 --- a/tests/swmm-nrtestsuite/benchmark/swmm-5112/user_4/user4.rpt +++ b/tests/swmm-nrtestsuite/benchmark/swmm-5112/user_4/user4.rpt @@ -829,7 +829,7 @@ Routing Time Step ........ 5.00 sec Variable Time Step ....... NO Maximum Trials ........... 8 - Number of Threads ........ 32 + Number of Threads ........ 1 Head Tolerance ........... 0.005000 ft @@ -1928,6 +1928,6 @@ 23810025-23810024 0.01 0.01 0.01 0.02 0.01 - Analysis begun on: Tue Feb 06 10:57:30 2018 - Analysis ended on: Tue Feb 06 10:57:35 2018 - Total elapsed time: 00:00:05 \ No newline at end of file + Analysis begun on: Fri Mar 09 15:35:49 2018 + Analysis ended on: Fri Mar 09 15:36:01 2018 + Total elapsed time: 00:00:12 \ No newline at end of file diff --git a/tests/swmm-nrtestsuite/benchmark/swmm-5112/user_5/user5.rpt b/tests/swmm-nrtestsuite/benchmark/swmm-5112/user_5/user5.rpt index d5c97ce10..2f2499c3a 100644 --- a/tests/swmm-nrtestsuite/benchmark/swmm-5112/user_5/user5.rpt +++ b/tests/swmm-nrtestsuite/benchmark/swmm-5112/user_5/user5.rpt @@ -7319,7 +7319,7 @@ Routing Time Step ........ 0.50 sec Variable Time Step ....... NO Maximum Trials ........... 8 - Number of Threads ........ 32 + Number of Threads ........ 1 Head Tolerance ........... 0.005000 ft @@ -8655,6 +8655,6 @@ Brad_Out 1.88 3.83 1.99 2.01 1.47 - Analysis begun on: Tue Feb 06 10:57:35 2018 - Analysis ended on: Tue Feb 06 10:57:43 2018 - Total elapsed time: 00:00:08 \ No newline at end of file + Analysis begun on: Fri Mar 09 15:36:02 2018 + Analysis ended on: Fri Mar 09 15:36:29 2018 + Total elapsed time: 00:00:27 \ No newline at end of file diff --git a/tests/swmm-nrtestsuite/tests/examples/Example1.inp b/tests/swmm-nrtestsuite/tests/examples/Example1.inp index 3ad096315..4e54ae698 100644 --- a/tests/swmm-nrtestsuite/tests/examples/Example1.inp +++ b/tests/swmm-nrtestsuite/tests/examples/Example1.inp @@ -37,7 +37,7 @@ HEAD_TOLERANCE 0 SYS_FLOW_TOL 5 LAT_FLOW_TOL 5 ;MINIMUM_STEP 0.5 -;THREADS 1 +THREADS 1 [EVAPORATION] ;;Data Source Parameters diff --git a/tests/swmm-nrtestsuite/tests/examples/Example2.inp b/tests/swmm-nrtestsuite/tests/examples/Example2.inp index 8535cdf21..99a4bb1b7 100644 --- a/tests/swmm-nrtestsuite/tests/examples/Example2.inp +++ b/tests/swmm-nrtestsuite/tests/examples/Example2.inp @@ -22,6 +22,7 @@ LENGTHENING_STEP 0 MIN_SURFAREA 0 COMPATIBILITY 5 + THREADS 1 [JUNCTIONS] ;; Invert Max. Init. Surcharge Ponded diff --git a/tests/swmm-nrtestsuite/tests/examples/Example3.inp b/tests/swmm-nrtestsuite/tests/examples/Example3.inp index 9e79606b2..f9a807c9d 100644 --- a/tests/swmm-nrtestsuite/tests/examples/Example3.inp +++ b/tests/swmm-nrtestsuite/tests/examples/Example3.inp @@ -24,7 +24,8 @@ LENGTHENING_STEP 0 MIN_SURFAREA 0 COMPATIBILITY 5 - + THREADS 1 + [JUNCTIONS] ;; Invert Max. Init. Surcharge Ponded ;;Name Elev. Depth Depth Depth Area diff --git a/tests/swmm-nrtestsuite/tests/examples/Example4.inp b/tests/swmm-nrtestsuite/tests/examples/Example4.inp index ac846e64c..913398ad9 100644 --- a/tests/swmm-nrtestsuite/tests/examples/Example4.inp +++ b/tests/swmm-nrtestsuite/tests/examples/Example4.inp @@ -28,6 +28,7 @@ SKIP_STEADY_STATE NO FORCE_MAIN_EQUATION H-W LINK_OFFSETS DEPTH MIN_SLOPE 0 +THREADS 1 [EVAPORATION] ;;Type Parameters diff --git a/tests/swmm-nrtestsuite/tests/examples/Example5.inp b/tests/swmm-nrtestsuite/tests/examples/Example5.inp index 8deba4ad7..db7879a6d 100644 --- a/tests/swmm-nrtestsuite/tests/examples/Example5.inp +++ b/tests/swmm-nrtestsuite/tests/examples/Example5.inp @@ -37,6 +37,7 @@ MAX_TRIALS 8 HEAD_TOLERANCE 0.005 SYS_FLOW_TOL 5 LAT_FLOW_TOL 5 +THREADS 1 [EVAPORATION] ;;Evap Data Parameters diff --git a/tests/swmm-nrtestsuite/tests/examples/Example6.inp b/tests/swmm-nrtestsuite/tests/examples/Example6.inp index 797fcf085..0e3bcb836 100644 --- a/tests/swmm-nrtestsuite/tests/examples/Example6.inp +++ b/tests/swmm-nrtestsuite/tests/examples/Example6.inp @@ -39,7 +39,7 @@ HEAD_TOLERANCE 0.005 SYS_FLOW_TOL 5 LAT_FLOW_TOL 5 ;MINIMUM_STEP 0.5 -;THREADS 1 +THREADS 1 [EVAPORATION] ;;Data Source Parameters diff --git a/tests/swmm-nrtestsuite/tests/extran/extran1.inp b/tests/swmm-nrtestsuite/tests/extran/extran1.inp index 34404cf36..a185aee27 100644 --- a/tests/swmm-nrtestsuite/tests/extran/extran1.inp +++ b/tests/swmm-nrtestsuite/tests/extran/extran1.inp @@ -28,6 +28,7 @@ SKIP_STEADY_STATE NO IGNORE_RAINFALL NO FORCE_MAIN_EQUATION D-W LINK_OFFSETS DEPTH +THREADS 1 [JUNCTIONS] ;; Invert Max. Init. Surcharge Ponded diff --git a/tests/swmm-nrtestsuite/tests/extran/extran10.inp b/tests/swmm-nrtestsuite/tests/extran/extran10.inp index 41600eb95..c5a6c7210 100644 --- a/tests/swmm-nrtestsuite/tests/extran/extran10.inp +++ b/tests/swmm-nrtestsuite/tests/extran/extran10.inp @@ -26,6 +26,7 @@ MIN_SURFAREA 0 NORMAL_FLOW_LIMITED BOTH SKIP_STEADY_STATE NO + THREADS 1 [OUTFALLS] ;; Invert Outfall Stage/Table Tide diff --git a/tests/swmm-nrtestsuite/tests/extran/extran2.inp b/tests/swmm-nrtestsuite/tests/extran/extran2.inp index d9ff17b1b..8b8c9b722 100644 --- a/tests/swmm-nrtestsuite/tests/extran/extran2.inp +++ b/tests/swmm-nrtestsuite/tests/extran/extran2.inp @@ -25,7 +25,8 @@ LENGTHENING_STEP 0 MIN_SURFAREA 0 NORMAL_FLOW_LIMITED BOTH - + THREADS 1 + [JUNCTIONS] ;; Invert Max. Init. Surcharge Ponded ;;Name Elev. Depth Depth Depth Area diff --git a/tests/swmm-nrtestsuite/tests/extran/extran3.inp b/tests/swmm-nrtestsuite/tests/extran/extran3.inp index 4babaa755..0a6dee2d9 100644 --- a/tests/swmm-nrtestsuite/tests/extran/extran3.inp +++ b/tests/swmm-nrtestsuite/tests/extran/extran3.inp @@ -26,6 +26,8 @@ Sump Orifice MIN_SURFAREA 0 NORMAL_FLOW_LIMITED BOTH SKIP_STEADY_STATE NO + THREADS 1 + [JUNCTIONS] ;; Invert Max. Init. Surcharge Ponded diff --git a/tests/swmm-nrtestsuite/tests/extran/extran4.inp b/tests/swmm-nrtestsuite/tests/extran/extran4.inp index d207087fc..e38017061 100644 --- a/tests/swmm-nrtestsuite/tests/extran/extran4.inp +++ b/tests/swmm-nrtestsuite/tests/extran/extran4.inp @@ -25,7 +25,8 @@ Weir LENGTHENING_STEP 0 MIN_SURFAREA 0 NORMAL_FLOW_LIMITED BOTH - + THREADS 1 + [JUNCTIONS] ;; Invert Max. Init. Surcharge Ponded ;;Name Elev. Depth Depth Depth Area diff --git a/tests/swmm-nrtestsuite/tests/extran/extran5.inp b/tests/swmm-nrtestsuite/tests/extran/extran5.inp index 57e03cc64..a267353a7 100644 --- a/tests/swmm-nrtestsuite/tests/extran/extran5.inp +++ b/tests/swmm-nrtestsuite/tests/extran/extran5.inp @@ -26,6 +26,8 @@ Storage + Side Orifice MIN_SURFAREA 0 NORMAL_FLOW_LIMITED BOTH SKIP_STEADY_STATE NO + THREADS 1 + [JUNCTIONS] ;; Invert Max. Init. Surcharge Ponded diff --git a/tests/swmm-nrtestsuite/tests/extran/extran6.inp b/tests/swmm-nrtestsuite/tests/extran/extran6.inp index 32c4e7eda..bab62e78e 100644 --- a/tests/swmm-nrtestsuite/tests/extran/extran6.inp +++ b/tests/swmm-nrtestsuite/tests/extran/extran6.inp @@ -26,6 +26,8 @@ Type 1 Pump MIN_SURFAREA 0 NORMAL_FLOW_LIMITED BOTH SKIP_STEADY_STATE NO + THREADS 1 + [JUNCTIONS] ;; Invert Max. Init. Surcharge Ponded diff --git a/tests/swmm-nrtestsuite/tests/extran/extran7.inp b/tests/swmm-nrtestsuite/tests/extran/extran7.inp index 495d0eb2d..78755371c 100644 --- a/tests/swmm-nrtestsuite/tests/extran/extran7.inp +++ b/tests/swmm-nrtestsuite/tests/extran/extran7.inp @@ -26,6 +26,7 @@ Type 2 Pump MIN_SURFAREA 0 NORMAL_FLOW_LIMITED BOTH SKIP_STEADY_STATE NO + THREADS 1 [JUNCTIONS] ;; Invert Max. Init. Surcharge Ponded diff --git a/tests/swmm-nrtestsuite/tests/extran/extran8a.inp b/tests/swmm-nrtestsuite/tests/extran/extran8a.inp index dd996af77..4fc466947 100644 --- a/tests/swmm-nrtestsuite/tests/extran/extran8a.inp +++ b/tests/swmm-nrtestsuite/tests/extran/extran8a.inp @@ -26,6 +26,7 @@ MIN_SURFAREA 0 NORMAL_FLOW_LIMITED BOTH SKIP_STEADY_STATE NO + THREADS 1 [FILES] SAVE HOTSTART "extran8.hsf" diff --git a/tests/swmm-nrtestsuite/tests/extran/extran8b.inp b/tests/swmm-nrtestsuite/tests/extran/extran8b.inp index 7604e424b..6c05e62aa 100644 --- a/tests/swmm-nrtestsuite/tests/extran/extran8b.inp +++ b/tests/swmm-nrtestsuite/tests/extran/extran8b.inp @@ -26,7 +26,8 @@ MIN_SURFAREA 0 NORMAL_FLOW_LIMITED BOTH SKIP_STEADY_STATE NO - + THREADS 1 + [FILES] USE HOTSTART "extran8b.hsf" diff --git a/tests/swmm-nrtestsuite/tests/extran/extran9.inp b/tests/swmm-nrtestsuite/tests/extran/extran9.inp index 5c69ee822..73d963608 100644 --- a/tests/swmm-nrtestsuite/tests/extran/extran9.inp +++ b/tests/swmm-nrtestsuite/tests/extran/extran9.inp @@ -26,7 +26,8 @@ MIN_SURFAREA 0 NORMAL_FLOW_LIMITED BOTH SKIP_STEADY_STATE NO - + THREADS 1 + [OUTFALLS] ;; Invert Outfall Stage/Table Tide ;;Name Elev. Type Time Series Gate diff --git a/tests/swmm-nrtestsuite/tests/routing/test1.inp b/tests/swmm-nrtestsuite/tests/routing/test1.inp index 6d1e22fd1..88c51e0ad 100644 --- a/tests/swmm-nrtestsuite/tests/routing/test1.inp +++ b/tests/swmm-nrtestsuite/tests/routing/test1.inp @@ -26,7 +26,8 @@ FLAT SLOPE EXAMPLE MIN_SURFAREA 0 NORMAL_FLOW_LIMITED BOTH SKIP_STEADY_STATE NO - + THREADS 1 + [JUNCTIONS] ;; Invert Max. Init. Surcharge Ponded ;;Name Elev. Depth Depth Depth Area diff --git a/tests/swmm-nrtestsuite/tests/routing/test2.inp b/tests/swmm-nrtestsuite/tests/routing/test2.inp index 6d33a1673..c1276d3ca 100644 --- a/tests/swmm-nrtestsuite/tests/routing/test2.inp +++ b/tests/swmm-nrtestsuite/tests/routing/test2.inp @@ -29,6 +29,7 @@ SKIP_STEADY_STATE NO IGNORE_RAINFALL NO FORCE_MAIN_EQUATION D-W LINK_OFFSETS DEPTH +THREADS 1 [JUNCTIONS] ;; Invert Max. Init. Surcharge Ponded diff --git a/tests/swmm-nrtestsuite/tests/routing/test3.inp b/tests/swmm-nrtestsuite/tests/routing/test3.inp index 7f63507a2..4f0231b7e 100644 --- a/tests/swmm-nrtestsuite/tests/routing/test3.inp +++ b/tests/swmm-nrtestsuite/tests/routing/test3.inp @@ -26,7 +26,8 @@ DROP WITH SURCHARGE EXAMPLE MIN_SURFAREA 0 NORMAL_FLOW_LIMITED BOTH SKIP_STEADY_STATE NO - + THREADS 1 + [JUNCTIONS] ;; Invert Max. Init. Surcharge Ponded ;;Name Elev. Depth Depth Depth Area diff --git a/tests/swmm-nrtestsuite/tests/routing/test4.inp b/tests/swmm-nrtestsuite/tests/routing/test4.inp index 92e97f040..3aa073968 100644 --- a/tests/swmm-nrtestsuite/tests/routing/test4.inp +++ b/tests/swmm-nrtestsuite/tests/routing/test4.inp @@ -26,7 +26,8 @@ INVERTED SIPHON EXAMPLE MIN_SURFAREA 0 NORMAL_FLOW_LIMITED BOTH SKIP_STEADY_STATE NO - + THREADS 1 + [JUNCTIONS] ;; Invert Max. Init. Surcharge Ponded ;;Name Elev. Depth Depth Depth Area diff --git a/tests/swmm-nrtestsuite/tests/routing/test5.inp b/tests/swmm-nrtestsuite/tests/routing/test5.inp index 8edda03fd..7d79ffbf5 100644 --- a/tests/swmm-nrtestsuite/tests/routing/test5.inp +++ b/tests/swmm-nrtestsuite/tests/routing/test5.inp @@ -26,6 +26,7 @@ UPSTREAM OFFSETS EXAMPLE MIN_SURFAREA 0 NORMAL_FLOW_LIMITED BOTH SKIP_STEADY_STATE NO + THREADS 1 [JUNCTIONS] ;; Invert Max. Init. Surcharge Ponded diff --git a/tests/swmm-nrtestsuite/tests/user/user1.inp b/tests/swmm-nrtestsuite/tests/user/user1.inp index f6d2a513c..83834e046 100644 --- a/tests/swmm-nrtestsuite/tests/user/user1.inp +++ b/tests/swmm-nrtestsuite/tests/user/user1.inp @@ -25,7 +25,8 @@ TEST PROBLEM USER1 MIN_SURFAREA 12.566 NORMAL_FLOW_LIMITED BOTH SKIP_STEADY_STATE NO - + THREADS 1 + [EVAPORATION] ;;Type Parameters ;;----------------------- diff --git a/tests/swmm-nrtestsuite/tests/user/user2.inp b/tests/swmm-nrtestsuite/tests/user/user2.inp index 29191ecf8..b3c07a2c6 100644 --- a/tests/swmm-nrtestsuite/tests/user/user2.inp +++ b/tests/swmm-nrtestsuite/tests/user/user2.inp @@ -25,7 +25,8 @@ EXAMPLE USER2 MIN_SURFAREA 12.0 NORMAL_FLOW_LIMITED BOTH SKIP_STEADY_STATE NO - + THREADS 1 + [EVAPORATION] ;;Type Parameters ;;----------------------- diff --git a/tests/swmm-nrtestsuite/tests/user/user3.inp b/tests/swmm-nrtestsuite/tests/user/user3.inp index 2cbf5b3f6..be3134536 100644 --- a/tests/swmm-nrtestsuite/tests/user/user3.inp +++ b/tests/swmm-nrtestsuite/tests/user/user3.inp @@ -25,7 +25,8 @@ Example User3 MIN_SURFAREA 0 NORMAL_FLOW_LIMITED BOTH SKIP_STEADY_STATE NO - + THREADS 1 + [EVAPORATION] ;;Type Parameters ;;----------------------- diff --git a/tests/swmm-nrtestsuite/tests/user/user4.inp b/tests/swmm-nrtestsuite/tests/user/user4.inp index 5cf91eb47..744b67458 100644 --- a/tests/swmm-nrtestsuite/tests/user/user4.inp +++ b/tests/swmm-nrtestsuite/tests/user/user4.inp @@ -25,7 +25,8 @@ Example User4 MIN_SURFAREA 12.556 NORMAL_FLOW_LIMITED BOTH SKIP_STEADY_STATE NO - + THREADS 1 + [EVAPORATION] ;;Type Parameters ;;----------------------- diff --git a/tests/swmm-nrtestsuite/tests/user/user5.inp b/tests/swmm-nrtestsuite/tests/user/user5.inp index 26081c86b..64b197f34 100644 --- a/tests/swmm-nrtestsuite/tests/user/user5.inp +++ b/tests/swmm-nrtestsuite/tests/user/user5.inp @@ -25,7 +25,8 @@ Example User5 MIN_SURFAREA 0 NORMAL_FLOW_LIMITED BOTH SKIP_STEADY_STATE NO - + THREADS 1 + [EVAPORATION] ;;Type Parameters ;;----------------------- From 6eb28fc6ccd7a93b7ffc65dcc5c7c5fa99f343dd Mon Sep 17 00:00:00 2001 From: "Bryant E. McDonnell" Date: Fri, 9 Mar 2018 16:42:50 -0500 Subject: [PATCH 40/57] Reverted system totalizers to original from 5.1.12 --- src/routing.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/routing.c b/src/routing.c index 038daf624..55b9592dc 100644 --- a/src/routing.c +++ b/src/routing.c @@ -804,7 +804,7 @@ void removeOutflows(double tStep) // --- update mass balance with flow and mass leaving the system // through outfalls and flooded interior nodes q = node_getSystemOutflow(i, &isFlooded); - if ( q > 0.0 ) + if ( q != 0.0 ) { massbal_addOutflowFlow(q, isFlooded); for ( p = 0; p < Nobjects[POLLUT]; p++ ) @@ -813,7 +813,6 @@ void removeOutflows(double tStep) massbal_addOutflowQual(p, w, isFlooded); } } - else massbal_addInflowFlow(EXTERNAL_INFLOW, -q); // --- update mass balance with mass leaving system through negative // lateral inflows (lateral flow was previously accounted for) From 01638a690e81280a3d7834a5f4e2c3c36da9740c Mon Sep 17 00:00:00 2001 From: "Bryant E. McDonnell" Date: Fri, 9 Mar 2018 17:32:28 -0500 Subject: [PATCH 41/57] License File Update For Github --- LICENSE.txt => LICENSE | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename LICENSE.txt => LICENSE (100%) diff --git a/LICENSE.txt b/LICENSE similarity index 100% rename from LICENSE.txt rename to LICENSE index 61f7a065a..da29ff7ab 100644 --- a/LICENSE.txt +++ b/LICENSE @@ -1,7 +1,7 @@ -Contains public domain works. Other works copyright the AUTHORS - MIT-License +Contains public domain works. Other works copyright the AUTHORS + Copyright (c) 2016 (see AUTHORS.txt). Permission is hereby granted, free of charge, to any person obtaining a copy From 60cd9589f3bdbfe00e5d1ccda49f76beab75c26d Mon Sep 17 00:00:00 2001 From: "Bryant E. McDonnell" Date: Fri, 9 Mar 2018 17:34:02 -0500 Subject: [PATCH 42/57] License File Format --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index da29ff7ab..f5b4528fb 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -MIT-License +MIT License Contains public domain works. Other works copyright the AUTHORS From 3ceb7665072575de4a87604fdf1b782d09f43c13 Mon Sep 17 00:00:00 2001 From: "Bryant E. McDonnell" Date: Fri, 9 Mar 2018 17:45:04 -0500 Subject: [PATCH 43/57] Removed Recipe --- conda.recipe/bld.bat | 17 ------------- conda.recipe/build.sh | 14 ----------- conda.recipe/meta.yaml | 55 ------------------------------------------ 3 files changed, 86 deletions(-) delete mode 100644 conda.recipe/bld.bat delete mode 100644 conda.recipe/build.sh delete mode 100644 conda.recipe/meta.yaml diff --git a/conda.recipe/bld.bat b/conda.recipe/bld.bat deleted file mode 100644 index 1212c468c..000000000 --- a/conda.recipe/bld.bat +++ /dev/null @@ -1,17 +0,0 @@ -setlocal EnableDelayedExpansion - -:: Make a build folder and change to it. -mkdir build -cd build - -:: Configure using the CMakeFiles -%LIBRARY_BIN%\cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX:PATH="%LIBRARY_PREFIX%" -DCMAKE_BUILD_TYPE:STRING=Release .. -if errorlevel 1 exit 1 - -:: Build! -nmake -if errorlevel 1 exit 1 - -:: Install! -nmake install -if errorlevel 1 exit 1 diff --git a/conda.recipe/build.sh b/conda.recipe/build.sh deleted file mode 100644 index 7b69317b2..000000000 --- a/conda.recipe/build.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -# Make build directory and change to it -mkdir build -cd build - -# Configure using the CMakeFiles -cmake -DCMAKE_INSTALL_PREFIX=$PREFIX -DCMAKE_BUILD_TYPE:STRING=Release .. - -# Build -make -j $CPU_COUNT - -# Install -make install diff --git a/conda.recipe/meta.yaml b/conda.recipe/meta.yaml deleted file mode 100644 index 01ced5bdd..000000000 --- a/conda.recipe/meta.yaml +++ /dev/null @@ -1,55 +0,0 @@ -{% set name = "libswmm" %} -{% set version = "5.2.0.dev0" %} - -package: - name: {{ name|lower }} - version: {{ version }} - -source: - git_url: ../ - git_tag: HEAD - -build: - number: {{ environ.get('GIT_DESCRIBE_NUMBER', 0) }} - features: - - vc9 # [win and py27] - - vc10 # [win and py34] - - vc14 # [win and py>=35] - -requirements: - build: - - cmake - - gcc # [unix] - - python # [win] - - vc 9 # [win and py27] - - vc 10 # [win and py34] - - vc 14 # [win and py>=35] - run: - - libgcc # [unix] - - vc 9 # [win and py27] - - vc 10 # [win and py34] - - vc 14 # [win and py>=35] - -test: - commands: - - run-swmm --help - - run-swmm --version - -about: - home: https://github.com/OpenWaterAnalytics/Stormwater-Management-Model - license_family: MIT - license: MIT - license_file: LICENSE.txt - summary: ORD Stormwater Management Model (aka SWMM). - description: | - SWMM is a dynamic hydrology-hydraulic water quality simulation model. - It is used for single event or long-term (continuous) simulation of - runoff quantity and quality from primarily urban areas. SWMM source - code is written in the C Programming Language and released in the - Public Domain. - dev_url: https://github.com/OpenWaterAnalytics/Stormwater-Management-Model - -extra: - recipe-maintainers: - - goanpeca - - bemcdonnell From fc2df226c1e5c1dfec62b1d75b3e62bc99dd8017 Mon Sep 17 00:00:00 2001 From: Abhi Date: Sat, 10 Mar 2018 01:06:05 -0500 Subject: [PATCH 44/57] Fixed rain api --- src/gage.c | 153 +++++++++++++++++++++++------------------------ src/objects.h | 2 +- src/toolkitAPI.c | 11 +++- 3 files changed, 85 insertions(+), 81 deletions(-) diff --git a/src/gage.c b/src/gage.c index 694c01955..2ac404b28 100644 --- a/src/gage.c +++ b/src/gage.c @@ -335,59 +335,51 @@ void gage_setState(int j, DateTime t) return; } - if (Gage[j].dataSource == RAIN_API) + // --- otherwise march through rainfall record until date t is bracketed + t += OneSecond; + for (;;) { - Gage[j].rainfall = Gage[j].externalRain; - return; - } - else - { - // --- otherwise march through rainfall record until date t is bracketed - t += OneSecond; - for (;;) - { - // --- no rainfall if no interval start date - if ( Gage[j].startDate == NO_DATE ) - { - Gage[j].rainfall = 0.0; - return; - } - - // --- no rainfall if time is before interval start date - if ( t < Gage[j].startDate ) - { - Gage[j].rainfall = 0.0; - return; - } - - // --- use current rainfall if time is before interval end date - if ( t < Gage[j].endDate ) - { - return; - } - - // --- no rainfall if t >= interval end date & no next interval exists - if ( Gage[j].nextDate == NO_DATE) - { - Gage[j].rainfall = 0.0; - return; - } - - // --- no rainfall if t > interval end date & < next interval date - if ( t < Gage[j].nextDate ) - { - Gage[j].rainfall = 0.0; - return; - } - - // --- otherwise update next rainfall interval date - Gage[j].startDate = Gage[j].nextDate; - Gage[j].endDate = datetime_addSeconds(Gage[j].startDate, - Gage[j].rainInterval); - Gage[j].rainfall = Gage[j].nextRainfall; - - if ( !getNextRainfall(j) ) Gage[j].nextDate = NO_DATE; - } + // --- no rainfall if no interval start date + if ( Gage[j].startDate == NO_DATE ) + { + Gage[j].rainfall = 0.0; + return; + } + + // --- no rainfall if time is before interval start date + if ( t < Gage[j].startDate ) + { + Gage[j].rainfall = 0.0; + return; + } + + // --- use current rainfall if time is before interval end date + if ( t < Gage[j].endDate ) + { + return; + } + + // --- no rainfall if t >= interval end date & no next interval exists + if ( Gage[j].nextDate == NO_DATE) + { + Gage[j].rainfall = 0.0; + return; + } + + // --- no rainfall if t > interval end date & < next interval date + if ( t < Gage[j].nextDate ) + { + Gage[j].rainfall = 0.0; + return; + } + + // --- otherwise update next rainfall interval date + Gage[j].startDate = Gage[j].nextDate; + Gage[j].endDate = datetime_addSeconds(Gage[j].startDate, + Gage[j].rainInterval); + Gage[j].rainfall = Gage[j].nextRainfall; + + if ( !getNextRainfall(j) ) Gage[j].nextDate = NO_DATE; } } @@ -541,35 +533,42 @@ int getNextRainfall(int j) double rNext; // next rain intensity (in/hr or mm/hr) Gage[j].nextRainfall = 0.0; - do + if (Gage[j].dataSource == RAIN_API) { - if ( Gage[j].dataSource == RAIN_FILE ) - { - if ( Frain.file && Gage[j].currentFilePos < Gage[j].endFilePos ) - { - fseek(Frain.file, Gage[j].currentFilePos, SEEK_SET); - fread(&Gage[j].nextDate, sizeof(DateTime), 1, Frain.file); - fread(&vNext, sizeof(float), 1, Frain.file); - Gage[j].currentFilePos = ftell(Frain.file); - rNext = convertRainfall(j, (double)vNext); - } - else return 0; - } + rNext = Gage[j].externalRain; + } + else + { + do + { + if ( Gage[j].dataSource == RAIN_FILE ) + { + if ( Frain.file && Gage[j].currentFilePos < Gage[j].endFilePos ) + { + fseek(Frain.file, Gage[j].currentFilePos, SEEK_SET); + fread(&Gage[j].nextDate, sizeof(DateTime), 1, Frain.file); + fread(&vNext, sizeof(float), 1, Frain.file); + Gage[j].currentFilePos = ftell(Frain.file); + rNext = convertRainfall(j, (double)vNext); + } + else return 0; + } - else if (Gage[j].dataSource == RAIN_TSERIES) - { - k = Gage[j].tSeries; - if ( k >= 0 ) - { - if ( !table_getNextEntry(&Tseries[k], - &Gage[j].nextDate, &rNext) ) return 0; - rNext = convertRainfall(j, rNext); - } - else return 0; - } + else if (Gage[j].dataSource == RAIN_TSERIES) + { + k = Gage[j].tSeries; + if ( k >= 0 ) + { + if ( !table_getNextEntry(&Tseries[k], + &Gage[j].nextDate, &rNext) ) return 0; + rNext = convertRainfall(j, rNext); + } + else return 0; + } - } while (rNext == 0.0); + } while (rNext == 0.0); + } Gage[j].nextRainfall = rNext; return 1; } diff --git a/src/objects.h b/src/objects.h index 98c444148..d6174412c 100644 --- a/src/objects.h +++ b/src/objects.h @@ -100,7 +100,7 @@ typedef struct typedef struct { char* ID; // raingage name - int externalRain; // rainfall-rate injected RAIN API + int externalRain; // rainfall-rate injected RAIN API int dataSource; // data from time series or file int tSeries; // rainfall data time series index char fname[MAXFNAME+1]; // name of rainfall data file diff --git a/src/toolkitAPI.c b/src/toolkitAPI.c index b4e481080..60ba174b5 100644 --- a/src/toolkitAPI.c +++ b/src/toolkitAPI.c @@ -1248,7 +1248,7 @@ int DLLEXPORT swmm_getSystemRunoffStats(SM_RunoffTotals *runoffTot) return(errorcode); } -int DLLEXPORT swmm_getGagePrecip(int index, double *value) +int DLLEXPORT swmm_getGagePrecip(int index, double *rainfall, double *snowfall, double *total) // // Input: index = Index of desired ID // Output: value = value to be output @@ -1269,7 +1269,9 @@ int DLLEXPORT swmm_getGagePrecip(int index, double *value) // Read the rainfall value else { - *value = Gage[index].rainfall / UCF(RAINFALL); + *rainfall = Gage[index].rainfall / UCF(RAINFALL); + *snowfall = 0.0; + *total = 0.0; } return(errcode); } @@ -1295,7 +1297,10 @@ int DLLEXPORT swmm_setGagePrecip(int index, double value) // Read the rainfall value else { - Gage[index].dataSource = RAIN_API; + if (Gage[index].dataSource != RAIN_API) + { + Gage[index].dataSource = RAIN_API; + } Gage[index].externalRain = value * UCF(RAINFALL); } return(errcode); From 05fde6faaf23e6f26f3fc882a61f852d7ddab9c2 Mon Sep 17 00:00:00 2001 From: Abhi Date: Sat, 10 Mar 2018 01:12:31 -0500 Subject: [PATCH 45/57] updated gage format --- src/gage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gage.c b/src/gage.c index 2ac404b28..b16bc0082 100644 --- a/src/gage.c +++ b/src/gage.c @@ -266,7 +266,7 @@ void gage_initState(int j) Gage[j].isUsed = FALSE; Gage[j].rainfall = 0.0; Gage[j].reportRainfall = 0.0; - // Rainfall API sets external rainfall rate + // --- rainfall api sets external rainfall rate Gage[j].externalRain = 0.0; if ( IgnoreRainfall ) return; From 9deab8b2e74bd6baf5dcd8c2bfb171fdf452a544 Mon Sep 17 00:00:00 2001 From: Abhi Date: Sat, 10 Mar 2018 01:22:29 -0500 Subject: [PATCH 46/57] updated toolkit api --- src/toolkitAPI.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/toolkitAPI.c b/src/toolkitAPI.c index 60ba174b5..c8520ffcd 100644 --- a/src/toolkitAPI.c +++ b/src/toolkitAPI.c @@ -1269,9 +1269,14 @@ int DLLEXPORT swmm_getGagePrecip(int index, double *rainfall, double *snowfall, // Read the rainfall value else { - *rainfall = Gage[index].rainfall / UCF(RAINFALL); + *rainfall = 0.0; *snowfall = 0.0; - *total = 0.0; + if ( !IgnoreSnowmelt && Temp.ta <= Snow.snotmp ) + { + *snowfall = Gage[j].rainfall * Gage[j].snowFactor / UCF(RAINFALL); + } + else *rainfall = Gage[j].rainfall / UCF(RAINFALL); + *total = (*rainfall) + (*snowfall); } return(errcode); } From 155d93cc598e2a135a5f8804ab9de8c78beb5c68 Mon Sep 17 00:00:00 2001 From: Abhi Date: Sat, 10 Mar 2018 01:24:13 -0500 Subject: [PATCH 47/57] updated toolkit api fix --- src/toolkitAPI.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/toolkitAPI.c b/src/toolkitAPI.c index c8520ffcd..b2c15b121 100644 --- a/src/toolkitAPI.c +++ b/src/toolkitAPI.c @@ -1273,9 +1273,9 @@ int DLLEXPORT swmm_getGagePrecip(int index, double *rainfall, double *snowfall, *snowfall = 0.0; if ( !IgnoreSnowmelt && Temp.ta <= Snow.snotmp ) { - *snowfall = Gage[j].rainfall * Gage[j].snowFactor / UCF(RAINFALL); + *snowfall = Gage[index].rainfall * Gage[index].snowFactor / UCF(RAINFALL); } - else *rainfall = Gage[j].rainfall / UCF(RAINFALL); + else *rainfall = Gage[index].rainfall / UCF(RAINFALL); *total = (*rainfall) + (*snowfall); } return(errcode); From dfbab7efac63195413285248b37a98b7f45a46f3 Mon Sep 17 00:00:00 2001 From: Abhi Date: Sat, 10 Mar 2018 09:32:29 -0500 Subject: [PATCH 48/57] Updated toolkitapi getPrecip --- src/toolkitAPI.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/toolkitAPI.c b/src/toolkitAPI.c index b2c15b121..5b38fdcf2 100644 --- a/src/toolkitAPI.c +++ b/src/toolkitAPI.c @@ -1269,14 +1269,7 @@ int DLLEXPORT swmm_getGagePrecip(int index, double *rainfall, double *snowfall, // Read the rainfall value else { - *rainfall = 0.0; - *snowfall = 0.0; - if ( !IgnoreSnowmelt && Temp.ta <= Snow.snotmp ) - { - *snowfall = Gage[index].rainfall * Gage[index].snowFactor / UCF(RAINFALL); - } - else *rainfall = Gage[index].rainfall / UCF(RAINFALL); - *total = (*rainfall) + (*snowfall); + *total = gage_getPrecip(index, rainfall, snowfall); } return(errcode); } From cb95728d120d1a7418fcc99ee84e88aeaa0011ca Mon Sep 17 00:00:00 2001 From: Abhi Date: Thu, 15 Mar 2018 11:20:48 -0400 Subject: [PATCH 49/57] Updated toolkitapi.h with rainapi functions --- include/toolkitAPI.h | 17 ++++++++++++++++- src/toolkitAPI.c | 4 ++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/include/toolkitAPI.h b/include/toolkitAPI.h index 3dcac3190..5e74577a3 100644 --- a/include/toolkitAPI.h +++ b/include/toolkitAPI.h @@ -569,6 +569,14 @@ int DLLEXPORT swmm_getLinkStats(int index, SM_LinkStats *linkStats); pre-allocated by the caller. @return Error code */ +int DLLEXPORT swmm_getGagePrecip(int index, double *rainfall, double *snowfall, double *total) + +/** +@brief Get rainfall information for a gage. +@param index The index of gage +@param[out] rainfall and snow associated with the gage. +@return Error code +*/ int DLLEXPORT swmm_getPumpStats(int index, SM_PumpStats *pumpStats); /** @@ -641,5 +649,12 @@ int DLLEXPORT swmm_setOutfallStage(int index, double stage); } // matches the linkage specification from above */ #endif +int DLLEXPORT swmm_setGagePrecip(int index, double value); -#endif \ No newline at end of file +/** + @brief Set an rainfall intensity to the gage. + @param index The gage index. + @param value The new rainfall intensity. + @return Error code + */ +#endif diff --git a/src/toolkitAPI.c b/src/toolkitAPI.c index 5b38fdcf2..7229f3f2a 100644 --- a/src/toolkitAPI.c +++ b/src/toolkitAPI.c @@ -1251,7 +1251,7 @@ int DLLEXPORT swmm_getSystemRunoffStats(SM_RunoffTotals *runoffTot) int DLLEXPORT swmm_getGagePrecip(int index, double *rainfall, double *snowfall, double *total) // // Input: index = Index of desired ID -// Output: value = value to be output +// Output: Rainfall intensity and snow for the gage // Return: API Error // Purpose: Gets the precipitaion value in the gage. { @@ -1277,7 +1277,7 @@ int DLLEXPORT swmm_getGagePrecip(int index, double *rainfall, double *snowfall, int DLLEXPORT swmm_setGagePrecip(int index, double value) // // Input: index = Index of desired ID -// value = value to be output +// value = rainfall intensity to be set // Return: API Error // Purpose: Sets the precipitation in from the external database { From 95ebfd651522c6f39d156d6781dce5c86cb5c2e9 Mon Sep 17 00:00:00 2001 From: Abhi Date: Thu, 15 Mar 2018 14:45:57 -0400 Subject: [PATCH 50/57] Updated function docstring and added ; --- include/toolkitAPI.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/include/toolkitAPI.h b/include/toolkitAPI.h index 5e74577a3..5bd19a6d4 100644 --- a/include/toolkitAPI.h +++ b/include/toolkitAPI.h @@ -569,7 +569,7 @@ int DLLEXPORT swmm_getLinkStats(int index, SM_LinkStats *linkStats); pre-allocated by the caller. @return Error code */ -int DLLEXPORT swmm_getGagePrecip(int index, double *rainfall, double *snowfall, double *total) +int DLLEXPORT swmm_getPumpStats(int index, SM_PumpStats *pumpStats); /** @brief Get rainfall information for a gage. @@ -577,7 +577,7 @@ int DLLEXPORT swmm_getGagePrecip(int index, double *rainfall, double *snowfall, @param[out] rainfall and snow associated with the gage. @return Error code */ -int DLLEXPORT swmm_getPumpStats(int index, SM_PumpStats *pumpStats); +int DLLEXPORT swmm_getGagePrecip(int index, double *rainfall, double *snowfall, double *total); /** @brief Get subcatchment statistics. @@ -645,16 +645,17 @@ int DLLEXPORT swmm_setNodeInflow(int index, double flowrate); */ int DLLEXPORT swmm_setOutfallStage(int index, double stage); +/** +@brief Set an rainfall intensity to the gage. +@param index The gage index. +@param value The new rainfall intensity. +@return Error code +*/ +int DLLEXPORT swmm_setGagePrecip(int index, double value); + #ifdef __cplusplus } // matches the linkage specification from above */ #endif -int DLLEXPORT swmm_setGagePrecip(int index, double value); -/** - @brief Set an rainfall intensity to the gage. - @param index The gage index. - @param value The new rainfall intensity. - @return Error code - */ #endif From a7ce9766b8817c1232238b973fbb1f042b9c604b Mon Sep 17 00:00:00 2001 From: Abhi Date: Thu, 15 Mar 2018 15:41:52 -0400 Subject: [PATCH 51/57] updated docstring for toolkitapi --- include/toolkitAPI.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/toolkitAPI.h b/include/toolkitAPI.h index 5bd19a6d4..b8de96734 100644 --- a/include/toolkitAPI.h +++ b/include/toolkitAPI.h @@ -572,9 +572,11 @@ int DLLEXPORT swmm_getLinkStats(int index, SM_LinkStats *linkStats); int DLLEXPORT swmm_getPumpStats(int index, SM_PumpStats *pumpStats); /** -@brief Get rainfall information for a gage. +@brief Get rainfall rates for a gage. @param index The index of gage -@param[out] rainfall and snow associated with the gage. +@param[out] rainfall rainfall rate +@param[out] snowfall snowfall rate +@param[out] total total precipitation rate @return Error code */ int DLLEXPORT swmm_getGagePrecip(int index, double *rainfall, double *snowfall, double *total); From 6bb4062b7718af85f68466683d0533293c1106ea Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Thu, 15 Mar 2018 16:02:53 -0400 Subject: [PATCH 52/57] Updating Appveyor to use swmm-output binary wheel --- appveyor.yml | 21 ++++++++------------- tools/nrtest-swmm/setup.py | 2 +- tools/requirements-appveyor.txt | 18 ++++++++++++++++++ tools/swmm-output/setup.py | 2 +- 4 files changed, 28 insertions(+), 15 deletions(-) create mode 100644 tools/requirements-appveyor.txt diff --git a/appveyor.yml b/appveyor.yml index 504239e90..c4a226ae7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -78,27 +78,22 @@ init: - echo %BOOST_LIB% install: - # Install SWIG using chocolatey - - choco install swig - - swig -version - # `C:\Python27` (x86) is default on path for `python` command - - python --version + # Install nrtest and dependencies for regression tests + - python -m pip install -r tools\requirements-appveyor.txt before_build: + - mkdir %BUILD_HOME% + - cd %BUILD_HOME% - cmake -G %GENERATOR% -DBOOST_ROOT="%BOOST_ROOT%" -DBOOST_LIBRARYDIR="%BOOST_LIB%" -DBoost_USE_STATIC_LIBS="ON" - -DCMAKE_INSTALL_PREFIX:PATH=%BUILD_HOME% -DCMAKE_BUILD_TYPE:STRING=Release build_script: - cmake --build . --config Release before_test: - # Install nrtest and dependencies for regression tests - - python -m pip install --src %BUILD_HOME%\packages -r tools\requirements.txt - # - cd %SWMM_HOME% - tools\gen-config.cmd %SWMM_HOME%\bin\Release > %TEST_HOME%\apps\swmm-%APPVEYOR_REPO_COMMIT%.json @@ -106,10 +101,10 @@ test_script: # run unit tests - cd %SWMM_HOME%\tests - ctest -C Release + # Run regression tests - cd %SWMM_HOME% - # Run regression tests - tools\run-nrtest.cmd %NRTEST_SCRIPT% %TEST_HOME% %APPVEYOR_REPO_COMMIT% -cache: - - C:\ProgramData\chocolatey\bin -> appveyor.yml - - C:\ProgramData\chocolatey\lib -> appveyor.yml +#cache: +# - C:\ProgramData\chocolatey\bin -> appveyor.yml +# - C:\ProgramData\chocolatey\lib -> appveyor.yml diff --git a/tools/nrtest-swmm/setup.py b/tools/nrtest-swmm/setup.py index 46d6cb69c..596b71278 100644 --- a/tools/nrtest-swmm/setup.py +++ b/tools/nrtest-swmm/setup.py @@ -38,7 +38,7 @@ 'header_detail_footer>=2.3', 'nrtest>=0.2.0', 'numpy>=1.7.0', - 'swmm_output>=1.0.0', + 'swmm_output', ], keywords='nrtest_swmm' ) diff --git a/tools/requirements-appveyor.txt b/tools/requirements-appveyor.txt new file mode 100644 index 000000000..27af6d73c --- /dev/null +++ b/tools/requirements-appveyor.txt @@ -0,0 +1,18 @@ +# +# requirements-appveyor.txt +# +# Date Created: 3/15/2018 +# Author: Michael E. Tryby +# US EPA ORD/NRMRL +# +# Useful for configuring a python environment to run swmm-nrtestsuite. +# +# command: pip install -r tools/requirements-appveyor.txt +# + + +nrtest>=0.2.3 + +-f https://github.com/OpenWaterAnalytics/swmm-python/releases/download/v0.1.0-alpha/swmm_output-0.1.0a0-cp27-cp27m-win32.whl + +-e ./tools/nrtest-swmm diff --git a/tools/swmm-output/setup.py b/tools/swmm-output/setup.py index c55f1e949..cd7ff491e 100644 --- a/tools/swmm-output/setup.py +++ b/tools/swmm-output/setup.py @@ -20,7 +20,7 @@ setup( name = "swmm-output", - version = "1.0", + version = "0.1.0-alpha", ext_modules = [ Extension("_swmm_output", define_macros = [('swmm_output_EXPORTS', None)], From b8ed4c1a2b6eb86c94283ebe81083607291c26f2 Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Thu, 15 Mar 2018 16:10:01 -0400 Subject: [PATCH 53/57] Fixing typo --- appveyor.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index c4a226ae7..27bf41298 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -87,8 +87,7 @@ before_build: - cmake -G %GENERATOR% -DBOOST_ROOT="%BOOST_ROOT%" -DBOOST_LIBRARYDIR="%BOOST_LIB%" - -DBoost_USE_STATIC_LIBS="ON" - -DCMAKE_BUILD_TYPE:STRING=Release + -DBoost_USE_STATIC_LIBS="ON" .. build_script: - cmake --build . --config Release From 866b7553fb0e9de69b2f9bbe8b030a45b55d2a31 Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Thu, 15 Mar 2018 16:13:32 -0400 Subject: [PATCH 54/57] Fixing typo --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 27bf41298..819cff02f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -94,7 +94,7 @@ build_script: before_test: - cd %SWMM_HOME% - - tools\gen-config.cmd %SWMM_HOME%\bin\Release > %TEST_HOME%\apps\swmm-%APPVEYOR_REPO_COMMIT%.json + - tools\gen-config.cmd %SWMM_HOME%\%BUILD_HOME%\bin\Release > %TEST_HOME%\apps\swmm-%APPVEYOR_REPO_COMMIT%.json test_script: # run unit tests From c5177ae5dc3ed35b9a3782ad52aa8c74b2dd1c39 Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Thu, 15 Mar 2018 16:17:00 -0400 Subject: [PATCH 55/57] Fixing typo --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 819cff02f..cdaf6c1b6 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -98,7 +98,7 @@ before_test: test_script: # run unit tests - - cd %SWMM_HOME%\tests + - cd %BUILD_HOME%\tests - ctest -C Release # Run regression tests - cd %SWMM_HOME% From 3e73abc2b36d5a96d5e757b3911d9136b8174d41 Mon Sep 17 00:00:00 2001 From: "Bryant E. McDonnell" Date: Wed, 28 Mar 2018 21:18:41 -0400 Subject: [PATCH 56/57] Cleaned up contributing guides and removed old scripts --- .github/CONTRIBUTING.md | 201 +++++++++++++++------------------- src/Roadmap.txt | 189 -------------------------------- tools/build_and_upload.py | 31 ------ tools/run_regression_tests.py | 157 -------------------------- 4 files changed, 89 insertions(+), 489 deletions(-) delete mode 100644 src/Roadmap.txt delete mode 100644 tools/build_and_upload.py delete mode 100644 tools/run_regression_tests.py diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index d09022136..208b5384c 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -1,175 +1,152 @@ -# I. Setting up the development environment (This is a work in progress) +## Building OWA SWMM From Source on Windows +by Michael E. Tryby -The official windows compiler used for originally building SWMM was Visual Studio 2010 32 bits and as such is the recommended compiler on windows for current development. We are in the process of validating that other compilers on windows for different architecture and different operating systems results in the same results (Regression tests). +Created on: March 13, 2018 -If you are also testing the PySWMM wrapper for development, we advised to use Python 3.4 (32 bits) which uses the same compiler and hence provides full binary compatibility for SWMM -## A.) Windows +### Introduction -### Install Dependencies +Building OWA's fork of SWMM from source is a basic skill that all developers interested in contributing to the project should know how to perform. This document describes the build process step-by-step. You will learn -- Visual Studio C++ 10. Link to download -- Install CMake >= `` Link to download -- Python 3.4. Link to download -- Install the nrtest dependencies. Links to download +1. how to configure your machine to build the project locally; +2. how to obtain the project files using git; +3. how to use cmake to generate build files and build the project; and +4. how to use ctest and nrtest to perform unit and regression testing on the build artifacts produced. Be advised, you will need local admin privileges on your machine to follow this tutorial. Let’s begin! -### Building -To build SWMM then run: +### Dependencies -``` -$ cmake -G "Visual Studio " -DCMAKE_INSTALL_PREFIX:PATH=output -DCMAKE_BUILD_TYPE:STRING=Release -``` +Before the project can be built the required tools must be installed. The OWA SWMM project adheres to a platform compiler policy - for each platform there is a designated compiler. The platform compiler for Windows is Visual Studio cl, for Linux gcc, and for Mac OS clang. These instructions describe how to build SWMM on Windows. CMake is a cross platform build, testing, and packaging tool that is used to automate the SWMM build workflow. Boost is a free portable peer-reviewed C++ library. Unit tests are linked with Boost unit test libraries. Lastly, git is a free and open source distributed version control system. Git must be installed to obtain the project source code from the OWA SWMM repository found on GitHub. -### Running +### Summary of Dependencies +- Platform Compiler + - Windows: Visual Studio 10.0 32-bit cl (version 16.00.40219.01 for 80x86) +- CMake (version 3.0.0 or greater) +- Boost Libraries (version 1.58 or greater) +- git (version 2.6.0 or greater) -``` -$ run-swmm --help -``` -## B.) Linux +#### Step 1 - Install Dependencies +###### Install Visual Studio 2010 Express and SP1 -### Install Dependencies -- Build dependencies... gcc >= libgcc >= -- cmake -- Install the nrtest dependencies..... Links to download +Our current benchmark platform and compiler is Windows 32-bit Visual Studio 10 2010. Older versions of Visual Studio are available for download here: -#### On Debian (.deb) based systems you can use -``` -$ sudo apt install ... -``` +https://www.visualstudio.com/vs/older-downloads/ -#### On Centos (.rpm) based systems you can use +A service pack for Visual Studio 10 2010 is available here: -``` -$ sudo yum install ... -``` +https://www.microsoft.com/en-us/download/details.aspx?id=34677 -### Building +###### Install Boost -``` -$ cmake -DCMAKE_INSTALL_PREFIX=$PREFIX -DCMAKE_BUILD_TYPE:STRING=Release .. -$ make -j $CPU_COUNT -$ make install -``` +Boost binaries for Windows offer a convenient installation solution. Be sure to select for download the boost installer exe that corresponds to the version of Visual Studio you have installed. -### Running +https://sourceforge.net/projects/boost/files/boost-binaries/1.58.0/ -``` -$ run-swmm --help -``` +Although newer version of Boost are available, a link to Boost 1.58 is provided. This is the library version that the unit tests have been written against. Older versions of Boost may not work. The default install location for the Boost -## C.) OSX +Libraries is `C:\local\boost_1_58_0` -### InstallDependencies -- Clang version >= ??? or -- gcc version >= ??? -- cmake -- Install python and the nrtest dependencies..... Links to download or commands +###### Install Chocolatey, CMake, and git -#### If using Homebrew -``` -$ brew install ... -``` +Chocolatey is a Windows package manager that makes installing some of these dependencies a little easier. When working with Chocolatey it is useful to have local admin privileges. Chocolatey is available here: -### Building +https://chocolatey.org/install -``` -$ cmake -DCMAKE_INSTALL_PREFIX=$PREFIX -DCMAKE_BUILD_TYPE:STRING=Release .. -$ make -j $CPU_COUNT -$ make install -``` - -### Running +Once Chocolately is installed, from a command prompt running with admin privileges issue the following commands ``` -$ run-swmm --help +\>choco install -y cmake --installargs 'ADD_CMAKE_TO_PATH=User' +\>choco install -y git --installargs /GitOnlyOnPath +\>refreshenv ``` +###### Common Problems -# II. If you are developing for PySwmm - -If you are developing for PySwmm you need to install these versions to work with [how python is compiled](https://wiki.python.org/moin/WindowsCompilers) on different platforms: - -## A.) Windows - -### Python 2.7 -- Visual Studio C++ 9 for Python 2.7. Link to download -- Python 2.7. Link to download - -### Python 3.4 -- Visual Studio C++ 10 for Python 3.4. Link to download -- Python 3.4. Link to download. - -### Python 3.5 and 3.6 -- Visual Studio C++ 14 for Python 3.5 and 3.6. Link to download -- Python 3.5. Link to download -- Python 3.6. Link to download +Using chocolatey requires a command prompt with admin privileges. Check to make sure installed applications are on the command path. Make note of the Boost Library install location. -## B.) Linux +#### Step 2 - Build The Project -.... +As administrator open a Visual Studio 2010 Command Prompt. Change directories to the location where you wish to build the SWMM project. Now we will issue a series of commands to create a parent directory for the project root and clone the project from OWA's GitHub repository. -## C.) OSX +###### Clone the SWMM Repository -.... +``` +\>mkdir OWA +\>cd OWA +\>git clone https://github.com/OpenWaterAnalytics/Stormwater-Management-Model.git +\>cd Stormwater-Management-Model +``` +The present working directory is now the project root SWMM. The directory contains the same files that are visibly present in the GitHub Repo by browsing to the URL https://github.com/OpenWaterAnalytics/stormwater-management-model/tree/develop . -# III. Regression Testing +Now we will create a build products directory and generate the platform build file using cmake. -To execute regression tests run: +###### Generate the build files ``` -$ python +\>mkdir buildprod +\>cd buildprod +\>set BOOST_ROOT=C:\local\boost_1_58_0 +\>cmake -G "Visual Studio 10 2010" -DBOOST_ROOT="%BOOST_ROOT%" -DBoost_USE_STATIC_LIBS="ON" .. ``` -# IV. Unit tests +Now that the dependencies have been installed and the build system has been generated, building SWMM is a simple CMake command. -To execute unit tests run: +###### Build SWMM ``` -$ python +\>cmake --build . --config Debug ``` +###### Common Problems -# V. Contributing to the project +CMake may not be able to find the project CMakeLists.txt file or the Boost library install location. -## Git and Github +#### Step 3 - Testing -We use git and github for all development and any time you want to make a -contribution make sure to follow these steps. +Unit Testing uses Boost Unit Test library and CMake ctest as the test runner. Cmake has been configured to register tests with ctest as part of the build process. -### Step 1: Fork the repository -Make sure to fork the `https://github.com/OpenWaterAnalytics/Stormwater-Management-Model` -repo so that you now have on your local account `https://github.com//Stormwater-Management-Model` +###### Unit Testing -### Step 2: Add the original repo as remote - -On the terminal type: ``` -$ git remote add upstream https://github.com/OpenWaterAnalytics/Stormwater-Management-Model.git +\>cd tests +\>ctest -C Debug ``` -### Step 3: Make a branch from develop, make changes and push code +The unit tests run quietly. Ctest redirects stdout to a log file which can be found in the "tests\Testing\Temporary" folder. This is useful when a test fails. + +Regression testing is somewhat more complicated because it relies on Python to execute SWMM for each test and compare the binary files and report files. To run regression tests first python and any required packages must be installed. If Python is already installed on your local machine the installation of miniconda can be skipped. -Update local repository and create branch `fix/some-branch-fix` +###### Installing Regression Testing Dependencies ``` -$ git checkout develop -$ git pull upstream develop -$ git push origin develop -$ git checkout -b fix/some-branch-fix +cd ..\.. +\>choco install -y miniconda --installargs '/AddToPath=1' +\>refreshenv +\>pip install -r tools/requirements-appveyor.txt ``` -Make changes and then commit them with sensible messages. +With Python and the necessary dependencies installed, regression testing can be run using the gen-config and run-nrtest helper scripts found in the tools folder. The script gen-config creates a json formatted file that describes the build artifact under test - run-swmm - and how to run it. The script run-nrtest calls nrtest execute and nrtest compare to perform the regression test. + +To run the executable under test, nrtest needs the absolute path to it and a unique identifier for it such as the version number. The project build places build artifacts in the `buildprod\bin\` folder. On Windows the build configuration "Debug" or "Release" must also be indicated. On Windows it is also necessary to specify the path to the Python Scripts folder so the nrtest execute and compare commands can be found. You need to substitute bracketed fields below like "" with the values for your setup. + +###### Regression Testing ``` -$ git add . -$ git commit -m "My awesome message!" -$ git push origin fix/some-branch-fix +\>tools/gen-config.cmd > tests/apps/swmm-.json +\>tools/run-nrtest.cmd /tests/swmm-nrtestsuite ``` -### Step 4: Make Pull request +###### Common Problems + +The nrtest script complains that it can't find manifest files. -Once the work is done go to https://github.com/OpenWaterAnalytics/Stormwater-Management-Model -and make a pull request from your created branch. +That concludes this tutorial on building OWA SWMM from source on Windows. You have learned how to configure your machine satisfying project dependencies and how to acquire, build, and test SWMM on your local machine. To be sure, there is a lot more to learn, but this is a good start! Learn more by following the links provided below. +### Further Reading + Visual Studio - https://msdn.microsoft.com/en-us/library/dd831853(v=vs.100).aspx + CMake - https://cmake.org/documentation/ + Boost - http://www.boost.org/doc/ + git - https://git-scm.com/doc + Miniconda - https://conda.io/docs/user-guide/index.html + nrtest - https://nrtest.readthedocs.io/en/latest/ diff --git a/src/Roadmap.txt b/src/Roadmap.txt deleted file mode 100644 index 11952fad7..000000000 --- a/src/Roadmap.txt +++ /dev/null @@ -1,189 +0,0 @@ -A Roadmap to the SWMM 5 Engine Source Code -========================================== - -The SWMM 5 computational engine consists of 49 C-code files plus several -header files. The engine can be compiled either as a Dynamic Link Library -(DLL) under Windows or as a stand-alone console application under both -Windows and Linux, depending on which of the #define DLL and #define CLE -declarations at the top of swmm5.c is commented out. - -The following header files contain definitions that are used throughout the -code and should be consulted if the meaning of a variable, a data structure, -or a constant is unclear: - -enums.h defines various enumerated (symbolic) constants. - -objects.h defines the major classes of data objects used by SWMM 5. - -consts.h defines useful numerical constants. - -text.h defines various text strings used throughout the code. - -macros.h defines several macros used throughout the code. - -globals.h declares global variables that are referenced in many - SWMM 5 code modules. - -funcs.h contains prototypes of functions that can be called from any - module of SWMM 5 that #includes funcs.h. - --------------------------------------------------------------------------- - -The following modules form the main core of the SWMM 5 engine: - -swmm5.c contains functions that provide supervisory control over the - program. - -project.c contains functions that create and destroy all project data, - establish default values, and look up objects by ID name. - -input.c reads a project's data from an input file. - -runoff.c computes runoff quantity and quality from the project's - subcatchments. - -routing.c routes runoff and external inflows through the project's - drainage system network of nodes and links. - -massbal.c performs mass balance calculations for runoff and routing. - -stats.c collects summary statistics on flow rates, water depths, - solution iterations, and variable time steps for a - simulation. - -statsrpt.c writes summary simulation results to a status report. - -output.c writes/reads runoff and routing results to/from a binary - output file. - -report.c prepares a status report of simulation results and, for the - command line version of SWMM 5, reports complete results for - selected subcatchments, nodes, and links. - -inputrpt.c writes a summary of a project's input data to the status report. - -------------------------------------------------------------------------------- - -The following collection of modules are used to perform runoff calculations: - -rain.c places data from external rainfall files into a single rainfall - interface file. - -gage.c provides rainfall data, either from an interface file or from an - internal time series, for runoff calculations. - -climate.c provides temperature, evaporation, and wind speed data to the - simulation. - -snow.c computes snow fall accumulation, snow removal operations, and - snow melt for a project's subcatchments. - -infil.c performs infiltration calculations on a project's subcatchments. - -gwater.c computes groundwater fluxes and updates groundwater depths over - the project's study area. - -subcatch.c computes rainfall runoff, pollutant buildup and washoff, and - street sweeping over individual subcatchments. - -landuse.c evaluates pollutant buildup and washoff functions for a project's - various types of land uses. - -lid.c evaluates the hydrologic performance of Low Impact Development - practices utilized within subcatchment areas. - -lidproc.c computes the hydrologic performance of individual LID units. - -------------------------------------------------------------------------------- - -These modules are used for flow and water quality routing: - -flowrout.c implements top-level control of flow routing through a project's - drainage network. - -inflow.c provides direct time series inflows and recurring dry weather - inflows to the drainage system's nodes at each step of the - simulation. - -rdii.c computes rainfall dependent infiltration/inflow at selected nodes - of the drainage network. - -kinwave.c performs kinematic wave flow routing calculations at each time - step of the simulation. - -dynwave.c performs dynamic wave flow routing calculations at each time - step of the simulation - -dwflow.c solves the dynamic wave flow continuity and momentum equations in - a single conduit over a single time step. - -controls.c implements rule-based control actions on pumps and regulators - as the simulation unfolds. - -qualrout.c performs routing of water quality constituents through the - study area's drainage system. - -treatmnt.c computes pollutant removal at specific nodes of the drainage - system where user-defined treatment functions have been - assigned. - -node.c contains functions used to compute the properties and behavior - of the drainage system's nodes which include junctions, flow - dividers, storage units, and outfalls. - -link.c contains functions used to compute the properties and behavior - of the drainage system's links which include conduits, pumps, - orifices, weirs, and outlets. - -forcmain.c computes friction losses in force mains that use either the - Hazen-Williams or Darcy-Weisbach equations in place of the - Manning equation for pressurized flow. - -culvert.c computes flow reduction in culvert-type conduits due to - inlet control using equations from the FHWA HEC-5 circular. - -------------------------------------------------------------------------------- - -The following modules provide various support functions for SWMM 5: - -datetime.c functions for manipulating dates and times. - -error.c error reporting functions. - -findroot.c equation root finding functions. - -hash.c functions that implement hash tables for fast object retrieval. - -hotstart.c saves or reads the state of the drainage system to or from a - hot start file. - -iface.c functions for reading from and writing to routing interface - files. - -keywords.c defines lists of keywords that appear as part of a SWMM 5 - input file. - -mathexpr.c functions that parse and evaluate user-supplied mathematical - expressions for pollutant removal at treatment nodes. - -mempool.c functions that provide a memory pool used to store object - ID names. - -odesolve.c implementation of a fifth-order Runge-Kutta ordinary - differential equation solver. - -shape.c functions that compute the geometric cross-section properties - of closed conduits with user-defined shapes. - -table.c functions used for accessing lookup tables that contain - SWMM 5's curve data and time series data. - -toposort.c functions used to topologically sort the links of a drainage - network and detect any closed cyclic loops. - -transect.c functions that create geometric tables for irregular shaped - cross section transects. - -xsect.c functions that compute geometric properties of conduit cross - sections. - \ No newline at end of file diff --git a/tools/build_and_upload.py b/tools/build_and_upload.py deleted file mode 100644 index 2c25cb5eb..000000000 --- a/tools/build_and_upload.py +++ /dev/null @@ -1,31 +0,0 @@ -# -*- coding: utf-8 -*- -"""Script used in appveyor CI for building and uploading packages.""" - -# Standard library imports -import os -import subprocess - - -def main(): - """Build and upload a package if on develop and PR is merged.""" - pr_number = os.environ.get('APPVEYOR_PULL_REQUEST_NUMBER') - branch= os.environ.get('APPVEYOR_REPO_BRANCH') - token = os.environ.get('SWWM_CI_UPLOAD_TOKEN') - python = os.environ.get('PYTHON_VERSION') - - print([pr_number, branch]) - - if branch == 'develop' and pr_number is None: - cmd = ['conda-build', 'conda.recipe', '--user', 'owa', - '--token', token, '--old-build-string', '--python', python] - p = subprocess.Popen(cmd, stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - stdout, stderr = p.communicate() - stdout = stdout.decode() - stderr = stderr.decode() - print(stdout) - print(stderr) - - -if __name__ == '__main__': - main() diff --git a/tools/run_regression_tests.py b/tools/run_regression_tests.py deleted file mode 100644 index b93d4147f..000000000 --- a/tools/run_regression_tests.py +++ /dev/null @@ -1,157 +0,0 @@ -# -*- coding: utf-8 -*- -"""Run regression tests.""" - -# Standard library imports -import io -import json -import subprocess -import os -import shutil -import sys - - -# Reference -SWMM_REF_VERSION = '5112' -SWMM_EXEC = 'run-swmm' - -# Ensure proper cross os / \\ handling and allow running independent of pwd -HERE = os.path.abspath(os.path.dirname(__file__)) -REPO_ROOT = os.path.dirname(HERE) -PACKAGES_PATH = os.path.join(REPO_ROOT, 'build', 'packages', 'nrtest', - 'scripts') -TESTS_PATH = os.path.join(REPO_ROOT, 'tests') -NRTESTSUITE_PATH = os.path.join(TESTS_PATH, 'swmm-nrtestsuite') -APPS_PATH = os.path.join(NRTESTSUITE_PATH, 'apps') -TEST_EXAMPLES_PATH = os.path.join(NRTESTSUITE_PATH, 'tests', 'examples') -BENCHARK_PATH = os.path.join(NRTESTSUITE_PATH, 'benchmark') -REF_BENCHMARK_PATH = os.path.join(BENCHARK_PATH, 'swmm-' + SWMM_REF_VERSION) - -# OS identifiers -MAC = sys.platform == 'darwin' -WIN = os.name == 'nt' -LINUX = sys.platform.startswith('linux') -PY3 = sys.version_info[0] == 3 - - -def run_command(cmd, print_command=True): - """Run command in pipes and return stdout, sterr and return code.""" - stdout, stderr, code = None, None, None - cmd = [str(c) for c in cmd] - if print_command: - print('\nINFO: ' + ' '.join(cmd) + '\n') - - try: - p = subprocess.Popen( - cmd, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - ) - stdout, stderr = p.communicate() - code = p.returncode - if PY3: - stdout = stdout.decode() - stderr = stderr.decode() - except Exception as e: - print(e) - - return stdout, stderr, code - - -def generate_config_data(executable_location): - """Generate configuration file for running regression tests.""" - path = os.path.abspath(executable_location) - - if LINUX or MAC: - test_cmd = os.path.join(path, SWMM_EXEC) - elif WIN: - # nrtests works with unix style separators on windows - test_cmd = os.path.join(path, SWMM_EXEC + '.exe').replace('\\', '/') - else: - raise Exception('Machine not supported!') - - # Check executable existence - if not os.path.isfile(test_cmd): - raise Exception('SWMM executable not found on location') - - version = "" - build_description = "" - data = { - "name": "swmm", - "version": version, - "description": build_description, - "setup_script": "", - "exe": test_cmd, - } - return data - - -def run_tests(executable_location, testid, rtol=0.01, atol=0.0): - """Run regression tests.""" - test_app_path = os.path.join(APPS_PATH, 'swmm-' + testid + '.json') - test_output_path = os.path.join(BENCHARK_PATH, "swmm-" + testid) - - # Clean any previous runs - if os.path.isdir(test_output_path): - print("\n\n\nINFO: Removing previous run data\n") - shutil.rmtree(test_output_path) - - # Generate configuration data and write to disk - print('\n\n\nINFO: Generating configuration data:\n') - data = generate_config_data(executable_location) - print(data) - with io.open(test_app_path, 'wb') as f_handle: - json.dump(data, f_handle, indent=4, sort_keys=True) - - pyexe = 'python' - nrtest_script = 'nrtest' - python_exe = [] - if WIN: - pyexe = 'python.exe' - nrtest_script = os.path.join(PACKAGES_PATH, 'nrtest') - python_exe = [os.path.join(sys.prefix, pyexe)] - - # Generate commands - exec_cmd = python_exe + [ - nrtest_script, - 'execute', - test_app_path, - TEST_EXAMPLES_PATH, - '-o', - test_output_path, - ] - compare_cmd = python_exe + [ - nrtest_script, - 'compare', - test_output_path, - REF_BENCHMARK_PATH, - '--rtol', - rtol, - '--atol', - atol, - ] - print('\n\n\nINFO: Running nrtest execute command:\n') - out, err, code = run_command(exec_cmd) - print(err) - print(out) - - if code == 0: - print('\n\n\nINFO: Running nrtest compare command:\n') - out, err, code = run_command(compare_cmd) - print(err) - print(out) - - if code != 0: - print('\n\n\nERROR: Comparison against benchmark failed!\n') - sys.exit(code) - else: - print('\n\n\nERROR: Generation of benchmark failed!\n') - sys.exit(code) - - -if __name__ == '__main__': - args = sys.argv[1:] - if args and len(args) == 2: - executable_location, test_id = args - run_tests(executable_location, test_id) - else: - print('ERROR: Need to provide `path to swmm exec folder` and `testid`') From b18d8ea96bdca81948260fcc8fe7cffdd4516043 Mon Sep 17 00:00:00 2001 From: "Bryant E. McDonnell" Date: Mon, 2 Apr 2018 15:21:10 -0400 Subject: [PATCH 57/57] Fix Typo --- .github/CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 208b5384c..8dc7d82d5 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -38,7 +38,7 @@ https://www.microsoft.com/en-us/download/details.aspx?id=34677 ###### Install Boost -Boost binaries for Windows offer a convenient installation solution. Be sure to select for download the boost installer exe that corresponds to the version of Visual Studio you have installed. +Boost binaries for Windows offer a convenient installation solution. Be sure to select download the boost installer exe that corresponds to the version of Visual Studio you have installed. https://sourceforge.net/projects/boost/files/boost-binaries/1.58.0/