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