      real FUNCTION FUNCTN(X,I,PARMS,CONST,MODFIT)
C-----------------------------------------------------------------------
C @(#)functn.f	5.1 06/22/94
C-----------------------------------------------------------------------
C
C  THIS FUNCTION SUBPROGRAM CALCULATES THE SYSTEM TEMPERATURE FOR
C  A GIVEN ATMOSPHERIC OPTICAL DEPTH, RECEIVER NOISE TEMP,
C  AMBIENT TEMPERATURE, MEAN ATMOSPHERIC TEMPERATURE, AND SKY
C  EFFICIENCY.
C
C  DESCRIPTION OF PARAMETERS:
C    X - ARRAY OF DATA POINTS FOR INDEPENDENT VARIABLE (AIR MASS);
C    I - INDEX OF DATA POINTS;
C    PARMS - ARRAY OF PARAMETERS;
C    CONST - ARRAY OF CONSTANTS;
C    MODFIT - FIT MODE, I.E., WHICH VARIABLES ARE TO BE FREE OF FIXED.
C
      real X(*), PARMS(*), CONST(*), tau0, rtm, rtsbr, rtchop, etal, xi,
     .     ex, rtbg
      integer*2 modfit, i
c
C  DEFINE PARAMETERS AS TRANSFERRED FROM THE MAIN PROGRAM:
      TAU0 = PARMS(1)
      RTM = CONST(5)
      RTSBR = CONST(8)
      RTBG = CONST(10)
      RTCHOP = CONST(14)
C
C  DEFINE CONSTANTS AND FREE PARAMETERS ACCORDING TO MODFIT:
C
      GO TO (310,315) MODFIT
  310 CONTINUE
      ETAL = CONST(15)
      GO TO 330
  315 CONTINUE
      ETAL = PARMS(2)
  330 CONTINUE
C
C  FUNCTION IS TCAL = RTCHOP - ETAL*RTM*(1 - EXP(-TAU0 * X))
C          - (1 - ETAL)*RTSBR - ETAL*RTBG*EXP(-TAU0 * X)
C
      XI = X(I)
      EX = EXP(-TAU0*XI)
      FUNCTN = RTCHOP - ETAL*RTM*(1. - EX)
      FUNCTN = FUNCTN - (1. - ETAL)*RTSBR - ETAL*RTBG*EX
      RETURN
      END
C

