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