c
c	cprobe.f 1.4 92/07/01 15:18:05
c
c  Copyright 1991 Intel Corporation, Inc.
c  See the "Copyright" file for complete rights and liability information.
c
c  Requires at least a two-node cube.  Node 0 sends a message; other nodes
c  receive it.

      include 'fcube.h'

      integer      iam, msg_type
      integer      count, node, pid, type
      character*80 msg, smsg, rmsg
      parameter    (msg_type = 10)

c  Identify self.

      iam = mynode()

c  If node 0, then ...

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

c    Build message.

         msg = 'Hello from node '
         write(smsg, 100) msg, iam
100      format(a16, i3, '.')

c    Send message.

         call csend(msg_type, smsg, len(smsg), -1, mypid())

         write(*, 200) iam, smsg
200      format('Node ', i3, ' sent: ', a20)

c  if not node 0, then ...

      else

c    Probe for message.

         call cprobe(msg_type)

c    Receive message.

         if(infocount() .le. len(rmsg)) then
            call crecv(msg_type, rmsg, len(rmsg))
            count = infocount()
            type  = infotype()
            pid   = infopid()
            node  = infonode()

c    Report receipt of message.

            write(*, 300) iam, count, type, pid, node
300         format('Node ', i3,
     1         ' reports ', i3
     2         '-byte message of type ', i2,
     3         ' received from PID ', i2,
     4         ' on node ', i3, '.')

            write(*, 400) iam, rmsg
400         format('Node ', i3, ' received: ', a30)

         endif

      endif

      end
