MED fichier: Fichier source de MEDfieldInterpWr.c

MED fichier

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

MEDfieldInterpWr.c
Aller à la documentation de ce fichier.
1 /* This file is part of MED.
2 *
3 * COPYRIGHT (C) 1999 - 2019 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 #include <hdf5.h>
23 #include <string.h>
24
35 med_err
36 MEDfieldInterpWr(const med_idt fid,
37 const char* const fieldname,
38 const char* const interpname
39 )
40 {
41 med_err _ret=-1;
42 med_idt _fieldinterpid=0,_fieldid=0,_interpid=0;
43 char _path[MED_TAILLE_CHA_INTERP+MED_NAME_SIZE+1]=MED_CHA_INTERP;
44
45 /*
46 * On inhibe le gestionnaire d'erreur HDF 5
47 */
48 _MEDmodeErreurVerrouiller();
49 if (_MEDcheckVersion30(fid) < 0) goto ERROR;
50
51 /*
52 * On ouvre le champ /MED_CHA_INTERP
53 */
54 if ((_fieldinterpid = _MEDdatagroupOpen(fid,MED_CHA_INTERP)) < 0)
55 if ((_fieldinterpid = _MEDdatagroupCreer(fid,MED_CHA_INTERP)) < 0) {
56 MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,MED_CHA_INTERP);
57 goto ERROR;
58 }
59
60 NOFINALBLANK(interpname,ERROR);
61 strcat(_path,fieldname);
62
63 /*
64 * On ouvre le champ /MED_CHA_INTERP/<fieldname>
65 */
66 if ((_fieldid = _MEDdatagroupOuvrir(_fieldinterpid,fieldname)) < 0)
67 if ((_fieldid = _MEDdatagroupCreer(_fieldinterpid,fieldname)) < 0) {
68 MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,_path);
69 goto ERROR;
70 }
71
72 /*
73 * Si le DataGroup /MED_CHA_INTERP/<fieldname>/<interpname> n'existe pas, on le cree
74 */
75 if ((_interpid = _MEDdatagroupOpen(_fieldid,interpname)) < 0)
76 if ((_interpid = _MEDdatagroupCreer(_fieldid,interpname)) < 0) {
77 MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,interpname);
78 SSCRUTE(_path);
79 goto ERROR;
80 }
81
82 _ret = 0;
83
84 ERROR:
85
86 if (_interpid>0) if (_MEDdatagroupFermer(_interpid) < 0) {
87 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,interpname);
88 SSCRUTE(_path); ISCRUTE_id(_interpid);
89 }
90
91 if (_fieldid>0) if (_MEDdatagroupFermer(_fieldid) < 0) {
92 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,fieldname);
93 SSCRUTE(_path);ISCRUTE_id(_fieldid);
94 }
95
96 if (_fieldinterpid>0) if (_MEDdatagroupFermer(_fieldinterpid) < 0) {
97 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,MED_CHA_INTERP);
98 SSCRUTE(_path); ISCRUTE_id(_fieldinterpid);
99 }
100
101
102 return _ret;
103 }
104
MED_TAILLE_CHA_INTERP
#define MED_TAILLE_CHA_INTERP
Definition: med_outils.h:181
med_err
herr_t med_err
Definition: med.h:327
NOFINALBLANK
#define NOFINALBLANK(chaine, label)
Definition: med_utils.h:304
MED_ERR_
#define MED_ERR_(rt, r1, r2, r3)
Definition: med_utils.h:158
_MEDcheckVersion30
MEDC_EXPORT med_err _MEDcheckVersion30(med_idt fid)
med_config.h
MED_ERR_CREATE
#define MED_ERR_CREATE
Definition: med_err.h:24
MED_ERR_CLOSE
#define MED_ERR_CLOSE
Definition: med_err.h:27
_MEDdatagroupOuvrir
MEDC_EXPORT med_idt _MEDdatagroupOuvrir(med_idt pid, const char *const nom)
MED_ERR_DATAGROUP
#define MED_ERR_DATAGROUP
Definition: med_err.h:98
med_idt
hid_t med_idt
Definition: med.h:326
_MEDdatagroupFermer
MEDC_EXPORT med_err _MEDdatagroupFermer(med_idt id)
med_outils.h
MED_NAME_SIZE
#define MED_NAME_SIZE
Definition: med.h:79
MEDfieldInterpWr
med_err MEDfieldInterpWr(const med_idt fid, const char *const fieldname, const char *const interpname)
Cette routine associe une fonction d'interpolation interpname au champ résultat fieldname.
Definition: MEDfieldInterpWr.c:36
med.h
MED_CHA_INTERP
#define MED_CHA_INTERP
Definition: med_outils.h:180
ISCRUTE_id
#define ISCRUTE_id(entier)
Definition: med_utils.h:311
_MEDdatagroupCreer
MEDC_EXPORT med_idt _MEDdatagroupCreer(med_idt pid, const char *const nom)
SSCRUTE
#define SSCRUTE(chaine)
Definition: med_utils.h:315
_MEDmodeErreurVerrouiller
MEDC_EXPORT void _MEDmodeErreurVerrouiller(void)
_MEDdatagroupOpen
MEDC_EXPORT med_idt _MEDdatagroupOpen(const med_idt pid, const char *const name)