 MODULE comcolig3d

   !!======================================================================
   !!                   ***  MODULE comcolig3d  ***
   !! 
   !&E ** History :
   !&E       !  2008-07  (L. Debreu, M. Honnorat, T. Duhaut) time scheme
   !&E       !  2009-07  (V. Garnier) MPI2d : initialize cdvit
   !&E
   !!======================================================================
   !! * Modules used
   USE parameters

   !! * Accessibility

   !! * Shared or public module variables

   !! * Private variables
   REAL(kind=rsh),ALLOCATABLE,DIMENSION(:,:)   :: cdvit
   REAL(kind=rlg),ALLOCATABLE,DIMENSION(:,:)   :: intz_exp
   REAL(kind=rsh),ALLOCATABLE,DIMENSION(:,:)   :: intz_exp_ustar, intz_exp_vstar
   REAL(kind=rlg),ALLOCATABLE,DIMENSION(:,:,:) :: yz_exp
#if key_dyn_pg_djcs
   REAL(kind=rsh),ALLOCATABLE,DIMENSION(:,:,:) :: zr,pr
#endif

 CONTAINS

   !!======================================================================

  SUBROUTINE alloc_comcolig3d

   !&E---------------------------------------------------------------------
   !&E                 ***  ROUTINE alloc_comcolig3d  ***
   !&E
   !&E ** Purpose : 
   !&E
   !&E ** Description :
   !&E
   !&E ** Called by :
   !&E
   !&E ** External calls : 
   !&E
   !&E ** Used ij-arrays : 
   !&E
   !&E ** Modified variables :
   !&E
   !&E ** Reference :
   !&E
   !&E ** History :
   !&E       !  
   !&E
   !&E---------------------------------------------------------------------
   !! * Modules used
   IMPLICIT NONE

   !! * Arguments

   !! * Local declarations

   !!----------------------------------------------------------------------
   !! * Executable part

#if key_dyn_pg_djcs
   ALLOCATE(zr(kmax,liminm1:limaxp2,ljminm1:ljmaxp2))
   ALLOCATE(pr(kmax,limin:limaxp1,ljmin:ljmaxp1))
   zr(:,:,:)=0.0_rsh  ! to manage with sleeping cpus
   pr(:,:,:)=0.0_rsh
#endif
   ALLOCATE(cdvit(limin:limax,ljmin:ljmax))
   ALLOCATE(intz_exp(limin:limax,ljmin:ljmax))
   ALLOCATE(intz_exp_ustar(limin:limax,ljmin:ljmax))
   ALLOCATE(intz_exp_vstar(limin:limax,ljmin:ljmax))
   ALLOCATE(yz_exp(kmax,limin:limax,ljmin:ljmax))
   cdvit(:,:)=0.0_rsh
   intz_exp(:,:)=0.0_rlg
   yz_exp(:,:,:)=0.0_rlg
   intz_exp_ustar(:,:)=0.0_rsh
   intz_exp_vstar(:,:)=0.0_rsh

  END SUBROUTINE alloc_comcolig3d

   !!======================================================================

  SUBROUTINE dealloc_comcolig3d

   !&E---------------------------------------------------------------------
   !&E                 ***  ROUTINE dealloc_comcolig3d  ***
   !&E
   !&E ** Purpose : 
   !&E
   !&E ** Description :
   !&E
   !&E ** Called by :
   !&E
   !&E ** External calls : 
   !&E
   !&E ** Used ij-arrays : 
   !&E
   !&E ** Modified variables :
   !&E
   !&E ** Reference :
   !&E
   !&E ** History :
   !&E       !  
   !&E
   !&E---------------------------------------------------------------------
   !! * Modules used
   IMPLICIT NONE

   !! * Arguments

   !! * Local declarations

   !!----------------------------------------------------------------------
   !! * Executable part
   DEALLOCATE(cdvit,intz_exp,yz_exp,intz_exp_ustar,intz_exp_vstar)

#ifdef key_dyn_pg_djcs
   DEALLOCATE(zr,pr)
#endif

  END SUBROUTINE dealloc_comcolig3d

   !!======================================================================

 END MODULE comcolig3d
