CMAX: [Version 1.0 (6/22/93)]
CMAX: ----------------------------------------------------
CMAX: Transformation of GCD from gcd.f
CMAX: ----------------------------------------------------
      SUBROUTINE gcd_v1(lat1,os,ln,lon1,os100,ln100,lat2,os101,ln101,
     &    lon2,os102,ln102,dist,os103,ln103,np)
      include '/usr/include/cm/CMF_defs.h'

C......................................................................
C                                                                     .
C  Program:    GCD                                                    .
C  Language:   FORTRAN V (ANSI-77 STANDARD)                           .
C  Computer:   Cray YMP 8/432                                         .
C                                                                     .
C  Programmer: M. SEABLOM ( AFTER J. WOOLLEN, JULY 1985 )             .
C  Date:       JANUARY, 1990                                          .
C                                                                     .
C  SUBROUTINE COMPUTES CHORD LENGTH APPROXIMATION TO GREAT CIRCLE     .
C  DISTANCE.                                                          .
C                                                                     .
C  INPUT:  LAT1,LON1 AND LAT2,LON2  ARE THE LOCATIONS OF PAIRS OF     .
C                                   POINTS ON THE EARTH.              .
C                                                                     .
C          NP  IS THE NUMBER OF PAIRS OF POINTS.                      .
C                                                                     .
C  OUTPUT: DIST  IS AN ARRAY CONTAINING THE DISTANCES OF THE PAIRS.   .
C                                                                     .
C  METHODOLOGY.                                                       .
C       THE NORMAL ANGLE BETWEEN THE TWO POINTS IS GIVEN BY           .
C                                                                     .
C S*S/2 = 1 - COS(LAT1-LAT2) + COS(LAT1)*COS(LAT2)*(1-COS(LON1-LON2)) .
C......................................................................
cmax: Changed argument LAT1 to passed with index
      INTEGER os
      INTEGER ln
cmax: Changed argument LON1 to passed with index
      INTEGER os100
      INTEGER ln100
cmax: Changed argument LAT2 to passed with index
      INTEGER os101
      INTEGER ln101
cmax: Changed argument LON2 to passed with index
      INTEGER os102
      INTEGER ln102
cmax: Changed argument DIST to passed with index
      INTEGER os103
      INTEGER ln103
      REAL lat1(1-os+1:ln+1-os), lat2(1-os101+1:ln101+1-os101), 
     &    lon1(1-os100+1:ln100+1-os100), lon2(1-os102+1:ln102+1-os102), 
     &    dist(1-os103+1:ln103+1-os103)
!hpf$ distribute dist(block)
!hpf$ distribute lat1(block)
!hpf$ distribute lat2(block)
!hpf$ distribute lon1(block)
!hpf$ distribute lon2(block)
      REAL  CLAT2100(1-os101+1:ln101+1-os101)
!hpf$ distribute clat2100(block)
      REAL  TEMP100(1-os103+1:ln103+1-os103)
!hpf$ distribute temp100(block)
      REAL  CLOND100(1-os100+1:ln100+1-os100)
!hpf$ distribute clond100(block)
      REAL  CLAT1100(1-os+1:ln+1-os)
!hpf$ distribute clat1100(block)
      REAL  CDIF1100(1-os+1:ln+1-os)
!hpf$ distribute cdif1100(block)
      pi = 3.141592653
      drc = pi / 180.
      rade = 6.375E3
      clat1100(1:np) = cos(lat1(1:np) * drc)
      clat2100(1:np) = cos(lat2(1:np) * drc)
      clond100(1:np) = cos((lon1(1:np) - lon2(1:np)) * drc)
      cdif1100(1:np) = cos((lat1(1:np) - lat2(1:np)) * drc)
      temp100(1:np) = 1. - cdif1100(1:np) + clat1100(1:np) 
     &    * clat2100(1:np) * (1. - clond100(1:np))
      dist(1:np) = sqrt(2. * temp100(1:np)) * rade
      RETURN
      END
CMAX: ----------------------------------------------------
