  SUBROUTINE DEALLOC

   !&E---------------------------------------------------------------------
   !&E                 ***  ROUTINE DEALLOC  ***
   !&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       ! 2010-02 (G. Simon) add wave module
   !&E
   !&E---------------------------------------------------------------------
   !! * Modules used
   USE comvars2d, ONLY : l_modele2d,dealloc_comvars2d,hex,hey,htx,hty
   USE comfluxdo, ONLY : dealloc_comfluxdo,dealloc_comfluxdo3d,dealloc_fsalxy
   USE comvars3d, ONLY : dealloc_comvars3d,wz
   USE cometemp,  ONLY : dealloc_cometemp,dealloc_ftempxy
   USE comdem,    ONLY : dealloc_comdem
   USE output,    ONLY : output_dealloc
   USE sflxatm,   ONLY : dealloc_sflxatm
   USE cometdyn,  ONLY : dealloc_cometdyn
   USE obccombine,ONLY : dealloc_obc
   USE comvarp2d, ONLY : sal,temp,u,v,ssh
#ifdef key_casacc
   USE modcasinit,ONLY : temp0,uz0,vz0,u0,v0,ssh0
#endif
   USE comvarp2d, ONLY : sal2,temp2
#ifdef key_turbadv
   USE comvarp3d, ONLY : boz,uz,vz,ect,ect2,psi,psi2
#else
   USE comvarp3d, ONLY : boz,uz,vz,ect,psi
#endif
#ifdef key_profil_back
   USE comvars3d, ONLY : boz2
#endif
   USE comturb,   ONLY : dealloc_comturb
   USE comaree,   ONLY : dealloc_comaree
   USE comvarp2d, ONLY : dealloc_comvarp2d
   USE comsiggen, ONLY : dealloc_comsiggen
#if defined key_tssub_wquickupwind || defined key_tssub_wcompact
   USE comfluvert,ONLY : dealloc_comfluvert
#endif
#ifdef key_wave
   USE wave,      ONLY : wave_dealloc
#endif
#ifdef key_substance
   USE comsubstance, ONLY : dealloc_fxfyfz
#endif
#if defined key_siggen || defined key_gencoord
   USE comsiggen, ONLY : hzex,hzey
#endif
#ifdef key_diagdyn
  USE  diagdyn,   ONLY : diagdyn_dealloc
#endif
#ifdef key_wave_qeuler_diag
  USE  wavediag,   ONLY : wave_diag_qeuler_dealloc
#endif

   !! * Arguments

   !! * Local declarations

   !!----------------------------------------------------------------------
   !! * Executable part
   CALL output_dealloc
   CALL dealloc_comdem
   CALL dealloc_cometemp
   CALL dealloc_cometdyn
#ifdef key_wave
   CALL wave_dealloc
#endif
   CALL dealloc_comfluxdo
   CALL dealloc_comvars2d
   CALL dealloc_comvars3d
   CALL dealloc_sflxatm
   CALL dealloc_obc
   CALL dealloc_ftempxy
   CALL dealloc_fsalxy
   CALL dealloc_comturb
   CALL dealloc_comaree
   CALL dealloc_comvarp2d
#if defined key_tssub_wquickupwind || defined key_tssub_wcompact
   CALL dealloc_comfluvert
#endif
   IF(.NOT.l_modele2d) CALL dealloc_comfluxdo3d
#ifdef key_substance
   CALL dealloc_fxfyfz      !deallocating fxfy
#endif

#ifdef key_turbadv
   DEALLOCATE(boz,hex,hey,htx,hty,ect,ect2,psi,psi2,u,v,uz,vz,wz,ssh,sal,temp,sal2,temp2)
#else
   DEALLOCATE(boz,hex,hey,htx,hty,ect,psi,u,v,uz,vz,wz,ssh,sal,temp,sal2,temp2)
#endif
#ifdef key_profil_back
   DEALLOCATE(boz2)
#endif
#ifdef key_casacc
   DEALLOCATE(temp0,uz0,vz0,u0,v0,ssh0)
#endif

#if defined key_siggen || defined key_gencoord
   CALL dealloc_comsiggen
   DEALLOCATE(hzex,hzey)
#endif

#ifdef key_diagdyn
   CALL diagdyn_dealloc
#endif
#ifdef key_wave_qeuler_diag
   CALL wave_diag_qeuler_dealloc
#endif

  END SUBROUTINE DEALLOC
