Processes communicate and synchronize by sending and receiving values on typed communication streams called channels. A channel is created by a CHANNEL statement, which also defines the supplied inport and outport to be references to the new channel. A channel is a first-in/first-out message queue. An element is appended to this queue by applying the SEND statement to the outport that references the channel. This statement is asynchronous: it returns immediately. An element is removed from the queue by applying the RECEIVE statement to the inport that references the channel. This statement is synchronous: it blocks until a value is available. The ENDCHANNEL statement appends an end-of-channel (EOC) message to the queue. The MOVEPORT statement copies a channel reference from one port variable to another.
These statements all take as arguments a control information list (cilist). The optional IOSTAT= , END= , and ERR= specifiers 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. An implementation should also provide, as a debugging aid, the option of signaling an error if a SEND , ENDCHANNEL , or RECEIVE statement is applied to a port that is the only reference to a channel.
A port is initially undefined. An undefined port becomes defined if it is included in a CHANNEL (or MERGER : see below) statement, if it occurs as a destination in a RECEIVE , or if it is named as the target of a MOVEPORT statement whose source is a defined port. Any other statement involving an undefined port is erroneous.
Application of the ENDCHANNEL statement to an outport causes that port to become undefined. The corresponding inport remains defined until the EOC message is received by a RECEIVE statement, and then becomes undefined. Both inports and outports become undefined if they are named as the source of a SEND or MOVEPORT operation.
Storage allocated for a channel is reclaimed when both (a) either the outport has been closed, or the outport goes out of scope or is redefined, and (b) either EOC is received on the inport, or the inport goes out of scope or is redefined.