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
call pvmfrecv(tid, msgtag, bufid)This will receive a message from task
msgtagand 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
call pvmfunpack(what, xp, nitem, stride, info)The
whatargument specifies the type of data to be unpacked. The options used for
pvmfpack()are valid for this routine. The
xpparameter is where the first item unpacked is to be stored. The
stridearguments 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
resultsarray and adds it to the running sum.