/[MITgcm]/MITgcm_contrib/test_scripts/svante/test_submit_svante
ViewVC logotype

Contents of /MITgcm_contrib/test_scripts/svante/test_submit_svante

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.13 - (show annotations) (download)
Fri Apr 14 21:02:06 2017 UTC (8 years, 3 months ago) by jmc
Branch: MAIN
Changes since 1.12: +5 -7 lines
change job name

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

  ViewVC Help
Powered by ViewVC 1.1.22