      PROGRAM PROB04
C
C     PROBLEM 04
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
      PARAMETER (KASES=3)
      INTEGER N(KASES)
      DATA N /16384,65536,524288/
      REAL X
      REAL TARRAY(2),TIME1,TIME2

      DO 50 K = 1, KASES

      TIME1=DTIME(TARRAY)

      DO MANY=1,25
      NK=N(K)
      CALL DOIT(NK,X)

      ENDDO

      TIME2=DTIME(TARRAY)

      PRINT *,'PROBLEM 4 WITH N =',NK
      PRINT *,'GIVES X  = ',X


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

   50 CONTINUE
      STOP
      END

      SUBROUTINE DOIT(NK,X)
      INTEGER NK
      REAL X
      INTEGER NMAX,I
      PARAMETER (NMAX=524288)
      REAL Y(NMAX),Z(NMAX)
      DO MANY=1,20
      DO I = 1, NK
C        Y(I)=1.0/(1.0+I)
       Y(I)=MANY
      ENDDO

      DO I = 1, NK
        IF(Y(I).NE.0) THEN
          Z(I)=1.0/Y(I)
        ELSE
          Z(I)=0
        ENDIF
      ENDDO

      ENDDO


      X=0
      DO I = 1, NK
       X=X+Z(I)
      ENDDO


      RETURN
      END








