Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into hotfix/cesm_so_t
Browse files Browse the repository at this point in the history
  • Loading branch information
uturuncoglu committed Mar 14, 2024
2 parents 8d85e92 + e6dda63 commit 8a03c6f
Show file tree
Hide file tree
Showing 39 changed files with 1,687 additions and 843 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
4 changes: 1 addition & 3 deletions cesm/driver/ensemble_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ subroutine SetModelServices(ensemble_driver, rc)
integer :: pio_asyncio_stride
integer :: pio_asyncio_rootpe
integer :: Global_Comm
character(len=CL) :: start_type ! Type of startup
character(len=CL) :: start_type ! Type of startup
character(len=7) :: drvrinst
character(len=5) :: inst_suffix
character(len=CX) :: msgstr
Expand Down Expand Up @@ -377,10 +377,8 @@ subroutine SetModelServices(ensemble_driver, rc)
endif
call shr_log_setLogUnit (logunit)
! Create a clock for each driver instance

call esm_time_clockInit(ensemble_driver, driver, logunit, localpet==petList(1), rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

enddo
inst = localPet/(ntasks_per_member+pio_asyncio_ntasks) + 1

Expand Down
50 changes: 36 additions & 14 deletions cesm/driver/esm.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1224,13 +1224,17 @@ subroutine esm_set_single_column_attributes(compname, gcomp, rc)
real (r8), allocatable :: lats(:) ! temporary
real (r8), allocatable :: lons(:) ! temporary
real (r8), allocatable :: pos_lons(:) ! temporary
real (r8), allocatable :: pos_lats(:) ! temporary
real (r8), allocatable :: cols(:) ! temporary
real (r8), allocatable :: glob_grid(:,:) ! temporary
real (r8) :: pos_scol_lon ! temporary
real (r8) :: pos_scol_lat ! temporary
real (r8) :: scol_data(1)
integer :: iscol_data(1)
integer :: petcount
character(len=CL) :: cvalue
character(len=*), parameter :: subname= ' (esm_get_single_column_attributes) '
logical :: unstructured = .false.
!-------------------------------------------------------------------------------

rc = ESMF_SUCCESS
Expand Down Expand Up @@ -1324,7 +1328,15 @@ subroutine esm_set_single_column_attributes(compname, gcomp, rc)
if (status /= nf90_noerr) call shr_sys_abort (subname//' inq_varid frac')

! Read in domain file for single column
allocate(lats(nj))
! Check for unstructured data ni>1 and nj==1
if (ni.gt.1 .and. nj == 1) unstructured=.true.

if (unstructured) then
allocate(lats(ni))
allocate(pos_lats(ni))
else
allocate(lats(nj))
end if
allocate(lons(ni))
allocate(pos_lons(ni))
allocate(glob_grid(ni,nj))
Expand All @@ -1334,28 +1346,37 @@ subroutine esm_set_single_column_attributes(compname, gcomp, rc)
count3=(/ni,nj,1/)
status = nf90_get_var(ncid, varid_xc, glob_grid, start3, count3)
if (status /= nf90_noerr) call shr_sys_abort (subname//' get_var xc')
do i = 1,ni
lons(i) = glob_grid(i,1)
end do
lons(1:ni) = glob_grid(1:ni,1)
status = nf90_get_var(ncid, varid_yc, glob_grid, start3, count3)
if (status /= nf90_noerr) call shr_sys_abort (subname//' get_var yc')
do j = 1,nj
lats(j) = glob_grid(1,j)
end do

if (unstructured) then
lats(1:ni) = glob_grid(1:ni,1)
else
lats(1:nj) = glob_grid(1,1:nj)
end if
! find nearest neighbor indices of scol_lon and scol_lat in single_column_lnd_domain file
! convert lons array and scol_lon to 0,360 and find index of value closest to 0
! and obtain single-column longitude/latitude indices to retrieve
pos_lons(:) = mod(lons(:) + 360._r8, 360._r8)
pos_scol_lon = mod(scol_lon + 360._r8, 360._r8)
start(1) = (MINLOC(abs(pos_lons - pos_scol_lon), dim=1))
start(2) = (MINLOC(abs(lats -scol_lat ), dim=1))

if (unstructured) then
allocate(cols(ni))
pos_lons(:) = mod(lons(:) + 360._r8, 360._r8)
pos_scol_lon = mod(scol_lon + 360._r8, 360._r8)
pos_lats(:) = lats(:) + 90._r8
pos_scol_lat = scol_lat + 90._r8
cols=abs(pos_lons - pos_scol_lon)+abs(pos_lats - pos_scol_lat)
start(1) = MINLOC(cols, dim=1)
start(2) = 1
deallocate(cols)
else
pos_lons(:) = mod(lons(:) + 360._r8, 360._r8)
pos_scol_lon = mod(scol_lon + 360._r8, 360._r8)
start(1) = (MINLOC(abs(pos_lons - pos_scol_lon), dim=1))
start(2) = (MINLOC(abs(lats -scol_lat ), dim=1))
end if
deallocate(lats)
deallocate(lons)
deallocate(pos_lons)
deallocate(glob_grid)

! read in value of nearest neighbor lon and RESET scol_lon and scol_lat
! also get area of gridcell, mask and frac
status = nf90_get_var(ncid, varid_xc, scol_lon, start)
Expand Down Expand Up @@ -1517,6 +1538,7 @@ subroutine esm_finalize(driver, rc)

call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO)
rc = ESMF_SUCCESS

call shr_log_setLogunit(logunit)
call ESMF_GridCompGet(driver, vm=vm, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
Expand Down
1 change: 0 additions & 1 deletion cesm/driver/esm_time_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@ subroutine esm_time_clockInit(ensemble_driver, instance_driver, logunit, maintas
call ESMF_TimeSet( RefTime, yy=yr, mm=mon, dd=day, s=ref_tod, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return


call ESMF_TimeIntervalSet( TimeStep, s=dtime_drv, rc=rc )
if (ChkErr(rc,__LINE__,u_FILE_u)) return

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
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
26 changes: 0 additions & 26 deletions cime_config/config_component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -821,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 @@ -1035,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
Loading

0 comments on commit 8a03c6f

Please sign in to comment.