c
c	gopf1.f 1.4 92/07/01 15:20:15
c
c  Copyright 1991 Intel Corporation, Inc.
c  See the "Copyright" file for complete rights and liability information.
c
c  Part 1 of 2:
c    Runs on all nodes.
c    Creates a list of random numbers in the range 1..100
c      and determines the largest value in the list.
c    Calls the function max_node (defined in the file gopf2.f)
c      to determine the largest value across all nodes.

      include 'fcube.h'

      external max_node

      integer*4 iam, max_node, size, seed
      parameter (size = 10)
      real      list(size)
      real      mine(3), work(3)

c  Identify self.

      iam = mynode()
      if(iam .eq. 0) print *, 'Starting ...'

c  Create list of random reals in the range 0..100.

      seed = (2 * mclock()/(iam+1)) + 1
      do 1, i = 1, size
         list(i) = 100 * ran(seed)
1     continue

      write(*, 100) iam, (list(i), i = 1, size)
100   format('List for Node ', i3, ' is: ', 10f6.1)

c  Determine: mine(1) -- maximum absolute value in list.
c             mine(2) -- associated element number.
c             mine(3) -- associated node number.

      mine(1) = abs(list(1))
      mine(2) = 1
      mine(3) = iam
      do 2, i = 2, size
         if(mine(1) .lt. abs(list(i))) then
             mine(1) = abs(list(i))
             mine(2) = i
         endif
2     continue

c  Call gopf() to determine maximum value across all nodes.

      call gopf(mine, 12, work, max_node)

c  Display maximum value and associated element and node numbers.

      if(iam .eq. 0) write(*, 200) mine(1), mine(2), mine(3)
200   format(/, 'Maximum value is ', f4.1, ' in element ', f3.0,
     1       ' on Node ', f3.0)

      end
