Skip to content

Commit

Permalink
cpld_gridgen - Add 9-degree ocean+ice file generation (ufs-community#…
Browse files Browse the repository at this point in the history
…1013)

Adds a 9-degree ocean and ice resolution to the list of supported resolutions.
 
Updates the regression test to generate the desired resolutions of mapped 
ocean files through the "rt.conf" configuration file.

Fixes ufs-community#1004
  • Loading branch information
DeniseWorthen authored Feb 25, 2025
1 parent d0739a0 commit dd9257e
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 110 deletions.
4 changes: 2 additions & 2 deletions fix/link_fixdirs.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash
set -ex

# Set up the 'fixed' directories.
#
# Set up the 'fixed' directories.
#
# This script takes two arguments:
#
# $RUN_ENVIR - Either 'emc' (creates links) or
Expand Down
1 change: 1 addition & 0 deletions reg_tests/cpld_gridgen/parm/grid.nml.IN
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ res=RESNAME
editmask=DO_MASKEDIT
debug=DO_DEBUG
do_postwgts=DO_POSTWGTS
atmreslist=ATMRESLIST
/
27 changes: 18 additions & 9 deletions reg_tests/cpld_gridgen/rt.conf
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
#################################################################
# 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
# Baseline configurations are defined as
# TEST_NAME | ATMRESLIST
# TEST_NAME is one of the available ocean resolutions from
# 9deg (mx900) through 1/4deg (mx025)
# If ATMRESLIST is empty, mapped ocean mask files for ATM
# resolutions from C12 through C3072 will be generated for each
# ocean resolution
# Note that C3072 requires additional time and resources, see
# rt.sh
# The ATMRESLIST can also be specified as a subset of all available
# ATM resolutions, eg: 12,24,48 or 96,1152
#################################################################

# TEST_NAME |
mx025
mx050
mx100
mx500
# TEST_NAME | ATMRESLIST

