Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modify cpld_gridgen as required by new ocnice_prep utility #945

Closed
Closed
16 changes: 7 additions & 9 deletions reg_tests/cpld_gridgen/rt.conf
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
#################################################################
# Baseline configurations
# C384_025 needs to be the first test due to dependency of
# the weight-generation from 1/4deg ocean to lower resolution
#################################################################

# TEST_NAME | DEP_NAME
#
# TEST_NAME |

C384_025 |
C192_050 | C384_025
C096_100 | C384_025
C048_500 | C384_025
C192_050 |
C096_100 |
C048_500 |

#################################################################
# Non-baseline configurations.
Expand All @@ -29,5 +27,5 @@
#C768_025 |

#C192_025 |
#C048_500 | C384_025
#C096_500 | C384_025
#C048_500 |
#C096_500 |
10 changes: 0 additions & 10 deletions reg_tests/cpld_gridgen/rt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -235,30 +235,20 @@ while read -r line || [ "$line" ]; do
[[ $line =~ \# ]] && continue

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

cd $PATHRT
RUNDIR=$RUNDIR_ROOT/$TEST_NAME
BASELINE=$BASELINE_ROOT/$TEST_NAME
NEW_BASELINE=$NEW_BASELINE_ROOT/$TEST_NAME
DEPDIR=$RUNDIR_ROOT/$DEP_NAME
mkdir -p $RUNDIR

# OUTDIR_PATH is passed down to $PATHTR/ush/cpld_gridgen.sh
# It MUST be set
export OUTDIR_PATH=$RUNDIR
export MOSAICRES=$MOSAICRES

if [[ -n $DEP_NAME ]]; then
cp $DEPDIR/Ct.mx025_SCRIP.nc $RUNDIR >/dev/null 2>&1 && d=$? || d=$?
if [[ $d -eq 1 ]]; then
error "DEPDIR $DEPDIR does not exist. Dependency not met"
fi
fi

cp $PATHTR/exec/cpld_gridgen $RUNDIR
cp $PATHTR/ush/cpld_gridgen.sh $RUNDIR
cp $PATHRT/parm/grid.nml.IN $RUNDIR
Expand Down
2 changes: 1 addition & 1 deletion sorc/cpld_gridgen.fd/docs/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ EXAMPLE_RECURSIVE = NO
# that contain images that are to be included in the documentation (see the
# \image command).

IMAGE_PATH =
IMAGE_PATH = @abs_top_srcdir@/sorc/cpld_gridgen.fd/docs/_static

# The INPUT_FILTER tag can be used to specify a program that doxygen should
# invoke to filter for each input file. Doxygen will invoke the filter program
Expand Down
Binary file added sorc/cpld_gridgen.fd/docs/_static/murray.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
196 changes: 149 additions & 47 deletions sorc/cpld_gridgen.fd/docs/cpld_gridgen.md

Large diffs are not rendered by default.

76 changes: 36 additions & 40 deletions sorc/cpld_gridgen.fd/gen_fixgrid.F90
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,8 @@ program gen_fixgrid
fdst = trim(dirout)//'/'//'grid_cice_NEMS_mx'//trim(res)//'.nc'
call write_cicegrid(trim(fdst))
deallocate(ulon, ulat, htn, hte)
! write scrip grids; only the Ct is required, the remaining
! staggers are used only in the postweights generation

! write SCRIP files for generation of positional weights
do k = 1,nv
cstagger = trim(staggerlocs(k))
fdst = trim(dirout)//'/'//trim(cstagger)//'.mx'//trim(res)//'_SCRIP.nc'
Expand Down Expand Up @@ -505,56 +505,52 @@ program gen_fixgrid
call make_frac_land(trim(fsrc), trim(fwgt))

!---------------------------------------------------------------------
! use ESMF to find the tripole:tripole weights for creation
! of CICE ICs; the source grid is always mx025; don't create this
! file if destination is also mx025
! use ESMF to create positional weights for mapping a field from its
! native stagger location (Cu,Cv,Bu) onto the center (Ct) grid location
!---------------------------------------------------------------------

method=ESMF_REGRIDMETHOD_BILINEAR
fdst = trim(dirout)//'/'//'Ct.mx'//trim(res)//'_SCRIP.nc'
do k = 2,nv
cstagger = trim(staggerlocs(k))
fsrc = trim(dirout)//'/'//trim(cstagger)//'.mx'//trim(res)//'_SCRIP.nc'
fwgt = trim(dirout)//'/'//'tripole.mx'//trim(res)//'.'//trim(cstagger)//'.to.Ct.bilinear.nc'
logmsg = 'creating weight file '//trim(fwgt)
print '(a)',trim(logmsg)

call ESMF_RegridWeightGen(srcFile=trim(fsrc),dstFile=trim(fdst), &
weightFile=trim(fwgt), regridmethod=method, &
ignoreDegenerate=.true., &
unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) call ESMF_Finalize(endflag=ESMF_END_ABORT)
end do

!---------------------------------------------------------------------
! use ESMF to create positional weights for mapping a field from the
! center (Ct) grid location back to the native stagger location
! (Cu,Cv,Bu). The destination is never mx025.
!---------------------------------------------------------------------

if(trim(res) .ne. '025') then
fsrc = trim(dirout)//'/'//'Ct.mx025_SCRIP.nc'
inquire(FILE=trim(fsrc), EXIST=fexist)
if (fexist ) then
method=ESMF_REGRIDMETHOD_NEAREST_STOD
fdst = trim(dirout)//'/'//'Ct.mx'//trim(res)//'_SCRIP.nc'
fwgt = trim(dirout)//'/'//'tripole.mx025.Ct.to.mx'//trim(res)//'.Ct.neareststod.nc'
method=ESMF_REGRIDMETHOD_BILINEAR
fsrc = trim(dirout)//'/'//'Ct.mx'//trim(res)//'_SCRIP.nc'
do k = 2,nv
cstagger = trim(staggerlocs(k))
fdst = trim(dirout)//'/'//trim(cstagger)//'.mx'//trim(res)//'_SCRIP.nc'
fwgt = trim(dirout)//'/'//'tripole.mx'//trim(res)//'.Ct.to.'//trim(cstagger)//'.bilinear.nc'
logmsg = 'creating weight file '//trim(fwgt)
print '(a)',trim(logmsg)
call ESMF_RegridWeightGen(srcFile=trim(fsrc),dstFile=trim(fdst), &
weightFile=trim(fwgt), regridmethod=method, &
ignoreDegenerate=.true., unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, 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_BILINEAR
fdst = trim(dirout)//'/'//'Ct.mx'//trim(res)//'_SCRIP.nc'
fwgt = trim(dirout)//'/'//'tripole.mx025.Ct.to.mx'//trim(res)//'.Ct.bilinear.nc'
logmsg = 'creating weight file '//trim(fwgt)
print '(a)',trim(logmsg)
call ESMF_RegridWeightGen(srcFile=trim(fsrc),dstFile=trim(fdst), &
weightFile=trim(fwgt), regridmethod=method, &
ignoreDegenerate=.true., unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, rc=rc)
ignoreDegenerate=.true., &
unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) call ESMF_Finalize(endflag=ESMF_END_ABORT)
else
logmsg = 'ERROR: '//trim(fsrc)//' is required to generate tripole:triple weights'
print '(a)',trim(logmsg)
stop
end if
end do
end if

! tripole Ct->tripole Bu for CICE are only for CICE IC creation
fsrc = trim(dirout)//'/'//'Ct.mx'//trim(res)//'_SCRIP.nc'
fdst = trim(dirout)//'/'//'Bu.mx'//trim(res)//'_SCRIP.nc'
fwgt = trim(dirout)//'/'//'tripole.mx'//trim(res)//'.Ct.to.Bu.bilinear.nc'
logmsg = 'creating weight file '//trim(fwgt)
print '(a)',trim(logmsg)

call ESMF_RegridWeightGen(srcFile=trim(fsrc),dstFile=trim(fdst), &
weightFile=trim(fwgt), regridmethod=method, &
ignoreDegenerate=.true., unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) call ESMF_Finalize(endflag=ESMF_END_ABORT)

!---------------------------------------------------------------------
!
!---------------------------------------------------------------------
Expand Down
28 changes: 2 additions & 26 deletions sorc/cpld_gridgen.fd/postwgts.F90
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,20 @@ module postwgts

use gengrid_kinds, only : CL,CM,CS
use grdvars, only : nv
use charstrings, only : dirout, res, staggerlocs, logmsg
use charstrings, only : dirout, res, logmsg
use netcdf

implicit none

contains
!> Create the ESMF weights files to remap velocity points from their native stagger location to the center
!! (Ct) location. Create the ESMF weights file to remap from the Ct location to a rectilinear grid
!> Create the ESMF weights file to remap from the Ct location to a rectilinear grid
!!
!! @author [email protected]

subroutine make_postwgts

! local variables
character(len=CL) :: fsrc, fdst, fwgt
character(len= 2) :: cstagger

character(len=CM), dimension(2) :: methodname = (/'conserve', 'bilinear'/)

Expand Down Expand Up @@ -60,28 +58,6 @@ subroutine make_postwgts
destgrds = (/'5p00', '1p00', '0p50', '0p25'/)
end if

!---------------------------------------------------------------------
! use ESMF to create the weights for unstaggering the points onto
! the Ct staggers for post; the destination is always Ct
!---------------------------------------------------------------------

method=ESMF_REGRIDMETHOD_BILINEAR
fdst = trim(dirout)//'/'//'Ct.mx'//trim(res)//'_SCRIP.nc'
do k = 2,nv
cstagger = trim(staggerlocs(k))
fsrc = trim(dirout)//'/'//trim(cstagger)//'.mx'//trim(res)//'_SCRIP.nc'
fwgt = trim(dirout)//'/'//'tripole.mx'//trim(res)//'.'//trim(cstagger)//'.to.Ct.bilinear.nc'
logmsg = 'creating weight file '//trim(fwgt)
print '(a)',trim(logmsg)

call ESMF_RegridWeightGen(srcFile=trim(fsrc),dstFile=trim(fdst), &
weightFile=trim(fwgt), regridmethod=method, &
ignoreDegenerate=.true., &
unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) call ESMF_Finalize(endflag=ESMF_END_ABORT)
end do

!---------------------------------------------------------------------
! use ESMF to create the weights from the Ct tripole to the rectilinear
! grids with conservative and bilinear methods for post; the source
Expand Down
Loading