C***********************************************************
C***********************************************************
C
      SUBROUTINE CLBUOY
     I   ( TPOT, QVAP, QCLW, QRAI,
     I     IBY,
     O     BUOY,  BUOYW,
     B     TPOT0,
     C     GRAV, RMVAP,
     G     FDZ,
     D     NX, NZ, NXB, NZB, NROT )
C
C***********************************************************
      IMPLICIT REAL*8 ( A-H, O-Z )
C***********************************************************
C
      DIMENSION
     \   TPOT( -2:NXB, -2:NZB, NROT ),
     \   QVAP( -2:NXB, -2:NZB, NROT ),
     \   QCLW( -2:NXB, -2:NZB, NROT ),
     \   QRAI( -2:NXB, -2:NZB, NROT )
C
      DIMENSION
     \   BUOY ( -2:NXB, -2:NZB ),
     \   BUOYW( -2:NXB, -2:NZB )
C
      DIMENSION
     \   TPOT0( -2:NZB ), FDZ( -2:NZB )
C
C===========================================================
C     WRITE(6,*)'FDZ IN CLBUOY'
C     WRITE(6,*) FDZ
C
      DO 11 IZ = 0, NZ-1
      DO 11 IX = 1, NX
         BUOY(IX,IZ) = GRAV / ( (TPOT0(IZ-1)+TPOT0(IZ))/2.0D0 )
     \      * ( 9.0D0 * (   TPOT(IX,IZ  ,IBY)
     \                    + TPOT(IX,IZ-1,IBY) )
     \                - (   TPOT(IX,IZ+1,IBY)
     \                    + TPOT(IX,IZ-2,IBY) ) ) / 16.0D0
C        BUOY(IX,IZ) = GRAV / ( (TPOT0(IZ-1)+TPOT0(IZ))/2.0D0 )
C    \      *           (   TPOT(IX,IZ  ,IBY)
C    \                    + TPOT(IX,IZ-1,IBY) ) / 2.0D0
         BUOYW(IX,IZ) =
     \     GRAV / 16.0D0
     \      * (    9.0D0 *
     \             ( (  (1.0D0/RMVAP-1.0D0) * QVAP(IX,IZ  ,IBY)
     \                      - MAX ( 0.0D0, QCLW(IX,IZ  ,IBY) )
     \                      - MAX ( 0.0D0, QRAI(IX,IZ  ,IBY) ) )
     \             + (  (1.0D0/RMVAP-1.0D0) * QVAP(IX,IZ-1,IBY)
     \                      - MAX ( 0.0D0, QCLW(IX,IZ-1,IBY) )
     \                      - MAX ( 0.0D0, QRAI(IX,IZ-1,IBY) ) ) )
     \          -  ( (  (1.0D0/RMVAP-1.0D0) * QVAP(IX,IZ+1,IBY)
     \                      - MAX ( 0.0D0, QCLW(IX,IZ+1,IBY) )
     \                      - MAX ( 0.0D0, QRAI(IX,IZ+1,IBY) ) )
     \             + (  (1.0D0/RMVAP-1.0D0) * QVAP(IX,IZ-2,IBY)
     \                      - MAX ( 0.0D0, QCLW(IX,IZ-2,IBY) )
     \                      - MAX ( 0.0D0, QRAI(IX,IZ-2,IBY) ) ) ) )
   11 CONTINUE
C
      DO 12 IX = 1, NX
         BUOY (IX,NZ) = 0.0D0
         BUOYW(IX,NZ) = 0.0D0
   12 CONTINUE
C
      CALL BOUND ( BUOY , NX, NZ, NXB, NZB, 1, -1, 0, 1 )
      CALL BOUND ( BUOYW, NX, NZ, NXB, NZB, 1, -1, 0, 1 )
C
C-----------------------------------------------------------
C
      RETURN
      E N D
