SUBROUTINE GPINOZST(KSTART,KPROF,KSTGLO,PKOZO)

!**** *GPINOZST* - Ozone physico-chemical properties
!                  and subgrid surface temperature.

!     Purpose. 
!     -------- 

!**   Interface.
!     ----------
!        *CALL* *GPINOZST(...)

!        Explicit arguments :
!        --------------------    

!        INPUT:
!         KSTART       : start of work
!         KPROF        : depth of work
!         KSTGLO       : global offset

!        OUTPUT:
!         PKOZO        : fields for photochemistery of ozone

!        Implicit arguments :
!        --------------------

!     Method.
!     -------
!        See documentation

!     Externals.  None. 
!     ----------
!      Called by CPG_GP.

!     Reference.
!     ----------
!        ECMWF Research Department documentation of the IFS

!     Author.
!     -------
!        ????

! Modifications.
! --------------
!   Original : ????
!   K. Yessad (Sep 2008): add missing comments, cleanings.
! End Modifications
!------------------------------------------------------------------

USE PARKIND1  ,ONLY : JPIM     ,JPRB
USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK

USE YOMDIM   , ONLY : NFLEVG   ,NPROMA
USE YOMDPHY  , ONLY : NVCLIS   ,NTOZ2D   ,NTOZ3D
USE YOMGEM   , ONLY : NGPTOT
USE YOMMP    , ONLY : MY_REGION_NS   ,MY_REGION_EW   ,NONL     ,NFRSTLAT ,&
 & NLSTLAT  ,NPTRFLOFF  
USE YOMOZO   , ONLY : TOZ2DL   ,TOZ3DBL 

! ----------------------------------------------------------------------------

IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: KSTART 
INTEGER(KIND=JPIM),INTENT(IN)    :: KPROF 
INTEGER(KIND=JPIM),INTENT(IN)    :: KSTGLO 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PKOZO(NPROMA,NFLEVG*NVCLIS) 

! ----------------------------------------------------------------------------

INTEGER(KIND=JPIM) :: IGRILAT(NGPTOT)

INTEGER(KIND=JPIM) :: ICH, ILAT, IROF, IROFST, ISTART, ISTOP, JFLEV,&
 & JGL, JLON, JROF, JVCLI  
REAL(KIND=JPRB) :: ZHOOK_HANDLE

! ----------------------------------------------------------------------------

IF (LHOOK) CALL DR_HOOK('GPINOZST',0,ZHOOK_HANDLE)

! ----------------------------------------------------------------------------

IROF=0
DO JGL=1,NLSTLAT(MY_REGION_NS)-NFRSTLAT(MY_REGION_NS)+1
  DO JLON=1,NONL(NPTRFLOFF+JGL,MY_REGION_EW)
    IROF=IROF+1
    IGRILAT(IROF)=JGL
  ENDDO
ENDDO
IROFST=KSTGLO
ISTART=KSTART
ISTOP =KPROF

IF (NTOZ3D == 1) THEN
  DO JFLEV=1,NFLEVG
    DO JVCLI=1,NVCLIS
      ICH=(JVCLI-1)*NFLEVG+JFLEV
      IROF=IROFST
      DO JROF=ISTART,ISTOP
        PKOZO(JROF,ICH)=TOZ3DBL(IROF,ICH)
        IROF=IROF+1
      ENDDO
    ENDDO
  ENDDO
ENDIF

IF (NTOZ2D == 1) THEN
  DO JFLEV=1,NFLEVG
    DO JVCLI=1,NVCLIS
      ICH=(JVCLI-1)*NFLEVG+JFLEV
      IROF=IROFST
      DO JROF=ISTART,ISTOP
        ILAT=IGRILAT(IROF)
        PKOZO(JROF,ICH)=TOZ2DL(ILAT,ICH)
        IROF=IROF+1
      ENDDO
    ENDDO
  ENDDO
ENDIF

! ----------------------------------------------------------------------------

IF (LHOOK) CALL DR_HOOK('GPINOZST',1,ZHOOK_HANDLE)
END SUBROUTINE GPINOZST
