1 |
#! /usr/bin/env bash |
2 |
|
3 |
# $Header: /u/gcmpack/MITgcm_contrib/test_scripts/svante/test_submit_svante,v 1.3 2016/04/16 14:55:05 jmc Exp $ |
4 |
# $Name: $ |
5 |
|
6 |
today=`date +%Y%m%d` |
7 |
dInWeek=`date +%a` |
8 |
|
9 |
if test $# = 0 |
10 |
then |
11 |
TEST_LIST='pgiMPI' |
12 |
#if test "x$dInWeek" = xSun ; then TEST_LIST="$TEST_LIST iad ifc oad" ; fi |
13 |
else |
14 |
TEST_LIST=$* |
15 |
fi |
16 |
|
17 |
QSUB="qsub" |
18 |
QSTAT="qstat" |
19 |
dNam=`hostname -s` |
20 |
HERE="$HOME/test_${dNam}" |
21 |
TST_DISK="/net/fs09/d0" |
22 |
TST_DIR="$TST_DISK/jm_c/test_${dNam}" |
23 |
logPfix='test_submit' |
24 |
|
25 |
SUB_DIR="$HERE/$dNam" |
26 |
OUT_DIR="$HERE/output" |
27 |
LOG_FIL="$OUT_DIR/$logPfix."`date +%m%d`".log" |
28 |
#SUB_DIR="$HERE/temp" |
29 |
|
30 |
#-- clean up old log files and start a new one: |
31 |
cd $OUT_DIR |
32 |
|
33 |
rm -f $logPfix.*.log_bak |
34 |
if test -f $LOG_FIL ; then mv -f $LOG_FIL ${LOG_FIL}_bak ; fi |
35 |
echo -n '-- Starting: ' | tee -a $LOG_FIL |
36 |
date | tee -a $LOG_FIL |
37 |
|
38 |
n=$(( `ls $logPfix.*.log | wc -l` - 10 )) |
39 |
if test $n -gt 0 ; then |
40 |
echo ' remove old log files:' | tee -a $LOG_FIL |
41 |
ls -lt $logPfix.*.log | tail -"$n" | tee -a $LOG_FIL |
42 |
ls -t $logPfix.*.log | tail -"$n" | xargs rm -f |
43 |
fi |
44 |
|
45 |
#------------------------------------------------------------- |
46 |
# defaults |
47 |
#export PATH="$PATH:/usr/local/bin" |
48 |
if [ -d ~/bin ]; then export PATH=$PATH:~/bin ; fi |
49 |
#- to get case insensitive "ls" (and order of tested experiments) |
50 |
export LC_ALL="en_US.UTF-8" |
51 |
# Turn off stack limit for FIZHI & AD-tests |
52 |
ulimit -s unlimited |
53 |
|
54 |
if test -f /etc/profile.d/modules.sh ; then |
55 |
. /etc/profile.d/modules.sh |
56 |
fi |
57 |
#- load standard modules: |
58 |
module add fedora torque maui svante |
59 |
module list >> $LOG_FIL 2>&1 |
60 |
|
61 |
#- method to acces CVS: |
62 |
cmdCVS='cvs -d :pserver:cvsanon@mitgcm.org:/u/gcmpack -q' |
63 |
|
64 |
#---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
65 |
#-- Download/Update reference version of MITgcm code: |
66 |
checkOut=1 |
67 |
gcmDIR='MITgcm' |
68 |
exp2add='' |
69 |
updFile='updated_code' |
70 |
|
71 |
echo "cd $TST_DISK ; pwd (x2)" | tee -a $LOG_FIL |
72 |
cd $TST_DISK | tee -a $LOG_FIL 2>&1 |
73 |
pwd | tee -a $LOG_FIL |
74 |
sleep 30 |
75 |
pwd | tee -a $LOG_FIL |
76 |
if test ! -d $TST_DIR ; then |
77 |
echo -n "Creating a working dir: $TST_DIR ..." | tee -a $LOG_FIL |
78 |
#/bin/rm -rf $TST_DIR |
79 |
mkdir $TST_DIR |
80 |
retVal=$? |
81 |
if test "x$retVal" != x0 ; then |
82 |
echo "Error: unable to make dir: $TST_DIR (err=$retVal ) --> Exit" | tee -a $LOG_FIL |
83 |
exit 1 |
84 |
fi |
85 |
fi |
86 |
cd $TST_DIR |
87 |
|
88 |
#- remove date/lock-file: |
89 |
if test -f $updFile ; then rm -f $updFile ; sleep 2 ; fi |
90 |
|
91 |
if [ $checkOut -eq 1 ] ; then |
92 |
if test -d $gcmDIR/CVS ; then |
93 |
echo -n "Update dir $gcmDIR using '$cmdCVS update -P -d' ..." | tee -a $LOG_FIL |
94 |
echo '' >> $LOG_FIL |
95 |
( cd $gcmDIR ; $cmdCVS update -P -d ) >> $LOG_FIL 2>&1 |
96 |
RETVAL=$? |
97 |
if test "x$RETVAL" != x0 ; then echo '' |
98 |
echo "cvs update on '"`hostname`"' fail (return val=$RETVAL) => exit" | tee -a $LOG_FIL |
99 |
exit |
100 |
else echo " done" | tee -a $LOG_FIL |
101 |
fi |
102 |
else |
103 |
echo "no dir: $gcmDIR/CVS => try a fresh check-out" | tee -a $LOG_FIL |
104 |
checkOut=2 |
105 |
fi |
106 |
fi |
107 |
if [ $checkOut -eq 2 ] ; then |
108 |
test -e $gcmDIR && rm -rf $gcmDIR |
109 |
echo -n "Downloading using '$cmdCVS co -P -d $gcmDIR MITgcm' ..." | tee -a $LOG_FIL |
110 |
$cmdCVS co -P -d $gcmDIR MITgcm > /dev/null |
111 |
RETVAL=$? |
112 |
if test "x$RETVAL" != x0 ; then echo '' | tee -a $LOG_FIL |
113 |
echo "cvs co on '"`hostname`"' fail (return val=$RETVAL) => exit" | tee -a $LOG_FIL |
114 |
exit |
115 |
else echo " done" | tee -a $LOG_FIL |
116 |
fi |
117 |
if test -d $gcmDIR/verification ; then |
118 |
for exp2add in $addExp ; do |
119 |
echo " add dir: $exp2add (from Contrib:verification_other)" | tee -a $LOG_FIL |
120 |
( cd $gcmDIR/verification ; $cmdCVS co -P -d $exp2add \ |
121 |
MITgcm_contrib/verification_other/$exp2add > /dev/null ) |
122 |
done |
123 |
fi |
124 |
/usr/bin/find $gcmDIR -type d | xargs chmod g+rxs |
125 |
/usr/bin/find $gcmDIR -type f | xargs chmod g+r |
126 |
fi |
127 |
|
128 |
#- update date/lock-file: |
129 |
if test -d $gcmDIR/verification ; then |
130 |
echo $today > $updFile ; sleep 2 |
131 |
ls -l $updFile | tee -a $LOG_FIL |
132 |
fi |
133 |
|
134 |
#-- leave TST Dir and go back to output dir |
135 |
cd $OUT_DIR |
136 |
#---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
137 |
#-- now really do something: |
138 |
|
139 |
JOB_LIST=$TEST_LIST |
140 |
NB_SUB_JOBS=0 |
141 |
for i in $JOB_LIST |
142 |
do |
143 |
case $i in |
144 |
'pgiMPI') sfx='pgi_mpi' ;; |
145 |
'pgiAdm') sfx='pgi_adm' ;; |
146 |
*) sfx=${i}'_mpi' ;; |
147 |
esac |
148 |
BATCH_SCRIPT="test_svante_$sfx" |
149 |
if test -f $SUB_DIR/$BATCH_SCRIPT ; then |
150 |
JOB="tst_"$i |
151 |
job_exist=`$QSTAT -a | grep $USER | grep $JOB | wc -l` |
152 |
if test "x_$job_exist" = x_0 ; then |
153 |
#-- move previous output file |
154 |
outList=`ls $JOB.std??? 2> /dev/null` |
155 |
if test "x$outList" != x ; then |
156 |
echo -n " moving job $JOB old output files:" | tee -a $LOG_FIL |
157 |
if test -d $OUT_DIR/prev ; then |
158 |
for xx in $outList ; do |
159 |
pp=$OUT_DIR/prev/$xx ; echo -n " $xx" | tee -a $LOG_FIL |
160 |
test -f $pp.sav && mv -f $pp.sav $pp.old |
161 |
test -f $pp && mv -f $pp $pp.sav |
162 |
chmod a+r $xx ; mv -f $xx $OUT_DIR/prev |
163 |
done |
164 |
echo " to dir ./prev" | tee -a $LOG_FIL |
165 |
else |
166 |
echo " <-- missing dir $OUT_DIR/prev" | tee -a $LOG_FIL |
167 |
fi |
168 |
else echo " no old output files from job '$JOB'" | tee -a $LOG_FIL |
169 |
fi |
170 |
#-- submit job |
171 |
echo -n "--> $JOB : " | tee -a $LOG_FIL |
172 |
$QSUB $SUB_DIR/$BATCH_SCRIPT | tee -a $LOG_FIL |
173 |
NB_SUB_JOBS=`expr $NB_SUB_JOBS + 1` |
174 |
else |
175 |
echo "--> $JOB :" | tee -a $LOG_FIL |
176 |
$QSTAT -a | grep $USER | grep $JOB | tee -a $LOG_FIL |
177 |
echo ' job already exist => skip this test' | tee -a $LOG_FIL |
178 |
fi |
179 |
else |
180 |
echo 'no file:' $BATCH_SCRIPT 'to submit' | tee -a $LOG_FIL |
181 |
fi |
182 |
done |
183 |
echo "info-sub-list: NB_SUB_JOBS='$NB_SUB_JOBS'" >> $LOG_FIL |
184 |
echo -n '-- Finished at: ' | tee -a $LOG_FIL |
185 |
date | tee -a $LOG_FIL |
186 |
|
187 |
#---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
188 |
exit 0 |