Skip to content

Commit 4f613fe

Browse files
sfc_climo_gen - Output fractions of each vegetation/soil type category (#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.
1 parent 7efbe0f commit 4f613fe

23 files changed

+1000
-70
lines changed

docs/source/ufs_utils.rst

+4
Original file line numberDiff line numberDiff line change
@@ -484,10 +484,13 @@ Location of the source code: ./sorc/sfc_climo_gen.fd. Brief description of each
484484

485485
* driver.F90 - The main driver routine.
486486
* interp.F90 - The interpolation driver routine. Reads the input source data and interpolates it to the model grid.
487+
* 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).
487488
* model_grid.F90 - Defines the ESMF grid object for the model grid.
488489
* output.f90 - Writes the output surface data to a NetCDF file. For regional grids, will output separate files with and without the halo.
490+
* output_frac_cats.f90 - Same as output.f90, but for writing fractional soil and vegetation type. (When namelist variable 'vegsoilt_frac' is true).
489491
* program_setup.f90 - Reads the namelist and sets up program execution.
490492
* 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.
493+
* search_frac_cats.f90 - Same as search.f90, but for the fractional soil and vegetation type option. (When namelist variable 'vegsoilt_frac' is true).
491494
* 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.
492495
* utils.f90 - Contains error handling utility routines.
493496

@@ -512,6 +515,7 @@ Program execution is controlled via a namelist. The namelist variables are:
512515
* maximum_snow_albedo_method - interpolation method for this field. Bilinear or conservative. Default is bilinear.
513516
* snowfree_albedo_method - interpolation method for this field. Bilinear or conservative. Default is bilinear.
514517
* vegetation_greenness_method - interpolation method for this field. Bilinear or conservative. Default is bilinear.
518+
* 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'.
515519

516520
Program inputs and outputs
517521
--------------------------

driver_scripts/driver_grid.hera.sh

+12-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
#SBATCH -o log.fv3_grid_driver
77
#SBATCH -e log.fv3_grid_driver
88
#SBATCH --nodes=1 --ntasks-per-node=24
9+
##SBATCH --partition=bigmem
910
#SBATCH -q debug
10-
#SBATCH -t 00:30:00
11+
#SBATCH -t 00:20:00
1112

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

7577
export gtype=uniform # 'uniform', 'stretch', 'nest',
7678
# 'regional_gfdl', 'regional_esg'.
79+
7780
export make_gsl_orog=false # When 'true' will output 'oro' files for
7881
# the GSL orographic drag suite.
7982

83+
export vegsoilt_frac='.false.' # When .false., output dominant soil and
84+
# vegetation type category. When .true.,
85+
# output fraction of each category and
86+
# the dominant category. A Fortran logical,
87+
# so include the dots.
88+
8089
export veg_type_src="modis.igbp.0.05" # Vegetation type data.
8190
# For viirs-based vegetation type data, set to:
8291
# 1) "viirs.igbp.0.1" for global 0.10-deg data

driver_scripts/driver_grid.jet.sh

+6
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ export gtype=uniform # 'uniform', 'stretch', 'nest',
7878
export make_gsl_orog=false # When 'true' will output 'oro' files for
7979
# the GSL orographic drag suite.
8080

81+
export vegsoilt_frac='.false.' # When true, outputs percent of each
82+
# soil and veg type category and a
83+
# dominant category. When false, only
84+
# outputs the dominant category. A
85+
# Fortran logical, so include the dots.
86+
8187
export veg_type_src="modis.igbp.0.05" # Vegetation type data.
8288
# For viirs-based vegetation type data, set to:
8389
# 1) "viirs.igbp.0.1" for global 0.10-deg data

driver_scripts/driver_grid.orion.sh

+6
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ export gtype=regional_esg # 'uniform', 'stretch', 'nest',
7777
export make_gsl_orog=false # When 'true' will output 'oro' files for
7878
# the GSL orographic drag suite.
7979

