1C*  This file is part of MED.
2C*
3C*  COPYRIGHT (C) 1999 - 2019  EDF R&D, CEA/DEN
4C*  MED is free software: you can redistribute it and/or modify
5C*  it under the terms of the GNU Lesser General Public License as published by
6C*  the Free Software Foundation, either version 3 of the License, or
7C*  (at your option) any later version.
8C*
9C*  MED is distributed in the hope that it will be useful,
10C*  but WITHOUT ANY WARRANTY; without even the implied warranty of
11C*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12C*  GNU Lesser General Public License for more details.
13C*
14C*  You should have received a copy of the GNU Lesser General Public License
15C*  along with MED.  If not, see <http://www.gnu.org/licenses/>.
16C*
17
18C******************************************************************************
19C * - Description : open/close med files
20C *
21C *****************************************************************************
22      program test1
23C
24      implicit none
25      include 'med.hf'
26C
27C
28      integer cret
29      integer*8 fid
30
31      character*255 fname
32      character*200 des
33      parameter (des = "Ceci est un courte description"
34     1     // " du fichier test1.med")
35
36C     Creation du fichier "test1.med"
37      call mfiope(fid,'test1.med',MED_ACC_RDWR, cret)
38      print *,cret
39      if (cret .ne. 0 ) then
40         print *,'Erreur à la création du fichier'
41         call efexit(-1)
42      endif
43
44C     Ecriture d'un en-tete dans le fichier
45      call mficow(fid,des,cret)
46      print *,cret
47      if (cret .ne. 0 ) then
48         print *,'Erreur à ecriture en-tete'
49         call efexit(-1)
50      endif
51
52C     Lecture de la taille du nom de fichier "test1.med"
53      call mfinam(fid,"", cret)
54      print *,cret
55      if (cret .le. 0 ) then
56         print *,'Erreur à la lecture de la taille du nom de fichier'
57         call efexit(-1)
58      endif
59
60C     Lecture du nom de fichier "test1.med"
61      call mfinam(fid,fname, cret)
62      print *,cret
63      if (cret .le. 0 ) then
64         print *,'Erreur à la lecture du nom de fichier'
65         call efexit(-1)
66      endif
67      print *,fname
68
69C     Fermeture du fichier
70      call mficlo(fid,cret)
71      print *,cret
72      if (cret .ne. 0 ) then
73         print *,'Erreur à la fermeture du fichier'
74         call efexit(-1)
75      endif
76
77C     Re-ouverture du fichier en lecture seule
78      call mfiope(fid,'test1.med',MED_ACC_RDONLY, cret)
79      print *,cret
80      if (cret .ne. 0 ) then
81         print *,'Erreur ouverture du fichier en lecture'
82         call efexit(-1)
83      endif
84
85C     Fermeture du fichier
86      call mficlo(fid,cret)
87      print *,cret
88      if (cret .ne. 0 ) then
89         print *,'Erreur à la fermeture du fichier'
90         call efexit(-1)
91      endif
92
93      end
94