  SUBROUTINE cas_cylinder

   !&E---------------------------------------------------------------------
   !&E                 ***  ROUTINE cas_cylinder  ***
   !&E
   !&E ** Purpose : definition of a test case for a low salinity cylinder
   !&E
   !&E ** Description :
   !&E
   !&E ** Called by : cas_init
   !&E
   !&E ** External calls :
   !&E
   !&E ** Used ij-arrays : 
   !&E
   !&E ** Modified variables : hx, hy, h0, sal, temp, dy, dhx, dhy, dsigu, dsigw
   !&E                         surf, fisac, gwac, dgac, dfiac, fu, fv, sig, sigw 
   !&E                         tfiusr, tfivsr, goulet, govlet, ig, id, jb, jh 
   !&E                         ssh,u,v,uz,vz
   !&E
   !&E ** Reference :
   !&E
   !&E ** History :
   !&E       !  2005-10-13  Original code
   !&E       !  2008-12  (V. Garnier) shift of sigma values : -1 < sig < 0
   !&E       !  2011-02 (B. Thouvenin) correction for key_subs_part_eqsubdt key
   !&E
   !&E---------------------------------------------------------------------

#include "toolcpp.h"

   !! * Modules used
   USE parameters, ONLY : rsh,rlg,riolg,kmax,ljminm1,ljmaxp2,liminm1,limaxp2
   USE comvars2d, ONLY : fisac,gwac,fu,fv,dtmin,dtmax,dt,halfdt,suffix,l_maxu
   USE comvarp2d, ONLY : sal
   USE comvars3d, ONLY : saliref_lin,kzinit,nzinit
   USE obccombine, ONLY : l_obc_south,l_obc_north,l_obc_west,l_obc_east,l_obc_mars,l_obc_tide
   USE output,  ONLY : pasor
#ifdef key_substance
   USE comsubstance, ONLY : cv_wat,nvpc,nvp,nv_cp,nv_ncp,nv_sorb,nv_dis,nv_fix,nv_dri,nv_int,name_var,nb_var,date_startsub
   USE comsubstance, ONLY : itypv,typart,ws_free_opt,ws_free_min,ws_free_max,ws_hind_opt,ws_free_para
   USE casinit,   ONLY : cas_init_subs,cas_init_subs_disspart
#endif
#if defined key_siggen || defined key_gencoord
   USE comsiggen, ONLY : theta_sig,b_sig,hc
#endif
   USE comdiag,     ONLY : l_diag
   USE casinit,   ONLY : cas_init_param,cas_init_grid,cas_init_bathy, &
                         cas_init_io,cas_init_obc,cas_init_meteo,     &
                         cas_init_visc,cas_init_turb,cas_init_tspar,  &
                         cas_init_progvar,cas_init_misc,cas_init_river

   IMPLICIT NONE

   !! * Arguments

   !! * Local declarations
   CHARACTER(LEN=19) :: date_start,date_end,date_start3d,date_startagrif
   CHARACTER(LEN=19) :: tool_sectodat
   INTEGER           :: i,j,k
   REAL(KIND=rsh)    :: z0bottom,z0surface,depthcst
   REAL(KIND=rsh)    :: dxval,dyval,d
   REAL(KIND=rlg)    :: tool_datosec
#ifdef key_substance
   INTEGER           :: n,isubs
   LOGICAL           :: l_filesubs
#endif

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

   !--------------------------------------------
   !--------------------------------------------
   !! premier  cas_test : cas_cylinder desalle !!
   !--------------------------------------------
   !--------------------------------------------


   ! general parametrization (each parameter can be reassigned)
   ! -----------------------

   ! dynamics
   CALL cas_init_param

   ! over-assignement
   l_maxu=.FALSE.

   ! tracers : among others, saliref=saliref_lin=35.5_rsh, tetaref=tetaref_lin=10.0_rsh
   ! ----------
   CALL cas_init_tspar

   ! over-assignement
   saliref_lin=34.85_rsh


   ! Bathymetry
   ! ----------

   ! assignement : input variables for cas_init_bathy routine
   depthcst = 20.0_rsh
#if defined key_siggen || defined key_gencoord
   hc= 5.0_rsh
#endif

   ! flat bottom, no wall
   CALL cas_init_bathy(depthcst)


   ! grid parametrization
   ! --------------------

   ! assignement : input variables for cas_init_grid routine
   dxval = 1000.0_rsh
   dyval = 1000.0_rsh
   fisac=0.0_riolg
   gwac=0.0_riolg

#if defined key_siggen || defined key_gencoord
   theta_sig= 4.0_rsh ! entre 0 et 20
   theta_sig= 0.0000001_rsh ! entre 0 et 20
   b_sig= 1.0_rsh     ! entre 0 et 1
