forked from ufs-community/UFS_UTILS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsfc_climo_gen.sh
executable file
·115 lines (102 loc) · 3.83 KB
/
sfc_climo_gen.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/ksh
#-------------------------------------------------------------------------
# Run sfc_climo_gen program to create surface fixed fields,
# such as vegetation type.
#
# Stand-alone regional grids may be run with any number of
# tasks. All other configurations must be run with a
# MULTIPLE OF SIX MPI TASKS.
#
# Some variable definitions:
#
# BASE_DIR Location of your repository.
# input_sfc_climo_dir Location of raw input surface climo data
# EXEC_DIR Location of program executable
# FIX_DIR Location of 'grid' and 'orog' files
# GRIDTYPE Flag to invoke logic for global nests
# and regional grids. Valid values are
# 'nest' and 'regional'.
# HALO Number of halo row/cols to remove
# for regional grid.
# mosaic_file Path/name of mosaic file.
# res Resolution of cubed-sphere grid
# SAVE_DIR Directory where output is saved
# WORK_DIR Temporary working directory
#-------------------------------------------------------------------------
set -x
ulimit -s unlimited
ulimit -a
res=${res:-96}
WORK_DIR=${WORK_DIR:-/scratch3/NCEPDEV/stmp1/$LOGNAME/sfc_climo_gen.C${res}}
SAVE_DIR=${SAVE_DIR:-$WORK_DIR}
BASE_DIR=${BASE_DIR:?}
EXEC_DIR=${EXEC_DIR:-$BASE_DIR/exec}
GRIDTYPE=${GRIDTYPE:-NULL}
FIX_FV3=${FIX_FV3:-/scratch4/NCEPDEV/global/save/glopara/git/fv3gfs/fix/fix_fv3_gmted2010/C${res}}
input_sfc_climo_dir=${input_sfc_climo_dir:?}
mosaic_file=${mosaic_file:-$FIX_FV3/C${res}_mosaic.nc}
HALO=${HALO:-0}
if [ ! -d $SAVE_DIR ]; then
mkdir -p $SAVE_DIR
fi
rm -fr $WORK_DIR
mkdir -p $WORK_DIR
cd $WORK_DIR
#----------------------------------------------------------------------------------
# The stand-alone regional and global nest are assumed to be tile 7.
#----------------------------------------------------------------------------------
if [[ $GRIDTYPE == "nest" ]] || [[ $GRIDTYPE == "regional" ]]; then
the_orog_files='"C'${res}'_oro_data.tile7.nc"'
else
the_orog_files='"C'${res}'_oro_data.tile1.nc","C'${res}'_oro_data.tile2.nc","C'${res}'_oro_data.tile3.nc","C'${res}'_oro_data.tile4.nc","C'${res}'_oro_data.tile5.nc","C'${res}'_oro_data.tile6.nc"'
fi
cat << EOF > ./fort.41
&config
input_facsf_file="${input_sfc_climo_dir}/facsf.1.0.nc"
input_substrate_temperature_file="${input_sfc_climo_dir}/substrate_temperature.2.6x1.5.nc"
input_maximum_snow_albedo_file="${input_sfc_climo_dir}/maximum_snow_albedo.0.05.nc"
input_snowfree_albedo_file="${input_sfc_climo_dir}/snowfree_albedo.4comp.0.05.nc"
input_slope_type_file="${input_sfc_climo_dir}/slope_type.1.0.nc"
input_soil_type_file="${input_sfc_climo_dir}/soil_type.statsgo.0.05.nc"
input_vegetation_type_file="${input_sfc_climo_dir}/vegetation_type.igbp.0.05.nc"
input_vegetation_greenness_file="${input_sfc_climo_dir}/vegetation_greenness.0.144.nc"
mosaic_file_mdl="$mosaic_file"
orog_dir_mdl="$FIX_FV3"
orog_files_mdl=$the_orog_files
halo=$HALO
maximum_snow_albedo_method="bilinear"
snowfree_albedo_method="bilinear"
vegetation_greenness_method="bilinear"
/
EOF
APRUN_SFC=${APRUN_SFC:-"aprun -j 1 -n 6 -N 6"}
$APRUN_SFC $EXEC_DIR/sfc_climo_gen
rc=$?
if [[ $rc == 0 ]]; then
if [[ $GRIDTYPE != "regional" ]]; then
for files in *.nc
do
if [[ -f $files ]]; then
mv $files ${SAVE_DIR}/C${res}.${files}
fi
done
else
for files in *.halo.nc
do
if [[ -f $files ]]; then
file2=${files%.halo.nc}
mv $files ${SAVE_DIR}/C${res}.${file2}.halo${HALO}.nc
fi
done
for files in *.nc
do
if [[ -f $files ]]; then
file2=${files%.nc}
mv $files ${SAVE_DIR}/C${res}.${file2}.halo0.nc
fi
done
fi # is regional?
else
exit $rc
fi
exit 0