      SUBROUTINE WRTR1T2800(OBSHIR,BOX,I,J,II,JJ,
     2                  R1T1ST,OLR,LC1,LC2,LC3,LC4,QCFLAG,NEWCH8,
     3                  PROFLV,LIMTER,A10U8,PREDTEMP,
     4                  SURF8,RDT8CA,RDT8MA,RCLODA,AROSOL,H8RAD,H8STER,
     5                  CCHRAD,TCLOUD,HBTCCL,CONPCT,RCCCTT,RCC8STE,
     6                  RCCPC8,CPERROR,TCLEAR4,PREDTEM8,RDTC8A,TCLR84,
     7                  PCLRATN,BCORSTE,ATNPCLR,ATNPCL8,PRSTRO,TMPTRO,
     8                  DNCHAN,RADT8C8,RCBIAS,DELPRS8,LOGSFC,
     9                  LOGCTP,LOGPEAK,DELPRS1,DELPRS2,DELPRS3,DELPRS4,
     +                  PRSTRO2,TMPTRO2,CHNERRORIG,TSFCOB,CTPITER,
     +                  CHNERRFIN,ECAORIG,PASSFAIL,
     +                  OPDEPTH,RADSTE,RADT8CU,ATNPCLR8,BCATPCLR8,RADBCATPC8,
     +                  PREDTEM8COR,LPINDX,RADCLR,DELPRESX,NCH1GUESS,
     +                  T_VALUE)

      IMPLICIT NONE
