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