80+
export vegsoilt_frac='.false.' # When true, outputs percent of each
81+
# soil and veg type category and a
82+
# dominant category. When false, only
83+
# outputs the dominant category. A
84+
# Fortran logical, so include the dots.
85+
8086
export veg_type_src="modis.igbp.0.05" # Vegetation type data.
8187
# For viirs-based vegetation type data, set to:
8288
# 1) "viirs.igbp.0.1" for global 0.10-deg data

driver_scripts/driver_grid.wcoss2.sh

+6
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ export gtype=regional_esg # 'uniform', 'stretch', 'nest',
7676
export make_gsl_orog=false # When 'true' will output 'oro' files for
7777
# the GSL orographic drag suite.
7878

79+
export vegsoilt_frac='.false.' # When true, outputs percent of each
80+
# soil and veg type category and a
81+
# dominant category. When false, only
82+
# outputs the dominant category. A
83+
# Fortran logical, so include the dots.
84+
7985
export veg_type_src="modis.igbp.0.05" # Vegetation type data.
8086
# For viirs-based vegetation type data, set to:
8187
# 1) "viirs.igbp.0.1" for global 0.10-deg data

reg_tests/grid_gen/driver.hera.sh

+14-5
Original file line numberDiff line numberDiff line change
@@ -86,27 +86,36 @@ TEST3=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:07:00 -A $PROJECT_
8686
-o $LOG_FILE3 -e $LOG_FILE3 ./gfdl.regional.sh)
8787

8888
#-----------------------------------------------------------------------------
89-
# esg regional grid
89+
# ESG regional grid (output dominant soil/vegetation type).
9090
#-----------------------------------------------------------------------------
9191

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

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

100101
LOG_FILE5=${LOG_FILE}05
101-
TEST5=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:07:00 -A $PROJECT_CODE -q $QUEUE -J reg.gsl.gwd \
102-
-o $LOG_FILE5 -e $LOG_FILE5 ./regional.gsl.gwd.sh)
102+
TEST5=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:07:00 -A $PROJECT_CODE -q $QUEUE -J esg.regional.pct.cat \
103+
-o $LOG_FILE5 -e $LOG_FILE5 ./esg.regional.pct.cat.sh)
104+
105+
#-----------------------------------------------------------------------------
106+
# Regional GSL gravity wave drag test.
107+
#-----------------------------------------------------------------------------
108+
109+
LOG_FILE6=${LOG_FILE}06
110+
TEST6=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:07:00 -A $PROJECT_CODE -q $QUEUE -J reg.gsl.gwd \
111+
-o $LOG_FILE6 -e $LOG_FILE6 ./regional.gsl.gwd.sh)
103112

104113
#-----------------------------------------------------------------------------
105114
# Create summary log.
106115
#-----------------------------------------------------------------------------
107116

108117
sbatch --nodes=1 -t 0:01:00 -A $PROJECT_CODE -J grid_summary -o $LOG_FILE -e $LOG_FILE \
109-
--open-mode=append -q $QUEUE -d afterok:$TEST1:$TEST2:$TEST3:$TEST4:$TEST5 << EOF
118+
--open-mode=append -q $QUEUE -d afterok:$TEST1:$TEST2:$TEST3:$TEST4:$TEST5:$TEST6 << EOF
110119
#!/bin/bash
111120
grep -a '<<<' ${LOG_FILE}* > $SUM_FILE
112121
EOF

reg_tests/grid_gen/driver.jet.sh

+14-5
Original file line numberDiff line numberDiff line change
@@ -84,27 +84,36 @@ TEST3=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:07:00 -A $PROJECT_
8484
--partition=xjet -o $LOG_FILE3 -e $LOG_FILE3 ./gfdl.regional.sh)
8585

8686
#-----------------------------------------------------------------------------
87-
# ESG regional grid
87+
# ESG regional grid (output dominant soil/vegetation type).
8888
#-----------------------------------------------------------------------------
8989

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

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

