Skip to content

Commit

Permalink
GSL orographic drag parameter computation (#273)
Browse files Browse the repository at this point in the history
Add new program to compute parameters needed for the GSL 
subgrid-scale orographic drag suite. 

Update the grid generation scripts to make the creation
of these parameters an option.

Add a regression test for this new option.

Fixes #253
  • Loading branch information
mdtoy authored Apr 9, 2021
1 parent e28b309 commit 15bab55
Show file tree
Hide file tree
Showing 19 changed files with 3,004 additions and 12 deletions.
2 changes: 2 additions & 0 deletions driver_scripts/driver_grid.cray.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ module list

export gtype=uniform # 'uniform', 'stretch', 'nest',
# 'regional_gfdl', 'regional_esg'
export make_gsl_orog=false # 'true' if user needs 'oro' files for GSL
# orographic drag suite
if [ $gtype = uniform ]; then
export res=96
export add_lake=false # Add lake frac and depth to orography data.
Expand Down
2 changes: 2 additions & 0 deletions driver_scripts/driver_grid.dell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ module list

export gtype=uniform # 'uniform', 'stretch', 'nest',
# 'regional_gfdl', 'regional_esg'
export make_gsl_orog=false # 'true' if user needs 'oro' files for GSL
# orographic drag suite
if [ $gtype = uniform ]; then
export res=96
export add_lake=false # Add lake frac and depth to orography data.
Expand Down
8 changes: 5 additions & 3 deletions driver_scripts/driver_grid.hera.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

#SBATCH -J fv3_grid_driver
#SBATCH -A fv3-cpu
#SBATCH -A wrfruc
#SBATCH --open-mode=truncate
#SBATCH -o log.fv3_grid_driver
#SBATCH -e log.fv3_grid_driver
Expand Down Expand Up @@ -71,6 +71,8 @@ module list

export gtype=uniform # 'uniform', 'stretch', 'nest',
# 'regional_gfdl', 'regional_esg'
export make_gsl_orog=false # 'true' if user needs 'oro' files for GSL
# orographic drag suite
if [ $gtype = uniform ]; then
export res=96
export add_lake=false # Add lake frac and depth to orography data.
Expand All @@ -92,7 +94,7 @@ elif [ $gtype = nest ] || [ $gtype = regional_gfdl ]; then
export jstart_nest=331 # Starting j-direction index of nest grid in parent tile supergrid
export iend_nest=1402 # Ending i-direction index of nest grid in parent tile supergrid
export jend_nest=1194 # Ending j-direction index of nest grid in parent tile supergrid
export halo=3 # Lateral boundary halo
export halo=4 # Lateral boundary halo
elif [ $gtype = regional_esg ] ; then
export res=-999 # equivalent resolution is computed
export target_lon=-97.5 # Center longitude of grid
Expand All @@ -105,7 +107,7 @@ elif [ $gtype = regional_esg ] ; then
# direction is related to delx as follows:
# distance = 2*delx*(circumf_Earth/360 deg)
export dely=0.0585 # Grid spacing (in degrees) in the 'j' direction.
export halo=3 # number of row/cols for halo
export halo=4 # number of row/cols for halo
fi

#-----------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions driver_scripts/driver_grid.jet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ module list

export gtype=uniform # 'uniform', 'stretch', 'nest',
# 'regional_gfdl', 'regional_esg'
export make_gsl_orog=false # 'true' if user needs 'oro' files for GSL
# orographic drag suite
if [ $gtype = uniform ]; then
export res=96
export add_lake=false # Add lake frac and depth to orography data.
Expand Down
2 changes: 2 additions & 0 deletions driver_scripts/driver_grid.orion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ module list

export gtype=uniform # 'uniform', 'stretch', 'nest',
# 'regional_gfdl', 'regional_esg'
export make_gsl_orog=false # 'true' if user needs 'oro' files for GSL
# orographic drag suite
if [ $gtype = uniform ]; then
export res=96
export add_lake=false # Add lake frac and depth to orography data.
Expand Down
9 changes: 8 additions & 1 deletion reg_tests/grid_gen/driver.cray.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,17 @@ bsub -e $LOG_FILE -o $LOG_FILE -q $QUEUE -P $PROJECT_CODE -J gfdl.regional -W 0:
bsub -e $LOG_FILE -o $LOG_FILE -q $QUEUE -P $PROJECT_CODE -J esg.regional -W 0:10 -M 2400 \
-w 'ended(gfdl.regional)' -extsched 'CRAYLINUX[]' "export NODES=1; $PWD/esg.regional.sh"

#-----------------------------------------------------------------------------
# Regional GSL gravity wave drag.
#-----------------------------------------------------------------------------

bsub -e $LOG_FILE -o $LOG_FILE -q $QUEUE -P $PROJECT_CODE -J reg.gsl.gwd -W 0:08 -M 2400 \
-w 'ended(esg.regional)' -extsched 'CRAYLINUX[]' "export NODES=1; $PWD/regional.gsl.gwd.sh"

#-----------------------------------------------------------------------------
# Create summary log.
#-----------------------------------------------------------------------------

bsub -o $LOG_FILE -q $QUEUE -P $PROJECT_CODE -J summary -R "rusage[mem=100]" -W 0:01 -w 'ended(esg.regional)' "grep -a '<<<' $LOG_FILE >> $SUM_FILE"
bsub -o $LOG_FILE -q $QUEUE -P $PROJECT_CODE -J summary -R "rusage[mem=100]" -W 0:01 -w 'ended(reg.gsl.gwd)' "grep -a '<<<' $LOG_FILE >> $SUM_FILE"

exit
9 changes: 8 additions & 1 deletion reg_tests/grid_gen/driver.dell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,16 @@ bsub -e $LOG_FILE -o $LOG_FILE -q $QUEUE -P $PROJECT_CODE -J gfdl.regional -W 0:
bsub -e $LOG_FILE -o $LOG_FILE -q $QUEUE -P $PROJECT_CODE -J esg.regional -W 0:10 -x -n 24 -w 'ended(gfdl.regional)' \
-R "span[ptile=24]" -R "affinity[core(1):distribute=balance]" "$PWD/esg.regional.sh"

#-----------------------------------------------------------------------------
# Regional GSL gravity wave drag.
#-----------------------------------------------------------------------------

bsub -e $LOG_FILE -o $LOG_FILE -q $QUEUE -P $PROJECT_CODE -J reg.gsl.gwd -W 0:08 -x -n 24 -w 'ended(esg.regional)' \
-R "span[ptile=24]" -R "affinity[core(1):distribute=balance]" "$PWD/regional.gsl.gwd.sh"

#-----------------------------------------------------------------------------
# Create summary log.
#-----------------------------------------------------------------------------

bsub -o $LOG_FILE -q $QUEUE -P $PROJECT_CODE -J summary -R "affinity[core(1)]" -R "rusage[mem=100]" -W 0:01 \
-w 'ended(esg.regional)' "grep -a '<<<' $LOG_FILE >> $SUM_FILE"
-w 'ended(reg.gsl.gwd)' "grep -a '<<<' $LOG_FILE >> $SUM_FILE"
9 changes: 8 additions & 1 deletion reg_tests/grid_gen/driver.hera.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,19 @@ TEST2=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:10:00 -A $PROJECT_
TEST3=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:10:00 -A $PROJECT_CODE -q $QUEUE -J esg.regional \
-o $LOG_FILE -e $LOG_FILE -d afterok:$TEST2 ./esg.regional.sh)

