  SUBROUTINE cas_obsthydroflume

   !&E---------------------------------------------------------------------
   !&E                 ***  ROUTINE cas_obsthydroflume  ***
   !&E
   !&E ** Purpose : hydrodynamic experimental flume for fine calibration
   !&E              of hydrodynamics in presence of obstructions (vegetation
   !&E              or other).
   !&E
   !&E ** Description : The flume is by default a 2DV flume, 4 m long and 0.215 m
   !&E                  deep. It is forced through a river discharge allowing to 
   !&E                  prescribe a constant velocity without feedbacks with bottom 
   !&E                  friction.
   !&E                  This test-case only required the following CPP keys:
   !&E                  -Dkey_castestriver , -Dkey_obstructions
   !&E                  using -Dkey_dyn_adv_quick and -Dkey_tssub_adv_ultimatequickestmacho
   !&E                  prevent generation of model instabilities at the edges of obstructions patch
   !&E                  You also can use the CPP key : -Dkey_castestobstructions3D
   !&E
   !&E ** Called by : cas_init
   !&E
   !&E ** External calls :
   !&E
   !&E ** Used ij-arrays : 
   !&E
   !&E ** Modified variables :
   !&E
   !&E ** Reference :
   !&E
   !&E ** History :
   !&E       !  2014-07 (F. Ganthy) main code
   !&E       !  2016-09 (F. Ganthy) optimization on Abdelrhman 2007 method
   !&E                              for computation on obstruction height : 
   !&E                              add number of obstruction segment to user-defined
   !&E                              parameters
   !&E       ! 2017-10 (F. Ganthy) Add new cpp keys related to new test-case options
   !&E       ! 2017-10 (F. Ganthy) Some modifications:
   !&E                             - Allowing multiple obstructions type in a single grid cell
   !&E                             - Allowing 3D obstructions
   !&E                             - Add simplified obstructions kind
   !&E       ! 2017-11 (F. Ganthy) Remove useless variables related to turbulence coefficients
   !&E
   !&E---------------------------------------------------------------------

#include "toolcpp.h"

   !! * Modules used
   USE parameters, ONLY : rsh,rlg,riolg,valmanq,kmax,imin,imax,jmin,jmax,lchain,&
                          ljminm1,ljmaxp2,liminm1,limaxp2,liminp1,limin,limax,ljmin,ljmax,&
                          liminm2,ljminm2
   USE comvars2d,  ONLY : fisac,gwac,dtmin,dtmax,dt,halfdt,suffix,fvisc,kx,ky,qmax,iscreenlog,z0b,l_modele2d,l_smagor
   USE comvars3d,  ONLY : nzinit,kzinit,qmaxz,l_stateeq_lin,saliref_lin
#if defined key_siggen || defined key_gencoord
   USE comsiggen, ONLY : theta_sig,b_sig,hc
#endif
   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,                &
#ifdef key_obstructions
                         cas_init_obstructions,                         &
#endif
                         cas_init_river
   USE output,    ONLY : pasor,l_out_sal,l_out_temp,fileresu,tdebsor,tfinsor, &
                         iextmin,iextmax,jextmin,jextmax
   USE toolgeom,  ONLY : f_zu
   USE comvarp2d, ONLY : temp,sal,ssh,u,v
   USE comvars3d, ONLY : tetaref,saliref
   USE comvars2d, ONLY : icon,fu,fv,h0,tobs,out_dir,hminfrot
   USE comvarp3d, ONLY : uz,vz,ect,psi
   USE obccombine,ONLY : l_obc_mars,l_obc_east
   USE comvars2d, ONLY : h0_g,hx_g,hy_g,h0fond,hm,dhj,hrdef,vis2d,vish_xe,vish_phi
   USE comvars3d, ONLY : turb_nbeq,turb_2eq_option,bgdiff
   USE comturb, ONLY   : eps
   USE comdiag, ONLY : l_diag,file_diag,tdebdiag,tfindiag
   USE comfluxdo,  ONLY : nbfl,iriv,jriv,kriv,debmoy,tmfle,amtfle,l_tempriv,l_flestat,river_thickness
#ifdef key_substance
   USE comsubstance
   USE casinit,   ONLY : cas_init_subs,cas_init_subs_disspart,cas_init_outflow,cas_init_subs_budget
#ifdef key_sedim_MUSTANG
   USE parameters, ONLY : ksdmax
   USE comMUSTANG
   USE casinit,  ONLY : cas_init_sedim
   USE sedimorpho,  ONLY : sed_morphoinit
#endif
#endif
#ifdef key_obstructions
   USE obstructions
#endif
   USE comvars2d,ONLY : uforcing

   IMPLICIT NONE

   !! * Local declarations
   CHARACTER(LEN=19) :: date_start,date_end,date_start3d,date_startagrif
   CHARACTER(LEN=19) :: date_startout,date_endout
   CHARACTER(LEN=lchain) :: fileresutmp 
   INTEGER           :: i,j,k,isubs,iv,lnam,iobst
   INTEGER           :: ni_wall_e,ni_wall_w,nj_wall_n,nj_wall_s
   INTEGER           :: IERR_MPI
   REAL(KIND=rsh)    :: dxval,dyval,dzsmaxinit
   REAL(KIND=rsh)    :: z0bottom,z0surface,depthcst,zr
   REAL(KIND=rlg)    :: tool_datosec
   LOGICAL           :: l_filesubs,l_nc4par
#ifdef key_castestobstructions3D
   ! FOR PATCHY DISTRIBUTION
   INTEGER                                 :: nb_patch
   REAL(KIND=rsh)                          :: diam_patch,distp
   REAL(KIND=rsh),DIMENSION(limin:limax)   :: xxp
   REAL(KIND=rsh),DIMENSION(ljmin:ljmax)   :: yyp
   REAL(KIND=rsh),DIMENSION(:),ALLOCATABLE :: xpatch,ypatch
#endif

#if defined key_casobstflume_ganthy2015 || defined key_casobstflume_lefebvre2010
   !! Local declaration for simulation of flume experiments
   CHARACTER(LEN=19)     :: date_end_flume,date_startout_flume
   CHARACTER(LEN=lchain) :: cas,vit,test,fileres
   LOGICAL               :: l_Tsed
   REAL(KIND=rsh)        :: hwat,thick_leaf,rho_leaf,z0pvc,z0samp
   INTEGER               :: IndTest,IndVit,abdel_nmax
#endif
#ifdef key_casobstflume_ganthy2015
   CHARACTER(LEN=lchain),DIMENSION(6) :: Filedistrib
   INTEGER,DIMENSION(6)               :: obst_imin,obst_imax
   REAL(KIND=rsh),DIMENSION(6)        :: Lenght_leaf,Width_leaf,Density_leaf
   REAL(KIND=rsh),DIMENSION(6,4)      :: Uveloc
#else
#ifdef key_casobstflume_lefebvre2010
   CHARACTER(LEN=lchain),DIMENSION(5) :: Filedistrib
   INTEGER,DIMENSION(5)               :: obst_imin,obst_imax
   REAL(KIND=rsh),DIMENSION(5)        :: Lenght_leaf,Width_leaf,Density_leaf
   REAL(KIND=rsh),DIMENSION(5,2)      :: Uveloc
#endif
#endif
#if defined key_casobstflume_ganthy2015 || defined key_casobstflume_lefebvre2010
   !! List des variables a lire dans la namelist (namcas.txt/nam_case)
   NAMELIST/nam_case/cas,vit,test
#endif
   !!----------------------------------------------------------------------
   !! * Executable part
#ifdef key_castestobstructions3D
   PRINT_DBG*, 'enter CAS_OBSTHYDROFLUME3D routine'
#else
     PRINT_DBG*, 'enter CAS_OBSTHYDROFLUME3D routine'
#endif
#if defined key_casobstflume_ganthy2015 || defined key_casobstflume_lefebvre2010
   ! Lecture de la namelist a proprement parler
   !-------------------------------------------
   OPEN(4012,file='namcas.txt',status='old',form='formatted',access='sequential')
   READ(4012,nam_case)
   CLOSE(4012)
   ! Verification de la bonne lecture
   fileres = TRIM(test)//'_'//TRIM(cas)//TRIM(vit)
   WRITE(*,*) 'SIMULATION (CAS/VIT_RESULTS) : ',fileres
   IF (cas.EQ.'Ts') THEN
     l_Tsed = .TRUE.
   ELSE
     l_Tsed = .FALSE.
   ENDIF
#endif
#ifdef key_casobstflume_ganthy2015
   !--------------------------------------------------------------
   ! Attribution des valeurs pour l ensemble des tests et vitesses
   !--------------------------------------------------------------
   date_end_flume      = '01/01/1900 00:02:30'
   date_startout_flume = '01/01/1900 00:02:00'
   abdel_nmax      = 3 
   hwat            = 0.215_rsh
   thick_leaf      = 0.0002_rsh
   rho_leaf        = 625.0_rsh
   z0pvc           = 5E-05 ! mm
   z0samp          = 0.003_rsh ! mm

   Filedistrib(1)  = '../inputs/FILES_OBST/File_repartition_TEST_1.dat'
   Filedistrib(2)  = '../inputs/FILES_OBST/File_repartition_TEST_2.dat'
   Filedistrib(3)  = '../inputs/FILES_OBST/File_repartition_TEST_3.dat'
   Filedistrib(4)  = '../inputs/FILES_OBST/File_repartition_TEST_4.dat'
   Filedistrib(5)  = '../inputs/FILES_OBST/File_repartition_TEST_5.dat'
   Filedistrib(6)  = '../inputs/FILES_OBST/File_repartition_TEST_5.dat'
   obst_imin(1)    = 36
   obst_imin(2)    = 36
   obst_imin(3)    = 36
   obst_imin(4)    = 36
   obst_imin(5)    = 36
   obst_imin(6)    = 36
   obst_imax(1)    = 53
   obst_imax(2)    = 53
   obst_imax(3)    = 53
   obst_imax(4)    = 53
   obst_imax(5)    = 53
   obst_imax(6)    = 53
   Lenght_leaf(1)  = 0.056_rsh
   Lenght_leaf(2)  = 0.072_rsh
   Lenght_leaf(3)  = 0.076_rsh
   Lenght_leaf(4)  = 0.063_rsh
   Lenght_leaf(5)  = 0.150_rsh
   Lenght_leaf(6)  = 0.150_rsh
   Width_leaf(1)   = 0.00056_rsh
   Width_leaf(2)   = 0.00058_rsh
   Width_leaf(3)   = 0.00063_rsh
   Width_leaf(4)   = 0.00082_rsh
   Width_leaf(5)   = 0.00121_rsh
   Width_leaf(6)   = 0.00121_rsh
   Density_leaf(1) = 26650.0_rsh
   Density_leaf(2) = 34190.0_rsh
   Density_leaf(3) = 42540.0_rsh
   Density_leaf(4) = 80940.0_rsh
   Density_leaf(5) = 51080.0_rsh
   Density_leaf(6) = 51080.0_rsh
   Uveloc(1,1)     = 0.0866_rsh
   Uveloc(1,2)     = 0.1723_rsh
   Uveloc(1,3)     = 0.2763_rsh
   Uveloc(1,4)     = 0.3758_rsh
   Uveloc(2,1)     = 0.0851_rsh
   Uveloc(2,2)     = 0.1804_rsh
   Uveloc(2,3)     = 0.2766_rsh
   Uveloc(2,4)     = 0.3739_rsh
   Uveloc(3,1)     = 0.0865_rsh
   Uveloc(3,2)     = 0.1829_rsh
   Uveloc(3,3)     = 0.2782_rsh
   Uveloc(3,4)     = 0.3782_rsh
   Uveloc(4,1)     = 0.0877_rsh
   Uveloc(4,2)     = 0.1806_rsh
   Uveloc(4,3)     = 0.2730_rsh
   Uveloc(4,4)     = 0.3700_rsh
   Uveloc(5,1)     = 0.0856_rsh
   Uveloc(5,2)     = 0.1774_rsh
   Uveloc(5,3)     = 0.2782_rsh
   Uveloc(5,4)     = 0.3822_rsh
   Uveloc(6,1)     = 0.0840_rsh
   Uveloc(6,2)     = 0.1772_rsh
   Uveloc(6,3)     = 0.2721_rsh
   Uveloc(6,4)     = 0.3664_rsh
