      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 SEQUENTIAL-1.00  (PLAIN FORTRAN77)
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
      REAL TARRAY(2),TIME1,TIME2

      DO 50 K = 1, KASES

      TIME1=DTIME(TARRAY)
      DO MANY=1,150
      NK=N(K)
      MK=M(K)
      CALL DOIT(NK,MK,TP1,TP2)
      ENDDO
      TIME2=DTIME(TARRAY)

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

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

   50 CONTINUE

      STOP
      END


      SUBROUTINE DOIT(NK,MK,TP1,TP2)
      INTEGER NK,MK
      REAL TP1,TP2
      INTEGER NDIM,MDIM,ND1,MD1,I,J
      PARAMETER (NDIM=1023,MDIM=511,ND1=NDIM+1,MD1=MDIM+1)
      REAL A(NDIM,MDIM),R(MDIM),C(NDIM),ABIG(ND1,MD1)
      REAL ACORN

         DO 20 I = 1, NK
            C(I) = 1.-I
            DO 10 J = 1, MK
               A(I,J) = I+J
   10       CONTINUE
   20    CONTINUE
         DO 30 J = 1, MK
            R(J) = 1.+J
   30    CONTINUE
         ACORN = .5
         ABIG(NK+1,MK+1) = ACORN

         DO 50 I = 1, NK
            ABIG(I,MK+1) = C(I)
            DO 40 J = 1, MK
               ABIG(I,J) = A(I,J)
   40       CONTINUE
   50    CONTINUE
         DO 60 J = 1, MK
            ABIG(NK+1,J) = R(J)
   60    CONTINUE


      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






