From 4275baee260819d1757d3604b0af52bb59cf402f Mon Sep 17 00:00:00 2001 From: Ahmad Jan Date: Fri, 3 May 2024 13:23:44 -0400 Subject: [PATCH] set soil_storage to non-zero in the unittest, 0 triggers assertion. --- src/main_smp_topmodel.cxx | 2 +- tests/main_unittest.cxx | 175 +++++++++++++++++++------------------- 2 files changed, 90 insertions(+), 87 deletions(-) diff --git a/src/main_smp_topmodel.cxx b/src/main_smp_topmodel.cxx index 89f7800..1252ed9 100644 --- a/src/main_smp_topmodel.cxx +++ b/src/main_smp_topmodel.cxx @@ -122,7 +122,7 @@ main(int argc, const char *argv[]) { /************************************************************************ Now loop through time and call the models with the intermediate get/set ************************************************************************/ - printf("looping through and calling updata\n"); + printf("looping through and calling update \n"); // output files -- writing water table depth, soil moisture fraction, and soil moisture profiles to separate files ofstream fout, fout_wt; diff --git a/tests/main_unittest.cxx b/tests/main_unittest.cxx index 66032a3..7dceb49 100644 --- a/tests/main_unittest.cxx +++ b/tests/main_unittest.cxx @@ -34,7 +34,7 @@ int main(int argc, char *argv[]) } std::cout<<"\n**************** BEGIN SoilMoistureProfiles BMI UNIT TEST *******************\n"; - + model.Initialize(argv[1]); model_layered.Initialize(argv[2]); @@ -43,17 +43,17 @@ int main(int argc, char *argv[]) bool test_status = true; int num_input_vars = 8; int num_output_vars = 3; - + std::vector bmi_input_vars = {"soil_storage", "soil_storage_change", "num_wetting_fronts", "soil_moisture_wetting_fronts", "soil_depth_wetting_fronts", "Qb_topmodel", "Qv_topmodel", "global_deficit"}; std::vector bmi_output_vars = {"soil_moisture_profile", "soil_water_table","soil_moisture_fraction"}; - + int nbytes_input[] = {sizeof(double), sizeof(double), sizeof(int), sizeof(double), sizeof(double), sizeof(double), sizeof(double), sizeof(double)}; int nbytes_output[] = {int(nz * sizeof(double)), sizeof(double), sizeof(double)}; //double soil_moisture_profile[] = {0.389,0.396,0.397,0.397}; // total_moisture_content - + std::cout<<"Num cells: "< names_in; std::vector names_out; - + // Test get_component_name() model_name = model.GetComponentName(); @@ -86,7 +86,7 @@ int main(int argc, char *argv[]) throw std::runtime_error(errMsg.str()); } - // Test GetInputVarNames + // Test GetInputVarNames names_in = model.GetInputVarNames(); if (VERBOSITY) { std::cout<<"Input variable names \n"; @@ -117,7 +117,7 @@ int main(int argc, char *argv[]) errMsg << "Number of output variables are different. "<< count_out <<" != "<< num_output_vars <<"\n"; throw std::runtime_error(errMsg.str()); } - + // Test BMI: VARIABLE INFORMATION FUNCTIONS std::cout<<"\n**************** TEST BMI VARIABLE INFORMATION FUNCTIONS\n***************************\n"; @@ -125,7 +125,7 @@ int main(int argc, char *argv[]) std::string location; std::string units; std::string vartype; - + // Loop through both input and output variables and call GetVar* functions for (int i=0; i 0 ? "Yes" : "No"; std::cout< 0 ? "Yes" : "No"; - + } - + std::cout< 0 ? "Yes" : "No"; } - + std::cout< 0 ? "Yes" : "No"; } - + std::cout< 0 ? "Yes" : "No"; - + std::cout<<"| Unittest passed : "<< RED << passed << RESET << GREEN <<"\n"; std::cout<<"| *************************************** \n"; std::cout<