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