    SUBROUTINE OZON2D &
    (LK,POZN,XLAT,RSIN1,RCOS1,RCOS2,QO3)
!***********************************************************************
!$$$  SUBPROGRAM DOCUMENTATION BLOCK
!                .      .    .
! SUBPROGRAM:    OZON2D      COMPUTE OZONE IN MODEL COLUMNS
!   PRGRMMR: KATZ/CAMPANA    ORG: W/NP22     DATE: ??-??-??

! ABSTRACT:
!     OZON2D COMPUTES THE OZONE MIXING RATIO IN EACH GRID BOX
!     OF COLUMNS WITHIN THE MODEL DOMAIN

! PROGRAM HISTORY LOG:
!   ??-??-??  KATZ/KC    - ORIGINATOR
!   96-07-26  BLACK      - MODIFIED FOR ETA MODEL
!   98-10-28  BLACK      - MODIFIED FOR DISTRIBUTED MEMORY

! USAGE: CALL OZON2D FROM SUBROUTINE RADTN
!   INPUT ARGUMENT LIST:
!     LK:    NUMBER OF LAYERS IN COLUMNS
!     XLAT:  GEODETIC LATITUDE OF GRID COLUMNS IN DEGREES
!     RSIN1: INFORMATION RELATING TO POSITION OF EARTH IN ITS ORBIT
!     RCOS1: INFORMATION RELATING TO POSITION OF EARTH IN ITS ORBIT
!     RCOS2: INFORMATION RELATING TO POSITION OF EARTH IN ITS ORBIT

!   OUTPUT ARGUMENT LIST:
!     QO3:  OZONE MIXING RATIO AT MIDLAYERS OF MODEL COLUMNS

!   OUTPUT FILES:
!     NONE

!   SUBPROGRAMS CALLED:

!     UNIQUE:
!        NONE

!     LIBRARY:
!        NONE

!   COMMON BLOCKS: SEASO3

! ATTRIBUTES:
!   LANGUAGE: FORTRAN 90
!   MACHINE : IBM SP
!$$$
!----------------------------------------------------------------------
    PARAMETER &
    (NL=81,NLP1=NL+1,LNGTH=37*NL,RTD=57.2957795)
!----------------------------------------------------------------------
    INCLUDE "parmeta.f90"
    INCLUDE "mpp.h"
    INCLUDE "COMM_SEASO3.f90"
#include "sp.h"
!----------------------------------------------------------------------
    DIMENSION &
    QO3(IDIM1:IDIM2,LK),POZN(IDIM1:IDIM2,LK),XLAT(IDIM1:IDIM2) &
    ,QO3O3(IDIM1:IDIM2,NL),JJROW(IDIM1:IDIM2),TTHAN(IDIM1:IDIM2)
!----------------------------------------------------------------------
    DO I=MYIS,MYIE
        TH2=0.2*XLAT(I)
        JJROW(I)=19.001-TH2
        TTHAN(I)=(19-JJROW(I))-TH2
    ENDDO

!***  SEASONAL AND SPATIAL INTERPOLATION DONE BELOW.

    DO K=1,NL
        DO I=MYIS,MYIE
            DO3V=XDUO3N(JJROW(I),K)+RSIN1*XDO3N2(JJROW(I),K) &
            +RCOS1*XDO3N3(JJROW(I),K) &
            +RCOS2*XDO3N4(JJROW(I),K)
!if (mype == 2) write(*,*) "TESTEOZ1",I,K,XDUO3N(JJROW(I),K)
            DO3VP=XDUO3N(JJROW(I)+1,K)+RSIN1*XDO3N2(JJROW(I)+1,K) &
            +RCOS1*XDO3N3(JJROW(I)+1,K) &
            +RCOS2*XDO3N4(JJROW(I)+1,K)
        
        !***  NOW LATITUDINAL INTERPOLATION
        !***  AND CONVERT O3 INTO MASS MIXING RATIO (ORIG DATA MPY BY 1.E4)
        
            QO3O3(I,K)=1.E-4*(DO3V+TTHAN(I)*(DO3VP-DO3V))
        ENDDO
    ENDDO
!***
!***  VERTICAL INTERPOLATION FOR EACH GRIDPOINT (LINEAR IN LN P)
!***
    NUMITR=0
    ILOG=NL
    20 CONTINUE
    ILOG=(ILOG+1)/2
    IF(ILOG == 1)GO TO 25
    NUMITR=NUMITR+1
    GO TO 20
    25 CONTINUE

    DO 60 K=1,LK
    
        NHALF=(NL+1)/2
        DO I=MYIS,MYIE
            JJROW(I)=NHALF
        ENDDO
    
        DO 40 IT=1,NUMITR
            NHALF=(NHALF+1)/2
            DO I=MYIS,MYIE
                IF(POZN(I,K) < PRGFDL(JJROW(I)-1))THEN
                    JJROW(I)=JJROW(I)-NHALF
                ELSEIF(POZN(I,K) >= PRGFDL(JJROW(I)))THEN
                    JJROW(I)=JJROW(I)+NHALF
                ENDIF
                JJROW(I)=MIN(JJROW(I),NL)
                JJROW(I)=MAX(JJROW(I),2)
            ENDDO
        40 END DO
    
        DO 50 I=MYIS,MYIE
            IF(POZN(I,K) < PRGFDL(1))THEN
                QO3(I,K)=QO3O3(I,1)
            ELSE IF(POZN(I,K) > PRGFDL(NL))THEN
                QO3(I,K)=QO3O3(I,NL)
            ELSE
                APLO=ALOG(PRGFDL(JJROW(I)-1))
                APHI=ALOG(PRGFDL(JJROW(I)))
                QO3(I,K)=QO3O3(I,JJROW(I))+(ALOG(POZN(I,K))-APHI)/ &
                (APLO-APHI)* &
                (QO3O3(I,JJROW(I)-1)-QO3O3(I,JJROW(I)))
            ENDIF
        50 END DO
    
    60 END DO
!----------------------------------------------------------------------
    RETURN
    END SUBROUTINE OZON2D