#-----------------------------------------------------------------------------
# Regional GSL gravity wave drag test.
#-----------------------------------------------------------------------------

TEST4=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:10:00 -A $PROJECT_CODE -q $QUEUE -J reg.gsl.gwd \
-o $LOG_FILE -e $LOG_FILE -d afterok:$TEST3 ./regional.gsl.gwd.sh)

#-----------------------------------------------------------------------------
# Create summary log.
#-----------------------------------------------------------------------------

sbatch --nodes=1 -t 0:01:00 -A $PROJECT_CODE -J grid_summary -o $LOG_FILE -e $LOG_FILE \
--open-mode=append -q $QUEUE -d afterok:$TEST3 << EOF
--open-mode=append -q $QUEUE -d afterok:$TEST4 << EOF
#!/bin/bash
grep -a '<<<' $LOG_FILE > $SUM_FILE
EOF
9 changes: 8 additions & 1 deletion reg_tests/grid_gen/driver.jet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,19 @@ TEST2=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:10:00 -A $PROJECT_
TEST3=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:10:00 -A $PROJECT_CODE -q $QUEUE -J esg.regional \
--partition=xjet -o $LOG_FILE -e $LOG_FILE -d afterok:$TEST2 ./esg.regional.sh)

#-----------------------------------------------------------------------------
# Regional GSL gravity wave drag.
#-----------------------------------------------------------------------------

