/[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.3 by jmc, Fri Feb 27 22:58:57 2009 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=
29    SCRIPT='../tools/tst_2+2'
30    COMMAND=
31    mpi=0
32  OUTDIR=`hostname`  OUTDIR=`hostname`
33    SAVELOG=0
34  ADDRESS=  ADDRESS=
 SCRIPT='../tools/tst_2+2'  
35  MPACK="../tools/mpack-1.6/mpack"  MPACK="../tools/mpack-1.6/mpack"
36  here=`pwd`  here=`pwd`
37  yy=  yy=
# Line 40  do Line 46  do
46        -clean) CLEAN=1 ;;        -clean) CLEAN=1 ;;
47        -t    ) yy=TESTDIRS ;;        -t    ) yy=TESTDIRS ;;
48        -skd  ) yy=SKIPDIRS ;;        -skd  ) yy=SKIPDIRS ;;
49          -exe  ) yy=COMMAND ;;
50          -mpi  ) mpi=1 ;;
51        -a    ) yy=ADDRESS ;;        -a    ) yy=ADDRESS ;;
52          -A    ) yy=ADDRESS ; SAVELOG=1 ;;
53        -o    ) yy=OUTDIR ;;        -o    ) yy=OUTDIR ;;
54          *) echo "Error: unrecognized option: "$xx ; usage ; exit ;;          *) echo "Error: unrecognized option: "$xx ; usage ; exit ;;
55        esac        esac
# Line 48  do Line 57  do
57  done  done
58  #------------------------  #------------------------
59    
60  if test "x$TESTDIRS" = x  if test "x$TESTDIRS" = x ; then TESTDIRS=`ls ` ; fi
 then  
  TESTDIRS=`ls `  
 fi  
61  LIST=""  LIST=""
62  for xx in $TESTDIRS  for xx in $TESTDIRS
63  do  do
64    yy=`echo $SKIPDIRS | grep -c $xx`    yy=`echo $SKIPDIRS | grep -c $xx`
65    if test $yy = 0 ; then    if test $yy = 0 ; then
66      if test -f $xx/results/output.txt      if test -f $xx/results/output.txt ; then
     then  
67         LIST=${LIST}" "$xx         LIST=${LIST}" "$xx
68  #   else  #   else
69  #      echo ""; echo -n " -- skip \"$xx\" (not a directory !)"  #      echo ""; echo -n " -- skip \"$xx\" (not a directory !)"
# Line 71  done Line 76  done
76  if test -x $SCRIPT ; then  if test -x $SCRIPT ; then
77   echo "run script '$SCRIPT' for experiment in:"   echo "run script '$SCRIPT' for experiment in:"
78   echo " $LIST"   echo " $LIST"
79   yy=`echo $SCRIPT | grep -c '^\/'`   yy=`echo $SCRIPT | grep -c '^\/'`
80   if test $yy = 0 ; then SCRIPT="../../$SCRIPT" ; fi   if test $yy = 0 ; then SCRIPT="../../$SCRIPT" ; fi
81  else  else
82   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 91  if test $CLEAN = 1 ; then
91    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' )`
92    for yy in $listD    for yy in $listD
93    do    do
94      if test -r $xx/$yy/data.tst      if test -r $xx/$yy/data.tst ; then
     then  
