* Test of PVMFSEND AND PVMFRECEIVE Function Subroutine Calls *********************************************************** * Program RcTest Parameter(Nprint=1) ! diagnostic print only for Nprint.gt.0. Real D(5),Dmax(1) Real DMmax(0:3),Result ! Master copies of local max changes. Real DGmax ! global max change Integer MsgTag,MyTID,MasTID,MyPE,MsgPE,Master Integer Info,BufID,SendTID Integer NPEs Intrinsic maxval * Include '/usr/include/mpp/fpvm3.h' ! include pvm header definitions * Code: Copies of This code are run by all processors. Code: Enroll into PVM Code: Obtain initial PVM data. Call pvmfmytid(MyTID) ! get This PE's Task ID (TID) Call pvmfgetpe(MyTID,MyPE) ! get PE's PE ID Call pvmfgsize(PVMALL,NPEs) ! get group size of all * Write(6,*) 'MyPE,MyTID,NPEs=',MyPE,MyTID,NPEs * Code: Job Script preSpawns Master and Nproc-1 slaves * Master = 0 Call pvmfgettid(PVMALL,Master,MasTID) ! get TID of Master Write(6,*) 'MyPE,MyTID,Master,MasTID=',MyPE,MyTID,Master,MasTID * Do i=1,5 D(i)=(NPEs-MyPE)*i*0.1 Enddo Write(6,66) MyPE,(D(i),i=1,5) * Dmax(1)=maxval(D) Write(6,67) MyPE,Dmax(1) * DMmax(0)=Dmax(1) MsgTag=2 If(MyPE.gt.0) Then CAREFUL of Sending Shared/Global Data, But Sending MyPE is OK Here: Call pvmfinitsend(PVMDEFAULT,BufID) CAUTION: T3D uses 8 Byte Integers! Call pvmfpack(Integer8,MyPE,1,1,Info) Call pvmfpack(Real8,Dmax(1),1,1,Info) Call pvmfsend(MasTID,MsgTag,Info) Else Do ip = 1, NPEs-1 Call pvmfrecv(-1,MsgTag,BufID) Call pvmfbufinfo(BufID,NBytes,MsgTag,SendTID,Info) ! Get SenderID Call pvmfunpack(Integer8,MsgPE,1,1,Info) Call pvmfunpack(Real8,Result,1,1,Info) Print65,'Slave:',SendTID,'; returned:',Result,'@NBytes:', & NBytes,' for All Messages' Write(6,67) MsgPE,Result ! print received results DMmax(ip)=Result Enddo Endif If(MyPE.eq.Master) Then DGmax=maxval(DMmax) ! Get Global Max of Local Maxs Write(6,68) MyPE,DGmax Endif 65 Format(1x,a,i13,a,f10.4,a,i13,a) 66 Format(1x,'MyPE,D(1:5)= ',i13,5F10.4) 67 Format(1x,'MyPE,LocalMax(D)= ',i13,F10.4) 68 Format(1x,'MyPE,GlobalMax(D)= ',i13,F10.4) * CAUTION: Must Use Barrier So Master Can Finish Global Max, Before Slaves Code: Leave with their Message Buffers! call pvmfbarrier(PVMALL,-1,Info) Code: Exit PVM Call pvmfexit(Info) * STOP END