Skip to content
Open
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
16 changes: 11 additions & 5 deletions CCPP/module_sf_mynnsfc_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,26 @@ MODULE module_sf_mynnsfc_driver
!! \htmlinclude module_sf_mynnsfc_driver_init.html
!!
subroutine module_sf_mynnsfc_driver_init(do_mynnsfclay, &
& errmsg, errflg)
con_cp, con_g, con_rd, con_rv, &
con_rocp, con_hvap, con_hfus, con_fvirt, &
con_eps, errmsg, errflg)

logical, intent(in) :: do_mynnsfclay
real(kind_phys), intent(in) :: con_cp, con_g, con_rd, con_rv
real(kind_phys), intent(in) :: con_rocp, con_hvap, con_hfus, con_fvirt
real(kind_phys), intent(in) :: con_eps
character(len=*), intent(out) :: errmsg
integer, intent(out) :: errflg

! Initialize CCPP error handling variables
errmsg = ''
errflg = 0

! Initialize sf_mynn
call sf_mynn_init(con_cp, con_g, con_rd, con_rv, &
con_rocp, con_hvap, con_hfus, con_fvirt, &
con_eps)

! Consistency checks
if (.not. do_mynnsfclay) then
write(errmsg,fmt='(*(a))') 'Logic error: do_mynnsfclay = .false.'
Expand Down Expand Up @@ -94,8 +104,6 @@ SUBROUTINE module_sf_mynnsfc_driver_run( &

! should be moved to inside the mynn:
use machine , only : kind_phys
use physcons, only : cp => con_cp, &
& grav => con_g

! USE module_sf_mynnsfc, only : SFCLAY_mynn
!tgs - info on iterations:
Expand All @@ -111,8 +119,6 @@ SUBROUTINE module_sf_mynnsfc_driver_run( &
!-------------------------------------------------------------------
implicit none
!-------------------------------------------------------------------
! --- derive more constant parameters:
real(kind_phys), parameter :: g_inv=1./grav

character(len=*), intent(out) :: errmsg
integer, intent(out) :: errflg
Expand Down
74 changes: 73 additions & 1 deletion CCPP/module_sf_mynnsfc_driver.meta
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[ccpp-table-properties]
name = module_sf_mynnsfc_driver
type = scheme
dependencies = ../../../../hooks/machine.F,../../../../hooks/physcons.F90,../module_sf_mynnsfc.F90
dependencies = ../../../../hooks/machine.F,../module_sf_mynnsfc.F90

########################################################################
[ccpp-arg-table]
Expand All @@ -14,6 +14,78 @@
dimensions = ()
type = logical
intent = in
[con_cp]
standard_name = specific_heat_of_dry_air_at_constant_pressure
long_name = specific heat of dry air at constant pressure
units = J kg-1 K-1
dimensions = ()
type = real
kind = kind_phys
intent = in
[con_g]
standard_name = gravitational_acceleration
long_name = gravitational acceleration
units = m s-2
dimensions = ()
type = real
kind = kind_phys
intent = in
[con_rd]
standard_name = gas_constant_of_dry_air
long_name = ideal gas constant for dry air
units = J kg-1 K-1
dimensions = ()
type = real
kind = kind_phys
intent = in
[con_rv]
standard_name = gas_constant_water_vapor
long_name = ideal gas constant for water vapor
units = J kg-1 K-1
dimensions = ()
type = real
kind = kind_phys
intent = in
[con_rocp]
standard_name = ratio_of_gas_constant_dry_air_to_specific_heat_of_dry_air_at_constant_pressure
long_name = (rd/cp)
units = none
dimensions = ()
type = real
kind = kind_phys
intent = in
[con_hvap]
standard_name = latent_heat_of_vaporization_of_water_at_0C
long_name = latent heat of evaporation/sublimation
units = J kg-1
dimensions = ()
type = real
kind = kind_phys
intent = in
[con_hfus]
standard_name = latent_heat_of_fusion_of_water_at_0C
long_name = latent heat of fusion
units = J kg-1
dimensions = ()
type = real
kind = kind_phys
intent = in
[con_fvirt]
standard_name = ratio_of_vapor_to_dry_air_gas_constants_minus_one
long_name = (rv/rd) - 1 (rv = ideal gas constant for water vapor)
units = none
dimensions = ()
type = real
kind = kind_phys
intent = in
[con_eps]
standard_name = ratio_of_dry_air_to_water_vapor_gas_constants
long_name = rd/rv
units = none
dimensions = ()
type = real
kind = kind_phys
intent = in
[errmsg]
standard_name = ccpp_error_message
long_name = error message for error handling in CCPP
Expand Down
60 changes: 43 additions & 17 deletions module_sf_mynnsfc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -63,28 +63,28 @@ MODULE module_sf_mynnsfc
!NOTE: This code was primarily tested in combination with the RUC LSM.
! Performance with the Noah (or other) LSM is relatively unknown.
!-------------------------------------------------------------------
!Include host model constants
use physcons, only : cp => con_cp, & !=7*Rd/2
& grav => con_g, & !=9.81
& Rd => con_rd, & !=287.
& Rv => con_rv, & !=461.6
! & cpv => con_cvap, & !=4*Rv
& rovcp => con_rocp, & !=Rd/cp
& xlv => con_hvap, & !2.5e6
& xlf => con_hfus, & !3.5e5
& ep1 => con_fvirt, & !Rv/Rd - 1
& ep2 => con_eps !Rd/Rv

!use kind_phys for real-types
use machine , only : kind_phys

!-------------------------------------------------------------------
IMPLICIT NONE
!-------------------------------------------------------------------
!Drive and/or define more constant:
real(kind_phys), parameter :: ep3 = 1.-ep2
real(kind_phys), parameter :: g_inv = 1.0/grav
real(kind_phys), parameter :: rvovrd = Rv/Rd
real(kind_phys) :: cp = 1.0E30_kind_phys

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question RE: initializing to 1000.0 as in the physics PR

real(kind_phys) :: grav = 1.0E30_kind_phys
real(kind_phys) :: Rd = 1.0E30_kind_phys
real(kind_phys) :: Rv = 1.0E30_kind_phys
real(kind_phys) :: rovcp = 1.0E30_kind_phys
real(kind_phys) :: xlv = 1.0E30_kind_phys
real(kind_phys) :: xlf = 1.0E30_kind_phys
real(kind_phys) :: ep1 = 1.0E30_kind_phys
real(kind_phys) :: ep2 = 1.0E30_kind_phys
real(kind_phys) :: ep3 = 1.0E30_kind_phys
real(kind_phys) :: g_inv = 1.0E30_kind_phys
real(kind_phys) :: rvovrd = 1.0E30_kind_phys
!$acc declare create(cp, grav, Rd, Rv, rovcp, xlv, xlf, &
!$acc ep1, ep2, ep3, g_inv, rvovrd)

real(kind_phys), parameter :: wmin = 0.1 ! Minimum wind speed
real(kind_phys), parameter :: karman = 0.4
real(kind_phys), parameter :: SVP1 = 0.6112
Expand Down Expand Up @@ -112,6 +112,32 @@ MODULE module_sf_mynnsfc

CONTAINS

subroutine sf_mynn_init(con_cp, con_g, con_rd, con_rv, &
con_rocp, con_hvap, con_hfus, con_fvirt, &
con_eps)
real(kind_phys), intent(in) :: con_cp, con_g, con_rd, con_rv
real(kind_phys), intent(in) :: con_rocp, con_hvap, con_hfus, con_fvirt
real(kind_phys), intent(in) :: con_eps
!Include host model constants
cp = con_cp
grav = con_g
Rd = con_rd
Rv = con_rv
rovcp = con_rocp
xlv = con_hvap
xlf = con_hfus
ep1 = con_fvirt
ep2 = con_eps

ep3 = 1.-ep2
g_inv = 1.0/grav
rvovrd = Rv/Rd

!$acc update device(cp, grav, Rd, Rv, rovcp, xlv, xlf, &
!$acc ep1, ep2, ep3, g_inv, rvovrd)
end subroutine sf_mynn_init


!-------------------------------------------------------------------
!-------------------------------------------------------------------
!>\ingroup mynn_sfc
Expand Down Expand Up @@ -2270,7 +2296,7 @@ SUBROUTINE SFCLAY1D_mynn(flag_iter, &
!$acc THSK_lnd, THSK_wat, THSK_ice, &
!$acc QSFC_lnd, QSFC_wat, QSFC_ice, &
!$acc U10, V10, U1D, V1D, U1D2, V1D2, &
!$acc ZNTstoch_lnd, ZNTstoch_lnd, ZNTstoch_ice, &
!$acc ZNTstoch_lnd, ZNTstoch_wat, ZNTstoch_ice, &

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha. Nice catches. Were these caught with an AI tool or something?

!$acc PSIX_lnd, PSIX_wat, PSIX_ice, &
!$acc PSIX10_lnd, PSIX10_wat, PSIX10_ice, &
!$acc PSIT2_lnd, PSIT2_wat, PSIT2_ice, &
Expand Down Expand Up @@ -2392,7 +2418,7 @@ SUBROUTINE SFCLAY1D_mynn(flag_iter, &
!-----------------------------------------------------
!$acc serial present(dry, wet, icy, CPM, MAVAIL, &
!$acc HFX, LH, wstar, RHO1D, PBLH, ZOL, ZA, MOL, &
!$acc PSIM, PSIH, WSTAR, T1D, TH1D, THV1D, QVSH, &
!$acc PSIM, PSIH, T1D, TH1D, THV1D, QVSH, &
!$acc UST_wat, UST_lnd, UST_ice, &
!$acc THSK_wat, THSK_lnd, THSK_ice, &
!$acc THVSK_wat, THVSK_lnd, THVSK_ice, &
Expand Down