Skip to content

Commit

Permalink
sfc_climo_gen - Output fractions of each vegetation/soil type category (
Browse files Browse the repository at this point in the history
#748)

The sfc_climo_gen program was updated to optionally output the fraction
of each vegetation and soil type category at a model point.  The dominant
category is also output. The default is to output just the dominant category.

Unit and consistency tests were added to test this new capability.

The 'readthedocs' was also updated.

Fixes #709.
  • Loading branch information
GeorgeGayno-NOAA authored Apr 6, 2023
1 parent 7efbe0f commit 4f613fe
Show file tree
Hide file tree
Showing 23 changed files with 1,000 additions and 70 deletions.
4 changes: 4 additions & 0 deletions docs/source/ufs_utils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,13 @@ Location of the source code: ./sorc/sfc_climo_gen.fd. Brief description of each

* driver.F90 - The main driver routine.
* interp.F90 - The interpolation driver routine. Reads the input source data and interpolates it to the model grid.
* interp_frac_cats.F90 - Same as interp.F90, but for computing the fraction of each soil and vegetation type category. (When namelist variable 'vegsoilt_frac' is true).
* model_grid.F90 - Defines the ESMF grid object for the model grid.
* output.f90 - Writes the output surface data to a NetCDF file. For regional grids, will output separate files with and without the halo.
* output_frac_cats.f90 - Same as output.f90, but for writing fractional soil and vegetation type. (When namelist variable 'vegsoilt_frac' is true).
* program_setup.f90 - Reads the namelist and sets up program execution.
* search.f90 - Replace undefined values on the model grid with a valid value at a nearby neighbor. Undefined values are typically associated with isolated islands where there is no source data.
* search_frac_cats.f90 - Same as search.f90, but for the fractional soil and vegetation type option. (When namelist variable 'vegsoilt_frac' is true).
* source_grid.F90 - Reads the grid specifications and land/sea mask for the source data. Sets up the ESMF grid object for the source grid.
* utils.f90 - Contains error handling utility routines.

Expand All @@ -512,6 +515,7 @@ Program execution is controlled via a namelist. The namelist variables are:
* maximum_snow_albedo_method - interpolation method for this field. Bilinear or conservative. Default is bilinear.
* snowfree_albedo_method - interpolation method for this field. Bilinear or conservative. Default is bilinear.
* vegetation_greenness_method - interpolation method for this field. Bilinear or conservative. Default is bilinear.
* vegsoilt_frac - When 'true', outputs the dominate soil and vegetation type, and the fraction of each category. When 'false', only outputs the dominate categories. Default is 'false'.

Program inputs and outputs
--------------------------
Expand Down
15 changes: 12 additions & 3 deletions driver_scripts/driver_grid.hera.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
#SBATCH -o log.fv3_grid_driver
#SBATCH -e log.fv3_grid_driver
#SBATCH --nodes=1 --ntasks-per-node=24
##SBATCH --partition=bigmem
#SBATCH -q debug
#SBATCH -t 00:30:00
#SBATCH -t 00:20:00

#-----------------------------------------------------------------------
# Driver script to create a cubic-sphere based model grid on Hera.
Expand All @@ -23,8 +24,9 @@
# Note: The sfc_climo_gen program only runs with an
# mpi task count that is a multiple of six. This is
# an ESMF library requirement. Large grids may require
# tasks spread across multiple nodes. The orography code
# benefits from threads.
# tasks spread across multiple nodes or to be run on
# 'bigmem' nodes (#SBATCH --partition=bigmem). The
# orography code benefits from threads.
#
# To run, do the following:
#
Expand Down Expand Up @@ -74,9 +76,16 @@ module list

export gtype=uniform # 'uniform', 'stretch', 'nest',
# 'regional_gfdl', 'regional_esg'.

export make_gsl_orog=false # When 'true' will output 'oro' files for
# the GSL orographic drag suite.

export vegsoilt_frac='.false.' # When .false., output dominant soil and
# vegetation type category. When .true.,
# output fraction of each category and
# the dominant category. A Fortran logical,
# so include the dots.

export veg_type_src="modis.igbp.0.05" # Vegetation type data.
# For viirs-based vegetation type data, set to:
# 1) "viirs.igbp.0.1" for global 0.10-deg data
Expand Down
6 changes: 6 additions & 0 deletions driver_scripts/driver_grid.jet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ export gtype=uniform # 'uniform', 'stretch', 'nest',
export make_gsl_orog=false # When 'true' will output 'oro' files for
# the GSL orographic drag suite.

export vegsoilt_frac='.false.' # When true, outputs percent of each
# soil and veg type category and a
# dominant category. When false, only
# outputs the dominant category. A
# Fortran logical, so include the dots.

export veg_type_src="modis.igbp.0.05" # Vegetation type data.
# For viirs-based vegetation type data, set to:
# 1) "viirs.igbp.0.1" for global 0.10-deg data
Expand Down
6 changes: 6 additions & 0 deletions driver_scripts/driver_grid.orion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ export gtype=regional_esg # 'uniform', 'stretch', 'nest',
export make_gsl_orog=false # When 'true' will output 'oro' files for
# the GSL orographic drag suite.

export vegsoilt_frac='.false.' # When true, outputs percent of each
# soil and veg type category and a
# dominant category. When false, only
# outputs the dominant category. A
# Fortran logical, so include the dots.

export veg_type_src="modis.igbp.0.05" # Vegetation type data.
# For viirs-based vegetation type data, set to:
# 1) "viirs.igbp.0.1" for global 0.10-deg data
Expand Down
6 changes: 6 additions & 0 deletions driver_scripts/driver_grid.wcoss2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ export gtype=regional_esg # 'uniform', 'stretch', 'nest',
export make_gsl_orog=false # When 'true' will output 'oro' files for
# the GSL orographic drag suite.

export vegsoilt_frac='.false.' # When true, outputs percent of each
# soil and veg type category and a
# dominant category. When false, only
# outputs the dominant category. A
# Fortran logical, so include the dots.

export veg_type_src="modis.igbp.0.05" # Vegetation type data.
# For viirs-based vegetation type data, set to:
# 1) "viirs.igbp.0.1" for global 0.10-deg data
Expand Down
19 changes: 14 additions & 5 deletions reg_tests/grid_gen/driver.hera.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,27 +86,36 @@ TEST3=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:07:00 -A $PROJECT_
-o $LOG_FILE3 -e $LOG_FILE3 ./gfdl.regional.sh)