TEST4=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:10:00 -A $PROJECT_CODE -q $QUEUE -J reg.gsl.gwd \
--partition=xjet -o $LOG_FILE -e $LOG_FILE -d afterok:$TEST3 ./regional.gsl.gwd.sh)

#-----------------------------------------------------------------------------
# Create summary log.
#-----------------------------------------------------------------------------

sbatch --partition=xjet --nodes=1 -t 0:01:00 -A $PROJECT_CODE -J grid_summary -o $LOG_FILE -e $LOG_FILE \
--open-mode=append -q $QUEUE -d afterok:$TEST3 << EOF
--open-mode=append -q $QUEUE -d afterok:$TEST4 << EOF
#!/bin/bash
grep -a '<<<' $LOG_FILE > $SUM_FILE
EOF
9 changes: 8 additions & 1 deletion reg_tests/grid_gen/driver.orion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,19 @@ TEST2=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:10:00 -A $PROJECT_
TEST3=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:10:00 -A $PROJECT_CODE -q $QUEUE -J esg.regional \
--open-mode=append -o $LOG_FILE -e $LOG_FILE -d afterok:$TEST2 ./esg.regional.sh)

#-----------------------------------------------------------------------------
# Regional grid with GSL gravity wave drag fields.
#-----------------------------------------------------------------------------

TEST4=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:10:00 -A $PROJECT_CODE -q $QUEUE -J reg.gsl.gwd \
--open-mode=append -o $LOG_FILE -e $LOG_FILE -d afterok:$TEST3 ./regional.gsl.gwd.sh)

#-----------------------------------------------------------------------------
# Create summary log.
#-----------------------------------------------------------------------------

sbatch --nodes=1 -t 0:01:00 -A $PROJECT_CODE -J grid_summary -o $LOG_FILE -e $LOG_FILE \
--open-mode=append -q $QUEUE -d afterok:$TEST3 << EOF
--open-mode=append -q $QUEUE -d afterok:$TEST4 << EOF
#!/bin/bash
grep -a '<<<' $LOG_FILE > $SUM_FILE
EOF
69 changes: 69 additions & 0 deletions reg_tests/grid_gen/regional.gsl.gwd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash

#-----------------------------------------------------------------------
# Create a regional esg grid with GSL gravity wave drag files.
# Compare output to a set of baseline files using the 'nccmp' utility.
# This script is run by the machine specific driver script.
#-----------------------------------------------------------------------

set -x

export TEMP_DIR=${WORK_DIR}/regional.gsl.gwd.work
export out_dir=${WORK_DIR}/regional.gsl.gwd

