/[MITgcm]/MITgcm_contrib/test_scripts/ref_machine/test_baudelaire
ViewVC logotype

Annotation of /MITgcm_contrib/test_scripts/ref_machine/test_baudelaire

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


Revision 1.4 - (hide annotations) (download)
Sat Feb 24 17:33:55 2018 UTC (7 years, 4 months ago) by jmc
Branch: MAIN
Changes since 1.3: +17 -8 lines
- test for "git pull" success, exit if it failed
- remove existing dir before making a new clone

1 jmc 1.1 #! /usr/bin/env bash
2    
3 jmc 1.4 # $Header: /u/gcmpack/MITgcm_contrib/test_scripts/ref_machine/test_baudelaire,v 1.3 2018/02/02 14:33:13 jmc Exp $
4 jmc 1.1
5     # Test script for MITgcm that should work on most of the x86_64 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     cmdCVS='cvs -d :pserver:cvsanon@mitgcm.org:/u/gcmpack'
27     cmdCVS='cvs -d /u/gcmpack'
28     # export CVS_RSH=ssh
29     # cmdCVS='cvs -q -d :ext:jmc@mitgcm.org:/u/gcmpack'
30    
31     #- and which GitHub repository to use:
32 jmc 1.3 git_repo='MITgcm'; git_code='MITgcm'
33     #git_repo='altMITgcm'; #git_code='MITgcm66h'
34 jmc 1.1
35     # checkOut=3 : clone from GitHub and make a new copy (if sepDir)
36     # =2 : update (git pull) repo and make a new copy code (switch to 2 if no repo)
37     # =1 : skip update but use a new copy (if sepDir)
38     # =0 : use existing test code ( switch to 1 if missing test code )
39     dInWeek=`date +%a`
40    
41     dNam=`hostname -s | tr '[:upper:]' '[:lower:]'`
42     #TESTDIR="$HOME/test_${dNam}"
43     #outDir=$dNam
44     #MC=11
45     TESTDIR="/scratch/jmc/test_${dNam}"
46     outDir="${dNam}-${tst_grp}"
47     MC=13
48     sepDir=1
49     option=
50    
51     if test $tst_grp = 'a' ; then
52     checkOut=2
53     tst_list='g7a mpa mth mp2+rs mpi oad'
54     #tst_list='mpa adm mpi gfo+rs mth+rs'
55     #tst_list="$tst_list oad"
56     else
57     checkOut=1
58     tst_list='adm g77 gfo+rs ifc'
59     if test "x$dInWeek" = xSun ; then tst_list="$tst_list tlm" ; fi
60     fi
61     echo " test: $outDir ; list='$tst_list'"
62    
63     #option="-nc" ; checkOut=0
64     #option="-q" ; checkOut=0
65    
66     TODAY=`date +%d`
67     tmpFil="/tmp/"`basename $0`".$$"
68     tdir=$TESTDIR
69     updFile='updated_code' ; today=`date +%Y%m%d`
70    
71     if [ $checkOut -le 1 ] ; then
72     if test -e $tdir/MITgcm_today/doc ; then
73     echo $tdir/MITgcm_today/doc 'exist'
74     else
75     echo -n $tdir/MITgcm_today 'missing ; '
76     checkOut=2
77     echo "will make a new copy ( checkOut=$checkOut )"
78     fi
79     fi
80    
81     if [ $checkOut -ge 2 ] ; then
82     #---- cleaning:
83     if test -e $tdir ; then
84     #- remove date/lock-file:
85     if test -f $tdir/$updFile ; then rm -f $tdir/$updFile ; sleep 2 ; fi
86     echo -n "Removing working copy: $tdir/MITgcm_today ..."
87     test -e $tdir/MITgcm_today && rm -rf $tdir/MITgcm_today
88     else
89     echo -n "Creating a working dir: $tdir ..."
90     mkdir $tdir
91     fi
92     echo " done"
93     cd $tdir
94    
95     #---- Making a new clone or updating existing one:
96 jmc 1.4 if [ $checkOut -eq 2 ] ; then
97     if test -e MITgcm/.git/config ; then
98     echo MITgcm/.git/config 'exist'
99     else
100     echo -n MITgcm/.git/config 'missing ; '
101     checkOut=3
102     echo "will get new clone ( checkOut=$checkOut )"
103     fi
104 jmc 1.1 fi
105     if [ $checkOut -eq 3 ] ; then
106 jmc 1.4 test -e $git_code && rm -rf $git_code
107 jmc 1.1 echo -n "Make a clone of $git_code from repo: $git_repo ..."
108     git clone https://github.com/$git_repo/${git_code}.git 2> $tmpFil
109     retVal=$?
110     if test $retVal = 0 ; then
111     echo ' --> done!'
112     rm -f $tmpFil
113     else
114     echo " Error: 'git clone' returned: $retVal"
115     cat $tmpFil
116     rm -f $tmpFil
117     exit 2
118     fi
119     else
120     echo "Updating current clone ( $git_code ) ..."
121     ( cd $git_code ; git pull )
122 jmc 1.4 retVal=$?
123     if test $retVal = 0 ; then
124     echo ' --> done!'
125     else
126     echo "git pull on '"`hostname`"' fail (return val=$retVal) => exit"
127     exit 3
128     fi
129 jmc 1.1 fi
130    
131     #---- making a new working copy: MITgcm_today
132     ( cd $git_code ; git checkout master )
133     # mkdir MITgcm_today
134     # cp -p -ra $git_code/* MITgcm_today
135     rsync -a $git_code/ MITgcm_today --exclude '.git'
136     #---- updating "other_input" dir
137     if test -d other_input ; then
138     list_dirs=`(cd other_input ; ls 2> /dev/null )`
139     echo "Updating ( $cmdCVS update -P -d ) 'other_input' extra dirs:"
140     for exd in $list_dirs ; do
141     if test -d other_input/$exd/CVS ; then echo " $exd"
142     ( cd other_input/$exd ; $cmdCVS update -P -d )
143     fi
144     done
145     echo " <-- update of 'other_input' dirs done"
146     fi
147     #---- update date/lock-file:
148     echo $today > $updFile ; sleep 2 ; ls -l $updFile
149     else
150     cd $tdir
151     fi
152    
153     #------------------------------------------------------------------------
154    
155     firstTst=`echo $tst_list | awk '{print $1}'`
156     last_Tst=`echo $tst_list | awk '{print $NF}'`
157     for tt in $tst_list
158     do
159    
160     echo "================================================================"
161     typ=`echo $tt | sed 's/+rs//'`
162     #- define list of additional experiences to test:
163     addExp=''
164     if test $typ = 'mp2' -o $typ = 'ifc' ; then
165     addExp="offline_cheapaml atm_gray"
166     fi
167     if test $typ = 'gfo' -o $typ = 'ifc' ; then
168     addExp="$addExp global_oce_biogeo_bling"
169     addExp="$addExp shelfice_remeshing"
170     fi
171     if test $typ = 'mpi' ; then
172     #addExp="$addExp global_ocean.gm_k3d"
173     addExp="$addExp global_oce_cs32"
174     fi
175     #- check day and time:
176     curDay=`date +%d` ; curHour=`date +%H`
177     if [ $curDay -ne $TODAY ] ; then
178     date ; echo "day is over => skip test $typ"
179     continue
180     fi
181     if [ $curHour -ge 18 ] ; then
182     date ; echo "too late to run test $typ"
183     continue
184     fi
185     if test $sepDir = 0 -a "x$option" != x -a $tt != $last_Tst ; then
186     echo "using option='$option' prevent multi-tests => skip test $typ"
187     continue
188     fi
189     #- clean-up old output files
190     if test -d $tdir/prev ; then
191     mv -f $tdir/output_${typ}* $tdir/prev
192     else
193     rm -f $tdir/output_${typ}*
194     fi
195     touch $tdir/output_$tt
196     echo -n "-- Starting test: $tt at: " >> $tdir/output_$tt
197     date >> $tdir/output_$tt
198     echo " typ='$typ', addExp='$addExp'" >> $tdir/output_$tt
199     if test $sepDir = 1 ; then
200     new_dir="MITgcm_$typ"
201     reUse=0 ; if [ $checkOut -le 0 ] ; then reUse=1 ; fi
202     if test -d $new_dir/CVS -a $reUse = 1 ; then
203     cd $tdir/$new_dir
204     if test $tt != $typ ; then
205     ( cd verification ; ../tools/do_tst_2+2 -clean )
206     fi
207     else
208     if test -d prev ; then
209     #-- save previous summary:
210     oldS=`ls -t ${new_dir}/verification/tr_${outDir}_*/summary.txt 2> /dev/null | head -1`
211     if test "x$oldS" != x ; then
212     cat $oldS | sed '/^[YN] [YN] [YN] [YN]/ s/ \. //g' > prev/tr_out.$typ
213     touch -r $oldS prev/tr_out.$typ
214     fi
215     if test $tt != $typ ; then
216     oldS=`ls -t ${new_dir}/verification/rs_${outDir}_*/summary.txt 2> /dev/null | head -1`
217     if test "x$oldS" != x ; then cp -p -f $oldS prev/rs_out.$typ ; fi
218     fi
219     fi
220     echo " remove dir: $new_dir and make new one" >> $tdir/output_$tt
221     test -e $new_dir && rm -rf $new_dir
222     mkdir $new_dir
223     #- before making a copy, check that code has been updated
224     nCount=0; today=`date +%Y%m%d`
225     updDate=0 ; test -f $updFile && updDate=`cat $updFile`
226     while [ $today -gt $updDate ] ; do
227     nCount=`expr $nCount + 1`
228     if [ $nCount -gt 40 ] ; then
229     echo " waiting too long (nCount=$nCount) for updated code"
230     echo " today=$today , updDate=$updDate "
231     ls -l $updFile
232     exit
233     fi
234     sleep 60
235     updDate=0 ; test -f $updFile && updDate=`cat $updFile`
236     done
237     ls -l $updFile | tee -a $tdir/output_$tt
238     echo " waited nCount=$nCount for updated code ($updDate) to copy" | tee -a $tdir/output_$tt
239     #-----------------------------
240     if test -d MITgcm_today -a -d $new_dir ; then
241     echo " copy main code from MITgcm_today to $new_dir" | tee -a $tdir/output_$tt
242     cp -ra MITgcm_today/* $new_dir 2>&1 | tee -a $tdir/output_$tt
243     else
244     if test -d MITgcm_today ; then
245     echo " missing dir $new_dir --> end test $tt" | tee -a $tdir/output_$tt
246     else
247     echo " missing dir MITgcm_today --> end test $tt" | tee -a $tdir/output_$tt
248     fi
249     continue
250     fi
251     echo -n " cd $tdir/$new_dir " | tee -a $tdir/output_$tt
252     cd $tdir/$new_dir
253     retVal=$?
254     ( echo "(retVal= $retVal )" ; pwd ) | tee -a $tdir/output_$tt
255     if test -d verification ; then
256     echo " check: dir verification exist" | tee -a $tdir/output_$tt
257     else
258     echo " missing dir verification --> end test $tt" | tee -a $tdir/output_$tt
259     continue
260     fi
261     #-- download additional experience from Contrib:
262     for exp2add in $addExp ; do
263     echo " add dir: $exp2add (from Contrib:verification_other)" | tee -a $tdir/output_$tt
264     ( cd verification ; $cmdCVS co -P -d $exp2add \
265     MITgcm_contrib/verification_other/$exp2add > /dev/null )
266     if test $exp2add = 'global_oce_cs32' ; then
267     echo " link dir 'other_input/core2_cnyf' in here" | tee -a $tdir/output_$tt
268     ( cd verification/${exp2add}
269     ln -s ../../../other_input/core2_cnyf . )
270     fi
271     if test $exp2add = 'shelfice_remeshing' ; then
272     echo " link dir 'other_input/remeshing_code' to 'extra_code'" | tee -a $tdir/output_$tt
273     ( cd verification/${exp2add}
274     ln -s ../../../other_input/remeshing_code extra_code )
275     fi
276     done
277     fi
278     else
279     cd $tdir/MITgcm_today
280     fi
281     cd verification
282    
283     #-- set the testreport command:
284     comm="./testreport"
285     if test $typ = 'g7a' -o $typ = 'adm' -o $typ = 'mpa' ; then
286     comm="$comm -adm"
287     elif test $typ = 'oad' ; then
288     comm="$comm -oad"
289     elif test $typ = 'tlm' ; then
290     comm="$comm -tlm"
291     elif test $typ = 'mth' -o $typ = 'mp2' ; then
292     export GOMP_STACKSIZE=400m
293     export OMP_NUM_THREADS=2
294     comm="$comm -mth"
295     else
296     comm="$comm -md cyrus-makedepend"
297     fi
298     comm="$comm -odir $outDir -a jm_c@mitgcm.org"
299     #-- set the optfile (+ mpi & match-precision)
300     MPI=0
301     case $typ in
302     'g77'|'g7a') OPTFILE='../tools/build_options/linux_amd64_g77' ;;
303     'gfo'|'adm'|'oad'|'tlm'|'mth') comm="$comm -match $MC -devel"
304     OPTFILE='../tools/build_options/linux_amd64_gfortran' ;;
305     'ifc') comm="$comm -devel"
306     OPTFILE='../tools/build_options/linux_amd64_ifort11' ;;
307     'pgi') OPTFILE='../tools/build_options/linux_amd64_pgf77' ;;
308     'mpa'|'mpi'|'mp2') comm="$comm -match $MC -devel" ; MPI=6
309     OPTFILE='../tools/build_options/linux_amd64_gfortran' ;;
310     *) OPTFILE= ;;
311     esac
312     #-- set MPI command:
313     if test $MPI != 0 ; then
314     if test $typ = 'mp2' ; then MPI=3 ; fi
315     if test $typ = 'mpa' ; then
316     EXE="mpirun -np TR_NPROC ./mitgcmuv_ad"
317     else
318     EXE="mpirun -np TR_NPROC ./mitgcmuv"
319     fi
320     fi
321    
322     #-- set specific Env Vars:
323     if test $typ = 'oad' ; then
324 jmc 1.2 #- for some reasons, "source ScriptFile | tee -a LogFile"
325     # does run the script but does not keep the env-var settings
326     source $HOME/mitgcm/bin/setenv_OpenAD.sh >> $tdir/output_$tt
327 jmc 1.1 fi
328     if test $typ = 'ifc' ; then
329     source /srv/software/intel/intel-11.1.073/bin/ifortvars.sh intel64
330     fi
331     if test $typ = 'pgi' ; then
332     #listT='fizhi-cs-32x32x40 fizhi-cs-aqualev20'
333     export PGI=/srv/software/pgi/pgi-10.9
334     export PATH="$PATH:$PGI/linux86-64/10.9/bin"
335     export LM_LICENSE_FILE=$PGI/license.dat
336     fi
337    
338     if test $sepDir = 0 -a "x$option" = x -a $tt = $firstTst -a $checkOut = 0 ; then
339     #-- cleaning:
340     echo "======================"
341     echo "Cleaning test directories:" | tee -a $tdir/output_$tt
342     cmdCLN="./testreport -clean"
343     echo " clean dir running: $cmdCLN" | tee -a $tdir/output_$tt
344     $cmdCLN >> $tdir/output_$tt 2>&1
345     echo "======================"
346     echo "" | tee -a $tdir/output_$tt
347     fi
348    
349     #-- run the testreport command:
350     echo -n "Running testreport using:" | tee -a $tdir/output_$tt
351     if test "x$OPTFILE" != x ; then
352     comm="$comm -of=$OPTFILE"
353     fi
354     if test $MPI = 0 ; then echo '' | tee -a $tdir/output_$tt
355     else echo " (EXE='$EXE')" | tee -a $tdir/output_$tt
356     comm="$comm -MPI $MPI -command \"\$EXE\""
357     fi
358     if test "x$option" != x ; then comm="$comm $option" ; fi
359     #if test $typ = 'pgi' ; then comm="$comm -t \"\$listT\"" ; fi
360     echo " \"eval $comm\"" | tee -a $tdir/output_$tt
361     echo "======================"
362     eval $comm >> $tdir/output_$tt 2>&1
363     sed -n "/^An email /,/^======== End of testreport / p" $tdir/output_$tt
364     echo "" | tee -a $tdir/output_$tt
365    
366     #-- also test restart (test 2+2=4)
367     if test $tt != $typ
368     then
369     echo "testing restart using:" | tee -a $tdir/output_$tt
370     comm="../tools/do_tst_2+2 -o $outDir -a jm_c@mitgcm.org"
371     if test $MPI = 0 ; then
372     echo " \"$comm\"" | tee -a $tdir/output_$tt
373     echo "======================"
374     $comm >> $tdir/output_$tt 2>&1
375     else
376     echo " \"$comm -mpi -exe $EXE\"" | tee -a $tdir/output_$tt
377     echo "======================"
378     $comm -mpi -exe "$EXE" >> $tdir/output_$tt 2>&1
379     fi
380     echo ; cat tst_2+2_out.txt
381     echo
382     fi
383     export OMP_NUM_THREADS=1
384    
385     if test $sepDir = 0 ; then
386     #-- cleaning:
387     echo "======================"
388     echo "Cleaning test directories:" | tee -a $tdir/output_$tt
389     if test $tt != $typ ; then
390     cmdCLN="../tools/do_tst_2+2 -clean"
391     echo " clean tst_2+2 running: $cmdCLN" | tee -a $tdir/output_$tt
392     $cmdCLN >> $tdir/output_$tt 2>&1
393     fi
394     if test $tt != $last_Tst ; then
395     cmdCLN="./testreport -clean"
396     echo " clean dir running: $cmdCLN" | tee -a $tdir/output_$tt
397     $cmdCLN >> $tdir/output_$tt 2>&1
398     fi
399     echo "======================"
400     echo
401     fi
402     cd $tdir
403    
404     done

  ViewVC Help
Powered by ViewVC 1.1.22