Skip to content

Commit

Permalink
Update CMEPS (#110)
Browse files Browse the repository at this point in the history
Sync w/ ESCOMP, adding CDEPS inline capability to CMEPS
  • Loading branch information
uturuncoglu committed Feb 5, 2024
1 parent 8cd4a32 commit 624920d
Show file tree
Hide file tree
Showing 23 changed files with 1,133 additions and 326 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
20 changes: 17 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 @@ -79,7 +79,21 @@ jobs:
- name: checkout externals
run: |
pushd cesm
./manage_externals/checkout_externals ccs_config cdeps cime share mct cpl7 parallelio
./manage_externals/checkout_externals ccs_config cdeps share mct cpl7 parallelio
cd ccs_config
git checkout main
cd ../
git clone https://github.com/ESMCI/cime
cd cime
if [[ ! -e "${PWD}/.gitmodules.bak" ]]
then
echo "Converting [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
cd ../components/cdeps
git checkout main
- name: Cache ESMF
id: cache-esmf
Expand Down
2 changes: 1 addition & 1 deletion cesm/driver/esmApp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ program esmApp
! Call Run for the ensemble driver
!-----------------------------------------------------------------------------
call ESMF_GridCompRun(ensemble_driver_comp, userRc=urc, rc=rc)
if (ESMF_LogFoundError(rcToCheck=urc, msg=ESMF_LOGERR_PASSTHRU, &
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=__FILE__)) &
call ESMF_Finalize(endflag=ESMF_END_ABORT)
Expand Down
41 changes: 37 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,12 +263,31 @@ 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)
cdn(Umps) = 0.0027_R8 / Umps + 0.000142_R8 + 0.0000764_R8 * Umps

! 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)
! 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
! cdn(Umps) = 0.0027_R8 / Umps + 0.000142_R8 + 0.0000764_R8 * Umps

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 @@ -317,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 @@ -452,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
10 changes: 9 additions & 1 deletion 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 @@ -105,7 +106,8 @@ def _create_drv_namelists(case, infile, confdir, nmlgen, files):
config["COMP_OCN"] = case.get_value("COMP_OCN")
config["COMP_ROF"] = case.get_value("COMP_ROF")
config["COMP_WAV"] = case.get_value("COMP_WAV")

config["CAMDEV"] = "True" if "CAM%DEV" in case.get_value("COMPSET") else "False"

if (
(
case.get_value("COMP_ROF") == "mosart"
Expand Down Expand Up @@ -144,6 +146,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 +665,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
35 changes: 9 additions & 26 deletions cime_config/config_component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,15 @@
<desc>List of job ids for most recent case.submit</desc>
</entry>

<entry id="JOB_PRIORITY">
<type>char</type>
<default_value>regular</default_value>
<valid_values>regular,premium,economy</valid_values>
<group>run_begin_stop_restart</group>
<file>env_run.xml</file>
<desc>job priority for systems supporting this option</desc>
</entry>

<!-- ===================================================================== -->
<!-- definitions archive -->
<!-- ===================================================================== -->
Expand Down Expand Up @@ -812,15 +821,6 @@
different MPI ranks to different GPUs within the same compute node</desc>
</entry>

<entry id="SMP_PRESENT">
<type>logical</type>
<valid_values>TRUE,FALSE</valid_values>
<default_value>FALSE</default_value>
<group>build_def</group>
<file>env_build.xml</file>
<desc>TRUE implies that at least one of the components is built threaded (DO NOT EDIT)</desc>
</entry>

<entry id="ESMF_AWARE_THREADING">
<type>logical</type>
<valid_values>TRUE,FALSE</valid_values>
Expand Down Expand Up @@ -1026,23 +1026,6 @@
this to work.</desc>
</entry>

<entry id="ESMF_LOGFILE_KIND">
<type>char</type>
<valid_values>ESMF_LOGKIND_SINGLE,ESMF_LOGKIND_MULTI,ESMF_LOGKIND_NONE</valid_values>
<default_value>ESMF_LOGKIND_NONE</default_value>
<group>run_flags</group>
<file>env_run.xml</file>
<desc>
Determines what ESMF log files (if any) are generated when
USE_ESMF_LIB is TRUE.
ESMF_LOGKIND_SINGLE: Use a single log file, combining messages from
all of the PETs. Not supported on some platforms.
ESMF_LOGKIND_MULTI: Use multiple log files -- one per PET.
ESMF_LOGKIND_NONE: Do not issue messages to a log file.
By default, no ESMF log files are generated.
</desc>
</entry>

<entry id="ESMF_VERBOSITY_LEVEL">
<type>char</type>
<valid_values>off,low,high,max</valid_values>
Expand Down
31 changes: 13 additions & 18 deletions cime_config/namelist_definition_drv.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,6 @@
</values>
</entry>

<entry id="esmf_logging" modify_via_xml="ESMF_LOGFILE_KIND">
<type>char</type>
<category>cime_pes</category>
<group>PELAYOUT_attributes</group>
<desc>
Determines what ESMF log files (if any) are generated when
USE_ESMF_LIB is TRUE.
ESMF_LOGKIND_SINGLE: Use a single log file, combining messages from
all of the PETs. Not supported on some platforms.
ESMF_LOGKIND_MULTI: Use multiple log files — one per PET.
ESMF_LOGKIND_NONE: Do not issue messages to a log file.
By default, no ESMF log files are generated.
</desc>
<values>
<value>$ESMF_LOGFILE_KIND</value>
</values>
</entry>

<entry id="pio_asyncio_ntasks" modify_via_xml="PIO_ASYNCIO_NTASKS">
<type>integer</type>
<category>pio</category>
Expand Down Expand Up @@ -964,6 +946,19 @@
</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 CAMDEV="True">.true.</value>
<value CAMDEV="False">.false.</value>
</values>
</entry>

<entry id="do_budgets" modify_via_xml="BUDGETS">
<type>logical</type>
<category>budget</category>
Expand Down
2 changes: 1 addition & 1 deletion cime_config/runseq/runseq_TG.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def gen_runseq(case, coupling_times):
runseq.add_action ("MED med_phases_post_lnd" , run_lnd)
runseq.add_action ("MED med_phases_prep_glc" , med_to_glc)
runseq.add_action ("MED -> GLC :remapMethod=redist" , med_to_glc)
runseq.add_action ("GLC" , run_glc)
runseq.add_action ("GLC" , run_glc and med_to_glc)
runseq.add_action ("GLC -> MED :remapMethod=redist" , run_glc)
runseq.add_action ("MED med_phases_history_write" , True)

Expand Down
Loading

0 comments on commit 624920d

Please sign in to comment.