MED fichier
f/2.3.6/test22.f
1 C* This file is part of MED.
2 C*
3 C* COPYRIGHT (C) 1999 - 2017 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 : test22.f
20 C*
21 C* - Description : lecture des valeurs scalaires numeriques dans un fichier MED
22 C ******************************************************************************
23  program test22
24 C
25  implicit none
26  include 'med.hf'
27 C
28  integer fid,cret
29  character*16 dtunit
30  character*32 nom
31  character*200 desc
32  integer vali
33  real*8 valr,dt
34  integer n,npdt,i,j,type,numdt,numo
35 C
36 C Ouverture du fichier test21.med en lecture seule
37 C
38  call efouvr(fid,'test21.med',med_lecture,cret)
39  print *,cret
40  if (cret .ne. 0 ) then
41  print *,'Erreur ouverture du fichier'
42  call efexit(-1)
43  endif
44  print *,'Ouverture du fichier test21.med'
45 C
46 C Lecture du nombre de variable scalaire
47 C
48  call efnsca(fid,n,cret)
49  print *,cret
50  if (cret .ne. 0 ) then
51  print *,'Erreur lecture du nombre de variable'
52  call efexit(-1)
53  endif
54  print *,'Nombre de variables scalaires : ',n
55 C
56 C Lecture des infos (type,description) propres
57 C a chaque variable
58 C
59  do 10 i=1,n
60  call efscai(fid,i,nom,type,desc,cret)
61  print *,cret
62  if (cret .ne. 0 ) then
63  print *,'Erreur lecture des infos'
64  call efexit(-1)
65  endif
66  print *,'- Scalaire de nom : ',nom
67  if (type.eq.med_float64) then
68  print *,' de type flottant'
69  else
70  print *,' de type entier'
71  endif
72  print *,' Description associee : ',desc
73 C
74 C Pour chaque scalaire, on regarde les valeurs associees
75 C eventuellement a un pas de temps et/ou un numero d'ordre
76 C
77  call efnspd(fid,nom,npdt,cret)
78  if (cret .ne. 0 ) then
79  print *,'Erreur lecture du nombre de pas de temps'
80  call efexit(-1)
81  endif
82  print *,cret
83  print *,' Nombre de valeurs : ',npdt
84 C
85  do 20 j=1,npdt
86  call efspdi(fid,nom,j,numdt,dtunit,dt,numo,cret)
87  print *,cret
88  if (cret .ne. 0 ) then
89  print *,'Erreur infos pas de temps'
90  call efexit(-1)
91  endif
92  print *,' Valeur ', j
93 C
94  if (numdt.eq.med_nopdt) then
95  print *,' - Aucun pas de temps'
96  else
97  print *,' - Pas de temps de numero ',numdt
98  print *,' de valeur : ',dt
99  print *,' unite : ',dtunit
100  endif
101 C
102  if (numo.eq.med_nonor) then
103  print *,' - Aucun numero ordre'
104  else
105  print *,' - Numero ordre : ',numo
106  endif
107 C
108  if (type.eq.med_float64) then
109 C ** Lecture de la valeur flottante associee
110 C ** au pas de temps
111  call efscfl(fid,nom,valr,numdt,numo,cret)
112  print *,cret
113  if (cret .ne. 0 ) then
114  print *,'Erreur lecture valeur'
115  call efexit(-1)
116  endif
117  print *,' - Valeur : ',valr
118  else
119 C ** Lecture de la valeur entiere associee
120 C ** au pas de temps
121  call efscel(fid,nom,vali,numdt,numo,cret)
122  print *,cret
123  if (cret .ne. 0 ) then
124  print *,'Erreur lecture valeur'
125  call efexit(-1)
126  endif
127  print *,' - Valeur : ',vali
128  endif
129 C
130  20 continue
131 C
132  10 continue
133 C
134 C Fermeture du fichier
135 C
136  call efferm(fid,cret)
137  print *,cret
138  if (cret .ne. 0 ) then
139  print *,'Erreur fermeture du fichier'
140  call efexit(-1)
141  endif
142  print *,'Fermeture du fichier test21.med'
143 C
144  end