A process receives a value by applying the RECEIVE statement to an inport. For example, the consumer process in example1.fm (§2) makes repeated calls to the RECEIVE statement so as to receive a sequence of integer messages, detecting end-of-channel by using the IOSTAT specifier, described in the preceding section. A RECEIVE statement is blocking (synchronous): it does not complete until data is available. Hence, the consumer process cannot ``run ahead'' of the producer.
Receive statements for more complex channel types must specify one variable for each value listed in the channel type. For example, the following is a receive statement corresponding to the send statement given as an example in the preceding section.
inport (integer, real x(10)) pi
integer i
real a(10)
...
receive(pi) i, a
An array element name can be given as an argument to a RECEIVE statement. If the corresponding message component is an array, then this is interpreted as a starting address and the required number of elements are stored in contiguous elements in array element order. Hence the following statement receives the ith row of the array b.
inport (integer, real x(10)) pi
integer i, j
real b(10,10)
...
receive(pi) j, b(1,i)
As in Fortran I/O statements, END= , ERR= , and IOSTAT= specifiers can be included to indicate how to recover from erroneous 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 END=label specifier causes execution to continue at the statement with the specified label upon receipt of a EOC message. See Appendix A for a list of the valid IOSTAT values.