UsesCase_MEDmesh_14.f90

Aller à la documentation de ce fichier.
00001 !*  This file is part of MED.
00002 !*
00003 !*  COPYRIGHT (C) 1999 - 2015  EDF R&D, CEA/DEN
00004 !*  MED is free software: you can redistribute it and/or modify
00005 !*  it under the terms of the GNU Lesser General Public License as published by
00006 !*  the Free Software Foundation, either version 3 of the License, or
00007 !*  (at your option) any later version.
00008 !*
00009 !*  MED is distributed in the hope that it will be useful,
00010 !*  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 !*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 !*  GNU Lesser General Public License for more details.
00013 !*
00014 !*  You should have received a copy of the GNU Lesser General Public License
00015 !*  along with MED.  If not, see <http://www.gnu.org/licenses/>.
00016 !*
00017 !*
00018 !*  Use case 14 : read a 2D unstructured mesh with 2 polygons
00019 !*
00020 
00021 program UsesCase_MEDmesh_14
00022 
00023   implicit none
00024   include 'med.hf90'
00025 
00026   integer cret
00027   integer fid
00028   
00029   ! mesh name
00030   character*64 mname
00031   ! file name
00032   character*64 finame
00033   ! mesh description
00034   character*200 mdesc
00035   ! mesh dim, space dim
00036   integer mdim, sdim
00037   !sorting type
00038   integer stype
00039   ! number of computing step
00040   integer nstep
00041   ! mesh type, coordinate axis type
00042   integer mtype, atype
00043   ! axis name, unit name
00044   character*16 axname(2), unname(2)
00045   ! time step unit
00046   character*16 dtunit
00047   ! coordinates
00048   real*8, dimension(:), allocatable :: coords
00049   integer nnodes
00050   integer npoly
00051   ! index size
00052   integer isize
00053   integer, dimension(:), allocatable :: index 
00054   ! connectivity
00055   integer, dimension(:), allocatable :: conity 
00056   ! connectivity size
00057   integer cosize
00058   ! coordinate changement, geotransformation
00059   integer coocha, geotra
00060 
00061   parameter (mname = "2D unstructured mesh")
00062   parameter (finame = "UsesCase_MEDmesh_13.med")
00063 
00064   ! open MED file with READ ONLY access mode
00065   call mfiope(fid, finame, MED_ACC_RDONLY, cret)
00066   if (cret .ne. 0 ) then
00067      print *,'ERROR : open file'
00068      call efexit(-1)
00069   endif
00070 
00071   ! read mesh informations : mesh dimension, space dimension ...
00072   call  mmhmin(fid, mname, sdim, mdim, mtype, mdesc, dtunit, stype, nstep, atype, axname, unname, cret)
00073   if (cret .ne. 0 ) then
00074      print *,'Read mesh informations'
00075      call efexit(-1)
00076   endif
00077   print *,"mesh name =", mname
00078   print *,"space dim =", sdim
00079   print *,"mesh dim =", mdim
00080   print *,"mesh type =", mtype
00081   print *,"mesh description =", mdesc
00082   print *,"dt unit = ", dtunit
00083   print *,"sorting type =", stype
00084   print *,"number of computing step =", nstep
00085   print *,"coordinates axis type =", atype
00086   print *,"coordinates axis name =", axname
00087   print *,"coordinates axis units =", unname
00088 
00089   ! read how many nodes in the mesh
00090   call mmhnme(fid,mname,MED_NO_DT,MED_NO_IT,MED_NODE,MED_POINT1,MED_COORDINATE,MED_NO_CMODE,coocha,geotra,nnodes,cret)
00091   if (cret .ne. 0 ) then
00092      print *,'Read number of nodes ...'
00093      call efexit(-1)
00094   endif
00095   print *,"Number of nodes  =", nnodes
00096 
00097   ! we know that we only have MED_POLYGON celles in the mesh, 
00098   ! a real code working would check all MED geometry cell types ...
00099 
00100   ! How many polygon in the mesh in nodal connectivity mode
00101   ! For the polygons, we get the size of array index
00102   call mmhnme(fid,mname,MED_NO_DT,MED_NO_IT,MED_CELL,MED_POLYGON,MED_INDEX_NODE,MED_NODAL,coocha,geotra,isize,cret)
00103   if (cret .ne. 0 ) then
00104      print *,'Read number of polygon ...'
00105      call efexit(-1)
00106   endif
00107   npoly = isize - 1
00108   print *,"Number of polygons  =", npoly
00109 
00110   ! how many nodes for the polygon connectivity ? 
00111   call mmhnme(fid,mname,MED_NO_DT,MED_NO_IT,MED_CELL,MED_POLYGON,MED_CONNECTIVITY,MED_NODAL,coocha,geotra,cosize,cret)
00112   if (cret .ne. 0 ) then
00113      print *,'Read connectivity size ...'
00114      call efexit(-1)
00115   endif
00116   print *,"Read connectivity size ...", cosize
00117 
00118   ! read mesh nodes coordinates
00119   allocate (coords(nnodes*sdim),STAT=cret)
00120   if (cret .ne. 0) then
00121      print *,'Memory allocation'
00122      call efexit(-1)
00123   endif
00124 
00125   call mmhcor(fid,mname,MED_NO_DT,MED_NO_IT,MED_FULL_INTERLACE,coords,cret)
00126   if (cret .ne. 0 ) then
00127      print *,'Read nodes coordinates ...'
00128      call efexit(-1)
00129   endif
00130   print *,"Read nodes coordinates ...", coords
00131 
00132   deallocate(coords)
00133 
00134   ! read polygons connectivity mmhpgr
00135   allocate (index(isize),STAT=cret)
00136   if (cret .ne. 0) then
00137      print *,'Memory allocation'
00138      call efexit(-1)
00139   endif
00140 
00141   allocate (conity(cosize),STAT=cret)
00142   if (cret .ne. 0) then
00143      print *,'Memory allocation'
00144      call efexit(-1)
00145   endif
00146 
00147   call mmhpgr(fid,mname,MED_NO_DT,MED_NO_IT,MED_CELL,MED_NODAL,index,conity,cret)
00148   if (cret .ne. 0 ) then
00149      print *,'Read polygon connectivity ...'
00150      call efexit(-1)
00151   endif
00152   print *,"Read polygon connectivity ...", conity
00153 
00154   deallocate(index)
00155   deallocate(conity)
00156 
00157   ! ... we know that the family number of nodes and elements is 0, a real working would check ...
00158 
00159 ! close MED file
00160   call mficlo(fid,cret)
00161   if (cret .ne. 0 ) then
00162      print *,'ERROR :  close file'
00163      call efexit(-1)
00164   endif
00165 
00166 end program UsesCase_MEDmesh_14

Généré le Thu Oct 8 14:26:17 2015 pour MED fichier par  doxygen 1.6.1