      PROGRAM PROB08
C
C     PROBLEM 08
C
C  REFERENCE:  PROBLEMS TO TEST PARALLEL AND VECTOR LANGUAGES
C              CSD-TR 516, COMPUTER SCIENCE, PURDUE UNIVERSITY
C              JOHN R. RICE, MAY 1, 1985
C
C              REVISED BY JOHN R. RICE AND J. JING, OCT. 1, 1990
C
C
C      *************************************************
C      *      Adapted for FORTRAN D benchmarking       *
C      *    by  T. HAUPT  (haupt@sccs.npac.syr.edu)    *
C      *                                               *
C      *    Northeast Parallel Architectures Center    *
C      *   at Syracuse University, Syracuse, NY, USA   *
C      *************************************************
C
C
C       VERSION SIMD/DECmpp-1.00
C       ==================================================
C
      INTEGER KASES,NK,MK
      PARAMETER (KASES=4)
      INTEGER N(KASES),M(KASES)
      DATA N / 8192,65536,131072,65536/
      DATA M /3,4,4,8/
C      PARAMETER (KASES=3)
C      INTEGER N(KASES),M(KASES)
C      DATA N / 8192,32768,16384/
C      DATA M /3,4,8/
      REAL SUMD
      INTEGER ITIME
      REAL TIME

      DO 50 K = 1, KASES

      CALL mpTIMERstart()
      DO MANY=1,150

      NK=N(K)
      MK=M(K)
      CALL DOIT(NK,MK,SUMD)
      ENDDO
      ITIME=mpTIMERelapsed()

      PRINT *,'PROBLEM 08 WITH N,M  =',NK,MK
      PRINT *,'GIVES SUM OF DIFFERENCES = ',SUMD


      TIME=FLOAT(ITIME)/1000
      PRINT *, 'DECmpp ELAPSED TIME:',TIME,' SECONDS'

   50 CONTINUE
      STOP
      END

      SUBROUTINE DOIT(NK,MK,SUMD)
      INTEGER NK,MK
      REAL SUMD
      INTEGER J,N
      REAL, ARRAY(NK)    :: X
      REAL, ARRAY(NK,MK) :: DIFF
CMPF  MAP DIFF(ALLBITS,MEMORY)

      X=0.2*[1:NK]+0.01*COS(REAL([1:NK])*0.01)
      DIFF=0
      DIFF(1:NK,1)=SIN(X)

      N=NK
      DO J=2,MK
      N=N-1
      C=0
      DIFF(1:N,J)=(DIFF(2:N+1,J-1)-DIFF(1:N,J-1))/(X(J:N+J-1)-X(1:N))
      ENDDO

      SUMD=SUM(DIFF(1:NK,2:MK))


      RETURN
      END









