/[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.1 by jmc, Tue Dec 25 22:10:51 2007 UTC revision 1.16 by jmc, Thu Oct 11 16:30:56 2012 UTC
# Line 1  Line 1 
1  #!/bin/sh  #! /usr/bin/env bash
2    
3  # $Header$  # $Header$
4  # $Name$  # $Name$
# Line 12  usage() Line 12  usage()
12          echo "  -help         : print usage"          echo "  -help         : print usage"
13          echo "  -t   LIST_EXP : only check experiments in LIST_EXP"          echo "  -t   LIST_EXP : only check experiments in LIST_EXP"
14          echo "  -skd LIST_EXP : skip experiments in LIST_EXP"          echo "  -skd LIST_EXP : skip experiments in LIST_EXP"
15          echo "  (-o) STRING   : used to build output directory name"          echo "  -exe  COMMAND : use COMMAND to run the tests"
16            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"
19          echo "                      (DEF=\"hostname\")"          echo "                      (DEF=\"hostname\")"
20          echo "  (-a) STRING   : email address to send output to"          echo "  -a,-A  STRING : email address to send output to"
21          echo "                      (DEF=\"\" no email is sent)"          echo "                      (DEF=\"\" no email is sent)"
22            echo "                      (-A: + save each log file)"
23          echo "  -clean        : clean output & reset"          echo "  -clean        : clean output & reset"
24          exit          exit
25  }  }
# Line 23  usage() Line 27  usage()
27  CLEAN=0  CLEAN=0
28  TESTDIRS=  TESTDIRS=
29  SKIPDIRS=  SKIPDIRS=
 OUTDIR=`hostname`  
 ADDRESS=  
30  SCRIPT='../tools/tst_2+2'  SCRIPT='../tools/tst_2+2'
31    LOGFILE='tst_2+2_out.log'
32    scrArg='All'
33    COMMAND=
34    mpi=0
35    MPI_MFILE=
36    OUTDIR=`hostname | sed 's/\..*$//'`
37    SAVELOG=0
38    ADDRESS=
39  MPACK="../tools/mpack-1.6/mpack"  MPACK="../tools/mpack-1.6/mpack"
40  here=`pwd`  here=`pwd`
41  yy=  yy=
# Line 40  do Line 50  do
50        -clean) CLEAN=1 ;;        -clean) CLEAN=1 ;;
51        -t    ) yy=TESTDIRS ;;        -t    ) yy=TESTDIRS ;;
52        -skd  ) yy=SKIPDIRS ;;        -skd  ) yy=SKIPDIRS ;;
53          -exe  ) yy=COMMAND ;;
54          -mpi  ) mpi=1 ;;
55          -mf   ) yy=MPI_MFILE ;;
56        -a    ) yy=ADDRESS ;;        -a    ) yy=ADDRESS ;;
57          -A    ) yy=ADDRESS ; SAVELOG=1 ;;
58        -o    ) yy=OUTDIR ;;        -o    ) yy=OUTDIR ;;
59          *) echo "Error: unrecognized option: "$xx ; usage ; exit ;;          *) echo "Error: unrecognized option: "$xx ; usage ; exit ;;
60        esac        esac
# Line 48  do Line 62  do
62  done  done
63  #------------------------  #------------------------
64    
65  if test "x$TESTDIRS" = x  if test "x$TESTDIRS" = x ; then TESTDIRS=`ls ` ; fi
 then  
  TESTDIRS=`ls `  
 fi  
66  LIST=""  LIST=""
67  for xx in $TESTDIRS  for xx in $TESTDIRS
68  do  do
69    yy=`echo $SKIPDIRS | grep -c $xx`    yy=`echo $SKIPDIRS | grep -c $xx`
70    if test $yy = 0 ; then    if test $yy = 0 ; then
71      if test -f $xx/results/output.txt      if test -f $xx/results/output.txt ; then
     then  