#-----------------------------------------------------------------------------
# esg regional grid
# ESG regional grid (output dominant soil/vegetation type).
#-----------------------------------------------------------------------------

LOG_FILE4=${LOG_FILE}04
TEST4=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:07:00 -A $PROJECT_CODE -q $QUEUE -J esg.regional \
-o $LOG_FILE4 -e $LOG_FILE4 ./esg.regional.sh)

#-----------------------------------------------------------------------------
# Regional GSL gravity wave drag test.
# ESG regional grid (output percent of each soil and vegetation type and
# the dominant category).
#-----------------------------------------------------------------------------

LOG_FILE5=${LOG_FILE}05
TEST5=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:07:00 -A $PROJECT_CODE -q $QUEUE -J reg.gsl.gwd \
-o $LOG_FILE5 -e $LOG_FILE5 ./regional.gsl.gwd.sh)
TEST5=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:07:00 -A $PROJECT_CODE -q $QUEUE -J esg.regional.pct.cat \
-o $LOG_FILE5 -e $LOG_FILE5 ./esg.regional.pct.cat.sh)

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

LOG_FILE6=${LOG_FILE}06
TEST6=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:07:00 -A $PROJECT_CODE -q $QUEUE -J reg.gsl.gwd \
-o $LOG_FILE6 -e $LOG_FILE6 ./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:$TEST1:$TEST2:$TEST3:$TEST4:$TEST5 << EOF
--open-mode=append -q $QUEUE -d afterok:$TEST1:$TEST2:$TEST3:$TEST4:$TEST5:$TEST6 << EOF
#!/bin/bash
grep -a '<<<' ${LOG_FILE}* > $SUM_FILE
EOF
19 changes: 14 additions & 5 deletions reg_tests/grid_gen/driver.jet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,27 +84,36 @@ TEST3=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:07:00 -A $PROJECT_
--partition=xjet -o $LOG_FILE3 -e $LOG_FILE3 ./gfdl.regional.sh)

#-----------------------------------------------------------------------------
# ESG regional grid
# ESG regional grid (output dominant soil/vegetation type).
#-----------------------------------------------------------------------------

LOG_FILE4=${LOG_FILE}04
TEST4=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:07:00 -A $PROJECT_CODE -q $QUEUE -J esg.regional \
--partition=xjet -o $LOG_FILE4 -e $LOG_FILE4 ./esg.regional.sh)

#-----------------------------------------------------------------------------
# Regional GSL gravity wave drag.
# ESG regional grid (output percent of each soil and vegetation type and
# the dominant category).
#-----------------------------------------------------------------------------