9899
LOG_FILE5=${LOG_FILE}05
99-
TEST5=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:07:00 -A $PROJECT_CODE -q $QUEUE -J reg.gsl.gwd \
100-
--partition=xjet -o $LOG_FILE5 -e $LOG_FILE5 ./regional.gsl.gwd.sh)
100+
TEST5=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:07:00 -A $PROJECT_CODE -q $QUEUE -J esg.regional.pct.cat \
101+
--partition=xjet -o $LOG_FILE5 -e $LOG_FILE5 ./esg.regional.pct.cat.sh)
102+
103+
#-----------------------------------------------------------------------------
104+
# Regional GSL gravity wave drag.
105+
#-----------------------------------------------------------------------------
106+
107+
LOG_FILE6=${LOG_FILE}06
108+
TEST6=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:07:00 -A $PROJECT_CODE -q $QUEUE -J reg.gsl.gwd \
109+
--partition=xjet -o $LOG_FILE6 -e $LOG_FILE6 ./regional.gsl.gwd.sh)
101110

102111
#-----------------------------------------------------------------------------
103112
# Create summary log.
104113
#-----------------------------------------------------------------------------
105114

106115
sbatch --partition=xjet --nodes=1 -t 0:01:00 -A $PROJECT_CODE -J grid_summary -o $LOG_FILE -e $LOG_FILE \
107-
-q $QUEUE -d afterok:$TEST1:$TEST2:$TEST3:$TEST4:$TEST5 << EOF
116+
-q $QUEUE -d afterok:$TEST1:$TEST2:$TEST3:$TEST4:$TEST5:$TEST6 << EOF
108117
#!/bin/bash
109118
grep -a '<<<' ${LOG_FILE}* > $SUM_FILE
110119
EOF

reg_tests/grid_gen/driver.orion.sh

+14-5
Original file line numberDiff line numberDiff line change
@@ -82,27 +82,36 @@ TEST3=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:10:00 -A $PROJECT_
8282
-o $LOG_FILE3 -e $LOG_FILE3 ./gfdl.regional.sh)
8383

8484
#-----------------------------------------------------------------------------
85-
# ESG regional grid
85+
# ESG regional grid (output dominant soil/vegetation type).
8686
#-----------------------------------------------------------------------------
8787

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

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

9697
LOG_FILE5=${LOG_FILE}05
97-
TEST5=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:10:00 -A $PROJECT_CODE -q $QUEUE -J reg.gsl.gwd \
98-
-o $LOG_FILE5 -e $LOG_FILE5 ./regional.gsl.gwd.sh)
98+
TEST5=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:10:00 -A $PROJECT_CODE -q $QUEUE -J esg.regional.pct.cat \
99+
-o $LOG_FILE5 -e $LOG_FILE5 ./esg.regional.pct.cat.sh)
100+
101+
#-----------------------------------------------------------------------------
102+
# Regional grid with GSL gravity wave drag fields.
103+
#-----------------------------------------------------------------------------
104+
105+
LOG_FILE6=${LOG_FILE}06
106+
TEST6=$(sbatch --parsable --ntasks-per-node=24 --nodes=1 -t 0:10:00 -A $PROJECT_CODE -q $QUEUE -J reg.gsl.gwd \
107+
-o $LOG_FILE6 -e $LOG_FILE6 ./regional.gsl.gwd.sh)
99108

100109
#-----------------------------------------------------------------------------
101110
# Create summary log.
102111
#-----------------------------------------------------------------------------
103112

104113
sbatch --nodes=1 -t 0:01:00 -A $PROJECT_CODE -J grid_summary -o $LOG_FILE -e $LOG_FILE \
105-
-q $QUEUE -d afterok:$TEST1:$TEST2:$TEST3:$TEST4:$TEST5 << EOF
114+
-q $QUEUE -d afterok:$TEST1:$TEST2:$TEST3:$TEST4:$TEST5:$TEST6 << EOF
106115
#!/bin/bash
107116
grep -a '<<<' ${LOG_FILE}* > $SUM_FILE
108117
EOF