#else
#ifdef key_casobstflume_lefebvre2010
   date_end_flume      = '01/01/1900 00:06:00'
   date_startout_flume = '01/01/1900 00:05:30'
   abdel_nmax      = 6
   hwat            = 0.4_rsh
   thick_leaf      = 0.001_rsh
   rho_leaf        = 700.0_rsh
   z0pvc           = 5E-05 ! mm
   z0samp          = 0.003_rsh ! mm

   Filedistrib(1)  = '../inputs/FILES_OBST/Marina_repartition_0.dat'
   Filedistrib(2)  = '../inputs/FILES_OBST/Marina_repartition_0.dat'
   Filedistrib(3)  = '../inputs/FILES_OBST/Marina_repartition_0.dat'
   Filedistrib(4)  = '../inputs/FILES_OBST/Marina_repartition_0.dat'
   Filedistrib(5)  = '../inputs/FILES_OBST/Marina_repartition_0.dat'
   obst_imin(1)    = 26
   obst_imin(2)    = 26
   obst_imin(3)    = 26
   obst_imin(4)    = 26
   obst_imin(5)    = 26
   obst_imax(1)    = 56
   obst_imax(2)    = 46
   obst_imax(3)    = 46
   obst_imax(4)    = 36
   obst_imax(5)    = 36
   Lenght_leaf(1)  = 0.284_rsh
   Lenght_leaf(2)  = 0.284_rsh
   Lenght_leaf(3)  = 0.284_rsh
   Lenght_leaf(4)  = 0.284_rsh
   Lenght_leaf(5)  = 0.284_rsh
   Width_leaf(1)   = 0.004_rsh
   Width_leaf(2)   = 0.004_rsh
   Width_leaf(3)   = 0.004_rsh
   Width_leaf(4)   = 0.004_rsh
   Width_leaf(5)   = 0.004_rsh
   Density_leaf(1) = 3300.0_rsh
   Density_leaf(2) = 3300.0_rsh
   Density_leaf(3) = 1980.0_rsh
   Density_leaf(4) = 3300.0_rsh
   Density_leaf(5) = 3300.0_rsh
   Uveloc(1,1)     = 0.1_rsh
   Uveloc(1,2)     = 0.2_rsh
   Uveloc(2,1)     = 0.1_rsh
   Uveloc(2,2)     = 0.2_rsh
   Uveloc(3,1)     = 0.1_rsh
   Uveloc(3,2)     = 0.2_rsh
   Uveloc(4,1)     = 0.1_rsh
   Uveloc(4,2)     = 0.2_rsh
   Uveloc(5,1)     = 0.1_rsh
   Uveloc(5,2)     = 0.2_rsh
#endif
#endif
#if defined key_casobstflume_ganthy2015 || defined key_casobstflume_lefebvre2010
   !---------------------------------------------------
   ! Attribution des indices du cas lu dans la namelist
   !---------------------------------------------------
   IF(cas.EQ.'T1') THEN ! TEST 1
     IndTest = 1
   ELSEIF(cas.EQ.'T2') THEN ! TEST 2
     IndTest = 2
   ELSEIF(cas.EQ.'T3') THEN ! TEST 3
     IndTest = 3
   ELSEIF(cas.EQ.'T4') THEN ! TEST 4
     IndTest = 4
   ELSEIF(cas.EQ.'T5') THEN ! TEST 5
     IndTest = 5
   ELSEIF(cas.EQ.'Ts')THEN
     IndTest = 6
     l_Tsed  = .TRUE.
   ENDIF
   IF(vit.EQ.'V1')THEN ! V1
     IndVit = 1
   ELSEIF(vit.EQ.'V2')THEN ! V2
     IndVit = 2
   ELSEIF(vit.EQ.'V3')THEN ! V3
     IndVit = 3
   ELSEIF(vit.EQ.'V4')THEN ! V3
     IndVit = 4
   ENDIF
#endif

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

   ! dynamics
   CALL cas_init_param

   ! over-assignement
   l_modele2d = .FALSE.

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

   ! over-assignement
   kx    = 1.0_rsh
   ky    = 1.0_rsh
   qmax  = 8.0_rsh
   qmaxz = 10.0_rsh
   IF(l_modele2d) THEN
     icon=0
   ELSE
     icon=2
   ENDIF
   saliref = 35.50_rsh
   tetaref = 10.0_rsh
   l_stateeq_lin=.FALSE.
   saliref_lin=saliref

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

   ! assignement : input variables for cas_init_bathy routine
   ni_wall_w = 2  ! land over ni_wall_w cells
   nj_wall_s = 2  ! land over nj_wall_s cells (from jmin row) at the southern part of the domain
   nj_wall_n = 1  ! land over nj_wall_n cells at the northern part of the domain
#if defined key_siggen || defined key_gencoord
   theta_sig = 4.0_rsh ! entre 0 et 20
   b_sig     = 0.750_rsh ! entre 0 et 1    
   hc        = 5.0_rsh
#endif
   h0fond   = 0.01_rsh
   hm       = 0.01_rsh
#ifdef key_castestobstructions3D
   depthcst = 1.0_rsh
#else
#if defined key_casobstflume_ganthy2015 || defined key_casobstflume_lefebvre2010
   depthcst = hwat
#else
   depthcst = 1.0_rsh
#endif
#endif
   dhj      = 0.1

   CALL cas_init_bathy(depthcst,nj_wall_n=nj_wall_n,nj_wall_s=nj_wall_s,ni_wall_w=ni_wall_w)

   ! over_assignement
#if defined key_castestmorpho && defined key_sedim_MUSTANG
   l_morphocoupl=.FALSE.
#endif

   ! Grid parametrization
   ! --------------------

   ! assignement : input variables for cas_init_grid routine
#ifdef key_castestobstructions3D
# if defined key_casobstflume3D_Test01_LD || defined key_casobstflume3D_Test02_HD
   dxval = 1.0_rsh
   dyval = 1.0_rsh
#else
   dxval = 0.1_rsh
   dyval = 0.1_rsh
#endif
#else
#ifdef key_casobstflume2D_Test07_Multi
   dxval = 0.2_rsh
   dyval = 0.2_rsh
#else
   dxval = 0.05_rsh
   dyval = 0.05_rsh
#endif
#endif
   fisac = 0.0_riolg
   gwac  = 0.0_riolg
   CALL cas_init_grid(dxval,dyval)

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


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

   ! assignement : input variables for cas_init_io routine
   date_start      =  '01/01/1900 00:00:00'
#ifdef key_substance
   date_end        = '01/01/1900 01:00:00'
#else
#if defined key_casobstflume_ganthy2015 || defined key_casobstflume_lefebvre2010
   date_end        = date_end_flume
#else
#ifdef key_casobstflume2D_Test07_Multi
   date_end        = '01/01/1900 00:04:00'
#else
#if defined key_casobstflume3D_Test01_LD || defined key_casobstflume3D_Test02_HD
   date_end        = '01/01/1900 00:30:00'
#else
   date_end        = '01/01/1900 00:02:30'
#endif
#endif
#endif
#endif
   date_start3d    = '01/01/1900 00:00:00'
   date_startagrif = '01/01/1900 00:00:00'
#ifdef key_castestobstructions3D
#if defined key_casobstflume3D_Test01_LD || defined key_casobstflume3D_Test02_HD
   dtmin  = 0.25_rlg
   dtmax  = 0.25_rlg
   dt     = 0.25_rlg
#ifdef key_casobstflume3D_Test01_LD
   suffix = 'obsthydroflume3d_Test01LD'
#endif
#ifdef key_casobstflume3D_Test02_HD
   suffix = 'obsthydroflume3d_Test02HD'
#endif
#else
   dtmin  = 0.005_rlg
   dtmax  = 0.005_rlg
   dt     = 0.005_rlg
   suffix = 'obsthydroflume3d'
#endif
#else
   dtmin  = 0.002_rlg
   dtmax  = 0.002_rlg
   dt     = 0.002_rlg
#if defined key_casobstflume_ganthy2015 || defined key_casobstflume_lefebvre2010
   suffix = fileres
#else
   suffix = 'obsthydroflume2dv'
   ! If specific test-cases, overwrite suffix
#ifdef key_casobstflume2D_Test01_RU
   suffix = 'obsthydroflume2dv_Test01_RU'
#endif
#ifdef key_casobstflume2D_Test02_RD
   suffix = 'obsthydroflume2dv_Test02_RD'
#endif
#ifdef key_casobstflume2D_Test03_FUP
   suffix = 'obsthydroflume2dv_Test03_FUP'
#endif
#ifdef key_casobstflume2D_Test04_FDP
   suffix = 'obsthydroflume2dv_Test04_FDP'
#endif
#ifdef key_casobstflume2D_Test05_FUA
   suffix = 'obsthydroflume2dv_Test05_FUA'
#endif
#ifdef key_casobstflume2D_Test06_3DO
   suffix = 'obsthydroflume2dv_Test06_3DO'
#endif
#ifdef key_casobstflume2D_Test07_Multi
   suffix = 'obsthydroflume2dv_Test07_Multi'
#endif
#endif
#endif
   halfdt=dt*0.5_rlg

#ifdef key_substance
   date_startsub='01/01/1900 00:05:00'
   tdebsubs=tool_datosec(date_startsub)
#ifdef key_sedim_MUSTANG
   ! consolidation only if  l_consolid=.true.  or l_diffused or l_bioturb
   date_start_sed=date_start
   tstart_sed=tool_datosec(date_start_sed)
   tstart_sed=MAX(tstart_sed,tdebsubs)
   t_sed=tstart_sed
   dt_sed=500.0_rlg
#endif
#endif
   l_nc4par = .TRUE.
   CALL cas_init_io(date_start,date_end,date_start3d,date_startagrif,suffix,l_nc4par)

   ! over-assignement
   iextmin(1) = imin
   iextmax(1) = imax
#ifdef key_castestobstructions3D
   jextmin(1) = jmin
   jextmax(1) = jmax
#else
   jextmin(1) = 2
   jextmax(1) = 2
#endif
#ifdef key_substance
   pasor(1)   = 10.0_rlg
#else
#ifdef key_castestobstructions3D
   pasor(1)   = 30.0_rlg
#else
   pasor(1)   = 5.0_rlg
#endif
#endif
   tobs       = 2.0_rlg*3600.0_rlg
   out_dir    = './'

! Name of results file :
! =========================================
#ifndef key_casobstflume_ganthy2015
#ifndef key_casobstflume_lefebvre2010
#ifndef key_casobstflume2D_Test01_RU
#ifndef key_casobstflume2D_Test02_RD
#ifndef key_casobstflume2D_Test03_FUP
#ifndef key_casobstflume2D_Test04_FDP
#ifndef key_casobstflume2D_Test05_FUA
#ifndef key_casobstflume2D_Test06_3DO
#ifndef key_casobstflume2D_Test07_Multi
#ifndef key_casobstflume3D_Test01_LD
#ifndef key_casobstflume3D_Test02_HD
   fileresu(1) = 'results.nc'
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
! =========================================
#if defined key_casobstflume_ganthy2015 || defined key_casobstflume_lefebvre2010
   date_startout = date_startout_flume
