Cube - communication  for  PVM
C 
C  Basic-Routine for Inner-Cube-Communication
C    Send N words from X to processor NrTo   ( 0, ..., NPROC-1)
C
	SUBROUTINE Send_Node_1(N,X,NrTo)

	INCLUDE 'trnet.inc'
	INCLUDE 'times.inc'
	INCLUDE 'trnet_m.inc'
	INCLUDE 'fpvm3.h'
	INTEGER   INFO
	Dimension X(*)
#ifdef SECNDS_EXTERNAL
	EXTERNAL secnds		! sonst bei SGI/LINUX falsches UP
#endif
	DATA MsgTag / 0 /

	ito =pvm_tids(NrTo)
C -
	N_out=N_out+1
	NW_out=NW_out+N
	t=secnds(0.0)
C -->
	if (N .GT. 0) then
 	  call pvmfinitsend ( PVMRAW, INFO )
	  call pvmfpack(BYTE1, X , 4*N, 1, INFO )
          if (INFO .LT. 0) then
            call pvmfperror("pvmfpack(X)")
            stop
          endif
	endif
	call pvmfsend ( ito, MsgTag, INFO )
	if (INFO .LT.0) then
          call pvmfperror("pvmfsend")
	  write(7,*) ICH,':  SendChan: IER=',INFO
	  stop
	endif
	Toutput=Toutput + secnds(t)
	RETURN
	END
C
C  Basic-Routine for Inner-Cube-Communication
C  Receive  N words from  processor NrFrom           ( 0, ..., NPROC-1 )
C
	SUBROUTINE Recv_Node_1(N,X,NrFrom)

	INCLUDE 'trnet.inc'
	INCLUDE 'trnet_m.inc'
	INCLUDE 'times.inc'
	INCLUDE 'fpvm3.h'
	INTEGER   INFO
	Dimension X(*)
#ifdef SECNDS_EXTERNAL
	EXTERNAL secnds		! sonst bei SGI/LINUX falsches UP
#endif
	DATA MsgTag / 0 /

	t=secnds(0.0)

	ifrom=pvm_tids(NrFrom)
C --
	N_in=N_in+1
	NW_in=NW_in+N
C -->
	if (N .GT. 0) then
	  call pvmfrecv(ifrom,MsgTag,INFO)
	  if (INFO .lt.0) then
            call pvmfperror("pvmfrecv")
	    write(*,*) ICH,':  Recv_Chan: IER=',INFO
	    stop
	  endif
	
 	  call pvmfunpack( BYTE1, X, 4*N, 1, INFO )
          if (INFO .lt. 0) then
            call pvmfperror("pvmfunpack(X)")
            stop
          endif
	endif
	Tinput=Tinput + secnds(t)
	RETURN
	END
 
