/[MITgcm]/MITgcm_contrib/test_scripts/svante/test_comp_pgiAdm.sh
ViewVC logotype

Annotation of /MITgcm_contrib/test_scripts/svante/test_comp_pgiAdm.sh

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


Revision 1.1 - (hide annotations) (download) (as text)
Fri Jan 13 22:40:45 2017 UTC (8 years, 6 months ago) by jmc
Branch: MAIN
File MIME type: application/x-sh
add (TAF) adjoint test using PGI & MPI: run staf on head-node and
 compile and run in SLURM batch job (for now, on fdr partition)

1 jmc 1.1 #! /usr/bin/env bash
2    
3     # $Header: /u/gcmpack/MITgcm_contrib/test_scripts/svante/test_comp_ifc.sh,v 1.1 2017/01/12 17:36:35 jmc Exp $
4    
5     # Test script for MITgcm to run on head-node of svante cluster (svante-login.mit.edu)
6     # to just generate source code (*.f) including TAF output src code.
7    
8     headNode=`hostname -s`
9     #QSUB="qsub"
10     #QSTAT="qstat -a | grep $USER"
11     #dNam=$headNode
12     QSUB="/usr/bin/sbatch"
13     QSTAT="/usr/bin/squeue -u $USER"
14     dNam='svante'
15     HERE="$HOME/test_${dNam}"
16    
17     SUB_DIR="$HERE/$dNam"
18     OUT_DIR="$HERE/output"
19     TST_DISK="/net/fs09/d0/jm_c"
20     TST_DIR="$TST_DISK/test_${dNam}"
21     #SUB_DIR="$HERE/temp"
22    
23     dInWeek=`date +%a`
24     TODAY=`date +%d`
25    
26     #- main options
27     sfx='pgiAdm'; typ='-adm'
28     addExp=''
29    
30     logPfix="test_comp_$sfx"
31     tst2submit="run_tst_$sfx"
32    
33     #-------------------------------
34     # checkOut=2 : download new code ;
35     # =1 : update code (if no existing code -> swith to 2)
36     # =0 : use existing code (if no existing code -> swith to 2)
37     checkOut=1
38     option=
39    
40     #option="-nc" ; checkOut=1
41     #option="-q" ; checkOut=0
42    
43     dAlt=`date +%d` ; dAlt=`expr $dAlt % 3`
44     if [ $dAlt -eq 1 ] ; then options="$options -fast"
45     else options="$options -devel" ; fi
46    
47     #- defaults
48     umask 0022
49     if [ -d ~/bin ]; then export PATH=$PATH:~/bin ; fi
50     #- to get case insensitive "ls" (and order of tested experiments)
51     export LC_ALL="en_US.UTF-8"
52     # Turn off stack limit for FIZHI & AD-tests
53     ulimit -s unlimited
54    
55     if test -f /etc/profile.d/modules.sh ; then . /etc/profile.d/modules.sh ; fi
56     if test -f /etc/profile.d/zz_modules.sh ; then . /etc/profile.d/zz_modules.sh ; fi
57    
58     #- method to acces CVS:
59     cmdCVS='cvs -d :pserver:cvsanon@mitgcm.org:/u/gcmpack -q'
60    
61     #-- clean up old log files and start a new one:
62     LOG_FIL="$OUT_DIR/$logPfix."`date +%m%d`".log"
63     cd $OUT_DIR
64    
65     rm -f $logPfix.*.log_bak
66     if test -f $LOG_FIL ; then mv -f $LOG_FIL ${LOG_FIL}_bak ; fi
67     echo -n '-- Starting: ' | tee -a $LOG_FIL
68     date | tee -a $LOG_FIL
69    
70     n=$(( `ls $logPfix.*.log | wc -l` - 10 ))
71     if test $n -gt 0 ; then
72     echo ' remove old log files:' | tee -a $LOG_FIL
73     ls -lt $logPfix.*.log | tail -"$n" | tee -a $LOG_FIL
74     ls -t $logPfix.*.log | tail -"$n" | xargs rm -f
75     fi
76    
77     #- load standard modules:
78     module add slurm
79    
80     #- load specific modules & set ENV variables:
81     module add pgi/16.9
82     module add openmpi
83     module add netcdf
84     OPTFILE="../tools/build_options/linux_amd64_pgf77"
85     MPI=6
86     #- needed for DIVA with MPI:
87     export MPI_INC_DIR="/home/software/pgi/16.9/linux86-64/2016/mpi/openmpi-1.10.2/include"
88    
89     echo '======= modules =======================================' | tee -a $LOG_FIL
90     module list 2>&1 | tee -a $LOG_FIL
91     echo '=======================================================' | tee -a $LOG_FIL
92    
93     dInWeek=`date +%a`
94     TODAY=`date +%d`
95     #tst_list='gads gadm gfo+rs gmpi gmth gmp2+rs ifc pgi'
96     #if test "x$dInWeek" = xSun ; then tst_list="$tst_list tlm oad" ; fi
97     tst_list='pgiAdm'
98    
99     echo "cd $TST_DISK ; pwd (x2)" | tee -a $LOG_FIL
100     cd $TST_DISK 2>&1 | tee -a $LOG_FIL
101     pwd | tee -a $LOG_FIL
102     if test ! -d $TST_DIR ; then
103     echo -n "Creating a working dir: $TST_DIR ..." | tee -a $LOG_FIL
104     #/bin/rm -rf $TST_DIR
105     mkdir $TST_DIR
106     retVal=$?
107     if test "x$retVal" != x0 ; then
108     echo "Error: unable to make dir: $TST_DIR (err=$retVal ) --> Exit" | tee -a $LOG_FIL
109     exit 1
110     fi
111     fi
112     cd $TST_DIR
113     pwd | tee -a $LOG_FIL
114    
115     #------------------------------------------------------------------------
116    
117     echo "================================================================"
118     gcmDIR="MITgcm_$sfx"
119    
120     #- check day and time:
121     curDay=`date +%d` ; curHour=`date +%H`
122     if [ $curDay -ne $TODAY ] ; then
123     date ; echo "day is over => skip test $sfx" | tee -a $LOG_FIL
124     exit 2
125     fi
126     if [ $curHour -ge 18 ] ; then
127     date ; echo "too late to run test $sfx" | tee -a $LOG_FIL
128     exit 2
129     fi
130     #- check for unfinished jobs
131     job_exist=`$QSTAT | grep $tst2submit | wc -l`
132     if test "x$job_exist" != x0 ; then
133     echo $tst2submit | tee -a $LOG_FIL
134     echo "job '$tst2submit' still in queue:" | tee -a $LOG_FIL
135     $QSTAT | grep $tst2submit | tee -a $LOG_FIL
136     echo " => skip this test" | tee -a $LOG_FIL
137     exit 2
138     fi
139     if test -d prev ; then
140     #-- save previous summary: tr_out.txt* tst_2+2_out.txt
141     oldS=`( cd ${gcmDIR}/verification ; ls t*_out.txt* ) 2> /dev/null`
142     for xx in $oldS ; do
143     #ss=`/bin/ls -l ${gcmDIR}/verification/$xx | awk '{print $6 $7}'`
144     ss=`/bin/ls -l --time-style=iso ${gcmDIR}/verification/$xx | awk '{print $6}'`
145     yy=`echo $xx | sed -e "s/\.txt.old/.$sfx.c/" \
146     -e "s/2_out.txt/2.$sfx./" -e "s/\.txt/.$sfx.r/"`
147     cp -p ${gcmDIR}/verification/$xx prev/${yy}$ss
148     done
149     fi
150     # touch $LOG_FIL
151    
152     #- clean and update code
153     if [ $checkOut -eq 1 ] ; then
154     if test -d $gcmDIR/CVS ; then
155     echo "cleaning output from $gcmDIR/verification :" | tee -a $LOG_FIL
156     #- remove previous output tar files and tar & remove previous output-dir
157     /bin/rm -f $gcmDIR/verification/??_${dNam}*_????????_?.tar.gz
158     ( cd $gcmDIR/verification
159     listD=`ls -1 -d tr_${headNode}_????????_? ??_${dNam}-${sfx}_????????_? 2> /dev/null`
160     for dd in $listD
161     do
162     if test -d $dd ; then
163     tar -cf ${dd}".tar" $dd > /dev/null 2>&1 && gzip ${dd}".tar" && /bin/rm -rf $dd
164     retVal=$?
165     if test "x$retVal" != x0 ; then
166     echo "ERROR in tar+gzip prev outp-dir: $dd"
167     echo " on '"`hostname`"' (return val=$retVal) but continue"
168     fi
169     fi
170     done )
171     # ( cd $gcmDIR/verification ; ../tools/do_tst_2+2 -clean ) >> $LOG_FIL 2>&1
172     ( cd $gcmDIR/verification ; ./testreport $typ -clean ) >> $LOG_FIL 2>&1
173     echo "cvs update of dir $gcmDIR :" | tee -a $LOG_FIL
174     ( cd $gcmDIR ; $cmdCVS update -P -d ) >> $LOG_FIL 2>&1
175     retVal=$?
176     if test "x$retVal" != x0 ; then
177     echo "cvs update on '"`hostname`"' fail (return val=$retVal) => exit"
178     exit 3
179     fi
180     else
181     echo "no dir: $gcmDIR/CVS => try a fresh check-out" | tee -a $LOG_FIL
182     checkOut=2
183     fi
184     fi
185     #- download new code
186     if [ $checkOut -eq 2 ] ; then
187     test -e $gcmDIR && rm -rf $gcmDIR
188     echo -n "Downloading the MITgcm code using: $cmdCVS ..." | tee -a $LOG_FIL
189     $cmdCVS co -P -d $gcmDIR MITgcm > /dev/null
190     echo " done" | tee -a $LOG_FIL
191     for exp2add in $addExp ; do
192     echo " add dir: $exp2add (from Contrib:verification_other)"| tee -a $LOG_FIL
193     ( cd $gcmDIR/verification ; $cmdCVS co -P -d $exp2add \
194     MITgcm_contrib/verification_other/$exp2add > /dev/null 2>&1 )
195     done
196     /usr/bin/find $gcmDIR -type d | xargs chmod g+rxs
197     /usr/bin/find $gcmDIR -type f | xargs chmod g+r
198     fi
199     #---------------------------------------------------
200     #-- set the testreport command:
201     comm="./testreport $typ"
202    
203     #-- run the testreport command:
204     echo -n "Running testreport using" | tee -a $LOG_FIL
205     if test $MPI != 0 ; then comm="$comm -MPI $MPI" ; fi
206     if test "x$options" != x ; then comm="$comm $options" ; fi
207     if test "x$OPTFILE" != x ; then
208     comm="$comm -of=$OPTFILE"
209     fi
210     echo " only produces fortran source-files ('-src'):" | tee -a $LOG_FIL
211     comm="$comm -src"
212     echo " \"eval $comm\"" | tee -a $LOG_FIL
213     echo "======================"
214     ( cd $gcmDIR/verification
215     eval $comm >> $LOG_FIL 2>&1
216     )
217     #sed -n "/^An email /,/^======== End of testreport / p" $LOG_FIL
218     sed -n "/^No results email was sent/,/^======== End of testreport / p" $LOG_FIL
219     echo "" | tee -a $LOG_FIL
220    
221     #-- submit SLURM script to run
222     if test -e $SUB_DIR/${tst2submit}.slurm ; then
223     echo " submit SLURM bach script '$SUB_DIR/${tst2submit}.slurm'" | tee -a $LOG_FIL
224     $QSUB $SUB_DIR/${tst2submit}.slurm | tee -a $LOG_FIL
225     echo " job '$tst2submit' in queue:" | tee -a $LOG_FIL
226     $QSTAT | grep $tst2submit | tee -a $LOG_FIL
227     else
228     echo " no SLURM script '$SUB_DIR/${tst2submit}.slurm' to submit" | tee -a $LOG_FIL
229     continue
230     fi
231    

  ViewVC Help
Powered by ViewVC 1.1.22