      SUBROUTINE PMRAYL(IMYR,IMO,IDAY,CHNO,SPRES,RAYO3)

C     VERSION: MAY 1, 1990 - P. REDDY

C     THIS SUBROUTINE CALCULATES THE SUM OF THE RAYLEIGH OPTICAL
C     DEPTH AND THE OZONE OPTICAL DEPTH (AT 500 NM) FOR THE MLO
C     PMOD SUNPHOTOMETER.  THE ROUTINE IS CURRENTLY CONFIGURED TO
C     HANDLE 3 CHANNELS (380 NM, 500 NM, AND 778 NM).  THE CENTRAL
C     WAVELENGTHS AT THE NOMINAL VALUES CHANGE WITH TIME.  THE ROUTINE
C     DETERMINES THE SUM BASED ON THE WAVELENGTH VALID ON THE DAY AND 
C     YEAR PASSED BY THE CALLING PROGRAM.

C     THE OZONE ABSORPTION VALUE AT 500 NM IS COMPUTED FROM THE 
C     MONTHLY MEAN OZONE. 
C     THE CORRECTIONS TO REFLECT YOUNG'S (1981) CORRECTION TO
C     ELTERMAN'S RAYLEIGH VALUES ARE +.003 AT 380 NM, -.002 AT 500 NM,
C     AND -.001 AT 778 NM.  THE DEFAULT STATION PRESSURE USED IS THE MEAN FOR
C     THE MLO OBSERVATORY FOR 1982-1988 AND IS 680.64. 
C     THE VALUES FOR RAYO3 ERRONEOUSLY USED IN THE PMOD PROCESSING PROGRAM
C     PRIOR TO 2/16/1990 WERE .297, .1066, AND .016 FOR 380 NM, 500 NM,
C     AND 778 NM RESPECTIVELY
C
C*************************************************************************
C     INTEGER VARIABLES:
C
C     IMYR - YEAR, PASSED BY CALLING PROGRAM.
C     IMO - MONTH PASSED BY CALLING PROGRAM.
C     IDAY - JULIAN DAY, PASSED BY CALLING PROGRAM.
C     JYR - YEAR INDEX FOR OZONE WHERE 1983 = 1, 1990 = 8.
C     CHNO - CURRENT CHANNEL NUMBER, PASSED BY CALLING PROGRAM.
C
C*************************************************************************
C     REAL VARIABLES:
C
C     YR - THE DECIMAL YEAR.
C     RAYO3 - THE SUM OF RAYL. OPTICAL DEPTH AND O3 ABSORPTION
C           PASSED BY PMRAYL.
C     SPRES - THE MEAN STATION PRESSURE FOR THE 2 HRS OR SO OF THE
C           LANGLEY PLOT.
C     O3 - OZONE OPTICAL DEPTH AT 500 NM.
C     OZONE(JYR,IMO) - MONTHLY MEAN MLO OZONE IN DOBSON UNITS.
C*************************************************************************


      REAL YR, RAYO3, SPRES, O3, OZONE(8,12)
      INTEGER IMYR, IDAY, CHNO, IMO, JYR

C     READS IN DOBSUN UNITS AT MLO FOR 1983
      DATA (OZONE(1,J),J=1,12) 
     ./225,236,249,276,277,283,271,268,266,261,255,257/

C     READS IN DOBSUN UNITS AT MLO FOR 1984
      DATA (OZONE(2,J),J=1,12) 
     ./249,273,264,301,290,277,277,274,269,262,244,246/

C     READS IN DOBSUN UNITS AT MLO FOR 1985
      DATA (OZONE(3,J),J=1,12) 
     ./231,232,250,272,282,280,281,266,264,254,260,251/

C     READS IN DOBSUN UNITS AT MLO FOR 1986
      DATA (OZONE(4,J),J=1,12) 
     ./243,263,269,292,281,279,266,259,258,261,248,251/

C     READS IN DOBSUN UNITS AT MLO FOR 1987
      DATA (OZONE(5,J),J=1,12)
     ./249,239,263,278,294,292,280,267,262,248,249,237/

C     READS IN DOBSUN UNITS AT MLO FOR 1988
      DATA (OZONE(6,J),J=1,12)
     ./229,241,265,279,288,276,276,266,259,266,261,253/

C     READS IN DOBSUN UNITS AT MLO FOR 1989
      DATA (OZONE(7,J),J=1,12)
     ./264,277,280,301,309,286,282,277,279,267,253,248/

C     READS IN DOBSUN UNITS AT MLO FOR 1990
      DATA (OZONE(8,J),J=1,12)
     ./250,250,265,278,286,282,276,00.,00.,00.,00.,00./
C
C       JAN-MAY O3 ENTERED 7/30/90, CLIMATOLOGICAL MEAN JUNE AND JULY
C       USED SINCE THESE MONTHS WERE NOT YET PROCESSED - PJR
C

      WRITE(*,*) 'IN PMRAYL SUBROUTINE:'
      WRITE(*,*) 'YEAR,MONTH,DAY = ',IMYR,IMO,IDAY
      WRITE(*,*) 'CHANNEL,NUM_CHAN,STAND_PRES = ',
     .            CHNO,SPRES

      JYR = IMYR-82

      IF(OZONE(JYR,IMO).LT.100) THEN
           OZONE(JYR,IMO) = 263.2
      ENDIF

      IF(SPRES.LT.600.0) THEN
           SPRES = 680.64
