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

  SUBROUTINE init_marsweb_simu

   !&E---------------------------------------------------------------------
   !&E                 ***  ROUTINE init_marsweb_simu ***
   !&E
   !&E ** Purpose : initialize the parameters set using the MARSWEB interface
   !&E              for the configuration of boundary conditions
   !&E
   !&E ** Description : main, zoom
   !&E
   !&E ** Called by : tool_datosec
   !&E
   !&E ** External calls :
   !&E
   !&E ** Reference :
   !&E
   !&E ** History :
   !&E       !          Original code
   !&E       !  2002-10-23  last modifications
   !&E
   !&E---------------------------------------------------------------------
   !! * Modules used
   USE parameters
   USE comvars2d
   USE comvars3d
   USE cometdyn
   USE cometemp
   USE comaree
   USE comfluxdo
#ifdef key_substance
   USE comsubstance
#endif
   USE comdiag
#if defined key_trajec2d || defined key_trajec3d || defined key_ibm
   USE comtraj,     ONLY : file_trajec
#endif
   USE trackpoints, ONLY : l_points,file_point
   USE output
   IMPLICIT NONE

   !! * Arguments

   !! * Local declarations

   CHARACTER(len=2)      :: nvers
   CHARACTER(len=lchain) :: modele,ficsimu
   CHARACTER(len=lchain) :: path_inputs,path_outputs,path_obc
   CHARACTER(len=19)     :: date_start,date_end,date_startout,date_endout
   CHARACTER(LEN=19)     :: comdate,tool_sectodat
   CHARACTER(LEN=200)    :: fileresu_mw
   LOGICAL               :: trac,riv,rej,l_trajec
   INTEGER               :: i,climassoc
   REAL(kind=rsh)        :: tool_latlon2i,tool_latlon2j
   REAL(kind=rlg)        :: tool_datosec,tdb,tfi
   REAL(KIND=rlg)        :: gwext,geext,fisext,finext,pasor_mw

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

   ! les namelists du para.commun
   !------------------------------

   NAMELIST/namhead/ modele,simunum,climassoc
   NAMELIST/namdate/ date_start,date_end
   NAMELIST/namoutput/ file_output
   NAMELIST/namriver/  riv,file_river
#ifdef key_substance
   NAMELIST/namtrac/ trac,name_filesubs
   NAMELIST/namrej/  rej,file_outflow
#endif
   NAMELIST/namdiag/ l_points,file_point
#if defined key_trajec2d || defined key_trajec3d
   NAMELIST/namtraj/ l_trajec,file_trajec
#endif

   ! lecture des namelists
   !-----------------------
   ! namelist a chercher dans le bon repertoire commune a tous les rangs
   !----------------------------------

   CALL getarg(1,path_obc)
   CALL getarg(2,path_inputs)
   CALL getarg(3,path_outputs)
   root=TRIM(path_outputs)
   ficsimu=TRIM(path_inputs)//'/simu.txt'
   WRITE(nvers,'(i1)') no
   filecl = TRIM(path_obc)//'/cl_rg'//TRIM(nvers)

   DEALLOCATE(tchrono)

   OPEN(50,file=ficsimu,status='old',form='formatted',access='sequential')
   READ(50,namhead)
   READ(50,namdate)
   READ(50,namoutput)
   READ(50,namriver)
#ifdef key_substance
   READ(50,namtrac)
   READ(50,namrej)
#endif
   READ(50,namdiag)
#if defined key_trajec2d || defined key_trajec3d
   READ(50,namtraj)
#endif
   CLOSE(50)

   tdeb = tool_datosec(date_start)
   tfin = tool_datosec(date_end)

   ! remplissage d un fichier de chronologie.
   ! pour simplifier les sequences de rejet et de debits.
   !-------------------------------------------------------

   l_chrono=.FALSE.
   tdb=tdeb+date_startshift*86400.0_rlg-perchrono
   tfi=tfin+perchrono
   nvalmax=NINT((tfi-tdb)/perchrono+0.5_rlg)+1
   ALLOCATE(tchrono(nvalmax))
   DO i=1,nvalmax 
     tchrono(i)=tdb+(i-1.0_rlg)*perchrono
   END DO
   indchrono=1
   l_chrono=.TRUE.
   ! fin de remplissage du vecteur chronologie

   t=tdeb+date_startshift*86400.0_rlg ! dates et pas de temps
   tdeb3d=tdeb
   tsauv=tdeb + saverestart_step
   cdate = tool_sectodat(t)
   CALL tool_decompdate(cdate,ijour,imois,ian,iheure,iminu,isec)

END SUBROUTINE init_marsweb_simu
