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

Annotation of /MITgcm_contrib/test_scripts/svante/test_submit_svante

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


Revision 1.10 - (hide annotations) (download)
Mon Jan 16 14:20:00 2017 UTC (8 years, 6 months ago) by jmc
Branch: MAIN
Changes since 1.9: +2 -2 lines
fix typo

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

  ViewVC Help
Powered by ViewVC 1.1.22