72         LIST=${LIST}" "$xx         LIST=${LIST}" "$xx
73  #   else  #   else
74  #      echo ""; echo -n " -- skip \"$xx\" (not a directory !)"  #      echo ""; echo -n " -- skip \"$xx\" (not a directory !)"
# Line 69  do Line 79  do
79  done  done
80    
81  if test -x $SCRIPT ; then  if test -x $SCRIPT ; then
82   echo "run script '$SCRIPT' for experiment in:"   if test $CLEAN = 1 ; then
83       echo "clean output from script '$SCRIPT' for experiment in:"
84     else
85       echo "run script '$SCRIPT' for experiment in:"
86     fi
87   echo " $LIST"   echo " $LIST"
88   yy=`echo $SCRIPT | grep -c '^\/'`   echo ""
89     yy=`echo $SCRIPT | grep -c '^\/'`
90   if test $yy = 0 ; then SCRIPT="../../$SCRIPT" ; fi   if test $yy = 0 ; then SCRIPT="../../$SCRIPT" ; fi
91  else  else
92   echo "ERROR: script '$SCRIPT' not found or not executable"   echo "ERROR: script '$SCRIPT' not found or not executable"
93   exit   exit
94  fi  fi
 echo ""  
95  #------------------------  #------------------------
96    
97  if test $CLEAN = 1 ; then  if test $CLEAN = 1 ; then
# Line 86  if test $CLEAN = 1 ; then Line 100  if test $CLEAN = 1 ; then
100    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' )`
101    for yy in $listD    for yy in $listD
102    do    do
103      if test -r $xx/$yy/data.tst      if test -r $xx/$yy/data.tst ; then
     then  
