Skip to content

Commit

Permalink
Merge pull request #422 from megandevlan/gustMods
Browse files Browse the repository at this point in the history
Add convective gust contribution to U10
  • Loading branch information
jedwards4b authored Dec 21, 2023
2 parents ad4d7a3 + b908586 commit ce6c935
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 17 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/extbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ jobs:
CPPFLAGS: "-I/usr/include -I/usr/local/include"

# Versions of all dependencies can be updated here
ESMF_VERSION: v8.4.2
ESMF_VERSION: v8.6.0
PNETCDF_VERSION: checkpoint.1.12.3
NETCDF_FORTRAN_VERSION: v4.6.0
PIO_VERSION: pio2_6_0
CDEPS_VERSION: cdeps1.0.15
NETCDF_FORTRAN_VERSION: v4.6.1
PIO_VERSION: pio2_6_2
CDEPS_VERSION: cdeps1.0.26
steps:
- uses: actions/checkout@v3
# Build the ESMF library, if the cache contains a previous build
Expand Down Expand Up @@ -84,7 +84,7 @@ jobs:
ref: ${{ env.CDEPS_VERSION }}
- name: Build CDEPS
if: steps.cache-cdeps.outputs.cache-hit != 'true'
uses: ESCOMP/CDEPS/.github/actions/[email protected].15
uses: ESCOMP/CDEPS/.github/actions/[email protected].26
with:
esmfmkfile: $HOME/ESMF/lib/libg/Linux.gfortran.64.openmpi.default/esmf.mk
pio_path: $HOME/pio
Expand All @@ -102,6 +102,6 @@ jobs:
make VERBOSE=1
popd
- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
# - name: Setup tmate session
# if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3
16 changes: 13 additions & 3 deletions .github/workflows/srt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ jobs:
CPPFLAGS: "-I/usr/include -I/usr/local/include "
LDFLAGS: "-L/usr/lib/x86_64-linux-gnu -lnetcdf -lnetcdff -lpnetcdf"
# Versions of all dependencies can be updated here
ESMF_VERSION: v8.5.0
PARALLELIO_VERSION: pio2_6_0
ESMF_VERSION: v8.6.0
PARALLELIO_VERSION: pio2_6_2
CIME_MODEL: cesm
CIME_DRIVER: nuopc
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -80,7 +80,17 @@ jobs:
run: |
pushd cesm
./manage_externals/checkout_externals ccs_config cdeps cime share mct cpl7 parallelio
cd ccs_config
git checkout main
cd ../cime
git checkout master
if [[ ! -e "${PWD}/.gitmodules.bak" ]]
then
echo "Convering [email protected] to https://github.com urls in ${PWD}/.gitmodules"
sed -i".bak" "s/[email protected]:/https:\/\/github.com\//g" "${PWD}/.gitmodules"
fi
git submodule update --init
- name: Cache ESMF
id: cache-esmf
uses: actions/cache@v3
Expand Down
31 changes: 27 additions & 4 deletions cesm/flux_atmocn/shr_flux_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,18 @@ end subroutine shr_flux_adjust_constants
! Thomas Toniazzo (Bjerknes Centre, Bergen) ”
!===============================================================================
SUBROUTINE flux_atmOcn(logunit, nMax ,zbot ,ubot ,vbot ,thbot , &
& qbot ,s16O ,sHDO ,s18O ,rbot, &
& qbot, rainc ,s16O ,sHDO ,s18O ,rbot, &
& tbot ,us ,vs, pslv, &
& ts ,mask , seq_flux_atmocn_minwind, &
& sen ,lat ,lwup , &
& r16O, rhdo, r18O, &
& evap ,evap_16O, evap_HDO, evap_18O, &
& taux ,tauy ,tref ,qref , &
& ocn_surface_flux_scheme, &
& duu10n, ustar_sv ,re_sv ,ssq_sv, &
& add_gusts, &
& duu10n, &
& ugust_out, &
& ustar_sv ,re_sv ,ssq_sv, &
& missval)

