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

Diff of /MITgcm_contrib/test_scripts/svante/test_submit_svante

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

revision 1.17 by jmc, Mon Feb 5 13:36:05 2018 UTC revision 1.27 by jmc, Mon Nov 6 13:35:50 2023 UTC
# Line 8  dInWeek=`date +%a` Line 8  dInWeek=`date +%a`
8    
9  if test $# = 0  if test $# = 0
10  then  then
11    TEST_LIST='ifcMPI pgiMPI pgiAdm pgiMth'    TEST_LIST='ifcMpi ifcAdm pgiMpi pgiAdm pgiMth'
12  else  else
13    TEST_LIST=$*    TEST_LIST=$*
14  fi  fi
15    
16  headNode=`hostname -s`  headNode=`hostname -s`
17  #QSUB="qsub"  #QSUB="qsub"
18  #QSTAT="qstat -u $USER"  #QLIST="qstat -u $USER"
19  #dNam=$headNode  #dNam=$headNode
20  QSUB="/usr/bin/sbatch"  QSUB="/usr/bin/sbatch"
21  QLIST="/usr/bin/squeue -u $USER"  QLIST="/usr/bin/squeue -u $USER"
# Line 23  dNam='svante' Line 23  dNam='svante'
23  HERE="$HOME/test_${dNam}"  HERE="$HOME/test_${dNam}"
24  TST_DISK="/net/fs09/d1/jm_c"  TST_DISK="/net/fs09/d1/jm_c"
25  TST_DIR="$TST_DISK/test_${dNam}"  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):  #- where local copy of code is (need to be consistent with run-job scripts):
28  #srcDIR=$TST_DIR  #srcDIR=$TST_DIR
29  srcDIR=$HERE  srcDIR=$HERE
# Line 49  if test $n -gt 0 ; then Line 50  if test $n -gt 0 ; then
50      ls -t  $logPfix.*.log | tail -"$n" | xargs rm -f      ls -t  $logPfix.*.log | tail -"$n" | xargs rm -f
51  fi  fi
52    
53    if test -d backup ; then
54      echo ' from "backup/", remove *.tar.gz files & gzip previous *.tar files'
55      n1=`ls backup/*.tar.gz | wc -l` ; n2=`ls backup/*.tar | wc -l`
56      echo " from 'backup/', remove $n1 *.tar.gz files:"    >> $LOG_FIL 2>&1
57      ( cd backup ; rm -f ??_${dNam}*.tar.gz )              >> $LOG_FIL 2>&1
58      echo "         and gzip previous $n2 *.tar files:"    >> $LOG_FIL 2>&1
59      ( cd backup ; gzip -9 ??_${dNam}*.tar ; ls -l *.tar.gz ) >> $LOG_FIL 2>&1
60    else
61      echo ' create dir "backup/" for backup tar files:'    | tee -a $LOG_FIL
62      mkdir backup
63    fi
64  #-------------------------------------------------------------  #-------------------------------------------------------------
65  # defaults  # defaults
66  #export PATH="$PATH:/usr/local/bin"  #export PATH="$PATH:/usr/local/bin"
# Line 65  if test -f /etc/profile.d/zz_modules.sh Line 77  if test -f /etc/profile.d/zz_modules.sh
77  module add slurm  module add slurm
78  module list                                             >> $LOG_FIL 2>&1  module list                                             >> $LOG_FIL 2>&1
79    
80  #- method to acces CVS:  #- method to access CVS:
81  cmdCVS='cvs -d :pserver:cvsanon@mitgcm.org:/u/gcmpack -q'    cmdCVS='cvs -d :pserver:cvsanon@mitgcm.org:/u/gcmpack -q'
82    #- which GitHub repository to use and how to access it:
83      git_repo='MITgcm';  git_code='MITgcm' ; git_other='verification_other'
84     #git_repo='altMITgcm'; #git_code='MITgcm66h'
85    #--
86      git_repo="https://github.com/$git_repo"
87     #git_repo="git://github.com/$git_repo"
88     #git_repo="git@github.com:$git_repo"
89    
 #---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|  
 #-- Download/Update reference version of MITgcm code:  
