From f82aae25888409300f71132b04ab680a79af1ffa Mon Sep 17 00:00:00 2001 From: GreyEvenson-NOAA Date: Tue, 12 Mar 2024 12:55:07 -0400 Subject: [PATCH 1/9] initial commit for exposing calibratable parameters --- bmi/bmi_noahowp.f90 | 260 +++++++++++++++++++++++++++++++---- src/EnergyModule.f90 | 2 +- src/ParametersType.f90 | 4 +- test/noahowp_driver_test.f90 | 62 ++++++--- 4 files changed, 279 insertions(+), 49 deletions(-) diff --git a/bmi/bmi_noahowp.f90 b/bmi/bmi_noahowp.f90 index dfbeec87..df21492d 100644 --- a/bmi/bmi_noahowp.f90 +++ b/bmi/bmi_noahowp.f90 @@ -99,11 +99,21 @@ module bminoahowp ! Exchange items integer, parameter :: input_item_count = 8 integer, parameter :: output_item_count = 23 + integer, parameter :: param_item_count = 18 + character (len=BMI_MAX_VAR_NAME), target, & dimension(input_item_count) :: input_items character (len=BMI_MAX_VAR_NAME), target, & dimension(output_item_count) :: output_items + character(len=BMI_MAX_VAR_NAME), & + dimension(param_item_count) :: param_items = & + [character(len=BMI_MAX_VAR_NAME) :: & + "CWP","VCMX25","MP","MFSNO","RSURF_SNOW","HVT", & + "BEXP","SMCMAX","FRZX","DKSAT","KDT","RSURF_EXP","REFKDT", & + "AXAJ","BXAJ","XXAJ","SLOPE","SCAMAX"] + integer, dimension(param_item_count) :: param_grid = 0 + contains ! Get the name of the model. @@ -305,12 +315,17 @@ function noahowp_var_grid(this, name, grid) result (bmi_status) case('SFCPRS', 'SFCTMP', 'SOLDN', 'LWDN', 'UU', 'VV', 'Q2', 'PRCPNONC', & ! input vars 'QINSUR', 'ETRAN', 'QSEVA', 'EVAPOTRANS', 'TG', 'SNEQV', 'TGS', & ! output vars 'ACSNOM','SNOWT_AVG','ISNOW','QRAIN','FSNO','SNOWH','QSNOW', & - 'ECAN','GH','TRAD','FSA','CMC','LH','FIRA','FSH') + 'ECAN','GH','TRAD','FSA','CMC','LH','FIRA','FSH','CWP','VCMX25', & + 'MP','MFSNO','RSURF_SNOW','HVT','FRXZ','KDT','RSURF_EXP','REFKDT', & + 'AXAJ','BXAJ','XXAJ','SLOPE','SCAMAX') grid = 0 bmi_status = BMI_SUCCESS case('SNLIQ') grid = 1 bmi_status = BMI_SUCCESS + case('BEXP','SMCMAX','DKSAT') + grid = 2 + bmi_status = BMI_SUCCESS case default grid = -1 bmi_status = BMI_FAILURE @@ -328,7 +343,7 @@ function noahowp_grid_type(this, grid, type) result (bmi_status) case(0) type = "scalar" bmi_status = BMI_SUCCESS - case(1) + case(1,2) type = "vector" bmi_status = BMI_SUCCESS !================================ IMPLEMENT WHEN noahowp DONE IN GRID ====================== @@ -352,7 +367,7 @@ function noahowp_grid_rank(this, grid, rank) result (bmi_status) case(0) rank = 0 bmi_status = BMI_SUCCESS - case(1) + case(1,2) rank = 1 bmi_status = BMI_SUCCESS !================================ IMPLEMENT WHEN noahowp DONE IN GRID ====================== @@ -402,6 +417,9 @@ function noahowp_grid_size(this, grid, size) result (bmi_status) ! case(1) ! size = this%model%n_y * this%model%n_x ! bmi_status = BMI_SUCCESS + case(2) + size = this%model%levels%nsoil + bmi_status = BMI_SUCCESS case default size = -1 bmi_status = BMI_FAILURE @@ -505,7 +523,7 @@ function noahowp_grid_node_count(this, grid, count) result(bmi_status) integer :: bmi_status select case(grid) - case(0:1) + case(0:2) bmi_status = this%get_grid_size(grid, count) case default count = -1 @@ -589,7 +607,9 @@ function noahowp_var_type(this, name, type) result (bmi_status) select case(name) case('SFCPRS', 'SFCTMP', 'SOLDN', 'LWDN', 'UU', 'VV', 'Q2', 'PRCPNONC', & ! forcing vars 'QINSUR', 'ETRAN', 'QSEVA', 'EVAPOTRANS', 'TG', 'SNEQV', 'TGS', 'ACSNOM', 'SNOWT_AVG', & ! output vars - 'QRAIN', 'FSNO', 'SNOWH', 'SNLIQ', 'QSNOW', 'ECAN', 'GH', 'TRAD', 'FSA', 'CMC', 'LH', 'FIRA', 'FSH') + 'QRAIN', 'FSNO', 'SNOWH', 'SNLIQ', 'QSNOW', 'ECAN', 'GH', 'TRAD', 'FSA', 'CMC', 'LH', 'FIRA', 'FSH', & + 'CWP','VCMX25','MP','MFSNO','RSURF_SNOW','HVT','FRXZ','KDT','RSURF_EXP','REFKDT', & + 'AXAJ','BXAJ','XXAJ','SLOPE','SCAMAX') type = "real" bmi_status = BMI_SUCCESS case('ISNOW') @@ -624,7 +644,7 @@ function noahowp_var_units(this, name, units) result (bmi_status) case("Q2") units = "kg/kg" bmi_status = BMI_SUCCESS - case("QINSUR") + case("QINSUR","DKSAT") units = "m/s" bmi_status = BMI_SUCCESS case("PRCPNONC", "QRAIN", "QSEVA", "QSNOW") @@ -633,12 +653,24 @@ function noahowp_var_units(this, name, units) result (bmi_status) case("SNEQV", "ACSNOM", "EVAPOTRANS", "SNLIQ", "ECAN", "ETRAN", "CMC") units = "mm" bmi_status = BMI_SUCCESS - case("FSNO","ISNOW") + case("FSNO","ISNOW","MP","MFSNO","BEXP","KDT","RSURF_EXP","REFKDT","AXAJ","BXAJ","XXAJ","SLOPE","FRZX","SCAMAX") units = "unitless" bmi_status = BMI_SUCCESS - case("SNOWH") + case("SNOWH","HVT") units = "m" bmi_status = BMI_SUCCESS + case("VCMX25") + units = "umol co2/m**2/s" + bmi_status = BMI_SUCCESS + case("CWP") + units = "1/m" + bmi_status = BMI_SUCCESS + case("RSURF_SNOW") + units = 's/m' + bmi_status = BMI_SUCCESS + case("SMCMAX") + units = 'volumetric' + bmi_status = BMI_SUCCESS case default units = "-" bmi_status = BMI_FAILURE @@ -653,9 +685,10 @@ function noahowp_var_itemsize(this, name, size) result (bmi_status) integer, intent(out) :: size integer :: bmi_status - associate(forcing => this%model%forcing, & - water => this%model%water, & - energy => this%model%energy) + associate(forcing => this%model%forcing, & + water => this%model%water, & + energy => this%model%energy, & + parameters => this%model%parameters) select case(name) case("SFCPRS") @@ -751,6 +784,60 @@ function noahowp_var_itemsize(this, name, size) result (bmi_status) case("SNLIQ") size = sizeof(water%SNLIQ(1)) ! 'sizeof' in gcc & ifort bmi_status = BMI_SUCCESS + case("CWP") + size = sizeof(parameters%CWP) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("VCMX25") + size = sizeof(parameters%VCMX25) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("MP") + size = sizeof(parameters%MP) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("MFSNO") + size = sizeof(parameters%MFSNO) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("RSURF_SNOW") + size = sizeof(parameters%RSURF_SNOW) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("HVT") + size = sizeof(parameters%HVT) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("BEXP") + size = sizeof(parameters%bexp(1)) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("SMCMAX") + size = sizeof(parameters%smcmax(1)) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("DKSAT") + size = sizeof(parameters%dksat(1)) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("RSURF_EXP") + size = sizeof(parameters%RSURF_EXP) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("REFKDT") + size = sizeof(parameters%refkdt) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("AXAJ") + size = sizeof(parameters%AXAJ) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("BXAJ") + size = sizeof(parameters%BXAJ) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("XXAJ") + size = sizeof(parameters%XXAJ) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("SLOPE") + size = sizeof(parameters%slope) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("FRZX") + size = sizeof(parameters%frzx) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("KDT") + size = sizeof(parameters%kdt) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("SCAMAX") + size = sizeof(parameters%SCAMAX) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS case default size = -1 bmi_status = BMI_FAILURE @@ -826,10 +913,11 @@ function noahowp_get_float(this, name, dest) result (bmi_status) real :: mm2m = 0.001 ! unit conversion mm to m real :: m2mm = 1000. ! unit conversion m to mm - associate(forcing => this%model%forcing, & - water => this%model%water, & - energy => this%model%energy, & - domain => this%model%domain) + associate(forcing => this%model%forcing, & + water => this%model%water, & + energy => this%model%energy, & + domain => this%model%domain, & + parameters => this%model%parameters) select case(name) case("SFCPRS") @@ -922,6 +1010,60 @@ function noahowp_get_float(this, name, dest) result (bmi_status) case("FSH") dest = [energy%FSH] bmi_status = BMI_SUCCESS + case("CWP") + dest = [parameters%CWP] + bmi_status = BMI_SUCCESS + case("VCMX25") + dest = [parameters%VCMX25] + bmi_status = BMI_SUCCESS + case("MP") + dest = [parameters%MP] + bmi_status = BMI_SUCCESS + case("MFSNO") + dest = [parameters%MFSNO] + bmi_status = BMI_SUCCESS + case("RSURF_SNOW") + dest = [parameters%RSURF_SNOW] + bmi_status = BMI_SUCCESS + case("HVT") + dest = [parameters%HVT] + bmi_status = BMI_SUCCESS + case("BEXP") + dest = [parameters%bexp] + bmi_status = BMI_SUCCESS + case("SMCMAX") + dest = [parameters%smcmax] + bmi_status = BMI_SUCCESS + case("FRZX") + dest = [parameters%frzx] + bmi_status = BMI_SUCCESS + case("DKSAT") + dest = [parameters%dksat] + bmi_status = BMI_SUCCESS + case("KDT") + dest = [parameters%kdt] + bmi_status = BMI_SUCCESS + case("RSURF_EXP") + dest = [parameters%RSURF_EXP] + bmi_status = BMI_SUCCESS + case("REFKDT") + dest = [parameters%refkdt] + bmi_status = BMI_SUCCESS + case("AXAJ") + dest = [parameters%AXAJ] + bmi_status = BMI_SUCCESS + case("BXAJ") + dest = [parameters%BXAJ] + bmi_status = BMI_SUCCESS + case("XXAJ") + dest = [parameters%XXAJ] + bmi_status = BMI_SUCCESS + case("SLOPE") + dest = [parameters%slope] + bmi_status = BMI_SUCCESS + case("SCAMAX") + dest = [parameters%SCAMAX] + bmi_status = BMI_SUCCESS case default dest(:) = -1.0 bmi_status = BMI_FAILURE @@ -1084,55 +1226,113 @@ function noahowp_set_float(this, name, src) result (bmi_status) real :: mm2m = 0.001 ! unit conversion mm to m real :: m2mm = 1000. ! unit conversion m to mm + associate(forcing => this%model%forcing, & + water => this%model%water, & + energy => this%model%energy, & + domain => this%model%domain, & + parameters => this%model%parameters) + select case(name) case("SFCPRS") - this%model%forcing%sfcprs = src(1) + forcing%sfcprs = src(1) bmi_status = BMI_SUCCESS case("SFCTMP") - this%model%forcing%sfctmp = src(1) + forcing%sfctmp = src(1) bmi_status = BMI_SUCCESS case("SOLDN") - this%model%forcing%soldn = src(1) + forcing%soldn = src(1) bmi_status = BMI_SUCCESS case("LWDN") - this%model%forcing%lwdn = src(1) + forcing%lwdn = src(1) bmi_status = BMI_SUCCESS case("UU") - this%model%forcing%uu = src(1) + forcing%uu = src(1) bmi_status = BMI_SUCCESS case("VV") - this%model%forcing%vv = src(1) + forcing%vv = src(1) bmi_status = BMI_SUCCESS case("Q2") - this%model%forcing%q2 = src(1) + forcing%q2 = src(1) bmi_status = BMI_SUCCESS case("PRCPNONC") - this%model%forcing%prcpnonc = src(1) + forcing%prcpnonc = src(1) bmi_status = BMI_SUCCESS case("QINSUR") - this%model%water%qinsur = src(1) + water%qinsur = src(1) bmi_status = BMI_SUCCESS case("ETRAN") - this%model%water%etran = src(1) / this%model%domain%DT + water%etran = src(1) / domain%DT bmi_status = BMI_SUCCESS case("QSEVA") - this%model%water%qseva = src(1) * mm2m + water%qseva = src(1) * mm2m bmi_status = BMI_SUCCESS case("EVAPOTRANS") - this%model%water%evapotrans = src(1) * m2mm / this%model%domain%DT + water%evapotrans = src(1) * m2mm / domain%DT bmi_status = BMI_SUCCESS case("TG") - this%model%energy%tg = src(1) + energy%tg = src(1) bmi_status = BMI_SUCCESS case("SNEQV") - this%model%water%sneqv = src(1) + water%sneqv = src(1) bmi_status = BMI_SUCCESS case("TGS") - this%model%energy%tgs = src(1) + energy%tgs = src(1) + bmi_status = BMI_SUCCESS + case("CWP") + parameters%CWP = src(1) + bmi_status = BMI_SUCCESS + case("VCMX25") + parameters%VCMX25 = src(1) + bmi_status = BMI_SUCCESS + case("MP") + parameters%MP = src(1) + bmi_status = BMI_SUCCESS + case("MFSNO") + parameters%MFSNO = src(1) + bmi_status = BMI_SUCCESS + case("RSURF_SNOW") + parameters%RSURF_SNOW = src(1) + bmi_status = BMI_SUCCESS + case("HVT") + parameters%HVT = src(1) + bmi_status = BMI_SUCCESS + case("BEXP") + parameters%bexp(:) = src(:) + bmi_status = BMI_SUCCESS + case("SMCMAX") + parameters%smcmax(:) = src(:) + parameters%frzx = 0.15 * (parameters%smcmax(1) / parameters%smcref(1)) * (0.412 / 0.468) + bmi_status = BMI_SUCCESS + case("DKSAT") + parameters%dksat(:) = src(:) + parameters%kdt = parameters%refkdt * parameters%dksat(1) / parameters%refdk + bmi_status = BMI_SUCCESS + case("RSURF_EXP") + parameters%RSURF_EXP = src(1) + bmi_status = BMI_SUCCESS + case("REFKDT") + parameters%refkdt = src(1) + parameters%kdt = parameters%refkdt * parameters%dksat(1) / parameters%refdk + bmi_status = BMI_SUCCESS + case("AXAJ") + parameters%AXAJ = src(1) + bmi_status = BMI_SUCCESS + case("BXAJ") + parameters%BXAJ = src(1) + bmi_status = BMI_SUCCESS + case("XXAJ") + parameters%XXAJ = src(1) + bmi_status = BMI_SUCCESS + case("SLOPE") + parameters%slope = src(1) + bmi_status = BMI_SUCCESS + case("SCAMAX") + parameters%SCAMAX = src(1) bmi_status = BMI_SUCCESS case default bmi_status = BMI_FAILURE end select + end associate ! NOTE, if vars are gridded, then use: ! this%model%temperature = reshape(src, [this%model%n_y, this%model%n_x]) end function noahowp_set_float diff --git a/src/EnergyModule.f90 b/src/EnergyModule.f90 index 7eff19a3..c68947b8 100644 --- a/src/EnergyModule.f90 +++ b/src/EnergyModule.f90 @@ -85,7 +85,7 @@ SUBROUTINE EnergyMain (domain, levels, options, parameters, forcing, energy, wat IF(water%SNOWH > 0.0) THEN water%BDSNO = water%SNEQV / water%SNOWH FMELT = (water%BDSNO / 100.)**parameters%MFSNO - water%FSNO = TANH( water%SNOWH /(2.5 * parameters%Z0 * FMELT)) ! eq. 4 from Niu and Yang (2007) + water%FSNO = parameters%SCAMAX * TANH( water%SNOWH /(2.5 * parameters%Z0 * FMELT)) ! eq. 4 from Niu and Yang (2007) ENDIF ! Compute ground roughness length diff --git a/src/ParametersType.f90 b/src/ParametersType.f90 index f57a2ff0..82521c05 100644 --- a/src/ParametersType.f90 +++ b/src/ParametersType.f90 @@ -142,7 +142,8 @@ module ParametersType real :: TBOT ! bottom condition for soil temp. (k) real :: GRAV ! acceleration due to gravity (m/s2) real :: rain_snow_thresh ! user-defined rain-snow temperature threshold (°C) - + real :: SCAMAX ! maximum fractional snow-covered area + contains procedure, public :: Init @@ -193,6 +194,7 @@ subroutine InitDefault(this) this%VAI = huge(1.0) this%VEG = .true. this%FVEG = huge(1.0) + this%SCAMAX = 1. end subroutine InitDefault diff --git a/test/noahowp_driver_test.f90 b/test/noahowp_driver_test.f90 index 0634712f..d70eae89 100644 --- a/test/noahowp_driver_test.f90 +++ b/test/noahowp_driver_test.f90 @@ -34,6 +34,7 @@ program noahmp_driver_test character (len = BMI_MAX_VAR_NAME) :: name ! var name integer :: n_inputs ! n input vars integer :: n_outputs ! n output vars + integer :: n_params ! n calibratable parameters integer :: iBMI ! loop counter character (len = 20) :: var_type ! name of variable type character (len = 10) :: var_units ! variable units @@ -65,6 +66,9 @@ program noahmp_driver_test integer, pointer :: var_value_get_int_ptr(:) ! value of a variable for get_value_ptr integer, allocatable, dimension(:) :: grid_indices ! grid indices (change dims as needed) + character (len = BMI_MAX_VAR_NAME), dimension(17) :: names_params = [character(len=BMI_MAX_VAR_NAME) :: "CWP","VCMX25","MP","MFSNO","RSURF_SNOW","HVT","BEXP","SMCMAX","FRZX", & + "DKSAT","KDT","RSURF_EXP","REFKDT","AXAJ","BXAJ","SLOPE","SCAMAX"] + !--------------------------------------------------------------------- ! Initialize !--------------------------------------------------------------------- @@ -88,6 +92,10 @@ program noahmp_driver_test print*, "Total output vars = ", count n_outputs = count + count = size(names_params) + write(*,'(a,I5)') "Total calibratable parameters = ", count + n_params = count + status = m%get_input_var_names(names_inputs) do iBMI = 1, n_inputs print*, "Input var = ", trim(names_inputs(iBMI)) @@ -97,17 +105,23 @@ program noahmp_driver_test do iBMI = 1, n_outputs print*, "Output var = ", trim(names_outputs(iBMI)) end do + + do iBMI = 1, n_params + print*, "Calibratable param = ", trim(names_params(iBMI)) + end do ! Sum input and outputs to get total vars - count = n_inputs + n_outputs + count = n_inputs + n_outputs + n_params ! Get other variable info do j = 1, count name = '' if(j <= n_inputs) then - name = names_inputs(j) + name = trim(names_inputs(j)) + else if(j <= n_inputs + n_outputs) then + name = trim(names_outputs(j - n_inputs)) else - name = names_outputs(j - n_inputs) + name = trim(names_params(j - n_inputs - n_outputs)) end if status = m%get_var_type(trim(name), var_type) status = m%get_var_units(trim(name), var_units) @@ -171,9 +185,11 @@ program noahmp_driver_test do iBMI = 1, count name = '' if(iBMI <= n_inputs) then - name = names_inputs(iBMI) + name = trim(names_inputs(iBMI)) + else if(iBMI <= n_inputs + n_outputs) then + name = trim(names_outputs(iBMI - n_inputs)) else - name = names_outputs(iBMI - n_inputs) + name = trim(names_params(iBMI - n_inputs - n_outputs)) end if status = m%get_var_type(trim(name),var_type) status = m%get_var_grid(trim(name),grid_int) @@ -213,9 +229,11 @@ program noahmp_driver_test do iBMI = 1, count name = '' if(iBMI <= n_inputs) then - name = names_inputs(iBMI) + name = trim(names_inputs(iBMI)) + else if(iBMI <= n_inputs + n_outputs) then + name = trim(names_outputs(iBMI - n_inputs)) else - name = names_outputs(iBMI - n_inputs) + name = trim(names_params(iBMI - n_inputs - n_outputs)) end if status = m%get_var_type(trim(name),var_type) status = m%get_var_grid(trim(name),grid_int) @@ -250,9 +268,11 @@ program noahmp_driver_test do iBMI = 1, count name = '' if(iBMI <= n_inputs) then - name = names_inputs(iBMI) + name = trim(names_inputs(iBMI)) + else if(iBMI <= n_inputs + n_outputs) then + name = trim(names_outputs(iBMI - n_inputs)) else - name = names_outputs(iBMI - n_inputs) + name = trim(names_params(iBMI - n_inputs - n_outputs)) end if status = m%get_var_type(trim(name),var_type) status = m%get_var_grid(trim(name),grid_int) @@ -300,22 +320,28 @@ program noahmp_driver_test !--------------------------------------------------------------------- ! Test the grid info functionality with BMI !--------------------------------------------------------------------- + do iBMI = 1, count - ! All vars currently have same spatial discretization - ! Modify to test all discretizations if > 1 + name = '' + if(iBMI <= n_inputs) then + name = trim(names_inputs(iBMI)) + else if(iBMI <= n_inputs + n_outputs) then + name = trim(names_outputs(iBMI - n_inputs)) + else + name = trim(names_params(iBMI - n_inputs - n_outputs)) + end if ! get_var_grid - iBMI = 1 - status = m%get_var_grid(trim(names_outputs(iBMI)), grid_int) - print*, "The integer value for the ", trim(names_outputs(iBMI)), " grid is ", grid_int + status = m%get_var_grid(trim(name), grid_int) + print*, "The integer value for the ", trim(name), " grid is ", grid_int ! get_grid_type status = m%get_grid_type(grid_int, grid_type) - print*, "The grid type for ", trim(names_outputs(iBMI)), " is ", trim(grid_type) + print*, "The grid type for ", trim(name), " is ", trim(grid_type) ! get_grid_rank status = m%get_grid_rank(grid_int, grid_rank) - print*, "The grid rank for ", trim(names_outputs(iBMI)), " is ", grid_rank + print*, "The grid rank for ", trim(name), " is ", grid_rank ! get_grid_shape ! only scalars implemented thus far @@ -326,7 +352,7 @@ program noahmp_driver_test ! get_grid_size status = m%get_grid_size(grid_int, grid_size) - print*, "The grid size for ", trim(names_outputs(iBMI)), " is ", grid_size + print*, "The grid size for ", trim(name), " is ", grid_size ! get_grid_spacing ! only scalars implemented thus far @@ -351,6 +377,8 @@ program noahmp_driver_test print*, "The Y coord for grid ", grid_int, " is ", grid_y print*, "The Z coord for grid ", grid_int, " is ", grid_z + end do + !--------------------------------------------------------------------- ! The following functions are not implemented/only return BMI_FAILURE ! Change if your model implements them From f556af5c2a69d46834568acc1da1cb44adf8779c Mon Sep 17 00:00:00 2001 From: GreyEvenson-NOAA Date: Tue, 12 Mar 2024 13:45:29 -0400 Subject: [PATCH 2/9] Cleanup --- bmi/bmi_noahowp.f90 | 18 ++++++++---------- test/noahowp_driver_test.f90 | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/bmi/bmi_noahowp.f90 b/bmi/bmi_noahowp.f90 index df21492d..bd44166d 100644 --- a/bmi/bmi_noahowp.f90 +++ b/bmi/bmi_noahowp.f90 @@ -106,14 +106,6 @@ module bminoahowp character (len=BMI_MAX_VAR_NAME), target, & dimension(output_item_count) :: output_items - character(len=BMI_MAX_VAR_NAME), & - dimension(param_item_count) :: param_items = & - [character(len=BMI_MAX_VAR_NAME) :: & - "CWP","VCMX25","MP","MFSNO","RSURF_SNOW","HVT", & - "BEXP","SMCMAX","FRZX","DKSAT","KDT","RSURF_EXP","REFKDT", & - "AXAJ","BXAJ","XXAJ","SLOPE","SCAMAX"] - integer, dimension(param_item_count) :: param_grid = 0 - contains ! Get the name of the model. @@ -393,6 +385,12 @@ function noahowp_grid_shape(this, grid, shape) result (bmi_status) ! case(1) ! shape(:) = [this%model%n_y, this%model%n_x] ! bmi_status = BMI_SUCCESS + case (1) + shape(:) = [this%model%levels%nsnow] + bmi_status = BMI_SUCCESS + case (2) + shape(:) = [this%model%levels%nsoil] + bmi_status = BMI_SUCCESS case default shape(:) = -1 bmi_status = BMI_FAILURE @@ -608,8 +606,8 @@ function noahowp_var_type(this, name, type) result (bmi_status) case('SFCPRS', 'SFCTMP', 'SOLDN', 'LWDN', 'UU', 'VV', 'Q2', 'PRCPNONC', & ! forcing vars 'QINSUR', 'ETRAN', 'QSEVA', 'EVAPOTRANS', 'TG', 'SNEQV', 'TGS', 'ACSNOM', 'SNOWT_AVG', & ! output vars 'QRAIN', 'FSNO', 'SNOWH', 'SNLIQ', 'QSNOW', 'ECAN', 'GH', 'TRAD', 'FSA', 'CMC', 'LH', 'FIRA', 'FSH', & - 'CWP','VCMX25','MP','MFSNO','RSURF_SNOW','HVT','FRXZ','KDT','RSURF_EXP','REFKDT', & - 'AXAJ','BXAJ','XXAJ','SLOPE','SCAMAX') + 'CWP','VCMX25','MP','MFSNO','RSURF_SNOW','HVT','FRZX','KDT','RSURF_EXP','REFKDT', & + 'AXAJ','BXAJ','XXAJ','SLOPE','SCAMAX','BEXP','SMCMAX','DKSAT') type = "real" bmi_status = BMI_SUCCESS case('ISNOW') diff --git a/test/noahowp_driver_test.f90 b/test/noahowp_driver_test.f90 index d70eae89..6f175ddc 100644 --- a/test/noahowp_driver_test.f90 +++ b/test/noahowp_driver_test.f90 @@ -93,7 +93,7 @@ program noahmp_driver_test n_outputs = count count = size(names_params) - write(*,'(a,I5)') "Total calibratable parameters = ", count + print*, "Total calibratable parameters = ", count n_params = count status = m%get_input_var_names(names_inputs) From 03309641e61e0cf3aff55bffd93db4011276123c Mon Sep 17 00:00:00 2001 From: GreyEvenson-NOAA Date: Tue, 12 Mar 2024 13:54:43 -0400 Subject: [PATCH 3/9] remove param_item_count as BMI module var --- bmi/bmi_noahowp.f90 | 1 - 1 file changed, 1 deletion(-) diff --git a/bmi/bmi_noahowp.f90 b/bmi/bmi_noahowp.f90 index bd44166d..8da49159 100644 --- a/bmi/bmi_noahowp.f90 +++ b/bmi/bmi_noahowp.f90 @@ -99,7 +99,6 @@ module bminoahowp ! Exchange items integer, parameter :: input_item_count = 8 integer, parameter :: output_item_count = 23 - integer, parameter :: param_item_count = 18 character (len=BMI_MAX_VAR_NAME), target, & dimension(input_item_count) :: input_items From a46feacd28df1c7b87358a99446ed0b2d8567c5b Mon Sep 17 00:00:00 2001 From: GreyEvenson-NOAA Date: Tue, 12 Mar 2024 14:42:20 -0400 Subject: [PATCH 4/9] Cleanup --- bmi/bmi_noahowp.f90 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bmi/bmi_noahowp.f90 b/bmi/bmi_noahowp.f90 index 8da49159..f1247c16 100644 --- a/bmi/bmi_noahowp.f90 +++ b/bmi/bmi_noahowp.f90 @@ -152,7 +152,6 @@ function noahowp_input_var_names(this, names) result (bmi_status) input_items(7) = 'Q2' ! mixing ratio (kg/kg) input_items(8) = 'PRCPNONC' ! precipitation rate (mm/s) - names => input_items bmi_status = BMI_SUCCESS end function noahowp_input_var_names @@ -307,7 +306,7 @@ function noahowp_var_grid(this, name, grid) result (bmi_status) 'QINSUR', 'ETRAN', 'QSEVA', 'EVAPOTRANS', 'TG', 'SNEQV', 'TGS', & ! output vars 'ACSNOM','SNOWT_AVG','ISNOW','QRAIN','FSNO','SNOWH','QSNOW', & 'ECAN','GH','TRAD','FSA','CMC','LH','FIRA','FSH','CWP','VCMX25', & - 'MP','MFSNO','RSURF_SNOW','HVT','FRXZ','KDT','RSURF_EXP','REFKDT', & + 'MP','MFSNO','RSURF_SNOW','HVT','FRZX','KDT','RSURF_EXP','REFKDT', & 'AXAJ','BXAJ','XXAJ','SLOPE','SCAMAX') grid = 0 bmi_status = BMI_SUCCESS @@ -1304,6 +1303,9 @@ function noahowp_set_float(this, name, src) result (bmi_status) parameters%dksat(:) = src(:) parameters%kdt = parameters%refkdt * parameters%dksat(1) / parameters%refdk bmi_status = BMI_SUCCESS + case("KDT") + parameters%KDT = src(1) + bmi_status = BMI_SUCCESS case("RSURF_EXP") parameters%RSURF_EXP = src(1) bmi_status = BMI_SUCCESS @@ -1326,6 +1328,9 @@ function noahowp_set_float(this, name, src) result (bmi_status) case("SCAMAX") parameters%SCAMAX = src(1) bmi_status = BMI_SUCCESS + case("FRZX") + parameters%FRZX = src(1) + bmi_status = BMI_SUCCESS case default bmi_status = BMI_FAILURE end select From 5aa36414227fbae40f590cf5dc52da11b75a7c90 Mon Sep 17 00:00:00 2001 From: GreyEvenson-NOAA Date: Tue, 12 Mar 2024 14:56:26 -0400 Subject: [PATCH 5/9] Removing space in BMI module header in hopes that auto tests succeed --- bmi/bmi_noahowp.f90 | 1 - 1 file changed, 1 deletion(-) diff --git a/bmi/bmi_noahowp.f90 b/bmi/bmi_noahowp.f90 index f1247c16..cb46fc4c 100644 --- a/bmi/bmi_noahowp.f90 +++ b/bmi/bmi_noahowp.f90 @@ -99,7 +99,6 @@ module bminoahowp ! Exchange items integer, parameter :: input_item_count = 8 integer, parameter :: output_item_count = 23 - character (len=BMI_MAX_VAR_NAME), target, & dimension(input_item_count) :: input_items character (len=BMI_MAX_VAR_NAME), target, & From 9f27c55063055b57a892e001c4c10f1082ff0f9b Mon Sep 17 00:00:00 2001 From: GreyEvenson-NOAA Date: Tue, 12 Mar 2024 16:04:07 -0400 Subject: [PATCH 6/9] Update unit test to print values for secondary parameter recalculations --- test/noahowp_driver_test.f90 | 43 +++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/test/noahowp_driver_test.f90 b/test/noahowp_driver_test.f90 index 6f175ddc..80fbc521 100644 --- a/test/noahowp_driver_test.f90 +++ b/test/noahowp_driver_test.f90 @@ -47,6 +47,7 @@ program noahmp_driver_test double precision :: current_time ! current model time character (len = 1) :: ts_units ! timestep units real, allocatable, target :: var_value_get_real(:) ! value of a variable + real, allocatable, target :: var_value_get_real_temp(:) ! value of a variable real, allocatable :: var_value_set_real(:) ! value of a variable integer, allocatable, target :: var_value_get_int(:) ! value of a variable integer, allocatable :: var_value_set_int(:) ! value of a variable @@ -61,7 +62,7 @@ program noahmp_driver_test double precision, dimension(1) :: grid_x ! X coordinate of grid nodes (change dims if multiple nodes) double precision, dimension(1) :: grid_y ! Y coordinate of grid nodes (change dims if multiple nodes) double precision, dimension(1) :: grid_z ! Y coordinate of grid nodes (change dims if multiple nodes) - + real :: temp_scalar real, pointer :: var_value_get_real_ptr(:) ! value of a variable for get_value_ptr integer, pointer :: var_value_get_int_ptr(:) ! value of a variable for get_value_ptr @@ -214,10 +215,50 @@ program noahmp_driver_test var_value_set_real = 999 status = m%get_value(trim(name), var_value_get_real) print*, trim(name), " from get_value = ", var_value_get_real + select case (trim(name)) + case('SMCMAX') + if(allocated(var_value_get_real_temp)) deallocate(var_value_get_real_temp) + allocate(var_value_get_real_temp(1)) + status = m%get_value('FRZX', var_value_get_real_temp) + print*," (FRZX is recalculated by setting SMCMAX)" + print*," from get_value (for FRZX)= ", var_value_get_real_temp + case('DKSAT') + if(allocated(var_value_get_real_temp)) deallocate(var_value_get_real_temp) + allocate(var_value_get_real_temp(1)) + status = m%get_value('KDT', var_value_get_real_temp) + print*," (KDT is recalculated by setting DKSAT)" + print*," from get_value (for KDT)= ", var_value_get_real_temp + case('REFKDT') + if(allocated(var_value_get_real_temp)) deallocate(var_value_get_real_temp) + allocate(var_value_get_real_temp(1)) + status = m%get_value('KDT', var_value_get_real_temp) + print*," (KDT is recalculated by setting REFKDT)" + print*," from get_value (for KDT)= ", var_value_get_real_temp + end select print*, " our replacement value = ", var_value_set_real status = m%set_value(trim(name), var_value_set_real) status = m%get_value(trim(name), var_value_get_real) print*, " and the new value of ", trim(name), " = ", var_value_get_real + select case (trim(name)) + case('SMCMAX') + if(allocated(var_value_get_real_temp)) deallocate(var_value_get_real_temp) + allocate(var_value_get_real_temp(1)) + status = m%get_value('FRZX', var_value_get_real_temp) + print*," (FRZX is recalculated by setting SMCMAX)" + print*," from get_value (for FRZX)= ", var_value_get_real_temp + case('DKSAT') + if(allocated(var_value_get_real_temp)) deallocate(var_value_get_real_temp) + allocate(var_value_get_real_temp(1)) + status = m%get_value('KDT', var_value_get_real_temp) + print*," (KDT is recalculated by setting DKSAT)" + print*," from get_value (for KDT)= ", var_value_get_real_temp + case('REFKDT') + if(allocated(var_value_get_real_temp)) deallocate(var_value_get_real_temp) + allocate(var_value_get_real_temp(1)) + status = m%get_value('KDT', var_value_get_real_temp) + print*," (KDT is recalculated by setting REFKDT)" + print*," from get_value (for KDT)= ", var_value_get_real_temp + end select end if end do From f439558c0aba0532cdad5514a0c6edfedaff7732 Mon Sep 17 00:00:00 2001 From: GreyEvenson-NOAA Date: Tue, 12 Mar 2024 16:14:21 -0400 Subject: [PATCH 7/9] Cleanup --- bmi/bmi_noahowp.f90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bmi/bmi_noahowp.f90 b/bmi/bmi_noahowp.f90 index cb46fc4c..09591ff0 100644 --- a/bmi/bmi_noahowp.f90 +++ b/bmi/bmi_noahowp.f90 @@ -383,10 +383,10 @@ function noahowp_grid_shape(this, grid, shape) result (bmi_status) ! shape(:) = [this%model%n_y, this%model%n_x] ! bmi_status = BMI_SUCCESS case (1) - shape(:) = [this%model%levels%nsnow] + shape(:) = this%model%levels%nsnow bmi_status = BMI_SUCCESS case (2) - shape(:) = [this%model%levels%nsoil] + shape(:) = this%model%levels%nsoil bmi_status = BMI_SUCCESS case default shape(:) = -1 From 364dcc46af9c1d860f6a46a7080877f8797798a2 Mon Sep 17 00:00:00 2001 From: GreyEvenson-NOAA Date: Tue, 9 Apr 2024 09:42:26 -0400 Subject: [PATCH 8/9] alphabatize some variable lists for easier reading --- bmi/bmi_noahowp.f90 | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/bmi/bmi_noahowp.f90 b/bmi/bmi_noahowp.f90 index 09591ff0..2aa78711 100644 --- a/bmi/bmi_noahowp.f90 +++ b/bmi/bmi_noahowp.f90 @@ -301,18 +301,19 @@ function noahowp_var_grid(this, name, grid) result (bmi_status) integer :: bmi_status select case(name) - case('SFCPRS', 'SFCTMP', 'SOLDN', 'LWDN', 'UU', 'VV', 'Q2', 'PRCPNONC', & ! input vars - 'QINSUR', 'ETRAN', 'QSEVA', 'EVAPOTRANS', 'TG', 'SNEQV', 'TGS', & ! output vars - 'ACSNOM','SNOWT_AVG','ISNOW','QRAIN','FSNO','SNOWH','QSNOW', & - 'ECAN','GH','TRAD','FSA','CMC','LH','FIRA','FSH','CWP','VCMX25', & - 'MP','MFSNO','RSURF_SNOW','HVT','FRZX','KDT','RSURF_EXP','REFKDT', & - 'AXAJ','BXAJ','XXAJ','SLOPE','SCAMAX') + case('ACSNOM', 'AXAJ', 'BXAJ', 'CMC', 'CWP', 'ECAN', 'ETRAN', & + 'EVAPOTRANS', 'FIRA', 'FRZX', 'FSA', 'FSH', 'FSNO', 'GH', & + 'HVT', 'ISNOW', 'KDT', 'LH', 'LWDN', 'MFSNO', 'MP', 'PRCPNONC', & + 'Q2', 'QINSUR', 'QRAIN', 'QSEVA', 'QSNOW', 'REFKDT', 'RSURF_EXP', & + 'RSURF_SNOW', 'SCAMAX', 'SFCPRS', 'SFCTMP', 'SLOPE', 'SNEQV', & + 'SNOWH', 'SNOWT_AVG', 'SOLDN', 'TG', 'TGS', 'TRAD', 'UU', 'VCMX25', & + 'VV', 'XXAJ') grid = 0 bmi_status = BMI_SUCCESS case('SNLIQ') grid = 1 bmi_status = BMI_SUCCESS - case('BEXP','SMCMAX','DKSAT') + case('BEXP','DKSAT','SMCMAX') grid = 2 bmi_status = BMI_SUCCESS case default @@ -600,11 +601,13 @@ function noahowp_var_type(this, name, type) result (bmi_status) integer :: bmi_status select case(name) - case('SFCPRS', 'SFCTMP', 'SOLDN', 'LWDN', 'UU', 'VV', 'Q2', 'PRCPNONC', & ! forcing vars - 'QINSUR', 'ETRAN', 'QSEVA', 'EVAPOTRANS', 'TG', 'SNEQV', 'TGS', 'ACSNOM', 'SNOWT_AVG', & ! output vars - 'QRAIN', 'FSNO', 'SNOWH', 'SNLIQ', 'QSNOW', 'ECAN', 'GH', 'TRAD', 'FSA', 'CMC', 'LH', 'FIRA', 'FSH', & - 'CWP','VCMX25','MP','MFSNO','RSURF_SNOW','HVT','FRZX','KDT','RSURF_EXP','REFKDT', & - 'AXAJ','BXAJ','XXAJ','SLOPE','SCAMAX','BEXP','SMCMAX','DKSAT') + case('ACSNOM', 'AXAJ', 'BEXP', 'BXAJ', 'CMC', 'CWP', 'DKSAT', & + 'ECAN', 'ETRAN', 'EVAPOTRANS', 'FIRA', 'FRZX', 'FSA', 'FSH', & + 'FSNO', 'GH', 'HVT', 'KDT', 'LH', 'LWDN', 'MFSNO', 'MP', & + 'PRCPNONC', 'Q2', 'QINSUR', 'QRAIN', 'QSEVA', 'QSNOW', 'REFKDT', & + 'RSURF_EXP', 'RSURF_SNOW', 'SCAMAX', 'SFCPRS', 'SFCTMP', 'SLOPE', & + 'SMCMAX', 'SNEQV', 'SNLIQ', 'SNOWH', 'SNOWT_AVG', 'SOLDN', 'TG', & + 'TGS', 'TRAD', 'UU', 'VCMX25', 'VV', 'XXAJ') type = "real" bmi_status = BMI_SUCCESS case('ISNOW') From cab75c8eecb26c2926f6a01cdf9d71dab2ec0248 Mon Sep 17 00:00:00 2001 From: GreyEvenson-NOAA Date: Tue, 9 Apr 2024 12:55:21 -0400 Subject: [PATCH 9/9] Alphabatize other BMI function listings --- bmi/bmi_noahowp.f90 | 734 ++++++++++++++++++++++---------------------- 1 file changed, 367 insertions(+), 367 deletions(-) diff --git a/bmi/bmi_noahowp.f90 b/bmi/bmi_noahowp.f90 index 2aa78711..c68f3893 100644 --- a/bmi/bmi_noahowp.f90 +++ b/bmi/bmi_noahowp.f90 @@ -689,153 +689,153 @@ function noahowp_var_itemsize(this, name, size) result (bmi_status) parameters => this%model%parameters) select case(name) - case("SFCPRS") - size = sizeof(forcing%sfcprs) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("SFCTMP") - size = sizeof(forcing%sfctmp) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("SOLDN") - size = sizeof(forcing%soldn) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("LWDN") - size = sizeof(forcing%lwdn) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("UU") - size = sizeof(forcing%uu) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("VV") - size = sizeof(forcing%vv) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("Q2") - size = sizeof(forcing%q2) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("PRCPNONC") - size = sizeof(forcing%prcpnonc) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("QINSUR") - size = sizeof(water%qinsur) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS + case("ACSNOM") + size = sizeof(water%ACSNOM) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("AXAJ") + size = sizeof(parameters%AXAJ) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("BEXP") + size = sizeof(parameters%bexp(1)) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("BXAJ") + size = sizeof(parameters%BXAJ) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("CMC") + size = sizeof(water%CMC) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("CWP") + size = sizeof(parameters%CWP) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("DKSAT") + size = sizeof(parameters%dksat(1)) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("ECAN") + size = sizeof(water%ECAN) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS case("ETRAN") - size = sizeof(water%etran) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("QSEVA") - size = sizeof(water%qseva) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS + size = sizeof(water%etran) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS case("EVAPOTRANS") - size = sizeof(water%evapotrans) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("TG") - size = sizeof(energy%tg) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("SNEQV") - size = sizeof(water%sneqv) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("TGS") - size = sizeof(energy%tgs) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("ACSNOM") - size = sizeof(water%ACSNOM) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("SNOWT_AVG") - size = sizeof(energy%SNOWT_AVG) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("ISNOW") - size = sizeof(water%ISNOW) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("QRAIN") - size = sizeof(water%QRAIN) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS + size = sizeof(water%evapotrans) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("FIRA") + size = sizeof(energy%FIRA) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("FRZX") + size = sizeof(parameters%frzx) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("FSA") + size = sizeof(energy%FSA) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("FSH") + size = sizeof(energy%FSH) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS case("FSNO") - size = sizeof(water%FSNO) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("SNOWH") - size = sizeof(water%SNOWH) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("QSNOW") - size = sizeof(water%QSNOW) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("ECAN") - size = sizeof(water%ECAN) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS + size = sizeof(water%FSNO) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS case("GH") - size = sizeof(energy%GH) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("TRAD") - size = sizeof(energy%TRAD) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("FSA") - size = sizeof(energy%FSA) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("CMC") - size = sizeof(water%CMC) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS + size = sizeof(energy%GH) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("HVT") + size = sizeof(parameters%HVT) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("ISNOW") + size = sizeof(water%ISNOW) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("KDT") + size = sizeof(parameters%kdt) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS case("LH") - size = sizeof(energy%LH) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("FIRA") - size = sizeof(energy%FIRA) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("FSH") - size = sizeof(energy%FSH) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("SNLIQ") - size = sizeof(water%SNLIQ(1)) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("CWP") - size = sizeof(parameters%CWP) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("VCMX25") - size = sizeof(parameters%VCMX25) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("MP") - size = sizeof(parameters%MP) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS + size = sizeof(energy%LH) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("LWDN") + size = sizeof(forcing%lwdn) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS case("MFSNO") - size = sizeof(parameters%MFSNO) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS + size = sizeof(parameters%MFSNO) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("MP") + size = sizeof(parameters%MP) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("PRCPNONC") + size = sizeof(forcing%prcpnonc) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("Q2") + size = sizeof(forcing%q2) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("QINSUR") + size = sizeof(water%qinsur) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("QRAIN") + size = sizeof(water%QRAIN) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("QSEVA") + size = sizeof(water%qseva) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("QSNOW") + size = sizeof(water%QSNOW) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("REFKDT") + size = sizeof(parameters%refkdt) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("RSURF_EXP") + size = sizeof(parameters%RSURF_EXP) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS case("RSURF_SNOW") - size = sizeof(parameters%RSURF_SNOW) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("HVT") - size = sizeof(parameters%HVT) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("BEXP") - size = sizeof(parameters%bexp(1)) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS + size = sizeof(parameters%RSURF_SNOW) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("SCAMAX") + size = sizeof(parameters%SCAMAX) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("SFCPRS") + size = sizeof(forcing%sfcprs) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("SFCTMP") + size = sizeof(forcing%sfctmp) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("SLOPE") + size = sizeof(parameters%slope) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS case("SMCMAX") - size = sizeof(parameters%smcmax(1)) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("DKSAT") - size = sizeof(parameters%dksat(1)) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("RSURF_EXP") - size = sizeof(parameters%RSURF_EXP) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("REFKDT") - size = sizeof(parameters%refkdt) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("AXAJ") - size = sizeof(parameters%AXAJ) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("BXAJ") - size = sizeof(parameters%BXAJ) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS + size = sizeof(parameters%smcmax(1)) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("SNEQV") + size = sizeof(water%sneqv) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("SNLIQ") + size = sizeof(water%SNLIQ(1)) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("SNOWH") + size = sizeof(water%SNOWH) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("SNOWT_AVG") + size = sizeof(energy%SNOWT_AVG) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("SOLDN") + size = sizeof(forcing%soldn) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("TG") + size = sizeof(energy%tg) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("TGS") + size = sizeof(energy%tgs) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("TRAD") + size = sizeof(energy%TRAD) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("UU") + size = sizeof(forcing%uu) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("VCMX25") + size = sizeof(parameters%VCMX25) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS + case("VV") + size = sizeof(forcing%vv) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS case("XXAJ") - size = sizeof(parameters%XXAJ) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("SLOPE") - size = sizeof(parameters%slope) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("FRZX") - size = sizeof(parameters%frzx) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("KDT") - size = sizeof(parameters%kdt) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS - case("SCAMAX") - size = sizeof(parameters%SCAMAX) ! 'sizeof' in gcc & ifort - bmi_status = BMI_SUCCESS + size = sizeof(parameters%XXAJ) ! 'sizeof' in gcc & ifort + bmi_status = BMI_SUCCESS case default size = -1 bmi_status = BMI_FAILURE @@ -918,150 +918,150 @@ function noahowp_get_float(this, name, dest) result (bmi_status) parameters => this%model%parameters) select case(name) - case("SFCPRS") - dest = [forcing%sfcprs] - bmi_status = BMI_SUCCESS - case("SFCTMP") - dest = [forcing%sfctmp] - bmi_status = BMI_SUCCESS - case("SOLDN") - dest = [forcing%soldn] - bmi_status = BMI_SUCCESS - case("LWDN") - dest = [forcing%lwdn] - bmi_status = BMI_SUCCESS - case("UU") - dest = [forcing%uu] - bmi_status = BMI_SUCCESS - case("VV") - dest = [forcing%vv] - bmi_status = BMI_SUCCESS - case("Q2") - dest = [forcing%q2] - bmi_status = BMI_SUCCESS - case("PRCPNONC") - dest = [forcing%prcpnonc] - bmi_status = BMI_SUCCESS - case("QINSUR") - dest = [water%qinsur] - bmi_status = BMI_SUCCESS + case("ACSNOM") + dest = [water%ACSNOM] + bmi_status = BMI_SUCCESS + case("AXAJ") + dest = [parameters%AXAJ] + bmi_status = BMI_SUCCESS + case("BEXP") + dest = [parameters%bexp] + bmi_status = BMI_SUCCESS + case("BXAJ") + dest = [parameters%BXAJ] + bmi_status = BMI_SUCCESS + case("CMC") + dest = [water%CMC] + bmi_status = BMI_SUCCESS + case("CWP") + dest = [parameters%CWP] + bmi_status = BMI_SUCCESS + case("DKSAT") + dest = [parameters%dksat] + bmi_status = BMI_SUCCESS + case("ECAN") + dest = [water%ECAN*domain%DT] + bmi_status = BMI_SUCCESS case("ETRAN") - dest = [water%etran*domain%DT] - bmi_status = BMI_SUCCESS - case("QSEVA") - dest = [water%qseva*m2mm] - bmi_status = BMI_SUCCESS + dest = [water%etran*domain%DT] + bmi_status = BMI_SUCCESS case("EVAPOTRANS") - dest = [water%evapotrans*domain%DT*mm2m] - bmi_status = BMI_SUCCESS - case("TG") - dest = [energy%tg] - bmi_status = BMI_SUCCESS - case("SNEQV") - dest = [water%sneqv] - bmi_status = BMI_SUCCESS - case("TGS") - dest = [energy%tgs] - bmi_status = BMI_SUCCESS - case("ACSNOM") - dest = [water%ACSNOM] - bmi_status = BMI_SUCCESS - case("SNOWT_AVG") - dest = [energy%SNOWT_AVG] - bmi_status = BMI_SUCCESS - case("QRAIN") - dest = [water%QRAIN] - bmi_status = BMI_SUCCESS + dest = [water%evapotrans*domain%DT*mm2m] + bmi_status = BMI_SUCCESS + case("FIRA") + dest = [energy%FIRA] + bmi_status = BMI_SUCCESS + case("FRZX") + dest = [parameters%frzx] + bmi_status = BMI_SUCCESS + case("FSA") + dest = [energy%FSA] + bmi_status = BMI_SUCCESS + case("FSH") + dest = [energy%FSH] + bmi_status = BMI_SUCCESS case("FSNO") - dest = [water%FSNO] - bmi_status = BMI_SUCCESS - case("SNOWH") - dest = [water%SNOWH] - bmi_status = BMI_SUCCESS - case("SNLIQ") - dest = water%SNLIQ - bmi_status = BMI_SUCCESS - case("QSNOW") - dest = [water%QSNOW] - bmi_status = BMI_SUCCESS - case("ECAN") - dest = [water%ECAN*domain%DT] - bmi_status = BMI_SUCCESS + dest = [water%FSNO] + bmi_status = BMI_SUCCESS case("GH") - dest = [energy%GH] - bmi_status = BMI_SUCCESS - case("TRAD") - dest = [energy%TRAD] - bmi_status = BMI_SUCCESS - case("FSA") - dest = [energy%FSA] - bmi_status = BMI_SUCCESS - case("CMC") - dest = [water%CMC] - bmi_status = BMI_SUCCESS + dest = [energy%GH] + bmi_status = BMI_SUCCESS + case("HVT") + dest = [parameters%HVT] + bmi_status = BMI_SUCCESS + case("KDT") + dest = [parameters%kdt] + bmi_status = BMI_SUCCESS case("LH") - dest = [energy%LH] - bmi_status = BMI_SUCCESS - case("FIRA") - dest = [energy%FIRA] - bmi_status = BMI_SUCCESS - case("FSH") - dest = [energy%FSH] - bmi_status = BMI_SUCCESS - case("CWP") - dest = [parameters%CWP] - bmi_status = BMI_SUCCESS - case("VCMX25") - dest = [parameters%VCMX25] - bmi_status = BMI_SUCCESS - case("MP") - dest = [parameters%MP] - bmi_status = BMI_SUCCESS + dest = [energy%LH] + bmi_status = BMI_SUCCESS + case("LWDN") + dest = [forcing%lwdn] + bmi_status = BMI_SUCCESS case("MFSNO") - dest = [parameters%MFSNO] - bmi_status = BMI_SUCCESS + dest = [parameters%MFSNO] + bmi_status = BMI_SUCCESS + case("MP") + dest = [parameters%MP] + bmi_status = BMI_SUCCESS + case("PRCPNONC") + dest = [forcing%prcpnonc] + bmi_status = BMI_SUCCESS + case("Q2") + dest = [forcing%q2] + bmi_status = BMI_SUCCESS + case("QINSUR") + dest = [water%qinsur] + bmi_status = BMI_SUCCESS + case("QRAIN") + dest = [water%QRAIN] + bmi_status = BMI_SUCCESS + case("QSEVA") + dest = [water%qseva*m2mm] + bmi_status = BMI_SUCCESS + case("QSNOW") + dest = [water%QSNOW] + bmi_status = BMI_SUCCESS + case("REFKDT") + dest = [parameters%refkdt] + bmi_status = BMI_SUCCESS + case("RSURF_EXP") + dest = [parameters%RSURF_EXP] + bmi_status = BMI_SUCCESS case("RSURF_SNOW") - dest = [parameters%RSURF_SNOW] - bmi_status = BMI_SUCCESS - case("HVT") - dest = [parameters%HVT] - bmi_status = BMI_SUCCESS - case("BEXP") - dest = [parameters%bexp] - bmi_status = BMI_SUCCESS + dest = [parameters%RSURF_SNOW] + bmi_status = BMI_SUCCESS + case("SCAMAX") + dest = [parameters%SCAMAX] + bmi_status = BMI_SUCCESS + case("SFCPRS") + dest = [forcing%sfcprs] + bmi_status = BMI_SUCCESS + case("SFCTMP") + dest = [forcing%sfctmp] + bmi_status = BMI_SUCCESS + case("SLOPE") + dest = [parameters%slope] + bmi_status = BMI_SUCCESS case("SMCMAX") - dest = [parameters%smcmax] - bmi_status = BMI_SUCCESS - case("FRZX") - dest = [parameters%frzx] - bmi_status = BMI_SUCCESS - case("DKSAT") - dest = [parameters%dksat] - bmi_status = BMI_SUCCESS - case("KDT") - dest = [parameters%kdt] - bmi_status = BMI_SUCCESS - case("RSURF_EXP") - dest = [parameters%RSURF_EXP] - bmi_status = BMI_SUCCESS - case("REFKDT") - dest = [parameters%refkdt] - bmi_status = BMI_SUCCESS - case("AXAJ") - dest = [parameters%AXAJ] - bmi_status = BMI_SUCCESS - case("BXAJ") - dest = [parameters%BXAJ] - bmi_status = BMI_SUCCESS + dest = [parameters%smcmax] + bmi_status = BMI_SUCCESS + case("SNEQV") + dest = [water%sneqv] + bmi_status = BMI_SUCCESS + case("SNLIQ") + dest = [water%SNLIQ] + bmi_status = BMI_SUCCESS + case("SNOWH") + dest = [water%SNOWH] + bmi_status = BMI_SUCCESS + case("SNOWT_AVG") + dest = [energy%SNOWT_AVG] + bmi_status = BMI_SUCCESS + case("SOLDN") + dest = [forcing%soldn] + bmi_status = BMI_SUCCESS + case("TG") + dest = [energy%tg] + bmi_status = BMI_SUCCESS + case("TGS") + dest = [energy%tgs] + bmi_status = BMI_SUCCESS + case("TRAD") + dest = [energy%TRAD] + bmi_status = BMI_SUCCESS + case("UU") + dest = [forcing%uu] + bmi_status = BMI_SUCCESS + case("VCMX25") + dest = [parameters%VCMX25] + bmi_status = BMI_SUCCESS + case("VV") + dest = [forcing%vv] + bmi_status = BMI_SUCCESS case("XXAJ") - dest = [parameters%XXAJ] - bmi_status = BMI_SUCCESS - case("SLOPE") - dest = [parameters%slope] - bmi_status = BMI_SUCCESS - case("SCAMAX") - dest = [parameters%SCAMAX] - bmi_status = BMI_SUCCESS + dest = [parameters%XXAJ] + bmi_status = BMI_SUCCESS case default dest(:) = -1.0 bmi_status = BMI_FAILURE @@ -1231,108 +1231,108 @@ function noahowp_set_float(this, name, src) result (bmi_status) parameters => this%model%parameters) select case(name) - case("SFCPRS") - forcing%sfcprs = src(1) - bmi_status = BMI_SUCCESS - case("SFCTMP") - forcing%sfctmp = src(1) - bmi_status = BMI_SUCCESS - case("SOLDN") - forcing%soldn = src(1) - bmi_status = BMI_SUCCESS + case("AXAJ") + parameters%AXAJ = src(1) + bmi_status = BMI_SUCCESS + case("BEXP") + parameters%bexp(:) = src(:) + bmi_status = BMI_SUCCESS + case("BXAJ") + parameters%BXAJ = src(1) + bmi_status = BMI_SUCCESS + case("CWP") + parameters%CWP = src(1) + bmi_status = BMI_SUCCESS + case("DKSAT") + parameters%dksat(:) = src(:) + parameters%kdt = parameters%refkdt * parameters%dksat(1) / parameters%refdk + bmi_status = BMI_SUCCESS + case("ETRAN") + water%etran = src(1) / domain%DT + bmi_status = BMI_SUCCESS + case("EVAPOTRANS") + water%evapotrans = src(1) * m2mm / domain%DT + bmi_status = BMI_SUCCESS + case("FRZX") + parameters%FRZX = src(1) + bmi_status = BMI_SUCCESS + case("HVT") + parameters%HVT = src(1) + bmi_status = BMI_SUCCESS + case("KDT") + parameters%KDT = src(1) + bmi_status = BMI_SUCCESS case("LWDN") - forcing%lwdn = src(1) - bmi_status = BMI_SUCCESS - case("UU") - forcing%uu = src(1) - bmi_status = BMI_SUCCESS - case("VV") - forcing%vv = src(1) - bmi_status = BMI_SUCCESS - case("Q2") - forcing%q2 = src(1) - bmi_status = BMI_SUCCESS + forcing%lwdn = src(1) + bmi_status = BMI_SUCCESS + case("MFSNO") + parameters%MFSNO = src(1) + bmi_status = BMI_SUCCESS + case("MP") + parameters%MP = src(1) + bmi_status = BMI_SUCCESS case("PRCPNONC") - forcing%prcpnonc = src(1) - bmi_status = BMI_SUCCESS + forcing%prcpnonc = src(1) + bmi_status = BMI_SUCCESS + case("Q2") + forcing%q2 = src(1) + bmi_status = BMI_SUCCESS case("QINSUR") - water%qinsur = src(1) - bmi_status = BMI_SUCCESS - case("ETRAN") - water%etran = src(1) / domain%DT - bmi_status = BMI_SUCCESS + water%qinsur = src(1) + bmi_status = BMI_SUCCESS case("QSEVA") - water%qseva = src(1) * mm2m - bmi_status = BMI_SUCCESS - case("EVAPOTRANS") - water%evapotrans = src(1) * m2mm / domain%DT - bmi_status = BMI_SUCCESS - case("TG") - energy%tg = src(1) - bmi_status = BMI_SUCCESS + water%qseva = src(1) * mm2m + bmi_status = BMI_SUCCESS + case("REFKDT") + parameters%refkdt = src(1) + parameters%kdt = parameters%refkdt * parameters%dksat(1) / parameters%refdk + bmi_status = BMI_SUCCESS + case("RSURF_EXP") + parameters%RSURF_EXP = src(1) + bmi_status = BMI_SUCCESS + case("RSURF_SNOW") + parameters%RSURF_SNOW = src(1) + bmi_status = BMI_SUCCESS + case("SCAMAX") + parameters%SCAMAX = src(1) + bmi_status = BMI_SUCCESS + case("SFCPRS") + forcing%sfcprs = src(1) + bmi_status = BMI_SUCCESS + case("SFCTMP") + forcing%sfctmp = src(1) + bmi_status = BMI_SUCCESS + case("SLOPE") + parameters%slope = src(1) + bmi_status = BMI_SUCCESS + case("SMCMAX") + parameters%smcmax(:) = src(:) + parameters%frzx = 0.15 * (parameters%smcmax(1) / parameters%smcref(1)) * (0.412 / 0.468) + bmi_status = BMI_SUCCESS case("SNEQV") - water%sneqv = src(1) - bmi_status = BMI_SUCCESS + water%sneqv = src(1) + bmi_status = BMI_SUCCESS + case("SOLDN") + forcing%soldn = src(1) + bmi_status = BMI_SUCCESS + case("TG") + energy%tg = src(1) + bmi_status = BMI_SUCCESS case("TGS") - energy%tgs = src(1) - bmi_status = BMI_SUCCESS - case("CWP") - parameters%CWP = src(1) - bmi_status = BMI_SUCCESS + energy%tgs = src(1) + bmi_status = BMI_SUCCESS + case("UU") + forcing%uu = src(1) + bmi_status = BMI_SUCCESS case("VCMX25") - parameters%VCMX25 = src(1) - bmi_status = BMI_SUCCESS - case("MP") - parameters%MP = src(1) - bmi_status = BMI_SUCCESS - case("MFSNO") - parameters%MFSNO = src(1) - bmi_status = BMI_SUCCESS - case("RSURF_SNOW") - parameters%RSURF_SNOW = src(1) - bmi_status = BMI_SUCCESS - case("HVT") - parameters%HVT = src(1) - bmi_status = BMI_SUCCESS - case("BEXP") - parameters%bexp(:) = src(:) - bmi_status = BMI_SUCCESS - case("SMCMAX") - parameters%smcmax(:) = src(:) - parameters%frzx = 0.15 * (parameters%smcmax(1) / parameters%smcref(1)) * (0.412 / 0.468) - bmi_status = BMI_SUCCESS - case("DKSAT") - parameters%dksat(:) = src(:) - parameters%kdt = parameters%refkdt * parameters%dksat(1) / parameters%refdk - bmi_status = BMI_SUCCESS - case("KDT") - parameters%KDT = src(1) - bmi_status = BMI_SUCCESS - case("RSURF_EXP") - parameters%RSURF_EXP = src(1) - bmi_status = BMI_SUCCESS - case("REFKDT") - parameters%refkdt = src(1) - parameters%kdt = parameters%refkdt * parameters%dksat(1) / parameters%refdk - bmi_status = BMI_SUCCESS - case("AXAJ") - parameters%AXAJ = src(1) - bmi_status = BMI_SUCCESS - case("BXAJ") - parameters%BXAJ = src(1) - bmi_status = BMI_SUCCESS + parameters%VCMX25 = src(1) + bmi_status = BMI_SUCCESS + case("VV") + forcing%vv = src(1) + bmi_status = BMI_SUCCESS case("XXAJ") - parameters%XXAJ = src(1) - bmi_status = BMI_SUCCESS - case("SLOPE") - parameters%slope = src(1) - bmi_status = BMI_SUCCESS - case("SCAMAX") - parameters%SCAMAX = src(1) - bmi_status = BMI_SUCCESS - case("FRZX") - parameters%FRZX = src(1) - bmi_status = BMI_SUCCESS + parameters%XXAJ = src(1) + bmi_status = BMI_SUCCESS case default bmi_status = BMI_FAILURE end select