<tt>SEND</tt> and <tt>ENDCHANNEL</tt>



next up previous contents index
Next: RECEIVE Up: Communication Previous: Communication

SEND and ENDCHANNEL

         

A process sends a message by applying the SEND  statement to an outport; the outport declaration specifies the message format. A process can also call ENDCHANNEL  to send an end-of-channel  (EOC) message. ENDCHANNEL  also sets the value of the port variable to NULL, preventing further messages from being sent on that port. The SEND  and ENDCHANNEL  statements are nonblocking (asynchronous): they complete immediately. When a SEND  statement completes, you are guaranteed that the variables that were sent are no longer needed by the send, so they may be modified.

For example, in the program example1.fm (§2), the outport po is defined to allow the communication of single integers. The producer process makes repeated calls to SEND  statement to send a sequence of integer messages, and then signals end-of-channel by a call to ENDCHANNEL .

  Channels can also be used to communicate more complex messages. For example, in the following code fragment the SEND  statement sends a message consisting of the integer i followed by the first 10 elements of the real array a.

      outport (integer, real x(10)) po
      integer i
      integer a(10)
      ...
      send(po) i, a

  An array element name can be given as an argument to a SEND  statement. If the corresponding message component is an array, then this is interpreted as a starting address, from which the required number of elements, as specified in the outport declaration, are taken in array element order. Hence, the following statement sends the ith row of the array b.

      outport (integer, real x(10)) po
      integer i
      integer b(10,10)
      ...
      send(po) i, b(1,i)

As in Fortran I/O statements, ERR=  and IOSTAT=  specifiers can be included to indicate how to recover from exceptional conditions. These have the same meaning as the equivalent Fortran I/O specifiers, with end-of-channel  treated as end-of-file, and an operation on an undefined port treated as erroneous. Hence, an ERR=label specifier in a SEND  or ENDCHANNEL  statement causes execution to continue at the statement with the specified label if the statement is an undefined port. An IOSTAT=intval specifier causes the integer variable intval to be set to 0 upon successful execution and to an error value otherwise. See Appendix A for a complete list of valid IOSTAT values.

     



next up previous contents index
Next: RECEIVE Up: Communication Previous: Communication



Steve Tuecke
Tue Aug 30 12:20:34 CDT 1994