   
      SUBROUTINE R_NK_PT_B(N,K,Matr_input,Matr_output)
C
C	########################################################################
C
C	Valerio Cappellini                                         February 2007
C
C     USES :: None
C     COMPATIBILITY :: Fortran 90
C     VERSION :: 1.0.0
C
C     R_NK_PT_B.f :: it take as input the 2 INTEGER numbers N and K and a 
C                 NxKxNxK REAL matrix M and return as output the NxN REAL 
C                 matrix "PARTIAL TRACE over B of M"
C
C	########################################################################
C
$	debug
	implicit none
       
      INTEGER N,K,emme,enne,mu
	REAL Matr_input(N,K,N,K), Matr_output(N,N)
	
	Do 10 enne=1,N
		Do 10 emme=1,N
			Matr_output(emme,enne) = 0.
			Do 10 mu=1,K	
   10			Matr_output(emme,enne) = 
     &		Matr_output(emme,enne) + Matr_input(emme,mu,enne,mu)
      RETURN
      END