C
C***********************************************************************
C    NAME- WRTR1T2800
C
C    LANGUAGE- FORTRAN        TYPE- SUBROUTINE    COMPUTER- AIX
C
C    VERSION- 1.0     DATE- 09/05/95   PROGRAMMER- LEAH WILSON (HSTX)
C    VERSION- 1.1     DATE- 11/25/96   PROGRAMMER- A. ALLEGRINO (HSTX)
C    VERSION- 1.2     DATE- 12/05/96   PROGRAMMER- A. ALLEGRINO (HSTX)
C    VERSION- 1.3     DATE- 12/30/96   PROGRAMMER- LEAH WILSON (HSTX)
C    VERSION- 1.4     DATE- 02/21/97   PROGRAMMER- LEAH WILSON (HSTX)
C    VERSION- 1.5     DATE- 05/01/97   PROGRAMMER- LEAH WILSON (HSTX)
C    VERSION- 1.6     DATE- 06/18/97   PROGRAMMER- A. ALLEGRINO (HSTX)
C    VERSION- 1.7     DATE- 08/28/97   PROGRAMMER- A. ALLEGRINO (HSTX)
C    VERSION- 3.0     DATE- 11/13/97   PROGRAMMER- BRIAN BARIL (HSTX)
C    VERSION- 3.1     DATE- 03/05/98   PROGRAMMER- LEAH WILSON (HSTX)
C    VERSION- 3.2     DATE- 06/02/98   PROGRAMMER- BRIAN BARIL (RSTX)
C    VERSION- 3.3     DATE- 07/24/98   PROGRAMMER- LEAH WILSON (RSTX)
C    VERSION- 3.4     DATE- 11/20/98   PROGRAMMER- LEAH WILSON (RAYTHEON)
C    VERSION- 3.5     DATE- 03/26/99   PROGRAMMER- BRIAN BARIL (RSTX)
C    VERSION- 3.6     DATE- 04/15/99   PROGRAMMER- A.ALLEGRINO (RAYTHEON)
C    VERSION- 3.7     DATE- 04/29/99   PROGRAMMER- BRIAN BARIL (RAYTHEON)
C    VERSION- 3.8     DATE- 10/14/99   PROGRAMMER- A. ALLEGRINO (RAYTHEON)
C    VERSION- 3.9     DATE- 04/17/00   PROGRAMMER- LEAH WILSON (RAYTHEON)
C    VERSION- 3.10    DATE- 04/18/00   PROGRAMMER- A. ALLEGRINO (RAYTHEON)
C    VERSION- 3.11    DATE- 06/29/00   PROGRAMMER- LEAH WILSON (RAYTHEON)
C    VERSION- 3.12    DATE- 08/24/00   PROGRAMMER- LEAH WILSON (RAYTHEON)
C    VERSION- 3.13    DATE- 06/01/01   PROGRAMMER- A. ALLEGRINO (RAYTHEON)
C    VERSION- 3.14    DATE- 09/19/01   PROGRAMMER- A. ALLEGRINO (RAYTHEON)
C    VERSION- 4.0     DATE- 05/09/02   PROGRAMMER- A. ALLEGRINO (RAYTHEON)
C    VERSION- 4.1     DATE- 09/12/02   PROGRAMMER- A. ALLEGRINO (RAYTHEON)
C    VERSION- 4.2     DATE- 12/03/02   PROGRAMMER- FRANK TILLEY (RAYTHEON)
C    VERSION- 4.3     DATE- 03/14/03   PROGRAMMER- FRANK TILLEY (RAYTHEON)
C    VERSION- 5.0     DATE- 02/27/03   PROGRAMMER- Rickey Rollins (CSC)
C    VERSION- 5.1     DATE- 07/25/04   PROGRAMMER- FRANK TILLEY (RAYTHEON)
C    VERSION- 5.2     DATE- 03/16/05   PROGRAMMER- FRANK TILLEY (RAYTHEON)
C    VERSION- 5.3     DATE- 03/23/06   PROGRAMMER- FRANK TILLEY (ERT)
C    VERSION- 5.4     DATE- 03/04/08   PROGRAMMER- FRANK TILLEY (IMSG)
C    VERSION- 5.5     DATE- 07/04/13   PROGRAMMER- FRANK TILLEY (IMSG)
C
C    FUNCTION- THIS SUBROUTINE WRITES CLIMATE INFORMATION TO THE DSDR1T.
C    FUNCTION- (VERSION 1.1) MODIFIED WRITING THE SPOT NUMBER TO THE
C              ROTATING 1T BY CHANGING THE INPUT FROM VARIABLE II TO
C              ISPT.  THIS RECTIFIED THE PROBLEM OF SEEING 3X3 SQUARES
C              OF THE SAME SPOT NUMBER ON THE ROTATING 1T
C    VERSION- 1.2 CHECKERBOARD PATTERN DISCOVERED WITH THE SPARES
C                 IN THE SUBROUTINE FILSPR. HAVE CHANGED THE II &
C                 JJ INPUTS TO THE SUBROUTINE TO ISPT AND ILINE TO
C                 CORRECT PROBLEM
C    VERSION- 1.3 REMOVE CALL TO R1TNOD.  THIS IS NOW CALCULATED IN
C                 SUBROUTINE NODR1T, CALLED BY THE SPGDVR MAIN.
C    VERSION- 1.4 ADD OLR AND LC1-4 AND QUESTIONABLE FLAG.
C    VERSION- 1.5 INCREASE 3RD DIMENSION OF OBSHIR FROM 19 TO 20.
C                 STORE NODE (INPUT FROM OBSHIR(X,Y,20)) ON DSDR1T.
C    VERSION- 1.6 USED 6TH SPARE TO STORE THE WATER VAPOR ATTENUATED
C                 HIRS CHANNEL 8
C    VERSION- 1.7 THE MISSING VALUE FOR THE CLOUD PRODUCTS ( MISSING=
C                 -777) IS NOT SCALED BEFORE BEING WRITTEN ONTO THE
C                 ROTATING 1T BECAUSE THE DSDR1T ARRAY IS I*2.
C    VERSION- 3.0 MODIFICATIONS FOR INCLUSION INTO ATOVS.  ADDED AMSU-A
C                 CHANNELS 1,2,3,4,6,8,10-15 AND 2 NEW RETRIEVAL LEVELS.
C                 REPLACED EQUIVALENCE STATEMENTS WITH CRAY2IBM TO HANDLE
C                 THE CONVERSION BETWEEN CEMSCS AND CRAY.
C    VERSION- 3.1 ADDED ERSTAT TO CALL TO OLRDVR SO AS NOT TO CALCULATE
C                 OLR PARAMETERS IF OLR COEFFICIENTS ARE MISSING FROM CDB.
C    VERSION- 3.2 CHANGED FROM PROCESSING 9 SPOTS TO 4 SPOTS.  RENAMED THE
C                 CLOUD-CLEARED WORDS TO AMSU.  ADDED AMSU CH. 14 AND 15
C                 WORDS.  CHANGES THE NUMBER OF I*2 WRITTEN TO THE R1T. 
C    VERSION- 3.3 SINCE NEW VERSION OF R1T FORMAT HAS ALL HIRS AND AMSU-A
C                 CHANNELS IN IT, REMOVE /R1TSPR/, RDSPAR, AND FILSPR,
C                 SINCE SOFT-CODED SPARES ARE NO LONGER REQUIRED.
C    VERSION- 3.4 ADD CLOUD COMPARISON FLAG TO EACH SPOT ON R1T. 
C    VERSION- 3.5 ADDED THE TERRAIN FLAG TO SPARE 3.
C    VERSION- 3.6 THE LIMB CORRECTED HIRS DATA IS OBTAINED FROM THE
C                 HIRDAT ARRAY INSTEAD OF THE OBSHIR ARRAY.  THE OBSHIR
C                 ARRAY IS STILL USED TO OBTAIN THE NODE.
C    VERSION- 3.7 ADDED THE CALCULATION OF SUPERADIABATIC FLAG AT THE
C                 RETRIEVAL FOV FOR OUTPUT TO THE R1T.
C    VERSION- 3.8 ADDED THE HIRS LINE NUMBER TO THE ROTATING 1T
C    VERSION- 3.9 PACK HIRS FOV CLOUD MASK WITH HIRS SPOT NUMBER.
C    VERSION- 3.10 PACKED THE DAY/NIGHT FLAG  WITH HIRS LINE NUMBER
C                  AND PACKED THE CLEAR SKY OLR AND LC1-4 INTO THE
C                  LAST REMAINING SPARES ON THE ROTATING 1T.
C    VERSION- 3.11 CHANGED CLEAR-SKY PARAMETER MISSING VALUES TO 1000
C                  FOR PROPER DISPLAY IN EDGEIS, AND PASSED VARIABLES
C                  FOR TERRAIN HEIGHT CHECKING FOR LC1-3 TO OLRDVR.
C    VERSION- 3.12 EXPAND LIMTER TO 5 ELEMENTS TO ADD LC3/4 PRESSURE
C                  LIMIT CHECKS.
C    VERSION- 3.13 ADDED CODE TO INITIALIZE THE CLOUD PATH FROM THE
C                  CLOUD ALGORITHM PARAMETER AND THE CLOUD DIFFERENCE
C                  PARAMETER TO INTEGER MISSING (I2SPV) AND, TO COMPUTE
C                  THESE PARAMETERS ONLY IF THE CLOUD PRODUCTS ARE NOT
C                  MISSING. (WR#154)
C    VERSION- 3.14 THE CLEAR SKY VALUES ARE DEPENDENT ON THE ALLSKY VALUES
C                  FOR THE LAYER COOLING RATES HENCE THE CHECK OF HIGH TERRAIN
C                  USING 1000 HAD TO BE CHANGED TO 10000 TO MATCH THE CHANGES
C                  IN THE ROUTINE OLRDVR.F. (WR#170)
C    VERSION- 4.0  RESTRUCTURED THE ROTATING 1T. ADDED THE ATTENUATION
C                  CORRECTION, HIRS CH 8 SURFACE TEMPERATURE ESTIMATE,
C                  AND PREDICTED CLEAR HIRS TEMPERATURE FOR EACH SPOT.
C                  AN ADDITIONAL 7 SPARES WERE INCLUDED FOR EACH SPOT.
C                  OUTSIDE OF THE SPOT AREA, THE RETRIEVED WATER VAPOR
C                  AND THE RETRIEVAL PRECIP CONTAMINATION FLAG ARE NEW
C                  ADDED PARAMETERS AND, 10 SPARE WORDS WERE ALSO ADDED.
C                  (WR#186 AND 187)
C    VERSION- 4.1  TURNED ON THE ADDITION OF THE AMSU-B DATA TO THE R1T
C                  (WR#186 AND 187)
C    VERSION- 4.2  REMOVED INVERSION OF PRESSURE AND TEMPERATURE
C                  PROFILES AND CONVERSION FROM KELVIN TO CELSIUS
C                  BEFORE CALL TO CHKSUP. ADDED SURFACE MODEL LEVEL TO
C                  THE CALL TO CHKSUP (WR #215).
C    VERSION- 4.3  ADDED ARRAYS RDT8CA, RTD8MA, AND RCLODA (ALL OF
C                  LENGTH 4) TO THE CALLING ARGUMENTS TO BE WRITTEN
C                  OUT TO THE R1T (WR #210).
C    VERSION- 5.0  Removed CRAY2IBM calls. Replaced R4SPV equivalence
C                  test with ISR4SPV function.
C    VERSION- 5.1  CHANGED CLOUD AMOUNT OUTPUT TO PUT -777 FOR SPOTS
C                  WHERE THE QCFLAG FLAG IS OTHER THAN -1, 0, 2, OR 4.
C                  ADDED EXPERIMENTAL CLOUD AMOUNT OUTPUT FOR ALL
C                  QCFLAG FLAGS. PUT EXPERIMENTAL AMOUNT WHERE THE
C                  ORIGINAL CLOUD AMOUNT USED TO BE AND PUT THE
C                  ORIGINAL CLOUD AMOUNT WHERE A SPARE USED TO
C                  BE. ADDED BEGINNING ORBIT NUMBER TO WORD 360 OF THE
C                  OUTPUT RECORD (WR #257).
C    VERSION- 5.2  ADDED CODE TO READ ELLINGSON COEFFICIENTS INTO THE
C                  'ECOFS' ARRAY IN COMMON /CLIMATE/. 
C    VERSION- 5.3  CHANGED FROM 'WRTR1T' TO 'WRTR1T1248' UNDER WR #296
C                  TO WORK WITH A 1248-BYTE DSDR1T RECORD LENGTH.
C                  INCLUDED COMMON R1TDAT1248 IN PLACE OF R1TDAT.
C                  ADDED CODE TO WRITE OUT ADDITIONAL PARAMETERS TO
C                  THE OUTPUT FILE. ADDED ARGUMENT FOR CLOUD CLEARED
C                  HIRS BRIGHTNESS TEMPERATURES.
C    VERSION- 5.4  CHANGED NAME FROM WRTR1T1248 TO WRTR1T2000 AND
C                  CHANGED R1T RECORD LENGTH FROM 1248 TO 2000 BYTES.
C                  ADDED CODE TO WRITE THE GUESS TEMPERATURE AND MOISTURE
C                  PROFILES TO THE R1T RECORD.
C    VERSION- 5.5  CHANGED NAME FROM WRTR1T2000 TO WRTR1T2800 AND
C                  CHANGED R1T RECORD LENGTH FROM 2000 TO 2800 BYTES.
C
C    CALLING ARGUMENTS-
C      VARIABLE      TYPE   I/O   DESCRIPTION
C      --------      ----   ---   -----------
C      OBSHIR         R      I    HIRS DATA BUFFER DIMENSIONED
C                                 (HNSPOT,HTOTLN,20).  THIS STORES
C                                 OBSERVED, NONLIMB-CORRECTED DATA, AS
C                                 OPPOSED TO THE HIRDAT BUFFER WHICH AT
C                                 THIS POINT IN THE PROCESSING CONTAINS
C                                 LIMB-CORRECTED DATA.
C                                 THE 20TH ELEMENT IS THE NODE, WHERE
C                                 1 = ASCENDING AND 2 = DESCENDING.
C      BOX            INT    I    ARRAY (DIMENSION 2X2X2) HOLDING THE
C                                 HIRS SPOT AND LINE NUMBERS OF THE 3X3
C                                 BOX USED FOR THE RETRIEVAL. 
C      I,J            INT    I    INDICES CORRESPONDING TO THE SPOT
C                                 AND LINE BEING PROCESSED - USED TO
C                                 ACCESS THE RETRIEVAL DATA BUFFERS.
C      II,JJ          INT         INDICES OF THE HIRS SPOT AND LINE
C                                 NUMBERS CORRESPONDING TO THE RETRIEVAL
C                                 (I,J) INDICES.
C      R1T1ST         LOG   I/O   TRUE IF THIS IS THE FIRST TIME THIS
C                                 SUBROUTINE IS CALLED.
C      OLR,LC1-4      REAL  I/O   ARRAY (DIMENSIONED HNSPOT X HTOTLN)
C                                 STORING OUTGOING LONGWAVE RADIATION
C                                 AND 4 LAYER COOLING RATES.
C      QCFLAG         INT    I    ARRAY (DIMENSIONED 4) STORING
C                                 QUESTIONABLE FLAG.
C      NEWCH8         REAL        ARRAY (DIMENSIONED HNSPOT X HTOTLN)
C                                 STORING THE LIMB CORRECTED HIRS CHANNEL 8
C      PROFLV         REAL   I    THE 42 PROFILE LEVELS.
C      CLRTHRES       REAL   I    THRESHOLD USED TO DETERMINE HOW CLEAR
C                                 ARE THE CLEAR SKY RADIATION PARAMETERS
C      LIMTER(5)      REAL   I    TERRAIN HEIGHT LIMITS FOR LAYER COOLING 
C                                 RATES 1-3. READ FROM SOFTFLAGS BY CLDTOP.
C                                 ELEMENTS 4 & 5 ARE LC3/4 PRESSURE LIMITS.
C      A10U8(4)       REAL   I    ATTENUATION CORRECTION ABOVE THE CLOUDS OF
C                                 THE 4 SPOTS.
C      PREDTEMP(4)    REAL   I    THE PREDICTION CLEAR HIRS TEMPERATURE FROM
C                                 THE CLOUD COEFFICIENTS.
C      SURF8(4)       REAL   I    THE HIRS CHANNEL 8 SURFACE TEMPERATURE
C                                 ESTIMATE. 
C      RDT8CA(4)      REAL   I    PREDICTED CLEAR SURFACE TEMP (RADIANCE)
C      RDT8MA(4)      REAL   I    HIRS 8 SURFACE TEMP ESTIMATE (RADIANCE)
C      RCLODA(4)      REAL   I    CLOUD TOP TEMPERATURE (RADIANCE)
C      TCLOUD(4)      REAL   I    EFFECTIVE CLOUD AMOUNT (NOT CONSTRAINED TO
C                                 THE 0.0 TO 1.0 RANGE)
C      HBTCCL         REAL   I    CLOUD-CLEARED HIRS BRIGHTNESS TEMPERATURES
C      CONPCT         REAL   I    PERCENT CONTAMINATION FOR THE 19 HIRS CHANNELS 
C      RCCCTT         REAL   I    CLOUD-CLEARED CLOUD TOP TEMPERATURE IN RADIANCE
C      RCC8STE        REAL   I    CLOUD-CLEARED HIRS 8 SURFACE TEMPERATURE
C                                 ESTIMATE IN RADIANCE.
C      RCCPC8         REAL   I    CLOUD-CLEARED PREDICTED CLEAR HIRS 8 IN
C                                 RADIANCE.
C      CPERROR        REAL   I    CLOUD PRODUCT ERROR. THIS IS THE CLOUD
C                                 AMOUNT FROM CLOUD-CLEARED HIRS DATA.
c      aten4pc        real   I    Attenuation correction for predicted clear
c                                 for HIRS channels 2-8
c      BIASCOR        REAL   I    BIAS CORRECTION APPLIED TO CTT BEFORE MAKING
C                                 THE RCLOUD PARAMETER USED IN CLOUD AMOUNT
C                                 CALCULATION.
C      PRSTRO         REAL   I    TROPOPAUSE PRESSURE
C      TMPTRO         REAL   I    TROPOPAUSE TEMPERATURE
C      PC3T           REAL   I    ADJUSTED PREDICTED CLEAR HIRS CHANNEL 3
C      H3T            REAL   I    ADJUSTED OBSERVED HIRS CHANNEL 3
C      ATCH3T         REAL   I    ATTENUATION FOR CHANNEL 3T
C      DNCHAN          INT   I    LOWER PEAKING CHANNEL OF HIRS CHANNEL PAIRS
C                                 USED IN CLOUD TOP TEMPERATURE CALCULATION
C      TSFCOB         REAL   I    BIAS CORRECTED HIRS 8 SURFACE TEMPERATURE
C                                 ESTIMATE
C
C    COMMON AREA PARAMETERS- RETLVL, RETPARM, RMPARM, FRMINF, COLLOC,
C                            R1TDAT2800, CLOUDMSK,  SPGUNT, SPVAL
C
C    LOCAL VARIABLES-
C      VARIABLE      TYPE   DESCRIPTION
C      --------      ----   -----------
C      BEGORB        INT    LAST THREE DIGITS OF THE BEGINNING ORBIT NUMBER.
C      DSDR1T        I*2    ARRAY (DIM 1000) OF DSDR1T RECORD BUFFER.
C      R1TREC        INT    DSDR1T RECORD NUMBER BEING WRITTEN.
C      R1TMAX        INT    TOTAL NUMBER OF RECORDS ON DSDR1T.
C      K,L           INT    LOOP CONTROL VARIABLES OVER 2X2 BOX.
C      N, O          INT    LOOP CONTROL VARIABLES FOR READING IN ELLINGSON
C                           COEFFICIENTS.
C      II,JJ         INT    INDICES OF THE HIRS SPOT AND LINE NUMBERS
C                           CORRESPONDING TO THE RETRIEVAL (I,J) INDICES
C      ISPT          INT    SPOT (OF 2X2 BOX) BEING PROCESSED.
C      ILINE         INT    LINE (OF 2X2 BOX) BEING PROCESSED.
C      CLLAT/CLLONG  REAL   LAT/LONG OF RETRIEVAL LOCATION.
C      CLDCMP        INT    CLOUD COMPARISON FLAG (COMPARED TO HODF CLOUD
C                           MASK):
C                           CLEAR HODF VS. CLEAR CLOUD ALG   -> 0 (GOOD)
C                           CLEAR HODF VS. CLOUDY CLOUD ALG  -> 1 (BAD)
C                           CLOUDY HODF VS. CLOUDY CLOUD ALG -> 0 (GOOD)
C                           CLOUDY HODF VS. CLEAR CLOUD ALG  -> 2 (SO-SO)
C      CLDPPT        INT    CLEAR/CLOUDY FLAG (0=CLR,1=CLDY) FROM THE 
C                           CLOUD ALGORITHM
C      SMODLV        INT    SURFACE MODEL LEVEL.
C      ECOFSZ        REAL   VECTOR OF 5 ELLINGSON COEFFICIENTS FOR A
C                           GIVEN SATELLITE ZENITH ANGLE.
C      ECOF37        REAL   VECTOR OF 5 ELLINGSON COEFFICIENTS FROM POSITION
C                           37 (OF 73), AS CLOSE AS POSSIBLE TO NADIR.
C      HIROBS        REAL   VECTOR OF NON LIMB-CORRECTED HIRS BRIGHTNESS
C                           TEMPERATURES (CHANNELS 1-19) FOR A GIVEN
C                           HIRS SPOT.
C      ISATZN        INT    INTEGER VERSION OF SATELLITE ZENITH ANGLE.
C      START, LAST   INT    VALUES USED TO ENTER DATA INTO THE R1T BUFFER
C                           AFTER THE SPOT-RELATED ARRAYS ARE WRITTEN.
C 
C    SUBPROGRAMS CALLED- RDWRDS2800, ODBTIM
C
C    FUNCTIONS USED- PLKRAD, IPLKRD
C
C    EXIT STATES-
C
C***********************************************************************
C
           
      INCLUDE'RETPARM'
      INCLUDE'RTVPARM'
      INCLUDE'RTVGRD'
      INCLUDE'RMPARM'
      INCLUDE'RETLVL'
      INCLUDE'INSPARM'
      INCLUDE'INSCOM'
      INCLUDE'FRMINF'
      INCLUDE'COLLOC'
      INCLUDE'R1TDAT2800'
      INCLUDE'CLOUDMSK'
      INCLUDE'SPGUNT'
      INCLUDE'SPVAL'
      INCLUDE'ERPARM'
      INCLUDE'ERINFO'
      INCLUDE'CLIMATE'
C
      INTEGER   I,J,BOX(2,2,2),ISPT, ILINE, II, JJ, R1TREC, R1TMAX, NODE
      INTEGER   R1TLEN, STAT, K, L, SNDTIM(3), MILTIM, QCFLAG(4), IOERR
      INTEGER   ERSTAT, CLDCMP, CLDPPT
      INTEGER   M,KOUNT,SUPLVL,SUPFLG, IDUM, IWRD, ISSPOT,IBSP, BEGORB
      INTEGER   N,O,DNCHAN(4),CTPITER(4),PASSFAIL(4),NCH1GUESS(4)
      REAL   OBSHIR(HNSPOT,HTOTLN,35)
      REAL   OLR(HNSPOT,HTOTLN), LC1(HNSPOT,HTOTLN), DLR
      REAL   LC2(HNSPOT,HTOTLN), LC3(HNSPOT,HTOTLN)
      REAL   LC4(HNSPOT,HTOTLN), RNODE,NEWCH8(HNSPOT,HTOTLN)
      REAL   CLLAT, CLLONG
      REAL   INVDAT(PRFTLV), INVPRS(PRFTLV),PROFLV(PRFTLV)
      REAL   LIMTER(5), THEIGHT, CLRTHRES, AROSOL(4), CCHRAD(4,19)
      REAL   HBTCCL(4,19),CONPCT(4,19),RCCCTT(4),RCC8STE(4),RCCPC8(4)
      REAL   A10U8(4),PREDTEMP(4),SURF8(4), RDT8CA(4), RDT8MA(4)
      REAL   RCLODA(4), PLKRAD, TCLOUD(4), CPERROR(4), IPLKRD
      REAL   RTEMP, ECOFSZ(5), HIROBS(19),TCLEAR4(4,28), PREDTEM8(4)
      REAL   H8RAD(4),H8STER(4), RDTC8A(4), TCLR84(4,28), PCLRATN(4)
      REAL   BCORSTE(4),ATNPCLR(4),ATNPCL8(4)
      REAL   ATNCTT(4),BIASCOR(4),PRSTRO(4),TMPTRO(4)
      REAL   PC3T(4), H3T(4), ATCH3T(4), RADT8C8(4), RCBIAS(4),RADSTE(4)
      REAL   DELPRS8(4,19),LOGSFC(4),LOGCTP(4),LOGPEAK(4,19)
      REAL   DELPRS1(4),DELPRS2(4,19),DELPRS3(4,19),DELPRS4(4,19)
      real   PRSTRO2(4),tmptro2(4),CHNERRFIN(4,19),TSFCOB(4),CHNERRORIG(4,19)
      real   BCAPC(4,3),BCOPC(4,3), ECOF37(5), CCOLR, ECAORIG(4)
      REAL   OPDEPTH(4), RADT8CU(4), ATNPCLR8(4), BCATPCLR8(4)
      REAL   RADBCATPC8(4),PREDTEM8COR(4),LPINDX(4),RADCLR(4),DELPRESX(4)
      REAL   CC8STE(4),T_VALUE(4)

      LOGICAL   OLR1ST, R1T1ST, SUPER
      LOGICAL   ISR4SPV
      DATA      OLR1ST/.TRUE./
      PARAMETER (R1TLEN = 2800)
      INTEGER   IOSTAT, SMODLV, ISATZN, START, LAST
      INTEGER*2 DSDR1T(R1TLEN/2)
      SAVE ERSTAT, OLR1ST
C
C   INITIALIZE THE DSDR1T BUFFER TO MISSING VALUES (I2SPV)
C
      DO IWRD = 1,R1TLEN/2
         DSDR1T(IWRD) = I2SPV
      END DO
C
C   IF THE RETRIEVAL LOCATION SPOT NUMBER IS MISSING,
C   DO NOT WRITE ANYTHING TO THE DSDR1T.
C
      IF(RETANC(I,J,1).EQ.R4SPV) GO TO 1000
C
C   EXTRACT DSDR1T HOUSEKEEPING PARAMETERS.  THIS RECORD WAS READ
C   IN SPGDVR WHEN THE FILE WAS OPENED AND R1THKP IS IN /R1TDAT2800/.
C
         R1TMAX = R1THKP(2)
         R1TREC = R1THKP(3)

C
C   IF THIS IS THE FIRST CALL TO WRTR1T, READ THE DSDR1T HOUSEKEEPING
C   RECORD AND ANCILLARY FILES.
C
      IF(R1T1ST) THEN
         OLR1ST = .TRUE.
         ERSTAT = 0
C
C   READ ELLINGSON COEFFICIENTS USED IN OLR CALCULATION INTO COMMON
C   /CLIMATE/.
C
         DO N = 1, 73
            READ (105,*) (ECOFS(N,O),O=1,5)
         END DO
C
C   READ WORDS FILE INTO /R1TDAT2800/
C
         CALL RDWRDS2800(WRDUNT)
C
         R1T1ST = .FALSE.
         R1TORB = 0
         R1TCLEAR = 0
         R1TSPOTS = 0
         QCFLAG7 = 0
      END IF
C
C   WRITE INFORMATION TO DSDR1T BUFFER.  SINCE DSDR1T INFORMATION
C   IS SCALED TO FIT INTO AN I*2 FORMAT, ERROR CHECKING MUST OCCUR
C   FOR ANY SCALED PARAMETERS SO AS NOT TO CAUSE UNDERFLOW ERRORS
C   BY TRYING TO SCALE MISSING VALUES.
C
      DSDR1T(1) = R1THKP(1)
C
C   THE BEST SPOT IS THE RETRIEVAL LOCATION, SO GET THE LATITUDE AND
C   LONGITUDE OF THIS SPOT FROM THE HIRS ANCILLARY BUFFER. IF THIS
C   IS MISSING, DO NOT WRITE ANY INFORMATION TO THE DSDR1T.
C
      CLLAT = HIRANC(II,JJ,1)
      CLLONG = HIRANC(II,JJ,2)
      IF(CLLAT .EQ. R4SPV .OR. CLLONG.EQ.R4SPV) GO TO 1000
C
C
C   THE NODE IS TAKEN FROM THE OBSHIR BUFFER, ELEMENT 20.
C   RNODE = 1 MEANS ASCENDING, RNODE = 2 MEANS DESCENDING.
C   NODE 1 = NORTHERN HEMISPHERE DESCENDING
C   NODE 2 = SOUTHERN HEMISPHERE DESCENDING
C   NODE 3 = SOUTHERN HEMISPHERE ASCENDING
C   NODE 4 = NORTHERN HEMISPHERE ASCENDING
C
      RNODE = OBSHIR(II,JJ,20)
      NODE = 0
      IF(CLLAT.GE.0.0.AND.RNODE.EQ.1.0) NODE = 4
      IF(CLLAT.GE.0.0.AND.RNODE.EQ.2.0) NODE = 1
      IF(CLLAT.LT.0.0.AND.RNODE.EQ.1.0) NODE = 3
      IF(CLLAT.LT.0.0.AND.RNODE.EQ.2.0) NODE = 2
      DSDR1T(2) = NODE
C
C   GET THE TIME BASED ON THE MILLISECOND TIME STORED IN COMMON
C
      MILTIM = HSCTIM(2,JJ) + ((II-1)*HIRTIM(2)) + HIRTIM(2)
      CALL ODBTIM(HSCTIM(1,JJ),MILTIM,SNDTIM)
      DSDR1T(4) = SNDTIM(1)
      DSDR1T(5) = SNDTIM(2)
      DSDR1T(6) = SNDTIM(3)
C
C
C   DETERMINE SUPERADIABATIC CONDITION (1=SUPER
C   2=NOT SUPER). 
C   WORD 8 IS FILLED WITH THE SUPERADIABATIC FLAG
C
      SUPER = .FALSE.
      SUPLVL= I4SPV
      DO M = 1, PRFTLV
         INVDAT(M) = RETDAT(I,J,M)
      END DO

      SMODLV = NINT(RETANC(I,J,7))
      CALL CHKSUP(PRFTLV,PROFLV,INVDAT,SUPER,SUPLVL,SMODLV)
      SUPFLG = 0
      IF(SUPER) SUPFLG=1
C
C   WORD 8 IS FILLED WITH THE SUPERADIABATIC FLAG
C
       DSDR1T(8) = SUPFLG

C
C   CONVERT RETRIEVAL FLAG TO TOVS TARM PATH
C
      IF(RETANC(I,J,4).EQ.0)  DSDR1T(9) = 111
      IF(RETANC(I,J,4).EQ.16) DSDR1T(9) = 211
      IF(RETANC(I,J,4).EQ.32) DSDR1T(9) = 221
C
C   INITIALIZE COUNTERS AND VARIABLES
C
      ISSPOT = 0
      IBSP = 0
C
C   WRITE INFORMATION TO DSDR1T BUFFER FROM ALL 4 SPOTS
C

      DO 400 K=1,2
         DO 300 L=1,2
            ISSPOT = ISSPOT + 1
            R1TSPOTS = R1TSPOTS + 1
            ISPT = BOX(K,L,1)
            ILINE = BOX(K,L,2)

C-- Write the Aerosol amount to the R1T. Leave it as missing
C   IF the corresponding cloud top pressure is missing.

            DSDR1T(AEROWRD(ISSPOT)) = 0
            DSDR1T(S154WD(ISSPOT)) = 0
            DSDR1T(S155WD(ISSPOT)) = 0
            DSDR1T(S156WD(ISSPOT)) = 0
            IF(.NOT. ISR4SPV(HIRANC(ISPT,ILINE,15))) THEN
               IF (AROSOL(ISSPOT).NE.R4SPV) THEN
                  DSDR1T(AEROWRD(ISSPOT)) = NINT(AROSOL(ISSPOT) * 1000.0)
c                   Aerosol CTP
                  DSDR1T(S154WD(ISSPOT)) = NINT(HIRANC(ISPT,ILINE,15))
c                   Aerosol CTT
                  DSDR1T(S155WD(ISSPOT)) = NINT(HIRANC(ISPT,ILINE,18) * 64.0)
C                   Aerosol CPE
                  DSDR1T(S156WD(ISSPOT)) = NINT(CPERROR(ISSPOT) * 1000.0)
               END IF
            END IF

c           IF (AROSOL(ISSPOT).EQ.R4SPV) THEN
c              DSDR1T(AEROWRD(ISSPOT)) = I2SPV
c           END IF

C   THE HIRS CHANNEL 20 ALBEDO IS STORED IN THE HIRDAT BUFFER.
C
            IF (HIRDAT(ISPT,ILINE,20).NE.R4SPV) THEN
               DSDR1T(7) = NINT(HIRDAT(ISPT,ILINE,20)*100.0)
C-- SET THE HIRS CHANNEL 20 ALBEDO TO ZERO FOR NIGHT TIME.

               IF (HIRANC(ISPT,ILINE,3).GT.90.5) THEN
                  DSDR1T(7) = 0
               END IF
            END IF


C Write the Surface Temperature Estimate Radiance before bias correction and
C the CLW adjusted predicted clear radiance before bias correction.
C
            IF (RADSTE(ISSPOT).NE.R4SPV) THEN
               DSDR1T(S157WD(ISSPOT)) = NINT(RADSTE(ISSPOT) * 64.0)
            END IF
            IF (RADT8CU(ISSPOT).NE.R4SPV) THEN
               DSDR1T(S158WD(ISSPOT)) = NINT(RADT8CU(ISSPOT) * 64.0)
            END IF

C Write out the Attenuation Corrected CLW adjusted Predicted Clear HIRS 8 temperature 
C
            IF (ATNPCLR8(ISSPOT).NE.R4SPV) THEN
               DSDR1T(S159WD(ISSPOT)) = NINT(ATNPCLR8(ISSPOT) * 64.0)
            END IF

C Write out the Bias Corrected Attenuation Corrected CLW adjusted Predicted Clear
C HIRS 8 temperature

            IF(BCATPCLR8(ISSPOT).NE.R4SPV) THEN
               DSDR1T(S160WD(ISSPOT)) = NINT(BCATPCLR8(ISSPOT) * 64.0)
            END IF

C Write out the Radiance for the Bias Corrected Attenuation Corrected CLW adjusted
C Predicted Clear HIRS 8 temperature.
c
            IF (RADBCATPC8(ISSPOT).NE.R4SPV) THEN
               DSDR1T(S161WD(ISSPOT)) = NINT(RADBCATPC8(ISSPOT) * 64.0)
            END IF
C Write out the radiance for the Unadjusted Predicted Clear
C
            IF (RADT8C8(ISSPOT).NE.R4SPV) THEN
               DSDR1T(S162WD(ISSPOT)) = NINT(RADT8C8(ISSPOT) * 64.0) 
               IF (dsdr1t(S162WD(ISSPOT)).LE.0.0) THEN
                  print *,'WRTR1T2800: RADT8C8(',ISSPOT,') = ',RADT8C8(ISSPOT)
               END IF
            END IF
C
C-- Write the observed HIRS 8 radiance to the R1T.
c
            IF (H8RAD(ISSPOT).NE.R4SPV) THEN
               DSDR1T(H8RWRD(ISSPOT)) = NINT(H8RAD(ISSPOT) * 64.0)
            END IF
C
C-- Write out the non-adjusted HIRS 8 Surface
C   Temperature Estimate radiance to the R1T.
C
            IF (H8STER(ISSPOT).NE.R4SPV) THEN
               DSDR1T(H8OSTEWRD(ISSPOT)) = NINT(H8STER(ISSPOT) * 64.0)
            END IF

C
C   IF THE HIRS CHANNEL 8 VALUES EXCEEDS 350.0 OR IS MISSING, DO NOT
C   WRITE ANY INFORMATION FOR THIS SPOT.
C
            IF(ISR4SPV(HIRDAT(ISPT,ILINE,8)) .OR.
     1         HIRDAT(ISPT,ILINE,8).GE.350.) GO TO 300

            IF(ISR4SPV(NEWCH8(ISPT,ILINE))) GO TO 300

C
C   STORE LATITUDE AND LONGITUDE, AND CHECK TO SEE IF THIS SPOT IS
C   THE BEST SPOT.  IF THESE VALUES ARE MISSING, GO TO THE NEXT SPOT.
C  

            IF(ISR4SPV(HIRANC(ISPT,ILINE,1)) .OR.
     1         ISR4SPV(HIRANC(ISPT,ILINE,2))) GO TO 300
C
            DSDR1T(LATWRD(ISSPOT)) = NINT(HIRANC(ISPT,ILINE,1)*128.0)
            DSDR1T(LONWRD(ISSPOT)) = NINT(HIRANC(ISPT,ILINE,2)*128.0)
            IF(HIRANC(ISPT,ILINE,1).EQ.CLLAT.AND.
     1         HIRANC(ISPT,ILINE,2).EQ.CLLONG) IBSP = ISSPOT

C 
C   SET SATELLITE ZENITH ANGLE.
C
c           IF(.NOT. ISR4SPV(HIRANC(ISPT,ILINE,5)))
c    1         DSDR1T(SZAWRD(ISSPOT)) = NINT(HIRANC(ISPT,ILINE,5)*128.0)
C   store the pass/fail flag
            DSDR1T(SZAWRD(ISSPOT)) = PASSFAIL(ISSPOT)
            HIRANC(ISPT,ILINE,48) = PASSFAIL(ISSPOT)
C
C   FILL CLOUD PARAMETER WORDS.
C
C        EFFECTIVE CLOUD AMOUNT. Leave it as missing IF the
C        corresponding Cloud Top Pressure is missing.
C
            IF(.NOT. ISR4SPV(HIRANC(ISPT,ILINE,15))) THEN
               IF (.NOT. ISR4SPV(TCLOUD(ISSPOT))) THEN
                  DSDR1T(ECAWRD(ISSPOT)) = NINT(TCLOUD(ISSPOT)*1000.0)
                  IF (TCLOUD(ISSPOT).EQ.0.0) R1TCLEAR = R1TCLEAR + 1
               ELSE
                  DSDR1T(ECAWRD(ISSPOT)) = I2SPV
               END IF
            END IF
C
C   Original Cloud Amount
C
c           IF (.NOT. ISR4SPV(ECAORIG(ISSPOT))) THEN
c              DSDR1T(SP96WD(ISSPOT)) = NINT(ECAORIG(ISSPOT) * 1000.0)
c           END IF
c   Replaced with Aerosol Optical Depth 5 March 2013
c
            IF (.NOT. ISR4SPV(OPDEPTH(ISSPOT))) THEN
               DSDR1T(SP96WD(ISSPOT)) = NINT(OPDEPTH(ISSPOT) * 1000.0)
            END IF

C
C        CLOUD-CLEARED CLOUD TOP TEMPERATURE RADIANCE.
C
            IF (.NOT. ISR4SPV(RCCCTT(ISSPOT))) THEN
               DSDR1T(CCCTTR(ISSPOT)) = NINT(RCCCTT(ISSPOT) * 64.0)
            END IF
C        CLOUD-CLEARED HIRS 8 SURFACE TEMPERATURE ESTIMATE RADIANCE
C
            CC8STE(ISSPOT) = R4SPV
            IF (.NOT. ISR4SPV(RCC8STE(ISSPOT))) THEN
               DSDR1T(CC8STER(ISSPOT)) = NINT(RCC8STE(ISSPOT) * 64.0)
               CC8STE(ISSPOT) = IPLKRD(RCC8STE(ISSPOT),8)
            END IF
C        CLOUD-CLEARED PREDICTED CLEAR HIRS 8 RADIANCE
C
c           IF (.NOT. ISR4SPV(RCCPC8(ISSPOT))) THEN
c              DSDR1T(CC8PCR(ISSPOT)) = NINT(RCCPC8(ISSPOT) * 64.0)
c           END IF 
ccft ATTENUATION CORRECTION FOR UNADJUSTED PREDICTED CLEAR.
ccft
c           IF (.NOT. ISR4SPV(ATNPCL8(ISSPOT))) THEN
c              DSDR1T(CC8PCR(ISSPOT)) = NINT(ATNPCL8(ISSPOT) * 64.0)
c           END IF 
C
C 
c           IF (ATNPCLR(ISSPOT).NE.R4SPV) THEN
c              DSDR1T(CAXWRD(ISSPOT)) = NINT(ATNPCLR(ISSPOT) * 64.0)
c           END IF
C-- Replace attenuation correction for adjusted predicted clear with
C   the channel number of the lower peaking channel:  9 July 2010
c
            IF (DNCHAN(ISSPOT).NE.I2SPV) THEN
               DSDR1T(CAXWRD(ISSPOT)) = DNCHAN(ISSPOT)
            END IF

C        CLOUD AMOUNT
C
            IF(.NOT. ISR4SPV(HIRANC(ISPT,ILINE,19))) THEN
C         EXPERIMENTAL CLOUD AMOUNT
C
               DSDR1T(CLAWRD(ISSPOT)) = NINT(HIRANC(ISPT,ILINE,19)*1000.0)
C         CLOUD PRODUCT ERROR.
C
               IF (CPERROR(ISSPOT).NE.R4SPV) THEN
                  DSDR1T(CPEWRD(ISSPOT)) = NINT(CPERROR(ISSPOT) * 1000.0)
               END IF
C
C              Store the percent Cloud Product Error
C                 HIRS 2
               IF (CHNERRFIN(ISSPOT,2).NE.R4SPV) THEN
                  DSDR1T(SP90WD(ISSPOT)) = NINT(CHNERRFIN(ISSPOT,2) * 100.0)
               END IF
C                 HIRS 3
               IF (CHNERRFIN(ISSPOT,3).NE.R4SPV) THEN
                  DSDR1T(SP91WD(ISSPOT)) = NINT(CHNERRFIN(ISSPOT,3) * 100.0)
               END IF
C                 HIRS 4
               IF (CHNERRFIN(ISSPOT,4).NE.R4SPV) THEN
                  DSDR1T(SP92WD(ISSPOT)) = NINT(CHNERRFIN(ISSPOT,4) * 100.0)
               END IF
C                 HIRS 5
               IF (CHNERRFIN(ISSPOT,5).NE.R4SPV) THEN
                  DSDR1T(SP93WD(ISSPOT)) = NINT(CHNERRFIN(ISSPOT,5) * 100.0)
               END IF
C                 HIRS 6
               IF (CHNERRFIN(ISSPOT,6).NE.R4SPV) THEN
                  DSDR1T(SP94WD(ISSPOT)) = NINT(CHNERRFIN(ISSPOT,6) * 100.0)
               END IF
C                 HIRS 7
               IF (CHNERRFIN(ISSPOT,7).NE.R4SPV) THEN
                  DSDR1T(SP95WD(ISSPOT)) = NINT(CHNERRFIN(ISSPOT,7) * 100.0)
               END IF
C                 HIRS 8
               IF (CHNERRFIN(ISSPOT,8).NE.R4SPV) THEN
                  DSDR1T(SP87WD(ISSPOT)) = NINT(CHNERRFIN(ISSPOT,8) * 100.0)
               END IF
C                 HIRS 10
               IF (CHNERRFIN(ISSPOT,10).NE.R4SPV) THEN
                  DSDR1T(SP98WD(ISSPOT)) = NINT(CHNERRFIN(ISSPOT,10) * 100.0)
               END IF
C                 HIRS 11
               IF (CHNERRFIN(ISSPOT,11).NE.R4SPV) THEN
                  DSDR1T(SP99WD(ISSPOT)) = NINT(CHNERRFIN(ISSPOT,11) * 100.0)
               END IF
C                 HIRS 12
               IF (CHNERRFIN(ISSPOT,12).NE.R4SPV) THEN
                  DSDR1T(S100WD(ISSPOT)) = NINT(CHNERRFIN(ISSPOT,12) * 100.0)
               END IF

            END IF
C
C        BIAS CORRECTED HIRS 8 SURFACE TEMPERATURE ESTIMATE
C
            IF (TSFCOB(ISSPOT).NE.R4SPV) THEN
               DSDR1T(SP88WD(ISSPOT)) = NINT(TSFCOB(ISSPOT) * 64.0)
            END IF
              
C
C        CLOUD TOP PRESSURE
C
            IF(.NOT. ISR4SPV(HIRANC(ISPT,ILINE,15))) THEN
               DSDR1T(CTPWRD(ISSPOT)) = NINT(HIRANC(ISPT,ILINE,15))
            END IF
C
C        CLOUD TOP TEMPERATURE (KELVIN)
C
C           IF(.NOT. ISR4SPV(HIRANC(ISPT,ILINE,18))) THEN
            IF(HIRANC(ISPT,ILINE,18).GE.0.0) THEN
              DSDR1T(CTTWRD(ISSPOT)) = NINT(HIRANC(ISPT,ILINE,18)*64.0)
            END IF
            IF (QCFLAG(ISSPOT).EQ.I2SPV) THEN
              DSDR1T(CTTWRD(ISSPOT)) = I2SPV
              DSDR1T(ECAWRD(ISSPOT)) = I2SPV
            END IF
C
C        CLOUD TOP TEMPERATURE (RADIANCE)
C
            IF(.NOT. ISR4SPV(RCLODA(ISSPOT))) THEN
               DSDR1T(RCDWRD(ISSPOT)) = NINT(RCLODA(ISSPOT)*64.0)
            END IF
C
C  IF CLOUD PARAMETERS ARE SET TO R4SPV, FILL DSDR1T WITH I2SPV
C
            IF(HIRANC(ISPT,ILINE,19).EQ. R4SPV)
     1         DSDR1T(CLAWRD(ISSPOT)) = I2SPV
            IF(HIRANC(ISPT,ILINE,15).EQ. R4SPV)
     1         DSDR1T(CTPWRD(ISSPOT)) = I2SPV
            IF(HIRANC(ISPT,ILINE,18).EQ. R4SPV)
     1        DSDR1T(CTTWRD(ISSPOT)) = I2SPV
C
C   FILL OBSERVED HIRS CHANNEL BRIGHTNESS TEMPERATURE WORDS
C
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,1)))
     1         DSDR1T(CH1WRD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,1)*64.)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,2)))
     1         DSDR1T(CH2WRD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,2)*64.)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,3)))
     1         DSDR1T(CH3WRD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,3)*64.)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,4)))
     1         DSDR1T(CH4WRD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,4)*64.)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,5)))
     1         DSDR1T(CH5WRD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,5)*64.)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,6)))
     1         DSDR1T(CH6WRD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,6)*64.)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,7)))
     1         DSDR1T(CH7WRD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,7)*64.)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,8)))
     1         DSDR1T(CH8WRD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,8)*64.)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,9)))
     1         DSDR1T(CH9WRD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,9)*64.)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,10)))
     1         DSDR1T(C10WRD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,10)*64.)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,11)))
     1         DSDR1T(C11WRD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,11)*64.)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,12)))
     1         DSDR1T(C12WRD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,12)*64.)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,13)))
     1         DSDR1T(C13WRD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,13)*64.)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,14)))
     1         DSDR1T(C14WRD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,14)*64.)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,15)))
     1         DSDR1T(C15WRD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,15)*64.)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,16)))
     1         DSDR1T(C16WRD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,16)*64.)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,17)))
     1         DSDR1T(C17WRD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,17)*64.)
            IF(.NOT. ISR4SPV(LOGSFC(ISSPOT)))
     1         DSDR1T(SP21WD(ISSPOT)) = NINT(LOGSFC(ISSPOT) * 100.0)
            IF(.NOT. ISR4SPV(LOGCTP(ISSPOT)))
     1         DSDR1T(SP22WD(ISSPOT)) = NINT(LOGCTP(ISSPOT) * 100.0)
            DSDR1T(SP23WD(ISSPOT)) = CTPITER(ISSPOT)
            IF(.NOT. ISR4SPV(LOGPEAK(ISSPOT,3)))
     1         DSDR1T(SP37WD(ISSPOT)) = NINT(LOGPEAK(ISSPOT,3) * 100.0)
            IF(.NOT. ISR4SPV(LOGPEAK(ISSPOT,4)))
     1         DSDR1T(SP38WD(ISSPOT)) = NINT(LOGPEAK(ISSPOT,4) * 100.0)
            IF(.NOT. ISR4SPV(LOGPEAK(ISSPOT,5)))
     1         DSDR1T(SP39WD(ISSPOT)) = NINT(LOGPEAK(ISSPOT,5) * 100.0)
            IF(.NOT. ISR4SPV(LOGPEAK(ISSPOT,6)))
     1         DSDR1T(SP40WD(ISSPOT)) = NINT(LOGPEAK(ISSPOT,6) * 100.0)
            IF(.NOT. ISR4SPV(LOGPEAK(ISSPOT,7)))
     1         DSDR1T(SP41WD(ISSPOT)) = NINT(LOGPEAK(ISSPOT,7) * 100.0)
            IF(.NOT. ISR4SPV(LOGPEAK(ISSPOT,8)))
     1         DSDR1T(SP42WD(ISSPOT)) = NINT(LOGPEAK(ISSPOT,8) * 100.0)
            IF(.NOT. ISR4SPV(PRSTRO(ISSPOT))) THEN
               DSDR1T(SP24WD(ISSPOT)) = NINT(PRSTRO(ISSPOT))
               DSDR1T(SP84WD(ISSPOT)) = NINT(ALOG(PRSTRO(ISSPOT)) * 100.0)
            END IF
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,18)))
     1         DSDR1T(C18WRD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,18)*64.)
            IF(.NOT. ISR4SPV(TMPTRO(ISSPOT)))
     1         DSDR1T(SP25WD(ISSPOT)) = NINT(TMPTRO(ISSPOT) * 64.0)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,19)))
     1         DSDR1T(C19WRD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,19)*64.)

