!+ Subroutine to calculate the residuals from a ESFT fit.
!
! Method:
!	Straightforward.
!
! Current Owner of Code: J. M. Edwards
!
! History:
!	Version		Date			Comment
!	1.0		12-04-95		First Version under RCS
!						(J. M. Edwards)
!
! Description of Code:
!   FORTRAN 77  with extensions listed in documentation.
!
!- ---------------------------------------------------------------------
      SUBROUTINE RESIDUAL_FIT(N_TERM, N_DATA
     &   , A, EXP_KU, TRANS
     &   , RESIDUAL
     &   )
!
!
      IMPLICIT NONE
!
!
!     INCLUDE HEADER FILES.
      INCLUDE 'incl/dimensions_spec.ucf'
      INCLUDE 'incl/dimensions_pp.ucf'
!
!     DUMMY ARGUMENTS.
      INTEGER 	!, INTENT(IN)
     &     N_TERM                           
!             NUMBER OF ESFT TERMS
     &   , N_DATA                           
!             NUMBER OF DATA POINTS
      REAL*8 	!, INTENT(IN)
     &     A(NPD_ESFT_TERM)                   
!             ESFT WEIGHTS
     &   , EXP_KU(NPD_ESFT_TERM, NPD_AMOUNT+1)
!             EXPONENTIAL TERMS
     &   , TRANS(NPD_AMOUNT+1)          
!             TRANSMISSIONS
      REAL*8 	!, INTENT(OUT)
     &     RESIDUAL(NPD_AMOUNT+1)       
!             RESIDUALS
!
!     LOCAL VARIABLES.
      INTEGER
     &     I                                
!             LOOP VARIABLE
     &   , N                                
!             LOOP VARIABLE
!
!
!     CALCULATE THE RESIDUALS.
      DO N=1, N_DATA
         RESIDUAL(N)=-TRANS(N)
         DO I=1, N_TERM
            RESIDUAL(N)=RESIDUAL(N)+A(I)*EXP_KU(I, N)
         ENDDO
      ENDDO
!
!
      RETURN
      END
