      SUBROUTINE FILDAT(SPOT,LINE)
      IMPLICIT NONE
C
C*********************************************************************
C
C   NAME- FILDAT
C
C   LANGUAGE- VS FORTRAN  TYPE- SUBROUTINE      COMPUTER- CRAY J916
C
C   VERSION- 1.0    DATE- 02/15/93   PROGRAMMER- CARLA NEIGH (SMSRC)
C   VERSION- 2.0    DATE- 07/19/94   PROGRAMMER- FRANK TILLEY (SMSRC)
C       ATOVS-12    EXPLICITLY DECLARED R*4 FUNCTION "SFCEST".
C   VERSION- 3.0    DATE- 05/29/96   PROGRAMMER- LEAH WILSON (HSTX)
C       SYNTAX MODS FOR ATOVS BASELINE ON CRAY.
C   VERSION- 3.1    DATE- 09/22/97   PROGRAMMER- LEAH WILSON (HSTX)
C   VERSION- 3.2    DATE- 05/01/00   PROGRAMMER- M.P.FERGUSON (HSTX)
C   VERSION- 3.3    DATE- 06/05/00   PROGRAMMER- M.P.FERGUSON (RITSS).
C
C   FUNCTION- THIS ROUTINE COMPUTES THE VALUES FOR A SPOT THAT ARE
C             NEEDED TO PERFORM THE CLOUD TESTS.
C   VERSION- 3.1 RTOVS UPGRADES TO USE THE SST FOR THE FCST SURFACE
C                TEMPERATURE IN PREFERENCE TO THE FCST SURFACE
C                PRESSURE AND POTENTIAL TEMPERATURE.  ALSO SET THE
C                FORECAST SURFACE TEMPERATURE TO MISSING OVER ALL
C                LAND AREAS AND SEA ICE.  SINCE /INSCOM/ IS NOW USED,
C                REMOVE NSPOTS,NLINES,NDATEL,NANC,HIRDAC & HIDANC
C                FROM SUBROUTINE CALL.
C   VERSION- 3.2 SETTING OF SNWFRE FLAG CHANGED SO THAT THERE IS NO
C                REQUIRED MINIMUM VALUE FOR TSFC8 OR TSFC18 IN ORDER
C                FOR A FIELD OF VIEW TO BE DESIGNATED "ICE FREE".
C   VERSION- 3.3 OVRLND REDEFINED TO INCLUDE COAST AREAS AS WELL TO
C                CORRESPOND TO CURRENT ATOVS CONVENTIONS.
C   VERSION- 3.4    DATE- 02/27/03   PROGRAMMER- Rickey Rollins (CSC)
C        Replace R4SPV equivalence test with ISR4SPV function      
C
C   CALLING SEQUENCE PARAMETERS-
C
C     NAME      TYPE  I/O                   DESCRIPTION
C     ----      ----  ---   ------------------------------------------
C     SPOT      INT    I    THE NUMBER OF THE SPOT IN THE SCAN LINE
C                           FOR WHICH THE VALUES ARE BEING COMPUTED.
C     LINE      INT    I    THE LINE IN THE HIRS DATA BUFFER CONTAINING
C                           THE SPOT.
C
C   COMMON AREA PARAMETERS- CLDDAT, REGCOE, SPVAL, INSPARM, INSCOM
C
C   LOCAL PARAMETERS-
C
C     NAME      TYPE   DESCRIPTION
C     --------  ----   -----------
C     TERAIN    INT    THE TERRAIN TYPE FROM THE HIRS ANCILLARY BUFFER.
C
C
C   FUNCTIONS USED- ABS, MOD, SFCEST
C
C   EXIT STATES-  NONE
C
C   COMMENTS-
C      IT IS ASSUMED THAT CDB COEFFICIENTS FOR THE CLOUD TESTS HAVE
C      BEEN PLACED IN THE COMMON BLOCK REGCOE.
C
C**********************************************************************
C
      INTEGER  SPOT,LINE