#else
   fileresu(1)   = TRIM(out_dir)//TRIM(fileresu(1))
   date_startout = '01/01/1900 00:00:00'
#endif
   date_endout   = date_end
   tdebsor(1)    = tool_datosec(date_startout)
   tfinsor(1)    = tool_datosec(date_endout)
   l_diag        = .FALSE.

   ! Open boundaries
   ! ---------------

   ! no open boundary
   CALL cas_init_obc

   ! over-assignement
   ! geometry (where are the open boundaries ?)
   l_obc_east = .TRUE. 
   ! used scheme to manage obc
   l_obc_mars = .TRUE.


   ! Viscosity  (none by default)
   !-----------

   ! none
   CALL cas_init_visc

   ! over-assignement
   l_smagor        = .TRUE.
   fvisc           = 1.0_rsh
   vis2d(:,:)      = fvisc*0.01_rsh*dyval**1.15_rsh
   vish_xe(:,:,:)  = fvisc*0.01_rsh*dyval**1.15_rsh
   vish_phi(:,:,:) = fvisc*0.01_rsh*dyval**1.15_rsh

   ! Turbulence
   ! ----------
#if defined key_casobstflume_ganthy2015 || defined key_casobstflume_lefebvre2010
   z0bottom  = z0pvc/1000.0_rsh
#else
   z0bottom  = 0.00005_rsh
#endif
   z0surface = 0.00005_rsh
   IF (l_modele2d) THEN
     nzinit    = 0.0001_rsh
     kzinit    = 0.0001_rsh
   ELSE
     nzinit    = 0.0001_rsh
     kzinit    = 0.0001_rsh
   ENDIF
   
   CALL cas_init_turb(kzinit,nzinit,z0surface,z0bottom)

   ! over-assignement
   IF(.NOT.l_modele2d) THEN
     bgdiff          = 0.000001_rsh
     turb_nbeq       = 2
     turb_2eq_option = 2
     hminfrot        = 0.001_rsh
     ect(:,:,:)      = 1.0e-8
     psi(:,:,:)      = 1.0e-12
     eps(:,:,:)      = 1.0e-12
   ENDIF

   ! Meteorology (none by default)
   ! -----------

   ! no forcing
   CALL cas_init_meteo

   ! Initialization of the pronostic variables
   ! -----------------------------------------

   ! set to 0,tetaref,saliref
   CALL cas_init_progvar

   ! over-assignement
   IF(.NOT.l_modele2d) THEN
     sal(:,:,:)  = 0.0_rsh
     temp(:,:,:) = 15.0_rsh
     WHERE( h0(liminm2:limaxp2,ljminm2:ljmaxp2)==-valmanq ) ssh(liminm2:limaxp2,ljminm2:ljmaxp2)=valmanq
     DO k=1,kmax
       WHERE( h0(liminm1:limaxp2,ljminm1:ljmaxp2)==-valmanq ) sal(k,liminm1:limaxp2,ljminm1:ljmaxp2)=valmanq
       WHERE( h0(liminm1:limaxp2,ljminm1:ljmaxp2)==-valmanq ) temp(k,liminm1:limaxp2,ljminm1:ljmaxp2)=valmanq
     END DO 
   ENDIF
#if defined key_casobstflume_ganthy2015 || defined key_casobstflume_lefebvre2010
   uforcing    = Uveloc(IndTest,IndVit)
#else
   uforcing    = 0.5_rsh ! (m.s-1) depth averaged velocity for initialization and used to compute river discharge
#endif

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

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


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

   ! assignement : input variables for cas_init_subs routine



   ! Substances
   !--------------
#ifdef key_substance
   nv_grav=0
   nv_sand=1
   nv_mud=1
   nv_cp=0
   nv_ncp=0
   nv_sorb=0
   nv_dis=0
   nv_fix=0
   nv_dri=0
   nv_int=0
   isubs=1
   name_var(isubs)='sable_fin'
   unit_var(isubs)='kg.m-3'
   isubs=2
   name_var(isubs)='vase'
   unit_var(isubs)='kg.m-3'

   nvpc=nv_cp+nv_mud+nv_sand+nv_grav
   nvp=nvpc+nv_ncp+nv_sorb
   name_filesubs = 'bidon'
   l_filesubs=.FALSE.

   IF(.NOT.l_filesubs) THEN
   ! allocation et initialisation des tableaux cv_wat,f90,t90...
     CALL cas_init_subs(date_start,date_startsub)   ! nvp must be defined before
   ELSE
     CALL cas_init_subs_budget(date_start)
   ENDIF
   ! over-assignement
   l_bilan=.TRUE.
   dtout_budget=1.00_rlg

!===========================DEFINITION DES VARIABLES======================================
! first variable (sable fin)
!-----------------
   itypv(1) = 2 
   typart(1)=1.
   ws_free_opt(1)=0
   ws_free_min(1)=.005_rsh
   ws_free_max(1)=.005_rsh
   ws_free_para(1,1)=0.0_rsh
   ws_free_para(2,1)=0.0_rsh
   ws_free_para(3,1)=0.0_rsh
   ws_free_para(4,1)=0.0_rsh
   ws_hind_opt(1)=0
   ws_hind_para(1,1)=.0_rsh
   ws_hind_para(2,1)=.0_rsh
   tocd(1)=100.0_rsh
   t90(1)=0.0_rsh
   sub_flx_atm(1)=0.0_rsh
   cv_rain(1)=0.0_rsh
   cv_wat(1,:,:,:) = cini_wat(1)
   obc_cv_wat_w(1,:,:,:)=cini_wat(1)

! second variable (vase)
!-----------------------
   itypv(2) = 3
   typart(2)=1.
   ws_free_opt(2)=0
   ws_free_min(2)=.0005_rsh
   ws_free_max(2)=.0005_rsh
   ws_free_para(1,2)=0.0_rsh
   ws_free_para(2,2)=0.0_rsh
   ws_free_para(3,2)=0.0_rsh
   ws_free_para(4,2)=0.0_rsh
   ws_hind_opt(2)=0
   ws_hind_para(1,2)=.0_rsh
   ws_hind_para(2,2)=.0_rsh
   tocd(2)=100.0_rsh
   t90(2)=0.0_rsh
   sub_flx_atm(2)=0.0_rsh
   cv_rain(2)=0.0_rsh
   cv_wat(2,:,:,:) = cini_wat(2)
   obc_cv_wat_w(2,:,:,:)=cini_wat(2)
!================================ FIN DEFINITION DES VARIABLES =====================

   ! si il existe des variables particulaires 
   IF (nvp>0) THEN

      CALL cas_init_subs_disspart(l_filesubs)

   ! over-assignement
#if defined key_castestsable || defined key_castestsablovase || defined key_castestsub
#ifdef key_sand2D
      l_subs2D(1)=.true.
      l_outsandrouse(1)=.true.
#endif
#endif

      DO j=ljminm1,ljmaxp2
        DO i=liminm1,limaxp2
          IF (h0(i,j) > -valmanq) THEN
    !        DO k=1,kmax
    !          zr=-f_zu(h0(i,j),0.0_rsh,k,i,j)
    !          cv_wat(1,k,i,j)= 0.1 - 0.00001_rsh/(9.81_rsh*0.0016)*zr
    !          cv_wat(2,k,i,j)= 50. - 0.001_rsh/(9.81_rsh*0.0016)*zr
     !        cv_wat(:,k,i,j) = cini_wat(:)
     !       END DO

          ELSE
             cv_wat(:,:,i,j) = valmanq
          END IF
        END DO
       END DO

    ! obligation de definir les ros et diam des particules apres l appel a cas_init_subs_disspart dans lasuelle ces variable sont allouees
    ! vase ne se sert pas du diametre mais il ne doit pas etre nul et il se sert de ros
#ifdef key_sedim_MUSTANG
     !First : sable fin
     ros(1)=2600.0_rsh
     diam_sed(1)=0.0001_rsh
     !Second : mud
     ros(2)=2600.0_rsh
     diam_sed(2)=0.0001_rsh
#endif
   ENDIF
#endif

   ! River and outflows
   ! -------------------
#ifdef key_casobstflume_river
#ifdef key_castestobstructions3D
   nbfl=jmax
#else
   nbfl=1
#endif
   CALL cas_init_river(nbfl)

   ! over-assignement
   iriv(1)=2
#ifdef key_castestobstructions3D
   iriv(:)=2
   DO j=jmin,jmax
     jriv(j)=j
   ENDDO
   IF(l_modele2d) THEN
     kriv(:) = 1
   ELSE
     kriv(:) = 1
   ENDIF
   river_thickness(:)= -1.0_rsh
   debmoy(:)=dyval*depthcst*uforcing
   tmfle(:)=15.0_rsh
   amtfle(:)=0.0_rsh
#else
   jriv(1)=2
   IF(l_modele2d) THEN
     kriv(:) = 1
   ELSE
     kriv(1) = 1
   ENDIF
   river_thickness(1)= -1.0_rsh
   debmoy(1)=dyval*depthcst*uforcing
   tmfle(1)=15.0_rsh
   amtfle(1)=0.0_rsh 
#endif

#ifdef key_substance
#ifdef key_sedim_MUSTANG 
   nbrej=2
   CALL cas_init_outflow

   nucon(1)=1
   nucon(2)=2
   valrej(:,1) = 0.1_rsh
   valrej(:,2) = 0.3_rsh
#endif

#endif
#endif

#ifdef key_sedim_MUSTANG
   ! Initialization of sedimentary parameters
   ! ----------------------------------------
   ! pre-assignement
   l_consolid = .FALSE.
   hseduni = 0.1_rsh
   ksmiuni = 1
   ksmauni = 2
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! ATTTENTION !!!
!!!!!!!!!!!!!!!!!!
!  the total concentration is given as an input, and the contribution
!                 of each variable (cini_sed(iv)) is given as a fraction of c_sedtot 
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   cseduni = 1508.0_rsh
   c_sedtot(:,:,:)=cseduni
   cini_sed(1)=0.2_rsh
   cini_sed(2)=0.8_rsh
   dzsmaxinit=10.0_rsh

! sediment output sur toutes les couches ---option 1---
   nk_nivsed_out=ksdmax
   ep_nivsed_out(:)=0.0_rsh
   ! Initialization of sediment layers
   ! ---------------------------------
   CALL cas_init_sedim(l_filesubs,dzsmaxinit=dzsmaxinit)

   ! over-assignement
   dzsmin = 1.0e-5
   cfreshmud = 400.0_rsh

#if defined key_castestmorpho && defined key_sedim_MUSTANG
! could be different from the default (equal to 0) if morpho using
   htncrit_eros=0.0_rsh
#endif
   IF(l_morphocoupl) CALL sed_morphoinit

! test sortie des couches 
!   dzsmaxuni = 0.02_rsh

#endif
        ! fin sedim




   ! Obstructions
   !--------------
#ifdef key_obstructions
   ! Number of obstruction variables
#ifdef key_casobstflume2D_Test07_Multi
   obst_nbvar = 4
#else
#if defined key_casobstflume3D_Test01_LD || defined key_casobstflume3D_Test02_HD
   obst_nbvar = 3
#else
   obst_nbvar = 1