C          680.64 IS THE MEAN STATION PRESSURE FOR 82 TO 88.
      ENDIF

      YR = FLOAT(IMYR) + FLOAT(IDAY)/365.

      IF(CHNO.EQ.1) THEN

           IF(YR.LT.85.5) THEN

             RAYO3 = (SPRES/1013.)*((.00877*.37969**(-4.05))+.003)

C     MEAN WAVELENGTH FROM 82 TILL 85.5 IS 379.83 NM LESS 0.14 TO CORRECT
C     FOR THE EFFECTIVE WAVELENGTH (ACCOUNTS FOR RAYLEIGH O.D. AND SOLAR 
C     CONSTANT OVER THE BANDPASS, AND FILTER TRANSMISSION CURVE).  

           ELSE IF(YR.LT.90.25616) THEN

             RAYO3 = (SPRES/1013.)*((.00877*.38037**(-4.05))+.003)

C     MEAN WAVELENGTH FROM 85.5 TILL 90.25616 IS 380.57 NM LESS 0.20 TO
C     CORRECT FOR THE EFFECTIVE WAVELENGTH (ACCOUNTS FOR RAYLEIGH O.D. AND 
C     SOLAR CONSTANT OVER THE BANDPASS, AND FILTER TRANSMISSION CURVE).  

           ELSE IF(YR.LT.95.0) THEN

             RAYO3 = (SPRES/1013.)*((.00877*.38125**(-4.05))+.003)

C     MEAN WAVELENGTH FROM 90.25616 TILL ? IS 381.47 NM LESS 0.22 TO 
C     CORRECT FOR THE EFFECTIVE WAVELENGTH (ACCOUNTS FOR RAYLEIGH O.D. AND 
C     SOLAR CONSTANT OVER THE BANDPASS, AND FILTER TRANSMISSION CURVE).  

           ENDIF

      ELSE IF(CHNO.EQ.2) THEN

           IF(YR.LT.85.5) THEN

             O3 = OZONE(JYR,IMO)*(2.71E-05 + 0.00197*(.49860-.497))

             RAYO3 = (SPRES/1013.)*((.00877*.49860**(-4.05))-.002)
     .       + O3

C     MEAN WAVELENGTH FROM 82 TILL 85.5 IS 498.63 NM LESS 0.03 TO 
C     CORRECT FOR THE EFFECTIVE WAVELENGTH (ACCOUNTS FOR RAYLEIGH O.D. AND 
C     SOLAR CONSTANT OVER THE BANDPASS, AND FILTER TRANSMISSION CURVE).  

           ELSE IF(YR.LT.90.25616) THEN

             O3 = OZONE(JYR,IMO)*(2.71E-05 + 0.00197*(.50025-.497))

             RAYO3 = (SPRES/1013.)*((.00877*.50025**(-4.05))-.002)
     .       + O3

C     MEAN WAVELENGTH FROM 85.5 TILL 90.25616 IS 500.27 NM LESS 0.02 TO
C     CORRECT FOR THE EFFECTIVE WAVELENGTH (ACCOUNTS FOR RAYLEIGH O.D. AND 
C     SOLAR CONSTANT OVER THE BANDPASS, AND FILTER TRANSMISSION CURVE).  

           ELSE IF(YR.LT.95.0) THEN

             O3 = OZONE(JYR,IMO)*(2.71E-05 + 0.00197*(.50134-.497))

             RAYO3 = (SPRES/1013.)*((.00877*.50134**(-4.05))-.002)
     .       + O3

C     MEAN WAVELENGTH FROM 90.25616 TILL ? IS 501.34 NM LESS 0.00 TO 
C     CORRECT FOR THE EFFECTIVE WAVELENGTH (ACCOUNTS FOR RAYLEIGH O.D. AND 
C     SOLAR CONSTANT OVER THE BANDPASS, AND FILTER TRANSMISSION CURVE).  

           ENDIF

      ELSE IF(CHNO.EQ.3) THEN

           IF(YR.LT.85.5) THEN

             RAYO3 = (SPRES/1013.)*((.00877*.77797**(-4.05))-.001)

C     MEAN WAVELENGTH FROM 82 TILL 85.5 IS 777.97 NM LESS 0.00 TO 
C     CORRECT FOR THE EFFECTIVE WAVELENGTH (ACCOUNTS FOR RAYLEIGH O.D. AND 
C     SOLAR CONSTANT OVER THE BANDPASS, AND FILTER TRANSMISSION CURVE).  

           ELSE IF(YR.LT.90.25616) THEN

             RAYO3 = (SPRES/1013.)*((.00877*.77715**(-4.05))-.001)

C     MEAN WAVELENGTH FROM 85.5 TILL 90.25616 IS 777.15 NM LESS 0.00 TO
C     CORRECT FOR THE EFFECTIVE WAVELENGTH (ACCOUNTS FOR RAYLEIGH O.D. AND 
C     SOLAR CONSTANT OVER THE BANDPASS, AND FILTER TRANSMISSION CURVE).  

           ELSE IF(YR.LT.95.0) THEN

             RAYO3 = (SPRES/1013.)*((.00877*.77797**(-4.05))-.001)

C     MEAN WAVELENGTH FROM 90.25616 TILL ? IS 777.97 NM LESS 0.00 TO 
C     CORRECT FOR THE EFFECTIVE WAVELENGTH (ACCOUNTS FOR RAYLEIGH O.D. AND 
C     SOLAR CONSTANT OVER THE BANDPASS, AND FILTER TRANSMISSION CURVE).  

           ENDIF

      ENDIF
      RETURN
      END
