      PROGRAM PROB03
C
C     PROBLEM 3
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=3)
      INTEGER N(KASES),M(KASES)
      DATA N / 64,512,1024 /
      DATA M /128,128,1024 /

      REAL S

      REAL TARRAY(2),TIME1,TIME2

      DO 50 K = 1, KASES

      TIME1=DTIME(TARRAY)

      DO MANY=1,50

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


      ENDDO

      TIME2=DTIME(TARRAY)

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

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

   50 CONTINUE
      STOP
      END

      SUBROUTINE DOIT(NK,MK,S)
      INTEGER NK,MK
      REAL S

      INTEGER NDIM,MDIM
      PARAMETER (NDIM=1024,MDIM=1024)
      DIMENSION A(NDIM,MDIM),P(NDIM)
      INTEGER I,J
C
C      intitialization
C
      DO  I = 1, NK
       DO J = 1, MK
        A(I,J)=1.0001
       ENDDO
      ENDDO
C
C     computation
C
      DO  I = 1, NK
        P(I) = 1
        DO J = 1, MK
         P(I) = P(I)*A(I,J)
        ENDDO
      ENDDO

      S = 0
      DO  I = 1, NK
         S = S+P(I)
      ENDDO

      RETURN
      END

