FORTRAN Reference Manual

Interprocess Communication
FORTRAN Reference Manual528615-001
14-9
READ Statement With $RECEIVE
The requester is the same as in the prior example. The server code is also the same,
except that there is another OPEN statement and the responding WRITE statement is
changed:
?RECEIVE (OPEN 2, MAXREPLY 132)
...
CHARACTER*80 request
CHARACTER*132 reply
...
OPEN (UNIT=1,FILE='$RECEIVE',MODE='INPUT')
OPEN (UNIT=2,FILE='$RECEIVE',MODE='OUTPUT')
...
10 READ (UNIT=1,END=100) request
IF (request(1:3) .EQ. 'ADD') THEN
... <-- Code to
... <-- process request
END IF
...
WRITE (UNIT=2) reply
GO TO 10
...
100 STOP
END
During program testing, you might use this approach and assign the input and output
units to separate disk files to test program logic without the complications of
asynchronous processing. When testing is completed, you can reassign both the input
unit and all the output units to $RECEIVE.
READ Statement With $RECEIVE
The control list of the READ statement includes a SOURCE specifier that enables a
server to determine the identity of, and information about, a requester.
The source specifier has the form:
SOURCE = iarr
where iarr is an integer array of at least 16 elements.
The layout of iarr if you specify ENV COMMON differs from the layout of iarr if you
specify ENV OLD or you do not specify an ENV directive. Table 14-1 on page 14-10