/[MITgcm]/MITgcm/tools/example_scripts/csail/test_baudelaire
ViewVC logotype

Contents of /MITgcm/tools/example_scripts/csail/test_baudelaire

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


Revision 1.34 - (show annotations) (download)
Sat May 13 16:22:16 2017 UTC (6 years, 11 months ago) by jmc
Branch: MAIN
Changes since 1.33: +57 -9 lines
before making a copy, check that code has been updated

1 #! /usr/bin/env bash
2
3 # $Header: /u/gcmpack/MITgcm/tools/example_scripts/csail/test_baudelaire,v 1.33 2017/04/22 14:52:51 jmc Exp $
4
5 # Test script for MITgcm that should work on most of the csail.mit.edu Linux machines.
6
7 tst_grp=0 ; if test $# = 1 ; then tst_grp=$1 ; fi
8 if test $tst_grp != 'a' -a $tst_grp != 'b' ; then
9 echo "missing or invalid argument (expect: 'a' or 'b') ==> exit"
10 exit 1
11 fi
12
13 # defaults
14 #export PATH="$PATH:/usr/local/bin"
15 if [ -d ~/bin ]; then export PATH=$PATH:~/bin ; fi
16 #- to get case insensitive "ls" (and order of tested experiments)
17 export LC_ALL="en_US.UTF-8"
18 # Turn off stack limit for FIZHI & AD-tests
19 ulimit -s unlimited
20 # MPI test (for now, only with gfortran)
21 export MPI_GCC_DIR=/srv/software/gcc/gcc-packages/gcc-4.4.5/mpich2/mpich2-1.3
22 export MPI_INC_DIR=$MPI_GCC_DIR/include
23 export PATH="$PATH:$MPI_GCC_DIR/bin"
24
25 #- method to acces CVS:
26 # export CVSROOT='/u/gcmpack'
27 # export CVSROOT=':ext:@mitgcm.org:/u/gcmpack'
28 # export CVS_RSH='ssh' ; cvs co -P MITgcm > /dev/null
29 # cvs -d :pserver:cvsanon@mitgcm.org:/u/gcmpack co -P MITgcm > /dev/null
30 cmdCVS='cvs -d :pserver:cvsanon@mitgcm.org:/u/gcmpack'
31 cmdCVS='cvs -d /u/gcmpack'
32
33 # checkOut=2 : download new code ;
34 # =3 : skip download but, if sepDir, use a new copy
35 # =1 : update code (if no existing code -> swith to 2)
36 # =0 : use existing code (if no existing code -> swith to 2)
37 dInWeek=`date +%a`
38
39 dNam=`hostname -s | tr '[:upper:]' '[:lower:]'`
40 TESTDIR="/scratch/jmc/test_${dName}"
41 outDir=`hostname -s`
42 MC=13
43 sepDir=1
44 option=
45
46 #tst_list='g7a adm mpa g77 gfo+rs mth mp2+rs mpi ifc'
47 #if test "x$dInWeek" = xSun ; then tst_list="$tst_list tlm oad" ; fi
48 if test $tst_grp = 'a' ; then
49 checkOut=2
50 tst_list='g7a mpa mth mp2+rs mpi oad'
51 else
52 checkOut=3
53 tst_list='adm g77 gfo+rs ifc'
54 if test "x$dInWeek" = xSun ; then tst_list="$tst_list tlm" ; fi
55 fi
56 echo " test: $outDir ; list='$tst_list'"
57
58 #option="-nc" ; checkOut=1
59 #option="-q" ; checkOut=1
60
61 TODAY=`date +%d`
62 tdir=$TESTDIR
63 updFile='updated_code' ; today=`date +%Y%m%d`
64 if test $checkOut != 2 ; then
65 if test -e $tdir/MITgcm/CVS ; then
66 echo $tdir/MITgcm/CVS 'exist'
67 if test $sepDir = 0 -a $checkOut = 1 ; then
68 #- remove date/lock-file:
69 if test -f $tdir/$updFile ; then rm -f $tdir/$updFile ; sleep 2 ; fi
70 echo -n "Update the MITgcm code using: $cmdCVS ..."
71 cd $tdir/MITgcm
72 $cmdCVS update -P -d
73 echo " done"
74 #- update date/lock-file:
75 ( cd $tdir ; echo $today > $updFile
76 sleep 2 ; ls -l $updFile )
77 fi
78 else
79 echo -n $tdir/MITgcm 'missing ; '
80 checkOut=2
81 fi
82 fi
83 if test $checkOut = 2 ; then
84 if test -e $tdir ; then
85 echo -n "Removing working copy: $tdir/MITgcm ..."
86 test -e $tdir/MITgcm && rm -rf $tdir/MITgcm
87 else
88 echo -n "Creating a working dir: $tdir ..."
89 mkdir $tdir
90 fi
91 echo " done"
92 cd $tdir
93 #- remove date/lock-file:
94 if test -f $updFile ; then rm -f $updFile ; sleep 2 ; fi
95 echo -n "Downloading the MITgcm code using: $cmdCVS ..."
96 $cmdCVS co -P MITgcm > /dev/null
97 echo " done"
98 if test -d other_input ; then
99 list_dirs=`(cd other_input ; ls 2> /dev/null )`
100 echo "Updating ( $cmdCVS update -P -d ) 'other_input' extra dirs:"
101 for exd in $list_dirs ; do
102 if test -d other_input/$exd/CVS ; then echo " $exd"
103 ( cd other_input/$exd ; $cmdCVS update -P -d )
104 fi
105 done
106 echo " <-- update of 'other_input' dirs done"
107 fi
108 #- update date/lock-file:
109 echo $today > $updFile ; sleep 2 ; ls -l $updFile
110 else
111 cd $tdir
112 fi
113
114 #------------------------------------------------------------------------
115
116 firstTst=`echo $tst_list | awk '{print $1}'`
117 last_Tst=`echo $tst_list | awk '{print $NF}'`
118 for tt in $tst_list
119 do
120
121 echo "================================================================"
122 typ=`echo $tt | sed 's/+rs//'`
123 #- define list of additional experiences to test:
124 addExp=''
125 if test $typ = 'mp2' -o $typ = 'ifc' ; then
126 addExp="offline_cheapaml atm_gray"
127 fi
128 if test $typ = 'gfo' -o $typ = 'ifc' ; then
129 addExp="$addExp global_oce_biogeo_bling"
130 addExp="$addExp shelfice_remeshing"
131 fi
132 if test $typ = 'mpi' ; then
133 addExp="$addExp global_oce_cs32"
134 fi
135 #- check day and time:
136 curDay=`date +%d` ; curHour=`date +%H`
137 if [ $curDay -ne $TODAY ] ; then
138 date ; echo "day is over => skip test $typ"
139 continue
140 fi
141 if [ $curHour -ge 18 ] ; then
142 date ; echo "too late to run test $typ"
143 continue
144 fi
145 if test $sepDir = 0 -a "x$option" != x -a $tt != $last_Tst ; then
146 echo "using option='$option' prevent multi-tests => skip test $typ"
147 continue
148 fi
149 #- clean-up old output files
150 rm -f $tdir/output_${typ}*
151 touch $tdir/output_$tt
152 if test $sepDir = 1 ; then
153 new_dir="MITgcm_$typ"
154 reUse=1 ; if [ $checkOut -ge 2 ] ; then reUse=0 ; fi
155 if test -d $new_dir/CVS -a $reUse = 1 ; then
156 cd $tdir/$new_dir
157 if test $tt != $typ ; then
158 ( cd verification ; ../tools/do_tst_2+2 -clean )
159 fi
160 if test $checkOut = 1 ; then
161 echo -n "Update the MITgcm code using: $cmdCVS ..."
162 $cmdCVS update -P -d
163 echo " done"
164 fi
165 else
166 if test -d prev ; then
167 #-- save previous summary:
168 oldS=`ls -t ${new_dir}/verification/tr_${outDir}_*/summary.txt 2> /dev/null | head -1`
169 if test "x$oldS" != x ; then
170 cat $oldS | sed '/^[YN] [YN] [YN] [YN]/ s/ \. //g' > prev/tr_out.$typ
171 touch -r $oldS prev/tr_out.$typ
172 fi
173 if test $tt != $typ ; then
174 oldS=`ls -t ${new_dir}/verification/rs_${outDir}_*/summary.txt 2> /dev/null | head -1`
175 if test "x$oldS" != x ; then cp -p -f $oldS prev/rs_out.$typ ; fi
176 fi
177 fi
178 test -e $new_dir && rm -rf $new_dir
179 mkdir $new_dir
180 #- before making a copy, check that code has been updated
181 nCount=0; today=`date +%Y%m%d`
182 updDate=0 ; test -f $updFile && updDate=`cat $updFile`
183 while [ $today -gt $updDate ] ; do
184 nCount=`expr $nCount + 1`
185 if [ $nCount -gt 40 ] ; then
186 echo " waiting too long (nCount=$nCount) for updated code"
187 echo " today=$today , updDate=$updDate "
188 ls -l $updFile
189 exit
190 fi
191 sleep 60
192 updDate=0 ; test -f $updFile && updDate=`cat $updFile`
193 done
194 ls -l $updFile | tee -a $tdir/output_$tt
195 echo " waited nCount=$nCount for updated code ($updDate) to copy" | tee -a $tdir/output_$tt
196 #-----------------------------
197 if test -d MITgcm -a -d $new_dir ; then
198 echo " copy main code from MITgcm to $new_dir" | tee -a $tdir/output_$tt
199 cp -ra MITgcm/* $new_dir 2>&1 | tee -a $tdir/output_$tt
200 else
201 if test -d MITgcm ; then
202 echo " missing dir $new_dir --> end test $tt" | tee -a $tdir/output_$tt
203 else
204 echo " missing dir MITgcm --> end test $tt" | tee -a $tdir/output_$tt
205 fi
206 continue
207 fi
208 echo -n " cd $tdir/$new_dir " | tee -a $tdir/output_$tt
209 cd $tdir/$new_dir
210 retVal=$?
211 ( echo "(retVal= $retVal )" ; pwd ) | tee -a $tdir/output_$tt
212 if test -d verification ; then
213 echo " check: dir verification exist" | tee -a $tdir/output_$tt
214 else
215 echo " missing dir verification --> end test $tt" | tee -a $tdir/output_$tt
216 continue
217 fi
218 #-- download additional experience from Contrib:
219 for exp2add in $addExp ; do
220 echo " add dir: $exp2add (from Contrib:verification_other)"
221 ( cd verification ; $cmdCVS co -P -d $exp2add \
222 MITgcm_contrib/verification_other/$exp2add > /dev/null )
223 if test $exp2add = 'global_oce_cs32' ; then
224 echo " link dir 'other_input/core2_cnyf' in here"
225 ( cd verification/${exp2add}
226 ln -s ../../../other_input/core2_cnyf . )
227 fi
228 if test $exp2add = 'shelfice_remeshing' ; then
229 echo " link dir 'other_input/remeshing_code' to 'extra_code'"
230 ( cd verification/${exp2add}
231 ln -s ../../../other_input/remeshing_code extra_code )
232 fi
233 done
234 fi
235 else
236 cd $tdir/MITgcm
237 fi
238 cd verification
239
240 #-- set the testreport command:
241 comm="./testreport"
242 if test $typ = 'g7a' -o $typ = 'adm' -o $typ = 'mpa' ; then
243 comm="$comm -adm"
244 elif test $typ = 'oad' ; then
245 comm="$comm -oad"
246 elif test $typ = 'tlm' ; then
247 comm="$comm -tlm"
248 elif test $typ = 'mth' -o $typ = 'mp2' ; then
249 export GOMP_STACKSIZE=400m
250 export OMP_NUM_THREADS=2
251 comm="$comm -mth"
252 else
253 comm="$comm -md cyrus-makedepend"
254 fi
255 comm="$comm -odir $outDir -a jmc@dev.mitgcm.org"
256 #-- set the optfile (+ mpi & match-precision)
257 MPI=0
258 case $typ in
259 'g77'|'g7a') OPTFILE='../tools/build_options/linux_amd64_g77' ;;
260 'gfo'|'adm'|'oad'|'tlm'|'mth') comm="$comm -match $MC -devel"
261 OPTFILE='../tools/build_options/linux_amd64_gfortran' ;;
262 'ifc') comm="$comm -devel"
263 OPTFILE='../tools/build_options/linux_amd64_ifort11' ;;
264 'pgi') OPTFILE='../tools/build_options/linux_amd64_pgf77' ;;
265 'mpa'|'mpi'|'mp2') comm="$comm -match $MC -devel" ; MPI=6
266 OPTFILE='../tools/build_options/linux_amd64_gfortran' ;;
267 *) OPTFILE= ;;
268 esac
269 #-- set MPI command:
270 if test $MPI != 0 ; then
271 if test $typ = 'mp2' ; then MPI=3 ; fi
272 if test $typ = 'mpa' ; then
273 EXE="mpirun -np TR_NPROC ./mitgcmuv_ad"
274 else
275 EXE="mpirun -np TR_NPROC ./mitgcmuv"
276 fi
277 fi
278
279 #-- set specific Env Vars:
280 if test $typ = 'oad' ; then
281 source ~jmc/mitgcm/bin/setenv_OpenAD.sh
282 fi
283 if test $typ = 'ifc' ; then
284 source /srv/software/intel/intel-11.1.073/bin/ifortvars.sh intel64
285 fi
286 if test $typ = 'pgi' ; then
287 #listT='fizhi-cs-32x32x40 fizhi-cs-aqualev20'
288 export PGI=/srv/software/pgi/pgi-10.9
289 export PATH="$PATH:$PGI/linux86-64/10.9/bin"
290 export LM_LICENSE_FILE=$PGI/license.dat
291 fi
292
293 if test $sepDir = 0 -a "x$option" = x -a $tt = $firstTst -a $checkOut != 2 ; then
294 #-- cleaning:
295 echo "======================"
296 echo "Cleaning test directories:" | tee -a $tdir/output_$tt
297 cmdCLN="./testreport -clean"
298 echo " clean dir running: $cmdCLN" | tee -a $tdir/output_$tt
299 $cmdCLN >> $tdir/output_$tt 2>&1
300 echo "======================"
301 echo "" | tee -a $tdir/output_$tt
302 fi
303
304 #-- run the testreport command:
305 echo -n "Running testreport using:" | tee -a $tdir/output_$tt
306 if test "x$OPTFILE" != x ; then
307 comm="$comm -of=$OPTFILE"
308 fi
309 if test $MPI = 0 ; then echo '' | tee -a $tdir/output_$tt
310 else echo " (EXE='$EXE')" | tee -a $tdir/output_$tt
311 comm="$comm -MPI $MPI -command \"\$EXE\""
312 fi
313 if test "x$option" != x ; then comm="$comm $option" ; fi
314 #if test $typ = 'pgi' ; then comm="$comm -t \"\$listT\"" ; fi
315 echo " \"eval $comm\"" | tee -a $tdir/output_$tt
316 echo "======================"
317 eval $comm >> $tdir/output_$tt 2>&1
318 sed -n "/^An email /,/^======== End of testreport / p" $tdir/output_$tt
319 echo "" | tee -a $tdir/output_$tt
320
321 #-- also test restart (test 2+2=4)
322 if test $tt != $typ
323 then
324 echo "testing restart using:" | tee -a $tdir/output_$tt
325 comm="../tools/do_tst_2+2 -o $outDir -a jmc@dev.mitgcm.org"
326 if test $MPI = 0 ; then
327 echo " \"$comm\"" | tee -a $tdir/output_$tt
328 echo "======================"
329 $comm >> $tdir/output_$tt 2>&1
330 else
331 echo " \"$comm -mpi -exe $EXE\"" | tee -a $tdir/output_$tt
332 echo "======================"
333 $comm -mpi -exe "$EXE" >> $tdir/output_$tt 2>&1
334 fi
335 echo ; cat tst_2+2_out.txt
336 echo
337 fi
338 export OMP_NUM_THREADS=1
339
340 if test $sepDir = 0 ; then
341 #-- cleaning:
342 echo "======================"
343 echo "Cleaning test directories:" | tee -a $tdir/output_$tt
344 if test $tt != $typ ; then
345 cmdCLN="../tools/do_tst_2+2 -clean"
346 echo " clean tst_2+2 running: $cmdCLN" | tee -a $tdir/output_$tt
347 $cmdCLN >> $tdir/output_$tt 2>&1
348 fi
349 if test $tt != $last_Tst ; then
350 cmdCLN="./testreport -clean"
351 echo " clean dir running: $cmdCLN" | tee -a $tdir/output_$tt
352 $cmdCLN >> $tdir/output_$tt 2>&1
353 fi
354 echo "======================"
355 echo
356 fi
357 cd $tdir
358
359 done

  ViewVC Help
Powered by ViewVC 1.1.22