The <tt>MERGER</tt> Statement



next up previous contents index
Next: The PROBE Statement Up: Nondeterministic Computations Previous: Nondeterministic Computations

The MERGER Statement

   

A MERGER  statement defines a first-in/first-out message queue, just like CHANNEL . However, it allows multiple outports to reference this queue and hence defines a many-to-one communication structure.    Messages sent on any outport are appended to the queue, with the order of messages sent on each outport being preserved and any message sent on an outport eventually appearing in the queue.

The MERGER  statement has the following general form.

merger(in=inport, out=outport_specifier)

This creates a new merger, defines inport  to be able to receive messages from this merger, and defines the outports specified by the outport_specifier to be able to send messages on this merger. An outport_specifier can be a single outport, a comma-separated list of outports, or an implied do-loop . The inport and the outports in the outport_specifier must be of the same type. Optional IOSTAT=  and ERR=  specifiers can be used as in Fortran file input/output statements to detect error conditions. See Appendix A for a list of valid IOSTAT  values.

The following merger1.fm example uses MERGER  to create a manager/worker structure with a single manager and multiple workers. The manager and worker components have been previously defined in the work_man.fm program in §3.7. In this example, two mergers are used: one to connect numwork workers with the manager, and one to connect the workers with an outmonitor process.

==

      program merger1
      integer numwork, i
      parameter (numwork = 10)
      inport  (real) scores_in
      outport (real) scores_out(numwork)
      inport  (outport (integer)) reqs_in
      outport (outport (integer)) reqs_out(numwork)
      
      merger(in=reqs_in, out=(reqs_out(i),i=1,numwork))
      merger(in=scores_in, out=(scores_out(i),i=1,numwork))
      
      processes
         processcall manager(reqs_in)
         processdo i = 1, numwork
            processcall worker(reqs_out(i), scores_out(i))
         endprocessdo
         processcall outmonitor(scores_in)
      endprocesses
      end
=1.03   

 



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