/[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.3 - (show annotations) (download)
Wed Nov 7 01:40:47 2007 UTC (16 years, 5 months ago) by jmc
Branch: MAIN
Changes since 1.2: +60 -36 lines
don't need additional scripts anymore

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

  ViewVC Help
Powered by ViewVC 1.1.22