      PROGRAM PROB02
C
C     PROBLEM 2
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 SEQUENTIAL-1.00  (PLAIN FORTRAN77)
C       ==================================================
      INTEGER KASES,NK,MK
      PARAMETER (KASES=4)
      INTEGER N(KASES),M(KASES)
      DATA N / 128,1024,1024,1024 /
      DATA M / 128,64,512,1024 /
      REAL TARRAY(2),TIME1,TIME2

      DO 50 K = 1, KASES

      TIME1=DTIME(TARRAY)

      DO MANY=1,25

      NK=N(K)
      MK=M(K)
         CALL DOIT(NK,MK,ESTAR)


      ENDDO

      TIME2=DTIME(TARRAY)

      PRINT 60, N(K),M(K)
  60  FORMAT ('PROBLEM 2 WITH N,M =',I6,2X,I6)
      PRINT *,'GIVES ESTAR =',ESTAR

      PRINT *, 'TIME',TIME2,' SECONDS'
      PRINT *, 'USER:',TARRAY(1),' SYSTEM:',TARRAY(2)

   50 CONTINUE
      STOP
      END


      SUBROUTINE DOIT(NK,MK,ESTAR)
      INTEGER NK,MK
      REAL ESTAR
      INTEGER NDIM,MDIM
      PARAMETER (NDIM = 1024)
      PARAMETER (MDIM = 1024)
      INTEGER I,J
      REAL T1,TEMP(NDIM,MDIM),PROD(MDIM)
      DO 30 I = 1, NK
         DO 10 J = 1, MK
            T1 = FLOAT(-IABS(I-J))
C            TEMP(I,J) = 1+EXP(T1)
             TEMP(I,J) = 1+0.5/(T1+0.001)
   10    CONTINUE

         PROD(I) = 1.0
         DO 20 J = 1, MK
            PROD(I) = PROD(I)*TEMP(I,J)
   20    CONTINUE
   30 CONTINUE
      ESTAR = 0
      DO 40 I = 1, NK
         ESTAR = ESTAR+PROD(I)
   40 CONTINUE

      RETURN
      END



