forked from ufs-community/UFS_UTILS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfv3gfs_make_grid.sh
executable file
·146 lines (126 loc) · 4.81 KB
/
fv3gfs_make_grid.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/ksh
set -ax
#-----------------------------------------------------------------------------------------
#
# Script name: fv3gfs_make_grid.sh
# -----------
#
# Description: Makes the 'grid' and mosaic file for an fv3 grid.
# -----------
#
# Shell variables:
# ---------------
#
# APRUN Command to invoke executables
# exec_dir Location of executables
# gtype Grid type. 'uniform' - global uniform; 'stretch' - global
# stretched; 'nest' - global stretched with nest; 'regional' -
# stand alone regional nest.
# halo Lateral boundary halo size, regional grids only.
# i/jstart_nest Starting i/j index of nest within parent tile.
# i/jend_nst Ending i/j index of nest within parent tile.
# outdir Working directory.
# refine_ratio Nest refinement ratio.
# res Resolution, i.e, 96.
# stretch_fac Stretching factor
# target_lat Center latitude of highest resolution tile
# target_lon Center longitude of highest resolution tile
#
#-----------------------------------------------------------------------------------------
gtype=${gtype:?}
res=${res:?}
outdir=${outdir:-$1}
exec_dir=${exec_dir:?}
APRUN=${APRUN:-time}
nx=`expr $res \* 2 `
if [ ! -s $outdir ]; then mkdir -p $outdir ;fi
cd $outdir
executable=$exec_dir/make_hgrid
if [ ! -s $executable ]; then
set +x
echo
echo "FATAL ERROR: ${executable} does not exist"
echo
set -x
exit 1
fi
#-----------------------------------------------------------------------------------------
# Create 'grid' files - one for each tile in netcdf.
#-----------------------------------------------------------------------------------------
if [ $gtype = uniform ]; then
ntiles=6
$APRUN $executable --grid_type gnomonic_ed --nlon $nx --grid_name C${res}_grid
elif [ $gtype = stretch ]; then
stretch_fac=${stretch_fac:?}
target_lon=${target_lon:?}
target_lat=${target_lat:?}
ntiles=6
$APRUN $executable --grid_type gnomonic_ed --nlon $nx --grid_name C${res}_grid \
--do_schmidt --stretch_factor ${stretch_fac} --target_lon ${target_lon} --target_lat ${target_lat}
elif [ $gtype = nest ] || [ $gtype = regional ] ; then
stretch_fac=${stretch_fac:?}
target_lon=${target_lon:?}
target_lat=${target_lat:?}
refine_ratio=${refine_ratio:?}
istart_nest=$2
jstart_nest=$3
iend_nest=$4
jend_nest=$5
halo=${halo:?}
if [ $gtype = regional ]; then
ntiles=1
else
ntiles=7
fi
$APRUN $executable --grid_type gnomonic_ed --nlon $nx --grid_name C${res}_grid \
--do_schmidt --stretch_factor ${stretch_fac} --target_lon ${target_lon} --target_lat ${target_lat} \
--nest_grid --parent_tile 6 --refine_ratio $refine_ratio --istart_nest $istart_nest --jstart_nest $jstart_nest \
--iend_nest $iend_nest --jend_nest $jend_nest --halo $halo --great_circle_algorithm
fi
if [ $? -ne 0 ]; then
set +x
echo
echo "FATAL ERROR creating C$res grid."
echo
set -x
exit 1
fi
#---------------------------------------------------------------------------------------
# Create mosaic file.
#
# For global nest grids, create three mosaic files - one for the nest, one for the
# global tiles and one for all tiles. Needed because ESMF-based utilities can't
# process seven tiles at once.
#
# For regional grids, there is only one tile and it is tile number 7.
#---------------------------------------------------------------------------------------
executable=$exec_dir/make_solo_mosaic
if [ ! -s $executable ]; then
set +x
echo
echo "FATAL ERROR: ${executable} does not exist."
echo
set -x
exit 1
fi
if [ $gtype = uniform ] || [ $gtype = stretch ] ; then
$APRUN $executable --num_tiles $ntiles --dir $outdir --mosaic C${res}_mosaic --tile_file \
C${res}_grid.tile1.nc,C${res}_grid.tile2.nc,C${res}_grid.tile3.nc,C${res}_grid.tile4.nc,C${res}_grid.tile5.nc,C${res}_grid.tile6.nc
elif [ $gtype = nest ]; then
$APRUN $executable --num_tiles $ntiles --dir $outdir --mosaic C${res}_mosaic --tile_file \
C${res}_grid.tile1.nc,C${res}_grid.tile2.nc,C${res}_grid.tile3.nc,C${res}_grid.tile4.nc,C${res}_grid.tile5.nc,C${res}_grid.tile6.nc,C${res}_grid.tile7.nc
$APRUN $executable --num_tiles 6 --dir $outdir --mosaic C${res}_coarse_mosaic --tile_file \
C${res}_grid.tile1.nc,C${res}_grid.tile2.nc,C${res}_grid.tile3.nc,C${res}_grid.tile4.nc,C${res}_grid.tile5.nc,C${res}_grid.tile6.nc
$APRUN $executable --num_tiles 1 --dir $outdir --mosaic C${res}_nested_mosaic --tile_file C${res}_grid.tile7.nc
elif [ $gtype = regional ];then
$APRUN $executable --num_tiles $ntiles --dir $outdir --mosaic C${res}_mosaic --tile_file C${res}_grid.tile7.nc
fi
if [ $? -ne 0 ]; then
set +x
echo
echo "FATAL ERROR creating mosaic file."
echo
set -x
exit 1
fi
exit