reg_tests/grid_gen/driver.wcoss2.sh

+12-3
Original file line numberDiff line numberDiff line change
@@ -87,27 +87,36 @@ TEST3=$(qsub -V -o $LOG_FILE3 -e $LOG_FILE3 -q $QUEUE -A $PROJECT_CODE -l wallti
8787
-N gfdl.regional -l select=1:ncpus=30:mem=40GB $PWD/gfdl.regional.sh)
8888

8989
#-----------------------------------------------------------------------------
90-
# esg regional grid
90+
# ESG regional grid (output dominant soil/vegetation type).
9191
#-----------------------------------------------------------------------------
9292

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

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

101102
LOG_FILE5=${LOG_FILE}05
102103
TEST5=$(qsub -V -o $LOG_FILE5 -e $LOG_FILE5 -q $QUEUE -A $PROJECT_CODE -l walltime=00:07:00 \
104+
-N esg.regional.pct.cat -l select=1:ncpus=30:mem=40GB $PWD/esg.regional.pct.cat.sh)
105+
106+
#-----------------------------------------------------------------------------
107+
# Regional GSL gravity wave drag test.
108+
#-----------------------------------------------------------------------------
109+
110+
LOG_FILE6=${LOG_FILE}06
111+
TEST6=$(qsub -V -o $LOG_FILE6 -e $LOG_FILE6 -q $QUEUE -A $PROJECT_CODE -l walltime=00:07:00 \
103112
-N rsg.gsl.gwd -l select=1:ncpus=30:mem=40GB $PWD/regional.gsl.gwd.sh)
104113

105114
#-----------------------------------------------------------------------------
106115
# Create summary log.
107116
#-----------------------------------------------------------------------------
108117

