next up previous

3.2 Fortran 77 Example     continued...

After the program is enrolled in the virtual machine, the master program initializes the data that is to be summed up. Next, the worker processes are spawned. The routine to spawn worker processes is pvmfspawn().

call pvmfspawn(task, flag, where, ntask, tids, numt)

The first parameter, task, is a string containing the name of the executable file that is to be used. The integer flag parameter is used to determine the specific machine or type of architecture the spawned task is to be run on. Possible values for flag are:

These symbolic names are predefined in parameter statements in the PVM Fortran include file fpvm3.h. The ntask parameter specifies the number of copies of the task to be spawned and tids is an integer array that is to contain the task ids of all tasks successfully spawned. The routine returns the number of tasks that were successfully created through the numt parameter. If some tasks could not be started, the last ( ntask - numt) positions of tids will contain error codes for the unspawned tasks.

In our example code five (NPROCS) copies of the executable file ``worker'' will be spawned by the master program. We allow PVM to choose which machines will be used to execute the worker code. The task ids will be placed in the array task_ids.