Skip to content

Commit

Permalink
cpld_gridgen - Generalize ATM-OCN resolutions for mapped ocean mask g…
Browse files Browse the repository at this point in the history
…eneration (#993)

The cpld_gridgen code is updated to loop over all 6 ATM resolutions 
(C48, C96, C100, C384, C768 and C1152) and produce the mapped ocean 
mask for a given OCN resolution.  The regression tests were updated to
include the processing of these new ATM resolutions. Minor updates to the 
documentation were also added.

Fixes #976.
  • Loading branch information
DeniseWorthen authored Nov 8, 2024
1 parent 2323761 commit c134505
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 73 deletions.
2 changes: 0 additions & 2 deletions reg_tests/cpld_gridgen/parm/grid.nml.IN
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ fv3dir='MOSAICDIR'
topofile='TOPOGFILE'
editsfile='EDITSFILE'
res=RESNAME
atmres='MOSAICRES'
npx=NPX
editmask=DO_MASKEDIT
debug=DO_DEBUG
do_postwgts=DO_POSTWGTS
Expand Down
33 changes: 7 additions & 26 deletions reg_tests/cpld_gridgen/rt.conf
Original file line number Diff line number Diff line change
@@ -1,31 +1,12 @@
#################################################################
# Baseline configurations
# For each listed OCN resolution, mapped ocean masks will be
# generated for C48,C96,C192,C384,C768 and C1152. For C3072
# resources and memory will need to be increased. See rt.sh
#################################################################

# TEST_NAME |

C384_025 |
C192_050 |
C096_100 |
C048_500 |

#################################################################
# Non-baseline configurations.
# These configurations have been tested on hera. For hera, the
# memory use for the C3072 config is approx 60% of the full node,
# C1152 is 12% of the full node and C768 is 8% of the full node.
# The default is set as 12g on RDHPCS platforms and should be
# sufficient for all but C3072. On hera C3072 requires approx 50min
# of wall clock and using --exclusive. See C3072 settings in rt.sh
#
# Note that the 5deg ocean cases are currently only supported on
# hera
#################################################################

#C3072_025 |
#C1152_025 |
#C768_025 |

#C192_025 |
#C048_500 |
#C096_500 |
mx025
mx050
mx100
mx500
4 changes: 1 addition & 3 deletions reg_tests/cpld_gridgen/rt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,7 @@ while read -r line || [ "$line" ]; do
[[ $line =~ \# ]] && continue

TEST_NAME=$(echo $line | cut -d'|' -f1 | sed -e 's/^ *//' -e 's/ *$//')
MOSAICRES=${TEST_NAME%_*}
TEST_NAME=${TEST_NAME##*_}
TEST_NAME=${TEST_NAME##mx}

cd $PATHRT
RUNDIR=$RUNDIR_ROOT/$TEST_NAME
Expand All @@ -251,7 +250,6 @@ while read -r line || [ "$line" ]; do
# OUTDIR_PATH is passed down to $PATHTR/ush/cpld_gridgen.sh
# It MUST be set
export OUTDIR_PATH=$RUNDIR
export MOSAICRES=$MOSAICRES

cp $PATHTR/exec/cpld_gridgen $RUNDIR
cp $PATHTR/ush/cpld_gridgen.sh $RUNDIR
Expand Down
2 changes: 1 addition & 1 deletion sorc/cpld_gridgen.fd/docs/cpld_gridgen.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ the source tripole grid.
<tr><td row=2>grid_cice_NEMS_mx025.nc <td>the CICE grid file <td>used at runtime by CICE6
<tr><td row=3>kmtu_cice_NEMS_mx025.nc <td>the CICE mask file <td>used at runtime by CICE6
<tr><td row=4>mesh.mx025.nc <td>the ocean and ice mesh file <td>used at runtime by CICE6, MOM6, and CMEPS
<tr><td row=5>C384.mx025.tile[1-6].nc <td>the mapped ocean mask on the ATM tiles <td>used to create ATM ICs consistent with the <br> fractional grid
<tr><td row=5>C[XXX].mx025.tile[1-6].nc <td>the mapped ocean mask on the ATM tiles <td>used to create ATM ICs consistent with the <br> fractional grid for a given ATM resolution, where C[XXX]=C48,C96,C192,C384,C768 or C1152
</table>

<br>
Expand Down
47 changes: 28 additions & 19 deletions sorc/cpld_gridgen.fd/gen_fixgrid.F90
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ program gen_fixgrid
use cicegrid, only: write_cicegrid
use scripgrid, only: write_scripgrid
use topoedits, only: add_topoedits, apply_topoedits
use charstrings, only: logmsg, res, dirsrc, dirout, atmres, fv3dir, editsfile
use charstrings, only: logmsg, res, atmres, dirsrc, dirout, fv3dir, editsfile
use charstrings, only: maskfile, maskname, topofile, toponame, editsfile, staggerlocs, cdate, history
use debugprint, only: checkseam, checkxlatlon, checkpoint
use netcdf
Expand All @@ -48,7 +48,7 @@ program gen_fixgrid
character(len= 2) :: cstagger

integer :: rc,ncid,id,xtype
integer :: i,j,k,i2,j2
integer :: i,j,k,n,i2,j2
integer :: ii
integer :: localPet, nPet
logical :: fexist = .false.
Expand Down Expand Up @@ -89,8 +89,6 @@ program gen_fixgrid
print '(a)',' output grid tag '//trim(res)
print '(a)',' supergrid source directory '//trim(dirsrc)
print '(a)',' output grid directory '//trim(dirout)
print '(a)',' atm resolution '//trim(atmres)
print '(a,i6)',' fv3 tile grid size ',npx
print '(a)',' atm mosaic directory '//trim(fv3dir)
print '(a)',' MOM6 topography file '//trim(topofile)
print '(a)',' MOM6 edits file '//trim(editsfile)
Expand Down Expand Up @@ -486,23 +484,34 @@ program gen_fixgrid
! tiled files containing the mapped ocean mask
!---------------------------------------------------------------------

method=ESMF_REGRIDMETHOD_CONSERVE
fsrc = trim(dirout)//'/'//'Ct.mx'//trim(res)//'_SCRIP_land.nc'
fdst = trim(fv3dir)//'/'//trim(atmres)//'/'//trim(atmres)//'_mosaic.nc'
fwgt = trim(dirout)//'/'//'Ct.mx'//trim(res)//'.to.'//trim(atmres)//'.nc'
logmsg = 'creating weight file '//trim(fwgt)
print '(a)',trim(logmsg)
do n = 1,nar
npx = catm(n)
if (npx < 100) then
write(atmres,'(a,i2)')'C',npx
elseif (npx < 1000) then
write(atmres,'(a,i3)')'C',npx
else
write(atmres,'(a,i4)')'C',npx
end if

call ESMF_RegridWeightGen(srcFile=trim(fsrc),dstFile=trim(fdst), &
weightFile=trim(fwgt), regridmethod=method, &
unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, ignoreDegenerate=.true., &
netcdf4fileFlag=.true., tileFilePath=trim(fv3dir)//'/'//trim(atmres)//'/', rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) call ESMF_Finalize(endflag=ESMF_END_ABORT)
method=ESMF_REGRIDMETHOD_CONSERVE
fsrc = trim(dirout)//'/'//'Ct.mx'//trim(res)//'_SCRIP_land.nc'
fdst = trim(fv3dir)//'/'//trim(atmres)//'/'//trim(atmres)//'_mosaic.nc'
fwgt = trim(dirout)//'/'//'Ct.mx'//trim(res)//'.to.'//trim(atmres)//'.nc'
logmsg = 'creating weight file '//trim(fwgt)
print '(a)',trim(logmsg)

logmsg = 'creating mapped ocean mask for '//trim(atmres)
print '(a)',trim(logmsg)
call make_frac_land(trim(fsrc), trim(fwgt))
call ESMF_RegridWeightGen(srcFile=trim(fsrc),dstFile=trim(fdst), &
weightFile=trim(fwgt), regridmethod=method, &
unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, ignoreDegenerate=.true., &
netcdf4fileFlag=.true., tileFilePath=trim(fv3dir)//'/'//trim(atmres)//'/', rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) call ESMF_Finalize(endflag=ESMF_END_ABORT)

logmsg = 'creating mapped ocean mask for '//trim(atmres)
print '(a)',trim(logmsg)
call make_frac_land(trim(fsrc), trim(fwgt))
end do

!---------------------------------------------------------------------
! use ESMF to create positional weights for mapping a field from its
Expand Down
3 changes: 3 additions & 0 deletions sorc/cpld_gridgen.fd/grdvars.F90
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ module grdvars
!! rounded to minimum_depth
real(kind=real_kind), parameter :: maximum_lat = 88.0 !< The maximum latitude for water points for WW3

integer, parameter :: nar = 6 !< the number of possible ATM resolutions
integer, parameter, dimension(nar) :: catm = (/48, 96, 192, 384, 768, 1152/) !< the ATM resolutions for mapped ocean masks

contains
!> Allocate grid variables
!!
Expand Down
5 changes: 2 additions & 3 deletions sorc/cpld_gridgen.fd/inputnml.F90
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module inputnml

use grdvars, only : nx,ny,ni,nj,npx
use grdvars, only : editmask, debug, do_postwgts
use charstrings, only : dirsrc, dirout, fv3dir, res, atmres, topofile, editsfile
use charstrings, only : dirsrc, dirout, fv3dir, res, topofile, editsfile

implicit none

Expand All @@ -30,8 +30,7 @@ subroutine read_inputnml(fname)
character(len=200) :: tmpstr

namelist /grid_nml/ ni, nj, dirsrc, dirout, fv3dir, topofile, editsfile, &
res, atmres, npx, editmask, debug, &
do_postwgts
res, editmask, debug, do_postwgts

! Check whether file exists.
inquire (file=trim(fname), iostat=rc)
Expand Down
19 changes: 0 additions & 19 deletions ush/cpld_gridgen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ function edit_namelist {
-e "s/TOPOGFILE/$TOPOGFILE/g" \
-e "s/EDITSFILE/$EDITSFILE/g" \
-e "s/RESNAME/$RESNAME/g" \
-e "s/MOSAICRES/$MOSAICRES/g" \
-e "s/NPX/$NPX/g" \
-e "s/DO_MASKEDIT/$MASKEDIT/g" \
-e "s/DO_DEBUG/$DEBUG/g" \
-e "s/DO_POSTWGTS/$DO_POSTWGTS/g"
Expand All @@ -23,23 +21,6 @@ export DEBUG=.false.
export MASKEDIT=.false.
export DO_POSTWGTS=.true.
export MOSAICDIR_PATH=${MOSAICDIR_PATH:-$PATHTR/fix/orog}
if [[ $MOSAICRES == C3072 ]]; then
export NPX=3072
elif [[ $MOSAICRES == C1152 ]]; then
export NPX=1152
elif [[ $MOSAICRES == C768 ]]; then
export NPX=768
elif [[ $MOSAICRES == C384 ]]; then
export NPX=384
elif [[ $MOSAICRES == C192 ]]; then
export NPX=192
elif [[ $MOSAICRES == C096 ]]; then
export MOSAICRES=C96
export NPX=96
elif [[ $MOSAICRES == C048 ]]; then
export MOSAICRES=C48
export NPX=48
fi
export FIXDIR_PATH=${MOM6_FIXDIR}/${RESNAME}

APRUN=${APRUN:-"srun"}
Expand Down

0 comments on commit c134505

Please sign in to comment.