LOG_FILE5=${LOG_FILE}05
TEST5=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:07:00 -A $PROJECT_CODE -q $QUEUE -J reg.gsl.gwd \
--partition=xjet -o $LOG_FILE5 -e $LOG_FILE5 ./regional.gsl.gwd.sh)
TEST5=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:07:00 -A $PROJECT_CODE -q $QUEUE -J esg.regional.pct.cat \
--partition=xjet -o $LOG_FILE5 -e $LOG_FILE5 ./esg.regional.pct.cat.sh)

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

LOG_FILE6=${LOG_FILE}06
TEST6=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:07:00 -A $PROJECT_CODE -q $QUEUE -J reg.gsl.gwd \
--partition=xjet -o $LOG_FILE6 -e $LOG_FILE6 ./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 \
-q $QUEUE -d afterok:$TEST1:$TEST2:$TEST3:$TEST4:$TEST5 << EOF
-q $QUEUE -d afterok:$TEST1:$TEST2:$TEST3:$TEST4:$TEST5:$TEST6 << EOF
#!/bin/bash
grep -a '<<<' ${LOG_FILE}* > $SUM_FILE
EOF
19 changes: 14 additions & 5 deletions reg_tests/grid_gen/driver.orion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,27 +82,36 @@ TEST3=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:10:00 -A $PROJECT_
-o $LOG_FILE3 -e $LOG_FILE3 ./gfdl.regional.sh)

#-----------------------------------------------------------------------------
# ESG regional grid
# ESG regional grid (output dominant soil/vegetation type).
#-----------------------------------------------------------------------------

LOG_FILE4=${LOG_FILE}04
TEST4=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:10:00 -A $PROJECT_CODE -q $QUEUE -J esg.regional \
-o $LOG_FILE4 -e $LOG_FILE4 ./esg.regional.sh)

#-----------------------------------------------------------------------------
# Regional grid with GSL gravity wave drag fields.
# ESG regional grid (output percent of each soil and vegetation type and
# the dominant category).
#-----------------------------------------------------------------------------

LOG_FILE5=${LOG_FILE}05
TEST5=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:10:00 -A $PROJECT_CODE -q $QUEUE -J reg.gsl.gwd \
-o $LOG_FILE5 -e $LOG_FILE5 ./regional.gsl.gwd.sh)
TEST5=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:10:00 -A $PROJECT_CODE -q $QUEUE -J esg.regional.pct.cat \
-o $LOG_FILE5 -e $LOG_FILE5 ./esg.regional.pct.cat.sh)

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

LOG_FILE6=${LOG_FILE}06
TEST6=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:10:00 -A $PROJECT_CODE -q $QUEUE -J reg.gsl.gwd \
-o $LOG_FILE6 -e $LOG_FILE6 ./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 \
-q $QUEUE -d afterok:$TEST1:$TEST2:$TEST3:$TEST4:$TEST5 << EOF
-q $QUEUE -d afterok:$TEST1:$TEST2:$TEST3:$TEST4:$TEST5:$TEST6 << EOF
#!/bin/bash
grep -a '<<<' ${LOG_FILE}* > $SUM_FILE
EOF
15 changes: 12 additions & 3 deletions reg_tests/grid_gen/driver.wcoss2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,27 +87,36 @@ TEST3=$(qsub -V -o $LOG_FILE3 -e $LOG_FILE3 -q $QUEUE -A $PROJECT_CODE -l wallti
-N gfdl.regional -l select=1:ncpus=30:mem=40GB $PWD/gfdl.regional.sh)

#-----------------------------------------------------------------------------
# esg regional grid
# ESG regional grid (output dominant soil/vegetation type).
#-----------------------------------------------------------------------------

LOG_FILE4=${LOG_FILE}04
TEST4=$(qsub -V -o $LOG_FILE4 -e $LOG_FILE4 -q $QUEUE -A $PROJECT_CODE -l walltime=00:07:00 \
-N esg.regional -l select=1:ncpus=30:mem=40GB $PWD/esg.regional.sh)

#-----------------------------------------------------------------------------
# Regional GSL gravity wave drag test.
# ESG regional grid (output percent of each soil and vegetation type and
# the dominant category).
#-----------------------------------------------------------------------------

LOG_FILE5=${LOG_FILE}05
TEST5=$(qsub -V -o $LOG_FILE5 -e $LOG_FILE5 -q $QUEUE -A $PROJECT_CODE -l walltime=00:07:00 \
-N esg.regional.pct.cat -l select=1:ncpus=30:mem=40GB $PWD/esg.regional.pct.cat.sh)

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

