-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyversion2.sh
executable file
·222 lines (191 loc) · 6.59 KB
/
myversion2.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
#!/bin/sh
#This routine will make the mod_defs that are needed as input in
#ufs-apps using WW3
# UFSMODELDIR is the location of your clone of ufs-weather-model
# OUTDIR is the location where the mod_def.* outputs will end up from this script
# SRCDIR is the location of the ww3_grid.inp files
# WORKDIR is the working directory for log files, e
#export UFSMODELDIR=<path-to-your>/ufs-weather-model
#export OUTDIR=<path-to-your>/outdir
#export SRCDIR=/scratch1/NCEPDEV/nems/emc.nemspara/RT/NEMSfv3gfs/input-data-20220414/WW3_input_data_20220418/createmoddefs
#export WORKDIR=<path-to-your>/workdir
export UFSMODELDIR=/glade/work/worthen/WaveIn_unstr6/ufs_wave
export OUTDIR=/glade/work/worthen/WaveIn_unstr6/moddefs
export SRCDIR=/glade/work/worthen/WaveIn_unstr6
export WORKDIR=/glade/work/worthen/WaveIn_unstr6/workdir
###################################
# Set up #
###################################
set +x
#source ./machine-setup.sh > /dev/null 2>&1
#if [ $target = hera ]; then export target=hera.intel ; fi
#if [ $target = orion ]; then export target=orion.intel ; fi
#if [ $target = stampede ]; then export target=stampede.intel ; fi
#if [ $target = gaea ]; then export target=gaea.intel ; fi
#if [ $target = jet ]; then export target=jet.intel ; fi
export target=derecho.intel
module use $UFSMODELDIR/modulefiles
module load ufs_$target
module list
set -x
#######################################
# Create Work and Build Dirs mesh #
#######################################
if [[ ! -d ${WORKDIR} ]] ; then
echo "Make WORKDIR: $WORKDIR"
mkdir -p $WORKDIR
fi
export WW3_DIR=$UFSMODELDIR/WW3
export SWITCHFILE="${WW3_DIR}/model/bin/switch_meshcap_pdlib"
export MAKEMESH=true
grids='exp.global_270k exp.wise.trip1degmask'
#grids='exp.wise.global_270k '
#grids='exp.wise.trip1degmask'
#export SWITCHFILE="${WW3_DIR}/model/bin/switch_meshcap_pdlib_ic4"
#grids='ic4.nk25.exp.wise.trip1degmask ic4.nk25.exp.wise.global_270k'
#export SWITCHFILE="${WW3_DIR}/model/bin/switch_meshcap"
#export SWITCHFILE="${WW3_DIR}/model/bin/switch_meshcap_ic4"
#export MAKEMESH=false
#grids='ic4.nk25.mx100'
#export SWITCHFILE="${WW3_DIR}/model/bin/switch_meshcap_pr1"
#export MAKEMESH=false
#grids='g37'
#export SWITCHFILE="${WW3_DIR}/model/bin/switch_meshcap"
#grids='mx100 glo_1deg'
#export MAKEMESH=false
path_build=$WORKDIR/build_mesh
mkdir -p $path_build
cd $path_build
########################################
# Build ww3_grid exe meshcap switch #
########################################
echo $(cat ${SWITCHFILE}) > ${path_build}/tempswitch
if grep -q PDLIB "${path_build}/tempswitch" && ! grep -q SCRIP "${path_build}/tempswitch"; then
sed -e "s/DIST/SHRD/g"\
-e "s/OMPG / /g"\
-e "s/OMPH / /g"\
-e "s/MPIT / /g"\
-e "s/MPI / /g"\
-e "s/B4B / /g"\
-e "s/SCOTCH / /g"\
-e "s/PDLIB / SCRIP SCRIPNC /g"\
-e "s/NOGRB/NCEP2/g"\
${path_build}/tempswitch > ${path_build}/switch
else
sed -e "s/DIST/SHRD/g"\
-e "s/OMPG / /g"\
-e "s/OMPH / /g"\
-e "s/MPIT / /g"\
-e "s/MPI / /g"\
-e "s/B4B / /g"\
-e "s/PDLIB / /g"\
-e "s/SCOTCH / /g"\
-e "s/NOGRB/NCEP2/g"\
${path_build}/tempswitch > ${path_build}/switch
fi
rm ${path_build}/tempswitch
echo "Switch file is $path_build/switch with switches:"
cat $path_build/switch
#cmake $WW3_DIR -DSWITCH=$path_build/switch -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Debug
cmake $WW3_DIR -DSWITCH=$path_build/switch -DCMAKE_INSTALL_PREFIX=install
rc=$?
if [[ $rc -ne 0 ]] ; then
echo "Fatal error in cmake."
exit $rc
fi
make -j 8
rc=$?
if [[ $rc -ne 0 ]] ; then
echo "Fatal error in make."
exit $rc
fi
make install
if [[ $rc -ne 0 ]] ; then
echo "Fatal error in make install."
exit $rc
fi
WW3_EXEDIR=$path_build/install/bin
###################################
# Make mod_def files mesh #
###################################
if [[ ! -d ${WORKDIR} ]] ; then
echo "Make WORKDIR: $WORKDIR"
mkdir -p $WORKDIR
fi
cd $WORKDIR
# mesh wave model grids
#grids='mx025lite mx025 mx050 mx100 gwes_30m natl_6m points'
#grids='with_land_CardDeck no_land_CardDeck no_land_Domain_Decomposition with_land_Domain_Decomposition'
#grids='trip1deg trip1deg_noland'
#grids='trip1deg_noland.mod'
#grids='trip1deg_noland_carddeck.mod'
#grids='trip1degmask_dd trip1degmask_cd'
#grids='trip10minmask_dd trip15minmask_dd'
#grids='global_270k global_350k global_500k'
#grids='global_270k'
#grids='exp.global_350k imp.global_350k'
#grids='exp.global_270k imp.global_270k'
#grids='exp.trip1degmask imp.trip1degmask'
#grids='cd.trip1degmask'
#grids='mx100 trip1degmask_dd trip1degmask_cd'
#grids='exp.trip1degmask'
#grids='exp.global_270k'
#grids='loice.exp.trip1degmask'
#grids='hiice.exp.trip1degmask'
#grids='exp.flckF.trip1degmask'
#grids='exp.flchF.trip1degmask exp.flF.trip1degmask'
#note these were created after updating WW3 from the ungridded stokes drift to the wise pr
#grids='imp.wise.trip1degmask exp.wise.trip1degmask'
#grids='exp.wise.global_500k'
#grids='exp.wise.global_270k'
# must change switch file for this, replace SEED with LN1
#grids='exp.noseed.trip1degmask'
#grids='exp.global_270k'
#grids='exp.wise.tnx1v4maskdry'
#grids='exp.wise.maskX'
#from baseline w/ mods to the number of freqs, timesteps, outs
#grids='mod.glo_1deg'
# noresm w/ mask pole
#grids='exp.wise.tnx1v4maskP'
echo 'Removing ST4TABUHF2.bin mod_def.*'
rm -rf ST4TABUHF2.bin mod_def.*
echo "$OUTDIR"
if [[ ! -d ${OUTDIR} ]] ; then
echo "Make OUTDIR: $OUTDIR"
mkdir -p $OUTDIR
fi
for grid in ${grids}
do
if [ -f ${SRCDIR}/ww3_grid.inp.${grid} ]
then
# the magic of google
IFS='.'
strs=($grid)
unset IFS;
len=${#strs[@]}
domain=${strs[len-1]}
echo ' '
echo " Copying WW3 grid input file ww3_grid.${grid} "
echo ' '
cp ${SRCDIR}/ww3_grid.inp.${grid} ww3_grid.inp
if [ -f ${WORKDIR}/ww3_${grid}.out ]; then
rm ${WORKDIR}/ww3_${grid}.out
fi
echo "Executing ww3_grid, see grid output in ww3_${grid}.out"
${WW3_EXEDIR}/ww3_grid > ${WORKDIR}/ww3_${grid}.out
mv mod_def.ww3 ${OUTDIR}/mod_def.${grid}
mv scrip.nc ${OUTDIR}/${grid}.SCRIP.nc
rm -f ww3_grid.inp ST4TABUHF2.bin
if [[ $MAKEMESH = true ]]; then
#srun -A nems -n 1 ESMF_Scrip2Unstruct ${OUTDIR}/${grid}.SCRIP.nc ${OUTDIR}/mesh.${domain}.nc 0
ESMF_Scrip2Unstruct ${OUTDIR}/${grid}.SCRIP.nc ${OUTDIR}/mesh.${domain}.nc 0
echo "Creating ESMF mesh for unstructured mesh mesh.${domain}.nc "
fi
else
echo ' '
echo " WW3 grid input file ww3_grid.inp.${grid} not found! "
echo ' ****************** ABORTING *********************'
echo ' '
exit
fi
done