#endif

   CALL cas_init_grid(dxval,dyval)

   ! over-assignement
   fu(:,:)=0.000115_rsh
   fv(:,:)=0.000115_rsh


   ! IO parametrization
   ! ------------------

   ! assignement : input variables for cas_init_io routine
   date_start=   '01/01/1900 00:00:00'
   date_end=   '10/01/1900 00:00:00'
   date_start3d=  '01/01/1900 00:00:00'
   date_startagrif='01/01/1900 00:00:00'
   dtmin=60.0_rlg
   dtmax=60.0_rlg
   dt=60.0_rlg
   halfdt=dt*0.5_rlg

   suffix='bulle'

   CALL cas_init_io(date_start,date_end,date_start3d,date_startagrif,suffix)

   ! over-assignement
   pasor(1)=3600.0_rlg
   l_diag=.TRUE.


   ! open boundaries
   ! ---------------

   ! no open boundary
   CALL cas_init_obc

   ! over-assignement
   ! geometry (where are the open boundaries ?)
   l_obc_south=.TRUE.
   l_obc_north=.TRUE.
   l_obc_west=.TRUE.
   l_obc_east=.TRUE.
   ! used scheme to manage obc
   l_obc_mars = .TRUE.
   ! physics introduced into the simulated area (tide or ogcm solution)
   l_obc_tide=.TRUE.

   ! viscosity
   !-----------

   ! none
   CALL cas_init_visc


   ! turbulence
   ! ----------

   z0bottom   =1.0e-9
   z0surface  =0.0_rsh
   kzinit=0.0_rsh
   nzinit=1.3e-5

   ! Gaspard parametrization
   CALL cas_init_turb(kzinit,nzinit,z0surface,z0bottom)

   ! over-assignement


   ! meteorology
   ! -----------

   ! no forcing
   CALL cas_init_meteo


   ! River and outflows
   ! -------------------

   ! no river
   CALL cas_init_river


   ! initialization of the pronostic variables
   ! -----------------------------------------

   ! set to 0,tetaref,saliref
   CALL cas_init_progvar

   ! over-assignement

   ! tracers
   DO j=ljminm1,ljmaxp2
     DO i=liminm1,limaxp2
       d=SQRT((REAL(i-19,rsh))**2+(REAL(j-19,rsh))**2)
       DO k=1,kmax
         sal(k,i,j) = 1.1_rsh*(d/3.0_rsh)**8+33.75_rsh
         IF(d >= 3.0_rsh .OR. k < 10) sal(k,i,j) = 33.75_rsh + 1.1_rsh
       END DO
     END DO
   END DO

#ifdef key_substance

   ! main initialization relative to the substances
   ! ----------------------------------------------

   ! assignement : input variables for cas_init_subs routine

   nvpc=1; nvp=1; nv_cp=1; ; nv_ncp=0; nv_sorb=0; nv_dis=2; nv_fix=0; nv_dri=0; nv_int=0
   date_startsub=date_start

   DO isubs = 1,nb_var
     IF (isubs==1) name_var(isubs)='PART'
     IF (isubs==2) name_var(isubs)='DISS1'
     IF (isubs==3) name_var(isubs)='DISS2'
   END DO

   CALL cas_init_subs(date_start)   ! nvp must be defined before

   ! over-assignement

   ! substances
   DO j=ljminm1,ljmaxp2
     DO i=liminm1,limaxp2
       d=SQRT((REAL(i-19,rsh))**2+(REAL(j-19,rsh))**2)
       DO k=1,kmax
         cv_wat(:,k,i,j) = 0.0001_rsh
         cv_wat(:,k,i,j) = d*0.05_rsh
         IF(d <= 4.0_rsh .AND. k > 10) cv_wat(1,k,i,j) = sal(k,i,j)/10.0_rsh
         IF(d <= 4.0_rsh .AND. k > 10) cv_wat(2,k,i,j) = sal(k,i,j)/100.0_rsh
         IF(d <= 4.0_rsh .AND. k > 10) cv_wat(3,k,i,j) = sal(k,i,j)/1000.0_rsh
       END DO
     END DO
   END DO

   ! substances with settling velocities
   ! -----------------------------------
   l_filesubs=.FALSE.
   itypv(1)=3
   typart(1)=1.
   ws_free_opt(1)=0
   ws_free_min(1)=.0005_rsh
   ws_free_max(1)=.0005_rsh
   ws_free_para(1,1)=0.0_rsh
   ws_hind_opt(1)=0

   CALL cas_init_subs_disspart(l_filesubs)

   ! over-assignement
#endif


   ! Miscellaneous
   ! ------------

   ! Domain of calculation
   ! Percent of wet surface on each cell
   CALL cas_init_misc

  END SUBROUTINE cas_cylinder
