Skip to content

Commit 29231c4

Browse files
authored
Added_NWM_ponded depth (#134)
* added nwm_ponded_depth as bmi output for parity with NWM surface ponded depth, updated Kinf_nash_surface default value. * added NWM_PONDED_DEPTH to the bmi output vars list, and updated realizations files.
1 parent c462707 commit 29231c4

5 files changed

Lines changed: 40 additions & 13 deletions

File tree

configs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Example configuration files are provided in this directory. To build and run the
3939
| K_nash_surface<sup>1</sup> | *double* | | 1/hour [h^-1] | parameter_adjustable | surface runoff | Nash Config param for surface runoff |
4040
| nash_storage_surface<sup>1</sup> | 1D array (*double*) | | meters [m] | parameter_adjustable | surface runoff | Nash Config param; reservoir surface storage; default is zero storage |
4141
| nsubsteps_nash_surface<sup>1</sup> | *int* | | | parameter_adjustable | surface runoff | optional (default = 10); number of subtimstep for Nash runoff |
42-
| Kinf_nash_surface<sup>*,1</sup> | *double* | | 1/hour [h^-1] | parameter_adjustable | surface runoff | optional (default = 0.05); storage fraction per hour that moves from reservoirs to soil |
42+
| Kinf_nash_surface<sup>*,1</sup> | *double* | | 1/hour [h^-1] | parameter_adjustable | surface runoff | optional (default = 0.001); storage fraction per hour that moves from reservoirs to soil |
4343
| retention_depth_nash_surface<sup>*,1</sup> | *double* | | m | parameter_adjustable | surface runoff | optional (default = 0.001); water retention depth threshold (only applied to the first reservoir) |
4444
| a_Xinanjiang_inflection_point_parameter<sup>*</sup> | *double* | | | parameter_adjustable | infiltration excess runoff | when `surface_water_partitioning_scheme=Xinanjiang` |
4545
| b_Xinanjiang_shape_parameter<sup>*</sup> | *double* | | | parameter_adjustable | infiltration excess runoff | when `surface_water_partitioning_scheme=Xinanjiang` |

include/bmi_cfe.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ struct cfe_state_struct {
8686

8787
int surface_runoff_scheme; // options: giuh-based runoff and nash cascade-based runoff
8888

89+
double nwm_ponded_depth_m;
8990
// ***********************************************************
9091
// ******************* Dynamic allocations *******************
9192
// ***********************************************************

realizations/realization_cfe_pet_surfgiuh.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"Q_OUT",
2020
"POTENTIAL_ET",
2121
"ACTUAL_ET",
22-
"SOIL_STORAGE"
22+
"SOIL_STORAGE",
23+
"NWM_PONDED_DEPTH"
2324
],
2425
"modules": [
2526
{

realizations/realization_cfe_pet_surfnash.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"Q_OUT",
2020
"POTENTIAL_ET",
2121
"ACTUAL_ET",
22-
"SOIL_STORAGE"
22+
"SOIL_STORAGE",
23+
"NWM_PONDED_DEPTH"
2324
],
2425
"modules": [
2526
{

src/bmi_cfe.c

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
#define CFE_DEBUG 0
2121

2222
#define INPUT_VAR_NAME_COUNT 5
23-
#define OUTPUT_VAR_NAME_COUNT 14
23+
#define OUTPUT_VAR_NAME_COUNT 15
2424

25-
#define STATE_VAR_NAME_COUNT 94 // must match var_info array size
25+
#define STATE_VAR_NAME_COUNT 95 // must match var_info array size
2626

2727

2828
#define PARAM_VAR_NAME_COUNT 18
@@ -178,8 +178,10 @@ Variable var_info[] = {
178178
// -------------------------------------------
179179
{ 91, "soil_moisture_profile", "double", 1},
180180
{ 92, "soil_layer_depths_m", "double", 1},
181-
{ 93, "max_rootzone_layer", "int", 1},
181+
{ 93, "max_rootzone_layer", "int", 1},
182182
//--------------------------------------------
183+
{ 94, "nwm_ponded_depth", "double", 1},
184+
183185
};
184186

185187
int i = 0;
@@ -200,7 +202,8 @@ static const char *output_var_names[OUTPUT_VAR_NAME_COUNT] = {
200202
"GW_STORAGE",
201203
"SOIL_STORAGE",
202204
"SOIL_STORAGE_CHANGE",
203-
"SURF_RUNOFF_SCHEME"
205+
"SURF_RUNOFF_SCHEME",
206+
"NWM_PONDED_DEPTH"
204207
};
205208

206209
static const char *output_var_types[OUTPUT_VAR_NAME_COUNT] = {
@@ -217,7 +220,8 @@ static const char *output_var_types[OUTPUT_VAR_NAME_COUNT] = {
217220
"double",
218221
"double",
219222
"double",
220-
"int"
223+
"int",
224+
"double"
221225
};
222226

223227
static const int output_var_item_count[OUTPUT_VAR_NAME_COUNT] = {
@@ -234,6 +238,7 @@ static const int output_var_item_count[OUTPUT_VAR_NAME_COUNT] = {
234238
1,
235239
1,
236240
1,
241+
1,
237242
1
238243
};
239244

@@ -251,7 +256,8 @@ static const char *output_var_units[OUTPUT_VAR_NAME_COUNT] = {
251256
"m",
252257
"m",
253258
"m",
254-
"none"
259+
"none",
260+
"m"
255261
};
256262

257263
static const int output_var_grids[OUTPUT_VAR_NAME_COUNT] = {
@@ -268,6 +274,7 @@ static const int output_var_grids[OUTPUT_VAR_NAME_COUNT] = {
268274
0,
269275
0,
270276
0,
277+
0,
271278
0
272279
};
273280

@@ -285,7 +292,8 @@ static const char *output_var_locations[OUTPUT_VAR_NAME_COUNT] = {
285292
"node",
286293
"node",
287294
"node",
288-
"none"
295+
"none",
296+
"node"
289297
};
290298

291299
// Don't forget to update Get_value/Get_value_at_indices (and setter) implementation if these are adjusted
@@ -1141,9 +1149,9 @@ int read_init_config_cfe(const char* config_file, cfe_state_struct* model)
11411149
}
11421150
if (is_K_infiltration_nash_surface_set == FALSE) {
11431151
#if CFE_DEBUG >= 1
1144-
printf("Config param 'Kinf_nash_surface' not found in config file, default value is 0.05 [1/hr] \n");
1152+
printf("Config param 'Kinf_nash_surface' not found in config file, default value is 0.001 [1/hr] \n");
11451153
#endif
1146-
model->nash_surface_params.K_infiltration = 0.05; // used in the runon infiltration
1154+
model->nash_surface_params.K_infiltration = 0.001; // used in the runon infiltration
11471155
}
11481156
if (is_retention_depth_nash_surface_set == FALSE) {
11491157
#if CFE_DEBUG >= 1
@@ -1547,6 +1555,17 @@ static int Update (Bmi *self)
15471555
// Advance the model time
15481556
cfe_ptr->current_time_step += 1;
15491557

1558+
// compute NWM ponded depth, which is assumed to be the leftover water in the GIUH/NASH queue
1559+
cfe_ptr->nwm_ponded_depth_m = 0.0;
1560+
if (cfe_ptr->surface_runoff_scheme == GIUH) {
1561+
for(i=0;i<cfe_ptr->num_giuh_ordinates;i++)
1562+
cfe_ptr->nwm_ponded_depth_m += cfe_ptr->runoff_queue_m_per_timestep[i];
1563+
}
1564+
else if (cfe_ptr->surface_runoff_scheme == NASH_CASCADE) {
1565+
for(i=0;i<cfe_ptr->nash_surface_params.N_nash;i++)
1566+
cfe_ptr->nwm_ponded_depth_m += cfe_ptr->nash_surface_params.nash_storage[i];
1567+
}
1568+
15501569
return BMI_SUCCESS;
15511570
}
15521571

@@ -2050,7 +2069,12 @@ static int Get_value_ptr (Bmi *self, const char *name, void **dest)
20502069
return BMI_SUCCESS;
20512070
}
20522071

2053-
2072+
if (strcmp (name, "NWM_PONDED_DEPTH") == 0) {
2073+
cfe_state_struct *cfe_ptr;
2074+
cfe_ptr = (cfe_state_struct *) self->data;
2075+
*dest = (void*)&cfe_ptr->nwm_ponded_depth_m;
2076+
return BMI_SUCCESS;
2077+
}
20542078
/***********************************************************/
20552079
/*********** INPUT ***********************************/
20562080
/***********************************************************/

0 commit comments

Comments
 (0)