      PROGRAM PROB12
C
C     PROBLEM 12
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,MK
      PARAMETER (KASES=4)
      INTEGER N(KASES),M(KASES)
      DATA N / 127,127,511,1023 /
      DATA M / 127,511,511,511 /
      REAL TP1,TP2
      INTEGER ITIME
      REAL TIME

      DO 50 K = 1, KASES

      CALL mpTIMERstart()
      DO MANY=1,150
      NK=N(K)
      MK=M(K)
      CALL DOIT(NK,MK,TP1,TP2)
      ENDDO
      ITIME=mpTIMERelapsed()

      PRINT 80,NK,MK
   80 FORMAT ('PROBLEM 12 WITH N,M =',I6,2X,I6)
      PRINT*,'GIVES CORNER PRODUCTS =', TP1,TP2

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

   50 CONTINUE

      STOP
      END


      SUBROUTINE DOIT(NK,MK,TP1,TP2)
      INTEGER NK,MK
      REAL TP1,TP2
      REAL, ARRAY(MK)           :: R
      REAL, ARRAY(NK)           :: C
      REAL, ARRAY(NK,MK)        :: A
      REAL, ARRAY(NK+1,MK+1)    :: ABIG
      REAL, ARRAY(1,1)          :: ACORN
      REAL, ARRAY(NK,MK) :: TEMP

      R=1.0+[1:MK]
      C=1.0-[1:NK]
      A=SPREAD([1:NK],2,MK)+SPREAD([1:MK],1,NK)

      ACORN = .5
      ABIG(1:NK,1:MK)=A
      ABIG(1:NK,MK+1)=C
      ABIG(NK+1,1:MK)=R
      ABIG(NK+1:NK+1,MK+1:MK+1)=ACORN


      TP1 = ABIG(1,1)*ABIG(1,MK+1)*ABIG(NK+1,MK)*ABIG(NK+1,MK+1)
      TP2 = ABIG(NK,MK)*ABIG(NK,MK+1)*ABIG(NK+1,MK)*ABIG(NK+1,MK+1)

      RETURN
      END






