MED fichier: Fichier source de UsesCase_MEDmesh_5.f90

MED fichier

- Documentation MED
- Guides d'utilisation
- Guides de référence

UsesCase_MEDmesh_5.f90
Aller à la documentation de ce fichier.
1 !* This file is part of MED.
2 !*
3 !* COPYRIGHT (C) 1999 - 2017 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
23 program usescase_medmesh_5
24
25 implicit none
26 include 'med.hf90'
27
28 integer cret
29 integer fid, nmesh, it, naxis, axis
30 integer coocha, geotra
31 character(64) :: mname = "2D structured mesh"
32 character(200) :: desc
33 character(16) :: dtunit
34 integer nstep, mdim, sdim, stype, mtype, atype, asize
35 integer gtype, ncell
36 character(16), dimension(:), allocatable :: aname
37 character(16), dimension (:), allocatable :: aunit
38 real*8, dimension (:), allocatable :: cooXaxis
39 real*8, dimension (:), allocatable :: cooYaxis
40 character*16, dimension (:), allocatable :: cnames
41
42 ! open MED file
43 call mfiope(fid,'UsesCase_MEDmesh_4.med',med_acc_rdonly, cret)
44 if (cret .ne. 0 ) then
45 print *,'ERROR : open file'
46 call efexit(-1)
47 endif
48
49 ! ... we know that the MED file has only one mesh,
50 ! a real code working would check ...
51
52 ! read computation space dimension
53 call mmhnan(fid,mname,naxis,cret)
54 if (cret .ne. 0 ) then
55 print *,'Read number of axis in the mesh'
56 call efexit(-1)
57 endif
58 print *,'Number of axis in the mesh = ',naxis
59
60 ! read mesh informations
61 allocate ( aname(naxis), aunit(naxis) ,stat=cret )
62 if (cret > 0) then
63 print *,'Memory allocation'
64 call efexit(-1)
65 endif
66
67 call mmhmin(fid, mname, sdim, mdim, mtype, desc, dtunit, stype, nstep, atype, aname, aunit, cret)
68 if (cret .ne. 0 ) then
69 print *,'Read mesh informations'
70 call efexit(-1)
71 endif
72 print *,"mesh name =", mname
73 print *,"space dim =", sdim
74 print *,"mesh dim =", mdim
75 print *,"mesh type =", mtype
76 print *,"mesh description =", desc
77 print *,"dt unit = ", dtunit
78 print *,"sorting type =", stype
79 print *,"number of computing step =", nstep
80 print *,"coordinates axis type =", atype
81 print *,"coordinates axis name =", aname
82 print *,"coordinates axis units =", aunit
83 deallocate(aname, aunit)
84
85 ! read grid type
86 call mmhgtr(fid,mname,gtype,cret)
87 if (cret .ne. 0 ) then
88 print *,'Read grid type'
89 call efexit(-1)
90 endif
91 print *,"grid type =", gtype
92
93 ! ... we know that we the mesh is a cartesian grid,
94 ! a real code working would check ...
95
96 ! read the axis coordinates (MED_CARTESIAN coordinates system)
97 ! X
98 axis = 1
99 call mmhnme(fid,mname,med_no_dt,med_no_it,med_node,med_none,med_coordinate_axis1,med_no_cmode,coocha,geotra,asize,cret)
100 if (cret .ne. 0 ) then
101 print *,'Read number of coordinates on X axis '
102 call efexit(-1)
103 endif
104 print *,"Number of coordinates on X axis =", asize
105 ncell = asize-1
106
107 allocate ( cooxaxis(asize),stat=cret )
108 if (cret > 0) then
109 print *,'Memory allocation'
110 call efexit(-1)
111 endif
112
113 call mmhgcr(fid,mname,med_no_dt,med_no_it,axis,cooxaxis,cret)
114 if (cret .ne. 0 ) then
115 print *,'Read axis X coordinates'
116 call efexit(-1)
117 endif
118 print *,"Axis X coordinates =", cooxaxis
119 deallocate(cooxaxis)
120
121 ! Y
122 axis = 2
123 call mmhnme(fid,mname,med_no_dt,med_no_it,med_node,med_none,med_coordinate_axis2,med_no_cmode,coocha,geotra,asize,cret)
124 if (cret .ne. 0 ) then
125 print *,'Read number of coordinates on Y axis '
126 call efexit(-1)
127 endif
128 print *,"Number of coordinates on Y axis =", asize
129 ncell = ncell * (asize-1)
130
131 allocate ( cooyaxis(asize),stat=cret )
132 if (cret > 0) then
133 print *,'Memory allocation'
134 call efexit(-1)
135 endif
136
137 call mmhgcr(fid,mname,med_no_dt,med_no_it,axis,cooyaxis,cret)
138 if (cret .ne. 0 ) then
139 print *,'Read axis Y coordinates'
140 call efexit(-1)
141 endif
142 print *,"Axis Y coordinates =", cooyaxis
143 deallocate(cooyaxis)
144
145 ! optionnal : read names for nodes or elements
146 print *,'ncell :', ncell
147 allocate ( cnames(ncell),stat=cret )
148 if (cret > 0) then
149 print *,'Memory allocation'
150 call efexit(-1)
151 endif
152
153 call mmhear(fid,mname,med_no_dt,med_no_it,med_cell,med_quad4,cnames,cret)
154 if (cret .ne. 0 ) then
155 print *,'Read names for elements'
156 call efexit(-1)
157 endif
158 print *,'Cells names =', cnames
159 deallocate(cnames)
160
161 ! close file
162 call mficlo(fid,cret)
163 if (cret .ne. 0 ) then
164 print *,'ERROR : close file'
165 call efexit(-1)
166 endif
167
168 end program usescase_medmesh_5
169
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:504
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:125
mficlo
subroutine mficlo(fid, cret)
Fermeture d'un fichier MED.
Definition: medfile.f:80
mmhgtr
subroutine mmhgtr(fid, name, gtype, cret)
Cette routine permet de lire le type d'un maillage structuré (MED_STRUCTURED_MESH).
Definition: medmesh.f:230
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 séquence de calcul donnée...
Definition: medmesh.f:525
mmhgcr
subroutine mmhgcr(fid, name, numdt, numit, axis, index, cret)
Cette routine permet la lecture des coordonnées des noeuds d'un maillage structuré selon un axe du re...
Definition: medmesh.f:385
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:83
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:41