!-------------------------------------- LICENCE BEGIN ------------------------------------
!Environment Canada - Atmospheric Science and Technology License/Disclaimer, 
!                     version 3; Last Modified: May 7, 2008.
!This is free but copyrighted software; you can use/redistribute/modify it under the terms 
!of the Environment Canada - Atmospheric Science and Technology License/Disclaimer 
!version 3 or (at your option) any later version that should be found at: 
!http://collaboration.cmc.ec.gc.ca/science/rpn.comm/license.html 
!
!This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
!without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
!See the above mentioned License/Disclaimer for more details.
!You should have received a copy of the License/Disclaimer along with this software; 
!if not, you can write to: EC-RPN COMM Group, 2121 TransCanada, suite 500, Dorval (Quebec), 
!CANADA, H9P 1J3; or send e-mail to service.rpn@ec.gc.ca
!-------------------------------------- LICENCE END --------------------------------------
***s/r e_gement_nml - Read namelist gement
*
#include "model_macros_f.h"
*

      integer function e_gement_nml (F_namelistf_S) 2
      implicit none
*
      character* (*) F_namelistf_S
*
*author
*     Michel Desgagne - Summer 2006
*
*revision
* v3_30 - Desgagne M.       - initial version
* v3_31 - Lee V.            - add Pil_maxcfl to control Pil_pil
*
*object
*  Default configuration and reading namelist gement
*
*implicits
#include "e_nml.cdk"
*
      integer  fnom
      external fnom
*
      character*120 dumc
      integer nrec,unf
*
*-------------------------------------------------------------------
*
      e_gement_nml = -1
*
      if ((F_namelistf_S.eq.'print').or.(F_namelistf_S.eq.'PRINT')) then
         e_gement_nml = 0
         write (6  ,nml=gement_p)
         return
      endif
*
* Defaults values for gement namelist variables
*
      Mod_runstrt_S ='@#$%'
      Pil_jobstrt_S ='@#$%'
      Pil_jobend_S  ='@#$%'
      Pil_sfc2d_L      = .true.
      Pil_3df_L        = .true.
      Pil_bcs_hollow_L = .true.
      Pil_bmf_L        = .false.
      Pil_dx           = 0.0
      Pil_maxcfl       = 1
      Pil_nesdt        = 0
      Pil_hblen        = 10
      Pil_lancemodel   = 10000
*
      Topo_filmx_L= .true.
      Topo_init_L = .true.
      Topo_dgfmx_L= .false.
      Topo_dgfms_L= .true.
*
      Anal_cond       = .false.
      anal_perturb    = .false.
      E_schm_stlag    = .true.
      E_schm_adcub    = .true.
      Schm_offline_L  = .false.
      E_geol_glanl_L  = .true.
      E_geol_glreg_L  = .false.
      E_geol_hsanl_L  = .true.
      E_geol_hscon_L  = .false.
      E_geol_hsreg_L  = .true.
      E_geol_gls  = 30.
      E_geol_gln  = 80.
      E_geol_glw  = 220.
      E_geol_gle  = 320.
      E_geol_hss  = 30.
      E_geol_hsn  = 80.
      E_geol_hsw  = 220.
      E_geol_hse  = 320.
      E_geol_hsea = 3000
      E_geol_poin = 3
      E_geol_modex_L = .false.
      E_geol_z0cst   = -1.
*
      Offline_int_accu_S = 'LINEAR'
      Offline_ip1a = 11950   
*
      E_tr3d_list_S = ''
*
      E_intwind_mta_L      = .FALSE.
      E_force_read_image_L = .FALSE.
*
      unf=0
      if (fnom (unf, F_namelistf_S, 'SEQ+OLD' , nrec) .eq. 0) then
         rewind(unf)
         read (unf, nml=gement, end=9110, err=9110)
         call fclos (unf)
         e_gement_nml = 1
         call low2up (Offline_int_accu_S,dumc)
         Offline_int_accu_S = dumc
         E_schm_offline_L=Schm_offline_L
         if (E_Schm_offline_L) Pil_bcs_hollow_L = .false.
         Pil_pil = max(1,Pil_maxcfl) + 5
         goto 7777
      else
         goto 9220
      endif
*
 9110 write (6, 8150) trim( F_namelistf_S )
      call fclos (unf)
      goto 7777
*
 9220 write (6, 8155) trim( F_namelistf_S )
*
 8150 format (/,' NAMELIST gement    INVALID IN FILE: ',a)
 8155 format (/,' FILE: ',a,' NOT AVAILABLE')
*
*-------------------------------------------------------------------
*
 7777 return
      end