  SUBROUTINE cas_seamount

   !&E---------------------------------------------------------------------
   !&E                 ***  ROUTINE cas_seamount  ***
   !&E
   !&E ** Purpose : definition of a test case for a seamount
   !&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
   !&E ** Reference :
   !&E
   !&E ** History :
   !&E       !  2006-01  (F. Dumas, V. Garnier) Original code
   !&E       !  2008-12  (V. Garnier) shift of sigma values : -1 < sig < 0
   !&E
   !&E---------------------------------------------------------------------

#include "toolcpp.h"

   !! * Modules used
   USE parameters,ONLY : rsh,rlg,riolg,imin,imax,jmin,jmax,kmax,  &
                         liminm1,limaxp2,ljminm1,ljmaxp2,    &
                         valmanq,pi
   USE comvars2d, ONLY : fisac,gwac,dtmin,dtmax,dt,halfdt,suffix,   &
                         qmax,h0,tfiusr,tfivsr,h0fond,radearth, &
                         hx_g,hy_g,h0_g
   USE comvarp2d, ONLY : temp
   USE comvars3d, ONLY : qmaxz,nzinit,kzinit,l_stateeq_lin,rhoref,saliref, &
                         tetaref,saliref_lin,tetaref_lin,sig
   USE output, ONLY : pasor,l_out_sal
!   USE cometemp
#if defined key_siggen || defined key_gencoord
   USE comsiggen, ONLY : theta_sig,b_sig,hc
#endif
   USE toolgeom,  ONLY : f_zu
   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
   INTEGER           :: i,j,k
   INTEGER           :: ni_wall_e,ni_wall_w,nj_wall_n,nj_wall_s
   REAL(KIND=rsh)    :: A,L,hmax,dxp,dyp,zr,dxval,dyval
   REAL(KIND=rsh)    :: z0bottom,z0surface,depthcst

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

  
   PRINT_DBG*, 'enter CAS_SEAMOUNT routine'

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

   ! dynamics
   CALL cas_init_param

   ! over-assignement

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

   ! over-assignement
   qmax=12.0_rsh
   qmaxz=10.0_rsh
   rhoref=1000.0_rsh
   saliref=35.0_rsh
   tetaref=5.0_rsh
   l_stateeq_lin=.FALSE.
   saliref_lin=0.0_rsh
   tetaref_lin=0.0_rsh


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

   ! assignement : input variables for cas_init_bathy routine
   depthcst = 0.0_rsh
   ni_wall_e = 5  ! land over ni_wall_e cells at the eastern part of the domain
   ni_wall_w = 4  ! land over ni_wall_w cells (from imin column) at the western part of the domain
   nj_wall_s = 4  ! land over nj_wall_s cells (from jmin row) at the southern part of the domain
   nj_wall_n = 5  ! land over nj_wall_n cells at the northern part of the domain
#if defined key_siggen || defined key_gencoord
   hc= 5.0_rsh
#endif


   ! As depthcst is null, specify your own bathymetry

   dxval = 8000.0_rsh
   dyval = 8000.0_rsh
   hmax=4500.0_rsh
   A=0.6_rsh
   L=50000.0_rsh
   hx_g(:,:)=hmax
   hy_g(:,:)=hmax
!valrom a revoiravec h0
   DO i=imin,imax
     DO j=jmin,jmax
!       dxp=dx(i,j)*(REAL(i-imax/2,rsh))/L
!       dyp=dx(i,j)*(REAL(j-jmax/2,rsh))/L
       dxp=dxval*(REAL(i-imax/2,rsh))/L
       dyp=dxval*(REAL(j-jmax/2,rsh))/L
       hx_g(i,j)=hmax*( 1.0_rsh - A*EXP(-(dxp*dxp+dyp*dyp)))
       hy_g(i,j)=hx_g(i,j)
     END DO
   END DO
   hx_g(imin:imin+3,:)=-valmanq-h0fond
   hx_g(imax-5:imax,:)=-valmanq-h0fond
   hx_g(:,jmin:jmin+3)=-valmanq-h0fond
   hx_g(:,jmax-4:jmax)=-valmanq-h0fond
   hy_g(imin:imin+3,:)=-valmanq-h0fond
   hy_g(imax-4:imax,:)=-valmanq-h0fond
   hy_g(:,jmin:jmin+3)=-valmanq-h0fond
   hy_g(:,jmax-5:jmax)=-valmanq-h0fond

   DO j=jmin+1,jmax
     DO i=imin+1,imax
       h0_g(i,j)=MAX(hx_g(i,j),hx_g(i-1,j),hy_g(i,j),hy_g(i,j-1))+h0fond
     END DO
   END DO
   DO j=jmin+1,jmax
     h0_g(imin,j)=MAX(hx_g(imin,j),hy_g(imin,j),hy_g(imin,j-1))+h0fond
   END DO
   DO i=imin+1,imax
     h0_g(i,jmin)=MAX(hx_g(i,jmin),hx_g(i-1,jmin),hy_g(i,jmin))+h0fond
   END DO
   h0_g(imin,jmin)=MAX(hx_g(imin,jmin),hy_g(imin,jmin))+h0fond


   ! walls
   CALL cas_init_bathy(depthcst,ni_wall_w=ni_wall_w,ni_wall_e=ni_wall_e, &
                                nj_wall_n=nj_wall_n,nj_wall_s=nj_wall_s)

   ! over-assignement


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

   ! assignement : input variables for cas_init_grid routine
 
   dxval = 8000.0_rsh
   dyval = 8000.0_rsh
   fisac=ASIN(0.0001_rsh/0.0001458_rsh)/(pi/180.0_rsh)
   gwac=1.0_riolg

#if defined key_siggen || defined key_gencoord
#ifdef key_siggen_g2
   theta_sig= 4.0_rsh ! entre 0 et 20
   b_sig= 0.0_rsh     ! entre 0 et 1
#else
   ! tends to sigma
   theta_sig= 0.0000001_rsh ! entre 0 et 20
   b_sig= 1.0_rsh     ! entre 0 et 1
#endif
#endif

   CALL cas_init_grid(dxval,dyval)

   ! over-assignement
   tfiusr(:,:)=TAN(fisac*pi/180.0_rsh)/radearth
   tfivsr(:,:)=TAN(fisac*pi/180.0_rsh)/radearth


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

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

   suffix='seamount'

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

   ! over-assignement
   pasor(1)=3600.0_rlg
   l_out_sal(1)=.FALSE.


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

   ! no open boundary
   CALL cas_init_obc


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

   ! none
   CALL cas_init_visc

   ! over-assignement


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

   z0bottom   =0.0035_rsh
   z0surface  =0.0_rsh
   nzinit=0.0_rsh
   kzinit=0.0_rsh

   ! 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
       IF (h0(i,j) > -valmanq) THEN
         DO k=1,kmax
           zr=-f_zu(h0(i,j),0.0_rsh,k,i,j)
           temp(k,i,j)= 5.0_rsh + 15.0_rsh*EXP(-zr/1000.0_rsh)
         END DO
       ELSE
         temp(:,i,j) = valmanq
       END IF
     END DO
   END DO


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

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


   PRINT_DBG*, 'exit CAS_SEAMOUNT routine'

  END SUBROUTINE cas_seamount
