c
c	isendrecv.f 1.4 92/07/01 15:22:39
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 arcsin,
c  and returns the result to node 0.

      include 'fcube.h'

      integer          msgid, inode, ipid
      double precision sbuf0, rbuf0, sbuf1, rbuf1

      sbuf0 = 0.0
      rbuf0 = 0.0
      sbuf1 = 0.0
      rbuf1 = 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(s) and post receive for result.

         sbuf0 = 0.21381
         msgid = isendrecv(10,sbuf0,8,-1,mypid(),11,rbuf0,8)

c    Wait for result.

         call msgwait(msgid)

c    Display result.

         write(*, 100) sbuf0, rbuf0
100      format('Arcsin of ', d15.5, ' is ', d15.5)

c  If not node 0, then ...

      else

c    Receive message.

         call crecv(10, rbuf1, 8)

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

         inode = infonode()
         ipid  = infopid()

c    Get value of result.

         sbuf1 = dasind(rbuf1)

c    Send result to calling node.

         call csend(11, sbuf1, 8, inode, ipid)

      endif

      end
