1 |
jmc |
1.1 |
#! /usr/bin/env bash |
2 |
|
|
|
3 |
|
|
# $Header: $ |
4 |
|
|
|
5 |
|
|
# Test script for MITgcm to run on head-node of svante cluster |
6 |
|
|
|
7 |
|
|
# defaults |
8 |
|
|
#export PATH="$PATH:/usr/local/bin" |
9 |
|
|
if [ -d ~/bin ]; then export PATH=$PATH:~/bin ; fi |
10 |
|
|
#- to get case insensitive "ls" (and order of tested experiments) |
11 |
|
|
export LC_ALL="en_US.UTF-8" |
12 |
|
|
# Turn off stack limit for FIZHI & AD-tests |
13 |
|
|
ulimit -s unlimited |
14 |
|
|
|
15 |
|
|
if test -f /etc/profile.d/modules.sh ; then |
16 |
|
|
. /etc/profile.d/modules.sh |
17 |
|
|
fi |
18 |
|
|
|
19 |
|
|
#- load standard modules: |
20 |
|
|
module add fedora torque maui svante |
21 |
|
|
module list |
22 |
|
|
|
23 |
|
|
#- method to acces CVS: |
24 |
|
|
cmdCVS='cvs -d :pserver:cvsanon@mitgcm.org:/u/gcmpack -q' |
25 |
|
|
|
26 |
|
|
# checkOut=2 : download new code ; |
27 |
|
|
# =3 : skip download but, if sepDir, use a new copy |
28 |
|
|
# =1 : update code (if no existing code -> swith to 2) |
29 |
|
|
# =0 : use existing code (if no existing code -> swith to 2) |
30 |
|
|
dInWeek=`date +%a` |
31 |
|
|
dName=`hostname -s` |
32 |
|
|
QSUB="qsub" |
33 |
|
|
QSTAT="qstat" |
34 |
|
|
HERE="$HOME/test_${dName}" |
35 |
|
|
OUTP="$HERE/output" |
36 |
|
|
SUB_DIR="$HERE/$dName" |
37 |
|
|
TESTDIR="/net/fs07/d1/testreport/test_${dName}" |
38 |
|
|
checkOut=2 |
39 |
|
|
option= |
40 |
|
|
|
41 |
|
|
#tst_list='gads gadm gfo+rs gmpi gmth gmp2+rs ifc pgi' |
42 |
|
|
#if test "x$dInWeek" = xSun ; then tst_list="$tst_list tlm oad" ; fi |
43 |
|
|
tst_list='ifc' |
44 |
|
|
|
45 |
|
|
#option="-nc" ; checkOut=1 |
46 |
|
|
#option="-q" ; checkOut=0 |
47 |
|
|
|
48 |
|
|
TODAY=`date +%d` |
49 |
|
|
tdir=$TESTDIR |
50 |
|
|
if test ! -d $TESTDIR ; then |
51 |
|
|
echo -n "Creating a working dir: $TESTDIR ..." |
52 |
|
|
/bin/rm -rf $TESTDIR |
53 |
|
|
mkdir $TESTDIR |
54 |
|
|
retVal=$? |
55 |
|
|
if test "x$retVal" != x0 ; then |
56 |
|
|
echo "Error: unable to make dir: $TESTDIR (err=$retVal ) --> Exit" |
57 |
|
|
exit 1 |
58 |
|
|
fi |
59 |
|
|
fi |
60 |
|
|
cd $TESTDIR |
61 |
|
|
|
62 |
|
|
#------------------------------------------------------------------------ |
63 |
|
|
|
64 |
|
|
#firstTst=`echo $tst_list | awk '{print $1}'` |
65 |
|
|
#last_Tst=`echo $tst_list | awk '{print $NF}'` |
66 |
|
|
for tt in $tst_list |
67 |
|
|
do |
68 |
|
|
|
69 |
|
|
echo "================================================================" |
70 |
|
|
newCode=$checkOut |
71 |
|
|
typ=`echo $tt | sed 's/+rs//'` |
72 |
|
|
gcmDIR="MITgcm_$typ" |
73 |
|
|
tst2submit="run_tst_$typ" |
74 |
|
|
addExp='' |
75 |
|
|
#- check day and time: |
76 |
|
|
curDay=`date +%d` ; curHour=`date +%H` |
77 |
|
|
if [ $curDay -ne $TODAY ] ; then |
78 |
|
|
date ; echo "day is over => skip test $typ" |
79 |
|
|
continue |
80 |
|
|
fi |
81 |
|
|
if [ $curHour -ge 18 ] ; then |
82 |
|
|
date ; echo "too late to run test $typ" |
83 |
|
|
continue |
84 |
|
|
fi |
85 |
|
|
#- check for unfinished jobs |
86 |
|
|
job_exist=`$QSTAT -a | grep $USER | grep $tst2submit | wc -l` |
87 |
|
|
if test "x$job_exist" != x0 ; then |
88 |
|
|
echo $tst2submit |
89 |
|
|
echo "job '$tst2submit' still in queue:" |
90 |
|
|
$QSTAT -a | grep $USER | grep $tst2submit |
91 |
|
|
echo " => skip this test" |
92 |
|
|
continue |
93 |
|
|
fi |
94 |
|
|
#- clean-up old output files |
95 |
|
|
rm -f $OUTP/output_${typ}*.old $OUTP/$tst2submit.std???.old |
96 |
|
|
oldS=`ls $OUTP/output_${tt} $OUTP/$tst2submit.std??? 2> /dev/null` |
97 |
|
|
for xx in $oldS ; do mv $xx $xx.old ; done |
98 |
|
|
if test -d prev ; then |
99 |
|
|
#-- save previous summary: tr_out.txt* tst_2+2_out.txt |
100 |
|
|
oldS=`( cd ${gcmDIR}/verification ; ls tr_out.txt* tst_2+2_out.txt ) 2> /dev/null` |
101 |
|
|
for xx in $oldS ; do |
102 |
|
|
yy=`echo $xx | sed "s/\.txt/.$typ/"` |
103 |
|
|
cp -p ${gcmDIR}/verification/$xx prev/$yy |
104 |
|
|
done |
105 |
|
|
fi |
106 |
|
|
#if test -d $HERE/prev ; then |
107 |
|
|
# oldS=`ls -t ${gcmDIR}/verification/tr_${dName}_*/summary.txt 2> /dev/null | head -1` |
108 |
|
|
# if test "x$oldS" != x ; then cp -p -f $oldS $HERE/prev/tr_out.$typ ; fi |
109 |
|
|
# # sed '/^[YN] [YN] [YN] [YN]/ s/ \. //g' $oldS > tr_out.$typ |
110 |
|
|
# if test $tt != $typ ; then |
111 |
|
|
# oldS=`ls -t ${gcmDIR}/verification/rs_${dName}_*/summary.txt 2> /dev/null | head -1` |
112 |
|
|
# if test "x$oldS" != x ; then cp -p -f $oldS $HERE/prev/rs_out.$typ ; fi |
113 |
|
|
# fi |
114 |
|
|
#fi |
115 |
|
|
touch $OUTP/output_$tt |
116 |
|
|
|
117 |
|
|
#- clean and update code |
118 |
|
|
if [ $newCode -eq 1 ] ; then |
119 |
|
|
if test -d $gcmDIR/CVS ; then |
120 |
|
|
#- remove previous output tar files and tar & remove previous output-dir |
121 |
|
|
/bin/rm -f $gcmDIR/verification/??_${dNam}-${typ}_????????_?.tar.gz |
122 |
|
|
( cd $gcmDIR/verification |
123 |
|
|
listD=`ls -1 -d ??_${dNam}-${typ}_????????_? 2> /dev/null` |
124 |
|
|
for dd in $listD |
125 |
|
|
do |
126 |
|
|
if test -d $dd ; then |
127 |
|
|
tar -cf ${dd}".tar" $dd > /dev/null 2>&1 && gzip ${dd}".tar" && /bin/rm -rf $dd |
128 |
|
|
retVal=$? |
129 |
|
|
if test "x$retVal" != x0 ; then |
130 |
|
|
echo "ERROR in tar+gzip prev outp-dir: $dd" |
131 |
|
|
echo " on '"`hostname`"' (return val=$retVal) but continue" |
132 |
|
|
fi |
133 |
|
|
fi |
134 |
|
|
done ) |
135 |
|
|
if test $tt != $typ ; then |
136 |
|
|
( cd $gcmDIR/verification ; ../tools/do_tst_2+2 -clean ) |
137 |
|
|
fi |
138 |
|
|
# ( cd $gcmDIR/verification ; ../testreport -clean ) |
139 |
|
|
echo "cvs update of dir $gcmDIR :" |
140 |
|
|
( cd $gcmDIR ; $cmdCVS update -P -d ) 2>&1 |
141 |
|
|
retVal=$? |
142 |
|
|
if test "x$retVal" != x0 ; then |
143 |
|
|
echo "cvs update on '"`hostname`"' fail (return val=$retVal) => exit" |
144 |
|
|
exit |
145 |
|
|
fi |
146 |
|
|
else |
147 |
|
|
echo "no dir: $gcmDIR/CVS => try a fresh check-out" |
148 |
|
|
newCode=2 |
149 |
|
|
fi |
150 |
|
|
fi |
151 |
|
|
#- download new code |
152 |
|
|
if [ $newCode -eq 2 ] ; then |
153 |
|
|
test -e $gcmDIR && rm -rf $gcmDIR |
154 |
|
|
echo -n "Downloading the MITgcm code using: $cmdCVS ..." |
155 |
|
|
$cmdCVS co -P -d $gcmDIR MITgcm > /dev/null 2>&1 |
156 |
|
|
echo " done" |
157 |
|
|
for exp2add in $addExp ; do |
158 |
|
|
echo " add dir: $exp2add (from Contrib:verification_other)" |
159 |
|
|
( cd $gcmDIR/verification ; $cmdCVS co -P -d $exp2add \ |
160 |
|
|
MITgcm_contrib/verification_other/$exp2add > /dev/null 2>&1 ) |
161 |
|
|
done |
162 |
|
|
/usr/bin/find $gcmDIR -type d | xargs chmod g+rxs |
163 |
|
|
/usr/bin/find $gcmDIR -type f | xargs chmod g+r |
164 |
|
|
fi |
165 |
|
|
#--------------------------------------------------- |
166 |
|
|
#-- set the testreport command: |
167 |
|
|
comm="./testreport" |
168 |
|
|
# if test $typ = $typ = 'gads' -o $typ = 'gadm' ; then |
169 |
|
|
# comm="$comm -adm" |
170 |
|
|
# elif test $typ = 'oad' ; then |
171 |
|
|
# comm="$comm -oad" |
172 |
|
|
# elif test $typ = 'tlm' ; then |
173 |
|
|
# comm="$comm -tlm" |
174 |
|
|
# elif test $typ = 'gmth' -o $typ = 'gmp2' ; then |
175 |
|
|
# export GOMP_STACKSIZE=400m |
176 |
|
|
# export OMP_NUM_THREADS=2 |
177 |
|
|
# comm="$comm -mth" |
178 |
|
|
# else |
179 |
|
|
# comm="$comm -md cyrus-makedepend" |
180 |
|
|
# comm="$comm -t hs94.cs-32x32x5" |
181 |
|
|
# fi |
182 |
|
|
if test "x$dInWeek" = xSun ; then |
183 |
|
|
comm="$comm -fast" |
184 |
|
|
#else |
185 |
|
|
# comm="$comm -devel" |
186 |
|
|
fi |
187 |
|
|
|
188 |
|
|
#-- set the optfile (+ mpi & match-precision) |
189 |
|
|
MPI=0 ; MC=13 |
190 |
|
|
case $typ in |
191 |
|
|
'gfo'|'gads'|'oad'|'tlm'|'gmth') comm="$comm -match $MC -devel" |
192 |
|
|
OPTFILE='../tools/build_options/linux_amd64_gfortran' ;; |
193 |
|
|
'ifc') MPI=6; #comm="$comm -devel" |
194 |
|
|
OPTFILE='../tools/build_options/linux_amd64_ifort11' ;; |
195 |
|
|
'pgi') MPI=6; #comm="$comm -devel" |
196 |
|
|
OPTFILE='../tools/build_options/linux_amd64_pgf77' ;; |
197 |
|
|
'gadm'|'gmpi'|'gmp2') MPI=6; comm="$comm -match $MC -devel" |
198 |
|
|
if test $typ = 'gmp2' ; then MPI=3 ; fi |
199 |
|
|
OPTFILE='../tools/build_options/linux_amd64_gfortran' ;; |
200 |
|
|
*) OPTFILE= ;; |
201 |
|
|
esac |
202 |
|
|
#-- set MPI command: |
203 |
|
|
# if test $MPI != 0 ; then |
204 |
|
|
# fi |
205 |
|
|
|
206 |
|
|
#-- set specific Env Vars: |
207 |
|
|
#if test $typ = 'oad' ; then |
208 |
|
|
# source ~jmc/mitgcm/bin/setenv_OpenAD.sh |
209 |
|
|
#fi |
210 |
|
|
if test $typ = 'ifc' ; then |
211 |
|
|
module add intel |
212 |
|
|
module add mvapich2 |
213 |
|
|
fi |
214 |
|
|
#if test $typ = 'pgi' ; then |
215 |
|
|
# #listT='fizhi-cs-32x32x40 fizhi-cs-aqualev20' |
216 |
|
|
# export PGI=/srv/software/pgi/pgi-10.9 |
217 |
|
|
# export PATH="$PATH:$PGI/linux86-64/10.9/bin" |
218 |
|
|
# export LM_LICENSE_FILE=$PGI/license.dat |
219 |
|
|
#fi |
220 |
|
|
|
221 |
|
|
#-- run the testreport command: |
222 |
|
|
echo -n "Running testreport using" | tee -a $OUTP/output_$tt |
223 |
|
|
if test "x$OPTFILE" != x ; then |
224 |
|
|
comm="$comm -of=$OPTFILE" |
225 |
|
|
fi |
226 |
|
|
if test $MPI != 0 ; then comm="$comm -MPI $MPI" ; fi |
227 |
|
|
echo " -norun option ('-nr'):" | tee -a $OUTP/output_$tt |
228 |
|
|
comm="$comm -nr" |
229 |
|
|
if test "x$option" != x ; then comm="$comm $option" ; fi |
230 |
|
|
echo " \"eval $comm\"" | tee -a $OUTP/output_$tt |
231 |
|
|
echo "======================" |
232 |
|
|
( cd $gcmDIR/verification |
233 |
|
|
eval $comm >> $OUTP/output_$tt 2>&1 |
234 |
|
|
) |
235 |
|
|
sed -n "/^An email /,/^======== End of testreport / p" $OUTP/output_$tt |
236 |
|
|
echo "" | tee -a $OUTP/output_$tt |
237 |
|
|
|
238 |
|
|
#-- submit PBS script to run |
239 |
|
|
if test -e $SUB_DIR/${tst2submit}.pbs ; then |
240 |
|
|
echo " submit PBS bach script '$SUB_DIR/${tst2submit}.pbs'" | tee -a $OUTP/output_$tt |
241 |
|
|
$QSUB $SUB_DIR/${tst2submit}.pbs | tee -a $OUTP/output_$tt |
242 |
|
|
echo " job '$tst2submit' in queue:" | tee -a $OUTP/output_$tt |
243 |
|
|
$QSTAT -a | grep $USER | grep $tst2submit | tee -a $OUTP/output_$tt |
244 |
|
|
else |
245 |
|
|
echo " no PBS script '$SUB_DIR/${tst2submit}.pbs' to submit"| tee -a $OUTP/output_$tt |
246 |
|
|
continue |
247 |
|
|
fi |
248 |
|
|
|
249 |
|
|
#-- also test restart (test 2+2=4) |
250 |
|
|
if test $tt != $typ |
251 |
|
|
then |
252 |
|
|
echo "testing restart using:" | tee -a $OUTP/output_$tt |
253 |
|
|
comm="../tools/do_tst_2+2 -o $dName -a jmc@mitgcm.org" |
254 |
|
|
if test $MPI = 0 ; then |
255 |
|
|
echo " \"$comm\"" | tee -a $OUTP/output_$tt |
256 |
|
|
echo "======================" |
257 |
|
|
$comm >> $OUTP/output_$tt 2>&1 |
258 |
|
|
else |
259 |
|
|
echo " \"$comm -mpi\"" | tee -a $OUTP/output_$tt |
260 |
|
|
echo "======================" |
261 |
|
|
$comm -mpi >> $OUTP/output_$tt 2>&1 |
262 |
|
|
fi |
263 |
|
|
echo ; cat tst_2+2_out.txt |
264 |
|
|
echo |
265 |
|
|
fi |
266 |
|
|
#--reset special setting: |
267 |
|
|
export OMP_NUM_THREADS=1 |
268 |
|
|
|
269 |
|
|
done |