Processes and Ports



next up previous contents index
Next: Creating Channels and Up: The Fortran M Previous: The Fortran M

Processes and Ports

   

As illustrated in the program example1.fm (§2), a task is implemented in Fortran M as a process . A process, like a Fortran program, can define common data (labeled PROCESS COMMON  to emphasize that it is local to the process) and subroutines that operate on that data. It also defines the interface by which it communicates with its environment. A process has the same syntax as a subroutine, except that the keyword PROCESS  is used in place of SUBROUTINE .

A process's dummy arguments  (formal parameters) are a set of typed port variables. These define the process's interface to its environment. (For convenience, conventional argument passing is also permitted between a process and its parent. This feature is discussed in Section 3.8.) A port variable declaration has the general form

port_type ( data_type_list ) name_list

The port_type is OUTPORT  or INPORT  and specifies whether the port is to be used to send or receive data, respectively. The data_type_list is a comma-separated list of type declarations and specifies the format of the messages  that will be sent on the port, much as a subroutine's dummy argument declarations defines the arguments that will be passed to the subroutine.

In the program example1.fm (§2), both pi and po are to be used to communicate  messages comprising single integers. More complex message formats can be defined. For example, the following declarations define inports able to (1) receive messages comprising single integers, (2) arrays of msgsize reals (p2), and (3) a single integer and a real array with size specified by the integer, respectively. In the second and third declaration, the names m and x have scope  local to the port declaration.

      inport (integer) p1
      inport (real x(msgsize)) p2
      inport (integer m, real x(m)) p3

The value of a port variable is initially a distinguished value NULL. It can be defined to be a reference to a channel by means of the CHANNEL , MERGER , MOVEPORT , or RECEIVE  statements, to be defined below.

A port cannot appear in an assignment statement. The MOVEPORT  statement is used to assign the value of one port to another. For example:

      inport (integer) p1, p2
      moveport(from=p1, to=p2)

This moves the port reference from p1 to p2, and then invalidates the FROM= port (p1) by setting it to NULL so that it can no longer be used by SEND , RECEIVE , etc.

   



next up previous contents index
Next: Creating Channels and Up: The Fortran M Previous: The Fortran M



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