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