C
C   Temporarily store tropopause pressure and temperature from
C   alternate calculation.
c
            IF (PRSTRO2(ISSPOT).NE.R4SPV)
     1         DSDR1T(SP85WD(ISSPOT)) = NINT(PRSTRO2(ISSPOT))
            IF (TMPTRO2(ISSPOT).NE.R4SPV)
     1         DSDR1T(SP86WD(ISSPOT)) = NINT(TMPTRO2(ISSPOT) * 64.0)

               
C
C   FILL CLOUD-CLEARED HIRS CHANNEL BRIGHTNESS TEMPERATURE WORDS
C
            IF(.NOT. ISR4SPV(HBTCCL(ISSPOT,1)))
     1         DSDR1T(CCH1WRD(ISSPOT)) = NINT(HBTCCL(ISSPOT,1) * 64.0)
            IF(.NOT. ISR4SPV(HBTCCL(ISSPOT,2)))
     1         DSDR1T(CCH2WRD(ISSPOT)) = NINT(HBTCCL(ISSPOT,2) * 64.0)
            IF(.NOT. ISR4SPV(HBTCCL(ISSPOT,3)))
     1         DSDR1T(CCH3WRD(ISSPOT)) = NINT(HBTCCL(ISSPOT,3) * 64.0)
            IF(.NOT. ISR4SPV(HBTCCL(ISSPOT,4)))
     1         DSDR1T(CCH4WRD(ISSPOT)) = NINT(HBTCCL(ISSPOT,4) * 64.0)
            IF(.NOT. ISR4SPV(HBTCCL(ISSPOT,5)))
     1         DSDR1T(CCH5WRD(ISSPOT)) = NINT(HBTCCL(ISSPOT,5) * 64.0)
            IF(.NOT. ISR4SPV(HBTCCL(ISSPOT,6)))
     1         DSDR1T(CCH6WRD(ISSPOT)) = NINT(HBTCCL(ISSPOT,6) * 64.0)
            IF(.NOT. ISR4SPV(HBTCCL(ISSPOT,7)))
     1         DSDR1T(CCH7WRD(ISSPOT)) = NINT(HBTCCL(ISSPOT,7) * 64.0)
            IF(.NOT. ISR4SPV(HBTCCL(ISSPOT,8))) 
     1         DSDR1T(CCH8WRD(ISSPOT)) = NINT(HBTCCL(ISSPOT,8) * 64.0)
            IF(.NOT. ISR4SPV(HBTCCL(ISSPOT,9)))
     1         DSDR1T(CCH9WRD(ISSPOT)) = NINT(HBTCCL(ISSPOT,9) * 64.0)
            IF(.NOT. ISR4SPV(HBTCCL(ISSPOT,10)))
     1         DSDR1T(CCH10WRD(ISSPOT)) = NINT(HBTCCL(ISSPOT,10) * 64.0)
            IF(.NOT. ISR4SPV(HBTCCL(ISSPOT,11)))
     1         DSDR1T(CCH11WRD(ISSPOT)) = NINT(HBTCCL(ISSPOT,11) * 64.0)
            IF(.NOT. ISR4SPV(HBTCCL(ISSPOT,12)))
     1         DSDR1T(CCH12WRD(ISSPOT)) = NINT(HBTCCL(ISSPOT,12) * 64.0)
            IF(.NOT. ISR4SPV(HBTCCL(ISSPOT,13)))
     1         DSDR1T(S101WD(ISSPOT)) = NINT(HBTCCL(ISSPOT,13) * 64.0)
            IF(.NOT. ISR4SPV(HBTCCL(ISSPOT,14)))
     1         DSDR1T(S102WD(ISSPOT)) = NINT(HBTCCL(ISSPOT,14) * 64.0)
            IF(.NOT. ISR4SPV(HBTCCL(ISSPOT,15)))
     1         DSDR1T(S103WD(ISSPOT)) = NINT(HBTCCL(ISSPOT,15) * 64.0)
            IF(.NOT. ISR4SPV(HBTCCL(ISSPOT,16)))
     1         DSDR1T(S104WD(ISSPOT)) = NINT(HBTCCL(ISSPOT,16) * 64.0)
            IF(.NOT. ISR4SPV(HBTCCL(ISSPOT,17)))
     1         DSDR1T(S105WD(ISSPOT)) = NINT(HBTCCL(ISSPOT,17) * 64.0)
            IF(.NOT. ISR4SPV(HBTCCL(ISSPOT,18)))
     1         DSDR1T(S106WD(ISSPOT)) = NINT(HBTCCL(ISSPOT,18) * 64.0)
            IF(.NOT. ISR4SPV(HBTCCL(ISSPOT,19)))
     1         DSDR1T(S107WD(ISSPOT)) = NINT(HBTCCL(ISSPOT,19) * 64.0)
