 SUBROUTINE read_mame(calc,icode,iarg)
!=========================== DOCUMENTATION ============================= 
!DOCDEBh*    UTI/PRE/read_mame *
!
!    NOM
! read_mame(calc,icode,iarg)
!    DESCRIPTION  
!*
! Lecture du Bloc MAME du fichier de donnees *.inp
! Reading the MAME block from the *.inp data file
!*
! 
!    ENTREES / INPUT
!    calc        : objet calcul / calculation object
!    icode,iarg  : 1,0/ tube a choc / shock tube
!                  1,1/ rectangle 2D / rectangle 2D
!                  1,2/ cube 3D / cube 3D
!                  2,*/ Maillage au format gmsh / Mesh in gmsh format
!
!    SORTIES / OUTPUT
!    calc%msh    : maillage / mesh
!
!    SOURCE
! Ce logiciel est regi par la licence [CeCILL-B]
! This software is governed by the [CeCILL-B] license
!=========================== DEBUT DES DECLARATIONS ==================== 
!.1-----  Implicit, Use
  use num
  use uti, only: mame2bloc,read_gmsh
  IMPLICIT NONE
!.2-----  Declaration
  type(calcul), intent(inout)        :: calc !! Objet calcul / Calcul object
  integer, intent(in)                :: icode,iarg !! Code, argument
  
  integer                            :: nx,ny,nz
  real(kind=kind(0.d0))              :: xmin,xmax,ymin,ymax,zmin,zmax
  character(20)                      :: fichmsh
!=========================== DEBUT DU CODE EXECUTABLE ==================
  write(*,*)
  write(*,*)achar(27)//'[34m================================================'
  write(*,*)'Reading Master mesh parameters: block MAME'
  write(*,*)'================================================'//achar(27)//'[0m'
  write(*,*)
  
nx=1;ny=1;nz=1

  SELECT CASE (icode)
      CASE (1) ! Creation d un maillage par CERF

          SELECT CASE (iarg)
              CASE (0)
                  write(*,*) 'Master Mesh creation: 1D case'
                  read(33,*) xmin,xmax
                  read(33,*)nx
                  calc%msh%ndim=1
                  ymin=-(xmax-xmin)*0.5d0/nx
                  ymax= (xmax-xmin)*0.5d0/nx
                  zmin=-(xmax-xmin)*0.5d0/nx
                  zmax= (xmax-xmin)*0.5d0/nx

              CASE (1)
                  write(*,*) 'Master Mesh creation: 2D case'
                  read(33,*) xmin,xmax,ymin,ymax
                  read(33,*)nx,ny
                  calc%msh%ndim=2
                  zmin=-min((xmax-xmin)*0.5d0/nx,(ymax-ymin)*0.5d0/ny)
                  zmax= min((xmax-xmin)*0.5d0/nx,(ymax-ymin)*0.5d0/ny)
            
              CASE (2)
                  write(*,*) 'Master Mesh creation: 3D case'
                  read(33,*) xmin,xmax,ymin,ymax,zmin,zmax
                  calc%msh%ndim=3
                  read(33,*)nx,ny,nz
          END SELECT
          calc%nb_bloc=nx*ny*nz
          allocate(calc%list_bloc(calc%nb_bloc))
          call mame2bloc(xmin,xmax,ymin,ymax,zmin,zmax,nx,ny,nz,calc%list_bloc,calc%msh%ndim)
!-----------------------------------------------------
      CASE (2) ! Lecture  du maillage sur fichier au format gmsh V2.2
          write(*,*)'MAME-Info reading GMSH mesh '
          read(33,'(a)')fichmsh
          write(*,*)
          write( *,1000)fichmsh
1000 format(' MAME-Info Reading the GMSH file: ',a20)
          calc%msh%ndim=iarg
          CALL read_gmsh  (fichmsh,calc) !----- Lecture du maillage maitre complet
          calc%msh%nb_dom=1

      CASE DEFAULT
         call print_err('READ_MAME', 'Master Mesh definition unforeseen case')

  END SELECT



!===========================   FIN DE LA ROUTINE    ====================
END SUBROUTINE read_mame
!DOCFIN