next up previous

3.2 Fortran 77 Example     continued...

After the array portions have been distributed, the master program must receive a partial sum from each of the worker processes. To receive a message, a task calls the pvmfrecv() routine.

call pvmfrecv(tid, msgtag, bufid)
This will receive a message from task tid with label msgtag and place it into the receive buffer with id bufid. If no message is waiting from the given task with the expected label, the routine waits until a message from the proper task and the correct label arrives. Values of `-1' for the parameters will match with any task id and/or label. In the example code, the master program is expecting a label value of `7' on messages from the worker tasks. The messages are to be received from tasks in the order that they were sent.

Once a message has been received the data contained must be unpacked. The unpacking routine is pvmfunpack.

call pvmfunpack(what, xp, nitem, stride, info)
The what argument specifies the type of data to be unpacked. The options used for pvmfpack() are valid for this routine. The xp parameter is where the first item unpacked is to be stored. The nitem and stride arguments give the number of items to be unpacked and the stride to be used. Our example code unpacks each partial result received into a different element of the results array and adds it to the running sum.