C
c           IF(.NOT. ISR4SPV(HBTCCL(ISSPOT,13)))
c    1         DSDR1T(CCH13WRD(ISSPOT)) = NINT(HBTCCL(ISSPOT,13) * 64.0)
C  PRECIP ADJUSTED MHS 3
c           IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,173)))
c    1         DSDR1T(CCH13WRD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,173) * 64.0)
c           IF(.NOT. ISR4SPV(HBTCCL(ISSPOT,14)))
c    1         DSDR1T(CCH14WRD(ISSPOT)) = NINT(HBTCCL(ISSPOT,14) * 64.0)
C  PREDICTED CLEAR HIRS 12
c           IF(.NOT. ISR4SPV(TCLEAR4(ISSPOT,12)))
c    1         DSDR1T(CCH14WRD(ISSPOT)) = NINT(TCLEAR4(ISSPOT,12) * 64.0)
c           IF(.NOT. ISR4SPV(HBTCCL(ISSPOT,15)))
c    1         DSDR1T(CCH15WRD(ISSPOT)) = NINT(HBTCCL(ISSPOT,15)* 64.0)
C  RADIANCE ERROR HIRS CHANNEL 12
c           IF(.NOT. ISR4SPV(CHNERRFIN(ISSPOT,12)))
c    1         DSDR1T(CCH15WRD(ISSPOT)) = NINT(CHNERRFIN(ISSPOT,12) * 100.0)
C  BIAS CORRECTION FOR SURFACE TEMPERATURE ESTIMATE
            IF (BCORSTE(ISSPOT).NE.R4SPV) 
     1         DSDR1T(SP33WD(ISSPOT)) = NINT(BCORSTE(ISSPOT) * 64.0)
