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" |
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 |
logPfix='test_submit' |
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" |
SUB_DIR="$HERE/$dNam" |
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" |
66 |
module add slurm |
module add slurm |
67 |
module list >> $LOG_FIL 2>&1 |
module list >> $LOG_FIL 2>&1 |
68 |
|
|
69 |
#- method to acces CVS: |
#- method to access CVS: |
70 |
cmdCVS='cvs -d :pserver:cvsanon@mitgcm.org:/u/gcmpack -q' |
cmdCVS='cvs -d :pserver:cvsanon@mitgcm.org:/u/gcmpack -q' |
71 |
|
#- which GitHub repository to use and how to access it: |
72 |
|
git_repo='MITgcm'; git_code='MITgcm' ; git_other='verification_other' |
73 |
|
#git_repo='altMITgcm'; #git_code='MITgcm66h' |
74 |
|
#-- |
75 |
|
git_repo="https://github.com/$git_repo" |
76 |
|
#git_repo="git://github.com/$git_repo" |
77 |
|
#git_repo="git@github.com:$git_repo" |
78 |
|
|
|
#---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
|
|
#-- Download/Update reference version of MITgcm code: |
|
79 |
checkOut=1 |
checkOut=1 |
80 |
gcmDIR='MITgcm' |
addExp='' |
|
exp2add='' |
|
81 |
updFile='updated_code' |
updFile='updated_code' |
82 |
|
|
83 |
echo "cd $TST_DISK ; pwd (x2)" | tee -a $LOG_FIL |
#---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
84 |
cd $TST_DISK | tee -a $LOG_FIL 2>&1 |
if [ $checkOut -ge 1 ] ; then |
85 |
pwd | tee -a $LOG_FIL |
#-- Download/Update reference version of MITgcm code: |
|
if test ! -d $TST_DIR ; then |
|
|
echo -n "Creating a working dir: $TST_DIR ..." | tee -a $LOG_FIL |
|
|
#/bin/rm -rf $TST_DIR |
|
|
mkdir $TST_DIR |
|
|
retVal=$? |
|
|
if test "x$retVal" != x0 ; then |
|
|
echo "Error: unable to make dir: $TST_DIR (err=$retVal ) --> Exit" | tee -a $LOG_FIL |
|
|
exit 1 |
|
|
fi |
|
|
fi |
|
|
cd $TST_DIR |
|
|
pwd | tee -a $LOG_FIL |
|
86 |
|
|
87 |
#- remove date/lock-file: |
if test $srcDIR = $TST_DIR ; then |
88 |
if test -f $updFile ; then rm -f $updFile ; sleep 2 ; fi |
echo "cd $TST_DISK ; pwd (x2)" | tee -a $LOG_FIL |
89 |
|
cd $TST_DISK | tee -a $LOG_FIL 2>&1 |
90 |
|
pwd | tee -a $LOG_FIL |
91 |
|
fi |
92 |
|
if test ! -d $srcDIR ; then |
93 |
|
echo -n "Creating a working dir: $srcDIR ..." | tee -a $LOG_FIL |
94 |
|
#/bin/rm -rf $srcDIR |
95 |
|
mkdir $srcDIR |
96 |
|
retVal=$? |
97 |
|
if test "x$retVal" != x0 ; then |
98 |
|
echo "Error: unable to make dir: $srcDIR (err=$retVal ) --> Exit" | tee -a $LOG_FIL |
99 |
|
exit 1 |
100 |
|
fi |
101 |
|
fi |
102 |
|
cd $srcDIR |
103 |
|
pwd | tee -a $LOG_FIL |
104 |
|
|
105 |
if [ $checkOut -eq 1 ] ; then |
#- remove date/lock-file and old copy: |
106 |
if test -d $gcmDIR/CVS ; then |
if test -f $updFile ; then rm -f $updFile ; sleep 2 ; fi |
107 |
echo -n "Update dir $gcmDIR using '$cmdCVS update -P -d' ..." | tee -a $LOG_FIL |
test -e $srcCode && rm -rf $srcCode |
108 |
echo '' >> $LOG_FIL |
|
109 |
( cd $gcmDIR ; $cmdCVS update -P -d ) >> $LOG_FIL 2>&1 |
if [ $checkOut -eq 1 ] ; then |
110 |
RETVAL=$? |
if test ! -e $git_code/.git/config ; then |
111 |
if test "x$RETVAL" != x0 ; then echo '' |
echo "no file: $git_code/.git/config => try a new clone" | tee -a $LOG_FIL |
112 |
echo "cvs update on '"`hostname`"' fail (return val=$RETVAL) => exit" | tee -a $LOG_FIL |
checkOut=2 |
113 |
exit |
fi |
114 |
else echo " done" | tee -a $LOG_FIL |
if test ! -e $git_other/.git/config ; then |
115 |
|
echo "no file: $git_other/.git/config => try a new clone" | tee -a $LOG_FIL |
116 |
|
checkOut=2 |
117 |
fi |
fi |
|
else |
|
|
echo "no dir: $gcmDIR/CVS => try a fresh check-out" | tee -a $LOG_FIL |
|
|
checkOut=2 |
|
118 |
fi |
fi |
119 |
fi |
if [ $checkOut -eq 2 ] ; then |
120 |
if [ $checkOut -eq 2 ] ; then |
if test -e $git_code ; then |
121 |
test -e $gcmDIR && rm -rf $gcmDIR |
echo -n " removing dir: $git_code ..." | tee -a $LOG_FIL |
122 |
echo -n "Downloading using '$cmdCVS co -P -d $gcmDIR MITgcm' ..." | tee -a $LOG_FIL |
rm -rf $git_code |
123 |
$cmdCVS co -P -d $gcmDIR MITgcm > /dev/null |
echo " done" | tee -a $LOG_FIL |
124 |
RETVAL=$? |
fi |
125 |
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 |
126 |
echo "cvs co on '"`hostname`"' fail (return val=$RETVAL) => exit" | tee -a $LOG_FIL |
git clone $git_repo/${git_code}.git 2> $tmpFil |
127 |
exit |
retVal=$? |
128 |
|
if test $retVal = 0 ; then |
129 |
|
echo ' --> done!' | tee -a $LOG_FIL |
130 |
|
rm -f $tmpFil |
131 |
|
else echo '' | tee -a $LOG_FIL |
132 |
|
echo " Error: 'git clone' returned: $retVal" | tee -a $LOG_FIL |
133 |
|
cat $tmpFil ; rm -f $tmpFil |
134 |
|
exit 2 |
135 |
|
fi |
136 |
|
#-- |
137 |
|
if test -e $git_other ; then |
138 |
|
echo -n " removing dir: $git_other ..." | tee -a $LOG_FIL |
139 |
|
rm -rf $git_other |
140 |
|
echo " done" | tee -a $LOG_FIL |
141 |
|
fi |
142 |
|
echo -n "Make a clone of $git_other from repo: $git_repo ..." | tee -a $LOG_FIL |
143 |
|
git clone $git_repo/${git_other}.git 2> $tmpFil |
144 |
|
retVal=$? |
145 |
|
if test $retVal = 0 ; then |
146 |
|
echo ' --> done!' | tee -a $LOG_FIL |
147 |
|
rm -f $tmpFil |
148 |
|
else echo '' | tee -a $LOG_FIL |
149 |
|
echo " Error: 'git clone' returned: $retVal" | tee -a $LOG_FIL |
150 |
|
cat $tmpFil ; rm -f $tmpFil |
151 |
|
exit 2 |
152 |
|
fi |
153 |
|
fi |
154 |
|
#-- |
155 |
|
if [ $checkOut -eq 1 ] ; then |
156 |
|
echo -n "Updating current clone ( $git_code ) ..." | tee -a $LOG_FIL |
157 |
|
echo '' >> $LOG_FIL |
158 |
|
( cd $git_code ; git pull ) >> $LOG_FIL 2>&1 |
159 |
|
retVal=$? |
160 |
|
if test "x$retVal" != x0 ; then echo '' |
161 |
|
echo "'git pull' on '"`hostname`"' fail (return val=$retVal) => exit" | tee -a $LOG_FIL |
162 |
|
exit |
163 |
else echo " done" | tee -a $LOG_FIL |
else echo " done" | tee -a $LOG_FIL |
164 |
fi |
fi |
165 |
if test -d $gcmDIR/verification ; then |
echo " and checkout master:" | tee -a $LOG_FIL |
166 |
for exp2add in $addExp ; do |
( cd $git_code ; git checkout master -- . ) | tee -a $LOG_FIL |
167 |
echo " add dir: $exp2add (from Contrib:verification_other)" | tee -a $LOG_FIL |
#--- |
168 |
( cd $gcmDIR/verification ; $cmdCVS co -P -d $exp2add \ |
echo -n "Updating current clone ( $git_other ) ..." | tee -a $LOG_FIL |
169 |
MITgcm_contrib/verification_other/$exp2add > /dev/null ) |
echo '' >> $LOG_FIL |
170 |
done |
( cd $git_other ; git pull ) >> $LOG_FIL 2>&1 |
171 |
|
retVal=$? |
172 |
|
if test "x$retVal" != x0 ; then echo '' |
173 |
|
echo "'git pull' on '"`hostname`"' fail (return val=$retVal) => exit" | tee -a $LOG_FIL |
174 |
|
exit |
175 |
|
else echo " done" | tee -a $LOG_FIL |
176 |
fi |
fi |
177 |
/usr/bin/find $gcmDIR -type d | xargs chmod g+rxs |
echo " and checkout master:" | tee -a $LOG_FIL |
178 |
/usr/bin/find $gcmDIR -type f | xargs chmod g+r |
( cd $git_other ; git checkout master -- . ) | tee -a $LOG_FIL |
179 |
fi |
fi |
180 |
|
#---- making a new working copy: MITgcm_today |
181 |
|
rsync -a $git_code/ $srcCode --exclude '.git' |
182 |
|
ls -ld $srcCode | tee -a $LOG_FIL |
183 |
|
/usr/bin/find $srcCode -type d | xargs chmod g+rxs |
184 |
|
/usr/bin/find $srcCode -type f | xargs chmod g+r |
185 |
|
#- update date/lock-file: |
186 |
|
if test -d $srcCode/verification ; then |
187 |
|
echo $today > $updFile ; sleep 2 |
188 |
|
ls -l $updFile | tee -a $LOG_FIL |
189 |
|
echo '' | tee -a $LOG_FIL |
190 |
|
fi |
191 |
|
|
192 |
#- update date/lock-file: |
#-- Done with Download/Update of MITgcm code |
|
if test -d $gcmDIR/verification ; then |
|
|
echo $today > $updFile ; sleep 2 |
|
|
ls -l $updFile | tee -a $LOG_FIL |
|
193 |
fi |
fi |
194 |
|
#---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
195 |
|
|
196 |
#-- leave TST Dir and go back to output dir |
#-- leave srcDIR and go back to output dir |
197 |
cd $OUT_DIR |
cd $OUT_DIR |
|
#---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
|
198 |
#-- now really do something: |
#-- now really do something: |
199 |
|
|
200 |
JOB_LIST=$TEST_LIST |
JOB_LIST=$TEST_LIST |
201 |
NB_SUB_JOBS=0 |
NB_SUB_JOBS=0 |
202 |
for i in $JOB_LIST |
for i in $JOB_LIST |
203 |
do |
do |
204 |
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 |
|
205 |
BATCH_SCRIPT="test_${dNam}_$sfx" |
BATCH_SCRIPT="test_${dNam}_$sfx" |
206 |
if test -f $SUB_DIR/$BATCH_SCRIPT ; then |
if test -f $SUB_DIR/$BATCH_SCRIPT ; then |
207 |
#- job name ( $JOB ) & output-file name ( $JOB.std??? ) must match |
#- job name ( $JOB ) & output-file name ( $JOB.std??? ) must match |
208 |
# definition within $BATCH_SCRIPT slurm script |
# definition within $BATCH_SCRIPT slurm script |
209 |
JOB="${i}_tst" |
JOB="${i}_tst" |
210 |
sJob=`printf "%8.8s" $JOB` #- squeue truncate name to only 1rst 8c |
sJob=`printf "%8.8s" $JOB` #- squeue truncate name to only 1rst 8c |
211 |
#job_exist=`$QSTAT | grep $JOB | wc -l` |
#job_exist=`$QLIST | grep $JOB | wc -l` |
212 |
job_exist=`$QLIST | grep $sJob | wc -l` |
job_exist=`$QLIST | grep $sJob | wc -l` |
213 |
if test "x_$job_exist" = x_0 ; then |
if test "x_$job_exist" = x_0 ; then |
214 |
#-- move previous output file |
#-- move previous output file |
229 |
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 |
230 |
fi |
fi |
231 |
#-- submit job |
#-- submit job |
232 |
echo -n "--> $JOB : " | tee -a $LOG_FIL |
echo -n "--> $JOB : $BATCH_SCRIPT , " | tee -a $LOG_FIL |
233 |
$QSUB $SUB_DIR/$BATCH_SCRIPT | tee -a $LOG_FIL |
$QSUB $SUB_DIR/$BATCH_SCRIPT | tee -a $LOG_FIL |
234 |
NB_SUB_JOBS=`expr $NB_SUB_JOBS + 1` |
NB_SUB_JOBS=`expr $NB_SUB_JOBS + 1` |
235 |
|
sleep 1 |
236 |
else |
else |
237 |
echo "--> $JOB :" | tee -a $LOG_FIL |
echo "--> $JOB :" | tee -a $LOG_FIL |
|
#$QSTAT | grep $JOB | tee -a $LOG_FIL |
|
238 |
$QLIST | grep $sJob | tee -a $LOG_FIL |
$QLIST | grep $sJob | tee -a $LOG_FIL |
239 |
echo ' job already exist => skip this test' | tee -a $LOG_FIL |
echo ' job already exist => skip this test' | tee -a $LOG_FIL |
240 |
fi |
fi |
242 |
echo 'no file:' $BATCH_SCRIPT 'to submit' | tee -a $LOG_FIL |
echo 'no file:' $BATCH_SCRIPT 'to submit' | tee -a $LOG_FIL |
243 |
fi |
fi |
244 |
done |
done |
245 |
echo "info-sub-list: NB_SUB_JOBS='$NB_SUB_JOBS'" >> $LOG_FIL |
#echo "info-sub-list: NB_SUB_JOBS='$NB_SUB_JOBS'" >> $LOG_FIL |
246 |
|
echo "Submitted $NB_SUB_JOBS jobs from dir: $SUB_DIR" | tee -a $LOG_FIL |
247 |
echo -n '-- Finished at: ' | tee -a $LOG_FIL |
echo -n '-- Finished at: ' | tee -a $LOG_FIL |
248 |
date | tee -a $LOG_FIL |
date | tee -a $LOG_FIL |
249 |
|
|