SUBROUTINE C8D (N,K,T,D,A,B,Z,ZZ,ITER,IER)
c
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c CVS Info
c $Date: 2005/01/10 21:55:51 $
c $Revision: 1.2 $
c $RCSfile: c8d.f,v $
c $Name: rel_5 $
c
c This is a check routine for Benchmark 8D. It will verify that the
c Lg Path Probability is correct for the path given in B, and that
c the path from B(I-2) through X to B(I) is at most as probable as the
c reported best path through B(I-1).
c
c Parameters:
c
c Provided by calling routine:
c N = Size of the A matrices
c K = Number of A matrices
c T = Length of D, and one less than the length of B
c D = T long array of integers between 1 and K used to
c select the appropriate A matrix
c A = K long array of N by N matrices
c B = T+1 long array containing the best path
c Z = Probability of this best path
c ZZ = Expected probability of the best path
c ITER = The iteration number for this pass
c
c Returned by this routine:
c IER = Error flag array
c IER(1) = Iteration on which error occurred
c IER(2) = Flag indicating type of error
c IER(3) = Step on which type 2 error occurred
c
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c
c An allowable difference in score
PARAMETER (DELTA=.00002)
c
c The maximum size of the matrices and vectors
PARAMETER (MN=30)
c
c Error flag array
INTEGER IER(3)
c
INTEGER T
INTEGER B(0:T)
INTEGER D(T)
REAL A(N,N,K)
REAL TEMP(MN), TEMP2
C--CVS variable declaration
TYPE CVS
sequence
character( 160 ) string
integer stringend
END TYPE CVS
C--CVS initilaize variables
TYPE( CVS ),save :: CVS_INFO =
$ CVS("BMARKGRP $Date: 2005/01/10 21:55:51 $ $Revision: 1.2 $" //
$ "$RCSfile: c8d.f,v $ $Name: rel_5 $", 0)
c
c Check that MN is larger than N
IF(MN .LT. N) THEN
PRINT 5,MN,N
5 FORMAT('Insufficient space in working arrays for C8D.',/,
$ 'Size available from parameter MN = ',I5,/,
$ 'Needed = ',I6)
STOP
ENDIF
c
c Initialize error array
IER(1) = ITER
IER(2) = 0
IER(3) = 0
c
c First check the score
ZZ = 0
DO 10 I=1,T
ZZ = ZZ + A(B(I-1),B(I),D(I))
10 CONTINUE
c
IF(ABS(Z/ZZ - 1) .GT. DELTA) THEN
IER(2) = 1
RETURN
ENDIF
c
c Check that this is the best path
DO 40 I=2,T
DO 20 J=1,N
TEMP(J) = A(B(I-2),J,D(I-1))
20 CONTINUE
c
TEMP2 = A(B(I-1),B(I),D(I)) + TEMP(B(I-1))
DO 30 J=1,N
IF((A(J,B(I),D(I)) + TEMP(J)) .GT. TEMP2) THEN
IER(2) = 2
IER(3) = I
RETURN
ENDIF
30 CONTINUE
40 CONTINUE
c
RETURN
END