summaryrefslogtreecommitdiffstats
path: root/funtools/funtest/tfuncalc
blob: 6f532b6ce0db749548875d179b554e486727dad5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!/bin/sh
#set -x

VERBOSE=0
OPROG=funcalc
NPROG=../funcalc
R="cir(511,512,1)"
OFILE="${HOME}/data/snr.ev"
NFILE="${HOME}/data/snr.ev.gz"

if [ -r /usr/ucb/echo ]; then
  ECHO=/usr/ucb/echo
else
  ECHO=echo
fi

while [ x"$1" != x ]; do
  case $1 in
  -1)
    DO1=YES
    shift
    continue;;
  -f2)
    shift
    OFILE=$1
    shift
    NFILE=$1
    shift
    continue;;
  -n)
    shift
    NPROG=$1
    shift
    continue;;
  -o)
    shift
    OPROG=$1
    shift
    continue;;
  -P)
    DO1=YES
    NPROG=../funcalc.pure
    shift
    continue;;
  -V)
    DO1=YES
    NPROG="/usr/bin/valgrind --tool=memcheck  --leak-check=yes --show-reachable=yes --trace-children=yes ../funcalc"
    shift
    continue;;
  -r)
    shift
    R=$1
    shift
    continue;;
  -v)
    VERBOSE=1
    shift
    continue;;
  -v2)
    VERBOSE=2
    shift
    continue;;
  *)
    shift
    continue;;
  esac
done

OFILE="${OFILE}[${R}]"
NFILE="${NFILE}[${R}]"
$ECHO "OPROG="${OPROG} "FILE="${OFILE}
$ECHO "NPROG="${NPROG} "FILE="${NFILE}

IFS="	"
while read ARG1 ARG2 ARG3; do
  if [ x"$ARG1" = x ]; then
    continue
  fi
  if [ x`$ECHO $ARG1 | sed 's/^#.*/YES/g'` = x"YES" ]; then
    continue
  fi
  CMD=${ARG1}
  if [ x"$ARG2" = x1 ]; then
    OUT=FALSE
  else
    OUT=TRUE
  fi	
  EXPR=${ARG3}
  if [ x$CMD = xZIEXACT ]; then
    if [ x$FILTER_PAINT = xtrue ]; then
      continue
    else
      CMD=EXACT
    fi
  fi
  if [ x$CMD = xZEXACT ]; then
    if [ x$FILTER_PAINT = xtrue ]; then
      CMD=SUM
    else
      CMD=EXACT
    fi
  fi
  case $CMD in
  OPROG)
    OPROG=$ARG2
    ;;
  NPROG)
    NPROG=$ARG2
    ;;
  OFILE)
    OFILE=$ARG2
    ;;
  NFILE)
    NFILE=$ARG2
    ;;
  REGION)
    R=$ARG2
    ;;
  EXIT)
    exit
    ;;
  EXACT|SUM|REV)
    if [ x"$DO1" = xYES ]; then
      $ECHO "DO1: $EXPR"
      if [ x"$OUT" = xFALSE ]; then
        $NPROG -l "-L.." -e "${EXPR}" ${NFILE}  > funcalc1.out
      else
        $NPROG -l "-L.." -e "${EXPR}" ${NFILE} stdout | fundisp stdin  > funcalc1.out
      fi
    else
      $ECHO "EXACT: $EXPR"
      CMP=yes
      XPROG=""
      if [ x"$OUT" = xFALSE ]; then
        $OPROG -e ${EXPR} ${OFILE} > tfuncalc1.out 2>err.log
      else
        $OPROG -e ${EXPR} ${OFILE} stdout | fundisp stdin > tfuncalc1.out 2>err.log
      fi
      if test $? -ne 0; then
        CMP=no
        XPROG="$OPROG"
      fi
      if [ x"$OUT" = xFALSE ]; then
        $NPROG -l "-L.." -e ${EXPR} ${NFILE} > tfuncalc2.out
      else
        $NPROG -l "-L.." -e ${EXPR} ${NFILE} stdout | fundisp stdin > tfuncalc2.out
      fi
      if test $? -ne 0; then
        CMP=no
        XPROG="${XPROG:-""}${XPROG:+" "}$NPROG"
      fi
      if [ x"$CMP" = xyes ]; then
        mv tfuncalc1.out funcalc1.out
        mv tfuncalc2.out funcalc2.out
        diff funcalc1.out funcalc2.out
      fi
    fi
    $ECHO " "
    ;;
  *)
    $ECHO "ERROR: unknown command: $CMD"
    exit 1
    ;;
  esac
  if [ $VERBOSE = 1 ]; then
    $ECHO "***** funcalc1.out *****"
    cat funcalc1.out
  fi
  if [ $VERBOSE = 2 ]; then
    $ECHO "***** funcalc1.out *****"
    cat funcalc1.out
    $ECHO "***** funcalc2.out *****"
    cat funcalc2.out
  fi
  rm -f err.log
done

rm -f funcalc1.out funcalc2.out tfuncalc1.out tfuncalc2.out