MED fichier: Fichier source de MEDparFileOpen.c

MED fichier

MEDparFileOpen.c
Aller à la documentation de ce fichier.
1 /* This file is part of MED.
2 *
3 * COPYRIGHT (C) 1999 - 2023 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 #include <med.h>
20 #include <med_config.h>
21 #include <med_outils.h>
22
23 #include <mpi.h>
24
25 #ifdef PPRO_NT_CALL
26 #define F_OK 0
27 #else
28 #include <unistd.h>
29 #endif
30
31
32 med_access_mode MED_ACCESS_MODE;
33
46 /*#define true 1*/
47
48 med_idt
49 MEDparFileOpen(const char* const filename,
50 const med_access_mode accessmode,
51 const MPI_Comm comm, const MPI_Info info)
52 {
53 med_idt _fid = -1;
54
55 /*
56 * On inhibe le gestionnaire d'erreur HDF
57 */
58 _MEDmodeErreurVerrouiller();
59 /*
60 * On ouvre le fichier MED sous HDF
61 */
62 switch(accessmode)
63 {
64 case MED_ACC_RDONLY :
65 if (_MEDaccess(filename,F_OK)) {
66 MED_ERR_(_fid,MED_ERR_DOESNTEXIST,MED_ERR_FILE,filename);
67 goto ERROR;
68
69 } else {
70 if ((_fid = _MEDparFileOpen((char*) filename, accessmode, comm, info)) < 0) {
71 MED_ERR_(_fid,MED_ERR_OPEN,MED_ERR_FILE,filename);
72 goto ERROR;
73 }
74 };
75 break;
76
77 case MED_ACC_RDWR :
78 if (_MEDaccess(filename,F_OK)) {
79 if ((_fid = _MEDparFileCreate((char*) filename,accessmode, comm, info)) < 0) {
80 MED_ERR_(_fid,MED_ERR_CREATE,MED_ERR_FILE,filename);
81 goto ERROR;
82 }
83 } else
84 if ((_fid = _MEDparFileOpen((char*) filename,accessmode, comm, info)) < 0) {
85 MED_ERR_(_fid,MED_ERR_OPEN,MED_ERR_FILE,filename);
86 goto ERROR;
87 }
88 break;
89
90 case MED_ACC_RDEXT :
91 if (_MEDaccess(filename,F_OK))
92 {
93 if ((_fid = _MEDparFileCreate((char*) filename,accessmode, comm, info)) < 0) {
94 MED_ERR_(_fid,MED_ERR_CREATE,MED_ERR_FILE,filename);
95 goto ERROR;
96 }
97 } else
98
99 if ((_fid = _MEDparFileOpen((char *) filename, accessmode, comm, info)) < 0) {
100 MED_ERR_(_fid,MED_ERR_OPEN,MED_ERR_FILE,filename);
101 goto ERROR;
102 }
103 break;
104
105 case MED_ACC_CREAT :
106 if ((_fid = _MEDparFileCreate((char *) filename,MED_ACC_RDWR, comm, info)) < 0) {
107 MED_ERR_(_fid,MED_ERR_CREATE,MED_ERR_FILE,filename);
108 goto ERROR;
109 }
110 break;
111
112 default :
113 MED_ERR_(_fid,MED_ERR_RANGE,MED_ERR_PARAMETER,"");
114 ISCRUTE_int(accessmode);
115 goto ERROR;
116 }
117
118 if (_MEDcheckVersion30(_fid) < 0) {
119 MEDfileClose(_fid);
120 _fid=-1;goto ERROR;
121 }
122
123 ERROR:
124
125 return _fid;
126 }
MED_ACC_RDONLY
Definition: med.h:122
MED_ERR_CREATE
#define MED_ERR_CREATE
Definition: med_err.h:27
MED_ERR_DOESNTEXIST
#define MED_ERR_DOESNTEXIST
Definition: med_err.h:38
filename
#define filename
Definition: 4.0.1/test10.c:75
ISCRUTE_int
#define ISCRUTE_int(entier)
Definition: med_utils.h:314
med_idt
hid_t med_idt
Definition: med.h:333
MED_ERR_
#define MED_ERR_(rt, r1, r2, r3)
Definition: med_utils.h:160
med_outils.h
MED_ACC_RDWR
Definition: med.h:123
_MEDaccess
MEDC_EXPORT int _MEDaccess(const char *const file, int mode)
MED_ERR_OPEN
#define MED_ERR_OPEN
Definition: med_err.h:37
MED_ACCESS_MODE
med_access_mode MED_ACCESS_MODE
Definition: MEDparFileOpen.c:32
MED_ERR_FILE
#define MED_ERR_FILE
Definition: med_err.h:82
med_config.h
med_access_mode
med_access_mode
Definition: med.h:122
MED_ACC_RDEXT
Definition: med.h:124
MEDfileClose
MEDC_EXPORT med_err MEDfileClose(med_idt fid)
Fermeture d'un fichier MED.
Definition: MEDfileClose.c:30
_MEDcheckVersion30
MEDC_EXPORT med_err _MEDcheckVersion30(med_idt fid)
MEDparFileOpen
med_idt MEDparFileOpen(const char *const filename, const med_access_mode accessmode, const MPI_Comm comm, const MPI_Info info)
Ouverture d'un fichier MED pour une utilisation parallèle.
Definition: MEDparFileOpen.c:49
med.h
MED_ERR_RANGE
#define MED_ERR_RANGE
Definition: med_err.h:34
_MEDmodeErreurVerrouiller
MEDC_EXPORT void _MEDmodeErreurVerrouiller(void)
MED_ERR_PARAMETER
#define MED_ERR_PARAMETER
Definition: med_err.h:103
MED_ACC_CREAT
Definition: med.h:125