95        echo "clean dir:" $xx/$yy        echo "clean dir:" $xx/$yy
96        cd $xx/$yy        cd $xx/$yy
97        echo ' ' >> outp.tst_2+2.log        echo ' ' >> outp.tst_2+2.log
98        echo $SCRIPT 4 >> outp.tst_2+2.log        echo $SCRIPT 4 >> outp.tst_2+2.log
99        $SCRIPT 4 >> outp.tst_2+2.log 2>&1        $SCRIPT 4 >> outp.tst_2+2.log 2>&1
# Line 130  echo  >> $SUMMARY Line 134  echo  >> $SUMMARY
134  echo 'P. Run  Result     experiment'  >> $SUMMARY  echo 'P. Run  Result     experiment'  >> $SUMMARY
135  echo '  1 2 3'  >> $SUMMARY  echo '  1 2 3'  >> $SUMMARY
136    
137    #-- For MPI test:
138    RUNOUTP="output.txt"
139    if [ $mpi -ge 1 ] ; then
140      SCRIPT="$SCRIPT -mpi"
141      RUNOUTP="STDOUT.0000"
142    fi
143    
144  for xx in $LIST  for xx in $LIST
145  do  do
146    echo ==============================================================================    echo ==============================================================================
147    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' )`
148    for yy in $listD    for yy in $listD
149    do    do
150      if test -f $xx/$yy/output.txt      if test -f $xx/$yy/$RUNOUTP ; then
     then  
151        if test "x$OPTFILE" = x -a -f $xx/build/Makefile ; then        if test "x$OPTFILE" = x -a -f $xx/build/Makefile ; then
152          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/^# //'`
153          echo "from '$xx/build/Makefile', extract:" > $DRESULTS/genmake_state          echo "from '$xx/build/Makefile', extract:" > $DRESULTS/genmake_state
154          echo $comm >> $DRESULTS/genmake_state          echo $comm >> $DRESULTS/genmake_state
155          eval $comm          eval $comm
156        fi        fi
157        if test $yy = 'run' ; then nam=$xx        if test $yy = 'run' ; then nam=$xx
158        else nam=$xx`echo $yy | sed 's/tr_run//'` ; fi        else nam=$xx`echo $yy | sed 's/tr_run//'` ; fi
159        echo -n "Entering $xx/$yy :"        echo -n "Entering $xx/$yy :"
160        cd $xx/$yy        cd $xx/$yy
161        echo $SCRIPT All > outp.tst_2+2.log ; echo ' ' >> outp.tst_2+2.log        pwd > outp.tst_2+2.log
162        $SCRIPT All >> outp.tst_2+2.log 2>&1        if test "x$COMMAND" = x ; then
163        out=$?          echo $SCRIPT All >> outp.tst_2+2.log ; echo ' ' >> outp.tst_2+2.log
164            $SCRIPT All >> outp.tst_2+2.log 2>&1
165            out=$?
166          else
167            echo "$SCRIPT All -command \"$COMMAND\"" >> outp.tst_2+2.log
168            echo ' ' >> outp.tst_2+2.log
169            $SCRIPT All -command "$COMMAND" >> outp.tst_2+2.log 2>&1
170            out=$?
171          fi
172        case $out in        case $out in
173         0 ) echo ' pass test 2+2=4'         0 ) echo ' pass test 2+2=4'
174             echo "Y Y Y Y  pass   <- $nam" >> ../../$SUMMARY ;;             echo "Y Y Y Y  pass   <- $nam" >> ../../$SUMMARY ;;
# Line 160  do Line 178  do
178         1 ) echo "Y N N N FAIL ($out) - $nam" >> ../../$SUMMARY ;;         1 ) echo "Y N N N FAIL ($out) - $nam" >> ../../$SUMMARY ;;
179         * ) echo "N N N N FAIL ($out) - $nam" >> ../../$SUMMARY ;;         * ) echo "N N N N FAIL ($out) - $nam" >> ../../$SUMMARY ;;
180        esac        esac
181        if test $out != '0'        if test $out != '0' ; then
       then  
182          echo " test 2+2=4 FAIL (exit $out)"          echo " test 2+2=4 FAIL (exit $out)"
183          echo " "          echo " "
184          tail -5 outp.tst_2+2.log          tail -5 outp.tst_2+2.log
185          echo " "          echo " "
186            cp -p outp.tst_2+2.log ../../$DRESULTS/$nam.log
187          elif test $SAVELOG = 1 ; then
188            cp -p outp.tst_2+2.log ../../$DRESULTS/$nam.log
189        fi        fi
190        cd $here        cd $here
191      fi      fi

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

  ViewVC Help
Powered by ViewVC 1.1.22