c
c	forflush.f 1.4 92/07/01 15:19:41
c
c  Copyright 1991 Intel Corporation, Inc.
c  See the "Copyright" file for complete rights and liability information.
c
c  Can run on a multi-node cube, but only node 0 does anything.
c
c  Note:  To verify that the file "mydata" contains the entire list,
c         load the program in the file "mydata.f"

      integer*4 seed
      integer   list(100)

c  Identify self.

      iam = mynode()

c  Node 0 does all the work.

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

c    Delete file named "mydata" (if it exists).

         open(unit = 12, file = '/cfs/mydata',
     1        status = 'unknown', form = 'unformatted')
         close(unit = 12, file = '/cfs/mydata', status = 'delete')

c    Open the file.

         open(unit = 12, file = '/cfs/mydata',
     1        status = 'new', form = 'unformatted')

c    Build list of random integers in the range 0..100.

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

c    Write to the file.

         write(12) (list(i), i = 1, 100)

c    Flush any buffered I/O.

         call forflush(12)

         print *,'... Finished.'

      endif

      end
