       function overlap ( ishp, rad, x0, y0, z0, xin, yin, zin, xout
     1                  , yout, zout )
c
c    dac:zeus3d.overlap <--------- overlap of region over Cartesian zone
c                                                            april, 1990
c
c    written by: David Clarke
c    modified 1:
c
c  PURPOSE:  Determines the fraction of a Cartesian zone that overlaps
c  the specified geometrical region (sphere or right cylinder).  This
c  is done by dividing the zone into 20**3 "subzones", and finding the
c  fraction of subzone centres lying inside the surface of the region.
c
c  INPUT VARIABLES:
c
c    ishp            =1 => sphere
c                    =2 => right cylinder
c    rad             radius of region
c    x0,y0,z0        coordinates of centre of curvature.
c    xin,yin,zin     coordinates of zone corner known to lie inside
c                    region.
c    xout,yout,zout  coordinates of zone corner diametrically opposed to
c                    zone corner known to lie inside region.
c
c  OUTPUT VARIABLES:
c
c  LOCAL VARIABLES:
c
c  EXTERNALS: [NONE]
c
c-----------------------------------------------------------------------
c
c
c-----------------------------------------------------------------------
c------------------------ IMPLICIT STATEMENTS --------------------------
c-----------------------------------------------------------------------
c
       implicit      none
c
c-----------------------------------------------------------------------
c----------------------------- PARAMETERS ------------------------------
c-----------------------------------------------------------------------
c
c      Primary parameters:
c
       integer       in      , jn      , kn      , ijkn    , nxpx
     1             , nypx    , nxrd    , nyrd    , niov    , nios
     2             , ntsl    , mn      , nmd     , isig
       real*8        pi  , tiny  , huge  , one  , mone  , haf  , zro
c
       parameter     ( in = 5005, jn = 1, kn = 10, ijkn = 5005)
       parameter     ( nxpx = 1, nypx = 1, nxrd =   1, nyrd =   1 )
       parameter     ( niov =  20, nios =  20, ntsl =1000 )
       parameter     ( mn   =   1, nmd  =   1 )
       parameter     ( pi   = 3.1415926535898 )
       parameter     ( isig = 9, tiny = 1.0d-99, huge = 1.0d+99 )
       parameter     ( one  = 1.0d+00, mone = -1.0d+00
     1                               , haf  =  0.5d+00, zro = 0.0d+00)
c
c      Secondary parameters:
c
       integer        idim    , jdim
     1              , nt01    , nt02    , nt03    , nt04    , nt05
     2              , nt06    , nt07    , nt08    , nt09    , nt10
     3              , nt11    , nt12    , nt13    , nt14    , nt15
     4              , nt16    , nt17    , nt18    , nt19    , nt20
       parameter     ( idim =   kn, jdim =   in )
       parameter     ( nt01 = 600, nt02 = 600, nt03 =   7, nt04 =   5 )
       parameter     ( nt05 =  18, nt06 =   1, nt07 =  10, nt08 =  12 )
       parameter     ( nt09 =   5, nt10 =  54, nt11 =   8 )
       parameter     ( nt12 =        16, nt17 =         4 )
       parameter     ( nt13 = nt12 +  4, nt18 = nt17 +  1 )
       parameter     ( nt14 = nt13     , nt19 = nt18      )
       parameter     ( nt15 = nt14 + 30, nt20 = nt19 +  3 )
       parameter     ( nt16 = nt14 + 42 )
c
       integer       i       , j       , k       , nx      , ny
     1             , nz      , ishp
       real*8        overlap
       real*8        rad     , x0      , y0      , z0      , xin
     1             , yin     , zin     , xout    , yout    , zout
     2             , delx    , dely    , delz    , r       , fact
     3             , scount
c
       real*8        xsq     (  20), ysq     (  20), zsq     (  20)
     1             , count   (  20)
c
c-----------------------------------------------------------------------
c
       overlap = 1.0
c
       return
       end
