      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 SIMD/DECmpp-1.00
C       ==================================================
C
      INTEGER KASES,NK
      PARAMETER (KASES=3)
      INTEGER N(KASES)
      DATA N /16384,65536,524288/
      REAL X
      INTEGER ITIME
      REAL TIME

      DO 50 K = 1, KASES

      CALL mpTIMERstart()

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

      ENDDO

      ITIME=mpTIMERelapsed()

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


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

   50 CONTINUE
      STOP
      END

      SUBROUTINE DOIT(NK,X)
      INTEGER NK
      REAL X
      REAL, ARRAY(NK)    :: Y,Z


C      Y=1.0/(1.0+[1:NK])
      DO MANY=1,20
      Y=MANY
      Z=0
      WHERE(Y.NE.0)
        Z=1.0/Y
      ENDWHERE
      ENDDO
      X=SUM(Z)


      RETURN
      END