90  checkOut=1  checkOut=1
91  exp2add=''  addExp=''
92  updFile='updated_code'  updFile='updated_code'
93    
94  if test $srcDIR = $TST_DIR ; then  #---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
95    echo "cd $TST_DISK ; pwd (x2)" | tee -a $LOG_FIL  if [ $checkOut -ge 1 ] ; then
96    cd $TST_DISK  | tee -a $LOG_FIL 2>&1  #-- Download/Update reference version of MITgcm code:
   pwd           | tee -a $LOG_FIL  
 fi  
 if test ! -d $srcDIR ; then  
    echo -n "Creating a working dir: $srcDIR ..."        | tee -a $LOG_FIL  
   #/bin/rm -rf $srcDIR  
    mkdir $srcDIR  
    retVal=$?  
    if test "x$retVal" != x0 ; then  
       echo "Error: unable to make dir: $srcDIR (err=$retVal ) --> Exit" | tee -a $LOG_FIL  
       exit 1  
    fi  
 fi  
 cd $srcDIR  
 pwd             | tee -a $LOG_FIL  
97    
98  #- remove date/lock-file:    if test $srcDIR = $TST_DIR ; then
99  if test -f $updFile ; then rm -f $updFile ; sleep 2 ; fi      echo "cd $TST_DISK ; pwd (x2)" | tee -a $LOG_FIL
100        cd $TST_DISK        | tee -a $LOG_FIL 2>&1
101        pwd                 | tee -a $LOG_FIL
102      fi
103      if test ! -d $srcDIR ; then
104         echo -n "Creating a working dir: $srcDIR ..."      | tee -a $LOG_FIL
105        #/bin/rm -rf $srcDIR
106         mkdir $srcDIR
107         retVal=$?
108         if test "x$retVal" != x0 ; then
109           echo "Error: unable to make dir: $srcDIR (err=$retVal ) --> Exit" | tee -a $LOG_FIL
110           exit 1
111         fi
112      fi
113      cd $srcDIR
114      pwd           | tee -a $LOG_FIL
115    
116  if [ $checkOut -eq 1 ] ; then    #- remove date/lock-file and old copy:
117    if test -d $srcCode/CVS ; then    if test -f $updFile ; then rm -f $updFile ; sleep 2 ; fi
118      echo -n "Update dir $srcCode using '$cmdCVS update -P -d' ..." | tee -a $LOG_FIL    test -e $srcCode && rm -rf $srcCode
119      echo '' >> $LOG_FIL  
120      ( cd $srcCode ; $cmdCVS update -P -d )              >> $LOG_FIL 2>&1    if [ $checkOut -eq 1 ] ; then
121      RETVAL=$?      if test ! -e $git_code/.git/config ; then
122      if test "x$RETVAL" != x0 ; then echo ''        echo "no file: $git_code/.git/config => try a new clone"  | tee -a $LOG_FIL
123         echo "cvs update on '"`hostname`"' fail (return val=$RETVAL) => exit" | tee -a $LOG_FIL        checkOut=2
124         exit      fi
125      else echo "  done"                                  | tee -a $LOG_FIL      if test ! -e $git_other/.git/config ; then
126          echo "no file: $git_other/.git/config => try a new clone" | tee -a $LOG_FIL
127          checkOut=2
128      fi      fi
  else  
     echo "no dir: $srcCode/CVS => try a fresh check-out"        | tee -a $LOG_FIL  
     checkOut=2  
