UsesCase_MEDmesh_3.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 !*
00019 !*  Use case 3 : read an unstructured mesh : generic approach
00020 !*  - Computation step : NO
00021 !*
00022 
00023 program UsesCase_MEDmesh_3
00024 
00025   implicit none
00026   include 'med.hf90'
00027 
00028   integer cret
00029   integer fid, nmesh, imesh, naxis, igeo, geotyp, nelt
00030   character(64)  :: mname, gtname
00031   character(200) :: desc
00032   character(16)  :: dtunit
00033   integer nstep, mdim, sdim, stype, mtype, atype
00034   integer coocha, geotra, nnodes, ngeo
00035   character(16), dimension(:), allocatable :: aname
00036   character(16), dimension (:), allocatable :: aunit
00037   real*8, dimension(:), allocatable :: ncoord
00038 
00039   integer, dimension(:), allocatable :: connectivity
00040 
00041   ! open file             **
00042   call mfiope(fid,'UsesCase_MEDmesh_1.med',MED_ACC_RDONLY, cret)
00043   if (cret .ne. 0 ) then
00044      print *,'ERROR : open file'
00045      call efexit(-1)
00046   endif
00047 
00048   ! how many mesh in the file ? **
00049   call mmhnmh(fid,nmesh,cret)
00050   if (cret .ne. 0 ) then
00051      print *,'Read how many mesh'
00052      call efexit(-1)
00053   endif
00054   print *,'Number of mesh = ',nmesh
00055 
00056   do imesh=1,nmesh
00057 
00058      print *,'mesh iterator =',imesh
00059 
00060      ! read computation space dimension **
00061      call mmhnax(fid,imesh,naxis,cret)
00062      if (cret .ne. 0 ) then
00063         print *,'Read number of axis in the mesh'
00064         call efexit(-1)
00065      endif
00066      print *,'Number of axis in the mesh  = ',naxis
00067 
00068      allocate ( aname(naxis), aunit(naxis) ,STAT=cret )
00069      if (cret > 0) then
00070         print *,'Memory allocation'
00071         call efexit(-1)
00072      endif
00073      ! read mesh informations **
00074      call  mmhmii(fid, imesh, mname, sdim, mdim, mtype, desc, dtunit, stype, nstep, atype, aname, aunit, cret)
00075      if (cret .ne. 0 ) then
00076         print *,'Read mesh informations'
00077         call efexit(-1)
00078      endif
00079      print *,"mesh name =", mname
00080      print *,"space dim =", sdim
00081      print *,"mesh dim =", mdim
00082      print *,"mesh type =", mtype
00083      print *,"mesh description =", desc
00084      print *,"dt unit = ", dtunit
00085      print *,"sorting type =", stype
00086      print *,"number of computing step =", nstep
00087      print *,"coordinates axis type =", atype
00088      print *,"coordinates axis name =", aname
00089      print *,"coordinates axis units =", aunit
00090      deallocate(aname, aunit)
00091 
00092      ! read how many nodes in the mesh
00093      call mmhnme(fid,mname,MED_NO_DT,MED_NO_IT,MED_NODE,MED_NO_GEOTYPE,MED_COORDINATE,MED_NO_CMODE,coocha,geotra,nnodes,cret)
00094      if (cret .ne. 0 ) then
00095         print *,'Read how many nodes in the mesh'
00096         call efexit(-1)
00097      endif
00098      print *,"number of nodes in the mesh =", nnodes
00099 
00100      ! read mesh nodes coordinates
00101      allocate ( ncoord(nnodes*2) ,STAT=cret )
00102      if (cret > 0) then
00103         print *,'Memory allocation'
00104         call efexit(-1)
00105      endif
00106 
00107      call mmhcor(fid,mname,MED_NO_DT,MED_NO_IT,MED_FULL_INTERLACE,ncoord,cret)
00108      if (cret .ne. 0 ) then
00109         print *,'Nodes coordinates'
00110         call efexit(-1)
00111      endif
00112      print *,"Nodes coordinates =", ncoord
00113      deallocate(ncoord)
00114 
00115      ! read number of geometrical types for cells 
00116      call mmhnme(fid,mname,MED_NO_DT,MED_NO_IT,MED_CELL,MED_GEO_ALL,MED_CONNECTIVITY,MED_NODAL,coocha,geotra,ngeo,cret)
00117      if (cret .ne. 0 ) then
00118         print *,'Read number of geometrical types for cells'
00119         call efexit(-1)
00120      endif
00121      print *,"number of geometrical types for cells =", ngeo
00122 
00123      do igeo=1,ngeo
00124 
00125         print *,'mesh iterator =',imesh
00126 
00127         ! get geometry type
00128         call mmheni(fid,mname,MED_NO_DT,MED_NO_IT,MED_CELL,igeo,gtname,geotyp,cret)
00129         if (cret .ne. 0 ) then
00130            print *,'Read geometry type'
00131            call efexit(-1)
00132         endif
00133         print *,"Geometry type =", geotyp
00134 
00135         ! how many cells of type geotype ?
00136         call mmhnme(fid,mname,MED_NO_DT,MED_NO_IT,MED_CELL,geotyp,MED_CONNECTIVITY,MED_NODAL,coocha,geotra,nelt,cret)
00137         if (cret .ne. 0 ) then
00138            print *,'Read number of cells in the geotype'
00139            call efexit(-1)
00140         endif
00141         print *,"number of cells in the geotype =", nelt
00142 
00143         ! read mesh nodes coordinates
00144         allocate ( connectivity(nelt*4) ,STAT=cret )
00145         if (cret > 0) then
00146            print *,'Memory allocation - connectivity'
00147            call efexit(-1)
00148         endif
00149 
00150         ! read cells connectivity in the mesh
00151         call mmhcyr(fid,mname,MED_NO_DT,MED_NO_IT,MED_CELL,geotyp,MED_NODAL,MED_FULL_INTERLACE,connectivity,cret)
00152         if (cret .ne. 0 ) then
00153            print *,'Connectivity'
00154            call efexit(-1)
00155         endif
00156         print *,"Connectivity =", connectivity
00157         deallocate(connectivity)
00158 
00159      enddo
00160   enddo
00161 
00162   ! close file **
00163   call mficlo(fid,cret)
00164   if (cret .ne. 0 ) then
00165      print *,'ERROR :  close file'
00166      call efexit(-1)
00167   endif
00168 
00169 end program UsesCase_MEDmesh_3
00170 

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