      PROGRAM NODE02
C
C     PROBLEM 2
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-NODE   (F77+mp)
C       ==================================================
C
      INCLUDE 'picl_def.h'
      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 PARTTYPE
      DATA PARTTYPE /20/
      INTEGER NK,MK
      REAL ESTAR
      INTEGER NDIM,MDIM
      PARAMETER (NDIM = 1024)
      PARAMETER (MDIM = 1024)
      INTEGER I,J
      REAL T1,TEMP(NDIM,MDIM),PROD(MDIM)
      CALL open0(NPROCS,ME,HOST)
      CALL setarc0(NPROCS,TOP,ORD,DIR)

  100 CONTINUE
      STARTTIME=clock0()
      CALL bcast0(MSG,MSGSIZE,INITTYPE,HOST)
      IF(NK.GT.0) THEN
        IF (ME.LT.NPROCS) THEN

      DO 30 I = ME+1, NK, NPROCS
         DO 10 J = 1, MK
            T1 = FLOAT(-IABS(I-J))
C            TEMP(I,J) = 1+EXP(T1)
             TEMP(I,J) = 1+0.5/(T1+0.001)
   10    CONTINUE

         PROD(I) = 1.0
         DO 20 J = 1, MK
            PROD(I) = PROD(I)*TEMP(I,J)
   20    CONTINUE
   30 CONTINUE
      ESTAR = 0
      DO 40 I = ME+1, NK, NPROCS
         ESTAR = ESTAR+PROD(I)
   40 CONTINUE

      CALL gsum0(ESTAR,1,4,PARTTYPE,HOST)
      NODE_SEC=clock0()-STARTTIME

      IF(ME.EQ.0) CALL send0(NODE_SEC,TIMESIZE,TIMETYPE,HOST)
      GOTO 100
      ENDIF

      ELSE

      CALL close0(1)
      WRITE(6,*) 'end of the job on node', ME
      STOP

      ENDIF
      END

