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