c           IF(.NOT. ISR4SPV(HBTCCL(ISSPOT,16)))
c    1         DSDR1T(CCH16WRD(ISSPOT)) = NINT(HBTCCL(ISSPOT,16) * 64.0)
c           IF(.NOT. ISR4SPV(HBTCCL(ISSPOT,17)))
c    1         DSDR1T(CCH17WRD(ISSPOT)) = NINT(HBTCCL(ISSPOT,17) * 64.0)
c           IF(DNCHAN(ISSPOT).NE.I2SPV)
c    1         DSDR1T(SP34WD(ISSPOT)) = DNCHAN(ISSPOT)
c           IF(.NOT. ISR4SPV(HBTCCL(ISSPOT,18)))
c    1         DSDR1T(CCH18WRD(ISSPOT)) = NINT(HBTCCL(ISSPOT,18) * 64.0)
c           IF(.NOT. ISR4SPV(RADT8C8(ISSPOT)))
c    1         DSDR1T(SP35WD(ISSPOT)) = NINT(RADT8C8(ISSPOT) * 64.0)
c           IF(.NOT. ISR4SPV(HBTCCL(ISSPOT,19)))
c    1         DSDR1T(CCH19WRD(ISSPOT)) = NINT(HBTCCL(ISSPOT,19) * 64.0)
C
C Replace CCHIRS BTs for HIRS channels 13-19 with Original Channel
C Error values for HIRS channels 4-8, 10 and 11.
C
            IF(.NOT. ISR4SPV(CHNERRORIG(ISSPOT,4)))
     1         DSDR1T(CCH13WRD(ISSPOT)) = NINT(CHNERRORIG(ISSPOT,4) * 100.0)
            IF(.NOT. ISR4SPV(CHNERRORIG(ISSPOT,5)))
     1         DSDR1T(CCH14WRD(ISSPOT)) = NINT(CHNERRORIG(ISSPOT,5) * 100.0)
            IF(.NOT. ISR4SPV(CHNERRORIG(ISSPOT,6)))
     1         DSDR1T(CCH15WRD(ISSPOT)) = NINT(CHNERRORIG(ISSPOT,6) * 100.0)
            IF(.NOT. ISR4SPV(CHNERRORIG(ISSPOT,7)))
     1         DSDR1T(CCH16WRD(ISSPOT)) = NINT(CHNERRORIG(ISSPOT,7) * 100.0)
            IF(.NOT. ISR4SPV(CHNERRORIG(ISSPOT,8)))
     1         DSDR1T(CCH17WRD(ISSPOT)) = NINT(CHNERRORIG(ISSPOT,8) * 100.0)
            IF(.NOT. ISR4SPV(CHNERRORIG(ISSPOT,10)))
     1         DSDR1T(CCH18WRD(ISSPOT)) = NINT(CHNERRORIG(ISSPOT,10) * 100.0)
            IF(.NOT. ISR4SPV(CHNERRORIG(ISSPOT,11)))
     1         DSDR1T(CCH19WRD(ISSPOT)) = NINT(CHNERRORIG(ISSPOT,11) * 100.0)
C
c    STORE THE PRECIPITATION ADJUSTED AMSU-A CHANNELS 1 AND 4-8, THE
C    PRECIPITATION INDEX, AND THE CLOUD LIQUID WATER
C
            IF (.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,194)))
     1         DSDR1T(S153WD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,194) * 64.0)
            IF (.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,154)))
     1         DSDR1T(SP1WRD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,154) * 64.0)
            IF (.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,155)))
     1         DSDR1T(SP2WRD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,155) * 64.0)
            IF (.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,156)))
     1         DSDR1T(SP3WRD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,156) * 64.0)
            IF (.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,157)))
     1         DSDR1T(SP4WRD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,157) * 64.0)
            IF (.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,158)))
     1         DSDR1T(CC8PCR(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,158) * 64.0)
            IF (.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,149)))
     1         DSDR1T(SP5WRD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,149) * 100.0)
C
C    STORE THE ADJUSTED PREDICTED CLEAR BRIGHTNESS TEMPERATURES FOR HIRS
C    CHANNELS 2-8
C

            IF (TCLEAR4(ISSPOT,2) .NE. R4SPV)
     1         DSDR1T(SP6WRD(ISSPOT)) = NINT(TCLEAR4(ISSPOT,2) * 64.0)
            IF (TCLEAR4(ISSPOT,3) .NE. R4SPV)
     1         DSDR1T(SP7WRD(ISSPOT)) = NINT(TCLEAR4(ISSPOT,3) * 64.0)
            IF (TCLEAR4(ISSPOT,4) .NE. R4SPV)
     1         DSDR1T(SP8WRD(ISSPOT)) = NINT(TCLEAR4(ISSPOT,4) * 64.0)
            IF (TCLEAR4(ISSPOT,5) .NE. R4SPV)
     1         DSDR1T(SP9WRD(ISSPOT)) = NINT(TCLEAR4(ISSPOT,5) * 64.0)
            IF (TCLEAR4(ISSPOT,6) .NE. R4SPV)
     1         DSDR1T(SP10WD(ISSPOT)) = NINT(TCLEAR4(ISSPOT,6) * 64.0)
            IF (TCLEAR4(ISSPOT,7) .NE. R4SPV)
     1         DSDR1T(SP11WD(ISSPOT)) = NINT(TCLEAR4(ISSPOT,7) * 64.0)
            IF (TCLEAR4(ISSPOT,8) .NE. R4SPV)
     1         DSDR1T(SP12WD(ISSPOT)) = NINT(TCLEAR4(ISSPOT,8) * 64.0)
C
C    STORE THE UNADJUSTED PREDICTED CLEAR BRIGHTNESS TEMPERATURES FOR HIRS
C    CHANNELS 2-8
C
            IF (.NOT. ISR4SPV(TCLR84(ISSPOT,2)))
     1         DSDR1T(SP13WD(ISSPOT)) = NINT(TCLR84(ISSPOT,2) * 64.0)
            IF (.NOT. ISR4SPV(TCLR84(ISSPOT,3)))
     1         DSDR1T(SP14WD(ISSPOT)) = NINT(TCLR84(ISSPOT,3) * 64.0)
            IF (.NOT. ISR4SPV(TCLR84(ISSPOT,4)))
     1         DSDR1T(SP15WD(ISSPOT)) = NINT(TCLR84(ISSPOT,4) * 64.0)
            IF (.NOT. ISR4SPV(TCLR84(ISSPOT,5)))
     1         DSDR1T(SP16WD(ISSPOT)) = NINT(TCLR84(ISSPOT,5) * 64.0)
            IF (.NOT. ISR4SPV(TCLR84(ISSPOT,6)))
     1         DSDR1T(SP17WD(ISSPOT)) = NINT(TCLR84(ISSPOT,6) * 64.0)
            IF (.NOT. ISR4SPV(TCLR84(ISSPOT,7)))
     1         DSDR1T(SP18WD(ISSPOT)) = NINT(TCLR84(ISSPOT,7) * 64.0)
            IF (.NOT. ISR4SPV(TCLR84(ISSPOT,8)))
     1         DSDR1T(SP19WD(ISSPOT)) = NINT(TCLR84(ISSPOT,8) * 64.0)
            IF (.NOT. ISR4SPV(RDTC8A(ISSPOT)))
     1         DSDR1T(SP20WD(ISSPOT)) = NINT(RDTC8A(ISSPOT) * 64.0)
C
C   STORE THE CLOUD-CLEARED HIRS 8 SURFACE TEMPERATURE ESTIMATE
C   RADIANCE.
C
            IF (.NOT. ISR4SPV(RCC8STE(ISSPOT)))
     1         DSDR1T(CC8STER(ISSPOT)) = NINT(RCC8STE(ISSPOT) * 64.0)
C
C   FILL AMSU CHANNEL BRIGHTNESS TEMPERATURE WORDS
C
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,21)))
     1         DSDR1T(M1WORD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,21)*64.0)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,22)))
     1         DSDR1T(M2WORD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,22)*64.0)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,23)))
     1         DSDR1T(M3WORD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,23)*64.0)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,24)))
     1         DSDR1T(M4WORD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,24)*64.0)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,25)))
     1         DSDR1T(M5WORD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,25)*64.0)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,26)))
     1         DSDR1T(M6WORD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,26)*64.0)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,27)))
     1         DSDR1T(M7WORD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,27)*64.0)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,28)))
     1         DSDR1T(M8WORD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,28)*64.0)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,29)))
     1         DSDR1T(M9WORD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,29)*64.0)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,30)))
     1         DSDR1T(M10WRD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,30)*64.0)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,31)))
     1         DSDR1T(M11WRD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,31)*64.0)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,32)))
     1         DSDR1T(M12WRD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,32)*64.0)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,33)))
     1         DSDR1T(M13WRD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,33)*64.0)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,34)))
     1         DSDR1T(M14WRD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,34)*64.0)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,35)))
     1         DSDR1T(M15WRD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,35)*64.0)

            IF (.not. ISR4SPV(HIRDAT(ISPT,ILINE,35))) THEN
               IF (HIRDAT(ISPT,ILINE,21).eq.HIRDAT(ISPT,ILINE,35)) THEN
                  print *,'HIRDAT(',ISPT,ILINE,21,') ',HIRDAT(ISPT,ILINE,21),
     +                    ' HIRDAT(',ISPT,ILINE,35,') ',HIRDAT(ISPT,ILINE,35)
               END IF
            END IF
C
C   STORE THE DELPRS VALUES USED IN CLOUD CLEARING
C
            IF(.NOT. ISR4SPV(DELPRS1(ISSPOT)))
     1         DSDR1T(SP43WD(ISSPOT)) = NINT(DELPRS1(ISSPOT) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS2(ISSPOT,2)))
     1         DSDR1T(SP44WD(ISSPOT)) = NINT(DELPRS2(ISSPOT,2) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS2(ISSPOT,3)))
     1         DSDR1T(SP45WD(ISSPOT)) = NINT(DELPRS2(ISSPOT,3) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS2(ISSPOT,4)))
     1         DSDR1T(SP46WD(ISSPOT)) = NINT(DELPRS2(ISSPOT,4) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS2(ISSPOT,5)))
     1         DSDR1T(SP47WD(ISSPOT)) = NINT(DELPRS2(ISSPOT,5) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS2(ISSPOT,6)))
     1         DSDR1T(SP48WD(ISSPOT)) = NINT(DELPRS2(ISSPOT,6) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS2(ISSPOT,7)))
     1         DSDR1T(SP49WD(ISSPOT)) = NINT(DELPRS2(ISSPOT,7) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS2(ISSPOT,8)))
     1         DSDR1T(SP50WD(ISSPOT)) = NINT(DELPRS2(ISSPOT,8) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS2(ISSPOT,10)))
     1         DSDR1T(S119WD(ISSPOT)) = NINT(DELPRS2(ISSPOT,10) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS2(ISSPOT,11)))
     1         DSDR1T(S120WD(ISSPOT)) = NINT(DELPRS2(ISSPOT,11) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS2(ISSPOT,12)))
     1         DSDR1T(S121WD(ISSPOT)) = NINT(DELPRS2(ISSPOT,12) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS2(ISSPOT,13)))
     1         DSDR1T(S122WD(ISSPOT)) = NINT(DELPRS2(ISSPOT,13) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS2(ISSPOT,14)))
     1         DSDR1T(S123WD(ISSPOT)) = NINT(DELPRS2(ISSPOT,14) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS2(ISSPOT,15)))
     1         DSDR1T(S124WD(ISSPOT)) = NINT(DELPRS2(ISSPOT,15) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS2(ISSPOT,16)))
     1         DSDR1T(S125WD(ISSPOT)) = NINT(DELPRS2(ISSPOT,16) * 1000.0)