C
      INTEGER TERAIN
      REAL SFCEST
      LOGICAL ISR4SPV
C
      INCLUDE 'CLDDAT'
      INCLUDE 'REGCOE'
      INCLUDE 'SPVAL'
      INCLUDE 'INSPARM'
      INCLUDE 'INSCOM'
C
C   COMPUTE THE SURFACE TEMPERATURE ESTIMATES FOR HIRS CHANNELS
C   8, 18, AND 19.
C
      TSFC8 = SFCEST(HIRDAT,HNSPOT,HTOTLN,HDATEL,TSE8,SPOT,LINE,8)
      TSFC18 = SFCEST(HIRDAT,HNSPOT,HTOTLN,HDATEL,TSE18,SPOT,LINE,18)
      TSFC19 = SFCEST(HIRDAT,HNSPOT,HTOTLN,HDATEL,TSE19,SPOT,LINE,19)
      ESTH8(SPOT,LINE) = TSFC8
      ESTH18(SPOT,LINE) = TSFC18
      ESTH19(SPOT,LINE) = TSFC19
      IF(TSFC8.EQ.0.0) ESTH8(SPOT,LINE) = R4SPV
      IF(TSFC18.EQ.0.0) ESTH18(SPOT,LINE) = R4SPV
      IF(TSFC19.EQ.0.0) ESTH19(SPOT,LINE) = R4SPV
C
C   SET THE LOGICAL CONDITION FLAGS FOR THE SPOT.
C
      IF (HIRANC(SPOT,LINE,3) .GT. 90.5) THEN
         NIGHT = .TRUE.
      ELSE
         NIGHT = .FALSE.
      ENDIF
C
      TERAIN = HIRANC(SPOT,LINE,9)
C
C SNOW, LAND, OR COAST ALL CONSIDERED LAND.
C
      IF (MOD(TERAIN,10) .EQ. 1 .OR. TERAIN .EQ. 2) THEN
         OVRLND = .TRUE.
      ELSE
         OVRLND = .FALSE.
      ENDIF
C
      IF (ABS(HIRANC(SPOT,LINE,1)) .GE. 60.0) THEN
         POLAR = .TRUE.
      ELSE
         POLAR = .FALSE.
      ENDIF
C
      IF (TERAIN .NE. 11) THEN
         SNWFRE = .TRUE.
      ELSE
         SNWFRE = .FALSE.
      ENDIF
C
      IF (TERAIN .NE. 10) THEN
         ICEFRE = .TRUE.
      ELSE
         ICEFRE = .FALSE.
      ENDIF
C
C   COMPUTE THE ESTIMATE OF THE SURFACE TEMPERATURE BASED ON DAYTIME
C   OR NIGHTTIME CONDITIONS.
C
      IF (NIGHT) THEN
         TSFEST = TSFC18
      ELSE
         TSFEST = TSFC8
      ENDIF
C
C   COMPUTE THE FORECAST SURFACE TEMPERATURE FROM THE SEA SURFACE
C   TEMPERATURE.
C
C   AT THIS TIME, SET ALL OVER-LAND AND NON-SEA ICE FCST VALUES TO
C   MISSING VALUES< SO THE SFC TEMPERATURE TEST WILL NOT BE USED
C   OVER LAND OR SEA ICE.
C
C   IF THE SST IS MISSING, USE THE POTENTIAL TEMPERATURE AND THE 
C   SURFACE PRESSURE TO CALCULATE THE FORECAST SFC POTENTIAL TEMP.
C   7/25/97 - IF SST MISSING OVER SEA (SEA ICE), DON'T USE FCST
C   SFC POT. TEMP., TURN OFF OVER SEA ICE.
C
      IF((.NOT.OVRLND).AND.(.NOT. ISR4SPV(HIRANC(SPOT,LINE,10)))) THEN
         FORCST = HIRANC(SPOT,LINE,10)
      ELSE
         FORCST = R4SPV
      ENDIF
C
      RETURN
      END
