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

Annotation of /MITgcm_contrib/test_scripts/ref_machine/test_villon

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


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

  ViewVC Help
Powered by ViewVC 1.1.22