/[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.6 by jmc, Thu Mar 25 23:09:29 2010 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    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' )`
149    for yy in $listD    for yy in $listD
150    do    do
151      if test -f $xx/$yy/output.txt      if test -f $xx/$yy/$RUNOUTP ; then
     then  
152        if test "x$OPTFILE" = x -a -f $xx/build/Makefile ; then        if test "x$OPTFILE" = x -a -f $xx/build/Makefile ; then
153          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/^# //'`
154          echo "from '$xx/build/Makefile', extract:" > $DRESULTS/genmake_state          echo "from '$xx/build/Makefile', extract:" > $DRESULTS/genmake_state
155            sed -n '/^# executed by:/,+1 p' $xx/build/Makefile >> $DRESULTS/genmake_state
156          echo $comm >> $DRESULTS/genmake_state          echo $comm >> $DRESULTS/genmake_state
157          eval $comm          eval $comm
158        fi        fi
159        if test $yy = 'run' ; then nam=$xx        if test $yy = 'run' ; then nam=$xx
160        else nam=$xx`echo $yy | sed 's/tr_run//'` ; fi        else nam=$xx`echo $yy | sed 's/tr_run//'` ; fi
161        echo -n "Entering $xx/$yy :"        echo -n "Entering $xx/$yy :"
162        cd $xx/$yy        cd $xx/$yy
163        echo $SCRIPT All > outp.tst_2+2.log ; echo ' ' >> outp.tst_2+2.log        pwd > outp.tst_2+2.log
164        $SCRIPT All >> outp.tst_2+2.log 2>&1        if test "x$COMMAND" = x ; then
165        out=$?          echo $SCRIPT $scrArg >> outp.tst_2+2.log ; echo ' ' >> outp.tst_2+2.log
166            $SCRIPT $scrArg >> outp.tst_2+2.log 2>&1
167            out=$?
168          else
169            echo "$SCRIPT $scrArg -command \"$COMMAND\"" >> outp.tst_2+2.log
170            echo ' ' >> outp.tst_2+2.log
171            $SCRIPT $scrArg -command "$COMMAND" >> outp.tst_2+2.log 2>&1
172            out=$?
173          fi
174        case $out in        case $out in
175         0 ) echo ' pass test 2+2=4'         0 ) echo ' pass test 2+2=4'
176             echo "Y Y Y Y  pass   <- $nam" >> ../../$SUMMARY ;;             echo "Y Y Y Y  pass   <- $nam" >> ../../$SUMMARY ;;
# Line 160  do Line 180  do
180         1 ) echo "Y N N N FAIL ($out) - $nam" >> ../../$SUMMARY ;;         1 ) echo "Y N N N FAIL ($out) - $nam" >> ../../$SUMMARY ;;
181         * ) echo "N N N N FAIL ($out) - $nam" >> ../../$SUMMARY ;;         * ) echo "N N N N FAIL ($out) - $nam" >> ../../$SUMMARY ;;
182        esac        esac
183        if test $out != '0'        if test $out != '0' ; then
       then  
184          echo " test 2+2=4 FAIL (exit $out)"          echo " test 2+2=4 FAIL (exit $out)"
185          echo " "          echo " "
186          tail -5 outp.tst_2+2.log          tail -5 outp.tst_2+2.log
187          echo " "          echo " "
188            cp -p outp.tst_2+2.log ../../$DRESULTS/$nam.log
189          elif test $SAVELOG = 1 ; then
190            cp -p outp.tst_2+2.log ../../$DRESULTS/$nam.log
191        fi        fi
192        cd $here        cd $here
193      fi      fi

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

  ViewVC Help
Powered by ViewVC 1.1.22