subroutine tinv(ama,bve,ampl,mode,rnorm,numdat,NTR2)

!  24 .... max possible number of PARAMETERS (time function shifts)


	  real (8) rnorm,ama(49152,400),bve(49152),ampl(400),wnn(400)
	  integer   i,j,mode
      integer   indx(400)
 
	  integer   numdat

 INTERFACE
  SUBROUTINE nnls (a, m, n, b, x, rnorm, w, indx, mode)
    USE precision
    IMPLICIT NONE
    INTEGER, INTENT(IN)       :: m, n
    INTEGER, INTENT(OUT)      :: indx(:), mode
    REAL (dp), INTENT(IN OUT) :: a(:,:), b(:)
    REAL (dp), INTENT(OUT)    :: x(:), rnorm, w(:)
  END SUBROUTINE nnls
 END INTERFACE

!  call nnls (ama,numdat,12,bve,ampl,rnorm,wnn,indx,mode)   
   
   call nnls (ama,numdat,NTR2,bve,ampl,rnorm,wnn,indx,mode)   





	   return
	   end