C
            IF(.NOT. ISR4SPV(DELPRS3(ISSPOT,2)))
     1         DSDR1T(SP51WD(ISSPOT)) = NINT(DELPRS3(ISSPOT,2) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS3(ISSPOT,3)))
     1         DSDR1T(SP52WD(ISSPOT)) = NINT(DELPRS3(ISSPOT,3) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS3(ISSPOT,4)))
     1         DSDR1T(SP53WD(ISSPOT)) = NINT(DELPRS3(ISSPOT,4) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS3(ISSPOT,5)))
     1         DSDR1T(SP54WD(ISSPOT)) = NINT(DELPRS3(ISSPOT,5) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS3(ISSPOT,6)))
     1         DSDR1T(SP55WD(ISSPOT)) = NINT(DELPRS3(ISSPOT,6) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS3(ISSPOT,7)))
     1         DSDR1T(SP56WD(ISSPOT)) = NINT(DELPRS3(ISSPOT,7) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS3(ISSPOT,8)))
     1         DSDR1T(SP57WD(ISSPOT)) = NINT(DELPRS3(ISSPOT,8) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS3(ISSPOT,10)))
     1         DSDR1T(S131WD(ISSPOT)) = NINT(DELPRS3(ISSPOT,10) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS3(ISSPOT,11)))
     1         DSDR1T(S132WD(ISSPOT)) = NINT(DELPRS3(ISSPOT,11) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS3(ISSPOT,12)))
     1         DSDR1T(S133WD(ISSPOT)) = NINT(DELPRS3(ISSPOT,12) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS3(ISSPOT,13)))
     1         DSDR1T(S134WD(ISSPOT)) = NINT(DELPRS3(ISSPOT,13) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS3(ISSPOT,14)))
     1         DSDR1T(S135WD(ISSPOT)) = NINT(DELPRS3(ISSPOT,14) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS3(ISSPOT,15)))
     1         DSDR1T(S136WD(ISSPOT)) = NINT(DELPRS3(ISSPOT,15) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS3(ISSPOT,16)))
     1         DSDR1T(S137WD(ISSPOT)) = NINT(DELPRS3(ISSPOT,16) * 1000.0)
C
            IF(.NOT. ISR4SPV(DELPRS4(ISSPOT,2)))
     1         DSDR1T(SP58WD(ISSPOT)) = NINT(DELPRS4(ISSPOT,2) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS4(ISSPOT,3)))
     1         DSDR1T(SP59WD(ISSPOT)) = NINT(DELPRS4(ISSPOT,3) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS4(ISSPOT,4)))
     1         DSDR1T(SP60WD(ISSPOT)) = NINT(DELPRS4(ISSPOT,4) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS4(ISSPOT,5)))
     1         DSDR1T(SP61WD(ISSPOT)) = NINT(DELPRS4(ISSPOT,5) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS4(ISSPOT,6)))
     1         DSDR1T(SP62WD(ISSPOT)) = NINT(DELPRS4(ISSPOT,6) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS4(ISSPOT,7)))
     1         DSDR1T(SP63WD(ISSPOT)) = NINT(DELPRS4(ISSPOT,7) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS4(ISSPOT,8)))
     1         DSDR1T(SP64WD(ISSPOT)) = NINT(DELPRS4(ISSPOT,8) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS4(ISSPOT,10)))
     1         DSDR1T(S143WD(ISSPOT)) = NINT(DELPRS4(ISSPOT,10) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS4(ISSPOT,11)))
     1         DSDR1T(S144WD(ISSPOT)) = NINT(DELPRS4(ISSPOT,11) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS4(ISSPOT,12)))
     1         DSDR1T(S145WD(ISSPOT)) = NINT(DELPRS4(ISSPOT,12) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS4(ISSPOT,13)))
     1         DSDR1T(S146WD(ISSPOT)) = NINT(DELPRS4(ISSPOT,13) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS4(ISSPOT,14)))
     1         DSDR1T(S147WD(ISSPOT)) = NINT(DELPRS4(ISSPOT,14) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS4(ISSPOT,15)))
     1         DSDR1T(S148WD(ISSPOT)) = NINT(DELPRS4(ISSPOT,15) * 1000.0)
            IF(.NOT. ISR4SPV(DELPRS4(ISSPOT,16)))
     1         DSDR1T(S149WD(ISSPOT)) = NINT(DELPRS4(ISSPOT,16) * 1000.0)
C
C  DELPRESX
            IF (.NOT. ISR4SPV(DELPRESX(ISSPOT)))
     1         DSDR1T(S108WD(ISSPOT)) = NINT(DELPRESX(ISSPOT) * 1000.0)
C
C   STORE THE PERCENT CONTAMINATION FOR HIRS CHANNELS 1-19
C
            IF(.NOT. ISR4SPV(CONPCT(ISSPOT,1)))
     1         DSDR1T(SP65WD(ISSPOT)) = NINT(CONPCT(ISSPOT,1) * 1000.0)
            IF(.NOT. ISR4SPV(CONPCT(ISSPOT,2)))
     1         DSDR1T(SP66WD(ISSPOT)) = NINT(CONPCT(ISSPOT,2) * 1000.0)
            IF(.NOT. ISR4SPV(CONPCT(ISSPOT,3)))
     1         DSDR1T(SP67WD(ISSPOT)) = NINT(CONPCT(ISSPOT,3) * 1000.0)
            IF(.NOT. ISR4SPV(CONPCT(ISSPOT,4)))
     1         DSDR1T(SP68WD(ISSPOT)) = NINT(CONPCT(ISSPOT,4) * 1000.0)
            IF(.NOT. ISR4SPV(CONPCT(ISSPOT,5)))
     1         DSDR1T(SP69WD(ISSPOT)) = NINT(CONPCT(ISSPOT,5) * 1000.0)
            IF(.NOT. ISR4SPV(CONPCT(ISSPOT,6)))
     1         DSDR1T(SP70WD(ISSPOT)) = NINT(CONPCT(ISSPOT,6) * 1000.0)
            IF(.NOT. ISR4SPV(CONPCT(ISSPOT,7)))
     1         DSDR1T(SP71WD(ISSPOT)) = NINT(CONPCT(ISSPOT,7) * 1000.0)
            IF(.NOT. ISR4SPV(CONPCT(ISSPOT,8)))
     1         DSDR1T(SP72WD(ISSPOT)) = NINT(CONPCT(ISSPOT,8) * 1000.0)
            IF(.NOT. ISR4SPV(CONPCT(ISSPOT,9)))
     1         DSDR1T(SP73WD(ISSPOT)) = NINT(CONPCT(ISSPOT,9) * 1000.0)
            IF(.NOT. ISR4SPV(CONPCT(ISSPOT,10)))
     1         DSDR1T(SP74WD(ISSPOT)) = NINT(CONPCT(ISSPOT,10) * 1000.0)
            IF(.NOT. ISR4SPV(CONPCT(ISSPOT,11)))
     1         DSDR1T(SP75WD(ISSPOT)) = NINT(CONPCT(ISSPOT,11) * 1000.0)
            IF(.NOT. ISR4SPV(CONPCT(ISSPOT,12)))
     1         DSDR1T(SP76WD(ISSPOT)) = NINT(CONPCT(ISSPOT,12) * 1000.0)
            IF(.NOT. ISR4SPV(CONPCT(ISSPOT,13)))
     1         DSDR1T(SP77WD(ISSPOT)) = NINT(CONPCT(ISSPOT,13) * 1000.0)
            IF(.NOT. ISR4SPV(CONPCT(ISSPOT,14)))
     1         DSDR1T(SP78WD(ISSPOT)) = NINT(CONPCT(ISSPOT,14) * 1000.0)
            IF(.NOT. ISR4SPV(CONPCT(ISSPOT,15)))
     1         DSDR1T(SP79WD(ISSPOT)) = NINT(CONPCT(ISSPOT,15) * 1000.0)
            IF(.NOT. ISR4SPV(CONPCT(ISSPOT,16)))
     1         DSDR1T(SP80WD(ISSPOT)) = NINT(CONPCT(ISSPOT,16) * 1000.0)
            IF(.NOT. ISR4SPV(CONPCT(ISSPOT,17)))
     1         DSDR1T(SP81WD(ISSPOT)) = NINT(CONPCT(ISSPOT,17) * 1000.0)
            IF(.NOT. ISR4SPV(CONPCT(ISSPOT,18)))
     1         DSDR1T(SP82WD(ISSPOT)) = NINT(CONPCT(ISSPOT,18) * 1000.0)
            IF(.NOT. ISR4SPV(CONPCT(ISSPOT,19)))
     1         DSDR1T(SP83WD(ISSPOT)) = NINT(CONPCT(ISSPOT,19) * 1000.0)
           
C
C   FILL MHS CHANNEL BRIGHTNESS TEMPERATURE WORDS
C
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,163)))
     1         DSDR1T(B1WORD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,163)*64.0)
c           IF(.NOT. ISR4SPV(RADT8CU(ISSPOT)))
c    1         DSDR1T(B1WORD(ISSPOT)) = NINT(RADT8CU(ISSPOT) * 64.0)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,164)))
     1         DSDR1T(B2WORD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,164)*64.0)
C    REPLACED MHS 2 WITH CALCULATED BIAS CORRECTION FOR PREDICTED CLEAR
C    THAT HAS NO CLW ADJUSTMENT. 27 December 2013 - Restored MHS 2 14 February 2014
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,165)))
     1         DSDR1T(B3WORD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,165)*64.0)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,166)))
     1         DSDR1T(B4WORD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,166)*64.0)
            IF(.NOT. ISR4SPV(HIRDAT(ISPT,ILINE,167)))
     1         DSDR1T(B5WORD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,167)*64.0)
C
C   CALCULATE AND STORE OLR/DLR/LC PARAMETERS IF THE NON-CLOUD
C   CLEARED OLR WORD IS SET.  OTHERWISE, NO OLR/DLR/LC PARAMETERS
C   ARE CALCULATED.
C
            THEIGHT=HIRANC(ISPT,ILINE,8)
C
C   USE THE SATELLITE ZENITH ANGLE TO DETERMINE WHICH SET OF
C   ELLINGSON COEFFICIENTS TO USE FOR OLR CALCULATION USING
C   NON LIMB-CORRECTED HIRS CHANNELS.  USE THE NADIR-MOST
C   ANGLE FOR ELLINGSON COEFFICIENTS TO BE USED WITH LIMB-CORRECTED
C   AND CLOUD-CLEARED HIRS CHANNELS.
C
            ISATZN = INT(HIRANC(ISPT,ILINE,5)+1.5)
            IF (ISATZN.GT.73) ISATZN=73
            DO N = 1, 5
               ECOFSZ(N) = ECOFS(ISATZN,N)
               ECOF37(N) = ECOFS(37,N)
            END DO
C
C   EXTRACT NON LIMB CORRECTED BRIGHTNESS TEMPERATURES FOR
C   HIRS CHANNELS 1-19.
C
            DO N = 1, 19
               HIROBS(N) = OBSHIR(ISPT,ILINE,N)
            END DO
            CALL OLRDVR2800(DSDR1T,ISSPOT,OLR1ST,HIROBS,ECOFSZ,ECOF37,
     1                  OLR(ISPT,ILINE),LC1(ISPT,ILINE),
     2                  LC2(ISPT,ILINE),LC3(ISPT,ILINE),
     3                  LC4(ISPT,ILINE),CCOLR,LIMTER,THEIGHT,ERSTAT)
C
C   APPLY BIAS CORRECTION TO THE CLOUD-CLEARED OLR
C           
            IF (CCOLR.NE.R4SPV) THEN
               CCOLR = CCOLR + DLRBIAS(ISPT)
            END IF
C
C  IF THE SPOT IS CLEAR, CALCULATE AND STORE THE DOWNWARD LONGWAVE
C  RADIATION.
C
            IF (HIRANC(ISPT,ILINE,15).NE.0.0) THEN
               IF (OLR(ISPT,ILINE).NE.R4SPV.AND.
     +             CCOLR.NE.R4SPV) THEN
                  DLR = CCOLR - OLR(ISPT,ILINE)
ccft              DSDR1T(SP96WD(ISSPOT)) = NINT(DLR * 10.0) 
               END IF
            END IF
                                 
C
C   STORE SURFACE PRESSURE.
C
            DSDR1T(SFPWRD(ISSPOT)) = NINT(HIRANC(ISPT,ILINE,12)*1.0)
C
C   STORE THE HIRS SPOT NUMBER (1-56)
C
C
C   DETERMINE THE HIRS CLOUD MASK 
C
           IF(CLDMSK(ISPT,ILINE).EQ.0) THEN
              IDUM = 111
           ELSEIF(CLDMSK(ISPT,ILINE).EQ.1) THEN
              IDUM = 221
           ELSEIF(CLDMSK(ISPT,ILINE).EQ.2) THEN
              IDUM = 211
           ELSE
C
C   MISSING CLOUD MASKS ARE SET TO 0
C
              IDUM = 0
           END IF
C
C   PACK SPOT NUMBER WITH HIRS CLOUD MASK
C
           DSDR1T(SPTWRD(ISSPOT)) = IDUM * 100 + ISPT
