      FUNCTION SFCEST(HIRDAT,NSPOTS,NLINES,NDATEL,COEFF,SPOT,LINE,CHAN)
      IMPLICIT NONE
C***********************************************************************
C
C   NAME-  SFCEST
C
C   LANGUAGE- VS FORTRAN  TYPE- REAL*4 FUNCTION  COMPUTER-  HDS 9000
C
C   VERSION- 1.0    DATE- 02/05/93   PROGRAMMER- CARLA NEIGH, SMSRC
C   VERSION- 3.0    DATE- 05/29/96   PROGRAMMER- LEAH CASEY (HSTX)
C        SYNTAX MODS FOR ATOVS BASELINE ON CRAY.
C   VERSION- 1.2    DATE- 02/08/02   PROGRAMMER- RICKEY ROLLINS (CSC)
C      REDECLARED VARIABLES AAS I*8 and R*8
C   VERSION- 2.0    DATE- 02/27/03   PROGRAMMER- Rickey Rollins (CSC)
C        Replace R4SPV equivalence test with ISR4SPV function
C
C   FUNCTION-  THIS FUNCTION RETURNS THE SURFACE TEMPERATURE
C              COMPUTED FROM THE SPECIFIED HIRS CHANNEL.
C
C
C   CALLING SEQUENCE PARAMETERS-
C   NAME    TYPE   I/O   DESCRIPTION
C   ----    ----   ---   -----------
C   HIRDAT  REAL    I    ARRAY (DIM NSPOTS X NLINES X NDATEL) CONTAINING
C                        THE HIRS DATA BUFFER.
C   NSPOTS  INT     I    TOTAL NUMBER OF SPOTS IN A SCAN LINE IN THE
C                        HIRS DATA BUFFER.
C   NLINES  INT     I    TOTAL NUMBER OF SCAN LINES IN THE HIRS DATA
C                        BUFFER.
C   NDATEL  INT     I    TOTAL NUMBER OF DATA ELEMENTS IN THE HIRS
C                        DATA BUFFER.
C   COEFF   REAL    I    ARRAY (DIM NSPOTS X 6) OF REGRESSION
C                        COEFFICIENTS FOR THE SURFACE TEMPERATURE
C                        ESTIMATION FOR THE CHANNEL.
C   SPOT    INT     I    SPOT NUMBER IN HIRS DATA BUFFER FOR WHICH THE
C                        SURFACE TEMPERATURE ESTIMATE IS BEING COMPUTED.
C   LINE    INT     I    LINE NUMBER IN HIRS DATA BUFFER FOR WHICH THE
C                        SURFACE TEMPERATURE ESTIMATE IS BEING COMPUTED.
C   CHAN    INT     I    NUMBER OF HIRS CHANNEL USED TO ESTIMATE THE
C                        SURFACE TEMPERATURE.
C
C   EXIT STATES- NONE
C
C   COMMENTS-
C     THE REGRESSION COEFFICIENTS MUST BE THE CORRECT COEFFICIENTS FOR
C     THE CHANNEL INPUT.  IT IS ASSUMED THAT NONE OF THESE VALUES ARE
C     MISSING.
C
C     IF ANY OF THE HIRS VALUES USED TO COMPUTE THE SURFACE TEMPERATURE
C     ESTIMATE ARE MISSING, THE RETURN VALUE OF THE FUNCTION IS A
C     MISSING VALUE.
C
C***********************************************************************
C
      INTEGER NSPOTS, NLINES, NDATEL, SPOT, LINE, CHAN
      REAL SFCEST, HIRDAT(NSPOTS,NLINES,NDATEL), COEFF(NSPOTS,6)
      LOGICAL   ISR4SPV
C
      INCLUDE 'SPVAL'
C
C  IF ANY OF THE HIRS CHANNEL VALUES NEEDED FOR THE COMPUTATION ARE
C  MISSING, THE SURFACE TEMPERATURE ESTIMATE IS RETURNED AS A
C  MISSING VALUE.
C
      IF ((ISR4SPV(HIRDAT(SPOT,LINE,6))) .OR.
     1   (ISR4SPV(HIRDAT(SPOT,LINE,7))) .OR.
     2   (ISR4SPV(HIRDAT(SPOT,LINE,10))) .OR.
     3   (ISR4SPV(HIRDAT(SPOT,LINE,11))) .OR.
     4   (ISR4SPV(HIRDAT(SPOT,LINE,CHAN)))) THEN
C
         SFCEST = R4SPV
         RETURN
      ENDIF
C
C  COMPUTE THE SURFACE TEMPERATURE ESTIMATE FOR THE CHANNEL.
C
      SFCEST = COEFF(SPOT,1) + COEFF(SPOT,2)*HIRDAT(SPOT,LINE,6)
     1         + COEFF(SPOT,3)*HIRDAT(SPOT,LINE,7)
     2         + COEFF(SPOT,4)*HIRDAT(SPOT,LINE,10)
     3         + COEFF(SPOT,5)*HIRDAT(SPOT,LINE,11)
     4         + COEFF(SPOT,6)*HIRDAT(SPOT,LINE,CHAN)
C
      RETURN
      END
