SUBROUTINE GCDIS(PLA1,PLO1,PLA2,PLO2,PDIS)

!**** SUBROUTINE GCDIS - FIND GREAT CIRCLE DISTANCE BETWEEN TWO POINTS

!          HEIKKI JARVINEN   ECMWF          15/MAR/1995

!*    PURPOSE
!     -------

!        FIND GREAT CIRCLE DISTANCE BETWEEN TWO POINTS.

!**   INTERFACE
!     ---------

!     ***CALL GCDIS(PLA1,PLO1,PLA2,PLO2,PDIS)
!     WHERE PLA1 = LATITUDE  OF THE FIRST  POINT (IN RADIANS)
!           PLO1 = LONGITUDE OF THE FIRST  POINT (IN RADIANS)
!           PLA2 = LATITUDE  OF THE SECOND POINT (IN RADIANS)
!           PLO2 = LONGITUDE OF THE SECOND POINT (IN RADIANS)
!           PDIS = DISTANCE IN METERS

!        GCDIS IS CALLED BY VARIOUS SUBROUTINES

!*    METHOD
!     ------

!*    EXTERNALS
!     ---------

!**   MODIFICATIONS
!     -------------
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!        M.Hamrud      01-Dec-2003 CY28R1 Cleaning 

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

USE PARKIND1  ,ONLY : JPRB
USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
USE YOMCST   , ONLY : RA

IMPLICIT NONE

REAL(KIND=JPRB)   ,INTENT(IN)    :: PLA1 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PLO1 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PLA2 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PLO2 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PDIS 
REAL(KIND=JPRB) :: ZX
REAL(KIND=JPRB) :: ZHOOK_HANDLE

!*
!     ------------------------------------------------------------------

!        1.       CALCULATE THE DISTANCE
!                 ----------------------

IF (LHOOK) CALL DR_HOOK('GCDIS',0,ZHOOK_HANDLE)
IF(PLA1 == PLA2.AND. PLO1 == PLO2) THEN
  PDIS = 0.0_JPRB
ELSE
  ZX=COS(PLA1)*COS(PLA2)*COS(PLO1-PLO2)+SIN(PLA1)*SIN(PLA2)
  ZX=MAX(ZX,-1.0_JPRB)
  ZX=MIN(ZX,1.0_JPRB)
  PDIS = ACOS(ZX)*RA
ENDIF
!*
!     ------------------------------------------------------------------

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

