next up previous

3.2 Fortran 77 Example     continued...

After the sum is computed and printed the master task informs the PVM daemon that it is withdrawing from the virtual machine. This is done by calling the routine pvmfexit().

call pvmfexit(info)

As for the worker program, after enrolling in the virtual machine the worker tasks wait to receive their portion of the array to be summed. Using the `-1' values in the pvmfrecv() call indicates that the task does not care what task the message was sent from nor what label was used. Since the size of the array being sent may not be known ahead of time, the receiving array is declared with enough space to hold any reasonable number of items. Once unpacked, the array fragment is summed up and the total is sent back to the parent. The task id of the task that spawned the current task is returned by the pvmfparent() routine.

call pvmfparent(tid)
Note that since the master program is expecting a msgtag of `7' from the worker tasks, this value must be used in the pvmfsend() call.

Helpful Hint: If the set of tasks spawned will need to communicate amongst themselves, the spawning task needs to send the task array tids that is generated in the pvmfspawn() routine to each.