#endif
#endif
   CALL obst_alloc_nbvar
   ! Initialisation of each obstruction variables (the following lines should be repeated for 
   ! each variable
   ! FIRST VARIABLE
   iobst=1
   obst_varnum(iobst)               = iobst             ! * (1)  VARIABLE NUMBER
   obst_varname(iobst)              = 'Obstruc'         ! * (2)  VARIABLE NAME
   l_obst_flexible(iobst)           = .FALSE.           ! * (3)  VARIABLE IS RIGID OR FLEXIBLE
   l_obst_downward(iobst)           = .FALSE.           ! * (4)  VARIABLE IS UPWARD OR DOWNWARD
   l_obst_cylindre(iobst)           = .FALSE.           ! * (5)  LOGICAL FOR SHAPE OF OBSTRUCTIONS
   l_obst_3dobst(iobst)             = .FALSE.           ! * (6)  LOGICAL FOR FULL 3D OBSTRUCTIONS
   l_obst_noturb(iobst)             = .FALSE.           ! * (7)  LOGICAL FOR USE SIMPLIFIED FORMULATION (Z0)
   l_obst_filechar(iobst)           = .FALSE.           ! * (8)  LOGICAL FOR USE OF TEMPORAL OBSTRUCTION CHARACTERISTICS
   obst_fn_char(iobst)              = './'              ! * (9)  FILENAME FOR TEMPORAL OBSTRUCTION CHARACTERISTICS
   l_obst_filedistri(iobst)         = .FALSE.           ! * (10)  LOGICAL FOR USE A FILE FOR VERTICAL DISTRIBUTION OF OBSTRUCTIONS
   obst_fn_distrib(iobst)           = './'              ! * (11)  FILENAME FOR VERTICAL DISTRIBUTION FILE
   l_obst_fracxy(iobst)             = .FALSE.           ! * (12) LOGICAL TO TAKE ACCOUNT FOR COVERAGE CORRECTION WITHIN GRID CELL
   obst_fracxy_type(iobst)          = 2                 ! * (13) INTEGER FOR THE TYPE OF COVERAGE CORRECTION
   obst_c_fracxy_k0(iobst)          = 6.0_rsh           ! * (14) FIRST PARAMETER FOR COVERAGE CORRECTION (TYPE=1 or TYPE=2)
   obst_c_fracxy_k1(iobst)          = 12.0_rsh          ! * (15) SECOND PARAMETER FOR COVERAGE CORRECTION (TYPE=2)
   obst_c_fracxy_l(iobst)           = 3.5_rsh           ! * (16) THIRD PARAMETER FOR COVERAGE CORRECTION (TYPE=2)
   obst_i_height(iobst)             = 0.15_rsh          ! * (17) INITIAL OBSTRUCTION HEIGHT
   obst_i_width(iobst)              = 0.001_rsh         ! * (18) INITIAL OBSTRUCTION WIDTH
   obst_i_thick(iobst)              = 0.0002_rsh        ! * (19) INITIAL OBSTRUCTION THICKNESS
   obst_i_dens(iobst)               = 40000.0_rsh       ! * (20) INITIAL OBSTRUCTION DENSITY
   l_obst_abdelposture(iobst)       = .FALSE.           ! * (21) USE ABDELRHMAN 2007 METHOD FOR OBSTRUCTION POSTURE
   obst_i_abdel_nmax(iobst)         = 5                 ! * (22) NUMBER OF OBSTRUCTION HEIGHT DISCRETIZATION FOR ABDELRHMAN 2007 METHOD
   obst_i_rho(iobst)                = 650.0_rsh         ! * (23) INITIAL OBSTRUCTION VOLUMETRIC MASS
   l_obst_param_height(iobst)       = .FALSE.           ! * (24) USE PARAMETERIZATION (FROM VELOCITY) FOR FLEXIBLE OBSTRUCTION HEIGHT
   obst_c_height_x0(iobst)          = 0.99_rsh          ! * (25) FIRST COEFFICIENT FOR OBSTRUCTION HEIGHT
   obst_c_height_x1(iobst)          = -3.92_rsh         ! * (26) SECOND COEFFICIENT FOR OBSTRUCTION HEIGHT
   l_obst_drag_cste(iobst)          = .TRUE.            ! * (27) USE CONSTANT DRAG COEFFICIENT
   obst_i_drag(iobst)               = 1.5_rsh           ! * (28) DRAG COEFFICIENT FOR OBSTRUCTION
   obst_i_lift(iobst)               = 0.0_rsh           ! * (29) LIFT COEFFICIENT FOR OBSTRUCTIONS
   obst_c_shelter(iobst)            = 100.0_rsh         ! * (30) SCALING FACTOR FOR SHELETERING COEFFICIENT
   obst_c_lz(iobst)                 = 0.1_rsh           ! * (31) FORM COEFFICIENT FOR DISSIPATION TIME-SCALE WITHIN OBSTRUCTIONS
   l_obst_z0bstress(iobst)          = .TRUE.            ! * (32) IMPACT OF OBSTRUCTIONS ON SEDIMENTOLOGICAl ROUGHNESS LENGTH
   l_obst_z0bstress_strick(iobst)   = .FALSE.           ! * (33) USE OF Z0 CORRECTION FROM STRICKLER COEFFICIENT
   l_obst_z0bstress_param3d(iobst)  = .FALSE.           ! * (34) USE OF Z0 CORRECTION FROM PARAMETERIZATION FOR 3D FORMULATIONS
   obst_i_z0bstress3d(iobst)        = 0.0012_rsh        ! * (35) INITIAL VALUE FOR SEDIMENTOLOGICAL ROUGHNESS LENGTH
   obst_c_z0bstress3d_x0(iobst)     = 0.0011_rsh        ! * (36) FIRST PARAMETER FOR ROUGHNESS LENGTH PARAMETERIZATION FOR 3D FORMULATIONS
   obst_c_z0bstress3d_x1(iobst)     = 0.2974_rsh        ! * (37) SECOND PARAMETER FOR ROUGHNESS LENGTH PARAMETERIZATION FOR 3D FORMULATIONS
   l_obst_z0bstress_param2dh(iobst) = .FALSE.           ! * (38) USE OF Z0 CORRECTION FROM PARAMETERIZATION FOR 2Donly FORMULATIONS
   obst_i_z0bstress2dh(iobst)       = 0.0042_rsh        ! * (39) INITIAL VALUE FOR SEDIMENTOLOGICAL ROUGHNESS LENGTH FOR 2D FORMULATIONS
   obst_c_z0bstress2dh_x0(iobst)    = 0.0001_rsh        ! * (40) FIRST PARAMETER FOR ROUGHNESS LENGTH PARAMETERIZATION FOR 2D FORMULATIONS
   obst_c_z0bstress2dh_x1(iobst)    = -1.3348_rsh       ! * (41) SECOND PARAMETER FOR ROUGHNESS LENGTH PARAMETERIZATION FOR 2D FORMULATIONS
   ! END of Initialization of first obstruction variable

   ! ************************************************************* !
   ! *** OVERWRITE SOME VARIABLES FOR SOME SPECIFIC TEST-CASES *** !
   ! ************************************************************* !
   ! *** FLUME EXPERIMENTS on Zostera noltei, Ganthy et al., 2015 (Sedimentology)
#ifdef key_casobstflume_ganthy2015
   iobst = 1
   obst_varname(iobst)              = 'Z.noltei'            ! * (2)  VARIABLE NAME
   l_obst_flexible(iobst)           = .TRUE.                ! * (3)  VARIABLE IS RIGID OR FLEXIBLE
   l_obst_filedistri(iobst)         = .TRUE.                ! * (10)  LOGICAL FOR USE A FILE FOR VERTICAL DISTRIBUTION OF OBSTRUCTIONS
   obst_fn_distrib(iobst)           = Filedistrib(IndTest)  ! * (11)  FILENAME FOR VERTICAL DISTRIBUTION FILE
   obst_i_height(iobst)             = Lenght_leaf(IndTest)  ! * (17) INITIAL OBSTRUCTION HEIGHT
   obst_i_width(iobst)              = Width_leaf(IndTest)   ! * (18) INITIAL OBSTRUCTION WIDTH
   obst_i_thick(iobst)              = thick_leaf            ! * (19) INITIAL OBSTRUCTION THICKNESS
   obst_i_dens(iobst)               = Density_leaf(IndTest) ! * (20) INITIAL OBSTRUCTION DENSITY  
   l_obst_abdelposture(iobst)       = .TRUE.                ! * (21) USE ABDELRHMAN 2007 METHOD FOR OBSTRUCTION POSTURE
   l_obst_param_height(iobst)       = .FALSE.               ! * (24) USE PARAMETERIZATION (FROM VELOCITY) FOR FLEXIBLE OBSTRUCTION HEIGHT
   obst_i_abdel_nmax(iobst)         = abdel_nmax            ! * (22) NUMBER OF OBSTRUCTION HEIGHT DISCRETIZATION FOR ABDELRHMAN 2007 METHOD
   obst_i_rho(iobst)                = rho_leaf              ! * (23) INITIAL OBSTRUCTION VOLUMETRIC MASS
#endif
   ! *** FLUME EXPERIMENTS on Zostera marina, Lefebvre et al., 2010 (Continental Shelf Research)
#ifdef key_casobstflume_lefebvre2010
   iobst = 1
   obst_varname(iobst)              = 'Z.marina'            ! * (2)  VARIABLE NAME
   l_obst_flexible(iobst)           = .TRUE.                ! * (3)  VARIABLE IS RIGID OR FLEXIBLE
   l_obst_filedistri(iobst)         = .TRUE.                ! * (10)  LOGICAL FOR USE A FILE FOR VERTICAL DISTRIBUTION OF OBSTRUCTIONS
   obst_fn_distrib(iobst)           = Filedistrib(IndTest)  ! * (11)  FILENAME FOR VERTICAL DISTRIBUTION FILE
   obst_i_height(iobst)             = Lenght_leaf(IndTest)  ! * (17) INITIAL OBSTRUCTION HEIGHT
   obst_i_width(iobst)              = Width_leaf(IndTest)   ! * (18) INITIAL OBSTRUCTION WIDTH
   obst_i_thick(iobst)              = thick_leaf            ! * (19) INITIAL OBSTRUCTION THICKNESS
   obst_i_dens(iobst)               = Density_leaf(IndTest) ! * (20) INITIAL OBSTRUCTION DENSITY  
   l_obst_abdelposture(iobst)       = .TRUE.                ! * (21) USE ABDELRHMAN 2007 METHOD FOR OBSTRUCTION POSTURE
   l_obst_param_height(iobst)       = .FALSE.               ! * (24) USE PARAMETERIZATION (FROM VELOCITY) FOR FLEXIBLE OBSTRUCTION HEIGHT
   obst_i_abdel_nmax(iobst)         = abdel_nmax            ! * (22) NUMBER OF OBSTRUCTION HEIGHT DISCRETIZATION FOR ABDELRHMAN 2007 METHOD
   obst_i_rho(iobst)                = rho_leaf              ! * (23) INITIAL OBSTRUCTION VOLUMETRIC MASS
#endif
   ! *** TEST-CASE (USED BY CHAIN VALID): Test01 - Rigid Upward obstruction
#ifdef key_casobstflume2D_Test01_RU
   iobst = 1
   obst_varname(iobst)              = 'RigidUp'             ! * (2)  VARIABLE NAME
   l_obst_flexible(iobst)           = .FALSE.               ! * (3)  VARIABLE IS RIGID OR FLEXIBLE
   l_obst_downward(iobst)           = .FALSE.               ! * (4)  VARIABLE IS UPWARD OR DOWNWARD
   l_obst_3dobst(iobst)             = .FALSE.               ! * (6)  LOGICAL FOR FULL 3D OBSTRUCTIONS
   l_obst_abdelposture(iobst)       = .FALSE.               ! * (21) USE ABDELRHMAN 2007 METHOD FOR OBSTRUCTION POSTURE
   l_obst_param_height(iobst)       = .FALSE.               ! * (24) USE PARAMETERIZATION (FROM VELOCITY) FOR FLEXIBLE OBSTRUCTION HEIGHT
#endif
   ! *** TEST-CASE (USED BY CHAIN VALID): Test02 - Rigid Downward obstruction
#ifdef key_casobstflume2D_Test02_RD
   iobst = 1
   obst_varname(iobst)              = 'RigidDown'           ! * (2)  VARIABLE NAME
   l_obst_flexible(iobst)           = .FALSE.               ! * (3)  VARIABLE IS RIGID OR FLEXIBLE
   l_obst_downward(iobst)           = .TRUE.                ! * (4)  VARIABLE IS UPWARD OR DOWNWARD
   l_obst_3dobst(iobst)             = .FALSE.               ! * (6)  LOGICAL FOR FULL 3D OBSTRUCTIONS
   l_obst_abdelposture(iobst)       = .FALSE.               ! * (21) USE ABDELRHMAN 2007 METHOD FOR OBSTRUCTION POSTURE
   l_obst_param_height(iobst)       = .FALSE.               ! * (24) USE PARAMETERIZATION (FROM VELOCITY) FOR FLEXIBLE OBSTRUCTION HEIGHT
#endif
   ! *** TEST-CASE (USED BY CHAIN VALID): Test03 - Flexible Upward obstruction with empirical parameterization for flexibility
#ifdef key_casobstflume2D_Test03_FUP
   iobst = 1
   obst_varname(iobst)              = 'FlexibleUpParam'     ! * (2)  VARIABLE NAME
   l_obst_flexible(iobst)           = .TRUE.                ! * (3)  VARIABLE IS RIGID OR FLEXIBLE
   l_obst_downward(iobst)           = .FALSE.               ! * (4)  VARIABLE IS UPWARD OR DOWNWARD
   l_obst_3dobst(iobst)             = .FALSE.               ! * (6)  LOGICAL FOR FULL 3D OBSTRUCTIONS
   l_obst_abdelposture(iobst)       = .FALSE.               ! * (21) USE ABDELRHMAN 2007 METHOD FOR OBSTRUCTION POSTURE
   l_obst_param_height(iobst)       = .TRUE.                ! * (24) USE PARAMETERIZATION (FROM VELOCITY) FOR FLEXIBLE OBSTRUCTION HEIGHT
#endif
   ! *** TEST-CASE (USED BY CHAIN VALID): Test04 - Flexible Downward obstruction with empirical parameterization for flexibility
#ifdef key_casobstflume2D_Test04_FDP
   iobst = 1
   obst_varname(iobst)              = 'FlexibleDownParam'   ! * (2)  VARIABLE NAME
   l_obst_flexible(iobst)           = .TRUE.                ! * (3)  VARIABLE IS RIGID OR FLEXIBLE
   l_obst_downward(iobst)           = .TRUE.                ! * (4)  VARIABLE IS UPWARD OR DOWNWARD
   l_obst_3dobst(iobst)             = .FALSE.               ! * (6)  LOGICAL FOR FULL 3D OBSTRUCTIONS
   l_obst_abdelposture(iobst)       = .FALSE.               ! * (21) USE ABDELRHMAN 2007 METHOD FOR OBSTRUCTION POSTURE
   l_obst_param_height(iobst)       = .TRUE.                ! * (24) USE PARAMETERIZATION (FROM VELOCITY) FOR FLEXIBLE OBSTRUCTION HEIGHT
#endif
   ! *** TEST-CASE (USED BY CHAIN VALID): Test05 - Flexible Upward obstruction with Abdlhrman's formulation for flexibility
#ifdef key_casobstflume2D_Test05_FUA
   iobst = 1
   obst_varname(iobst)              = 'FlexibleUpAbdel'     ! * (2)  VARIABLE NAME
   l_obst_flexible(iobst)           = .TRUE.                ! * (3)  VARIABLE IS RIGID OR FLEXIBLE
   l_obst_downward(iobst)           = .FALSE.               ! * (4)  VARIABLE IS UPWARD OR DOWNWARD
   l_obst_3dobst(iobst)             = .FALSE.               ! * (6)  LOGICAL FOR FULL 3D OBSTRUCTIONS
   l_obst_abdelposture(iobst)       = .TRUE.                ! * (21) USE ABDELRHMAN 2007 METHOD FOR OBSTRUCTION POSTURE
   l_obst_param_height(iobst)       = .FALSE.               ! * (24) USE PARAMETERIZATION (FROM VELOCITY) FOR FLEXIBLE OBSTRUCTION HEIGHT
#endif
   ! *** TEST-CASE (USED BY CHAIN VALID): Test06 - 3D obstruction like oyster bags
#ifdef key_casobstflume2D_Test06_3DO
   iobst = 1
   obst_varname(iobst)              = '3Dobst'              ! * (2)  VARIABLE NAME
   l_obst_flexible(iobst)           = .FALSE.               ! * (3)  VARIABLE IS RIGID OR FLEXIBLE
   l_obst_downward(iobst)           = .FALSE.               ! * (4)  VARIABLE IS UPWARD OR DOWNWARD
   l_obst_3dobst(iobst)             = .TRUE.                ! * (6)  LOGICAL FOR FULL 3D OBSTRUCTIONS
   l_obst_abdelposture(iobst)       = .FALSE.               ! * (21) USE ABDELRHMAN 2007 METHOD FOR OBSTRUCTION POSTURE
   l_obst_param_height(iobst)       = .FALSE.               ! * (24) USE PARAMETERIZATION (FROM VELOCITY) FOR FLEXIBLE OBSTRUCTION HEIGHT
   obst_i_height(iobst)             = 0.65_rsh              ! * (17) INITIAL OBSTRUCTION HEIGHT
#endif
   ! *** TEST-CASE (USED BY CHAIN VALID): Test06 - Multiple obstructions (Z. noltei+Z. marina+Oyster bags+Suspended Obst)
#ifdef key_casobstflume2D_Test07_Multi
   ! FIRST VARIABLE: Z. noltei
   iobst=1
   obst_varnum(iobst)               = iobst             ! * (1)  VARIABLE NUMBER
   obst_varname(iobst)              = 'Z. noltei'       ! * (2)  VARIABLE NAME
   l_obst_flexible(iobst)           = .TRUE.            ! * (3)  VARIABLE IS RIGID OR FLEXIBLE
   l_obst_downward(iobst)           = .FALSE.           ! * (4)  VARIABLE IS UPWARD OR DOWNWARD
   l_obst_cylindre(iobst)           = .FALSE.           ! * (5)  LOGICAL FOR SHAPE OF OBSTRUCTIONS
   l_obst_3dobst(iobst)             = .FALSE.           ! * (6)  LOGICAL FOR FULL 3D OBSTRUCTIONS
   l_obst_noturb(iobst)             = .FALSE.           ! * (7)  LOGICAL FOR USE SIMPLIFIED FORMULATION (Z0)
   l_obst_filechar(iobst)           = .FALSE.           ! * (8)  LOGICAL FOR USE OF TEMPORAL OBSTRUCTION CHARACTERISTICS
   obst_fn_char(iobst)              = './'              ! * (9)  FILENAME FOR TEMPORAL OBSTRUCTION CHARACTERISTICS
   l_obst_filedistri(iobst)         = .FALSE.           ! * (10)  LOGICAL FOR USE A FILE FOR VERTICAL DISTRIBUTION OF OBSTRUCTIONS
   obst_fn_distrib(iobst)           = './'              ! * (11)  FILENAME FOR VERTICAL DISTRIBUTION FILE
   l_obst_fracxy(iobst)             = .FALSE.           ! * (12) LOGICAL TO TAKE ACCOUNT FOR COVERAGE CORRECTION WITHIN GRID CELL
   obst_fracxy_type(iobst)          = 2                 ! * (13) INTEGER FOR THE TYPE OF COVERAGE CORRECTION
   obst_c_fracxy_k0(iobst)          = 6.0_rsh           ! * (14) FIRST PARAMETER FOR COVERAGE CORRECTION (TYPE=1 or TYPE=2)
   obst_c_fracxy_k1(iobst)          = 12.0_rsh          ! * (15) SECOND PARAMETER FOR COVERAGE CORRECTION (TYPE=2)
   obst_c_fracxy_l(iobst)           = 3.5_rsh           ! * (16) THIRD PARAMETER FOR COVERAGE CORRECTION (TYPE=2)
   obst_i_height(iobst)             = 0.15_rsh          ! * (17) INITIAL OBSTRUCTION HEIGHT
   obst_i_width(iobst)              = 0.001_rsh         ! * (18) INITIAL OBSTRUCTION WIDTH
   obst_i_thick(iobst)              = 0.0002_rsh        ! * (19) INITIAL OBSTRUCTION THICKNESS
   obst_i_dens(iobst)               = 40000.0_rsh       ! * (20) INITIAL OBSTRUCTION DENSITY
   l_obst_abdelposture(iobst)       = .TRUE.            ! * (21) USE ABDELRHMAN 2007 METHOD FOR OBSTRUCTION POSTURE
   obst_i_abdel_nmax(iobst)         = 5                 ! * (22) NUMBER OF OBSTRUCTION HEIGHT DISCRETIZATION FOR ABDELRHMAN 2007 METHOD
   obst_i_rho(iobst)                = 650.0_rsh         ! * (23) INITIAL OBSTRUCTION VOLUMETRIC MASS
   l_obst_param_height(iobst)       = .FALSE.           ! * (24) USE PARAMETERIZATION (FROM VELOCITY) FOR FLEXIBLE OBSTRUCTION HEIGHT
   obst_c_height_x0(iobst)          = 0.99_rsh          ! * (25) FIRST COEFFICIENT FOR OBSTRUCTION HEIGHT
   obst_c_height_x1(iobst)          = -3.92_rsh         ! * (26) SECOND COEFFICIENT FOR OBSTRUCTION HEIGHT
   l_obst_drag_cste(iobst)          = .TRUE.            ! * (27) USE CONSTANT DRAG COEFFICIENT
   obst_i_drag(iobst)               = 1.5_rsh           ! * (28) DRAG COEFFICIENT FOR OBSTRUCTION
   obst_i_lift(iobst)               = 0.0_rsh           ! * (29) LIFT COEFFICIENT FOR OBSTRUCTIONS
   obst_c_shelter(iobst)            = 100.0_rsh         ! * (30) SCALING FACTOR FOR SHELETERING COEFFICIENT
   obst_c_lz(iobst)                 = 0.1_rsh           ! * (31) FORM COEFFICIENT FOR DISSIPATION TIME-SCALE WITHIN OBSTRUCTIONS
   l_obst_z0bstress(iobst)          = .TRUE.            ! * (32) IMPACT OF OBSTRUCTIONS ON SEDIMENTOLOGICAl ROUGHNESS LENGTH
   l_obst_z0bstress_strick(iobst)   = .FALSE.           ! * (33) USE OF Z0 CORRECTION FROM STRICKLER COEFFICIENT
   l_obst_z0bstress_param3d(iobst)  = .FALSE.           ! * (34) USE OF Z0 CORRECTION FROM PARAMETERIZATION FOR 3D FORMULATIONS
   obst_i_z0bstress3d(iobst)        = 0.0012_rsh        ! * (35) INITIAL VALUE FOR SEDIMENTOLOGICAL ROUGHNESS LENGTH
   obst_c_z0bstress3d_x0(iobst)     = 0.0011_rsh        ! * (36) FIRST PARAMETER FOR ROUGHNESS LENGTH PARAMETERIZATION FOR 3D FORMULATIONS
   obst_c_z0bstress3d_x1(iobst)     = 0.2974_rsh        ! * (37) SECOND PARAMETER FOR ROUGHNESS LENGTH PARAMETERIZATION FOR 3D FORMULATIONS
   l_obst_z0bstress_param2dh(iobst) = .FALSE.           ! * (38) USE OF Z0 CORRECTION FROM PARAMETERIZATION FOR 2Donly FORMULATIONS
   obst_i_z0bstress2dh(iobst)       = 0.0042_rsh        ! * (39) INITIAL VALUE FOR SEDIMENTOLOGICAL ROUGHNESS LENGTH FOR 2D FORMULATIONS
   obst_c_z0bstress2dh_x0(iobst)    = 0.0001_rsh        ! * (40) FIRST PARAMETER FOR ROUGHNESS LENGTH PARAMETERIZATION FOR 2D FORMULATIONS
   obst_c_z0bstress2dh_x1(iobst)    = -1.3348_rsh       ! * (41) SECOND PARAMETER FOR ROUGHNESS LENGTH PARAMETERIZATION FOR 2D FORMULATIONS
   ! SECOND VARIABLE: Z. marina
   iobst=2
   obst_varnum(iobst)               = iobst             ! * (1)  VARIABLE NUMBER
   obst_varname(iobst)              = 'Z. marina'       ! * (2)  VARIABLE NAME
   l_obst_flexible(iobst)           = .TRUE.            ! * (3)  VARIABLE IS RIGID OR FLEXIBLE
   l_obst_downward(iobst)           = .FALSE.           ! * (4)  VARIABLE IS UPWARD OR DOWNWARD
   l_obst_cylindre(iobst)           = .FALSE.           ! * (5)  LOGICAL FOR SHAPE OF OBSTRUCTIONS
   l_obst_3dobst(iobst)             = .FALSE.           ! * (6)  LOGICAL FOR FULL 3D OBSTRUCTIONS
   l_obst_noturb(iobst)             = .FALSE.           ! * (7)  LOGICAL FOR USE SIMPLIFIED FORMULATION (Z0)
   l_obst_filechar(iobst)           = .FALSE.           ! * (8)  LOGICAL FOR USE OF TEMPORAL OBSTRUCTION CHARACTERISTICS
   obst_fn_char(iobst)              = './'              ! * (9)  FILENAME FOR TEMPORAL OBSTRUCTION CHARACTERISTICS
   l_obst_filedistri(iobst)         = .FALSE.           ! * (10)  LOGICAL FOR USE A FILE FOR VERTICAL DISTRIBUTION OF OBSTRUCTIONS
   obst_fn_distrib(iobst)           = './'              ! * (11)  FILENAME FOR VERTICAL DISTRIBUTION FILE
   l_obst_fracxy(iobst)             = .FALSE.           ! * (12) LOGICAL TO TAKE ACCOUNT FOR COVERAGE CORRECTION WITHIN GRID CELL
   obst_fracxy_type(iobst)          = 2                 ! * (13) INTEGER FOR THE TYPE OF COVERAGE CORRECTION
   obst_c_fracxy_k0(iobst)          = 6.0_rsh           ! * (14) FIRST PARAMETER FOR COVERAGE CORRECTION (TYPE=1 or TYPE=2)
   obst_c_fracxy_k1(iobst)          = 12.0_rsh          ! * (15) SECOND PARAMETER FOR COVERAGE CORRECTION (TYPE=2)
   obst_c_fracxy_l(iobst)           = 3.5_rsh           ! * (16) THIRD PARAMETER FOR COVERAGE CORRECTION (TYPE=2)
   obst_i_height(iobst)             = 0.35_rsh          ! * (17) INITIAL OBSTRUCTION HEIGHT
   obst_i_width(iobst)              = 0.01_rsh          ! * (18) INITIAL OBSTRUCTION WIDTH
   obst_i_thick(iobst)              = 0.001_rsh         ! * (19) INITIAL OBSTRUCTION THICKNESS
   obst_i_dens(iobst)               = 1500.0_rsh        ! * (20) INITIAL OBSTRUCTION DENSITY
   l_obst_abdelposture(iobst)       = .TRUE.            ! * (21) USE ABDELRHMAN 2007 METHOD FOR OBSTRUCTION POSTURE
   obst_i_abdel_nmax(iobst)         = 5                 ! * (22) NUMBER OF OBSTRUCTION HEIGHT DISCRETIZATION FOR ABDELRHMAN 2007 METHOD
   obst_i_rho(iobst)                = 650.0_rsh         ! * (23) INITIAL OBSTRUCTION VOLUMETRIC MASS
   l_obst_param_height(iobst)       = .FALSE.           ! * (24) USE PARAMETERIZATION (FROM VELOCITY) FOR FLEXIBLE OBSTRUCTION HEIGHT
   obst_c_height_x0(iobst)          = 0.99_rsh          ! * (25) FIRST COEFFICIENT FOR OBSTRUCTION HEIGHT
   obst_c_height_x1(iobst)          = -3.92_rsh         ! * (26) SECOND COEFFICIENT FOR OBSTRUCTION HEIGHT
   l_obst_drag_cste(iobst)          = .TRUE.            ! * (27) USE CONSTANT DRAG COEFFICIENT
   obst_i_drag(iobst)               = 1.5_rsh           ! * (28) DRAG COEFFICIENT FOR OBSTRUCTION
   obst_i_lift(iobst)               = 0.0_rsh           ! * (29) LIFT COEFFICIENT FOR OBSTRUCTIONS
   obst_c_shelter(iobst)            = 100.0_rsh         ! * (30) SCALING FACTOR FOR SHELETERING COEFFICIENT
   obst_c_lz(iobst)                 = 0.1_rsh           ! * (31) FORM COEFFICIENT FOR DISSIPATION TIME-SCALE WITHIN OBSTRUCTIONS
   l_obst_z0bstress(iobst)          = .TRUE.            ! * (32) IMPACT OF OBSTRUCTIONS ON SEDIMENTOLOGICAl ROUGHNESS LENGTH
   l_obst_z0bstress_strick(iobst)   = .FALSE.           ! * (33) USE OF Z0 CORRECTION FROM STRICKLER COEFFICIENT
   l_obst_z0bstress_param3d(iobst)  = .FALSE.           ! * (34) USE OF Z0 CORRECTION FROM PARAMETERIZATION FOR 3D FORMULATIONS
   obst_i_z0bstress3d(iobst)        = 0.0012_rsh        ! * (35) INITIAL VALUE FOR SEDIMENTOLOGICAL ROUGHNESS LENGTH
   obst_c_z0bstress3d_x0(iobst)     = 0.0011_rsh        ! * (36) FIRST PARAMETER FOR ROUGHNESS LENGTH PARAMETERIZATION FOR 3D FORMULATIONS
   obst_c_z0bstress3d_x1(iobst)     = 0.2974_rsh        ! * (37) SECOND PARAMETER FOR ROUGHNESS LENGTH PARAMETERIZATION FOR 3D FORMULATIONS
   l_obst_z0bstress_param2dh(iobst) = .FALSE.           ! * (38) USE OF Z0 CORRECTION FROM PARAMETERIZATION FOR 2Donly FORMULATIONS
   obst_i_z0bstress2dh(iobst)       = 0.0042_rsh        ! * (39) INITIAL VALUE FOR SEDIMENTOLOGICAL ROUGHNESS LENGTH FOR 2D FORMULATIONS
   obst_c_z0bstress2dh_x0(iobst)    = 0.0001_rsh        ! * (40) FIRST PARAMETER FOR ROUGHNESS LENGTH PARAMETERIZATION FOR 2D FORMULATIONS
   obst_c_z0bstress2dh_x1(iobst)    = -1.3348_rsh       ! * (41) SECOND PARAMETER FOR ROUGHNESS LENGTH PARAMETERIZATION FOR 2D FORMULATIONS
   ! THIRD VARIABLE: Oyster Bags
   iobst=3
   obst_varnum(iobst)               = iobst             ! * (1)  VARIABLE NUMBER
   obst_varname(iobst)              = 'OysterBags'      ! * (2)  VARIABLE NAME
   l_obst_flexible(iobst)           = .FALSE.           ! * (3)  VARIABLE IS RIGID OR FLEXIBLE
   l_obst_downward(iobst)           = .FALSE.           ! * (4)  VARIABLE IS UPWARD OR DOWNWARD
   l_obst_cylindre(iobst)           = .TRUE.            ! * (5)  LOGICAL FOR SHAPE OF OBSTRUCTIONS
   l_obst_3dobst(iobst)             = .TRUE.            ! * (6)  LOGICAL FOR FULL 3D OBSTRUCTIONS
   l_obst_noturb(iobst)             = .FALSE.           ! * (7)  LOGICAL FOR USE SIMPLIFIED FORMULATION (Z0)
   l_obst_filechar(iobst)           = .FALSE.           ! * (8)  LOGICAL FOR USE OF TEMPORAL OBSTRUCTION CHARACTERISTICS
   obst_fn_char(iobst)              = './'              ! * (9)  FILENAME FOR TEMPORAL OBSTRUCTION CHARACTERISTICS
   l_obst_filedistri(iobst)         = .FALSE.           ! * (10)  LOGICAL FOR USE A FILE FOR VERTICAL DISTRIBUTION OF OBSTRUCTIONS
   obst_fn_distrib(iobst)           = './'              ! * (11)  FILENAME FOR VERTICAL DISTRIBUTION FILE
   l_obst_fracxy(iobst)             = .FALSE.           ! * (12) LOGICAL TO TAKE ACCOUNT FOR COVERAGE CORRECTION WITHIN GRID CELL
   obst_fracxy_type(iobst)          = 2                 ! * (13) INTEGER FOR THE TYPE OF COVERAGE CORRECTION
   obst_c_fracxy_k0(iobst)          = 6.0_rsh           ! * (14) FIRST PARAMETER FOR COVERAGE CORRECTION (TYPE=1 or TYPE=2)
   obst_c_fracxy_k1(iobst)          = 12.0_rsh          ! * (15) SECOND PARAMETER FOR COVERAGE CORRECTION (TYPE=2)
   obst_c_fracxy_l(iobst)           = 3.5_rsh           ! * (16) THIRD PARAMETER FOR COVERAGE CORRECTION (TYPE=2)
   obst_i_height(iobst)             = 0.65_rsh          ! * (17) INITIAL OBSTRUCTION HEIGHT
   obst_i_width(iobst)              = 0.06_rsh          ! * (18) INITIAL OBSTRUCTION WIDTH
   obst_i_thick(iobst)              = 0.06_rsh          ! * (19) INITIAL OBSTRUCTION THICKNESS
   obst_i_dens(iobst)               = 350.0_rsh         ! * (20) INITIAL OBSTRUCTION DENSITY
   l_obst_abdelposture(iobst)       = .FALSE.           ! * (21) USE ABDELRHMAN 2007 METHOD FOR OBSTRUCTION POSTURE
   obst_i_abdel_nmax(iobst)         = 5                 ! * (22) NUMBER OF OBSTRUCTION HEIGHT DISCRETIZATION FOR ABDELRHMAN 2007 METHOD
   obst_i_rho(iobst)                = 650.0_rsh         ! * (23) INITIAL OBSTRUCTION VOLUMETRIC MASS
   l_obst_param_height(iobst)       = .FALSE.           ! * (24) USE PARAMETERIZATION (FROM VELOCITY) FOR FLEXIBLE OBSTRUCTION HEIGHT
   obst_c_height_x0(iobst)          = 0.99_rsh          ! * (25) FIRST COEFFICIENT FOR OBSTRUCTION HEIGHT
   obst_c_height_x1(iobst)          = -3.92_rsh         ! * (26) SECOND COEFFICIENT FOR OBSTRUCTION HEIGHT
   l_obst_drag_cste(iobst)          = .TRUE.            ! * (27) USE CONSTANT DRAG COEFFICIENT
   obst_i_drag(iobst)               = 1.5_rsh           ! * (28) DRAG COEFFICIENT FOR OBSTRUCTION
   obst_i_lift(iobst)               = 0.0_rsh           ! * (29) LIFT COEFFICIENT FOR OBSTRUCTIONS
   obst_c_shelter(iobst)            = 100.0_rsh         ! * (30) SCALING FACTOR FOR SHELETERING COEFFICIENT
   obst_c_lz(iobst)                 = 0.3_rsh           ! * (31) FORM COEFFICIENT FOR DISSIPATION TIME-SCALE WITHIN OBSTRUCTIONS
   l_obst_z0bstress(iobst)          = .TRUE.            ! * (32) IMPACT OF OBSTRUCTIONS ON SEDIMENTOLOGICAl ROUGHNESS LENGTH
   l_obst_z0bstress_strick(iobst)   = .FALSE.           ! * (33) USE OF Z0 CORRECTION FROM STRICKLER COEFFICIENT
   l_obst_z0bstress_param3d(iobst)  = .FALSE.           ! * (34) USE OF Z0 CORRECTION FROM PARAMETERIZATION FOR 3D FORMULATIONS
   obst_i_z0bstress3d(iobst)        = 0.0012_rsh        ! * (35) INITIAL VALUE FOR SEDIMENTOLOGICAL ROUGHNESS LENGTH
   obst_c_z0bstress3d_x0(iobst)     = 0.0011_rsh        ! * (36) FIRST PARAMETER FOR ROUGHNESS LENGTH PARAMETERIZATION FOR 3D FORMULATIONS
   obst_c_z0bstress3d_x1(iobst)     = 0.2974_rsh        ! * (37) SECOND PARAMETER FOR ROUGHNESS LENGTH PARAMETERIZATION FOR 3D FORMULATIONS
   l_obst_z0bstress_param2dh(iobst) = .FALSE.           ! * (38) USE OF Z0 CORRECTION FROM PARAMETERIZATION FOR 2Donly FORMULATIONS
   obst_i_z0bstress2dh(iobst)       = 0.0042_rsh        ! * (39) INITIAL VALUE FOR SEDIMENTOLOGICAL ROUGHNESS LENGTH FOR 2D FORMULATIONS
   obst_c_z0bstress2dh_x0(iobst)    = 0.0001_rsh        ! * (40) FIRST PARAMETER FOR ROUGHNESS LENGTH PARAMETERIZATION FOR 2D FORMULATIONS
   obst_c_z0bstress2dh_x1(iobst)    = -1.3348_rsh       ! * (41) SECOND PARAMETER FOR ROUGHNESS LENGTH PARAMETERIZATION FOR 2D FORMULATIONS
   ! FOURTH VARIABLE: Mussels rope
   iobst=4
   obst_varnum(iobst)               = iobst             ! * (1)  VARIABLE NUMBER
   obst_varname(iobst)              = 'MusselRope'      ! * (2)  VARIABLE NAME
   l_obst_flexible(iobst)           = .FALSE.           ! * (3)  VARIABLE IS RIGID OR FLEXIBLE
   l_obst_downward(iobst)           = .TRUE.            ! * (4)  VARIABLE IS UPWARD OR DOWNWARD
   l_obst_cylindre(iobst)           = .TRUE.            ! * (5)  LOGICAL FOR SHAPE OF OBSTRUCTIONS
   l_obst_3dobst(iobst)             = .FALSE.           ! * (6)  LOGICAL FOR FULL 3D OBSTRUCTIONS
   l_obst_noturb(iobst)             = .FALSE.           ! * (7)  LOGICAL FOR USE SIMPLIFIED FORMULATION (Z0)
   l_obst_filechar(iobst)           = .FALSE.           ! * (8)  LOGICAL FOR USE OF TEMPORAL OBSTRUCTION CHARACTERISTICS
   obst_fn_char(iobst)              = './'              ! * (9)  FILENAME FOR TEMPORAL OBSTRUCTION CHARACTERISTICS
   l_obst_filedistri(iobst)         = .FALSE.           ! * (10)  LOGICAL FOR USE A FILE FOR VERTICAL DISTRIBUTION OF OBSTRUCTIONS
   obst_fn_distrib(iobst)           = './'              ! * (11)  FILENAME FOR VERTICAL DISTRIBUTION FILE
   l_obst_fracxy(iobst)             = .FALSE.           ! * (12) LOGICAL TO TAKE ACCOUNT FOR COVERAGE CORRECTION WITHIN GRID CELL
   obst_fracxy_type(iobst)          = 2                 ! * (13) INTEGER FOR THE TYPE OF COVERAGE CORRECTION
   obst_c_fracxy_k0(iobst)          = 6.0_rsh           ! * (14) FIRST PARAMETER FOR COVERAGE CORRECTION (TYPE=1 or TYPE=2)
   obst_c_fracxy_k1(iobst)          = 12.0_rsh          ! * (15) SECOND PARAMETER FOR COVERAGE CORRECTION (TYPE=2)
   obst_c_fracxy_l(iobst)           = 3.5_rsh           ! * (16) THIRD PARAMETER FOR COVERAGE CORRECTION (TYPE=2)
   obst_i_height(iobst)             = 0.1_rsh           ! * (17) INITIAL OBSTRUCTION HEIGHT
   obst_i_width(iobst)              = 0.1_rsh           ! * (18) INITIAL OBSTRUCTION WIDTH
   obst_i_thick(iobst)              = 0.1_rsh           ! * (19) INITIAL OBSTRUCTION THICKNESS
   obst_i_dens(iobst)               = 30.0_rsh          ! * (20) INITIAL OBSTRUCTION DENSITY
   l_obst_abdelposture(iobst)       = .FALSE.           ! * (21) USE ABDELRHMAN 2007 METHOD FOR OBSTRUCTION POSTURE
   obst_i_abdel_nmax(iobst)         = 5                 ! * (22) NUMBER OF OBSTRUCTION HEIGHT DISCRETIZATION FOR ABDELRHMAN 2007 METHOD
   obst_i_rho(iobst)                = 650.0_rsh         ! * (23) INITIAL OBSTRUCTION VOLUMETRIC MASS
   l_obst_param_height(iobst)       = .FALSE.           ! * (24) USE PARAMETERIZATION (FROM VELOCITY) FOR FLEXIBLE OBSTRUCTION HEIGHT
   obst_c_height_x0(iobst)          = 0.99_rsh          ! * (25) FIRST COEFFICIENT FOR OBSTRUCTION HEIGHT
   obst_c_height_x1(iobst)          = -3.92_rsh         ! * (26) SECOND COEFFICIENT FOR OBSTRUCTION HEIGHT
   l_obst_drag_cste(iobst)          = .TRUE.            ! * (27) USE CONSTANT DRAG COEFFICIENT
   obst_i_drag(iobst)               = 1.5_rsh           ! * (28) DRAG COEFFICIENT FOR OBSTRUCTION
   obst_i_lift(iobst)               = 0.0_rsh           ! * (29) LIFT COEFFICIENT FOR OBSTRUCTIONS
   obst_c_shelter(iobst)            = 100.0_rsh         ! * (30) SCALING FACTOR FOR SHELETERING COEFFICIENT
   obst_c_lz(iobst)                 = 0.3_rsh           ! * (31) FORM COEFFICIENT FOR DISSIPATION TIME-SCALE WITHIN OBSTRUCTIONS
   l_obst_z0bstress(iobst)          = .TRUE.            ! * (32) IMPACT OF OBSTRUCTIONS ON SEDIMENTOLOGICAl ROUGHNESS LENGTH
   l_obst_z0bstress_strick(iobst)   = .FALSE.           ! * (33) USE OF Z0 CORRECTION FROM STRICKLER COEFFICIENT
   l_obst_z0bstress_param3d(iobst)  = .FALSE.           ! * (34) USE OF Z0 CORRECTION FROM PARAMETERIZATION FOR 3D FORMULATIONS
   obst_i_z0bstress3d(iobst)        = 0.0012_rsh        ! * (35) INITIAL VALUE FOR SEDIMENTOLOGICAL ROUGHNESS LENGTH
   obst_c_z0bstress3d_x0(iobst)     = 0.0011_rsh        ! * (36) FIRST PARAMETER FOR ROUGHNESS LENGTH PARAMETERIZATION FOR 3D FORMULATIONS
   obst_c_z0bstress3d_x1(iobst)     = 0.2974_rsh        ! * (37) SECOND PARAMETER FOR ROUGHNESS LENGTH PARAMETERIZATION FOR 3D FORMULATIONS
   l_obst_z0bstress_param2dh(iobst) = .FALSE.           ! * (38) USE OF Z0 CORRECTION FROM PARAMETERIZATION FOR 2Donly FORMULATIONS
   obst_i_z0bstress2dh(iobst)       = 0.0042_rsh        ! * (39) INITIAL VALUE FOR SEDIMENTOLOGICAL ROUGHNESS LENGTH FOR 2D FORMULATIONS
   obst_c_z0bstress2dh_x0(iobst)    = 0.0001_rsh        ! * (40) FIRST PARAMETER FOR ROUGHNESS LENGTH PARAMETERIZATION FOR 2D FORMULATIONS
   obst_c_z0bstress2dh_x1(iobst)    = -1.3348_rsh       ! * (41) SECOND PARAMETER FOR ROUGHNESS LENGTH PARAMETERIZATION FOR 2D FORMULATIONS
#endif
   ! *** TEST-CASE (USED BY CHAIN VALID): 3D Test01/02 - 3D Multiple obstructions (Z. noltei+Rigid)
#if defined key_casobstflume3D_Test01_LD || defined key_casobstflume3D_Test02_HD
   ! Preliminar initialization
   DO iobst=1,obst_nbvar
     obst_varnum(iobst)               = iobst             ! * (1)  VARIABLE NUMBER
     obst_varname(iobst)              = 'obst'            ! * (2)  VARIABLE NAME
     l_obst_flexible(iobst)           = .FALSE.           ! * (3)  VARIABLE IS RIGID OR FLEXIBLE
     l_obst_downward(iobst)           = .FALSE.           ! * (4)  VARIABLE IS UPWARD OR DOWNWARD
     l_obst_cylindre(iobst)           = .FALSE.           ! * (5)  LOGICAL FOR SHAPE OF OBSTRUCTIONS
     l_obst_3dobst(iobst)             = .FALSE.           ! * (6)  LOGICAL FOR FULL 3D OBSTRUCTIONS
     l_obst_noturb(iobst)             = .FALSE.           ! * (7)  LOGICAL FOR USE SIMPLIFIED FORMULATION (Z0)
     l_obst_filechar(iobst)           = .FALSE.           ! * (8)  LOGICAL FOR USE OF TEMPORAL OBSTRUCTION CHARACTERISTICS
     obst_fn_char(iobst)              = './'              ! * (9)  FILENAME FOR TEMPORAL OBSTRUCTION CHARACTERISTICS
     l_obst_filedistri(iobst)         = .FALSE.           ! * (10)  LOGICAL FOR USE A FILE FOR VERTICAL DISTRIBUTION OF OBSTRUCTIONS
     obst_fn_distrib(iobst)           = './'              ! * (11)  FILENAME FOR VERTICAL DISTRIBUTION FILE
     l_obst_fracxy(iobst)             = .FALSE.           ! * (12) LOGICAL TO TAKE ACCOUNT FOR COVERAGE CORRECTION WITHIN GRID CELL
     obst_fracxy_type(iobst)          = 2                 ! * (13) INTEGER FOR THE TYPE OF COVERAGE CORRECTION
     obst_c_fracxy_k0(iobst)          = 6.0_rsh           ! * (14) FIRST PARAMETER FOR COVERAGE CORRECTION (TYPE=1 or TYPE=2)
     obst_c_fracxy_k1(iobst)          = 12.0_rsh          ! * (15) SECOND PARAMETER FOR COVERAGE CORRECTION (TYPE=2)
     obst_c_fracxy_l(iobst)           = 3.5_rsh           ! * (16) THIRD PARAMETER FOR COVERAGE CORRECTION (TYPE=2)
     obst_i_height(iobst)             = 0.2_rsh           ! * (17) INITIAL OBSTRUCTION HEIGHT
     obst_i_width(iobst)              = 0.001_rsh         ! * (18) INITIAL OBSTRUCTION WIDTH
     obst_i_thick(iobst)              = 0.0002_rsh        ! * (19) INITIAL OBSTRUCTION THICKNESS
     obst_i_dens(iobst)               = 40000.0_rsh       ! * (20) INITIAL OBSTRUCTION DENSITY
     l_obst_abdelposture(iobst)       = .FALSE.           ! * (21) USE ABDELRHMAN 2007 METHOD FOR OBSTRUCTION POSTURE
     obst_i_abdel_nmax(iobst)         = 5                 ! * (22) NUMBER OF OBSTRUCTION HEIGHT DISCRETIZATION FOR ABDELRHMAN 2007 METHOD
     obst_i_rho(iobst)                = 650.0_rsh         ! * (23) INITIAL OBSTRUCTION VOLUMETRIC MASS
     l_obst_param_height(iobst)       = .FALSE.           ! * (24) USE PARAMETERIZATION (FROM VELOCITY) FOR FLEXIBLE OBSTRUCTION HEIGHT
     obst_c_height_x0(iobst)          = 0.99_rsh          ! * (25) FIRST COEFFICIENT FOR OBSTRUCTION HEIGHT
     obst_c_height_x1(iobst)          = -3.92_rsh         ! * (26) SECOND COEFFICIENT FOR OBSTRUCTION HEIGHT
     l_obst_drag_cste(iobst)          = .TRUE.            ! * (27) USE CONSTANT DRAG COEFFICIENT
     obst_i_drag(iobst)               = 1.5_rsh           ! * (28) DRAG COEFFICIENT FOR OBSTRUCTION
     obst_i_lift(iobst)               = 0.0_rsh           ! * (29) LIFT COEFFICIENT FOR OBSTRUCTIONS
     obst_c_shelter(iobst)            = 100.0_rsh         ! * (30) SCALING FACTOR FOR SHELETERING COEFFICIENT
     obst_c_lz(iobst)                 = 0.1_rsh           ! * (31) FORM COEFFICIENT FOR DISSIPATION TIME-SCALE WITHIN OBSTRUCTIONS
     l_obst_z0bstress(iobst)          = .TRUE.            ! * (32) IMPACT OF OBSTRUCTIONS ON SEDIMENTOLOGICAl ROUGHNESS LENGTH
     l_obst_z0bstress_strick(iobst)   = .FALSE.           ! * (33) USE OF Z0 CORRECTION FROM STRICKLER COEFFICIENT
     l_obst_z0bstress_param3d(iobst)  = .FALSE.           ! * (34) USE OF Z0 CORRECTION FROM PARAMETERIZATION FOR 3D FORMULATIONS
     obst_i_z0bstress3d(iobst)        = 0.0012_rsh        ! * (35) INITIAL VALUE FOR SEDIMENTOLOGICAL ROUGHNESS LENGTH
     obst_c_z0bstress3d_x0(iobst)     = 0.0011_rsh        ! * (36) FIRST PARAMETER FOR ROUGHNESS LENGTH PARAMETERIZATION FOR 3D FORMULATIONS
     obst_c_z0bstress3d_x1(iobst)     = 0.2974_rsh        ! * (37) SECOND PARAMETER FOR ROUGHNESS LENGTH PARAMETERIZATION FOR 3D FORMULATIONS
     l_obst_z0bstress_param2dh(iobst) = .FALSE.           ! * (38) USE OF Z0 CORRECTION FROM PARAMETERIZATION FOR 2Donly FORMULATIONS
     obst_i_z0bstress2dh(iobst)       = 0.0042_rsh        ! * (39) INITIAL VALUE FOR SEDIMENTOLOGICAL ROUGHNESS LENGTH FOR 2D FORMULATIONS
     obst_c_z0bstress2dh_x0(iobst)    = 0.0001_rsh        ! * (40) FIRST PARAMETER FOR ROUGHNESS LENGTH PARAMETERIZATION FOR 2D FORMULATIONS
     obst_c_z0bstress2dh_x1(iobst)    = -1.3348_rsh       ! * (41) SECOND PARAMETER FOR ROUGHNESS LENGTH PARAMETERIZATION FOR 2D FORMULATIONS
   ENDDO
   ! OVERWRITE
   ! First variable
   iobst=1
   obst_varname(iobst)              = 'Flexible_0.1'   ! * (2)  VARIABLE NAME
   l_obst_flexible(iobst)           = .TRUE.           ! * (3)  VARIABLE IS RIGID OR FLEXIBLE
   l_obst_abdelposture(iobst)       = .TRUE.           ! * (21) USE ABDELRHMAN 2007 METHOD FOR OBSTRUCTION POSTURE
#ifdef key_casobstflume3D_Test01_LD
   obst_i_dens(iobst)               = 2000.0_rsh       ! * (20) INITIAL OBSTRUCTION DENSITY
#endif
   ! Second variable
   iobst=2
   obst_varname(iobst)              = 'Rigid_0.5'      ! * (2)  VARIABLE NAME
   obst_i_height(iobst)             = 0.5_rsh          ! * (17) INITIAL OBSTRUCTION HEIGHT
#ifdef key_casobstflume3D_Test01_LD
   obst_i_dens(iobst)               = 2000.0_rsh       ! * (20) INITIAL OBSTRUCTION DENSITY
#endif
   ! Third variable
   iobst=3
   obst_varname(iobst)              = 'Rigid_1.0'      ! * (2)  VARIABLE NAME
   obst_i_height(iobst)             = 1.5_rsh          ! * (17) INITIAL OBSTRUCTION HEIGHT
#ifdef key_casobstflume3D_Test01_LD
   obst_i_dens(iobst)               = 2000.0_rsh       ! * (20) INITIAL OBSTRUCTION DENSITY
#endif
#endif
   ! ************************************************************* !
   ! ***         END OF SPECIFIC TEST-CASES OVERWRITE          *** !
   ! ************************************************************* !

   ! The roughness length for bottom shear stress (outside obstructions)
   obst_i_z0bstress = 0.00024_rsh

   ! Finalizing initialization
   CALL cas_init_obstructions

   ! over-assignement
   ! Position of the fist variable over the domain
#ifdef key_castestobstructions3D
#if defined key_casobstflume3D_Test01_LD || defined key_casobstflume3D_Test02_HD
   DO i=limin,limax
     DO j=ljmin,ljmax
       iobst=1
       IF((i.GE.15).AND.(i.LE.17).AND.(j.GE.8).AND.(j.LE.10))  obst_position(iobst,i,j)=1.0_rsh
       IF((i.GE.24).AND.(i.LE.28).AND.(j.EQ.60))               obst_position(iobst,i,j)=1.0_rsh
       IF((i.GE.23).AND.(i.LE.29).AND.(j.GE.61).AND.(j.LE.65)) obst_position(iobst,i,j)=1.0_rsh
       IF((i.GE.24).AND.(i.LE.28).AND.(j.EQ.66))               obst_position(iobst,i,j)=1.0_rsh
       iobst=2
       IF((i.GE.14).AND.(i.LE.18).AND.(j.EQ.32))               obst_position(iobst,i,j)=1.0_rsh
       IF((i.GE.13).AND.(i.LE.19).AND.(j.GE.33).AND.(j.LE.37)) obst_position(iobst,i,j)=1.0_rsh
       IF((i.GE.14).AND.(i.LE.18).AND.(j.EQ.38))               obst_position(iobst,i,j)=1.0_rsh
       IF((i.GE.50).AND.(i.LE.52).AND.(j.GE.48).AND.(j.LE.50)) obst_position(iobst,i,j)=1.0_rsh
       iobst=3
       IF((i.GE.54).AND.(i.LE.58).AND.(j.EQ.13))               obst_position(iobst,i,j)=1.0_rsh
       IF((i.GE.53).AND.(i.LE.59).AND.(j.GE.14).AND.(j.LE.18)) obst_position(iobst,i,j)=1.0_rsh
       IF((i.GE.54).AND.(i.LE.58).AND.(j.EQ.19))               obst_position(iobst,i,j)=1.0_rsh
       IF((i.GE.60).AND.(i.LE.62).AND.(j.GE.72).AND.(j.LE.74)) obst_position(iobst,i,j)=1.0_rsh
     ENDDO
   ENDDO
#else
   ! Position of the fist variable over the domain
   DO i=limin,limax
     xxp(i) = REAL(i,rsh)*dxval
   ENDDO
   DO j=ljmin,ljmax
     yyp(j) = REAL(j,rsh)*dyval
   ENDDO
   nb_patch = 1
   ALLOCATE(xpatch(1:nb_patch))
   ALLOCATE(ypatch(1:nb_patch))
   diam_patch = 0.4_rsh
   xpatch(1) = 2.0_rsh
   ypatch(1) = MAXVAL(yyp)/2.0_rsh
   DO k=1,nb_patch
     DO i=limin,limax
       DO j=ljmin,ljmax
         distp = sqrt((xxp(i)-xpatch(k))**2.0_rsh + (yyp(j)-ypatch(k))**2.0_rsh)
         IF (distp.LE.(diam_patch/2.0_rsh)) obst_position(iobst,i,j) = 1.0_rsh
       ENDDO
     ENDDO
   ENDDO
#endif
#else
#if defined key_casobstflume_ganthy2015 || defined key_casobstflume_lefebvre2010
   IF (l_Tsed)THEN
     obst_position(1,obst_imin(IndTest):obst_imax(IndTest),:) = 0.0_rsh
   ELSE
     obst_position(1,obst_imin(IndTest):obst_imax(IndTest),:) = 1.0_rsh
   ENDIF
   z0b(obst_imin(IndTest):obst_imax(IndTest),:) = z0samp/1000.0_rsh
#else
#ifdef key_casobstflume2D_Test07_Multi
     obst_position(1,5:10,:)  = 1.0_rsh ! Z. noltei patch 1
     obst_position(1,17:25,:) = 1.0_rsh ! Z. noltei patch 2
     obst_position(1,40:50,:) = 1.0_rsh ! Z. noltei patch 3
     obst_position(1,65:75,:) = 1.0_rsh ! Z. noltei patch 4
     obst_position(2,20:35,:) = 1.0_rsh ! Z. marina patch 1
     obst_position(2,55:70,:) = 1.0_rsh ! Z. marina patch 2
     obst_position(3,30:40,:) = 1.0_rsh ! Oyster bags patch 1
     obst_position(3,50:60,:) = 1.0_rsh ! Oyster bags patch 1
     obst_position(4,5:15,:)  = 1.0_rsh ! Mussels Bags patch1
     obst_position(4,42:52,:) = 1.0_rsh ! Mussels Bags patch1
#else
     obst_position(1,36:53,:) = 1.0_rsh
#endif
#endif
#endif


#endif
#ifdef key_castestobstructions3D
   PRINT_DBG*, 'exit CAS_OBSTHYDROFLUME3D routine'
#else
   PRINT_DBG*, 'exit CAS_OBSTHYDROFLUME2DV routine'
#endif

  END SUBROUTINE cas_obsthydroflume
