      PROGRAM PROB13
C
C     PROBLEM 13
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=4)
      INTEGER N(KASES)
      DATA N / 8192, 16384,65536,262144 /
      REAL E
      INTEGER ITIME
      REAL TIME

      DO 50 K = 1, KASES

      CALL mpTIMERstart()
      DO MANY=1,100
      NK=N(K)
      CALL DOIT(NK,E)
      ENDDO
      ITIME=mpTIMERelapsed()

      PRINT *,'PROBLEM 13 WITH N =',NK
      PRINT *,'GIVES E  = ', E


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

   50 CONTINUE
      STOP
      END

      SUBROUTINE DOIT(NK,E)
      INTEGER NK
      REAL E
      REAL, ARRAY(NK)    :: A,B,C,D

         A = [1:NK]/10.0 + 1.0/[1:NK]
         B = LOG10(A) + 0.02
         C = (A + B) * SIN(A)
         D = A + B - 2.0*C

        A = A ** SIN(B)

        WHERE(SIN(A).LT.COS(C))
         A=A+C
        ELSEWHERE
         A=A-D
        END WHERE

        E=SUM(A**2)


      RETURN
      END








