Cube - communication  for  PVM
C 
C  Basic-Routine for Inner-Cube-Communication
C    Send N words from X over Link NrLink
C
	SUBROUTINE Send_Chan_0(N,X,NrLink)

	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 falsches UP
#endif

	IWHO=IEOR(ICH,Ishft(1,NrLink-1))
	ito =pvm_tids(IWHO)
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("pvmpack(X)")
            stop
          endif
	  call pvmfsend ( ito, NrLink, INFO )
	  if (INFO .lt.0) then
            call pvmfperror("pvmfsend")
	    write(7,*) ICH,':  SendChan: IER=',INFO
	    stop
	  endif
	ENDIF
	Toutput=Toutput + secnds(t)
	RETURN
	END
C
C  Basic-Routine for Inner-Cube-Communication
C  Receive N words over Link NrLink
C
	SUBROUTINE Recv_Chan_0(N,X,NrLink)

	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 falsches UP
#endif

	t=secnds(0.0)

	IWHO=IEOR(ICH,Ishft(1,NrLink-1))
	ifrom=pvm_tids(IWHO)
C --
	N_in=N_in+1
	NW_in=NW_in+N
C -->
	IF (N .GT. 0) THEN
	  call pvmfrecv(ifrom,NrLink,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
 