129    fi    fi
130  fi    if [ $checkOut -eq 2 ] ; then
131  if [ $checkOut -eq 2 ] ; then      if test -e $git_code ; then
132      test -e $srcCode && rm -rf $srcCode         echo -n " removing dir: $git_code ..."           | tee -a $LOG_FIL
133      echo -n "Downloading using '$cmdCVS co -P -d $srcCode MITgcm' ..."  | tee -a $LOG_FIL         rm -rf $git_code
134      $cmdCVS co -P -d $srcCode MITgcm > /dev/null         echo "  done"                                    | tee -a $LOG_FIL
135      RETVAL=$?      fi
136      if test "x$RETVAL" != x0 ; then echo ''             | tee -a $LOG_FIL      echo -n "Make a clone of $git_code from repo: $git_repo ..."        | tee -a $LOG_FIL
137        echo "cvs co on '"`hostname`"' fail (return val=$RETVAL) => exit" | tee -a $LOG_FIL      git clone $git_repo/${git_code}.git 2> $tmpFil
138        exit      retVal=$?
139        if test $retVal = 0 ; then
140           echo ' --> done!'                                | tee -a $LOG_FIL
141           rm -f $tmpFil
142        else echo ''                                        | tee -a $LOG_FIL
143           echo " Error: 'git clone' returned: $retVal"     | tee -a $LOG_FIL
144           cat $tmpFil ; rm -f $tmpFil
145           exit 2
146        fi
147       #--
148        if test -e $git_other ; then
149           echo -n " removing dir: $git_other ..."          | tee -a $LOG_FIL
150           rm -rf $git_other
151           echo "  done"                                    | tee -a $LOG_FIL
152        fi
153        echo -n "Make a clone of $git_other from repo: $git_repo ..."       | tee -a $LOG_FIL
154        git clone $git_repo/${git_other}.git 2> $tmpFil
155        retVal=$?
156        if test $retVal = 0 ; then
157           echo ' --> done!'                                | tee -a $LOG_FIL
158           rm -f $tmpFil
159        else echo ''                                        | tee -a $LOG_FIL
160           echo " Error: 'git clone' returned: $retVal"     | tee -a $LOG_FIL
161           cat $tmpFil ; rm -f $tmpFil
162           exit 2
163        fi
164      fi
165      #--
166      if [ $checkOut -eq 1 ] ; then
167        echo -n "Updating current clone ( $git_code ) ..."  | tee -a $LOG_FIL
168        echo '' >> $LOG_FIL
169        ( cd $git_code ; git pull )                         >> $LOG_FIL 2>&1
170        retVal=$?
171        if test "x$retVal" != x0 ; then echo ''
172             echo "'git pull' on '"`hostname`"' fail (return val=$retVal) => exit" | tee -a $LOG_FIL
173             exit
174      else echo "  done"                                  | tee -a $LOG_FIL      else echo "  done"                                  | tee -a $LOG_FIL
175      fi      fi
176      if test -d $srcCode/verification ; then      echo "  and checkout master:"                       | tee -a $LOG_FIL
177        for exp2add in $addExp ; do      ( cd $git_code ; git checkout master -- . )         | tee -a $LOG_FIL
178          echo " add dir: $exp2add (from Contrib:verification_other)" | tee -a $LOG_FIL     #---
179          ( cd $srcCode/verification ; $cmdCVS co -P -d $exp2add \      echo -n "Updating current clone ( $git_other ) ..." | tee -a $LOG_FIL
180                         MITgcm_contrib/verification_other/$exp2add > /dev/null )      echo '' >> $LOG_FIL
181        done      ( cd $git_other ; git pull )                        >> $LOG_FIL 2>&1
182        retVal=$?
183        if test "x$retVal" != x0 ; then echo ''
184             echo "'git pull' on '"`hostname`"' fail (return val=$retVal) => exit" | tee -a $LOG_FIL
185             exit
186        else echo "  done"                                  | tee -a $LOG_FIL
187      fi      fi
188      /usr/bin/find $srcCode -type d | xargs chmod g+rxs      echo "  and checkout master:"                       | tee -a $LOG_FIL
189      /usr/bin/find $srcCode -type f | xargs chmod g+r      ( cd $git_other ; git checkout master -- . )        | tee -a $LOG_FIL
190  fi    fi
191      #---- making a new working copy: MITgcm_today
192      rsync -a $git_code/ $srcCode --exclude '.git'
193      ls -ld $srcCode                                       | tee -a $LOG_FIL
194      /usr/bin/find $srcCode -type d | xargs chmod g+rxs
195      /usr/bin/find $srcCode -type f | xargs chmod g+r
196      #- update date/lock-file:
197      if test -d $srcCode/verification ; then
198        echo $today > $updFile ; sleep 2
199        ls -l $updFile                                      | tee -a $LOG_FIL
200        echo ''                                             | tee -a $LOG_FIL
201      fi
202    
203  #- update date/lock-file:  #-- Done with Download/Update of MITgcm code
 if test -d $srcCode/verification ; then  
   echo $today > $updFile ; sleep 2  
   ls -l $updFile                                        | tee -a $LOG_FIL  
204  fi  fi
205    #---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
206    
207  #-- leave TST Dir and go back to output dir  #-- leave srcDIR and go back to output dir
208  cd $OUT_DIR  cd $OUT_DIR
 #---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|  
