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