/[MITgcm]/MITgcm/tools/do_tst_2+2
ViewVC logotype

Diff of /MITgcm/tools/do_tst_2+2

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

revision 1.6 by jmc, Thu Mar 25 23:09:29 2010 UTC revision 1.13 by jmc, Thu May 19 13:18:43 2011 UTC
# Line 14  usage() Line 14  usage()
14          echo "  -skd LIST_EXP : skip experiments in LIST_EXP"          echo "  -skd LIST_EXP : skip experiments in LIST_EXP"
15          echo "  -exe  COMMAND : use COMMAND to run the tests"          echo "  -exe  COMMAND : use COMMAND to run the tests"
16          echo "  -mpi          : run the tests using MPI"          echo "  -mpi          : run the tests using MPI"
17            echo "  -mf    STRING :(MPI) file with list of possible machines to run on"
18          echo "  -o     STRING : used to build output directory name"          echo "  -o     STRING : used to build output directory name"
19          echo "                      (DEF=\"hostname\")"          echo "                      (DEF=\"hostname\")"
20          echo "  -a,-A  STRING : email address to send output to"          echo "  -a,-A  STRING : email address to send output to"
# Line 27  CLEAN=0 Line 28  CLEAN=0
28  TESTDIRS=  TESTDIRS=
29  SKIPDIRS=  SKIPDIRS=
30  SCRIPT='../tools/tst_2+2'  SCRIPT='../tools/tst_2+2'
31    LOGFILE='tst_2+2_out.log'
32  scrArg='All'  scrArg='All'
33  COMMAND=  COMMAND=
34  mpi=0  mpi=0
35    MPI_MFILE=
36  OUTDIR=`hostname | sed 's/\..*$//'`  OUTDIR=`hostname | sed 's/\..*$//'`
37  SAVELOG=0  SAVELOG=0
38  ADDRESS=  ADDRESS=
# Line 49  do Line 52  do
52        -skd  ) yy=SKIPDIRS ;;        -skd  ) yy=SKIPDIRS ;;
53        -exe  ) yy=COMMAND ;;        -exe  ) yy=COMMAND ;;
54        -mpi  ) mpi=1 ;;        -mpi  ) mpi=1 ;;
55          -mf   ) yy=MPI_MFILE ;;
56        -a    ) yy=ADDRESS ;;        -a    ) yy=ADDRESS ;;
57        -A    ) yy=ADDRESS ; SAVELOG=1 ;;        -A    ) yy=ADDRESS ; SAVELOG=1 ;;
58        -o    ) yy=OUTDIR ;;        -o    ) yy=OUTDIR ;;
# Line 95  if test $CLEAN = 1 ; then Line 99  if test $CLEAN = 1 ; then
99      if test -r $xx/$yy/data.tst ; then      if test -r $xx/$yy/data.tst ; then
100        echo "clean dir:" $xx/$yy        echo "clean dir:" $xx/$yy
101        cd $xx/$yy        cd $xx/$yy
102        echo ' ' >> outp.tst_2+2.log        echo ' ' >> $LOGFILE
103        echo $SCRIPT 4 >> outp.tst_2+2.log        echo $SCRIPT 4 >> $LOGFILE
104        $SCRIPT 4 >> outp.tst_2+2.log 2>&1        $SCRIPT 4 >> $LOGFILE 2>&1
105        cd $here        cd $here
106      fi      fi
107    done    done
# Line 106  if test $CLEAN = 1 ; then Line 110  if test $CLEAN = 1 ; then
110  fi  fi
111  #------------------------  #------------------------
112  #  Create a uniquely named directory to store results  #  Create a uniquely named directory to store results
113    CMDLINE=$0
114    for xx in "$@" ; do nw=`echo $xx | wc -w`
115        if test $nw = '1' ; then CMDLINE="$CMDLINE $xx"
116                            else CMDLINE="$CMDLINE '$xx'" ; fi
117    done
118    #for xx in "$@" ; do CMDLINE="$CMDLINE '$xx'" ; done
119  DATE=`date +%Y%m%d`  DATE=`date +%Y%m%d`
120  BASE="rs_"$OUTDIR"_"$DATE"_"  BASE="rs_"$OUTDIR"_"$DATE"_"
121  xx=0  xx=0
# Line 125  OPTFILE= Line 135  OPTFILE=
135    
136  printf "Start time:  " >  $SUMMARY  printf "Start time:  " >  $SUMMARY
137  date  >> $SUMMARY  date  >> $SUMMARY
138    echo 'run:' $CMDLINE >> $SUMMARY
139  if test -f tr_out.txt ; then  if test -f tr_out.txt ; then
140   echo ' using output from:' >> $SUMMARY   echo ' using output from:' >> $SUMMARY
141   sed -n '2,/OPTFILE/ p' tr_out.txt >> $SUMMARY   sed -n '2,/^  OPTFILE=/ p' tr_out.txt >> $SUMMARY
142   echo >> $SUMMARY   echo >> $SUMMARY
143  fi  fi
144  echo  'test 2+2=4 summary :' >> $SUMMARY  echo  'test 2+2=4 summary :' >> $SUMMARY
# Line 136  echo 'P. Run  Result     experiment'  >> Line 147  echo 'P. Run  Result     experiment'  >>
147  echo '  1 2 3'  >> $SUMMARY  echo '  1 2 3'  >> $SUMMARY
148    
149  #-- For MPI test:  #-- For MPI test:
150    LOC_MFILE='tr_mpi_mfile'
151  RUNOUTP="output.txt"  RUNOUTP="output.txt"
152  if [ $mpi -ge 1 ] ; then  if [ $mpi -ge 1 ] ; then
153    SCRIPT="$SCRIPT -mpi"    SCRIPT="$SCRIPT -mpi"
# Line 145  fi Line 157  fi
157  for xx in $LIST  for xx in $LIST
158  do  do
159    echo ==============================================================================    echo ==============================================================================
160      if [ $mpi -le 0 ] ; then
161        rCommand=$COMMAND
162      else
163        LOC_NPROC=2
164        mpi_size=$xx/build/SIZE.h.mpi
165        if test -f $mpi_size ; then
166          px=`grep '^     & *nPx *=' $mpi_size | sed 's/^     & *nPx *= *//' | sed 's/, *$//'`
167          py=`grep '^     & *nPy *=' $mpi_size | sed 's/^     & *nPy *= *//' | sed 's/, *$//'`
168          pp=`expr $px \* $py` > /dev/null 2>&1 ; out=$?
169          if test "x$out" = x0 ; then LOC_NPROC=$pp ; fi
170        fi
171        rCommand=`echo $COMMAND | sed "s/ TR_NPROC / $LOC_NPROC /"`
172        if test "x$MPI_MFILE" != x ; then
173          #- create new MPI machine-file with the right number of Procs
174          rm -f $LOC_MFILE
175          cat $MPI_MFILE | sort | uniq | head -$LOC_NPROC > $LOC_MFILE
176          nl=`wc -l $LOC_MFILE | awk '{print $1}'`
177          if [ $nl -lt $LOC_NPROC ] ; then
178            rm -f $LOC_MFILE
179            cat $MPI_MFILE | head -$LOC_NPROC > $LOC_MFILE
180          fi
181          rCommand=`echo $rCommand | sed "s/ TR_MFILE / ..\/..\/$LOC_MFILE /"`
182        fi
183      fi
184    
185    listD='run '`(cd $xx/results ; ls output.*.txt 2> /dev/null | sed 's/^output\./tr_run./g' | sed 's/\.txt$//g' )`    listD='run '`(cd $xx/results ; ls output.*.txt 2> /dev/null | sed 's/^output\./tr_run./g' | sed 's/\.txt$//g' )`
186    for yy in $listD    for yy in $listD
187    do    do
# Line 153  do Line 190  do
190          comm=`grep '^# OPTFILE=' $xx/build/Makefile 2>/dev/null | head -1 | sed 's/^# //'`          comm=`grep '^# OPTFILE=' $xx/build/Makefile 2>/dev/null | head -1 | sed 's/^# //'`
191          echo "from '$xx/build/Makefile', extract:" > $DRESULTS/genmake_state          echo "from '$xx/build/Makefile', extract:" > $DRESULTS/genmake_state
192          sed -n '/^# executed by:/,+1 p' $xx/build/Makefile >> $DRESULTS/genmake_state          sed -n '/^# executed by:/,+1 p' $xx/build/Makefile >> $DRESULTS/genmake_state
193          echo $comm >> $DRESULTS/genmake_state          echo " $comm" >> $DRESULTS/genmake_state
194          eval $comm          eval $comm
195            gmkLog=$xx/build/genmake.log
196            grep '^Get compiler version using:' $gmkLog > /dev/null 2>&1
197            out=$?
198            if test "x$out" = x0 ; then
199                echo "from '$gmkLog', extract compiler version:" >> $DRESULTS/genmake_state
200                sed -n '/Get compiler version/,/<-- compiler version/p' $gmkLog \
201                           | grep -v '^... compiler version ' > tr_vers.tmp_log
202                sed -n '1,/^$/p' tr_vers.tmp_log | sed '/^$/d' | sed 's/^./ &/' \
203                          >> $DRESULTS/genmake_state
204                rm -f tr_vers.tmp_log
205            fi
206        fi        fi
207        if test $yy = 'run' ; then nam=$xx        if test $yy = 'run' ; then nam=$xx
208        else nam=$xx`echo $yy | sed 's/tr_run//'` ; fi        else nam=$xx`echo $yy | sed 's/tr_run//'` ; fi
209        echo -n "Entering $xx/$yy :"        echo -n "Entering $xx/$yy :"
210        cd $xx/$yy        cd $xx/$yy
211        pwd > outp.tst_2+2.log        pwd > $LOGFILE
212        if test "x$COMMAND" = x ; then        if test "x$COMMAND" = x ; then
213          echo $SCRIPT $scrArg >> outp.tst_2+2.log ; echo ' ' >> outp.tst_2+2.log          echo $SCRIPT $scrArg >> $LOGFILE ; echo ' ' >> $LOGFILE
214          $SCRIPT $scrArg >> outp.tst_2+2.log 2>&1          $SCRIPT $scrArg >> $LOGFILE 2>&1
215          out=$?          out=$?
216        else        else
217          echo "$SCRIPT $scrArg -command \"$COMMAND\"" >> outp.tst_2+2.log          echo "$SCRIPT $scrArg -command \"$rCommand\"" >> $LOGFILE
218          echo ' ' >> outp.tst_2+2.log          echo ' ' >> $LOGFILE
219          $SCRIPT $scrArg -command "$COMMAND" >> outp.tst_2+2.log 2>&1          $SCRIPT $scrArg -command "$rCommand" >> $LOGFILE 2>&1
220          out=$?          out=$?
221        fi        fi
222        case $out in        case $out in
# Line 183  do Line 231  do
231        if test $out != '0' ; then        if test $out != '0' ; then
232          echo " test 2+2=4 FAIL (exit $out)"          echo " test 2+2=4 FAIL (exit $out)"
233          echo " "          echo " "
234          tail -5 outp.tst_2+2.log          tail -5 $LOGFILE
235          echo " "          echo " "
236          cp -p outp.tst_2+2.log ../../$DRESULTS/$nam.log          cp -p $LOGFILE ../../$DRESULTS/$nam.log
237        elif test $SAVELOG = 1 ; then        elif test $SAVELOG = 1 ; then
238          cp -p outp.tst_2+2.log ../../$DRESULTS/$nam.log          cp -p $LOGFILE ../../$DRESULTS/$nam.log
239        fi        fi
240        cd $here        cd $here
241      fi      fi
242    done    done
243      if test "x$mpi" != x0 -a "x$MPI_MFILE" != x ; then rm -f $LOC_MFILE ; fi
244  done  done
245  printf "End time:    " >> $SUMMARY  printf "End time:    " >> $SUMMARY
246  date >> $SUMMARY  date >> $SUMMARY

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.13

  ViewVC Help
Powered by ViewVC 1.1.22