UsesCase_MEDmesh_5.f90
Aller à la documentation de ce fichier.
!* This file is part of MED.
!*
!* COPYRIGHT (C) 1999 - 2020 EDF R&D, CEA/DEN
!* MED is free software: you can redistribute it and/or modify
!* it under the terms of the GNU Lesser General Public License as published by
!* the Free Software Foundation, either version 3 of the License, or
!* (at your option) any later version.
!*
!* MED 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
!* GNU Lesser General Public License for more details.
!*
!* You should have received a copy of the GNU Lesser General Public License
!* along with MED. If not, see <http://www.gnu.org/licenses/>.
!*
!*
!*
!* Use case 5 : read a 2D structured mesh
!*
program usescase_medmesh_5
implicit none
include 'med.hf90'
integer cret
integer*8 fid
integer nmesh, it, naxis, axis
integer coocha, geotra
character(64) :: mname = "2D structured mesh"
character(200) :: desc
character(16) :: dtunit
integer nstep, mdim, sdim, stype, mtype, atype, asize
integer gtype, ncell
character(16), dimension(:), allocatable :: aname
character(16), dimension (:), allocatable :: aunit
real*8, dimension (:), allocatable :: cooxaxis
real*8, dimension (:), allocatable :: cooyaxis
character*16, dimension (:), allocatable :: cnames
! open MED file
call mfiope(fid,'UsesCase_MEDmesh_4.med',med_acc_rdonly, cret)
if (cret .ne. 0 ) then
print *,'ERROR : open file'
call efexit(-1)
endif
! ... we know that the MED file has only one mesh,
! a real code working would check ...
! read computation space dimension
call mmhnan(fid,mname,naxis,cret)
if (cret .ne. 0 ) then
print *,'Read number of axis in the mesh'
call efexit(-1)
endif
print *,'Number of axis in the mesh = ',naxis
! read mesh informations
allocate ( aname(naxis), aunit(naxis) ,stat=cret )
if (cret > 0) then
print *,'Memory allocation'
call efexit(-1)
endif
call mmhmin(fid, mname, sdim, mdim, mtype, desc, dtunit, stype, nstep, atype, aname, aunit, cret)
if (cret .ne. 0 ) then
print *,'Read mesh informations'
call efexit(-1)
endif
print *,"mesh name =", mname
print *,"space dim =", sdim
print *,"mesh dim =", mdim
print *,"mesh type =", mtype
print *,"mesh description =", desc
print *,"dt unit = ", dtunit
print *,"sorting type =", stype
print *,"number of computing step =", nstep
print *,"coordinates axis type =", atype
print *,"coordinates axis name =", aname
print *,"coordinates axis units =", aunit
deallocate(aname, aunit)
! read grid type
call mmhgtr(fid,mname,gtype,cret)
if (cret .ne. 0 ) then
print *,'Read grid type'
call efexit(-1)
endif
print *,"grid type =", gtype
! ... we know that we the mesh is a cartesian grid,
! a real code working would check ...
! read the axis coordinates (MED_CARTESIAN coordinates system)
! X
axis = 1
call mmhnme(fid,mname,med_no_dt,med_no_it,med_node,med_none,med_coordinate_axis1,med_no_cmode,coocha,geotra,asize,cret)
if (cret .ne. 0 ) then
print *,'Read number of coordinates on X axis '
call efexit(-1)
endif
print *,"Number of coordinates on X axis =", asize
ncell = asize-1
allocate ( cooxaxis(asize),stat=cret )
if (cret > 0) then
print *,'Memory allocation'
call efexit(-1)
endif
call mmhgcr(fid,mname,med_no_dt,med_no_it,axis,cooxaxis,cret)
if (cret .ne. 0 ) then
print *,'Read axis X coordinates'
call efexit(-1)
endif
print *,"Axis X coordinates =", cooxaxis
deallocate(cooxaxis)
! Y
axis = 2
call mmhnme(fid,mname,med_no_dt,med_no_it,med_node,med_none,med_coordinate_axis2,med_no_cmode,coocha,geotra,asize,cret)
if (cret .ne. 0 ) then
print *,'Read number of coordinates on Y axis '
call efexit(-1)
endif
print *,"Number of coordinates on Y axis =", asize
ncell = ncell * (asize-1)
allocate ( cooyaxis(asize),stat=cret )
if (cret > 0) then
print *,'Memory allocation'
call efexit(-1)
endif
call mmhgcr(fid,mname,med_no_dt,med_no_it,axis,cooyaxis,cret)
if (cret .ne. 0 ) then
print *,'Read axis Y coordinates'
call efexit(-1)
endif
print *,"Axis Y coordinates =", cooyaxis
deallocate(cooyaxis)
! optionnal : read names for nodes or elements
print *,'ncell :', ncell
allocate ( cnames(ncell),stat=cret )
if (cret > 0) then
print *,'Memory allocation'
call efexit(-1)
endif
call mmhear(fid,mname,med_no_dt,med_no_it,med_cell,med_quad4,cnames,cret)
if (cret .ne. 0 ) then
print *,'Read names for elements'
call efexit(-1)
endif
print *,'Cells names =', cnames
deallocate(cnames)
! close file
call mficlo(fid,cret)
if (cret .ne. 0 ) then
print *,'ERROR : close file'
call efexit(-1)
endif
end program usescase_medmesh_5
usescase_medmesh_5
program usescase_medmesh_5
Definition UsesCase_MEDmesh_5.f90:23
mfiope
subroutine mfiope(fid, name, access, cret)
Ouverture d'un fichier MED.
Definition medfile.f:42
mficlo
subroutine mficlo(fid, cret)
Fermeture d'un fichier MED.
Definition medfile.f:82
mmhmin
subroutine mmhmin(fid, name, sdim, mdim, mtype, desc, dtunit, stype, nstep, atype, aname, aunit, cret)
Cette routine permet de lire les informations relatives à un maillage en précisant son nom.
Definition medmesh.f:130
mmhgtr
subroutine mmhgtr(fid, name, gtype, cret)
Cette routine permet de lire le type d'un maillage structuré (MED_STRUCTURED_MESH).
Definition medmesh.f:241
mmhnme
subroutine mmhnme(fid, name, numdt, numit, entype, geotype, datype, cmode, chgt, tsf, n, cret)
Cette routine permet de lire le nombre d'entités dans un maillage pour une étape de calcul donnée.
Definition medmesh.f:551
mmhnan
subroutine mmhnan(fid, name, naxis, cret)
Cette routine permet de lire dans un maillage le nombre d'axes du repère des coordonnées des noeuds a...
Definition medmesh.f:86
mmhear
subroutine mmhear(fid, mname, numdt, numit, entype, geotype, ename, cret)
Cette routine permet de lire les noms d'un type d'entité d'un maillage.
Definition medmesh.f:529
mmhgcr
subroutine mmhgcr(fid, name, numdt, numit, axis, index, cret)
Definition medmesh.f:404