From 0c150043cea22301329cdd1505522ad56d0bc822 Mon Sep 17 00:00:00 2001 From: AJKhattak-NOAA Date: Fri, 13 Sep 2024 16:39:57 -0400 Subject: [PATCH] fix_giuh_array_water (#34) * bug fix in computing leftover water in the giuh array. * bug fix in the giuh ordinates reader. --- include/all.hxx | 2 +- src/lgar.cxx | 46 +++++++++++--------------- tests/configs/config_lasam_synth_1.txt | 2 +- tests/configs/config_lasam_synth_2.txt | 2 +- 4 files changed, 23 insertions(+), 29 deletions(-) diff --git a/include/all.hxx b/include/all.hxx index 52750f0..a3c3fd2 100755 --- a/include/all.hxx +++ b/include/all.hxx @@ -36,7 +36,7 @@ extern string verbosity; #define use_bmi_flag FALSE // TODO set to TRUE to run in BMI environment #define MAX_NUM_SOIL_LAYERS 4 -#define MAX_NUM_SOIL_TYPES 16 +#define MAX_NUM_SOIL_TYPES 15 #define MAX_SOIL_NAME_CHARS 25 #define MAX_NUM_WETTING_FRONTS 300 diff --git a/src/lgar.cxx b/src/lgar.cxx index 5d84872..4a09fd0 100755 --- a/src/lgar.cxx +++ b/src/lgar.cxx @@ -787,12 +787,6 @@ ReadVectorData(string key) if (z1.find(delimiter) == string::npos) { double v = stod(z1); - if (v == 0.0) { - stringstream errMsg; - errMsg << "soil_z (depth of soil reservior) should be greater than zero. It it set to "<< v << " in the config file "<< "\n"; - throw runtime_error(errMsg.str()); - } - value.push_back(v); } @@ -890,29 +884,29 @@ extern void lgar_global_mass_balance(struct model_state *state, double *giuh_run //check if the giuh queue have some water left at the end of simulaiton; needs to be included in the global mass balance // hold on; this is probably not needed as we have volrunoff in the balance; revist AJK - for(int i=1; i <= state->lgar_bmi_params.num_giuh_ordinates; i++) + for(int i=0; i <= state->lgar_bmi_params.num_giuh_ordinates; i++) volend_giuh_cm += giuh_runoff_queue_cm[i]; - double global_error_cm = volstart + volprecip - volrunoff - volAET - volon - volrech - volend + volchange_calib_cm; - - printf("\n********************************************************* \n"); - printf("-------------------- Simulation Summary ----------------- \n"); - //printf("Time (sec) = %6.10f \n", elapsed); - printf("------------------------ Mass balance ------------------- \n"); - printf("Initial water in soil = %14.10f cm\n", volstart); - printf("Total precipitation = %14.10f cm\n", volprecip); - printf("Total infiltration = %14.10f cm\n", volin); - printf("Final water in soil = %14.10f cm\n", volend); - printf("Surface ponded water = %14.10f cm\n", volon); - printf("Surface runoff = %14.10f cm\n", volrunoff); - printf("GIUH runoff = %14.10f cm\n", volrunoff_giuh); - printf("Total percolation = %14.10f cm\n", volrech); - printf("Total AET = %14.10f cm\n", volAET); - printf("Total PET = %14.10f cm\n", volPET); - printf("Total discharge (Q) = %14.10f cm\n", total_Q_cm); - printf("Vol change (calibration) = %14.10f cm\n", volchange_calib_cm); - printf("Global balance = %.6e cm\n", global_error_cm); + + printf("\n********************************************************* \n"); + printf("-------------------- Simulation Summary ----------------- \n"); + //printf("Time (sec) = %6.10f \n", elapsed); + printf("------------------------ Mass balance ------------------- \n"); + printf("Initial water in soil = %14.10f cm\n", volstart); + printf("Total precipitation = %14.10f cm\n", volprecip); + printf("Total infiltration = %14.10f cm\n", volin); + printf("Final water in soil = %14.10f cm\n", volend); + printf("Surface ponded water = %14.10f cm\n", volon); + printf("Surface runoff = %14.10f cm\n", volrunoff); + printf("GIUH runoff = %14.10f cm\n", volrunoff_giuh); + printf("GIUH water (in array) = %14.10f cm\n", volend_giuh_cm); + printf("Total percolation = %14.10f cm\n", volrech); + printf("Total AET = %14.10f cm\n", volAET); + printf("Total PET = %14.10f cm\n", volPET); + printf("Total discharge (Q) = %14.10f cm\n", total_Q_cm); + printf("Vol change (calibration) = %14.10f cm\n", volchange_calib_cm); + printf("Global balance = %.6e cm\n", global_error_cm); } diff --git a/tests/configs/config_lasam_synth_1.txt b/tests/configs/config_lasam_synth_1.txt index 761d5c0..c31f29f 100644 --- a/tests/configs/config_lasam_synth_1.txt +++ b/tests/configs/config_lasam_synth_1.txt @@ -10,4 +10,4 @@ layer_soil_type=13,14,15 max_valid_soil_types=25 wilting_point_psi=15495.0[cm] field_capacity_psi=340.9[cm] -giuh_ordinates=0.0,0.0,0.0,0.0,0.0 +giuh_ordinates=0.0 diff --git a/tests/configs/config_lasam_synth_2.txt b/tests/configs/config_lasam_synth_2.txt index e3b1da8..22ba45b 100644 --- a/tests/configs/config_lasam_synth_2.txt +++ b/tests/configs/config_lasam_synth_2.txt @@ -10,4 +10,4 @@ layer_soil_type=13,14,15 max_valid_soil_types=25 wilting_point_psi=15495.0[cm] field_capacity_psi=340.9[cm] -giuh_ordinates=0.0,0.0,0.0,0.0,0.0 +giuh_ordinates=0.0