LOG_FILE6=${LOG_FILE}06
TEST6=$(qsub -V -o $LOG_FILE6 -e $LOG_FILE6 -q $QUEUE -A $PROJECT_CODE -l walltime=00:07:00 \
-N rsg.gsl.gwd -l select=1:ncpus=30:mem=40GB $PWD/regional.gsl.gwd.sh)

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

qsub -V -o ${LOG_FILE} -e ${LOG_FILE} -q $QUEUE -A $PROJECT_CODE -l walltime=00:02:00 \
-N grid_summary -l select=1:ncpus=1:mem=100MB -W depend=afterok:$TEST1:$TEST2:$TEST3:$TEST4:$TEST5 << EOF
-N grid_summary -l select=1:ncpus=1:mem=100MB -W depend=afterok:$TEST1:$TEST2:$TEST3:$TEST4:$TEST5:$TEST6 << EOF
#!/bin/bash
cd ${this_dir}
grep -a '<<<' ${LOG_FILE}* | grep -v echo > $SUM_FILE
Expand Down
75 changes: 75 additions & 0 deletions reg_tests/grid_gen/esg.regional.pct.cat.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/bash

#-----------------------------------------------------------------------
# Create a regional esg grid. Output dominant soil and vegetation
# categories and well as the percentage of each category.
# Compare output to a set of baseline files using the 'nccmp'
# utility. This script is run by the machine specific driver script.
#-----------------------------------------------------------------------

set -x

TEST_NAME="esg.regional.pct.cat"
export TEMP_DIR=${WORK_DIR}/${TEST_NAME}.work
export out_dir=${WORK_DIR}/${TEST_NAME}

export gtype=regional_esg
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=1301 # Dimension of grid in 'i' direction
export jdim=600 # Dimension of grid in 'j' direction
export delx=0.0145 # Grid spacing in degrees in 'i' direction
export dely=0.0145 # Grid spacing in degrees in 'j' direction
export halo=3
export vegsoilt_frac=.true. # Output dominant soil/veg categories as well
# as the percentage of each category.

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 "<<< ESG REGIONAL PERCENT CATEGORY TEST FAILED. <<<"
exit $iret
fi

echo "Ending at: " `date`

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

cd $out_dir/C3113

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

set +x
if [ $test_failed -ne 0 ]; then
echo "<<< ESG REGIONAL PERCENT CATEGORY TEST FAILED. >>>"
if [ "$UPDATE_BASELINE" = "TRUE" ]; then
$home_dir/reg_tests/update_baseline.sh "${HOMEreg}/.." "${TEST_NAME}" $commit_num
fi
else
echo "<<< ESG REGIONAL PERCENT CATEGORY TEST PASSED. >>>"
fi

exit 0
3 changes: 3 additions & 0 deletions sorc/sfc_climo_gen.fd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@

set(lib_src
interp.F90
interp_frac_cats.F90
model_grid.F90
output.f90
output_frac_cats.F90
program_setup.f90
search.f90
search_frac_cats.f90
source_grid.F90
utils.f90)

Expand Down
20 changes: 16 additions & 4 deletions sorc/sfc_climo_gen.fd/driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,14 @@ program driver
!-------------------------------------------------------------------------

call define_source_grid(localpet, npets, input_vegetation_type_file)
method=ESMF_REGRIDMETHOD_NEAREST_STOD
call interp(localpet, method, input_vegetation_type_file)
if (fract_vegsoil_type) then
print*,'- WILL OUTPUT VEGETATION TYPE FRACTION AND DOMINANT CATEGORY.'
call interp_frac_cats(localpet, input_vegetation_type_file)
else
print*,'- WILL OUTPUT DOMINANT VEGETATION TYPE.'
method=ESMF_REGRIDMETHOD_NEAREST_STOD
call interp(localpet, method, input_vegetation_type_file)
endif
call source_grid_cleanup

! Snow free albedo
Expand Down Expand Up @@ -136,8 +142,14 @@ program driver

if (trim(input_soil_type_file) /= "NULL") then
call define_source_grid(localpet, npets, input_soil_type_file)
method=ESMF_REGRIDMETHOD_NEAREST_STOD
call interp(localpet, method, input_soil_type_file)
if (fract_vegsoil_type) then
print*,'- WILL OUTPUT SOIL TYPE FRACTION AND DOMINANT CATEGORY.'
call interp_frac_cats(localpet, input_soil_type_file)
else
print*,'- WILL OUTPUT DOMINANT SOIL TYPE.'
method=ESMF_REGRIDMETHOD_NEAREST_STOD
call interp(localpet, method, input_soil_type_file)
endif
call source_grid_cleanup
endif

Expand Down
Loading

0 comments on commit 4f613fe

Please sign in to comment.