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