104        echo "clean dir:" $xx/$yy        echo "clean dir:" $xx/$yy
105        cd $xx/$yy        cd $xx/$yy
106        echo ' ' >> outp.tst_2+2.log        echo ' ' >> $LOGFILE
107        echo $SCRIPT 4 >> outp.tst_2+2.log        echo $SCRIPT 4 >> $LOGFILE
108        $SCRIPT 4 >> outp.tst_2+2.log 2>&1        $SCRIPT 4 >> $LOGFILE 2>&1
109        cd $here        cd $here
110      fi      fi
111    done    done
# Line 101  if test $CLEAN = 1 ; then Line 114  if test $CLEAN = 1 ; then
114  fi  fi
115  #------------------------  #------------------------
116  #  Create a uniquely named directory to store results  #  Create a uniquely named directory to store results
117  DATE=`date +%Y%m%d`  CMDLINE=$0
118    for xx in "$@" ; do nw=`echo $xx | wc -w`
119        if test $nw = '1' ; then CMDLINE="$CMDLINE $xx"
120                            else CMDLINE="$CMDLINE '$xx'" ; fi
121    done
122    #for xx in "$@" ; do CMDLINE="$CMDLINE '$xx'" ; done
123    DATE=''
124    if test -f tr_out.txt ; then
125    #  try to use the date corresponding to 'Start time:' in file "tr_out.txt" :
126      sTime=`grep '^Start time:  ' tr_out.txt 2>/dev/null | sed 's/Start time:  //'`
127      if test "x$sTime" != x ; then DATE=`date -d "$sTime" "+%Y%m%d" 2>/dev/null` ; fi
128    fi
129    #  otherwise, use current date:
130    if test "x$DATE" = x ; then DATE=`date +%Y%m%d`; fi
131  BASE="rs_"$OUTDIR"_"$DATE"_"  BASE="rs_"$OUTDIR"_"$DATE"_"
132  xx=0  xx=0
133  DRESULTS="$BASE$xx"  DRESULTS="$BASE$xx"
# Line 120  OPTFILE= Line 146  OPTFILE=
146    
147  printf "Start time:  " >  $SUMMARY  printf "Start time:  " >  $SUMMARY
148  date  >> $SUMMARY  date  >> $SUMMARY
149    echo 'run:' $CMDLINE >> $SUMMARY
150  if test -f tr_out.txt ; then  if test -f tr_out.txt ; then
151   echo ' using output from:' >> $SUMMARY   echo ' using output from:' >> $SUMMARY
152   sed -n '2,/OPTFILE/ p' tr_out.txt >> $SUMMARY   sed -n '2,/^  OPTFILE=/ p' tr_out.txt >> $SUMMARY
153   echo >> $SUMMARY   echo >> $SUMMARY
154  fi  fi
155  echo  'test 2+2=4 summary :' >> $SUMMARY  echo  'test 2+2=4 summary :' >> $SUMMARY
# Line 130  echo  >> $SUMMARY Line 157  echo  >> $SUMMARY
157  echo 'P. Run  Result     experiment'  >> $SUMMARY  echo 'P. Run  Result     experiment'  >> $SUMMARY
158  echo '  1 2 3'  >> $SUMMARY  echo '  1 2 3'  >> $SUMMARY
159    
160    #-- For MPI test:
161    LOC_MFILE='tr_mpi_mfile'
162    RUNOUTP="output.txt"
163    if [ $mpi -ge 1 ] ; then
164      SCRIPT="$SCRIPT -mpi"
165      RUNOUTP="STDOUT.0000"
166    fi
167    
168  for xx in $LIST  for xx in $LIST
169  do  do
170    echo ==============================================================================    echo '------------------------------------------------------------------------------'
171      if [ $mpi -le 0 ] ; then
172        rCommand=$COMMAND
173      else
174        LOC_NPROC=2
175        mpi_size=$xx/build/SIZE.h.mpi
176        if test -f $mpi_size ; then
177          px=`grep '^     & *nPx *=' $mpi_size | sed 's/^     & *nPx *= *//' | sed 's/, *$//'`
178          py=`grep '^     & *nPy *=' $mpi_size | sed 's/^     & *nPy *= *//' | sed 's/, *$//'`
179          pp=`expr $px \* $py` > /dev/null 2>&1 ; out=$?
180          if test "x$out" = x0 ; then LOC_NPROC=$pp ; fi
181        fi
182        rCommand=`echo $COMMAND | sed "s/ TR_NPROC / $LOC_NPROC /"`
183        if test "x$MPI_MFILE" != x ; then
184          #- create new MPI machine-file with the right number of Procs
185          rm -f $LOC_MFILE
186          cat $MPI_MFILE | sort | uniq | head -$LOC_NPROC > $LOC_MFILE
187          nl=`wc -l $LOC_MFILE | awk '{print $1}'`
188          if [ $nl -lt $LOC_NPROC ] ; then
189            rm -f $LOC_MFILE
190            cat $MPI_MFILE | head -$LOC_NPROC > $LOC_MFILE
191          fi
192          rCommand=`echo $rCommand | sed "s/ TR_MFILE / ..\/..\/$LOC_MFILE /"`
193        fi
194      fi
195    
196    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' )`
197    for yy in $listD    for yy in $listD
198    do    do
199      if test -f $xx/$yy/output.txt      if test -f $xx/$yy/$RUNOUTP ; then
     then  