209  #-- now really do something:  #-- now really do something:
210    
211    JOB_LIST=$TEST_LIST    JOB_LIST=$TEST_LIST
212    NB_SUB_JOBS=0    NB_SUB_JOBS=0
213    for i in $JOB_LIST    for i in $JOB_LIST
214    do    do
215      case $i in      sfx=`echo ${i} | sed 's/^.../&_/' | tr '[:upper:]' '[:lower:]'`
       'pgiAdm') sfx='pgi_adm' ;;  
       'pgiMth') sfx='pgi_mth' ;;  
              *) sfx=`echo ${i} | sed 's/MPI$/_mpi/'`  ;;  
     esac  
216      BATCH_SCRIPT="test_${dNam}_$sfx"      BATCH_SCRIPT="test_${dNam}_$sfx"
217      if test -f $SUB_DIR/$BATCH_SCRIPT ; then      if test -f $SUB_DIR/$BATCH_SCRIPT ; then
218        #- job name ( $JOB ) & output-file name ( $JOB.std??? ) must match        #- job name ( $JOB ) & output-file name ( $JOB.std??? ) must match
219        #  definition within $BATCH_SCRIPT slurm script        #  definition within $BATCH_SCRIPT slurm script
220        JOB="${i}_tst"        JOB="${i}_tst"
221        sJob=`printf "%8.8s" $JOB` #- squeue truncate name to only 1rst 8c        sJob=`printf "%8.8s" $JOB` #- squeue truncate name to only 1rst 8c
222        #job_exist=`$QSTAT | grep $JOB | wc -l`        #job_exist=`$QLIST | grep $JOB | wc -l`
223        job_exist=`$QLIST | grep $sJob | wc -l`        job_exist=`$QLIST | grep $sJob | wc -l`
224        if test "x_$job_exist" = x_0 ; then        if test "x_$job_exist" = x_0 ; then
225          #-- move previous output file          #-- move previous output file
# Line 179  cd $OUT_DIR Line 240  cd $OUT_DIR
240          else echo " no old output files from job '$JOB'" | tee -a $LOG_FIL          else echo " no old output files from job '$JOB'" | tee -a $LOG_FIL
241          fi          fi
242          #-- submit job          #-- submit job
243            echo -n "--> $JOB : "                         | tee -a $LOG_FIL            echo -n "--> $JOB : $BATCH_SCRIPT , "         | tee -a $LOG_FIL
244            $QSUB $SUB_DIR/$BATCH_SCRIPT                  | tee -a $LOG_FIL            $QSUB $SUB_DIR/$BATCH_SCRIPT                  | tee -a $LOG_FIL
245            NB_SUB_JOBS=`expr $NB_SUB_JOBS + 1`            NB_SUB_JOBS=`expr $NB_SUB_JOBS + 1`
246              sleep 1
247        else        else
248            echo "--> $JOB :"                             | tee -a $LOG_FIL            echo "--> $JOB :"                             | tee -a $LOG_FIL
           #$QSTAT | grep $JOB                           | tee -a $LOG_FIL  
249            $QLIST | grep $sJob                           | tee -a $LOG_FIL            $QLIST | grep $sJob                           | tee -a $LOG_FIL
250            echo ' job already exist => skip this test'   | tee -a $LOG_FIL            echo ' job already exist => skip this test'   | tee -a $LOG_FIL
251        fi        fi
# Line 192  cd $OUT_DIR Line 253  cd $OUT_DIR
253         echo 'no file:' $BATCH_SCRIPT 'to submit'        | tee -a $LOG_FIL         echo 'no file:' $BATCH_SCRIPT 'to submit'        | tee -a $LOG_FIL
254      fi      fi
255    done    done
256    echo "info-sub-list: NB_SUB_JOBS='$NB_SUB_JOBS'"      >> $LOG_FIL    #echo "info-sub-list: NB_SUB_JOBS='$NB_SUB_JOBS'"     >> $LOG_FIL
257      echo "Submitted $NB_SUB_JOBS jobs from dir: $SUB_DIR" | tee -a $LOG_FIL
258    echo -n '-- Finished at: '                            | tee -a $LOG_FIL    echo -n '-- Finished at: '                            | tee -a $LOG_FIL
259    date                                                  | tee -a $LOG_FIL    date                                                  | tee -a $LOG_FIL
260    

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.27

  ViewVC Help
Powered by ViewVC 1.1.22