C
C
C   STORE THE CLOUD QUALITY CONTROL FLAG
C
            IF (QCFLAG(ISSPOT).NE.I2SPV) THEN
               DSDR1T(FLGWRD(ISSPOT)) = QCFLAG(ISSPOT)
               IF (QCFLAG(ISSPOT).EQ.7) QCFLAG7 = QCFLAG7 + 1
C
C   STORE THE QCFLAG IN THE HIRANC BUFFER
C
               HIRANC(ISPT,ILINE,47) = QCFLAG(ISSPOT)
            END IF

C
C   STORE THE ATTENUATION ABOVE THE CLOUD TOP
C
              
            IF(.NOT. ISR4SPV(A10U8(ISSPOT)) .AND.
     >         HIRANC(ISPT,ILINE,15) .NE. 0.0)
     >         DSDR1T(ATNWRD(ISSPOT)) = A10U8(ISSPOT)*64.0 
C
C   CALCULATE AND STORE THE CLOUD COMPARISON FLAG
C
            CLDCMP = I2SPV
            IF(CLDMSK(ISPT,ILINE).EQ.0 .AND.
     >         HIRANC(ISPT,ILINE,15).NE. R4SPV) THEN
C
C    HIRS CLOUD DETECTION SAYS CLEAR AND CLOUD PRODUCT IS NOT MISSING
C
               IF(HIRANC(ISPT,ILINE,15).NE.0.0) THEN
C
C    CLOUD ALGORITHM SAYS CLOUDY
C
                  CLDCMP = 1
               ELSE
C
C    CLOUD ALGORITHM SAYS CLEAR
C
                  CLDCMP = 3
               END IF 
C
            ELSEIF(CLDMSK(ISPT,ILINE).EQ.1 .AND. 
     >             HIRANC(ISPT,ILINE,15).NE. R4SPV) THEN
C
C    HIRS CLOUD DETECTION SAYS CLOUDY AND CLOUD PRODUCT IS NOT MISSING
C
               IF(HIRANC(ISPT,ILINE,15).NE.0.0) THEN
C
C    CLOUD ALGORITHM SAYS CLOUDY
C
                  CLDCMP = 0
               ELSE
C
C    CLOUD ALGORITHM SAYS CLEAR

                  CLDCMP = 2
               END IF 
            END IF 
            DSDR1T(CDFWRD(ISSPOT)) = CLDCMP
C
            IF (DELPRS8(ISSPOT,2).NE.R4SPV) 
     1         DSDR1T(SP26WD(ISSPOT)) = NINT(DELPRS8(ISSPOT,2) * 1000.0)
            IF (DELPRS8(ISSPOT,3).NE.R4SPV) 
     1         DSDR1T(SP27WD(ISSPOT)) = NINT(DELPRS8(ISSPOT,3) * 1000.0)
            IF (DELPRS8(ISSPOT,4).NE.R4SPV) 
     1         DSDR1T(SP28WD(ISSPOT)) = NINT(DELPRS8(ISSPOT,4) * 1000.0)
            IF (DELPRS8(ISSPOT,5).NE.R4SPV) 
     1         DSDR1T(SP29WD(ISSPOT)) = NINT(DELPRS8(ISSPOT,5) * 1000.0)
            IF (DELPRS8(ISSPOT,6).NE.R4SPV) 
     1         DSDR1T(SP30WD(ISSPOT)) = NINT(DELPRS8(ISSPOT,6) * 1000.0)
            IF (DELPRS8(ISSPOT,7).NE.R4SPV) 
     1         DSDR1T(SP31WD(ISSPOT)) = NINT(DELPRS8(ISSPOT,7) * 1000.0)
            IF (DELPRS8(ISSPOT,8).NE.R4SPV) 
     1         DSDR1T(SP32WD(ISSPOT)) = NINT(DELPRS8(ISSPOT,8) * 1000.0)
            IF (DELPRS8(ISSPOT,10).NE.R4SPV) 
     1         DSDR1T(SP34WD(ISSPOT)) = NINT(DELPRS8(ISSPOT,10) * 1000.0)
            IF (DELPRS8(ISSPOT,11).NE.R4SPV) THEN 
               IF (DELPRS8(ISSPOT,11).LT.0.0) THEN
                  print *,'DELPRS8 ch 11 = ',DELPRS8(ISSPOT,11),' QCFLAG: ',
     +                     QCFLAG(ISSPOT)
               END IF  
               DSDR1T(SP35WD(ISSPOT)) = NINT(DELPRS8(ISSPOT,11) * 1000.0)
            END IF
            IF (DELPRS8(ISSPOT,12).NE.R4SPV) 
     1         DSDR1T(SP36WD(ISSPOT)) = NINT(DELPRS8(ISSPOT,12) * 1000.0)
            IF (DELPRS8(ISSPOT,13).NE.R4SPV) 
     1         DSDR1T(S110WD(ISSPOT)) = NINT(DELPRS8(ISSPOT,13)* 1000.0)
            IF (DELPRS8(ISSPOT,14).NE.R4SPV) 
     1         DSDR1T(S111WD(ISSPOT)) = NINT(DELPRS8(ISSPOT,14)* 1000.0)
            IF (DELPRS8(ISSPOT,15).NE.R4SPV) 
     1         DSDR1T(S112WD(ISSPOT)) = NINT(DELPRS8(ISSPOT,15)* 1000.0)
            IF (DELPRS8(ISSPOT,16).NE.R4SPV) 
     1         DSDR1T(S113WD(ISSPOT)) = NINT(DELPRS8(ISSPOT,16)* 1000.0)

C
C  DETERMINE AND STORE THE CLOUD PATH FROM THE CLOUD
C  ALGORITHM.

            CLDPPT = I2SPV
            IF(HIRANC(ISPT,ILINE,15).NE. R4SPV) THEN
               IF(HIRANC(ISPT,ILINE,15).NE.0.0) THEN
                  CLDPPT = 1
               ELSE
                  CLDPPT = 0
               END IF
            END IF
            DSDR1T(CPHWRD(ISSPOT)) = CLDPPT 
C
C  STORE THE TERRAIN FLAG
C
            IF(.NOT. ISR4SPV(HIRANC(ISPT,ILINE,9)))     
     1         DSDR1T(SP89WD(ISSPOT)) = NINT(HIRANC(ISPT,ILINE,9))

C  Store the terrain height
            IF(.NOT. ISR4SPV(HIRANC(ISPT,ILINE,8)))     
     1         DSDR1T(TERWRD(ISSPOT)) = NINT(HIRANC(ISPT,ILINE,8))
C
C  DETERMINE AND STORE THE DAY/NIGHT FLAG
C  0=NIGHT 1=DAY
C
            DSDR1T(LINWRD(ISSPOT)) = 1
            IF(HIRANC(ISPT,ILINE,3).GT.90.5) 
     1         DSDR1T(LINWRD(ISSPOT)) = 0
C
C   PACK THE HIRS LINE NUMBER WITH THE DAY/NIGHT FLAG
C
            DSDR1T(LINWRD(ISSPOT)) = ILINE *100 +
     1                               DSDR1T(LINWRD(ISSPOT))
C
C   PACK THE  CLEAR SKY OLR AND LC1-4 VALUES.
C   CHECK BOTH THE CLOUD AMOUNT AND THE AEROSOL AMOUNT WHEN
C   DETERMINING THAT A SPOT IS CLEAR.
C
c           IF(HIRANC(ISPT,ILINE,19) .LE. CLRTHRES .AND.
c    1      HIRANC(ISPT,ILINE,19) .NE. R4SPV .AND.
c    1      HIRANC(ISPT,ILINE,26) .LE. CLRTHRES) THEN
c   Only pack the Clear Sky OLR values where the ECA is zero,
C   indicationg clear.
C
            IF (TCLOUD(ISSPOT).EQ.0.0) THEN

               IF(.NOT. ISR4SPV(OLR(ISPT,ILINE))) 
     1         DSDR1T(CSOWRD(ISSPOT))=NINT(OLR(ISPT,ILINE)*10.0)
C
C    IF LC1-3 ARE SET TO 1000, THEN THEY WERE NOT COMPUTED BECAUSE
C    OF THE TERRAIN CHECK, SO ENSURE THEY REMAIN AS VALUES OF 1000.
C
C    CHANGED THE VALUE OF THE TERRAIN CHECK FROM 1000 TO 10000.
C    HOWEVER, THE VALUE ON THE DSDR1T REMAINS AT 1000 (ASA,9/19/01)
C
               IF(.NOT. ISR4SPV(LC1(ISPT,ILINE))) THEN
                  IF(LC1(ISPT,ILINE).EQ.10000.0) THEN
                     DSDR1T(CS1WRD(ISSPOT)) = 1000
                  ELSE
                     DSDR1T(CS1WRD(ISSPOT)) = 
     1                          NINT(LC1(ISPT,ILINE)*1000.0)
                  END IF
               END IF
               IF(.NOT. ISR4SPV(LC2(ISPT,ILINE))) THEN
                  IF(LC2(ISPT,ILINE).EQ.10000.0) THEN
                     DSDR1T(CS2WRD(ISSPOT)) = 1000
                  ELSE
                     DSDR1T(CS2WRD(ISSPOT)) = 
     1                          NINT(LC2(ISPT,ILINE)*1000.0)
                  END IF
               END IF
               IF(.NOT. ISR4SPV(LC3(ISPT,ILINE))) THEN
                  IF(LC3(ISPT,ILINE).EQ.10000.0) THEN
                     DSDR1T(CS3WRD(ISSPOT)) = 1000
                  ELSE
                     DSDR1T(CS3WRD(ISSPOT)) = 
     1                          NINT(LC3(ISPT,ILINE)*1000.0)
                  END IF
               END IF
C
C     NO LIMITS CHECKS ARE APPLIED TO LC4
C
               IF(.NOT. ISR4SPV(LC4(ISPT,ILINE))) 
     1         DSDR1T(CS4WRD(ISSPOT))=NINT(LC4(ISPT,ILINE)*1000.0)
C
            ELSE
C
C     IF THE SPOT IS NOT CLEAR OR THE CLOUD AMOUNT IS MISSING,
C     SET THE CLEAR SKY OLR AND LAYER COOLING RATES TO 1000.
C
               DSDR1T(CSOWRD(ISSPOT)) = 1000
               DSDR1T(CS1WRD(ISSPOT)) = 1000
               DSDR1T(CS2WRD(ISSPOT)) = 1000
               IF (HIRANC(ISPT,ILINE,19) .EQ. R4SPV) THEN
                  LC3(ISPT,ILINE) = R4SPV
                  LC4(ISPT,ILINE) = R4SPV
                  DSDR1T(CS3WRD(ISSPOT)) = 1000
                  DSDR1T(CS4WRD(ISSPOT)) = 1000
                  GO TO 290
               END IF
C
C     IF CTP GT 700 MB, DON'T SCREEN LC3
C
               IF(HIRANC(ISPT,ILINE,15).GT.LIMTER(4)) THEN
                  IF(.NOT. ISR4SPV(LC3(ISPT,ILINE))) THEN
                     IF(LC3(ISPT,ILINE).EQ.1000.0) THEN
                        DSDR1T(CS3WRD(ISSPOT)) = 1000
                     ELSE
                        DSDR1T(CS3WRD(ISSPOT)) = 
     1                         NINT(LC3(ISPT,ILINE)*1000.0)
                     END IF
                  END IF
               ELSE
                  DSDR1T(CS3WRD(ISSPOT)) = 1000
               END IF
C
C     IF CTP GT 500 MB, DON'T SCREEN LC4
C
               IF(HIRANC(ISPT,ILINE,15).GT.LIMTER(5)) THEN
                  IF(.NOT. ISR4SPV(LC4(ISPT,ILINE))) 
     1            DSDR1T(CS4WRD(ISSPOT))=NINT(LC4(ISPT,ILINE)*1000.0)
               ELSE
                  DSDR1T(CS4WRD(ISSPOT)) = 1000
               END IF
  290          CONTINUE
            END IF
C
C   PACK THE PREDICTED HIRS CLEAR TEMPERATURE VALUES
C
ccft     IF(PREDTEMP(ISSPOT).GT.50.0) THEN
c           DSDR1T(PDTWRD(ISSPOT))= NINT(PREDTEMP(ISSPOT)*64.0) 
c        END IF
C  Pack the attenuation corrected, CLW adjusted predicted
C  clear.
         IF(PCLRATN(ISSPOT).GT.50.0) THEN
            DSDR1T(PDTWRD(ISSPOT))= NINT(PCLRATN(ISSPOT)*64.0)
         END IF
         IF(PREDTEMP(ISSPOT).GT.50.0) THEN
            IF (RDT8CA(ISSPOT).NE.R4SPV) THEN
               DSDR1T(R8CWRD(ISSPOT)) = NINT(RDT8CA(ISSPOT)*64.0)
            END IF
         END IF
C
C   PACK HIRS CHANNEL 8 SURFACE TEMPERATURE ESTIMATE VALUES
C   USED IN CLOUD CALCULATION.
C
         IF(.NOT. ISR4SPV(SURF8(ISSPOT))) THEN
            DSDR1T(E8TWRD(ISSPOT))= NINT(SURF8(ISSPOT)*64.0)
         END IF
         IF(.NOT. ISR4SPV(RDT8MA(ISSPOT))) THEN
            DSDR1T(R8MWRD(ISSPOT)) = NINT(RDT8MA(ISSPOT)*64.0)
         END IF