! !USES:
Expand All @@ -156,11 +159,13 @@ SUBROUTINE flux_atmOcn(logunit, nMax ,zbot ,ubot ,vbot ,thbot , &
integer(IN),intent(in) :: nMax ! data vector length
integer(IN),intent(in) :: mask (nMax) ! ocn domain mask 0 <=> out of domain
integer(IN),intent(in) :: ocn_surface_flux_scheme
logical ,intent(in) :: add_gusts
real(R8) ,intent(in) :: zbot (nMax) ! atm level height (m)
real(R8) ,intent(in) :: ubot (nMax) ! atm u wind (m/s)
real(R8) ,intent(in) :: vbot (nMax) ! atm v wind (m/s)
real(R8) ,intent(in) :: thbot(nMax) ! atm potential T (K)
real(R8) ,intent(in) :: qbot (nMax) ! atm specific humidity (kg/kg)
real(R8) ,intent(in) :: rainc(nMax) ! atm precip for convective gustiness (kg/m^3) - RBN 24Nov2008/MDF 31Jan2022
real(R8) ,intent(in) :: s16O (nMax) ! atm H216O tracer conc. (kg/kg)
real(R8) ,intent(in) :: sHDO (nMax) ! atm HDO tracer conc. (kg/kg)
real(R8) ,intent(in) :: s18O (nMax) ! atm H218O tracer conc. (kg/kg)
Expand Down Expand Up @@ -188,6 +193,7 @@ SUBROUTINE flux_atmOcn(logunit, nMax ,zbot ,ubot ,vbot ,thbot , &
real(R8),intent(out) :: tref (nMax) ! diag: 2m ref height T (K)
real(R8),intent(out) :: qref (nMax) ! diag: 2m ref humidity (kg/kg)
real(R8),intent(out) :: duu10n(nMax) ! diag: 10m wind speed squared (m/s)^2
real(R8),intent(out) :: ugust_out(nMax) ! diag: gustiness addition to U10 (m/s)

real(R8),intent(out),optional :: ustar_sv(nMax) ! diag: ustar
real(R8),intent(out),optional :: re_sv (nMax) ! diag: sqrt of exchange coefficient (water)
Expand Down Expand Up @@ -257,14 +263,16 @@ SUBROUTINE flux_atmOcn(logunit, nMax ,zbot ,ubot ,vbot ,thbot , &
real(R8) :: tdiff(nMax) ! tbot - ts
real(R8) :: vscl

real(R8) :: ugust ! function: gustiness as a function of convective rainfall.
real(R8) :: gprec ! convective rainfall argument for ugust

qsat(Tk) = 640380.0_R8 / exp(5107.4_R8/Tk)

! Large and Yeager 2009
cdn(Umps) = 0.0027_R8 / min(33.0000_R8,Umps) + 0.000142_R8 + &
0.0000764_R8 * min(33.0000_R8,Umps) - 3.14807e-13_r8 * min(33.0000_R8,Umps)**6
! Capped Large and Pond by wind
! cdn(Umps) = 0.0027_R8 / min(30.0_R8,Umps) + 0.000142_R8 + 0.0000764_R8 * min(30.0_R8,Umps)
! cdn(Umps) = 0.0027_R8 / min(30.0_R8,Umps) + 0.000142_R8 + 0.0000764_R8 * min(30.0_R8,Umps)
! Capped Large and Pond by Cd
! cdn(Umps) = min(0.0025_R8, (0.0027_R8 / Umps + 0.000142_R8 + 0.0000764_R8 * Umps ))
! Large and Pond
Expand All @@ -273,6 +281,13 @@ SUBROUTINE flux_atmOcn(logunit, nMax ,zbot ,ubot ,vbot ,thbot , &
psimhu(xd) = log((1.0_R8+xd*(2.0_R8+xd))*(1.0_R8+xd*xd)/8.0_R8) - 2.0_R8*atan(xd) + 1.571_R8
psixhu(xd) = 2.0_R8 * log((1.0_R8 + xd*xd)/2.0_R8)

! Convective gustiness appropriate for input precipitation.
! Following Regelsperger et al. (2000, J. Clim)
! Ug = log(1.0+6.69R-0.476R^2)
! Coefficients X by 8640 for mm/s (from cam) -> cm/day (for above forumla)
ugust(gprec) = log(1._R8+57801.6_r8*gprec-3.55332096e7_r8*(gprec**2))


!--- formats ----------------------------------------
character(*),parameter :: subName = '(flux_atmOcn) '
character(*),parameter :: F00 = "('(flux_atmOcn) ',4a)"
Expand Down Expand Up @@ -327,7 +342,14 @@ SUBROUTINE flux_atmOcn(logunit, nMax ,zbot ,ubot ,vbot ,thbot , &
if (mask(n) /= 0) then

!--- compute some needed quantities ---
vmag = max(seq_flux_atmocn_minwind, sqrt( (ubot(n)-us(n))**2 + (vbot(n)-vs(n))**2) )
if (add_gusts) then
vmag = max(seq_flux_atmocn_minwind, sqrt( (ubot(n)-us(n))**2 + (vbot(n)-vs(n))**2) + ugust(min(rainc(n),6.94444e-4_r8)) )
ugust_out(n) = ugust(min(rainc(n),6.94444e-4_r8))
else
vmag = max(seq_flux_atmocn_minwind, sqrt( (ubot(n)-us(n))**2 + (vbot(n)-vs(n))**2) )
ugust_out(n) = 0.0_r8
end if

if (use_coldair_outbreak_mod) then
! Cold Air Outbreak Modification:
! Increase windspeed for negative tbot-ts
Expand Down Expand Up @@ -462,6 +484,7 @@ SUBROUTINE flux_atmOcn(logunit, nMax ,zbot ,ubot ,vbot ,thbot , &
tref (n) = spval ! 2m reference height temperature (K)
qref (n) = spval ! 2m reference height humidity (kg/kg)
duu10n(n) = spval ! 10m wind speed squared (m/s)^2
ugust_out(n) = spval ! gustiness addition (m/s)

if (present(ustar_sv)) ustar_sv(n) = spval
if (present(re_sv )) re_sv (n) = spval
Expand Down
7 changes: 7 additions & 0 deletions cime_config/buildnml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ from CIME.case import Case
from CIME.nmlgen import NamelistGenerator
from CIME.utils import expect
from CIME.utils import get_model, get_time_in_seconds, get_timestamp
from CIME.namelist import literal_to_python_value
from CIME.buildnml import create_namelist_infile, parse_input
from CIME.XML.files import Files

Expand Down Expand Up @@ -144,6 +145,11 @@ def _create_drv_namelists(case, infile, confdir, nmlgen, files):
if config["COMP_OCN"] == "docn" and "aqua" in case.get_value("DOCN_MODE"):
nmlgen.set_value("aqua_planet", value=".true.")

# make sure that variable add_gusts is only set to true if compset includes cam_dev
add_gusts = literal_to_python_value(nmlgen.get_value("add_gusts"), type_="logical")
if add_gusts:
expect("CAM%DEV" in case.get_value("COMPSET"),"ERROR: add_gusts can only be set if CAM%DEV in compset {}".format(case.get_value("COMPSET")))

# --------------------------------
# Overwrite: set component coupling frequencies
# --------------------------------
Expand Down Expand Up @@ -658,6 +664,7 @@ def buildnml(case, caseroot, component):
create_namelist_infile(case, user_nl_file, namelist_infile, infile_text)
infile = [namelist_infile]


# create the files nuopc.runconfig, nuopc.runseq, drv_in and drv_flds_in
_create_drv_namelists(case, infile, confdir, nmlgen, files)

Expand Down
12 changes: 12 additions & 0 deletions cime_config/namelist_definition_drv.xml
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,18 @@
</values>
</entry>

<entry id="add_gusts">
<type>logical</type>
<category>control</category>
<group>MED_attributes</group>
<desc>
add a wind gustiness factor
</desc>
<values>
<value>.false.</value>
</values>
</entry>

<entry id="do_budgets" modify_via_xml="BUDGETS">
<type>logical</type>
<category>budget</category>
Expand Down
20 changes: 20 additions & 0 deletions mediator/esmFldsExchange_cesm_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc)
call addfld_from(compatm, 'Sa_shum')
call addfld_from(compatm, 'Sa_ptem')
call addfld_from(compatm, 'Sa_dens')
call addfld_from(compatm, 'Faxa_rainc')
if (flds_wiso) then
call addfld_from(compatm, 'Sa_shum_wiso')
end if
Expand All @@ -288,6 +289,7 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc)
call addmap_from(compatm, 'Sa_u' , compocn, mappatch, 'one', atm2ocn_map)
call addmap_from(compatm, 'Sa_v' , compocn, mappatch, 'one', atm2ocn_map)
end if
call addmap_from(compatm, 'Faxa_rainc', compocn, mapconsf, 'one', atm2ocn_map)
call addmap_from(compatm, 'Sa_z' , compocn, mapbilnr, 'one', atm2ocn_map)
call addmap_from(compatm, 'Sa_tbot', compocn, mapbilnr, 'one', atm2ocn_map)
call addmap_from(compatm, 'Sa_pbot', compocn, mapbilnr, 'one', atm2ocn_map)
Expand Down Expand Up @@ -1365,6 +1367,24 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc)
end if
end if

! ---------------------------------------------------------------------
! to atm: unmerged ugust_out from ocn
! ---------------------------------------------------------------------
if (phase == 'advertise') then
call addfld_aoflux('So_ugustOut')
call addfld_to(compatm, 'So_ugustOut')
else
if ( fldchk(is_local%wrap%FBexp(compatm), 'So_ugustOut', rc=rc)) then
if (fldchk(is_local%wrap%FBMed_aoflux_o, 'So_ugustOut', rc=rc)) then
if (trim(is_local%wrap%aoflux_grid) == 'ogrid') then
call addmap_aoflux('So_ugustOut', compatm, mapconsf, 'ofrac', ocn2atm_map)
end if
call addmrg_to(compatm , 'So_ugustOut', &
mrg_from=compmed, mrg_fld='So_ugustOut', mrg_type='merge', mrg_fracname='ofrac')
end if
end if
end if

! ---------------------------------------------------------------------
! to atm: surface snow depth from ice (needed for cam)
! to atm: mean ice volume per unit area from ice
Expand Down
4 changes: 4 additions & 0 deletions mediator/fd_cesm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,10 @@
canonical_units: m
description: atmosphere import
#
- standard_name: So_ugustOut
canonical_units: m/s
description: atmosphere import
#
#-----------------------------------
# section: land-ice export
# Note that the fields sent from glc->med do NOT have elevation classes,
Expand Down
24 changes: 22 additions & 2 deletions mediator/med_phases_aofluxes_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ module med_phases_aofluxes_mod
logical :: compute_atm_dens
logical :: compute_atm_thbot
integer :: ocn_surface_flux_scheme ! use case
logical :: add_gusts

character(len=CS), pointer :: fldnames_ocn_in(:)
character(len=CS), pointer :: fldnames_atm_in(:)
Expand Down Expand Up @@ -125,6 +126,7 @@ module med_phases_aofluxes_mod
real(R8) , pointer :: shum_HDO (:) => null() ! atm HDO tracer
real(R8) , pointer :: shum_18O (:) => null() ! atm H218O tracer
real(R8) , pointer :: lwdn (:) => null() ! atm downward longwave heat flux
real(R8) , pointer :: rainc (:) => null() ! convective rain flux
! local size and computational mask and area: on aoflux grid
integer :: lsize ! local size
integer , pointer :: mask (:) => null() ! integer ocn domain mask: 0 <=> inactive cell
Expand All @@ -146,6 +148,7 @@ module med_phases_aofluxes_mod
real(R8) , pointer :: qref (:) => null() ! diagnostic: 2m ref Q
real(R8) , pointer :: u10 (:) => null() ! diagnostic: 10m wind speed
real(R8) , pointer :: duu10n (:) => null() ! diagnostic: 10m wind speed squared
real(R8) , pointer :: ugust_out (:) => null() ! diagnostic: gust wind added
real(R8) , pointer :: ustar (:) => null() ! saved ustar
real(R8) , pointer :: re (:) => null() ! saved re
real(R8) , pointer :: ssq (:) => null() ! saved sq
Expand Down Expand Up @@ -402,6 +405,14 @@ subroutine med_aofluxes_init(gcomp, aoflux_in, aoflux_out, rc)
end if
#endif

call NUOPC_CompAttributeGet(gcomp, name='add_gusts', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
if (isPresent .and. isSet) then
read(cvalue,*) add_gusts
else
add_gusts = .false.
end if

! bottom level potential temperature and/or botom level density
! will need to be computed if not received from the atm
if (FB_fldchk(is_local%Wrap%FBImp(Compatm,Compatm), 'Sa_ptem', rc=rc)) then
Expand Down Expand Up @@ -1052,6 +1063,7 @@ subroutine med_aofluxes_update(gcomp, aoflux_in, aoflux_out, rc)
call flux_atmocn (logunit=logunit, &
nMax=aoflux_in%lsize, &
zbot=aoflux_in%zbot, ubot=aoflux_in%ubot, vbot=aoflux_in%vbot, thbot=aoflux_in%thbot, qbot=aoflux_in%shum, &
rainc=aoflux_in%rainc, &
s16O=aoflux_in%shum_16O, sHDO=aoflux_in%shum_HDO, s18O=aoflux_in%shum_18O, rbot=aoflux_in%dens, &
tbot=aoflux_in%tbot, us=aoflux_in%uocn, vs=aoflux_in%vocn, pslv=aoflux_in%psfc, ts=aoflux_in%tocn, &
mask=aoflux_in%mask, seq_flux_atmocn_minwind=0.5_r8, &
Expand All @@ -1060,7 +1072,10 @@ subroutine med_aofluxes_update(gcomp, aoflux_in, aoflux_out, rc)
evap=aoflux_out%evap, evap_16O=aoflux_out%evap_16O, evap_HDO=aoflux_out%evap_HDO, evap_18O=aoflux_out%evap_18O, &
taux=aoflux_out%taux, tauy=aoflux_out%tauy, tref=aoflux_out%tref, qref=aoflux_out%qref, &
ocn_surface_flux_scheme=ocn_surface_flux_scheme, &
duu10n=aoflux_out%duu10n, ustar_sv=aoflux_out%ustar, re_sv=aoflux_out%re, ssq_sv=aoflux_out%ssq, &
add_gusts=add_gusts, &
duu10n=aoflux_out%duu10n, &
ugust_out = aoflux_out%ugust_out, &
ustar_sv=aoflux_out%ustar, re_sv=aoflux_out%re, ssq_sv=aoflux_out%ssq, &
missval=0.0_r8)

#else
Expand All @@ -1084,7 +1099,8 @@ subroutine med_aofluxes_update(gcomp, aoflux_in, aoflux_out, rc)
ocn_surface_flux_scheme=ocn_surface_flux_scheme, &
sen=aoflux_out%sen, lat=aoflux_out%lat, lwup=aoflux_out%lwup, evap=aoflux_out%evap, &
taux=aoflux_out%taux, tauy=aoflux_out%tauy, tref=aoflux_out%tref, qref=aoflux_out%qref, &
duu10n=aoflux_out%duu10n, missval=0.0_r8)
duu10n=aoflux_out%duu10n, &
missval=0.0_r8)
#ifdef UFS_AOFLUX
end if
#endif
Expand Down Expand Up @@ -1581,6 +1597,8 @@ subroutine set_aoflux_in_pointers(fldbun_a, fldbun_o, aoflux_in, lsize, xgrid, r
if (chkerr(rc,__LINE__,u_FILE_u)) return
call fldbun_getfldptr(fldbun_a, 'Sa_shum', aoflux_in%shum, xgrid=xgrid, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call fldbun_getfldptr(fldbun_a, 'Faxa_rainc', aoflux_in%rainc, xgrid=xgrid, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
end if

! extra fields for ufs.frac.aoflux
Expand Down Expand Up @@ -1692,6 +1710,8 @@ subroutine set_aoflux_out_pointers(fldbun, lsize, aoflux_out, xgrid, rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call fldbun_getfldptr(fldbun, 'So_duu10n', aoflux_out%duu10n, xgrid=xgrid, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call fldbun_getfldptr(fldbun, 'So_ugustOut', aoflux_out%ugust_out, xgrid=xgrid, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call fldbun_getfldptr(fldbun, 'Faox_taux', aoflux_out%taux, xgrid=xgrid, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call fldbun_getfldptr(fldbun, 'Faox_tauy', aoflux_out%tauy, xgrid=xgrid, rc=rc)
Expand Down

0 comments on commit ce6c935

Please sign in to comment.