/[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.9 by jmc, Wed Jan 19 23:43:13 2011 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 "  -o     STRING : used to build output directory name"
18          echo "                      (DEF=\"hostname\")"          echo "                      (DEF=\"hostname\")"
19          echo "  (-a) STRING   : email address to send output to"          echo "  -a,-A  STRING : email address to send output to"
20          echo "                      (DEF=\"\" no email is sent)"          echo "                      (DEF=\"\" no email is sent)"
21            echo "                      (-A: + save each log file)"
22          echo "  -clean        : clean output & reset"          echo "  -clean        : clean output & reset"
23          exit          exit
24  }  }
# Line 23  usage() Line 26  usage()
26  CLEAN=0  CLEAN=0
27  TESTDIRS=  TESTDIRS=
28  SKIPDIRS=  SKIPDIRS=
 OUTDIR=`hostname`  
 ADDRESS=  
29  SCRIPT='../tools/tst_2+2'  SCRIPT='../tools/tst_2+2'
30    scrArg='All'
31    COMMAND=
32    mpi=0
33    OUTDIR=`hostname | sed 's/\..*$//'`
34    SAVELOG=0
35    ADDRESS=
36  MPACK="../tools/mpack-1.6/mpack"  MPACK="../tools/mpack-1.6/mpack"
37  here=`pwd`  here=`pwd`
38  yy=  yy=
# Line 40  do Line 47  do
47        -clean) CLEAN=1 ;;        -clean) CLEAN=1 ;;
48        -t    ) yy=TESTDIRS ;;        -t    ) yy=TESTDIRS ;;
49        -skd  ) yy=SKIPDIRS ;;        -skd  ) yy=SKIPDIRS ;;
50          -exe  ) yy=COMMAND ;;
51          -mpi  ) mpi=1 ;;
52        -a    ) yy=ADDRESS ;;        -a    ) yy=ADDRESS ;;
53          -A    ) yy=ADDRESS ; SAVELOG=1 ;;
54        -o    ) yy=OUTDIR ;;        -o    ) yy=OUTDIR ;;
55          *) echo "Error: unrecognized option: "$xx ; usage ; exit ;;          *) echo "Error: unrecognized option: "$xx ; usage ; exit ;;
56        esac        esac
# Line 48  do Line 58  do
58  done  done
59  #------------------------  #------------------------
60    
61  if test "x$TESTDIRS" = x  if test "x$TESTDIRS" = x ; then TESTDIRS=`ls ` ; fi
 then  
  TESTDIRS=`ls `  
 fi  
62  LIST=""  LIST=""
63  for xx in $TESTDIRS  for xx in $TESTDIRS
64  do  do
65    yy=`echo $SKIPDIRS | grep -c $xx`    yy=`echo $SKIPDIRS | grep -c $xx`
66    if test $yy = 0 ; then    if test $yy = 0 ; then
67      if test -f $xx/results/output.txt      if test -f $xx/results/output.txt ; then
     then  
68         LIST=${LIST}" "$xx         LIST=${LIST}" "$xx
69  #   else  #   else
70  #      echo ""; echo -n " -- skip \"$xx\" (not a directory !)"  #      echo ""; echo -n " -- skip \"$xx\" (not a directory !)"
# Line 71  done Line 77  done
77  if test -x $SCRIPT ; then  if test -x $SCRIPT ; then
78   echo "run script '$SCRIPT' for experiment in:"   echo "run script '$SCRIPT' for experiment in:"
79   echo " $LIST"   echo " $LIST"
80   yy=`echo $SCRIPT | grep -c '^\/'`   yy=`echo $SCRIPT | grep -c '^\/'`
81   if test $yy = 0 ; then SCRIPT="../../$SCRIPT" ; fi   if test $yy = 0 ; then SCRIPT="../../$SCRIPT" ; fi
82  else  else
83   echo "ERROR: script '$SCRIPT' not found or not executable"   echo "ERROR: script '$SCRIPT' not found or not executable"
# Line 86  if test $CLEAN = 1 ; then Line 92  if test $CLEAN = 1 ; then
92    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' )`
93    for yy in $listD    for yy in $listD
94    do    do
95      if test -r $xx/$yy/data.tst      if test -r $xx/$yy/data.tst ; then
     then  
