/[MITgcm]/MITgcm_contrib/test_scripts/nasa_ames/test_submit_pleiades
ViewVC logotype

Annotation of /MITgcm_contrib/test_scripts/nasa_ames/test_submit_pleiades

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


Revision 1.2 - (hide annotations) (download)
Fri Feb 9 22:46:11 2018 UTC (8 years, 8 months ago) by jmc
Branch: MAIN
Changes since 1.1: +86 -61 lines
change to use new code repository on GitHub

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

  ViewVC Help
Powered by ViewVC 1.1.22