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