C-- STORE PARAMETERS SEPARATELY DEPENDING ON QCFLAG VALUE
C
         DSDR1T(S163WD(ISSPOT)) = 0
         DSDR1T(S164WD(ISSPOT)) = 0
         DSDR1T(S165WD(ISSPOT)) = 0
         DSDR1T(S166WD(ISSPOT)) = 0
         DSDR1T(S167WD(ISSPOT)) = 0
         DSDR1T(S168WD(ISSPOT)) = 0
         DSDR1T(S169WD(ISSPOT)) = 0
         DSDR1T(S170WD(ISSPOT)) = 0
         DSDR1T(S171WD(ISSPOT)) = 0
         DSDR1T(S172WD(ISSPOT)) = 0
         DSDR1T(S173WD(ISSPOT)) = 0
         DSDR1T(S174WD(ISSPOT)) = 0
         DSDR1T(S196WD(ISSPOT)) = 0
         DSDR1T(S197WD(ISSPOT)) = 0
         DSDR1T(S198WD(ISSPOT)) = 0
         DSDR1T(S199WD(ISSPOT)) = 0
         DSDR1T(S109WD(ISSPOT)) = 0
         DSDR1T(CCOLRWRD(ISSPOT)) = 0
         IF (QCFLAG(ISSPOT).EQ.0.OR.QCFLAG(ISSPOT).EQ.1) THEN
            IF (HIRANC(ISPT,ILINE,19).NE.R4SPV) THEN
               DSDR1T(S163WD(ISSPOT)) = NINT(HIRANC(ISPT,ILINE,19) * 1000.0)
            END IF
            IF (HIRANC(ISPT,ILINE,15).NE.R4SPV) THEN
               DSDR1T(S164WD(ISSPOT)) = NINT(HIRANC(ISPT,ILINE,15))
            END IF
            IF (HIRANC(ISPT,ILINE,18).NE.R4SPV) THEN
               DSDR1T(S165WD(ISSPOT)) = NINT(HIRANC(ISPT,ILINE,18) * 64.0)
            END IF
            IF (CPERROR(ISSPOT).NE.R4SPV) THEN
               DSDR1T(S166WD(ISSPOT)) = NINT(CPERROR(ISSPOT) * 1000.0)
            END IF
         END IF
         IF (QCFLAG(ISSPOT).EQ.2.OR.QCFLAG(ISSPOT).EQ.5) THEN
            IF (HIRANC(ISPT,ILINE,19).NE.R4SPV) THEN
               DSDR1T(S167WD(ISSPOT)) = NINT(HIRANC(ISPT,ILINE,19) * 1000.0)
            END IF
            IF (HIRANC(ISPT,ILINE,15).NE.R4SPV) THEN
               DSDR1T(S168WD(ISSPOT)) = NINT(HIRANC(ISPT,ILINE,15))
            END IF
            IF (HIRANC(ISPT,ILINE,18).NE.R4SPV) THEN
               DSDR1T(S169WD(ISSPOT)) = NINT(HIRANC(ISPT,ILINE,18) * 64.0)
            END IF
            IF (CPERROR(ISSPOT).NE.R4SPV) THEN
               DSDR1T(S170WD(ISSPOT)) = NINT(CPERROR(ISSPOT) * 1000.0)
            END IF
         END IF
C-- WRITE OUT QC6 AEROSOLS. THE SPOTS HAVE BEEN INITIALIZED TO ZERO.
         IF (QCFLAG(ISSPOT).EQ.3.OR.QCFLAG(ISSPOT).EQ.6) THEN
            IF (AROSOL(ISSPOT).GT.0.0) THEN
               IF (HIRANC(ISPT,ILINE,19).NE.R4SPV) THEN
                  DSDR1T(S171WD(ISSPOT)) = NINT(HIRANC(ISPT,ILINE,19) * 1000.0)
               END IF
               IF (HIRANC(ISPT,ILINE,15).NE.R4SPV) THEN
                  DSDR1T(S172WD(ISSPOT)) = NINT(HIRANC(ISPT,ILINE,15))
               END IF
               IF (HIRANC(ISPT,ILINE,18).NE.R4SPV) THEN
                  DSDR1T(S173WD(ISSPOT)) = NINT(HIRANC(ISPT,ILINE,18) * 64.0)
               END IF
               IF (CPERROR(ISSPOT).NE.R4SPV) THEN
                  DSDR1T(S174WD(ISSPOT)) = NINT(CPERROR(ISSPOT) * 1000.0)
               END IF
            END IF
         END IF
C-- WRITE OUT BOUNDARY LAYER VALUES
         IF ((QCFLAG(ISSPOT).EQ.1).OR.(QCFLAG(ISSPOT).EQ.3).OR.
     +       (QCFLAG(ISSPOT).EQ.6).OR.(QCFLAG(ISSPOT).EQ.(-1)).OR.
     +       (QCFLAG(ISSPOT).EQ.7)) THEN
            IF (T_VALUE(ISSPOT).NE.R4SPV) THEN
               DSDR1T(S109WD(ISSPOT)) = NINT(T_VALUE(ISSPOT) * 64.0)
            END IF
            IF (HIRANC(ISPT,ILINE,19).NE.R4SPV) THEN
               DSDR1T(S196WD(ISSPOT)) = NINT(HIRANC(ISPT,ILINE,19) * 1000.0)
            END IF
            IF (HIRANC(ISPT,ILINE,15).NE.R4SPV) THEN
               DSDR1T(S197WD(ISSPOT)) = NINT(HIRANC(ISPT,ILINE,15))
            END IF
            IF (HIRANC(ISPT,ILINE,18).NE.R4SPV) THEN
               DSDR1T(S198WD(ISSPOT)) = NINT(HIRANC(ISPT,ILINE,18) * 64.0)
            END IF
            IF (CPERROR(ISSPOT).NE.R4SPV) THEN
               DSDR1T(S199WD(ISSPOT)) = NINT(CPERROR(ISSPOT) * 1000.0)
            END IF
            IF (RADCLR(ISSPOT).NE.R4SPV) THEN
               DSDR1T(CCOLRWRD(ISSPOT)) = NINT(RADCLR(ISSPOT) * 64.0)
            END IF
         END IF

C-- STORE THE LAND PRECIPITATION INDEX
               
         IF (LPINDX(ISSPOT).NE.R4SPV) THEN
            DSDR1T(S175WD(ISSPOT)) = NINT(LPINDX(ISSPOT) * 64.0)
         END IF
C-- STORE THE CLOUD CLEARED SURFACE TEMPERATURE ESTIMATE IN TEMPERATURE SPACE

         IF (CC8STE(ISSPOT).NE.R4SPV) THEN
            DSDR1T(S176WD(ISSPOT)) = NINT(CC8STE(ISSPOT) * 64.0)
         END IF
C-- STORE THE BIAS CORRECTED UNADJUSTED PREDICTED CLEAR TEMPERATURE.

            IF(.NOT. ISR4SPV(PREDTEM8COR(ISSPOT)))
     1         DSDR1T(S177WD(ISSPOT)) = NINT(PREDTEM8COR(ISSPOT) * 64.0)

C-- STORE THE UNADJUSTED PREDICTED CLEAR TEMPERATURE.

            IF(.NOT. ISR4SPV(PREDTEM8(ISSPOT)))
     1         DSDR1T(S178WD(ISSPOT)) = NINT(PREDTEM8(ISSPOT) * 64.0)

C-- STORE THE FLAG INDICATING WHETHER HIRS CHANNEL 4 OR HIRS CHANNEL 7 WAS
C   USED AS THE UPPER PEAKING CHANNEL FOR THE FIRST CALCULATION OF CTT.

            IF (NCH1GUESS(ISSPOT).NE.I2SPV) THEN
               DSDR1T(S179WD(ISSPOT)) = NCH1GUESS(ISSPOT)
            END IF

C-- STORE THE HIRS CHANNEL 20 ALBEDO FOR EACH SPOT. SET THE ALBEDO TO ZERO
C   AT NIGHT.

            IF (HIRDAT(ISPT,ILINE,20).NE.R4SPV) THEN
               DSDR1T(S181WD(ISSPOT)) = NINT(HIRDAT(ISPT,ILINE,20)*100.0)
               IF (HIRANC(ISPT,ILINE,3) .GT. 90.5) THEN
                  DSDR1T(S181WD(ISSPOT)) = 0
               END IF
            END IF
C-- STORE THE HIRS CLOUD CLEARED RADIANCES FOR CHANNELS 2-8 AND 9-16

c           CHANNEL 2
            IF (CCHRAD(ISSPOT,2).NE.R4SPV) THEN
               DSDR1T(S182WD(ISSPOT)) = NINT(CCHRAD(ISSPOT,2) * 64.0)
            END IF
c           CHANNEL 3
            IF (CCHRAD(ISSPOT,3).NE.R4SPV) THEN
               DSDR1T(S183WD(ISSPOT)) = NINT(CCHRAD(ISSPOT,3) * 64.0)
            END IF
c           CHANNEL 4
            IF (CCHRAD(ISSPOT,4).NE.R4SPV) THEN
               DSDR1T(S184WD(ISSPOT)) = NINT(CCHRAD(ISSPOT,4) * 64.0)
            END IF
c           CHANNEL 5
            IF (CCHRAD(ISSPOT,5).NE.R4SPV) THEN
               DSDR1T(S185WD(ISSPOT)) = NINT(CCHRAD(ISSPOT,5) * 64.0)
            END IF
c           CHANNEL 6
            IF (CCHRAD(ISSPOT,6).NE.R4SPV) THEN
               DSDR1T(S186WD(ISSPOT)) = NINT(CCHRAD(ISSPOT,6) * 64.0)
            END IF
c           CHANNEL 7
            IF (CCHRAD(ISSPOT,7).NE.R4SPV) THEN
               DSDR1T(S187WD(ISSPOT)) = NINT(CCHRAD(ISSPOT,7) * 64.0)
            END IF
c           CHANNEL 8
            IF (CCHRAD(ISSPOT,8).NE.R4SPV) THEN
               DSDR1T(S188WD(ISSPOT)) = NINT(CCHRAD(ISSPOT,8) * 64.0)
            END IF
c           CHANNEL 10
            IF (CCHRAD(ISSPOT,10).NE.R4SPV) THEN
               DSDR1T(S189WD(ISSPOT)) = NINT(CCHRAD(ISSPOT,10) * 64.0)
            END IF
c           CHANNEL 11
            IF (CCHRAD(ISSPOT,11).NE.R4SPV) THEN
               DSDR1T(S190WD(ISSPOT)) = NINT(CCHRAD(ISSPOT,11) * 64.0)
            END IF
c           CHANNEL 12
            IF (CCHRAD(ISSPOT,12).NE.R4SPV) THEN
               DSDR1T(S191WD(ISSPOT)) = NINT(CCHRAD(ISSPOT,12) * 64.0)
            END IF
c           CHANNEL 13
            IF (CCHRAD(ISSPOT,13).NE.R4SPV) THEN
               DSDR1T(S192WD(ISSPOT)) = NINT(CCHRAD(ISSPOT,13) * 64.0)
            END IF
c           CHANNEL 14
            IF (CCHRAD(ISSPOT,14).NE.R4SPV) THEN
               DSDR1T(S193WD(ISSPOT)) = NINT(CCHRAD(ISSPOT,14) * 64.0)
            END IF
c           CHANNEL 15
            IF (CCHRAD(ISSPOT,15).NE.R4SPV) THEN
               DSDR1T(S194WD(ISSPOT)) = NINT(CCHRAD(ISSPOT,15) * 64.0)
            END IF
c           CHANNEL 16
            IF (CCHRAD(ISSPOT,16).NE.R4SPV) THEN
               DSDR1T(S195WD(ISSPOT)) = NINT(CCHRAD(ISSPOT,16) * 64.0)
            END IF

C
  300    CONTINUE
  400 CONTINUE
C
      DSDR1T(3) = IBSP
C
C   WRITE OUT THE 42 LEVELS OF RETRIEVED TEMPERATURES.
C

      START = 1213
      DO IWRD=1, 42
         IF(.NOT. ISR4SPV(RETDAT(I,J,IWRD)))
     1      DSDR1T(START+IWRD) = NINT(RETDAT(I,J,IWRD)*64.0)
      END DO
C
C   FILL THE NEXT WORDS WITH THE 19  LEVELS OF RETRIEVED MOISTURE (WATER VAPOR)
C

      START = 1255
      DO IWRD=1, 19
         IF(.NOT. ISR4SPV(RETDAT(I,J,(IWRD+42))))
     1      DSDR1T(START+IWRD) = NINT(ALOG(RETDAT(I,J,(IWRD+42)))* 1024.0)
         LAST = START + IWRD
      END DO
C
C   INSERT THE RETRIEVAL PRECIPITATION CONTAMINATION FLAG
C
      DSDR1T(1275) = RETANC(I,J,8)
C
C   EXTRACT THE BEGINNING ORBIT NUMBER FROM COMMON /ERINFO/ AND STORE THE
C   LAST THREE DIGITS OF THE ORBIT NUMBER
C
      BEGORB = MOD(SORB(1),1000)
      DSDR1T(1276) = BEGORB
C
C   FILL THE NEXT WORDS WITH THE 42 LEVELS OF FIRST GUESS TEMPERATURE
C
      START = 1276
      DO IWRD=1, 42
         IF(.NOT. ISR4SPV(RETANC(I,J,(IWRD+18))))
     1      DSDR1T(START+IWRD) = NINT(RETANC(I,J,(IWRD+18))*64.0)
      END DO
C
C   FILL THE NEXT WORDS WITH THE 19 LEVELS OF FIRST GUESS MIXING RATIOS
C
      START = 1318
      DO IWRD=1, 19
         IF(.NOT. ISR4SPV(RETANC(I,J,(IWRD+60))))
     1      DSDR1T(START+IWRD) = NINT(ALOG(RETANC(I,J,(IWRD+60)))* 1024.0)
      END DO
C 
C   UPDATE HOUSEKEEPING BUFFER EACH TIME, IN CASE OF ABNORMAL
C   TERMINATION
C
      R1TORB = R1TORB + 1
      R1TREC = R1TREC + 1
      IF(R1TREC.GT.R1TMAX) R1TREC = 2
      R1THKP(3) = R1TREC
      R1THKP(5) = R1TORB
C
C   WRITE BUFFER TO DSDR1T FILE
C 
       IF (R1TREC.NE.1) THEN       
          WRITE(R1TUNT,REC=R1TREC,IOSTAT=IOERR) DSDR1T
       END IF
C
 1000 RETURN
      END
