      SUBROUTINE CMPSLZ(LAT,LON,SPOT,SPTDIF,TIMCOR,YEAR,JDAY,MSEC,
     . SOLZEN,SOLAZM)
      IMPLICIT NONE
C***********************************************************************
C   NAME- CMPSLZ
C
C   LANGUAGE- FORTRAN 77    TYPE- SUBROUTINE   COMPUTER- CRAY    
C
C   VERSION- 1.0       DATE- 2/11/91    PROGRAMMER- CARLA NEIGH (SMSRC)
C   VERSION- 3.0       DATE- 5/10/96    PROGRAMMER- ALEX POZDNYAK (FDC)
C     MODIFIED TO RUN ON THE CRAY.  REPLACED I*4 WITH INT, L*4 WITH LOG
C     AND  R*4 WITH REAL.
C   VERSION- 3.1       DATE- 7/07/97    PROGRAMMER- LEAH WILSON (HSTX)
C     RTOVS UPGRADE TO GET NODE FROM SUBROUTINE SUNANG.
C   VERSION- 3.2       DATE- 6/26/01    PROGRAMMER- FRANK TILLEY (RAYTHEON)
C     REMOVED ALL REFERENCES TO ORBIT NODE. NODE IS NOW EXTRACTED FROM
C     1B* FILES INSTEAD OF BEING CALCULATED. (WR #164).
C  
C   FUNCTION-  THIS SUBROUTINE RETURNS THE SOLAR ZENITH ANGLE AND THE
C              SOLAR AZIMUTH ANGLE FOR A GIVEN SPOT.  BEFORE
C              CALCULATING THE SOLAR ZENITH ANGLE AND THE SOLAR AZIMUTH
C              ANGLE, THE TIME OF THE SPOT IS COMPUTED.
C
C   CALLING SEQUENCES-
C      VARIABLE   TYPE  I/O  DESCRIPTION
C      --------   ----  ---  -----------
C      LAT        REAL   I   SPOT LATITUDE (DEGREES)
C      LON        REAL   I   SPOT LONGITUDE (DEGREES)
C      SPOT       INT    I   NUMBER OF SPOT IN SCAN LINE
C                            (1 THROUGH N WHERE N IS TOTAL NUMBER OF
C                            SPOTS IN A SCAN LINE)
C      SPTDIF     INT    I   TIME DIFFERENCE (IN MILLISECONDS) BETWEEN
C                            SPOTS ALONG A SCAN LINE
C      TIMCOR     INT    I   TIME CORRECTION (IN MILLISECONDS) FOR
C                            INSTRUMENT MISALIGNMENT
C      YEAR       INT    I   YEAR OF START OF SCAN TIME (0-99)
C      JDAY       INT    I   DAY OF YEAR OF START OF SCAN TIME
C      MSEC       INT    I   MILLISECOND OF DAY OF START OF SCAN TIME
C      SOLZEN     REAL   O   SOLAR ZENITH ANGLE FOR SPOT
C                            (IN DEGREES)
C      SOLAZM     REAL   O   SOLAR AZIMUTH ANGLE FOR SPOT
C                            (IN DEGREES)
C
C   LOCAL VARIABLES-
C      VARIABLE    TYPE    DESCRIPTION
C      --------    ----    -----------
C      SPTYR       INT     YEAR OF SPOT
C      SPTJDY      INT     JULIAN DAY OF SPOT
C      SPTMSC      INT     MILLISECOND OF DAY OF SPOT
C      LEAPYR      LOG     LEAP YEAR FLAG FOR SPOT TIME-
C                          SET TO TRUE IF YEAR OF SPOT TIME IS A LEAP
C                          YEAR, OTHERWISE IS FALSE
C      DIST        REAL    DISTANCE FROM THE EARTH TO THE SUN (IN AU)
C                          (VALUE RETURNED BY SUNANG THAT WILL NOT BE
C                           USED.)
C
C
C   INTRINSIC FUNCTIONS USED - MOD
C
C   SUBROUTINES CALLED - SUNANG
C
C   EXIT STATES- NONE
C
C***********************************************************************
C
      REAL LAT, LON, SOLZEN, SOLAZM
      REAL DIST
C
      INTEGER SPOT, SPTDIF, TIMCOR, YEAR, JDAY, MSEC
      INTEGER SPTYR, SPTJDY, SPTMSC
C
      LOGICAL LEAPYR
C
      LEAPYR = .FALSE.
C
C   COMPUTE THE SPOT TIME.
C
      SPTYR = YEAR
      SPTJDY = JDAY
      SPTMSC = MSEC + SPTDIF*(SPOT - 1) + TIMCOR
C
C   CHECK IF SPOT TIME EXTENDS INTO THE NEXT DAY, AND IF SO, MAKE
C   ADJUSTMENTS TO SPOT TIME VALUES.
C   (86400000 IS THE TOTAL NUMBER OF MILLISECONDS IN A DAY)
C
      IF (SPTMSC .GT. 86400000) THEN
       SPTMSC = SPTMSC - 86400000
       IF (MOD(SPTYR,4).EQ.0) LEAPYR = .TRUE.
C
C   CHECK IF SPOT TIME EXTENDS INTO THE NEXT YEAR, AND IF SO, ADJUST
C   THE YEAR AND JULIAN DAY VALUES FOR THE SPOT.
C
       IF(((SPTJDY.EQ.365).AND.(.NOT.(LEAPYR))).OR.(SPTJDY.EQ.366))THEN
         IF (SPTYR .EQ. 99) THEN
           SPTYR = 0
         ELSE
           SPTYR = SPTYR + 1
         ENDIF
         SPTJDY = 1
       ELSE
         SPTJDY = SPTJDY + 1
       ENDIF
      ENDIF
C
C   CONVERT YEAR FROM 00-99 FORM TO ACTUAL YEAR SINCE YEAR 0.
C   ASSUME 20TH CENTURY IF YEAR IS GREATER THAN 50, OTHERWISE
C   ASSUME 21ST CENTURY.
C
      IF (SPTYR .GT. 50) THEN
        SPTYR = SPTYR + 1900
      ELSE
        SPTYR = SPTYR + 2000
      ENDIF
C
C   ALTHOUGH ROUTINE SUNANG ASSUMES THE LATITUDE INPUT IS GEOCENTRIC
C   LATITUDE, GEODETIC LATITUDE WILL BE USED FOR COMPUTATION OF SOLAR
C   ZENITH ANGLE AND SOLAR AZIMUTH ANGLE .  THIS PRODUCES AN ERROR IN
C   SOLAR ZENITH ANGLE < .01 DEGREES.
C
      CALL SUNANG(LAT,LON,SPTYR,SPTJDY,SPTMSC,SOLZEN,SOLAZM,DIST)
C
      RETURN
      END
