      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 SEQUENTIAL-1.00  (PLAIN FORTRAN77)
C       ==================================================
      INTEGER KASES,NK
      PARAMETER (KASES=4)
      INTEGER N(KASES)
      DATA N / 8192, 16384,65536,262144 /
      REAL E
      REAL TARRAY(2),TIME1,TIME2

      DO 50 K = 1, KASES

      TIME1=DTIME(TARRAY)
      DO MANY=1,100
      NK=N(K)
      CALL DOIT(NK,E)
      ENDDO
      TIME2=DTIME(TARRAY)

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


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

   50 CONTINUE
      STOP
      END

      SUBROUTINE DOIT(NK,E)
      INTEGER NK
      REAL E
      INTEGER NDIM,I
      PARAMETER (NDIM=262144)
      REAL A(NDIM),B(NDIM),C(NDIM),D(NDIM)
      DO I = 1, NK
         A(I) = I/10.+1./I
         B(I) = LOG10(A(I))+.02
         C(I) = (A(I)+B(I))*SIN(A(I))
         D(I) = A(I)+B(I)-2.*C(I)
      ENDDO
C
C                    HAVE CREATED THE 4 VECTORS OF DATA
C
      E = 0.0
      DO  I = 1, NK
         A(I) = A(I)**SIN(B(I))
         IF (SIN(A(I)).LT.COS(C(I))) THEN
            A(I) = A(I)+C(I)
         ELSE
            A(I) = A(I)-D(I)
         ENDIF
         E = E+A(I)**2
      ENDDO


      RETURN
      END








