/[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.17 - (show annotations) (download)
Mon Feb 5 13:36:05 2018 UTC (7 years, 5 months ago) by jmc
Branch: MAIN
Changes since 1.16: +3 -3 lines
switch to local "/scratch/" disk

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

  ViewVC Help
Powered by ViewVC 1.1.22