96        echo "clean dir:" $xx/$yy        echo "clean dir:" $xx/$yy
97        cd $xx/$yy        cd $xx/$yy
98        echo ' ' >> outp.tst_2+2.log        echo ' ' >> outp.tst_2+2.log
99        echo $SCRIPT 4 >> outp.tst_2+2.log        echo $SCRIPT 4 >> outp.tst_2+2.log
100        $SCRIPT 4 >> outp.tst_2+2.log 2>&1        $SCRIPT 4 >> outp.tst_2+2.log 2>&1
# Line 130  echo  >> $SUMMARY Line 135  echo  >> $SUMMARY
135  echo 'P. Run  Result     experiment'  >> $SUMMARY  echo 'P. Run  Result     experiment'  >> $SUMMARY
136  echo '  1 2 3'  >> $SUMMARY  echo '  1 2 3'  >> $SUMMARY
137    
138    #-- For MPI test:
139    RUNOUTP="output.txt"
140    if [ $mpi -ge 1 ] ; then
141      SCRIPT="$SCRIPT -mpi"
142      RUNOUTP="STDOUT.0000"
143    fi
144    
145  for xx in $LIST  for xx in $LIST
146  do  do
147    echo ==============================================================================    echo ==============================================================================
148      if [ $mpi -ge 1 ] ; then
149        NP_MPI=2
150        mpi_size=$xx/build/SIZE.h.mpi
151        if test -f $mpi_size ; then
152          px=`grep '^     & *nPx *=' $mpi_size | sed 's/^     & *nPx *= *//' | sed 's/, *$//'`
153          py=`grep '^     & *nPy *=' $mpi_size | sed 's/^     & *nPy *= *//' | sed 's/, *$//'`
154          pp=`expr $px \* $py` > /dev/null 2>&1 ; out=$?
155          if test "x$out" = x0 ; then NP_MPI=$pp ; fi
156        fi
157        rCommand=`echo $COMMAND | sed "s/ TR_NPROC / $NP_MPI /"`
158      else
159        rCommand=$COMMAND
160      fi
161    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' )`
162    for yy in $listD    for yy in $listD
163    do    do
164      if test -f $xx/$yy/output.txt      if test -f $xx/$yy/$RUNOUTP ; then
     then  
165        if test "x$OPTFILE" = x -a -f $xx/build/Makefile ; then        if test "x$OPTFILE" = x -a -f $xx/build/Makefile ; then
166          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/^# //'`
167          echo "from '$xx/build/Makefile', extract:" > $DRESULTS/genmake_state          echo "from '$xx/build/Makefile', extract:" > $DRESULTS/genmake_state
168          echo $comm >> $DRESULTS/genmake_state          sed -n '/^# executed by:/,+1 p' $xx/build/Makefile >> $DRESULTS/genmake_state
169            echo " $comm" >> $DRESULTS/genmake_state
170          eval $comm          eval $comm
171            gmkLog=$xx/build/genmake.log
172            grep '^Get compiler version using:' $gmkLog > /dev/null 2>&1
173            out=$?
174            if test "x$out" = x0 ; then
175                echo "from '$gmkLog', extract compiler version:" >> $DRESULTS/genmake_state
176                sed -n '/Get compiler version/,/<-- compiler version/p' $gmkLog \
177                           | grep -v '^... compiler version ' > tr_vers.tmp_log
178                sed -n '1,/^$/p' tr_vers.tmp_log | sed '/^$/d' | sed 's/^./ &/' \
179                          >> $DRESULTS/genmake_state
180                rm -f tr_vers.tmp_log
181            fi
182        fi        fi
183        if test $yy = 'run' ; then nam=$xx        if test $yy = 'run' ; then nam=$xx
184        else nam=$xx`echo $yy | sed 's/tr_run//'` ; fi        else nam=$xx`echo $yy | sed 's/tr_run//'` ; fi
185        echo -n "Entering $xx/$yy :"        echo -n "Entering $xx/$yy :"
186        cd $xx/$yy        cd $xx/$yy
187        echo $SCRIPT All > outp.tst_2+2.log ; echo ' ' >> outp.tst_2+2.log        pwd > outp.tst_2+2.log
188        $SCRIPT All >> outp.tst_2+2.log 2>&1        if test "x$COMMAND" = x ; then
189        out=$?          echo $SCRIPT $scrArg >> outp.tst_2+2.log ; echo ' ' >> outp.tst_2+2.log
190            $SCRIPT $scrArg >> outp.tst_2+2.log 2>&1
191            out=$?
192          else
193            echo "$SCRIPT $scrArg -command \"$rCommand\"" >> outp.tst_2+2.log
194            echo ' ' >> outp.tst_2+2.log
195            $SCRIPT $scrArg -command "$rCommand" >> outp.tst_2+2.log 2>&1
196            out=$?
197          fi
198        case $out in        case $out in
199         0 ) echo ' pass test 2+2=4'         0 ) echo ' pass test 2+2=4'
200             echo "Y Y Y Y  pass   <- $nam" >> ../../$SUMMARY ;;             echo "Y Y Y Y  pass   <- $nam" >> ../../$SUMMARY ;;
# Line 160  do Line 204  do
204         1 ) echo "Y N N N FAIL ($out) - $nam" >> ../../$SUMMARY ;;         1 ) echo "Y N N N FAIL ($out) - $nam" >> ../../$SUMMARY ;;
205         * ) echo "N N N N FAIL ($out) - $nam" >> ../../$SUMMARY ;;         * ) echo "N N N N FAIL ($out) - $nam" >> ../../$SUMMARY ;;
206        esac        esac
207        if test $out != '0'        if test $out != '0' ; then
       then  
208          echo " test 2+2=4 FAIL (exit $out)"          echo " test 2+2=4 FAIL (exit $out)"
209          echo " "          echo " "
210          tail -5 outp.tst_2+2.log          tail -5 outp.tst_2+2.log
211          echo " "          echo " "
212            cp -p outp.tst_2+2.log ../../$DRESULTS/$nam.log
213          elif test $SAVELOG = 1 ; then
214            cp -p outp.tst_2+2.log ../../$DRESULTS/$nam.log
215        fi        fi
216        cd $here        cd $here
217      fi      fi

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

  ViewVC Help
Powered by ViewVC 1.1.22