Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/topmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ struct TopModel_Struct{
double p; /* adjusted rain*/
double ep; /* adjusted potential evaporation*/
double ponded_depth; /* queued delayed runoff depth from hydrograph ordinates */
double qb_m3_per_s;

/************** Framework vars **************/
int stand_alone;
Expand Down
36 changes: 31 additions & 5 deletions src/bmi_topmodel.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

/* BMI Adaption: Max i/o file name length changed from 30 to 256 */
#define MAX_FILENAME_LENGTH 256
#define OUTPUT_VAR_NAME_COUNT 15
#define OUTPUT_VAR_NAME_COUNT 16
#define INPUT_VAR_NAME_COUNT 2
#define PARAM_VAR_NAME_COUNT 8

Expand All @@ -28,7 +28,8 @@ static const char *output_var_names[OUTPUT_VAR_NAME_COUNT] = {
"soil_water__domain_root-zone_volume_deficit", // sumrz
"soil_water__domain_unsaturated-zone_volume", // sumuz
"land_surface_water__water_balance_volume", // bal
"nwm_ponded_depth" // sum of Q[1..num_time_delay_histo_ords]
"nwm_ponded_depth", // sum of Q[1..num_time_delay_histo_ords]
"land_surface_water__baseflow_volume_flux_m3_per_s"
};

static const char *output_var_types[OUTPUT_VAR_NAME_COUNT] = {
Expand All @@ -46,11 +47,12 @@ static const char *output_var_types[OUTPUT_VAR_NAME_COUNT] = {
"double",
"double",
"double",
"double",
"double"
};

static const int output_var_item_count[OUTPUT_VAR_NAME_COUNT] =
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};

static const char *output_var_units[OUTPUT_VAR_NAME_COUNT] = {
"m h-1",
Expand All @@ -67,11 +69,12 @@ static const char *output_var_units[OUTPUT_VAR_NAME_COUNT] = {
"m",
"m",
"m",
"m"
"m",
"m3 s-1"
};

static const int output_var_grids[OUTPUT_VAR_NAME_COUNT] =
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

static const char *output_var_locations[OUTPUT_VAR_NAME_COUNT] = {
"node",
Expand All @@ -88,6 +91,7 @@ static const char *output_var_locations[OUTPUT_VAR_NAME_COUNT] = {
"node",
"node",
"node",
"node",
"node"
};

Expand Down Expand Up @@ -433,6 +437,7 @@ static int Initialize(Bmi *self, const char *cfg_file) {
topmodel->sump = 0.0;
topmodel->sumae = 0.0;
topmodel->sumq = 0.0;
topmodel->qb_m3_per_s = 0.0;

topmodel->max_contrib_area = 0.0;

Expand Down Expand Up @@ -859,6 +864,27 @@ static int Get_value_ptr(Bmi *self, const char *name, void **dest) {
*dest = (void *)&topmodel->qb;
return BMI_SUCCESS;
}
// qb in m3/s
if (strcmp(name, "land_surface_water__baseflow_volume_flux_m3_per_s") == 0) {
topmodel_model *topmodel;
topmodel = (topmodel_model *)self->data;

if (topmodel->area > 0.0) {
/* TOPMODEL native qb is baseflow depth rate [m h-1].
* NWM expects volume flow rate [m3 s-1].
*
* Conversion:
* m h-1 * m2 / 3600 s h-1 = m3 s-1
*/
topmodel->qb_m3_per_s = topmodel->qb * topmodel->area / 3600.0;
}
else {
topmodel->qb_m3_per_s = 0.0;
}

*dest = (void *)&topmodel->qb_m3_per_s;
return BMI_SUCCESS;
}
// sbar
if (strcmp(name, "soil_water__domain_volume_deficit") == 0) {
topmodel_model *topmodel;
Expand Down
Loading