MED fichier
UsesCase_MEDmesh_5.f90
Aller à la documentation de ce fichier.
1!* This file is part of MED.
2!*
3!* COPYRIGHT (C) 1999 - 2020 EDF R&D, CEA/DEN
4!* MED is free software: you can redistribute it and/or modify
5!* it under the terms of the GNU Lesser General Public License as published by
6!* the Free Software Foundation, either version 3 of the License, or
7!* (at your option) any later version.
8!*
9!* MED is distributed in the hope that it will be useful,
10!* but WITHOUT ANY WARRANTY; without even the implied warranty of
11!* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12!* GNU Lesser General Public License for more details.
13!*
14!* You should have received a copy of the GNU Lesser General Public License
15!* along with MED. If not, see <http://www.gnu.org/licenses/>.
16!*
17
18!*
19!*
20!* Use case 5 : read a 2D structured mesh
21!*
22
24
25 implicit none
26 include 'med.hf90'
27
28 integer cret
29 integer*8 fid
30 integer nmesh, it, naxis, axis
31 integer coocha, geotra
32 character(64) :: mname = "2D structured mesh"
33 character(200) :: desc
34 character(16) :: dtunit
35 integer nstep, mdim, sdim, stype, mtype, atype, asize
36 integer gtype, ncell
37 character(16), dimension(:), allocatable :: aname
38 character(16), dimension (:), allocatable :: aunit
39 real*8, dimension (:), allocatable :: cooxaxis
40 real*8, dimension (:), allocatable :: cooyaxis
41 character*16, dimension (:), allocatable :: cnames
42
43 ! open MED file
44 call mfiope(fid,'UsesCase_MEDmesh_4.med',med_acc_rdonly, cret)
45 if (cret .ne. 0 ) then
46 print *,'ERROR : open file'
47 call efexit(-1)
48 endif
49
50 ! ... we know that the MED file has only one mesh,
51 ! a real code working would check ...
52
53 ! read computation space dimension
54 call mmhnan(fid,mname,naxis,cret)
55 if (cret .ne. 0 ) then
56 print *,'Read number of axis in the mesh'
57 call efexit(-1)
58 endif
59 print *,'Number of axis in the mesh = ',naxis
60
61 ! read mesh informations
62 allocate ( aname(naxis), aunit(naxis) ,stat=cret )
63 if (cret > 0) then
64 print *,'Memory allocation'
65 call efexit(-1)
66 endif
67
68 call mmhmin(fid, mname, sdim, mdim, mtype, desc, dtunit, stype, nstep, atype, aname, aunit, cret)
69 if (cret .ne. 0 ) then
70 print *,'Read mesh informations'
71 call efexit(-1)
72 endif
73 print *,"mesh name =", mname
74 print *,"space dim =", sdim
75 print *,"mesh dim =", mdim
76 print *,"mesh type =", mtype
77 print *,"mesh description =", desc
78 print *,"dt unit = ", dtunit
79 print *,"sorting type =", stype
80 print *,"number of computing step =", nstep
81 print *,"coordinates axis type =", atype
82 print *,"coordinates axis name =", aname
83 print *,"coordinates axis units =", aunit
84 deallocate(aname, aunit)
85
86 ! read grid type
87 call mmhgtr(fid,mname,gtype,cret)
88 if (cret .ne. 0 ) then
89 print *,'Read grid type'
90 call efexit(-1)
91 endif
92 print *,"grid type =", gtype
93
94 ! ... we know that we the mesh is a cartesian grid,
95 ! a real code working would check ...
96
97 ! read the axis coordinates (MED_CARTESIAN coordinates system)
98 ! X
99 axis = 1
100 call mmhnme(fid,mname,med_no_dt,med_no_it,med_node,med_none,med_coordinate_axis1,med_no_cmode,coocha,geotra,asize,cret)
101 if (cret .ne. 0 ) then
102 print *,'Read number of coordinates on X axis '
103 call efexit(-1)
104 endif
105 print *,"Number of coordinates on X axis =", asize
106 ncell = asize-1
107
108 allocate ( cooxaxis(asize),stat=cret )
109 if (cret > 0) then
110 print *,'Memory allocation'
111 call efexit(-1)
112 endif
113
114 call mmhgcr(fid,mname,med_no_dt,med_no_it,axis,cooxaxis,cret)
115 if (cret .ne. 0 ) then
116 print *,'Read axis X coordinates'
117 call efexit(-1)
118 endif
119 print *,"Axis X coordinates =", cooxaxis
120 deallocate(cooxaxis)
121
122 ! Y
123 axis = 2
124 call mmhnme(fid,mname,med_no_dt,med_no_it,med_node,med_none,med_coordinate_axis2,med_no_cmode,coocha,geotra,asize,cret)
125 if (cret .ne. 0 ) then
126 print *,'Read number of coordinates on Y axis '
127 call efexit(-1)
128 endif
129 print *,"Number of coordinates on Y axis =", asize
130 ncell = ncell * (asize-1)
131
132 allocate ( cooyaxis(asize),stat=cret )
133 if (cret > 0) then
134 print *,'Memory allocation'
135 call efexit(-1)
136 endif
137
138 call mmhgcr(fid,mname,med_no_dt,med_no_it,axis,cooyaxis,cret)
139 if (cret .ne. 0 ) then
140 print *,'Read axis Y coordinates'
141 call efexit(-1)
142 endif
143 print *,"Axis Y coordinates =", cooyaxis
144 deallocate(cooyaxis)
145
146 ! optionnal : read names for nodes or elements
147 print *,'ncell :', ncell
148 allocate ( cnames(ncell),stat=cret )
149 if (cret > 0) then
150 print *,'Memory allocation'
151 call efexit(-1)
152 endif
153
154 call mmhear(fid,mname,med_no_dt,med_no_it,med_cell,med_quad4,cnames,cret)
155 if (cret .ne. 0 ) then
156 print *,'Read names for elements'
157 call efexit(-1)
158 endif
159 print *,'Cells names =', cnames
160 deallocate(cnames)
161
162 ! close file
163 call mficlo(fid,cret)
164 if (cret .ne. 0 ) then
165 print *,'ERROR : close file'
166 call efexit(-1)
167 endif
168
169end program usescase_medmesh_5
170
program usescase_medmesh_5
subroutine mfiope(fid, name, access, cret)
Ouverture d'un fichier MED.
Definition: medfile.f:42
subroutine mficlo(fid, cret)
Fermeture d'un fichier MED.
Definition: medfile.f:82
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
subroutine mmhgtr(fid, name, gtype, cret)
Cette routine permet de lire le type d'un maillage structuré (MED_STRUCTURED_MESH).
Definition: medmesh.f:241
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
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
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
subroutine mmhgcr(fid, name, numdt, numit, axis, index, cret)
Definition: medmesh.f:404