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

Annotation of /MITgcm_contrib/jmc_script/tst_2+2_cpl

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


Revision 1.6 - (hide annotations) (download)
Mon Sep 14 18:52:21 2009 UTC (14 years, 7 months ago) by jmc
Branch: MAIN
Changes since 1.5: +2 -2 lines
updated

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

  ViewVC Help
Powered by ViewVC 1.1.22