1 | #!/bin/bash |
---|
2 | |
---|
3 | #################################### Site-specific functions ####################### |
---|
4 | # In order to accomodate various computing environments, testing.sh relies on the following |
---|
5 | # site-specific functions which must be provided by include_site.sh |
---|
6 | # |
---|
7 | # submit_run_and_post EXP |
---|
8 | # Submit the run job run.job to the batch scheduler |
---|
9 | # Submit the post-processing job post.job to the batch scheduler |
---|
10 | # so that it starts after successful completion of run.job |
---|
11 | # |
---|
12 | # qstat |
---|
13 | # Display cluster status : jobs running, waiting, ect. |
---|
14 | # |
---|
15 | # print_run_job() |
---|
16 | # Print run.job on standard output |
---|
17 | # Standard output is redirected to run.job by caller |
---|
18 | # |
---|
19 | # print_post_job() |
---|
20 | # Print beginning of post.job on standard output. The caller will print additional lines depending on the test case. |
---|
21 | # Standard output is redirected to file post.job by caller |
---|
22 | # Script post.job must source include_site.sh, include_post.sh |
---|
23 | # and either include_post_xios.sh or include_post_noxios.sh . |
---|
24 | # These two scripts define functions suitable for output produced with/without XIOS |
---|
25 | # These functions are called at the end of post.job, in the test-case-dependent part appended by the caller |
---|
26 | # These functions call wrapper functions NCKS and CDO which must also be defined in include_site.sh |
---|
27 | |
---|
28 | ################################ Helper functions ############################## |
---|
29 | |
---|
30 | function redef() |
---|
31 | { |
---|
32 | while (($# > 0)) ; do |
---|
33 | sed -i "s/$1[ ]*=[ ]*[[:alnum:]\.]*/$1=$2/g" run.def |
---|
34 | shift; shift; |
---|
35 | done |
---|
36 | } |
---|
37 | |
---|
38 | function create_exp() |
---|
39 | { |
---|
40 | # EXP_NAME param_dir run grid post_XX |
---|
41 | mkdir -p $TESTING/$WORK/$1 |
---|
42 | cd $TESTING/$WORK/$1 |
---|
43 | ln -sf $DYNAMICO/bin/icosa_gcm.exe . |
---|
44 | ln -sf $TESTING/$WORK/$4 mygrid |
---|
45 | ln -sf $TESTING/include_*.sh . |
---|
46 | ln -sf $TESTING/iodef.xml $TESTING/lmdz_physics.xml . |
---|
47 | cp $TESTING/$WORK/param_sets/$2/*.def . |
---|
48 | cp -f "$3.def" tmp.def |
---|
49 | mv -f tmp.def run.def |
---|
50 | redef nsplit_i 2 nsplit_j 2 |
---|
51 | print_run_job > run.job |
---|
52 | print_post_job > post.job |
---|
53 | echo $5 >> post.job |
---|
54 | chmod a+rx *.job |
---|
55 | } |
---|
56 | |
---|
57 | function grid() |
---|
58 | { |
---|
59 | echo gridtype = lonlat |
---|
60 | echo xsize = $1 |
---|
61 | echo xfirst = $2 |
---|
62 | echo xinc = $3 |
---|
63 | echo ysize = $4 |
---|
64 | echo yfirst = $5 |
---|
65 | echo yinc = $6 |
---|
66 | } |
---|
67 | |
---|
68 | |
---|
69 | ########################### Resolution-dependent parameters #################### |
---|
70 | function nbpX() { redef nbp $1 dt $2 tau_graddiv $3 tau_gradrot $3 tau_divgrad $3 |
---|
71 | } |
---|
72 | function nbp32() { nbpX 32 600 21600 |
---|
73 | } |
---|
74 | function nbp64() { nbpX 64 300 10800 |
---|
75 | } |
---|
76 | function nbp128() { nbpX 128 150 5400 |
---|
77 | } |
---|
78 | function nbp40() { nbpX 40 480 18000 |
---|
79 | } |
---|
80 | function nbp80() { nbpX 80 240 9000 |
---|
81 | } |
---|
82 | function nbp160() { nbpX 160 120 4500 |
---|
83 | } |
---|
84 | ################################### Test cases ################################# |
---|
85 | |
---|
86 | # Williamson (1991) |
---|
87 | |
---|
88 | function W91() |
---|
89 | { |
---|
90 | EXP=W91_6_$1 |
---|
91 | echo "$EXP : nbp=$1 dt=$2 grid=$4" |
---|
92 | create_exp $EXP shallow_water/williamson91 run6 $4 post_W91 |
---|
93 | ln -sf $TESTING/icosa_SW.xml icosa.xml |
---|
94 | redef nbp $1 dt $2 tau_graddiv $3 tau_gradrot $3 tau_divgrad $3 |
---|
95 | redef write_period 86400 run_length 2592000 |
---|
96 | submit_run_and_post $EXP |
---|
97 | } |
---|
98 | |
---|
99 | # Jablonowski & Williamson (2006) |
---|
100 | |
---|
101 | function JW06() |
---|
102 | { |
---|
103 | EXP=JW06_$1 |
---|
104 | echo "$EXP : nbp=$1 dt=$2 grid=$4" |
---|
105 | create_exp $EXP dcmip2012 run41 $4 post_JW06 |
---|
106 | ln -sf $TESTING/icosa_JW06.xml icosa.xml |
---|
107 | # redef nbp $1 dt $2 tau_graddiv $3 tau_gradrot $3 tau_divgrad $3 |
---|
108 | nbp$1 |
---|
109 | redef write_period 86400 run_length 864000 etat0 jablonowsky06 |
---|
110 | submit_run_and_post $EXP |
---|
111 | } |
---|
112 | |
---|
113 | # DCMIP1.2 Transport by Hadley-like circulation |
---|
114 | |
---|
115 | function DCMIP12() |
---|
116 | { |
---|
117 | EXP=DCMIP12_$1_$2 |
---|
118 | echo "$EXP : nbp=$1 llm=$2 ncar_dz=$3 dt=$4 grid=$5" |
---|
119 | create_exp $EXP dcmip2012 run11 $5 post_DCMIP12 |
---|
120 | redef nqtot 1 nbp $1 llm $2 ncar_dz $3 dt $4 |
---|
121 | redef dcmip1_shape hadley dcmip1_wind hadley run_length 86400 write_period 3600 |
---|
122 | submit_run_and_post $EXP |
---|
123 | } |
---|
124 | |
---|
125 | # DCMIP2.0 Rest over orography (PGF error) |
---|
126 | |
---|
127 | function DCMIP20() |
---|
128 | { |
---|
129 | EXP=DCMIP20_$1_$2 |
---|
130 | echo "$EXP : nbp=$1 llm=$2 ncar_dz=$3 dt=$4 grid=$5" |
---|
131 | create_exp $EXP dcmip2012 run20 $5 post_DCMIP20 |
---|
132 | # redef nbp $1 dt $4 |
---|
133 | nbp$1 |
---|
134 | redef nqtot 0 llm $2 ncar_dz $3 |
---|
135 | # from make_rundefs.sh : group 'Time' run_length 518400 write_period 21600 |
---|
136 | # comment out the following line to conform to DCMIP document |
---|
137 | # redef run_length 86400 write_period 3600 |
---|
138 | submit_run_and_post $EXP |
---|
139 | } |
---|
140 | |
---|
141 | # DCMIP2.1 Orographic wave |
---|
142 | |
---|
143 | function DCMIP21() |
---|
144 | { |
---|
145 | EXP=DCMIP21_$1_$2 |
---|
146 | echo "$EXP : nbp=$1 llm=$2 ncar_dz=$3 dt=$4 grid=$5" |
---|
147 | create_exp $EXP dcmip2012 run21 $5 post_DCMIP21 |
---|
148 | # redef nbp $1 dt $4 |
---|
149 | nbp$1 |
---|
150 | redef nqtot 0 llm $2 ncar_dz $3 run_length 86400 write_period 3600 |
---|
151 | submit_run_and_post $EXP |
---|
152 | } |
---|
153 | |
---|
154 | # DCMIP3.1 Non-orographic gravity wave |
---|
155 | |
---|
156 | function DCMIP31() |
---|
157 | { |
---|
158 | EXP=DCMIP31_$1_$2 |
---|
159 | echo "$EXP : nbp=$1 llm=$2 ncar_dz=$3 dt=$4 grid=$5" |
---|
160 | create_exp $EXP dcmip2012 run3 $5 post_DCMIP31 |
---|
161 | # redef nbp $1 dt $4 |
---|
162 | nbp$1 |
---|
163 | redef nqtot 0 llm $2 ncar_dz $3 run_length 86400 write_period 3600 |
---|
164 | submit_run_and_post $EXP |
---|
165 | } |
---|
166 | |
---|
167 | # DCMIP4.1 JW06 on a small planet with tracers |
---|
168 | |
---|
169 | function DCMIP41() |
---|
170 | { |
---|
171 | EXP=DCMIP41_$1 |
---|
172 | echo "$EXP : nbp=$1 dt=$2 tau_dissip=$3 grid=$4" |
---|
173 | create_exp $EXP dcmip2012 run41 $4 post_DCMIP41 |
---|
174 | # redef nbp $1 dt $2 tau_graddiv $3 tau_gradrot $3 tau_divgrad $3 |
---|
175 | nbp$1 |
---|
176 | redef nqtot 2 write_period 86400 run_length 864000 |
---|
177 | submit_run_and_post $EXP |
---|
178 | } |
---|
179 | |
---|
180 | # DCMIP5 Tropical cyclone |
---|
181 | |
---|
182 | function DCMIP51() |
---|
183 | { |
---|
184 | EXP=DCMIP51_$1 |
---|
185 | echo "$EXP : nbp=$1 dt=$2 grid=$4" |
---|
186 | create_exp $EXP dcmip2012 run51 $4 post_DCMIP51 |
---|
187 | nbp$1 |
---|
188 | # redef nbp $1 dt $2 tau_graddiv $3 tau_gradrot $3 tau_divgrad $3 |
---|
189 | redef itau_physics 6 |
---|
190 | submit_run_and_post $EXP |
---|
191 | } |
---|
192 | |
---|
193 | # Held & Suarez (1994) |
---|
194 | |
---|
195 | function HS94() |
---|
196 | { |
---|
197 | EXP=HS94_$1_$3 |
---|
198 | echo "$EXP : nbp=$1 dt=$2 grid=$4" |
---|
199 | create_exp $EXP climate/Held_Suarez run $4 post_HS |
---|
200 | nbp$1 |
---|
201 | # redef nbp $1 dt $2 tau_graddiv $3 tau_gradrot $3 tau_divgrad $3 |
---|
202 | submit_run_and_post $EXP |
---|
203 | } |
---|
204 | |
---|
205 | # Saturn : start from rest, vertical temperature profile read from file |
---|
206 | |
---|
207 | function Saturn() |
---|
208 | { |
---|
209 | EXP=SATURN_$1 |
---|
210 | echo "$EXP : nbp=$1 dt=$2 grid=$4" |
---|
211 | create_exp $EXP planets run_saturn $4 |
---|
212 | for x in saturn_const.def callphys.def gases.def icosa.xml apbp.txt temp_profile.txt DATAGENERIC; do |
---|
213 | ln -s $TESTING/SATURN/TEST/$x |
---|
214 | done |
---|
215 | ln -sf $TESTING/icosa_SW.xml icosa.xml |
---|
216 | redef nbp $1 dt $2 tau_graddiv $3 tau_gradrot $3 tau_divgrad $3 |
---|
217 | redef nsplit_i 1 nsplit_j 1 nqtot 0 |
---|
218 | redef run_length 38052 # 1 Saturn day |
---|
219 | # redef run_length 3805200 # 100 Saturn days |
---|
220 | # redef run_length 76104000 # 20000 Saturn day |
---|
221 | # echo post_SATURN >> post.job |
---|
222 | # submit_run_and_post $EXP |
---|
223 | } |
---|
224 | |
---|
225 | ######################################## Main ####################################### |
---|
226 | |
---|
227 | function reset() |
---|
228 | { |
---|
229 | echo "Testing DYNAMICO revision $revision" |
---|
230 | set -x |
---|
231 | rm -rf $TESTING/$WORK |
---|
232 | mkdir $TESTING/$WORK |
---|
233 | set +x |
---|
234 | |
---|
235 | mkdir $TESTING/$WORK/param_sets |
---|
236 | cd $TESTING/$WORK/param_sets |
---|
237 | $TESTING/trunk/param_sets/make_rundefs.sh |
---|
238 | |
---|
239 | cd $TESTING/$WORK |
---|
240 | grid 720 0.25 0.5 360 -89.75 0.5 > fine_grid |
---|
241 | grid 360 0.5 1 180 -89.5 1 > medium_grid |
---|
242 | grid 180 1 2 90 -89 2 > coarse_grid |
---|
243 | } |
---|
244 | |
---|
245 | function debug() |
---|
246 | { |
---|
247 | # W91 32 600 21600 coarse_grid |
---|
248 | # HS94 32 600 86400 coarse_grid |
---|
249 | JW06 32 600 21600 coarse_grid |
---|
250 | # DCMIP12 40 30 400 600 coarse_grid |
---|
251 | # DCMIP12 80 60 200 300 medium_grid |
---|
252 | # DCMIP12 160 120 100 150 medium_grid |
---|
253 | # DCMIP20 40 30 400 480 coarse_grid |
---|
254 | # DCMIP21 40 60 500 480 coarse_grid |
---|
255 | # DCMIP31 40 10 1000 480 coarse_grid |
---|
256 | # DCMIP41 32 600 21600 coarse_grid |
---|
257 | # DCMIP51 32 600 21600 coarse_grid |
---|
258 | # cp -pr $TESTING/trunk/param_sets/planets $TESTING/$WORK/param_sets |
---|
259 | # Saturn 10 475.65 5000 coarse_grid |
---|
260 | } |
---|
261 | |
---|
262 | function fast() |
---|
263 | { |
---|
264 | W91 32 600 21600 coarse_grid |
---|
265 | JW06 32 600 21600 coarse_grid |
---|
266 | DCMIP12 40 30 400 600 coarse_grid |
---|
267 | DCMIP20 40 30 400 480 coarse_grid |
---|
268 | DCMIP21 40 60 500 480 coarse_grid |
---|
269 | DCMIP31 40 10 1000 480 coarse_grid |
---|
270 | DCMIP41 32 600 21600 coarse_grid |
---|
271 | DCMIP51 32 600 43200 coarse_grid |
---|
272 | } |
---|
273 | |
---|
274 | function GMD_2014() |
---|
275 | { |
---|
276 | # W91 32 600 21600 coarse_grid |
---|
277 | # JW06 32 600 21600 coarse_grid |
---|
278 | HS94 32 600 86400 coarse_grid |
---|
279 | } |
---|
280 | |
---|
281 | function extended() |
---|
282 | { |
---|
283 | W91 64 300 10800 fine_grid |
---|
284 | W91 128 150 5400 fine_grid |
---|
285 | JW06 64 300 10800 fine_grid |
---|
286 | JW06 128 150 5400 fine_grid |
---|
287 | DCMIP51 64 300 21600 fine_grid |
---|
288 | DCMIP51 128 150 10800 fine_grid |
---|
289 | HS94 32 600 86400 fine_grid |
---|
290 | HS94 32 600 5400 fine_grid |
---|
291 | HS94 40 480 50000 fine_grid |
---|
292 | HS94 40 480 21600 fine_grid |
---|
293 | HS94 64 300 10800 fine_grid |
---|
294 | } |
---|
295 | |
---|
296 | #set -o errexit |
---|
297 | |
---|
298 | # include machine-specific helper/wrapper functions : |
---|
299 | # print_run_job print_post_job submit_run_and_post qstat |
---|
300 | |
---|
301 | source include_site.sh |
---|
302 | |
---|
303 | clear |
---|
304 | echo "Usage : testing.sh [reset] [debug|fast|extended]" |
---|
305 | TESTING=$PWD |
---|
306 | DYNAMICO=$TESTING/trunk |
---|
307 | # find out revision number |
---|
308 | cd $DYNAMICO |
---|
309 | svn info --xml | grep revision | head -n 1 > info.xml |
---|
310 | sed -i "s/>//g" info.xml |
---|
311 | . info.xml |
---|
312 | WORK="r$revision" |
---|
313 | |
---|
314 | for x in $* ; do |
---|
315 | echo $x |
---|
316 | $x |
---|
317 | done |
---|
318 | |
---|
319 | #qstat |
---|