1 |
jmc |
1.1 |
#! /usr/bin/env bash |
2 |
|
|
|
3 |
jmc |
1.3 |
# $Header: /u/gcmpack/MITgcm_contrib/test_scripts/svante/test_submit_svante,v 1.2 2016/01/27 22:45:34 jmc Exp $ |
4 |
jmc |
1.1 |
# $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 |
jmc |
1.2 |
HERE="$HOME/test_${dNam}" |
21 |
jmc |
1.3 |
TST_DISK="/net/fs09/d0" |
22 |
|
|
TST_DIR="$TST_DISK/jm_c/test_${dNam}" |
23 |
jmc |
1.1 |
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 |
jmc |
1.3 |
echo "cd $TST_DISK ; pwd" | tee -a $LOG_FIL |
72 |
jmc |
1.2 |
cd $TST_DISK | tee -a $LOG_FIL 2>&1 |
73 |
|
|
pwd | tee -a $LOG_FIL |
74 |
jmc |
1.1 |
if test ! -d $TST_DIR ; then |
75 |
|
|
echo -n "Creating a working dir: $TST_DIR ..." | tee -a $LOG_FIL |
76 |
jmc |
1.2 |
#/bin/rm -rf $TST_DIR |
77 |
jmc |
1.1 |
mkdir $TST_DIR |
78 |
|
|
retVal=$? |
79 |
|
|
if test "x$retVal" != x0 ; then |
80 |
|
|
echo "Error: unable to make dir: $TST_DIR (err=$retVal ) --> Exit" | tee -a $LOG_FIL |
81 |
|
|
exit 1 |
82 |
|
|
fi |
83 |
|
|
fi |
84 |
|
|
cd $TST_DIR |
85 |
|
|
|
86 |
|
|
#- remove date/lock-file: |
87 |
|
|
if test -f $updFile ; then rm -f $updFile ; sleep 2 ; fi |
88 |
|
|
|
89 |
|
|
if [ $checkOut -eq 1 ] ; then |
90 |
|
|
if test -d $gcmDIR/CVS ; then |
91 |
|
|
echo -n "Update dir $gcmDIR using '$cmdCVS update -P -d' ..." | tee -a $LOG_FIL |
92 |
|
|
echo '' >> $LOG_FIL |
93 |
|
|
( cd $gcmDIR ; $cmdCVS update -P -d ) >> $LOG_FIL 2>&1 |
94 |
|
|
RETVAL=$? |
95 |
|
|
if test "x$RETVAL" != x0 ; then echo '' |
96 |
|
|
echo "cvs update on '"`hostname`"' fail (return val=$RETVAL) => exit" | tee -a $LOG_FIL |
97 |
|
|
exit |
98 |
|
|
else echo " done" | tee -a $LOG_FIL |
99 |
|
|
fi |
100 |
|
|
else |
101 |
|
|
echo "no dir: $gcmDIR/CVS => try a fresh check-out" | tee -a $LOG_FIL |
102 |
|
|
checkOut=2 |
103 |
|
|
fi |
104 |
|
|
fi |
105 |
|
|
if [ $checkOut -eq 2 ] ; then |
106 |
|
|
test -e $gcmDIR && rm -rf $gcmDIR |
107 |
|
|
echo -n "Downloading using '$cmdCVS co -P -d $gcmDIR MITgcm' ..." | tee -a $LOG_FIL |
108 |
|
|
$cmdCVS co -P -d $gcmDIR MITgcm > /dev/null |
109 |
|
|
RETVAL=$? |
110 |
|
|
if test "x$RETVAL" != x0 ; then echo '' | tee -a $LOG_FIL |
111 |
|
|
echo "cvs co on '"`hostname`"' fail (return val=$RETVAL) => exit" | tee -a $LOG_FIL |
112 |
|
|
exit |
113 |
|
|
else echo " done" | tee -a $LOG_FIL |
114 |
|
|
fi |
115 |
|
|
if test -d $gcmDIR/verification ; then |
116 |
|
|
for exp2add in $addExp ; do |
117 |
|
|
echo " add dir: $exp2add (from Contrib:verification_other)" | tee -a $LOG_FIL |
118 |
|
|
( cd $gcmDIR/verification ; $cmdCVS co -P -d $exp2add \ |
119 |
|
|
MITgcm_contrib/verification_other/$exp2add > /dev/null ) |
120 |
|
|
done |
121 |
|
|
fi |
122 |
|
|
/usr/bin/find $gcmDIR -type d | xargs chmod g+rxs |
123 |
|
|
/usr/bin/find $gcmDIR -type f | xargs chmod g+r |
124 |
|
|
fi |
125 |
|
|
|
126 |
|
|
#- update date/lock-file: |
127 |
|
|
if test -d $gcmDIR/verification ; then |
128 |
|
|
echo $today > $updFile ; sleep 2 |
129 |
|
|
ls -l $updFile | tee -a $LOG_FIL |
130 |
|
|
fi |
131 |
|
|
|
132 |
|
|
#-- leave TST Dir and go back to output dir |
133 |
|
|
cd $OUT_DIR |
134 |
|
|
#---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
135 |
|
|
#-- now really do something: |
136 |
|
|
|
137 |
|
|
JOB_LIST=$TEST_LIST |
138 |
|
|
NB_SUB_JOBS=0 |
139 |
|
|
for i in $JOB_LIST |
140 |
|
|
do |
141 |
|
|
case $i in |
142 |
|
|
'pgiMPI') sfx='pgi_mpi' ;; |
143 |
|
|
'pgiAdm') sfx='pgi_adm' ;; |
144 |
|
|
*) sfx=${i}'_mpi' ;; |
145 |
|
|
esac |
146 |
|
|
BATCH_SCRIPT="test_svante_$sfx" |
147 |
|
|
if test -f $SUB_DIR/$BATCH_SCRIPT ; then |
148 |
|
|
JOB="tst_"$i |
149 |
|
|
job_exist=`$QSTAT -a | grep $USER | grep $JOB | wc -l` |
150 |
|
|
if test "x_$job_exist" = x_0 ; then |
151 |
|
|
#-- move previous output file |
152 |
|
|
outList=`ls $JOB.std??? 2> /dev/null` |
153 |
|
|
if test "x$outList" != x ; then |
154 |
|
|
echo -n " moving job $JOB old output files:" | tee -a $LOG_FIL |
155 |
|
|
if test -d $OUT_DIR/prev ; then |
156 |
|
|
for xx in $outList ; do |
157 |
|
|
pp=$OUT_DIR/prev/$xx ; echo -n " $xx" | tee -a $LOG_FIL |
158 |
|
|
test -f $pp.sav && mv -f $pp.sav $pp.old |
159 |
|
|
test -f $pp && mv -f $pp $pp.sav |
160 |
|
|
chmod a+r $xx ; mv -f $xx $OUT_DIR/prev |
161 |
|
|
done |
162 |
|
|
echo " to dir ./prev" | tee -a $LOG_FIL |
163 |
|
|
else |
164 |
|
|
echo " <-- missing dir $OUT_DIR/prev" | tee -a $LOG_FIL |
165 |
|
|
fi |
166 |
|
|
else echo " no old output files from job '$JOB'" | tee -a $LOG_FIL |
167 |
|
|
fi |
168 |
|
|
#-- submit job |
169 |
|
|
echo -n "--> $JOB : " | tee -a $LOG_FIL |
170 |
|
|
$QSUB $SUB_DIR/$BATCH_SCRIPT | tee -a $LOG_FIL |
171 |
|
|
NB_SUB_JOBS=`expr $NB_SUB_JOBS + 1` |
172 |
|
|
else |
173 |
|
|
echo "--> $JOB :" | tee -a $LOG_FIL |
174 |
|
|
$QSTAT -a | grep $USER | grep $JOB | tee -a $LOG_FIL |
175 |
|
|
echo ' job already exist => skip this test' | tee -a $LOG_FIL |
176 |
|
|
fi |
177 |
|
|
else |
178 |
|
|
echo 'no file:' $BATCH_SCRIPT 'to submit' | tee -a $LOG_FIL |
179 |
|
|
fi |
180 |
|
|
done |
181 |
|
|
echo "info-sub-list: NB_SUB_JOBS='$NB_SUB_JOBS'" >> $LOG_FIL |
182 |
|
|
echo -n '-- Finished at: ' | tee -a $LOG_FIL |
183 |
|
|
date | tee -a $LOG_FIL |
184 |
|
|
|
185 |
|
|
#---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
186 |
|
|
exit 0 |