c
c	csendrecv.f 1.5 92/07/01 09:03:33
c
c  Copyright 1991 Intel Corporation, Inc.
c  See the "Copyright" file for complete rights and liability information.
c
c  Requires a two-node cube.  Node 0 sends a value to node 1 and posts a
c  receive for a reply; node 1 receives the value, determines its sin,
c  and returns the result to node 0.

      include 'fcube.h'

      integer          len, node, pid
      double precision sbuf, rbuf

      sbuf = 0.0
      rbuf = 0.0

c  Identify self.

      iam = mynode()

c  If node 0, then ...

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

c    Send message to other node and post receive for result.

         sbuf = 12.3456
         len  = csendrecv(10,sbuf,8,-1,mypid(),11,rbuf,8)

c    Display result.

         write(*, 100) sbuf, rbuf
100      format('Sin of ', d15.5, ' is ', d15.5)

c  If node 1, then ...

      else if(iam .eq. 1) then

c    Receive message.

         call crecv(10, rbuf, 8)

c    Get sending node and pid (for returning result).

         node = infonode()
         pid  = infopid()

c    Get value of result.

         sbuf = sind(rbuf)

c    Send result to calling node.

         call csend(11, sbuf, 8, node, pid)

      endif

      end
