 MODULE sflxatm
!!======================================================================
!!                   ***  MODULE  sflxatm  ***
!! Atmospherical fluxes :  declare and allocate atmospherical fluxes
!!======================================================================





























































!! * Modules used
   USE parameters, ONLY       : rsh,imin,imax,jmin,jmax,limin,limax,ljmin,ljmax, &
                                limaxp1,ljmaxp1

   IMPLICIT NONE
   PRIVATE

!! * Accessibility
   PUBLIC alloc_sflxatm,dealloc_sflxatm      ! function called by step

!! * Shared module variables
   REAL(KIND=rsh), ALLOCATABLE, DIMENSION(:,:), PUBLIC ::                  &
                                    rad,        &   ! short wave heat flux
                                    senslos,    &   ! sensible heat flux (loss)
                                    dsenslos,   &   ! its derivative
                                    irlos,      &   ! long wave heat flux (loss)
                                    dirlos,     &   ! its derivative
                                    latlos,     &   ! latent heat flux (loss)
                                    dlatlos         ! its derivative


   REAL(KIND=rsh), DIMENSION(13,11), PUBLIC ::                                &
                                    exch,       &   ! array used for bilinear evaluation of thermal exchange coefficient
                                    drag            ! array used for bilinear evaluation of drag coefficient

   INTEGER, PUBLIC               :: imeteo_exchtype,      &   ! switch to select dependence
! on tdif
                                    imeteo_dragtype           ! type of drag coefficient formulation

!! * Private variables

 CONTAINS

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

  SUBROUTINE alloc_sflxatm
   IF (ALLOCATED(rad)) PRINT*,"error: sflxatmd allocated"
   ALLOCATE(rad(limin:limax,ljmin:ljmax) )  
   ALLOCATE(senslos(limin:limax,ljmin:ljmax) )  
   ALLOCATE(dsenslos(limin:limax,ljmin:ljmax) )  
   ALLOCATE(irlos(limin:limax,ljmin:ljmax) )  
   ALLOCATE(dirlos(limin:limax,ljmin:ljmax) )  
   ALLOCATE(latlos(limin:limax,ljmin:ljmax) )  
   ALLOCATE(dlatlos(limin:limax,ljmin:ljmax) )  

   rad(:,:)=0.0_rsh
   senslos(:,:)=0.0_rsh
   dsenslos(:,:)=0.0_rsh
   latlos(:,:)=0.0_rsh
   dlatlos(:,:)=0.0_rsh
   irlos(:,:)=0.0_rsh
   dirlos(:,:)=0.0_rsh

  END SUBROUTINE alloc_sflxatm

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

  SUBROUTINE dealloc_sflxatm
  IF (.NOT.allocated(rad)) PRINT*,"error: sflxatm not allocated"
  DEALLOCATE(rad,senslos,dsenslos,irlos,dirlos,latlos,dlatlos)

  END SUBROUTINE dealloc_sflxatm

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

 END MODULE
