MODULE grid_param
   USE ISO_C_BINDING
   USE read_pmesh_mod, ONLY: t_pmesh
   IMPLICIT NONE
   SAVE

! Some variables are BIND(C) to be accessible from Python
! They are declared using C sizes

! FIMXE : BIND(C) for llm and nqdyn causes an error with ifort ; try again later
   INTEGER(C_INT) :: llm = 19  ! number of vertical levels
   INTEGER(C_INT) :: nqdyn   ! number of dynamical tracers : 1 if dry, more if moist

   INTEGER  :: nqtot ! number of tracers handled by advection scheme

   INTEGER  :: grid_type ! unstructured or icosahedral
   INTEGER, PARAMETER :: grid_unst = 1, grid_ico = 2

   ! icosahedral mesh parameters
   INTEGER  :: iim_glo = 40
   INTEGER  :: jjm_glo

   ! unstructured mesh parameters

   INTEGER(C_INT), BIND(C) :: &
      max_primal_deg, & ! number of primal cell edges (max)
      max_dual_deg, & ! number of dual cell edges (max)
      max_trisk_deg     ! size of TRiSK stencil (max)

   TYPE(t_pmesh), TARGET, SAVE :: pmesh

!  INTEGER(C_INT), BIND(C) :: &
   INTEGER(C_INT) :: &
      edge_num, & ! number of edges (halo included)
      primal_num, & ! number of primal cells (idem)
      dual_num          ! number of dual cells (idem)

   PRIVATE :: t_pmesh

END MODULE grid_param
