   
      SUBROUTINE R_TOT_TRACE(N,K,Matr_input,trace)
C
C	########################################################################
C
C	Valerio Cappellini                                         February 2007
C
C     USES :: None
C     COMPATIBILITY :: Fortran 90
C     VERSION :: 1.0.0
C
C     R_TOT_TRACE.f :: it take as input 2 INTEGER numbers N and K and a REAL
C     matrix M that can either be NxKxNxK or (N*K)x(N*K) and return as output
C     the REAL number "TRACE of M"
C
C	########################################################################
C
$	debug
	implicit none
       
      INTEGER N,K,i
	REAL Matr_input(N*K,N*K), trace
	
	trace = 0.
	Do 10 i=1,N*K
   10	trace = trace + Matr_input(i,i)

      RETURN
      END
