Skip to content

Commit b0004e2

Browse files
committed
added and_surface_water__baseflow_volume_flux_m3_per_s
1 parent 600cc72 commit b0004e2

2 files changed

Lines changed: 32 additions & 5 deletions

File tree

include/topmodel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ struct TopModel_Struct{
185185
double p; /* adjusted rain*/
186186
double ep; /* adjusted potential evaporation*/
187187
double ponded_depth; /* queued delayed runoff depth from hydrograph ordinates */
188+
double qb_m3_per_s;
188189

189190
/************** Framework vars **************/
190191
int stand_alone;

src/bmi_topmodel.c

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
/* BMI Adaption: Max i/o file name length changed from 30 to 256 */
88
#define MAX_FILENAME_LENGTH 256
9-
#define OUTPUT_VAR_NAME_COUNT 15
9+
#define OUTPUT_VAR_NAME_COUNT 16
1010
#define INPUT_VAR_NAME_COUNT 2
1111
#define PARAM_VAR_NAME_COUNT 8
1212

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

3435
static const char *output_var_types[OUTPUT_VAR_NAME_COUNT] = {
@@ -46,11 +47,12 @@ static const char *output_var_types[OUTPUT_VAR_NAME_COUNT] = {
4647
"double",
4748
"double",
4849
"double",
50+
"double",
4951
"double"
5052
};
5153

5254
static const int output_var_item_count[OUTPUT_VAR_NAME_COUNT] =
53-
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
55+
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
5456

5557
static const char *output_var_units[OUTPUT_VAR_NAME_COUNT] = {
5658
"m h-1",
@@ -67,11 +69,12 @@ static const char *output_var_units[OUTPUT_VAR_NAME_COUNT] = {
6769
"m",
6870
"m",
6971
"m",
70-
"m"
72+
"m",
73+
"m3 s-1"
7174
};
7275

7376
static const int output_var_grids[OUTPUT_VAR_NAME_COUNT] =
74-
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
77+
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
7578

7679
static const char *output_var_locations[OUTPUT_VAR_NAME_COUNT] = {
7780
"node",
@@ -88,6 +91,7 @@ static const char *output_var_locations[OUTPUT_VAR_NAME_COUNT] = {
8891
"node",
8992
"node",
9093
"node",
94+
"node",
9195
"node"
9296
};
9397

@@ -433,6 +437,7 @@ static int Initialize(Bmi *self, const char *cfg_file) {
433437
topmodel->sump = 0.0;
434438
topmodel->sumae = 0.0;
435439
topmodel->sumq = 0.0;
440+
topmodel->qb_m3_per_s = 0.0;
436441

437442
topmodel->max_contrib_area = 0.0;
438443

@@ -859,6 +864,27 @@ static int Get_value_ptr(Bmi *self, const char *name, void **dest) {
859864
*dest = (void *)&topmodel->qb;
860865
return BMI_SUCCESS;
861866
}
867+
// qb in m3/s
868+
if (strcmp(name, "land_surface_water__baseflow_volume_flux_m3_per_s") == 0) {
869+
topmodel_model *topmodel;
870+
topmodel = (topmodel_model *)self->data;
871+
872+
if (topmodel->area > 0.0) {
873+
/* TOPMODEL native qb is baseflow depth rate [m h-1].
874+
* NWM expects volume flow rate [m3 s-1].
875+
*
876+
* Conversion:
877+
* m h-1 * m2 / 3600 s h-1 = m3 s-1
878+
*/
879+
topmodel->qb_m3_per_s = topmodel->qb * topmodel->area / 3600.0;
880+
}
881+
else {
882+
topmodel->qb_m3_per_s = 0.0;
883+
}
884+
885+
*dest = (void *)&topmodel->qb_m3_per_s;
886+
return BMI_SUCCESS;
887+
}
862888
// sbar
863889
if (strcmp(name, "soil_water__domain_volume_deficit") == 0) {
864890
topmodel_model *topmodel;

0 commit comments

Comments
 (0)