/[MITgcm]/MITgcm_contrib/test_scripts/engaging/test_submit_engag
ViewVC logotype

Diff of /MITgcm_contrib/test_scripts/engaging/test_submit_engag

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

revision 1.2 by jmc, Wed Oct 21 14:01:55 2015 UTC revision 1.11 by jmc, Mon Oct 31 03:25:50 2022 UTC
# Line 6  Line 6 
6  today=`date +%Y%m%d`  today=`date +%Y%m%d`
7  dInWeek=`date +%a`  dInWeek=`date +%a`
8    
9    #- select type of BATCH_SCRIPT to submit:
10    typ=''
11    if [ $# -ge 1 ] ; then
12      case $1 in
13      'c6'|'c7') typ=".$1" ; shift ;;
14      esac
15    fi
16    
17  if test $# = 0  if test $# = 0
18  then  then
19    TEST_LIST='o64Adm gfoTlm'    TEST_LIST='gfoAdm ifcMpi ifcMp2 o64Adm o64Mpi gfoTlm'
20   #if test "x$dInWeek" = xSun ; then TEST_LIST="$TEST_LIST iad ifc oad" ; fi   #if test "x$dInWeek" = xSun ; then TEST_LIST="$TEST_LIST iad ifc oad" ; fi
21  else  else
22    TEST_LIST=$*    TEST_LIST=$*
23  fi  fi
24    
25  QSUB="/usr/bin/sbatch"  QSUB="/usr/bin/sbatch"
26  QSTAT="/usr/bin/qstat"  #QLIST="/usr/bin/qstat -u $USER"
27    QLIST="/usr/bin/squeue -u $USER"
28  dNam='engaging'  dNam='engaging'
29  HERE="$HOME/test_$dNam"  HERE="$HOME/test_$dNam"
30  TST_DIR="/pool001/jm_c/test_$dNam"  TST_DIR="/pool001/jm_c/test_$dNam"
# Line 24  logPfix='test_submit' Line 33  logPfix='test_submit'
33  SUB_DIR="$HERE/engaging"  SUB_DIR="$HERE/engaging"
34  OUT_DIR="$HERE/output"  OUT_DIR="$HERE/output"
35  LOG_FIL="$OUT_DIR/$logPfix."`date +%m%d`".log"  LOG_FIL="$OUT_DIR/$logPfix."`date +%m%d`".log"
36  #SUB_DIR="$HERE/temp"  #SUB_DIR="$HERE/local"
37    
38  #-- clean up old log files and start a new one:  #-- clean up old log files and start a new one:
39  cd $OUT_DIR  cd $OUT_DIR
40    
41  rm -f $logPfix.*.log_bak  rm -f $logPfix.*.log_bak
42  if test -f $LOG_FIL ; then mv -f $LOG_FIL ${LOG_FIL}_bak ; fi  if test -f $LOG_FIL ; then mv -f $LOG_FIL ${LOG_FIL}_bak ; fi
43  echo -n '-- Starting: ' | tee -a $LOG_FIL  echo -n '-- Starting: '                                 | tee -a $LOG_FIL
44  date | tee -a $LOG_FIL  date                                                    | tee -a $LOG_FIL
45    
46  n=$(( `ls $logPfix.*.log | wc -l` - 10 ))  n=$(( `ls $logPfix.*.log | wc -l` - 10 ))
47  if test $n -gt 0 ; then  if test $n -gt 0 ; then
48    echo ' remove old log files:' | tee -a $LOG_FIL    echo ' remove old log files:'                         | tee -a $LOG_FIL
49      ls -lt $logPfix.*.log | tail -"$n" | tee -a $LOG_FIL      ls -lt $logPfix.*.log | tail -"$n"                  | tee -a $LOG_FIL
50      ls -t  $logPfix.*.log | tail -"$n" | xargs rm -f      ls -t  $logPfix.*.log | tail -"$n" | xargs rm -f
51  fi  fi
52    
53  . /etc/profile.d/modules.sh  if test -f /etc/profile.d/modules.sh ; then
54  module list >> $LOG_FIL 2>&1    . /etc/profile.d/modules.sh
55    fi
56    module list                                             >> $LOG_FIL 2>&1
57    
58  #---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|  #---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
59  #-- now really do something:  #-- now really do something:
# Line 51  module list >> $LOG_FIL 2>&1 Line 62  module list >> $LOG_FIL 2>&1
62    NB_SUB_JOBS=0    NB_SUB_JOBS=0
63    for i in $JOB_LIST    for i in $JOB_LIST
64    do    do
65      case $i in      sfx=`echo ${i} | sed -e 's/^.../&_/' -e 's/^o64/op64/' | tr '[:upper:]' '[:lower:]'`
66        'o64Adm') sfx='op64_adm' ;;      BATCH_SCRIPT="test_engag_${sfx}${typ}"
       'gfoTlm') sfx='gfo_tlm' ;;  
              *) sfx=${i}'_mpi'  ;;  
     esac  
     BATCH_SCRIPT="test_engag_$sfx"  
