/[MITgcm]/MITgcm_contrib/jmc_script/tst_2+2_cpl
ViewVC logotype

Contents of /MITgcm_contrib/jmc_script/tst_2+2_cpl

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.7 - (show annotations) (download)
Sat Dec 26 23:43:22 2009 UTC (15 years, 6 months ago) by jmc
Branch: MAIN
Changes since 1.6: +84 -34 lines
easier to use (can group several steps + run the coupled set-up directly)

1 #!/bin/sh
2
3 # $Header: /u/gcmpack/MITgcm_contrib/jmc_script/tst_2+2_cpl,v 1.6 2009/09/14 18:52:21 jmc Exp $
4 # $Name: $
5
6 rnp_loc()
7 {
8 # rnp_loc arg_1 arg_2
9 # rename files with prefix = 'arg_1' to files with prefix = 'arg_2'
10 echo 'rnp_loc:' $1 $2
11 # rnp -s $1 $2
12 listY=`ls -1 $1*`
13 for yy in $listY
14 do
15 zz=`echo $yy | sed "s/^$1/$2/"`
16 mv $yy $zz
17 done
18 }
19
20 dif_tiles()
21 {
22 # dif_data_loc dd1 dd2 file
23 # for all tiles ==> do diff dd1/file dd2/file'
24 dd1=$1 ; dd2=$2 ; zz=$3
25 chkmeta='Y'
26 listY=`(cd $dd1 ; ls $zz.*.data | sed "s/$zz\.//" | sed "s/\.data//")`
27 echo '--> file='$zz', listY='$listY
28 for yy in $listY
29 do
30 echo diff $dd1/$zz.$yy.data $dd2
31 diff $dd1/$zz.$yy.data $dd2
32 out=$?
33 if test $out != 0
34 then echo 'Diff outp=' $out ' ==> stop'
35 exit ; fi
36 if test $chkmeta = 'Y'
37 then
38 echo diff $dd1/$zz.$yy.meta $dd2
39 diff $dd1/$zz.$yy.meta $dd2
40 out=$?
41 if test $out != 0
42 then echo 'Diff outp=' $out ' ==> stop'
43 exit ; fi
44 fi
45 done
46 }
47
48 if test -f input_ocn/data.tst
49 then
50 noc0=`sed -n 's/nIter0=//p' input_ocn/data.tst | sed 's/,//g' | sed 's/ //g'`
51 Dbl=`sed -n 's/nTimeSteps=//p' input_ocn/data.tst | sed 's/,//g'`
52 NiOc=`expr $Dbl / 2`
53 Nit=$NiOc
54 else
55 echo " file: 'input_ocn/data.tst' not found"
56 NiOc=0 ; Nit=2
57 fi
58 if test -f input_atm/data.tst
59 then
60 nat0=`sed -n 's/nIter0=//p' input_atm/data.tst | sed 's/,//g' | sed 's/ //g'`
61 Dbl=`sed -n 's/nTimeSteps=//p' input_atm/data.tst | sed 's/,//g'`
62 NiAt=`expr $Dbl / 2`
63 else
64 echo " file: 'input_atm/data.tst' not found"
65 NiAt=0
66 fi
67
68 #- parse options:
69 CMD='run_cpl_test'
70 MTH=
71 argList=$*
72 for xx in $argList
73 do
74 if test $xx = '-mth' ; then MTH=$xx ; shift ; continue ; fi
75 if test -x ${CMD}_$xx ; then CMD="${CMD}_$xx" ; shift ; continue ; fi
76 done
77
78 if [ $# -ne 1 ]
79 then
80 echo "Usage: `basename $0` [opt] flag"
81 echo " Check restart of coupled set-up: compare 1 run of 2 x $Nit it long"
82 echo " with 2 consecutive runs of $Nit it long each"
83 echo "opt = -mth : run script '$CMD' with option '-mth'"
84 echo "opt = sufx : run script 'run_cpl_test_{sufx}'"
85 echo " where: flag = 0 -> prepare for 1rst run"
86 echo " flag = r1 -> do 1rst run and step 1"
87 echo " flag = 1 -> move res. after 1rst run & prepare for 2nd"
88 echo " flag = r2 -> do 2nd run and step 2"
89 echo " flag = 2 -> move res. after 2nd run & prepare for 3rd"
90 echo " flag = r3 -> do 3rd run and step 3"
91 echo " flag = 3 -> move res. after 3rd run"
92 echo " flag=(r)N+ , N=1,2,3 => do steps (+run) from: (r)N to 3"
93 echo " flag = 4 -> compare Ocean results"
94 echo " flag = 5 -> compare Atmos results"
95 echo " flag = 6 -> diff pickup files"
96 exit
97 fi
98 if test $NiAt = 0 -o $NiOc = 0
99 then
100 echo " needs 2 data files: 'input_ocn/data.tst' & 'input_atm/data.tst'"
101 echo " (corresponding to 1rst run) to continue"
102 exit
103 fi
104 arg1=$1
105 xx=`echo $arg1 | sed 's/\+$//'`
106 if test $xx != $arg1
107 then kUp=`echo $xx | sed 's/^r//'` ; arg1=$xx
108 else kUp=9 ; fi
109 xx=`echo $arg1 | sed 's/^r//'`
110 if test $xx != $arg1 ; then doRun=1 ; arg1=$xx ; else doRun=0 ; fi
111 ksel=$arg1
112
113 CMD="./${CMD} $MTH 3"
114 echo " doRun='$doRun' ; ksel='$ksel' ; kUp='$kUp' ; command='$CMD'"
115
116 #make sure that local dir & ~jmc/bin is in the path:
117 #export PATH=${PATH}:.
118
119 Nit=$NiOc
120 Dbl=`expr $Nit + $Nit`
121 noc1=`expr $noc0 + $Nit`
122 noc2=`expr $noc0 + $Dbl`
123 noc0c=`printf "%10.10i\n" $noc0`
124 noc1c=`printf "%10.10i\n" $noc1`
125 noc2c=`printf "%10.10i\n" $noc2`
126 echo ' Oce (rank_1):' $noc0 $noc1 $noc2
127 echo ' ' $noc0c $noc1c $noc2c
128
129 Nit=$NiAt
130 Dbl=`expr $Nit + $Nit`
131 nat1=`expr $nat0 + $Nit`
132 nat2=`expr $nat0 + $Dbl`
133 nat0c=`printf "%10.10i\n" $nat0`
134 nat1c=`printf "%10.10i\n" $nat1`
135 nat2c=`printf "%10.10i\n" $nat2`
136 echo ' Atm (rank_2):' $nat0 $nat1 $nat2
137 echo ' ' $nat0c $nat1c $nat2c
138
139 listOc="pickup"
140 listAt="pickup pickup_cpl pickup_ic pickup_land"
141
142 #- dir where to put the results :
143 dir1=res_2it
144 dir2=res_1iA
145 dir3=res_1iB
146
147 #-- after a run, rename pickup file to restart
148 if test $ksel = 0
149 then
150 echo ' '
151 cd rank_1
152 for xx in $listOc
153 do rnp_loc $xx.ckptA $xx.$noc0c
154 done
155 cd ../rank_2
156 for xx in $listAt
157 do rnp_loc $xx.ckptA $xx.$nat0c
158 done
159 cd ..
160 #-- prepare for running Dbl
161 echo '=> prepare for running Dbl:'
162 Dbl=`expr $NiOc + $NiOc`
163 sed "1 s/[0-9]*/$Dbl/" input_cpl/data > rank_0/data
164 cp -p input_ocn/data.tst rank_1/data
165 cp -p input_atm/data.tst rank_2/data
166 echo 'rank_0/data:' `head -1 rank_0/data`
167 egrep 'nIter0|nTimeSteps' rank_?/data
168 fi
169
170 #-- run & post-process Dbl:
171 if [ $ksel -eq 1 -o $kUp -le 1 ]
172 then
173 echo ' '
174 #-- run coupled test (Dbl):
175 if [ $doRun -eq 1 -o $kUp -lt 1 ]
176 then
177 echo "=> run (Dbl): $CMD"
178 $CMD
179 fi
180 #-- after running Dbl:
181 rm -rf $dir1
182 mkdir $dir1
183 echo '=> move STDOUT to' $dir1
184 mv rank_1/STDOUT* $dir1/ocnSTDOUT.2it
185 mv rank_2/STDOUT* $dir1/atmSTDOUT.2it
186
187 mkdir $dir1/ocn
188 cd rank_1
189 for xx in $listOc
190 do
191 rnp_loc $xx.ckptA $xx.$noc2c
192 done
193 echo 'move pickups to' $dir1/ocn
194 mv pickup*.$noc2c.* ../$dir1/ocn
195 cd ..
196
197 mkdir $dir1/atm
198 cd rank_2
199 for xx in $listAt
200 do
201 rnp_loc $xx.ckptA $xx.$nat2c
202 done
203 echo 'move pickups to' $dir1/atm
204 mv pickup*.$nat2c.* ../$dir1/atm
205 cd ..
206
207 #-- prepare for running 1iA
208 echo '=> prepare for running 1iA:'
209 Nit=$NiOc
210 Dbl=`expr $Nit + $Nit`
211 sed "1 s/[0-9]*/$Nit/" input_cpl/data > rank_0/data
212 sed "s/^ nTimeSteps=$Dbl/ nTimeSteps=$Nit/g" input_ocn/data.tst > rank_1/data
213 Nit=$NiAt
214 Dbl=`expr $Nit + $Nit`
215 sed "s/^ nTimeSteps=$Dbl/ nTimeSteps=$Nit/g" input_atm/data.tst > rank_2/data
216 echo 'rank_0/data:' `head -1 rank_0/data`
217 egrep 'nIter0|nTimeSteps' rank_?/data
218 fi
219
220 #-- run & post-process 1iA:
221 if [ $ksel -eq 2 -o $kUp -le 2 ]
222 then
223 echo ' '
224 #-- run coupled test (1iA):
225 if [ $doRun -eq 1 -o $kUp -lt 2 ]
226 then
227 echo "=> run (1iA): $CMD"
228 $CMD
229 fi
230 #-- after running 1iA
231 rm -rf $dir2
232 mkdir $dir2
233 echo '=> move STDOUT to' $dir2
234 mv rank_1/STDOUT* $dir2/ocnSTDOUT.1iA
235 mv rank_2/STDOUT* $dir2/atmSTDOUT.1iA
236
237 mkdir $dir2/ocn
238 cd rank_1
239 for xx in $listOc
240 do
241 rnp_loc $xx.ckptA $xx.$noc1c
242 done
243 echo 'move pickups to' $dir2/ocn
244 mv pickup*.$noc1c.* ../$dir2/ocn
245 cd ..
246
247 mkdir $dir2/atm
248 cd rank_2
249 for xx in $listAt
250 do
251 rnp_loc $xx.ckptA $xx.$nat1c
252 done
253 echo 'move pickups to' $dir2/atm
254 mv pickup*.$nat1c.* ../$dir2/atm
255 cd ..
256
257 #-- prepare for running 1iB
258 echo '=> prepare for running 1iB:'
259 cd rank_1
260 sed "s/^ nIter0=$noc0/ nIter0=$noc1/g" data > data.tmp
261 mv -f data.tmp data
262 ln -s ../$dir2/ocn/* .
263 cd ../rank_2
264 sed "s/^ nIter0=$nat0/ nIter0=$nat1/g" data > data.tmp
265 mv -f data.tmp data
266 ln -s ../$dir2/atm/* .
267 cd ..
268 echo 'rank_0/data:' `head -1 rank_0/data`
269 egrep 'nIter0|nTimeSteps' rank_?/data
270 fi
271
272 #-- run & post-process 1iB:
273 if [ $ksel -eq 3 -o $kUp -le 3 ]
274 then
275 echo ' '
276 #-- run coupled test (1iB):
277 if [ $doRun -eq 1 -o $kUp -lt 3 ]
278 then
279 echo "=> run (1iB): $CMD"
280 $CMD
281 fi
282 #-- after running 1iB
283 rm -rf $dir3
284 mkdir $dir3
285 echo '=> move STDOUT to' $dir3
286 mv rank_1/STDOUT* $dir3/ocnSTDOUT.1iB
287 mv rank_2/STDOUT* $dir3/atmSTDOUT.1iB
288
289 mkdir $dir3/ocn
290 cd rank_1
291 for xx in $listOc
292 do rnp_loc $xx.ckptA $xx.$noc2c
293 done
294 echo 'move pickups to' $dir3/ocn
295 mv pickup*.$noc2c.* ../$dir3/ocn
296 rm -f pickup*.$noc1c.*
297 cd ..
298
299 mkdir $dir3/atm
300 cd rank_2
301 for xx in $listAt
302 do rnp_loc $xx.ckptA $xx.$nat2c
303 done
304 echo 'move pickups to' $dir3/atm
305 mv pickup*.$nat2c.* ../$dir3/atm
306 rm -f pickup*.$nat1c.*
307 cd ..
308 echo '=> restore std data files'
309 cp -p input_cpl/data rank_0
310 cp -p input_ocn/data rank_1
311 cp -p input_atm/data rank_2
312 fi
313
314 #-- compare output:
315 if test $ksel = 4
316 then
317 rm -f ocn.txt
318 echo ' run 2it: ---------- ' > tmp1.txt
319 grep "cg2d_init_res" $dir1/ocnSTDOUT.2it \
320 | sed 's/.* cg2d_init_res =//' >> tmp1.txt
321 Nit=`expr $NiOc + 2`
322 sed "$Nit i \ ... 2it continue ..." tmp1.txt > tmp2.txt
323 rm -f tmp1.txt
324 echo ' run 1iA: ---------- ' > tmp1.txt
325 grep "cg2d_init_res" $dir2/ocnSTDOUT.1iA \
326 | sed 's/.* cg2d_init_res =//' >> tmp1.txt
327 echo ' run 1iB: ---------- ' >> tmp1.txt
328 grep "cg2d_init_res" $dir3/ocnSTDOUT.1iB \
329 | sed 's/.* cg2d_init_res =//' >> tmp1.txt
330 nl tmp1.txt > tmp1.ttt
331 nl tmp2.txt > tmp2.ttt
332 join tmp1.ttt tmp2.ttt | sed 's/[0-9]*//' > ocn.txt
333 rm -f tmp1.ttt tmp2.ttt tmp1.txt tmp2.txt
334 echo ' ' ; echo '-- compare cg2d_init_res (Ocean):'
335 cat ocn.txt
336 exit
337 fi
338
339 if test $ksel = 5
340 then
341 rm -f atm.txt
342 echo ' run 2it: ---------- ' > tmp1.txt
343 grep "cg2d_init_res" $dir1/atmSTDOUT.2it \
344 | sed 's/.* cg2d_init_res =//' >> tmp1.txt
345 Nit=`expr $NiAt + 2`
346 sed "$Nit i \ ... 2it continue ..." tmp1.txt > tmp2.txt
347 rm -f tmp1.txt
348 echo ' run 1iA: ---------- ' > tmp1.txt
349 grep "cg2d_init_res" $dir2/atmSTDOUT.1iA \
350 | sed 's/.* cg2d_init_res =//' >> tmp1.txt
351 echo ' run 1iB: ---------- ' >> tmp1.txt
352 grep "cg2d_init_res" $dir3/atmSTDOUT.1iB \
353 | sed 's/.* cg2d_init_res =//' >> tmp1.txt
354 nl tmp1.txt > tmp1.ttt
355 nl tmp2.txt > tmp2.ttt
356 join tmp1.ttt tmp2.ttt | sed 's/[0-9]*//' > atm.txt
357 rm -f tmp1.ttt tmp2.ttt tmp1.txt tmp2.txt
358 echo ' ' ; echo '-- compare cg2d_init_res (Atmos):'
359 cat atm.txt
360 exit
361 fi
362
363 #- compare pickup file:
364 if test $ksel = 6
365 then
366 echo ' ' ; echo '=== compare Ocn pickups: =============='
367 for xx in $listOc
368 do
369 dif_tiles $dir1/ocn $dir3/ocn $xx.$noc2c
370 done
371 echo ' ' ; echo '=== compare Atm pickups: =============='
372 for xx in $listAt
373 do
374 dif_tiles $dir1/atm $dir3/atm $xx.$nat2c
375 done
376 exit
377 fi

  ViewVC Help
Powered by ViewVC 1.1.22