mx025 | 48,96,192,384,768,1152
mx050 | 48,96,192,384,768,1152
mx100 | 48,96,192,384,768,1152
mx500 | 24,48,96,192,384,768,1152
mx900 | 12,24
161 changes: 78 additions & 83 deletions reg_tests/cpld_gridgen/rt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,57 +43,57 @@ check_results() {
# verification run
if [[ $CREATE_BASELINE = false ]]; then

echo | tee -a $PATHRT/$REGRESSIONTEST_LOG
echo "Working dir = $RUNDIR" | tee -a $PATHRT/$REGRESSIONTEST_LOG
echo "Baseline dir = $BASELINE" | tee -a $PATHRT/$REGRESSIONTEST_LOG
echo | tee -a $PATHRT/$REGRESSIONTEST_LOG
echo "Checking test $TEST_NAME results ...." | tee -a $PATHRT/$REGRESSIONTEST_LOG

for file in $BASELINE/*.nc; do
printf %s "Comparing " $(basename ${file}) "...." | tee -a $PATHRT/$REGRESSIONTEST_LOG

if [[ ! -f $RUNDIR/$(basename ${file}) ]]; then
echo "....MISSING file" | tee -a $PATHRT/$REGRESSIONTEST_LOG
test_status=FAIL
else
$NCCMP -dmfqS -w format $(basename ${file}) $file >>${PATHRT}/nccmp_${TEST_NAME}.log 2>&1 && d=$? || d=$?
if [[ $d -ne 0 ]]; then
echo "....NOT OK" | tee -a $PATHRT/$REGRESSIONTEST_LOG
test_status=FAIL
else
echo "....OK" | tee -a $PATHRT/$REGRESSIONTEST_LOG
fi
fi
done
echo | tee -a $PATHRT/$REGRESSIONTEST_LOG

# baseline creation run
echo | tee -a $PATHRT/$REGRESSIONTEST_LOG
echo "Working dir = $RUNDIR" | tee -a $PATHRT/$REGRESSIONTEST_LOG
echo "Baseline dir = $BASELINE" | tee -a $PATHRT/$REGRESSIONTEST_LOG
echo | tee -a $PATHRT/$REGRESSIONTEST_LOG
echo "Checking test $TEST_NAME results ...." | tee -a $PATHRT/$REGRESSIONTEST_LOG

for file in $BASELINE/*.nc; do
printf %s "Comparing " $(basename ${file}) "...." | tee -a $PATHRT/$REGRESSIONTEST_LOG

if [[ ! -f $RUNDIR/$(basename ${file}) ]]; then
echo "....MISSING file" | tee -a $PATHRT/$REGRESSIONTEST_LOG
test_status=FAIL
else
$NCCMP -dmfqS -w format $(basename ${file}) $file >>${PATHRT}/nccmp_${TEST_NAME}.log 2>&1 && d=$? || d=$?
if [[ $d -ne 0 ]]; then
echo "....NOT OK" | tee -a $PATHRT/$REGRESSIONTEST_LOG
test_status=FAIL
else
echo "....OK" | tee -a $PATHRT/$REGRESSIONTEST_LOG
fi
fi
done
echo | tee -a $PATHRT/$REGRESSIONTEST_LOG

# baseline creation run
else

echo | tee -a $PATHRT/$REGRESSIONTEST_LOG
echo "Working dir = $RUNDIR" | tee -a $PATHRT/$REGRESSIONTEST_LOG
echo "Moving baseline files to $NEW_BASELINE ...." | tee -a $PATHRT/$REGRESSIONTEST_LOG
echo | tee -a $PATHRT/$REGRESSIONTEST_LOG
echo | tee -a $PATHRT/$REGRESSIONTEST_LOG
echo "Working dir = $RUNDIR" | tee -a $PATHRT/$REGRESSIONTEST_LOG
echo "Moving baseline files to $NEW_BASELINE ...." | tee -a $PATHRT/$REGRESSIONTEST_LOG
echo | tee -a $PATHRT/$REGRESSIONTEST_LOG

mkdir -p $NEW_BASELINE
mkdir -p $NEW_BASELINE

for file in *.nc; do
printf %s "Moving " $file "...." | tee -a $PATHRT/$REGRESSIONTEST_LOG
for file in *.nc; do
printf %s "Moving " $file "...." | tee -a $PATHRT/$REGRESSIONTEST_LOG

cp $file $NEW_BASELINE/$file && d=$? || d=$?
if [[ $d -ne 0 ]]; then
echo "....NOT OK" | tee -a $PATHRT/$REGRESSIONTEST_LOG
test_status=FAIL
else
echo "....OK" | tee -a $PATHRT/$REGRESSIONTEST_LOG
fi
done
echo | tee -a $PATHRT/$REGRESSIONTEST_LOG
cp $file $NEW_BASELINE/$file && d=$? || d=$?
if [[ $d -ne 0 ]]; then
echo "....NOT OK" | tee -a $PATHRT/$REGRESSIONTEST_LOG
test_status=FAIL
else
echo "....OK" | tee -a $PATHRT/$REGRESSIONTEST_LOG
fi
done
echo | tee -a $PATHRT/$REGRESSIONTEST_LOG

fi

if [[ $test_status == FAIL ]]; then
echo "$TEST_NAME failed" >> $PATHRT/fail_test_$TEST_NAME
echo "$TEST_NAME failed" >> $PATHRT/fail_test_$TEST_NAME
fi
}

Expand All @@ -106,12 +106,14 @@ readonly PATHTR="$(cd $PATHRT/../.. && pwd)"
export PATHTR
TESTS_FILE="$PATHRT/rt.conf"
export TEST_NAME=
export ATMLIST=

# for C3072 on hera, use WLCLK=60 and MEM="--exclusive"
WLCLK_dflt=60
export WLCLK=$WLCLK_dflt
MEM_dflt="--mem=16g"
export MEM=$MEM_dflt
export MOM6_version=20250128

cd $PATHRT
export compiler=${compiler:-intelllvm}
Expand All @@ -131,7 +133,7 @@ rm -f fail_test* $COMPILE_LOG run_*.log nccmp_*.log summary.log

if [[ $target = wcoss2 ]]; then
STMP=${STMP:-/lfs/h2/emc/stmp/$USER}
export MOM6_FIXDIR=/lfs/h2/emc/global/noscrub/emc.global/FIX/fix/mom6/20220805
export MOM6_FIXDIR=/lfs/h2/emc/global/noscrub/emc.global/FIX/fix/mom6/${MOM6_version}
BASELINE_ROOT=/lfs/h2/emc/nems/noscrub/emc.nems/UFS_UTILS/reg_tests/cpld_gridgen/baseline_data
ACCOUNT=${ACCOUNT:-GFS-DEV}
export APRUN="mpiexec -n 1 -ppn 1 --cpu-bind core"
Expand All @@ -140,7 +142,7 @@ if [[ $target = wcoss2 ]]; then
NCCMP=nccmp
elif [[ $target = hera ]]; then
STMP=${STMP:-/scratch1/NCEPDEV/stmp4/$USER}
export MOM6_FIXDIR=/scratch1/NCEPDEV/global/glopara/fix/mom6/20220805
export MOM6_FIXDIR=/scratch1/NCEPDEV/global/glopara/fix/mom6/${MOM6_version}
BASELINE_ROOT=/scratch1/NCEPDEV/nems/role.ufsutils/ufs_utils/reg_tests/cpld_gridgen/baseline_data
ACCOUNT=${ACCOUNT:-nems}
QUEUE=${QUEUE:-batch}
Expand All @@ -149,7 +151,7 @@ elif [[ $target = hera ]]; then
SBATCH_COMMAND="./cpld_gridgen.sh"
elif [[ $target = orion ]]; then
STMP=${STMP:-/work/noaa/stmp/$USER}
export MOM6_FIXDIR=/work/noaa/global/glopara/fix/mom6/20220805
export MOM6_FIXDIR=/work/noaa/global/glopara/fix/mom6/${MOM6_version}
BASELINE_ROOT=/work/noaa/nems/role-nems/ufs_utils/reg_tests/cpld_gridgen/baseline_data
ACCOUNT=${ACCOUNT:-nems}
QUEUE=${QUEUE:-batch}
Expand All @@ -159,7 +161,7 @@ elif [[ $target = orion ]]; then
SBATCH_COMMAND="./cpld_gridgen.sh"
elif [[ $target = hercules ]]; then
STMP=${STMP:-/work2/noaa/stmp/$USER}
export MOM6_FIXDIR=/work/noaa/global/glopara/fix/mom6/20220805
export MOM6_FIXDIR=/work/noaa/global/glopara/fix/mom6/${MOM6_version}
BASELINE_ROOT=/work/noaa/nems/role-nems/ufs_utils.hercules/reg_tests/cpld_gridgen/baseline_data
ACCOUNT=${ACCOUNT:-nems}
QUEUE=${QUEUE:-batch}
Expand All @@ -169,7 +171,7 @@ elif [[ $target = hercules ]]; then
SBATCH_COMMAND="./cpld_gridgen.sh"
elif [[ $target = jet ]]; then
STMP=${STMP:-/lfs5/HFIP/h-nems/$USER}
export MOM6_FIXDIR=/lfs5/HFIP/hfv3gfs/glopara/FIX/fix/mom6/20220805
export MOM6_FIXDIR=/lfs5/HFIP/hfv3gfs/glopara/FIX/fix/mom6/${MOM6_version}
BASELINE_ROOT=/lfs5/HFIP/hfv3gfs/emc.nemspara/role.ufsutils/ufs_utils/reg_tests/cpld_gridgen/baseline_data
ACCOUNT=${ACCOUNT:-h-nems}
QUEUE=${QUEUE:-batch}
Expand All @@ -185,21 +187,21 @@ BUILD_EXE=false
CREATE_BASELINE=false
while getopts :bcmh opt; do
case $opt in
b)
BUILD_EXE=true
;;
c)
CREATE_BASELINE=true
;;
m)
BASELINE_ROOT=$NEW_BASELINE_ROOT
;;
h)
usage_and_exit 0
;;
'?')
error "$program: invalid option"
;;
b)
BUILD_EXE=true
;;
c)
CREATE_BASELINE=true
;;
m)
BASELINE_ROOT=$NEW_BASELINE_ROOT
;;
h)
usage_and_exit 0
;;
'?')
error "$program: invalid option"
;;
esac
done

Expand All @@ -209,9 +211,9 @@ if [[ $BUILD_EXE = true ]]; then
rm -rf $PATHTR/build $PATHTR/exec $PATHTR/lib
./build_all.sh >$PATHRT/$COMPILE_LOG 2>&1 && d=$? || d=$?
if [[ d -ne 0 ]]; then
error "Build did not finish successfully. Check $COMPILE_LOG"
error "Build did not finish successfully. Check $COMPILE_LOG"
else
echo "Build was successful"
echo "Build was successful"
fi
fi

Expand Down Expand Up @@ -248,6 +250,10 @@ while read -r line || [ "$line" ]; do

TEST_NAME=$(echo $line | cut -d'|' -f1 | sed -e 's/^ *//' -e 's/ *$//')
TEST_NAME=${TEST_NAME##mx}
ATMLIST=$(echo $line | cut -d'|' -f2 | sed -e 's/^ *//' -e 's/ *$//')
if [[ -z ${ATMLIST} ]]; then
ATMLIST=-1
fi

cd $PATHRT
RUNDIR=$RUNDIR_ROOT/$TEST_NAME
Expand All @@ -266,28 +272,17 @@ while read -r line || [ "$line" ]; do

if [[ $target = wcoss2 ]]; then

# rm -f $RUNDIR/bad.${TEST_NAME}

TEST=$(qsub -V -o $PATHRT/run_${TEST_NAME}.log -e $PATHRT/run_${TEST_NAME}.log -q $QUEUE -A $ACCOUNT \
-Wblock=true -l walltime=00:${WLCLK}:00 -N $TEST_NAME -l select=1:ncpus=1:mem=12GB -v RESNAME=$TEST_NAME $SBATCH_COMMAND)

# qsub -o $PATHRT/run_${TEST_NAME}.log -e $PATHRT/run_${TEST_NAME}.log -q $QUEUE -A $ACCOUNT \
# -Wblock=true -l walltime=00:01:00 -N chgres_summary -l select=1:ncpus=1:mem=100MB -W depend=afternotok:$TEST << EOF
#!/bin/bash
# touch $RUNDIR/bad.${TEST_NAME}
#EOF
# if [[ -f $RUNDIR/bad.${TEST_NAME} ]]; then
# error "Batch job for test $TEST_NAME did not finish successfully. Refer to run_${TEST_NAME}.log"
# fi
TEST=$(qsub -V -o $PATHRT/run_${TEST_NAME}.log -e $PATHRT/run_${TEST_NAME}.log -q $QUEUE -A $ACCOUNT \
-Wblock=true -l walltime=00:${WLCLK}:00 -N $TEST_NAME -l select=1:ncpus=1:mem=12GB -v RESNAME=$TEST_NAME $SBATCH_COMMAND)

else
sbatch --wait --ntasks-per-node=1 --nodes=1 ${MEM} -t 00:${WLCLK}:00 -A $ACCOUNT -q $QUEUE -J $TEST_NAME \
--partition=$PARTITION -o $PATHRT/run_${TEST_NAME}.log -e $PATHRT/run_${TEST_NAME}.log \
--wrap "time $SBATCH_COMMAND $TEST_NAME" && d=$? || d=$?
sbatch --wait --ntasks-per-node=1 --nodes=1 ${MEM} -t 00:${WLCLK}:00 -A $ACCOUNT -q $QUEUE -J $TEST_NAME \
--partition=$PARTITION -o $PATHRT/run_${TEST_NAME}.log -e $PATHRT/run_${TEST_NAME}.log \
--wrap "time $SBATCH_COMMAND $TEST_NAME $ATMLIST" && d=$? || d=$?

if [[ d -ne 0 ]]; then
error "Batch job for test $TEST_NAME did not finish successfully. Refer to run_${TEST_NAME}.log"
fi
if [[ d -ne 0 ]]; then
error "Batch job for test $TEST_NAME did not finish successfully. Refer to run_${TEST_NAME}.log"
fi

fi

Expand Down
2 changes: 1 addition & 1 deletion sorc/cpld_gridgen.fd/gen_fixgrid.F90
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ program gen_fixgrid
! tiled files containing the mapped ocean mask
!---------------------------------------------------------------------

do n = 1,nar
do n = 1,size(catm)
npx = catm(n)
if (npx < 100) then
write(atmres,'(a,i2)')'C',npx
Expand Down
5 changes: 3 additions & 2 deletions sorc/cpld_gridgen.fd/grdvars.F90
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +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
! ATM resolutions
integer, parameter :: maxatmres = 10 !< The maximum number of possible ATM resolutions
integer, allocatable, dimension(:) :: catm !< The ATM resolutions for mapped ocean masks

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

module inputnml

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

Expand All @@ -26,11 +26,12 @@ subroutine read_inputnml(fname)
character(len=*), intent(in) :: fname

! local variables
integer :: iounit, rc
integer :: ii, nvalid, iounit, rc
character(len=200) :: tmpstr
character(len=6) :: atmreslist(maxatmres) = ''

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

! Check whether file exists.
inquire (file=trim(fname), iostat=rc)
Expand All @@ -50,6 +51,15 @@ subroutine read_inputnml(fname)
end if
close(iounit)

! Set the desired ATM resolutions
nvalid = 0
do ii = 1,size(atmreslist)
if (len_trim(atmreslist(ii)) > 0) nvalid = nvalid+1
end do
allocate(catm(nvalid))
do ii = 1,size(catm)
read(atmreslist(ii),'(i4)')catm(ii)
end do
! set supergrid dimensions
nx = ni*2
ny = nj*2
Expand Down
Loading

0 comments on commit dd9257e

Please sign in to comment.