67      if test -f $SUB_DIR/$BATCH_SCRIPT ; then      if test -f $SUB_DIR/$BATCH_SCRIPT ; then
68        JOB="tst_"$i        #- job name ( $JOB ) & output-file name ( $JOB.std??? ) must match
69        job_exist=`$QSTAT -a | grep $USER | grep $JOB | wc -l`        #  definition within $BATCH_SCRIPT slurm script
70          JOB="${i}_tst"
71          sJob=`printf "%8.8s" $JOB` #- squeue truncate name to only 1rst 8c
72          #job_exist=`$QLIST | grep $JOB | wc -l`
73          job_exist=`$QLIST | grep $sJob | wc -l`
74        if test "x_$job_exist" = x_0 ; then        if test "x_$job_exist" = x_0 ; then
75          #-- move previous output file          #-- move previous output file
76          outList=`ls $JOB.std??? 2> /dev/null`          outList=`ls $JOB.std??? 2> /dev/null`
77          if test "x$outList" != x ; then          if test "x$outList" != x ; then
78            echo -n " moving job $JOB old output files:" | tee -a $LOG_FIL            echo -n " moving job "$JOB" old output files:"| tee -a $LOG_FIL
79            if test -d $OUT_DIR/prev ; then            if test -d $OUT_DIR/prev ; then
80              for xx in $outList ; do              for xx in $outList ; do
81                echo -n " $xx" | tee -a $LOG_FIL                pp=$OUT_DIR/prev/$xx ; echo -n " $xx"     | tee -a $LOG_FIL
82                mv -f $xx $OUT_DIR/prev                test -f $pp.sav && mv -f $pp.sav $pp.old
83                  test -f $pp     && mv -f $pp     $pp.sav
84                  chmod a+r $xx ; mv -f $xx $OUT_DIR/prev
85              done              done
86              echo " to dir ./prev" | tee -a $LOG_FIL              echo " to dir ./prev"                       | tee -a $LOG_FIL
87            else            else
88              echo " <-- missing dir $OUT_DIR/prev" | tee -a $LOG_FIL              echo " <-- missing dir $OUT_DIR/prev"       | tee -a $LOG_FIL
89            fi            fi
90          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
91          fi          fi
92          #-- submit job          #-- submit job
93            echo -n "--> $JOB : " | tee -a $LOG_FIL            echo -n "--> $JOB : $BATCH_SCRIPT , "         | tee -a $LOG_FIL
94            $QSUB $SUB_DIR/$BATCH_SCRIPT | tee -a $LOG_FIL            $QSUB $SUB_DIR/$BATCH_SCRIPT                  | tee -a $LOG_FIL
95            NB_SUB_JOBS=`expr $NB_SUB_JOBS + 1`            NB_SUB_JOBS=`expr $NB_SUB_JOBS + 1`
96        else        else
97            echo "--> $JOB :" | tee -a $LOG_FIL            echo "--> $JOB :"                             | tee -a $LOG_FIL
98            $QSTAT -a | grep $USER | grep $JOB | tee -a $LOG_FIL            $QLIST | grep $sJob                           | tee -a $LOG_FIL
99            echo ' job already exist => skip this test' | tee -a $LOG_FIL            echo ' job already exist => skip this test'   | tee -a $LOG_FIL
100        fi        fi
101      else      else
102         echo 'no file:' $BATCH_SCRIPT 'to submit' | tee -a $LOG_FIL         echo 'no file:' $BATCH_SCRIPT 'to submit'        | tee -a $LOG_FIL
103      fi      fi
104    done    done
105    echo "info-sub-list: NB_SUB_JOBS='$NB_SUB_JOBS'" >> $LOG_FIL    #echo "info-sub-list: NB_SUB_JOBS='$NB_SUB_JOBS'"     >> $LOG_FIL
106      echo "Submitted $NB_SUB_JOBS jobs from dir: $SUB_DIR" | tee -a $LOG_FIL
107      echo -n '-- Finished at: '                            | tee -a $LOG_FIL
108      date                                                  | tee -a $LOG_FIL
109    
110  #---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|  #---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
111  exit 0  exit 0

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.11

  ViewVC Help
Powered by ViewVC 1.1.22