Skip to content

Commit

Permalink
Update grid generation process for coupled grids (#830)
Browse files Browse the repository at this point in the history
- Update the grid generation process to create grids for running the
coupled atm/ocn model.
- New program "ocean_merge" that determines the water mask by merging
the lake mask with the mapped ocean mask from MOM6.
- The orog program was modified to optionally read in an external land mask.
Also, when setting the orography at land/water points, use land fraction 
to determine land/water points instead of land mask.
- Updated link_fixdirs.sh to point to the 202310127 version of the 'orog' directory.

Fixes #825
  • Loading branch information
sanatcumar committed Dec 12, 2023
1 parent 340d87c commit a757eb0
Show file tree
Hide file tree
Showing 27 changed files with 3,507 additions and 139 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ option(FVCOMTOOLS "Enable building fvcom_tools.fd" ON)
option(GBLEVENTS "Enable building gblevents.fd" ON)
option(CPLD_GRIDGEN "Enable building cpld_gridgen.fd" ON)
option(WEIGHT_GEN "Enable building weight_gen.fd" ON)
option(OCEAN_MERGE "Enable building ocean_merge.fd" ON)

# Option to build application specific utilities
option(GFS "Enable building GFS-only utilities" OFF)
Expand All @@ -46,6 +47,7 @@ if(GFS)
set(GBLEVENTS OFF CACHE BOOL "Disable building gblevents.fd" FORCE)
set(CPLD_GRIDGEN OFF CACHE BOOL "Disable building cpld_gridgen.fd" FORCE)
set(WEIGHT_GEN OFF CACHE BOOL "Disable building weight_gen.fd" FORCE)
set(OCEAN_MERGE OFF CACHE BOOL "Disable building ocean_merge.fd" FORCE)
endif()

SET(TEST_FILE_DIR "." CACHE STRING "Check this directory for test files before using FTP.")
Expand Down
2 changes: 1 addition & 1 deletion cmake/mpiexec.hera
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# $2+ - Executable and its arguments
#

ACCOUNT=gsd-fv3
ACCOUNT=fv3-cpu
QOS=debug

NP=$1
Expand Down
20 changes: 12 additions & 8 deletions docs/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ https://github.com/ufs-community/UFS_UTILS.
- <a href="chgres_cube/index.html">chgres_cube</a> - Creates cold
start initial conditions for FV3 model runs.

- <a href="cpld_gridgen/index.html">cpld_gridgen</a> - Utility to
create the Fix and IC files for the S2SW and S2S applications

- <a href="emcsfc_ice_blend/index.html">emcsfc_ice_blend</a> - Blends
National Ice Center sea ice cover and EMC sea ice concentration data
to create a global sea ice analysis used to update the GFS once per
Expand Down Expand Up @@ -57,6 +60,15 @@ https://github.com/ufs-community/UFS_UTILS.
gnomonic grids, and to compute the equivalent global resolution of a
regional grid.

- <a href="lsm_routines/index.html">lsm_routines</a> - Land surface
model-specific routines that are utilised elsewhere within UFS_UTILS.
Currently, contains the routines required by global_cycle to
perform data assimilation updates to land model states

- <a href="ocean_merge/index.html">ocean_merge</a> - Utility to
determine the water mask by merging a lake mask with a mapped
ocean mask from MOM6.

- <a href="orog_mask_tools/index.html">orog_mask_tools</a> - Utilities
to create land mask, terrain and gravity wave drag fields; set lake
fraction and depth; creates an inland land mask.
Expand All @@ -70,14 +82,6 @@ https://github.com/ufs-community/UFS_UTILS.
top and the number of vertical levels. Outputs the 'ak' and 'bk'
parameters used by the forecast model to define the hybrid levels.

- <a href="lsm_routines/index.html">lsm_routines</a> - Land surface
model-specific routines that are utilised elsewhere within UFS_UTILS.
Currently, contains the routines required by global_cycle to
perform data assimilation updates to land model states

- <a href="cpld_gridgen/index.html">cpld_gridgen</a> - Utility to
create the Fix and IC files for the S2SW and S2S applications

- <a href="weight_gen/index.html">weight_gen</a> - Utility to
create gaussian grid ESMF 'scrip' files for use in creating
ESMF interpolation weight files.
10 changes: 6 additions & 4 deletions driver_scripts/driver_grid.hera.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#SBATCH --open-mode=truncate
#SBATCH -o log.fv3_grid_driver
#SBATCH -e log.fv3_grid_driver
#SBATCH --nodes=1 --ntasks-per-node=24
#SBATCH --nodes=6 --ntasks-per-node=12
#SBATCH --partition=bigmem
#SBATCH -q debug
#SBATCH -t 00:20:00
#SBATCH -t 00:30:00

#-----------------------------------------------------------------------
# Driver script to create a cubic-sphere based model grid on Hera.
Expand Down Expand Up @@ -103,7 +103,7 @@ export soil_type_src="bnu.v3.30s" # Soil type data.
# 3) "statsgo.conus.30s" for CONUS 30s data
# 4) "statsgo.nh.30s" for NH 30s data
# 5) "statsgo.30s" for global 30s data
# For Beijing Norm. Univ. data
# For Beijing Norm. Univ. data
# 1) "bnu.v3.30s" for global 30s data.

# choose dataset sources for lakefrac & lakedepth so that lake_data_srce=LakeFrac_LakeDepth;
Expand All @@ -115,6 +115,7 @@ if [ $gtype = uniform ]; then
export add_lake=true # Add lake frac and depth to orography data.
export lake_cutoff=0.50 # return 0 if lake_frac < lake_cutoff & add_lake=T
export binary_lake=1 # return 1 if lake_frac >= lake_cutoff & add_lake=T
export ocn=${ocn:-"025"} # use one of "025", "050", "100", "500". Cannot be empty
elif [ $gtype = stretch ]; then
export res=96
export stretch_fac=1.5 # Stretching factor for the grid
Expand Down Expand Up @@ -150,14 +151,15 @@ fi

#-----------------------------------------------------------------------
# Check paths.
#
# home_dir - location of repository.
# TEMP_DIR - working directory.
# out_dir - where files will be placed upon completion.
#-----------------------------------------------------------------------

export home_dir=$SLURM_SUBMIT_DIR/..
export TEMP_DIR=/scratch2/NCEPDEV/stmp1/$LOGNAME/fv3_grid.$gtype
export out_dir=/scratch2/NCEPDEV/stmp1/$LOGNAME/my_grids
export out_dir=/scratch2/NCEPDEV/stmp1/$LOGNAME/my_grids_ocean_fixed/

#-----------------------------------------------------------------------
# Should not need to change anything below here.
Expand Down
2 changes: 1 addition & 1 deletion driver_scripts/driver_grid.jet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ if [ $gtype = uniform ]; then
export add_lake=true # Add lake frac and depth to orography data.
export lake_cutoff=0.50 # return 0 if lake_frac < lake_cutoff & add_lake=T
export binary_lake=1 # return 1 if lake_frac >= lake_cutoff & add_lake=T
export ocn=${ocn:-"025"} # use one of "025", "050", "100", "500". Cannot be empty
elif [ $gtype = stretch ]; then
export res=96
export stretch_fac=1.5 # Stretching factor for the grid
Expand Down Expand Up @@ -156,7 +157,6 @@ fi
export home_dir=$SLURM_SUBMIT_DIR/..
export TEMP_DIR=/lfs4/HFIP/emcda/$LOGNAME/stmp/fv3_grid.$gtype
export out_dir=/lfs4/HFIP/emcda/$LOGNAME/stmp/my_grids

#-----------------------------------------------------------------------
# Should not need to change anything below here.
#-----------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions driver_scripts/driver_grid.orion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ if [ $gtype = uniform ]; then
export add_lake=true # Add lake frac and depth to orography data.
export lake_cutoff=0.50 # return 0 if lake_frac < lake_cutoff & add_lake=T
export binary_lake=1 # return 1 if lake_frac >= lake_cutoff & add_lake=T
export ocn=${ocn:-"025"} # use one of "025", "050", "100", "500". Cannot be empty
elif [ $gtype = stretch ]; then
export res=96
export stretch_fac=1.5 # Stretching factor for the grid
Expand Down
2 changes: 1 addition & 1 deletion driver_scripts/driver_grid.wcoss2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ if [ $gtype = uniform ]; then
export add_lake=true # Add lake frac and depth to orography data.
export lake_cutoff=0.50 # return 0 if lake_frac < lake_cutoff & add_lake=T
export binary_lake=1 # return 1 if lake_frac >= lake_cutoff & add_lake=T
export ocn=${ocn:-"025"} # use one of "025", "050", "100", "500". Cannot be empty
elif [ $gtype = stretch ]; then
export res=96
export stretch_fac=1.5 # Stretching factor for the grid
Expand Down Expand Up @@ -154,7 +155,6 @@ fi
export home_dir=$PBS_O_WORKDIR/..
export TEMP_DIR=/lfs/h2/emc/stmp/$LOGNAME/fv3_grid.$gtype
export out_dir=/lfs/h2/emc/stmp/$LOGNAME/my_grids

#-----------------------------------------------------------------------
# Should not need to change anything below here unless you want to
# to change the job card for the number of tasks to use. Then,
Expand Down
2 changes: 1 addition & 1 deletion fix/link_fixdirs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ elif [ $machine = "s4" ]; then
fi

am_ver=${am_ver:-20220805}
orog_ver=${orog_ver:-20220805}
orog_ver=${orog_ver:-20231027}
sfc_climo_ver=${sfc_climo_ver:-20230925}

for dir in am orog orog_raw sfc_climo; do
Expand Down
2 changes: 1 addition & 1 deletion reg_tests/grid_gen/c96.uniform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ echo "Ending at: " `date`
cd $out_dir/C96

test_failed=0
for files in *tile*.nc ./fix_sfc/*tile*.nc
for files in *tile*.nc ./sfc/*tile*.nc
do
if [ -f $files ]; then
echo CHECK $files
Expand Down
2 changes: 1 addition & 1 deletion reg_tests/grid_gen/c96.viirs.bnu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ echo "Ending at: " `date`
cd $out_dir/C96

test_failed=0
for files in *tile*.nc ./fix_sfc/*tile*.nc
for files in *tile*.nc ./sfc/*tile*.nc
do
if [ -f $files ]; then
echo CHECK $files
Expand Down
2 changes: 1 addition & 1 deletion reg_tests/grid_gen/esg.regional.pct.cat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ echo "Ending at: " `date`
cd $out_dir/C3113

test_failed=0
for files in *tile*.nc ./fix_sfc/*tile*.nc
for files in *tile*.nc ./sfc/*tile*.nc
do
if [ -f $files ]; then
echo CHECK $files
Expand Down
2 changes: 1 addition & 1 deletion reg_tests/grid_gen/esg.regional.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ echo "Ending at: " `date`
cd $out_dir/C3113

test_failed=0
for files in *tile*.nc ./fix_sfc/*tile*.nc
for files in *tile*.nc ./sfc/*tile*.nc
do
if [ -f $files ]; then
echo CHECK $files
Expand Down
2 changes: 1 addition & 1 deletion reg_tests/grid_gen/gfdl.regional.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ echo "Ending at: " `date`
cd $out_dir/C424

test_failed=0
for files in *tile*.nc ./fix_sfc/*tile*.nc
for files in *tile*.nc ./sfc/*tile*.nc
do
if [ -f $files ]; then
echo CHECK $files
Expand Down
2 changes: 1 addition & 1 deletion reg_tests/grid_gen/regional.gsl.gwd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ echo "Ending at: " `date`
cd $out_dir/C772

test_failed=0
for files in *tile*.nc ./fix_sfc/*tile*.nc
for files in *tile*.nc ./sfc/*tile*.nc
do
if [ -f $files ]; then
echo CHECK $files
Expand Down
4 changes: 4 additions & 0 deletions sorc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@ endif()
if(WEIGHT_GEN)
add_subdirectory(weight_gen.fd)
endif()
if(OCEAN_MERGE)
add_subdirectory(ocean_merge.fd)
endif()

26 changes: 26 additions & 0 deletions sorc/ocean_merge.fd/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
list(APPEND fortran_src
merge_lake_ocnmsk.f90
)

if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -r8 -i4 -convert big_endian")
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fdefault-real-8")
if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 10)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch")
endif()
endif()

set(exe_name ocean_merge)
add_executable(${exe_name} ${fortran_src})
target_link_libraries(
${exe_name}

NetCDF::NetCDF_Fortran)

install(TARGETS ${exe_name})

# If doxygen documentation we enabled, build it.
if(ENABLE_DOCS)
add_subdirectory(docs)
endif()
15 changes: 15 additions & 0 deletions sorc/ocean_merge.fd/docs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This is the CMake file for building this docs directory.
#
# Ed Hartnett 3/9/21

# Create doxyfile.
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)

# Build documentation with target all.
add_custom_target(ocean_merge_doc ALL
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API Documentation with Doxygen" VERBATIM)

# Ensure top-level docs have been generated.
add_dependencies(ocean_merge_doc doc)
Loading

0 comments on commit a757eb0

Please sign in to comment.