MED fichier
f/test2.f
1 C* This file is part of MED.
2 C*
3 C* COPYRIGHT (C) 1999 - 2023 EDF R&D, CEA/DEN
4 C* MED is free software: you can redistribute it and/or modify
5 C* it under the terms of the GNU Lesser General Public License as published by
6 C* the Free Software Foundation, either version 3 of the License, or
7 C* (at your option) any later version.
8 C*
9 C* MED is distributed in the hope that it will be useful,
10 C* but WITHOUT ANY WARRANTY; without even the implied warranty of
11 C* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 C* GNU Lesser General Public License for more details.
13 C*
14 C* You should have received a copy of the GNU Lesser General Public License
15 C* along with MED. If not, see <http://www.gnu.org/licenses/>.
16 C*
17 
18 C ******************************************************************************
19 C * - Nom du fichier : test2.f
20 C *
21 C * - Description : exemples de creations de maillage MED
22 C *
23 C ******************************************************************************
24  program test2
25 C
26  implicit none
27  include 'med.hf'
28 C
29 C
30  integer cret,ret
31  integer*8 fid
32 
33  character*200 des
34  integer hdfok, medok
35  integer fexist, accok
36  character*16 nomcoo(2)
37  character*16 unicoo(2)
38  data nomcoo /"x","y"/, unicoo /"cm","cm"/
39 
40 
41 C ** verifie que le fichier test1.med existe et est accessible **
42  call mfiexi('test1.med', med_acc_rdonly, fexist, accok, cret)
43  print *,"fexistf :",fexist, " ; accok :", accok
44 
45 C ** verifie que le fichier test1.med est au bon format **
46  call mficom('test1.med',hdfok,medok,cret)
47  print *,hdfok, medok, cret
48  if (cret .ne. 0 ) then
49  print *,'Erreur à la vérification du format'
50  call efexit(-1)
51  endif
52 
53 C ** Ouverture en mode de lecture du fichier test1.med
54  call mfiope(fid,'test1.med',med_acc_rdonly, cret)
55  print *,cret
56  if (cret .ne. 0 ) then
57  print *,'Erreur ouverture du fichier en lecture'
58  call efexit(-1)
59  endif
60 
61 C ** Lecture de l'en-tete du fichier
62  call mficor(fid,des,cret)
63  print *,cret
64  if (cret .ne. 0 ) then
65  print *,'Erreur lecture en-tete du fichier'
66  call efexit(-1)
67  endif
68  print *,"DESCRIPTEUR DE FICHIER : ",des
69 
70 
71 C ** Fermeture du fichier test1.med
72  call mficlo(fid,cret)
73  print *,cret
74  if (cret .ne. 0 ) then
75  print *,'Erreur fermeture du fichier'
76  call efexit(-1)
77  endif
78 
79 
80  call mfiexi('test2.med', med_acc_rdwr, fexist, accok, cret)
81  print *,"fexistf :",fexist, " ; accok :", accok
82 
83 C ** Ouverture en mode de creation du fichier test2.med
84  call mfiope(fid,'test2.med',med_acc_rdwr, cret)
85  print *,cret
86  if (cret .ne. 0 ) then
87  print *,'Erreur creation du fichier'
88  call efexit(-1)
89  endif
90 
91 C ** Creation du maillage maa1 de type non structure
92 C ** et de dimension 2
93  call mmhcre(fid,'maa1',2,2,
94  & med_unstructured_mesh,'un premier maillage',
95  & "",med_sort_dtit,med_cartesian,nomcoo,unicoo,ret)
96  print *,cret
97  cret = cret + ret
98 C ** Creation du nom universel
99  call mmhunw(fid,'maa1',ret)
100  cret = cret + ret
101  print *,cret
102  if (cret .ne. 0 ) then
103  print *,'Erreur creation du maillage'
104  call efexit(-1)
105  endif
106 
107 C ** Creation du maillage maa2 de type non structure
108  call mmhcre(fid,'maa2',2,2,
109  & med_unstructured_mesh,'un second maillage',
110  & "",med_sort_dtit,med_cartesian,nomcoo,unicoo,ret)
111  cret = cret + ret
112  if (cret .ne. 0 ) then
113  print *,'Erreur creation du maillage'
114  call efexit(-1)
115  endif
116 
117 
118 C ** Creation du maillage maa3 de type structure
119  call mmhcre(fid,'maa3',2,2,
120  & med_structured_mesh,'un troisieme maillage',
121  & "",med_sort_dtit,med_cartesian,nomcoo,unicoo,ret)
122  cret = cret + ret
123  print *,cret
124  if (cret .ne. 0 ) then
125  print *,'Erreur creation du maillage'
126  call efexit(-1)
127  endif
128 
129 C ** Fermeture du fichier
130  call mficlo(fid,cret)
131  print *,cret
132  if (cret .ne. 0 ) then
133  print *,'Erreur fermeture du fichier'
134  call efexit(-1)
135  endif
136 C
137  end
138 
139 
140 
141 
142 
mficom
subroutine mficom(fname, hdfok, medok, cret)
Vérification de la compatibilité d'un fichier avec HDF et MED.
Definition: medfile.f:170
test2
program test2
Definition: test2.f:24
mmhunw
subroutine mmhunw(fid, name, cret)
Cette routine permet l'écriture du nom universel d'un maillage.
Definition: medmesh.f:150
mmhcre
subroutine mmhcre(fid, name, sdim, mdim, mtype, desc, dtunit, stype, atype, aname, aunit, cret)
Cette routine permet de créer un maillage dans un fichier.
Definition: medmesh.f:20
mficlo
subroutine mficlo(fid, cret)
Fermeture d'un fichier MED.
Definition: medfile.f:82
mfiexi
subroutine mfiexi(fname, access, fexist, accok, cret)
Interroge l'existence d'un fichier de nom filename et la possibilité de l'ouvrir selon le mode d'accè...
Definition: medfile.f:244
mficor
subroutine mficor(fid, cmt, cret)
Lecture d'un descripteur dans un fichier MED.
Definition: medfile.f:116
mfiope
subroutine mfiope(fid, name, access, cret)
Ouverture d'un fichier MED.
Definition: medfile.f:42