      PROGRAM HOST12
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 MIMD/iPSC860-1.00-HOST   (F77+mp)
C       ==================================================
C
      INCLUDE 'picl_def.h'
      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
      DOUBLE PRECISION HOST_SEC, NODE_SEC, STARTTIME
      INTEGER*4 TIMESIZE, TIMETYPE
      DATA TIMESIZE,TIMETYPE /8,10/
      INTEGER*4 ME,HOST,ALLNODES
      INTEGER*4 NPROCS,TOP,ORD,DIR
      INTEGER*4 INITTYPE
      DATA INITTYPE /1/
      DATA TOP,ORD,DIR,ALLNODES /1,1,1,-1/
C -----------------------------------------------------------
C           parameters of the initial broadcast
C -----------------------------------------------------------
      INTEGER*4 MSG(2),MSGSIZE
      DATA MSGSIZE /8/
      EQUIVALENCE (MSG(1),NK),(MSG(2),MK)
C -----------------------------------------------------------
C      parameters of messages with partial results
C -----------------------------------------------------------
      INTEGER*4 BYTES
      REAL RES1,RES2,B(4),BUF1,BUF2
      INTEGER*4 MSG1,MSG2,MSG3
      DATA MSG1,MSG2,MSG3 /25,26,27/
      DATA BYTES /4/


      WRITE(6,*) 'enter the number of processors'
      READ(5,*) NPROCS
      CALL open0(NPROCS,ME,HOST)
      CALL load0("node12",ALLNODES)
      CALL setarc0(NPROCS, TOP, ORD, DIR)


      DO 50 K = 1, KASES

      STARTTIME=clock0()
      DO MANY=1,150
      NK=N(K)
      MK=M(K)
         CALL bcast0(MSG,MSGSIZE,INITTYPE,HOST)

         CALL recv0(BUF1,BYTES,MSG1)
         CALL recv0(BUF2,BYTES,MSG2)
         CALL recv0(B,4*BYTES,MSG3)

         TP1=BUF1*BUF2*B(2)*B(4)
         TP2=B(1)*B(2)*B(3)*B(4)
      ENDDO
      HOST_SEC=clock0()-STARTTIME

      CALL recv0(NODE_SEC,TIMESIZE,TIMETYPE)

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

      PRINT *, 'TIME ON NODE 0 =',NODE_SEC,' SECONDS'
      PRINT *, 'TIME ON HOST 0 =',HOST_SEC,' SECONDS'

   50 CONTINUE

C     stop processes on nodes
C
      NK=-1
      CALL bcast0(MSG,MSGSIZE,INITTYPE,HOST)
      CALL close0(1)
      STOP
      END







