C*******************************************************************
C*******************************************************************
C
      SUBROUTINE CDCOEF
     I   ( CDTURB,
     I     IC    ,
     O     CD1   , CD2   ,
     G     ZGRID ,
     D     NX    , NZ    , NXB   , NZB   , NROT  )
C
C*******************************************************************
      IMPLICIT REAL*8 ( A-H, O-Z )
C*******************************************************************
C
      DIMENSION
     \    CDTURB(-2:NXB, -2:NZB, NROT),
     \    CD1 (-2:NXB,-2:NZB), CD2 (-2:NXB,-2:NZB),
     \    ZGRID(-2:NZB)
C
C=================================================================
C
      DO 21 IZ=0,NZ-1
C
      CDMAX= 2000.0D0
      CDMIN= 0.0D0
C
      DO 21 IX=1,NX
         CD2(IX,IZ) = MIN ( CDMAX, MAX ( CDMIN, CDTURB(IX,IZ,IC) ) )
   21 CONTINUE
C
      CALL BOUND( CD2,NX, NZ, NXB,NZB,1,1,1,1)
C
C---------------------------------------------------------------
C
      DO 31 IZ=0,NZ
      DO 31 IX=1,NX
         CD1(IX,IZ)
     \         =  ( CD2(IX  ,IZ)  + CD2(IX  ,IZ-1)
     \             +CD2(IX-1,IZ)  + CD2(IX-1,IZ-1) ) /4.0D0
   31 CONTINUE
C
      CALL BOUND( CD1,NX,NZ,NXB,NZB,1,1,0,1)
C
C---------------------------------------------------------------
C
      RETURN
      E N D
