1 |
#! /usr/bin/env bash |
2 |
|
3 |
# $Header: /u/gcmpack/MITgcm/tools/example_scripts/csail/test_dickens,v 1.25 2013/05/10 20:24:07 jmc Exp $ |
4 |
|
5 |
# Test script for MITgcm that should work on most of the csail.mit.edu |
6 |
# Linux machines. |
7 |
|
8 |
# defaults |
9 |
export PATH="$PATH:/usr/local/bin" |
10 |
#if [ -d ~/bin ]; then export PATH=$PATH:~/bin ; fi |
11 |
#- to get case insensitive "ls" (and order of tested experiments) |
12 |
export LC_ALL="en_US.UTF-8" |
13 |
# Turn off stack limit for FIZHI & AD-tests |
14 |
ulimit -s unlimited |
15 |
# MPI test (for now, only with gfortran) |
16 |
# export MPI_GCC_DIR=/srv/software/gcc/gcc-packages/gcc-4.4.5/mpich2/mpich2-1.3 |
17 |
# export MPI_INC_DIR=$MPI_GCC_DIR/include |
18 |
# export PATH="$PATH:$MPI_GCC_DIR/bin" |
19 |
|
20 |
#- method to acces CVS: |
21 |
# export CVSROOT='/u/gcmpack' |
22 |
# export CVSROOT=':ext:@mitgcm.org:/u/gcmpack' |
23 |
# export CVS_RSH='ssh' ; cvs co -P MITgcm > /dev/null |
24 |
# cvs -d :pserver:cvsanon@mitgcm.org:/u/gcmpack co -P MITgcm > /dev/null |
25 |
cmdCVS='cvs -d :pserver:cvsanon@mitgcm.org:/u/gcmpack' |
26 |
cmdCVS='cvs -d /u/gcmpack' |
27 |
|
28 |
# checkOut=2 : download new code ; |
29 |
# =1 : update code (if no existing code -> swith to 2) |
30 |
# =0 : use existing code (if no existing code -> swith to 2) |
31 |
dInWeek=`date +%a` |
32 |
TESTDIR="/tmp/jmc/test_"`hostname -s` |
33 |
MC=13 |
34 |
checkOut=2 |
35 |
sepDir=0 |
36 |
option= |
37 |
#tst_list='g7a adm mpa g77 gfo+rs mth mp2+rs mpi ifc' |
38 |
#if test "x$dInWeek" = xSun ; then tst_list="$tst_list tlm oad" ; fi |
39 |
#tst_list='g77 adm gfo ifc mth pgi+rs' |
40 |
tst_list='g77 gfo+rs mth' |
41 |
|
42 |
#option="-nc" ; checkOut=1 |
43 |
#option="-q" ; checkOut=1 |
44 |
|
45 |
TODAY=`date +%d` |
46 |
tdir=$TESTDIR |
47 |
if test $checkOut != 2 ; then |
48 |
if test -e $tdir/MITgcm/CVS ; then |
49 |
echo $tdir/MITgcm/CVS 'exist' |
50 |
if test $sepDir = 0 -a $checkOut = 1 ; then |
51 |
echo -n "Update the MITgcm code using: $cmdCVS ..." |
52 |
cd $tdir/MITgcm |
53 |
$cmdCVS update -P -d |
54 |
echo " done" |
55 |
fi |
56 |
else |
57 |
echo -n $tdir/MITgcm 'missing ; ' |
58 |
checkOut=2 |
59 |
fi |
60 |
fi |
61 |
if test $checkOut = 2 ; then |
62 |
if test -e $tdir ; then |
63 |
echo -n "Removing working copy: $tdir/MITgcm ..." |
64 |
test -e $tdir/MITgcm && rm -rf $tdir/MITgcm |
65 |
else |
66 |
echo -n "Creating a working dir: $tdir ..." |
67 |
mkdir $tdir |
68 |
fi |
69 |
echo " done" |
70 |
echo -n "Downloading the MITgcm code using: $cmdCVS ..." |
71 |
cd $tdir |
72 |
$cmdCVS co -P MITgcm > /dev/null |
73 |
echo " done" |
74 |
else |
75 |
cd $tdir |
76 |
fi |
77 |
|
78 |
#------------------------------------------------------------------------ |
79 |
|
80 |
firstTst=`echo $tst_list | awk '{print $1}'` |
81 |
last_Tst=`echo $tst_list | awk '{print $NF}'` |
82 |
for tt in $tst_list |
83 |
do |
84 |
|
85 |
echo "================================================================" |
86 |
typ=`echo $tt | sed 's/+rs//'` |
87 |
#- check day and time: |
88 |
curDay=`date +%d` ; curHour=`date +%H` |
89 |
if [ $curDay -ne $TODAY ] ; then |
90 |
date ; echo "day is over => skip test $typ" |
91 |
continue |
92 |
fi |
93 |
if [ $curHour -ge 18 ] ; then |
94 |
date ; echo "too late to run test $typ" |
95 |
continue |
96 |
fi |
97 |
if test $sepDir = 0 -a "x$option" != x -a $tt != $last_Tst ; then |
98 |
echo "using option='$option' prevent multi-tests => skip test $typ" |
99 |
continue |
100 |
fi |
101 |
#- clean-up old output files |
102 |
rm -f $tdir/output_${typ}* |
103 |
touch $tdir/output_$tt |
104 |
if test $sepDir = 1 ; then |
105 |
new_dir="MITgcm_$typ" |
106 |
if test -d $new_dir/CVS -a $checkOut != 2 ; then |
107 |
pushd $new_dir |
108 |
if test $tt != $typ ; then |
109 |
( cd verification ; ../tools/do_tst_2+2 -clean ) |
110 |
fi |
111 |
if test $checkOut = 1 ; then |
112 |
echo -n "Update the MITgcm code using: $cmdCVS ..." |
113 |
$cmdCVS update -P -d |
114 |
echo " done" |
115 |
fi |
116 |
else |
117 |
test -e $new_dir && rm -rf $new_dir |
118 |
mkdir $new_dir |
119 |
pushd $new_dir |
120 |
cp -ra ../MITgcm/* . |
121 |
fi |
122 |
else |
123 |
pushd MITgcm |
124 |
fi |
125 |
cd verification |
126 |
|
127 |
#-- set the testreport command: |
128 |
comm="./testreport" |
129 |
if test $typ = 'g7a' -o $typ = 'adm' -o $typ = 'mpa' ; then |
130 |
comm="$comm -adm" |
131 |
elif test $typ = 'oad' ; then |
132 |
comm="$comm -oad" |
133 |
elif test $typ = 'tlm' ; then |
134 |
comm="$comm -tlm" |
135 |
elif test $typ = 'mth' -o $typ = 'mp2' ; then |
136 |
export GOMP_STACKSIZE=400m |
137 |
export OMP_NUM_THREADS=2 |
138 |
comm="$comm -mth" |
139 |
else |
140 |
comm="$comm -md makedepend" |
141 |
fi |
142 |
comm="$comm -a jmc@mitgcm.org" |
143 |
#-- set the optfile (+ mpi & match-precision) |
144 |
MPI=0 |
145 |
case $typ in |
146 |
'g77'|'g7a') OPTFILE='../tools/build_options/linux_amd64_g77' ;; |
147 |
'gfo'|'adm'|'oad'|'tlm'|'mth') comm="$comm -match $MC" |
148 |
OPTFILE='../tools/build_options/linux_amd64_gfortran' ;; |
149 |
'ifc') OPTFILE='../tools/build_options/linux_amd64_ifort11' ;; |
150 |
'pgi') OPTFILE='../tools/build_options/linux_amd64_pgf77' ;; |
151 |
'mpa'|'mpi'|'mp2') comm="$comm -match $MC" ; MPI=6 |
152 |
OPTFILE='../tools/build_options/linux_amd64_gfortran' ;; |
153 |
*) OPTFILE= ;; |
154 |
esac |
155 |
#-- set MPI command: |
156 |
if test $MPI != 0 ; then |
157 |
if test $typ = 'mp2' ; then MPI=3 ; fi |
158 |
if test $typ = 'mpa' ; then |
159 |
EXE="mpirun -np TR_NPROC ./mitgcmuv_ad" |
160 |
else |
161 |
EXE="mpirun -np TR_NPROC ./mitgcmuv" |
162 |
fi |
163 |
fi |
164 |
|
165 |
#-- set specific Env Vars: |
166 |
if test $typ = 'oad' ; then |
167 |
source ~jmc/mitgcm/bin/setenv_OpenAD.sh |
168 |
fi |
169 |
if test $typ = 'ifc' ; then |
170 |
source /srv/software/intel/intel-11.1.073/bin/ifortvars.sh intel64 |
171 |
fi |
172 |
if test $typ = 'pgi' ; then |
173 |
#listT='fizhi-cs-32x32x40 fizhi-cs-aqualev20' |
174 |
export PGI=/srv/software/pgi/pgi-10.9 |
175 |
export PATH="$PATH:$PGI/linux86-64/10.9/bin" |
176 |
export LM_LICENSE_FILE=$PGI/license.dat |
177 |
fi |
178 |
|
179 |
if test $sepDir = 0 -a "x$option" = x -a $tt = $firstTst -a $checkOut != 2 ; then |
180 |
#-- cleaning: |
181 |
echo "======================" |
182 |
echo "Cleaning test directories:" | tee -a $tdir/output_$tt |
183 |
cmdCLN="./testreport -clean" |
184 |
echo " clean dir running: $cmdCLN" | tee -a $tdir/output_$tt |
185 |
$cmdCLN >> $tdir/output_$tt 2>&1 |
186 |
echo "======================" |
187 |
echo "" | tee -a $tdir/output_$tt |
188 |
fi |
189 |
|
190 |
#-- run the testreport command: |
191 |
echo -n "Running testreport using:" | tee -a $tdir/output_$tt |
192 |
if test "x$OPTFILE" != x ; then |
193 |
comm="$comm -of=$OPTFILE" |
194 |
fi |
195 |
if test $MPI = 0 ; then echo '' | tee -a $tdir/output_$tt |
196 |
else echo " (EXE='$EXE')" | tee -a $tdir/output_$tt |
197 |
comm="$comm -MPI $MPI -command \"\$EXE\"" |
198 |
fi |
199 |
if test "x$option" != x ; then comm="$comm $option" ; fi |
200 |
#if test $typ = 'pgi' ; then comm="$comm -t \"\$listT\"" ; fi |
201 |
echo " \"eval $comm\"" | tee -a $tdir/output_$tt |
202 |
echo "======================" |
203 |
eval $comm >> $tdir/output_$tt 2>&1 |
204 |
sed -n "/^An email /,/^======== End of testreport / p" $tdir/output_$tt |
205 |
echo "" | tee -a $tdir/output_$tt |
206 |
|
207 |
#-- also test restart (test 2+2=4) |
208 |
if test $tt != $typ |
209 |
then |
210 |
echo "testing restart using:" | tee -a $tdir/output_$tt |
211 |
comm="../tools/do_tst_2+2 -a jmc@mitgcm.org" |
212 |
if test $MPI = 0 ; then |
213 |
echo " \"$comm\"" | tee -a $tdir/output_$tt |
214 |
echo "======================" |
215 |
$comm >> $tdir/output_$tt 2>&1 |
216 |
else |
217 |
echo " \"$comm -mpi -exe $EXE\"" | tee -a $tdir/output_$tt |
218 |
echo "======================" |
219 |
$comm -mpi -exe "$EXE" >> $tdir/output_$tt 2>&1 |
220 |
fi |
221 |
echo ; cat tst_2+2_out.txt |
222 |
echo |
223 |
fi |
224 |
export OMP_NUM_THREADS=1 |
225 |
|
226 |
if test $sepDir = 0 ; then |
227 |
#-- cleaning: |
228 |
echo "======================" |
229 |
echo "Cleaning test directories:" | tee -a $tdir/output_$tt |
230 |
if test $tt != $typ ; then |
231 |
cmdCLN="../tools/do_tst_2+2 -clean" |
232 |
echo " clean tst_2+2 running: $cmdCLN" | tee -a $tdir/output_$tt |
233 |
$cmdCLN >> $tdir/output_$tt 2>&1 |
234 |
fi |
235 |
if test $tt != $last_Tst ; then |
236 |
cmdCLN="./testreport -clean" |
237 |
echo " clean dir running: $cmdCLN" | tee -a $tdir/output_$tt |
238 |
$cmdCLN >> $tdir/output_$tt 2>&1 |
239 |
fi |
240 |
echo "======================" |
241 |
echo |
242 |
fi |
243 |
popd |
244 |
|
245 |
done |