109118
qsub -V -o ${LOG_FILE} -e ${LOG_FILE} -q $QUEUE -A $PROJECT_CODE -l walltime=00:02:00 \
110-
-N grid_summary -l select=1:ncpus=1:mem=100MB -W depend=afterok:$TEST1:$TEST2:$TEST3:$TEST4:$TEST5 << EOF
119+
-N grid_summary -l select=1:ncpus=1:mem=100MB -W depend=afterok:$TEST1:$TEST2:$TEST3:$TEST4:$TEST5:$TEST6 << EOF
111120
#!/bin/bash
112121
cd ${this_dir}
113122
grep -a '<<<' ${LOG_FILE}* | grep -v echo > $SUM_FILE
+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/bin/bash
2+
3+
#-----------------------------------------------------------------------
4+
# Create a regional esg grid. Output dominant soil and vegetation
5+
# categories and well as the percentage of each category.
6+
# Compare output to a set of baseline files using the 'nccmp'
7+
# utility. This script is run by the machine specific driver script.
8+
#-----------------------------------------------------------------------
9+
10+
set -x
11+
12+
TEST_NAME="esg.regional.pct.cat"
13+
export TEMP_DIR=${WORK_DIR}/${TEST_NAME}.work
14+
export out_dir=${WORK_DIR}/${TEST_NAME}
15+
16+
export gtype=regional_esg
17+
export target_lon=-97.5 # Center longitude of the highest resolution tile
18+
export target_lat=35.5 # Center latitude of the highest resolution tile
19+
export idim=1301 # Dimension of grid in 'i' direction
20+
export jdim=600 # Dimension of grid in 'j' direction
21+
export delx=0.0145 # Grid spacing in degrees in 'i' direction
22+
export dely=0.0145 # Grid spacing in degrees in 'j' direction
23+
export halo=3
24+
export vegsoilt_frac=.true. # Output dominant soil/veg categories as well
25+
# as the percentage of each category.
26+
27+
NCCMP=${NCCMP:-$(which nccmp)}
28+
29+
#-----------------------------------------------------------------------
30+
# Start script.
31+
#-----------------------------------------------------------------------
32+
33+
echo "Starting at: " `date`
34+
35+
$home_dir/ush/fv3gfs_driver_grid.sh
36+
37+
iret=$?
38+
if [ $iret -ne 0 ]; then
39+
set +x
40+
echo "<<< ESG REGIONAL PERCENT CATEGORY TEST FAILED. <<<"
41+
exit $iret
42+
fi
43+
44+
echo "Ending at: " `date`
45+
46+
#-----------------------------------------------------------------------------
47+
# Compare output to baseline set of data.
48+
#-----------------------------------------------------------------------------
49+
50+
cd $out_dir/C3113
51+
52+
test_failed=0
53+
for files in *tile*.nc ./fix_sfc/*tile*.nc
54+
do
55+
if [ -f $files ]; then
56+
echo CHECK $files
57+
$NCCMP -dmfqS $files $HOMEreg/${TEST_NAME}/$files
58+
iret=$?
59+
if [ $iret -ne 0 ]; then
60+
test_failed=1
61+
fi
62+
fi
63+
done
64+
65+
set +x
66+
if [ $test_failed -ne 0 ]; then
67+
echo "<<< ESG REGIONAL PERCENT CATEGORY TEST FAILED. >>>"
68+
if [ "$UPDATE_BASELINE" = "TRUE" ]; then
69+
$home_dir/reg_tests/update_baseline.sh "${HOMEreg}/.." "${TEST_NAME}" $commit_num
70+
fi
71+
else
72+
echo "<<< ESG REGIONAL PERCENT CATEGORY TEST PASSED. >>>"
73+
fi
74+
75+
exit 0

sorc/sfc_climo_gen.fd/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55

66
set(lib_src
77
interp.F90
8+
interp_frac_cats.F90
89
model_grid.F90
910
output.f90
11+
output_frac_cats.F90
1012
program_setup.f90
1113
search.f90
14+
search_frac_cats.f90
1215
source_grid.F90
1316
utils.f90)
1417

sorc/sfc_climo_gen.fd/driver.F90

+16-4
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,14 @@ program driver
8080
!-------------------------------------------------------------------------
8181

8282
call define_source_grid(localpet, npets, input_vegetation_type_file)
83-
method=ESMF_REGRIDMETHOD_NEAREST_STOD
84-
call interp(localpet, method, input_vegetation_type_file)
83+
if (fract_vegsoil_type) then
84+
print*,'- WILL OUTPUT VEGETATION TYPE FRACTION AND DOMINANT CATEGORY.'
85+
call interp_frac_cats(localpet, input_vegetation_type_file)
86+
else
87+
print*,'- WILL OUTPUT DOMINANT VEGETATION TYPE.'
88+
method=ESMF_REGRIDMETHOD_NEAREST_STOD
89+
call interp(localpet, method, input_vegetation_type_file)
90+
endif
8591
call source_grid_cleanup
8692

8793
! Snow free albedo
@@ -136,8 +142,14 @@ program driver
136142

137143
if (trim(input_soil_type_file) /= "NULL") then
138144
call define_source_grid(localpet, npets, input_soil_type_file)
139-
method=ESMF_REGRIDMETHOD_NEAREST_STOD
140-
call interp(localpet, method, input_soil_type_file)
145+
if (fract_vegsoil_type) then
146+
print*,'- WILL OUTPUT SOIL TYPE FRACTION AND DOMINANT CATEGORY.'
147+
call interp_frac_cats(localpet, input_soil_type_file)
148+
else
149+
print*,'- WILL OUTPUT DOMINANT SOIL TYPE.'
150+
method=ESMF_REGRIDMETHOD_NEAREST_STOD
151+
call interp(localpet, method, input_soil_type_file)
152+
endif
141153
call source_grid_cleanup
142154
endif
143155

0 commit comments

Comments
 (0)