/[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.19 - (show annotations) (download)
Fri Feb 9 17:22:14 2018 UTC (7 years, 5 months ago) by jmc
Branch: MAIN
Changes since 1.18: +4 -2 lines
minor improvement to log file report

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

  ViewVC Help
Powered by ViewVC 1.1.22