SUBROUTINE INTER0(KLAT,KLON,KLAT0,KLON0,PSTRET,KPP)

!     PURPOSE.
!     --------
!       Determination of the size of interpolation boxes.

!**   INTERFACE.
!     ----------
!       CALL INTER0 (KLAT,KLON,KLAT0,KLON0,PSTRET,KPP)
!     Input :
!       KLAT  = number of latitudes  of the final grid (model)
!       KLON  = number of longitudes of the final grid (model)
!       KLAT0 = number of latitudes  of the initial grid (data)
!       KLON0 = number of longitudes of the initial grid (data)
!       PSTRET= stretching factor
!     Output :
!       KPP   = size of the box

!     METHOD.
!     -------
!       KPP is odd and at least max( KLAT0*PSTRET/KLAT , KLON0*PSTRET/KLON )

!     EXTERNALS : None.
!     ----------

!     AUTHORS.
!     --------
!         D. Giard  MARCH 97 (from INCLI0)

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

IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: KLAT 
INTEGER(KIND=JPIM),INTENT(IN)    :: KLON 
INTEGER(KIND=JPIM),INTENT(IN)    :: KLAT0 
INTEGER(KIND=JPIM),INTENT(IN)    :: KLON0 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PSTRET 
INTEGER(KIND=JPIM),INTENT(OUT)   :: KPP 
INTEGER(KIND=JPIM) :: IP

REAL(KIND=JPRB) :: ZEPS, ZLAT, ZLON, ZP
REAL(KIND=JPRB) :: ZHOOK_HANDLE

IF (LHOOK) CALL DR_HOOK('INTER0',0,ZHOOK_HANDLE)
ZEPS=1.E-12_JPRB
ZLAT= REAL(KLAT0,JPRB)*PSTRET/REAL(MAX(1,KLAT),JPRB)
ZLON= REAL(KLON0,JPRB)*PSTRET/REAL(MAX(1,KLON),JPRB)
ZP= MAX(ZLAT,ZLON)
IP= MAX(1,INT(ZP))
IF ((ABS(IP-ZP) <= ZEPS) .AND. (MOD(IP,2) == 1)) THEN
  KPP= IP
ELSE
  KPP= ((IP+1)/2)*2+1
ENDIF

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