export gtype=regional_esg
export make_gsl_orog=true # Create GSL gravity wave drag fields
export target_lon=-97.5 # Center longitude of the highest resolution tile
export target_lat=35.5 # Center latitude of the highest resolution tile
export idim=301 # Dimension of grid in 'i' direction
export jdim=200 # Dimension of grid in 'j' direction
export delx=0.0585 # Grid spacing in degrees in 'i' direction
export dely=0.0585 # Grid spacing in degrees in 'j' direction
export halo=4

NCCMP=${NCCMP:-$(which nccmp)}

#-----------------------------------------------------------------------
# Start script.
#-----------------------------------------------------------------------

echo "Starting at: " `date`

$home_dir/ush/fv3gfs_driver_grid.sh

iret=$?
if [ $iret -ne 0 ]; then
set +x
echo "<<< REGIONAL GSL GWD TEST FAILED. <<<"
exit $iret
fi

echo "Ending at: " `date`

#-----------------------------------------------------------------------------
# Compare output to baseline set of data.
#-----------------------------------------------------------------------------

cd $out_dir/C772

test_failed=0
for files in *tile*.nc ./fix_sfc/*tile*.nc
do
if [ -f $files ]; then
echo CHECK $files
$NCCMP -dmfqS $files $HOMEreg/regional.gsl.gwd/$files
iret=$?
if [ $iret -ne 0 ]; then
test_failed=1
fi
fi
done

set +x
if [ $test_failed -ne 0 ]; then
echo "<<< REGIONAL GSL GWD TEST FAILED. >>>"
else
echo "<<< REGIONAL GSL GWD TEST PASSED. >>>"
fi

exit 0
1 change: 1 addition & 0 deletions sorc/orog_mask_tools.fd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# George Gayno, Mark Potts

add_subdirectory(orog.fd)
add_subdirectory(orog_gsl.fd)
add_subdirectory(lake.fd)
add_subdirectory(inland.fd)

Expand Down
21 changes: 21 additions & 0 deletions sorc/orog_mask_tools.fd/orog_gsl.fd/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
set(fortran_src
module_gsl_oro_data_lg_scale.f90
module_gsl_oro_data_sm_scale.f90
gsl_oro_data.f90)

if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -r8 -convert big_endian -assume byterecl")
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fdefault-real-8 -fconvert=big-endian -fno-range-check")
if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 10)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch -fallow-invalid-boz")
endif()
endif()

set(exe_name orog_gsl)
add_executable(${exe_name} ${fortran_src})
target_link_libraries(
${exe_name}
NetCDF::NetCDF_Fortran)

install(TARGETS ${exe_name} RUNTIME DESTINATION ${exec_dir})
18 changes: 18 additions & 0 deletions sorc/orog_mask_tools.fd/orog_gsl.fd/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
This code creates orographic statistics fields required for the orographic drag suite developed by NOAA's Global Systems Laboratory (GSL). The fields are a subset of the ones calculated by "orog.fd" except that they are calculated in a different manner. The fields are:
stddev -- standard deviation of subgrid topography
convexity -- convexity of subgrid topography
oa1,oa2,oa3,oa4 -- orographic asymmetry of subgrid topography (for 4 orientations:
1-westerly, 2-southerly, 3-southwesterly, 4-northwesterly)
ol1,ol2,ol3,ol4 -- orographic effective length of subgrid topography (for 4 orientations:
1-westerly, 2-southerly, 3-southwesterly, 4-northwesterly)

Two Cxxx_oro_data files are created:
- an "ls" (large-scale) file for the gravity wave drag and blocking schemes of Kim and Doyle (QJRMS, 2005)
- a "ss" (small-scale) file for the small-scale gravity wave drag scheme of Tsiringakis et al. (QJRMS, 2017) and the turbulent orographic form drag (TOFD) scheme of Beljaars et al. (QJRMS, 2004)

The inputs to be passed to the executable are tile number (1-6 for global, 7 for stand-alone regional) and grid resolution, e.g., 768 for C768.

The source data are the following two files to be located in the "fix" directory:
- geo_em.d01.lat-lon.2.5m.HGT_M.nc -- global topographic data on 2.5-minute lat-lon grid (interpolated from GMTED2010 30-second topographic data)
- HGT.Beljaars_filtered.lat-lon.30s_res.nc -- global topographic data on 30-second lat-lon grid (GMTED2010 data smoothed according to Beljaars et al. (QJRMS, 2004))

86 changes: 86 additions & 0 deletions sorc/orog_mask_tools.fd/orog_gsl.fd/gsl_oro_data.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
!> @file
!! @brief Create orographic (oro_data) files for use by GSL drag suite
!! @author Michael Toy, NOAA/GSL
!! @date 2021-03-12
!!
!! Program GSL_ORO_DATA
!!
!! This program calls subroutines which calculate the parameters
!! required for the GSL subgrid-scale orographic gravity-wave drag (GWDO)
!! suite on the FV3 grid. These parameters are for the small-scale
!! GWD (Tsiringakis et al., 2017) and turbulent orographic form drag (TOFD)
!! (Beljaars et al., 2004) schemes of the GSL drag suite.
!! The output fields are:
!! - stddev standard deviation of subgrid-scale topograpy
!! - convexity convexity (kurtosis) of subgrid-scale topography
!! - ol{1,2,3,4} orographic effective lengths of subgrid-scale topography
!! for 4 orientations: 1-westerly, 2-southerly, 3-southwesterly, 4-northwesterly
!! - oa{1,2,3,4} orographic asymmetries of subgrid-scale topography
!! for 4 orientations: 1-westerly, 2-southerly, 3-southwesterly, 4-northwesterly
!!
!! Note: This program works for both the global FV3GFS cubed
!! sphere, i.e., for tiles 1 through 6, (and 7 if nested
!! grid) (halo.eq.-999 for no halo), and for the stand-alone
!! regional lam (tile 7 and halo.ne.-999)
!! If a halo number is given, this is only to specify the
!! Cxxx_grid.halox data used for input. The oro_data files
!! are always "halo0" output.
!!
!! Based on code by Michael Duda provided by NCAR/MMM

!> Brief description of program: Creates orographic (oro_data) files
!! needed by the GSL drag suite physics parameterization
!!
!! @author Michaei Toy, NOAA/GSL
!! @return 0 for success, error code otherwise.
program gsl_oro_data

use gsl_oro_data_sm_scale, only: calc_gsl_oro_data_sm_scale
use gsl_oro_data_lg_scale, only: calc_gsl_oro_data_lg_scale

implicit none


character(len=2) :: tile_num ! tile number entered by user
character(len=7) :: res_indx ! grid-resolution index, e.g., 96, 192, 384, 768,
! etc. entered by user
character(len=4) :: halo ! halo value entered by user (for input grid data)

logical :: duplicate_oro_data_file ! flag for whether oro_data_ls file is a duplicate
! of oro_data_ss due to minimum grid size being less than 7.5km



! Read in FV3GFS grid info
print *
print *, "Enter tile number:"
read (5,*) tile_num
print *
print *, "Enter grid-resolution index:"
read (5,*) res_indx
print *
print *, "Enter halo number (-999 for no halo):"
read (5,*) halo
print *
print *, "Creating tile oro_data for tile number: ", tile_num
print *, "Grid resolution = ", res_indx
print *, "Halo = ", halo
print *


call calc_gsl_oro_data_sm_scale(tile_num,res_indx,halo,duplicate_oro_data_file)

print *, "duplicate_oro_data_file =", duplicate_oro_data_file
print *

if ( .not.duplicate_oro_data_file ) then
call calc_gsl_oro_data_lg_scale(tile_num,res_indx,halo)
end if


print *
print *, "End program gsl_oro_data"
print *


end program gsl_oro_data
Loading

0 comments on commit 15bab55

Please sign in to comment.