Skip to content

Commit

Permalink
add optional RH for postweights
Browse files Browse the repository at this point in the history
  • Loading branch information
DeniseWorthen committed Oct 10, 2023
1 parent a9309cb commit 6292d95
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion sorc/cpld_gridgen.fd/charstrings.F90
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module charstrings
character(len=CL) :: dirout !< The directory where output files will be written
character(len=CL) :: fv3dir !< The directory containing the FV3 mosaic files
character(len=CS) :: res !< The Ocean/Ice resolution, e.g. 500 (5deg), 100 (1deg)
!! 050 (1/2deg), 025 (1/4deg)
!! 050 (1/2deg), 025 (1/4deg)
character(len=CS) :: atmres !< The ATM resolution, e.g. C96, C192, C384
character(len=CL) :: logmsg !< An informational message

Expand Down
9 changes: 5 additions & 4 deletions sorc/cpld_gridgen.fd/postwgts.F90
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ subroutine make_postwgts

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

type(ESMF_RouteHandle) :: rh
type(ESMF_RegridMethod_Flag) :: method
! the number of possible destination grids depends on the source grid resolution
integer :: k,rc,nd,ndest
Expand Down Expand Up @@ -71,8 +72,8 @@ subroutine make_postwgts
print '(a)',trim(logmsg)

call ESMF_RegridWeightGen(srcFile=trim(fsrc),dstFile=trim(fdst), &
weightFile=trim(fwgt), regridmethod=method, &
ignoreDegenerate=.true., &
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 All @@ -98,8 +99,8 @@ subroutine make_postwgts
print '(a)',trim(logmsg)

call ESMF_RegridWeightGen(srcFile=trim(fsrc),dstFile=trim(fdst), &
weightFile=trim(fwgt), regridmethod=method, &
ignoreDegenerate=.true., &
weightFile=trim(fwgt), regridmethod=method, &
ignoreDegenerate=.true., regridRouteHandle=rh, &
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
18 changes: 18 additions & 0 deletions ush/cpld_gridgen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ if [ $RESNAME = 100 ]; then
if [ $DO_POSTWGTS == .true. ]; then
#pre-generate SCRIP files for dst rectilinear grids using NCO
ncremap -g ${OUTDIR_PATH}/rect.1p0_SCRIP.nc -G latlon=181,360#lon_typ=grn_ctr#lat_typ=cap
export FSRC=${OUTDIR_PATH}/rect.1p0_SCRIP.nc
export FDST=${OUTDIR_PATH}/rect.1p0_mesh.nc
$APRUN -n 1 ESMF_Scrip2Unstruct ${FSRC} ${FDST} 0
fi
fi

Expand All @@ -77,6 +80,12 @@ if [ $RESNAME = 050 ]; then
#pre-generate SCRIP files for dst rectilinear grids using NCO
ncremap -g ${OUTDIR_PATH}/rect.1p0_SCRIP.nc -G latlon=181,360#lon_typ=grn_ctr#lat_typ=cap
ncremap -g ${OUTDIR_PATH}/rect.0p5_SCRIP.nc -G latlon=361,720#lon_typ=grn_ctr#lat_typ=cap
export FSRC=${OUTDIR_PATH}/rect.1p0_SCRIP.nc
export FDST=${OUTDIR_PATH}/rect.1p0_mesh.nc
$APRUN -n 1 ESMF_Scrip2Unstruct ${FSRC} ${FDST} 0
export FSRC=${OUTDIR_PATH}/rect.0p5_SCRIP.nc
export FDST=${OUTDIR_PATH}/rect.0p5_mesh.nc
$APRUN -n 1 ESMF_Scrip2Unstruct ${FSRC} ${FDST} 0
fi
fi

Expand All @@ -90,6 +99,15 @@ if [ $RESNAME = 025 ]; then
ncremap -g ${OUTDIR_PATH}/rect.1p0_SCRIP.nc -G latlon=181,360#lon_typ=grn_ctr#lat_typ=cap
ncremap -g ${OUTDIR_PATH}/rect.0p5_SCRIP.nc -G latlon=361,720#lon_typ=grn_ctr#lat_typ=cap
ncremap -g ${OUTDIR_PATH}/rect.0p25_SCRIP.nc -G latlon=721,1440#lon_typ=grn_ctr#lat_typ=cap
export FSRC=${OUTDIR_PATH}/rect.1p0_SCRIP.nc
export FDST=${OUTDIR_PATH}/rect.1p0_mesh.nc
$APRUN -n 1 ESMF_Scrip2Unstruct ${FSRC} ${FDST} 0
export FSRC=${OUTDIR_PATH}/rect.0p5_SCRIP.nc
export FDST=${OUTDIR_PATH}/rect.0p5_mesh.nc
$APRUN -n 1 ESMF_Scrip2Unstruct ${FSRC} ${FDST} 0
export FSRC=${OUTDIR_PATH}/rect.0p25_SCRIP.nc
export FDST=${OUTDIR_PATH}/rect.0p25_mesh.nc
$APRUN -n 1 ESMF_Scrip2Unstruct ${FSRC} ${FDST} 0
fi
fi

Expand Down

0 comments on commit 6292d95

Please sign in to comment.