200        if test "x$OPTFILE" = x -a -f $xx/build/Makefile ; then        if test "x$OPTFILE" = x -a -f $xx/build/Makefile ; then
201          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/^# //'`
202          echo "from '$xx/build/Makefile', extract:" > $DRESULTS/genmake_state          echo "from '$xx/build/Makefile', extract:" > $DRESULTS/genmake_state
203          echo $comm >> $DRESULTS/genmake_state          sed -n '/^# executed by:/,+1 p' $xx/build/Makefile >> $DRESULTS/genmake_state
204            echo " $comm" >> $DRESULTS/genmake_state
205          eval $comm          eval $comm
206            gmkLog=$xx/build/genmake.log
207            grep '^Get compiler version using:' $gmkLog > /dev/null 2>&1
208            out=$?
209            if test "x$out" = x0 ; then
210                echo "from '$gmkLog', extract compiler version:" >> $DRESULTS/genmake_state
211                sed -n '/Get compiler version/,/<-- compiler version/p' $gmkLog \
212                           | grep -v '^... compiler version ' > tr_vers.tmp_log
213                sed -n '1,/^$/p' tr_vers.tmp_log | sed '/^$/d' | sed 's/^./ &/' \
214                          >> $DRESULTS/genmake_state
215                rm -f tr_vers.tmp_log
216            fi
217        fi        fi
218        if test $yy = 'run' ; then nam=$xx        if test $yy = 'run' ; then nam=$xx
219        else nam=$xx`echo $yy | sed 's/tr_run//'` ; fi        else nam=$xx`echo $yy | sed 's/tr_run//'` ; fi
220        echo -n "Entering $xx/$yy :"        echo -n "Entering $xx/$yy :"
221        cd $xx/$yy        cd $xx/$yy
222        echo $SCRIPT All > outp.tst_2+2.log ; echo ' ' >> outp.tst_2+2.log        pwd > $LOGFILE
223        $SCRIPT All >> outp.tst_2+2.log 2>&1        if test "x$COMMAND" = x ; then
224        out=$?          echo $SCRIPT $scrArg >> $LOGFILE ; echo ' ' >> $LOGFILE
225            $SCRIPT $scrArg >> $LOGFILE 2>&1
226            out=$?
227          else
228            echo "$SCRIPT $scrArg -command \"$rCommand\"" >> $LOGFILE
229            echo ' ' >> $LOGFILE
230            $SCRIPT $scrArg -command "$rCommand" >> $LOGFILE 2>&1
231            out=$?
232          fi
233        case $out in        case $out in
234         0 ) echo ' pass test 2+2=4'         0 ) echo ' pass test 2+2=4'
235             echo "Y Y Y Y  pass   <- $nam" >> ../../$SUMMARY ;;             echo "Y Y Y Y  pass   <- $nam" >> ../../$SUMMARY ;;
# Line 160  do Line 239  do
239         1 ) echo "Y N N N FAIL ($out) - $nam" >> ../../$SUMMARY ;;         1 ) echo "Y N N N FAIL ($out) - $nam" >> ../../$SUMMARY ;;
240         * ) echo "N N N N FAIL ($out) - $nam" >> ../../$SUMMARY ;;         * ) echo "N N N N FAIL ($out) - $nam" >> ../../$SUMMARY ;;
241        esac        esac
242        if test $out != '0'        if test $out != '0' ; then
       then  
243          echo " test 2+2=4 FAIL (exit $out)"          echo " test 2+2=4 FAIL (exit $out)"
244          echo " "          echo " "
245          tail -5 outp.tst_2+2.log          tail -5 $LOGFILE
246          echo " "          echo " "
247            cp -p $LOGFILE ../../$DRESULTS/$nam.log
248          elif test $SAVELOG = 1 ; then
249            cp -p $LOGFILE ../../$DRESULTS/$nam.log
250        fi        fi
251        cd $here        cd $here
252      fi      fi
253    done    done
254      if test "x$mpi" != x0 -a "x$MPI_MFILE" != x ; then rm -f $LOC_MFILE ; fi
255  done  done
256  printf "End time:    " >> $SUMMARY  printf "End time:    " >> $SUMMARY
257  date >> $SUMMARY  date >> $SUMMARY
# Line 208  cp -p $SUMMARY tst_2+2_out.txt Line 290  cp -p $SUMMARY tst_2+2_out.txt
290  if test "x$ADDRESS" = x ; then  if test "x$ADDRESS" = x ; then
291    rm -rf $DRESULTS    rm -rf $DRESULTS
292  fi  fi
   

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.16

  ViewVC Help
Powered by ViewVC 1.1.22