MED fichier: Fichier source de MEDinterpCr.c

MED fichier

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

MEDinterpCr.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
42 med_err
43 MEDinterpCr(const med_idt fid,
44 const char* const interpname,
45 const med_geometry_type geotype,
46 const med_bool cellnode,
47 const med_int nvariable,
48 const med_int maxdegree,
49 const med_int nmaxcoef
50 )
51 {
52 med_access_mode _MED_ACCESS_MODE;
53 med_idt _root=0,_interpid=0;
54 med_int _ret=-1;
55 char _path[MED_INTERPOLATION_GRP_SIZE+MED_NAME_SIZE+1]=MED_INTERPOLATION_GRP;
56 med_int _cellnodes = cellnode;
57 med_int _geotype = geotype;
58 /*
59 * On inhibe le gestionnaire d'erreur
60 */
61 _MEDmodeErreurVerrouiller();
62 if (_MEDcheckVersion30(fid) < 0) goto ERROR;
63
64 if ( (_MED_ACCESS_MODE = _MEDmodeAcces(fid) ) == MED_ACC_UNDEF ) {
65 MED_ERR_(_ret,MED_ERR_UNRECOGNIZED,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
66 goto ERROR;
67 }
68
69 if ( _MED_ACCESS_MODE == MED_ACC_RDONLY) {
70 MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
71 ISCRUTE_int(_MED_ACCESS_MODE);
72 goto ERROR;
73 }
74
75 /*
76 * Si le DataGroup /INTERP/ n'existe pas, on le cree
77 */
78 if ((_root = _MEDdatagroupOpen(fid,_path)) < 0)
79 if ((_root = _MEDdatagroupCreer(fid,_path)) < 0) {
80 MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,_path);
81 goto ERROR;
82 }
83
84 NOFINALBLANK(interpname,ERROR);
85
86 /*
87 * Si le DataGroup /INTERP/<interpname> n'existe pas, on le cree
88 */
89 if ((_interpid = _MEDdatagroupOpen(_root,interpname)) < 0)
90 if ((_interpid = _MEDdatagroupCreer(_root,interpname)) < 0) {
91 MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,interpname);
92 SSCRUTE(_path);goto ERROR;
93 }
94
95 strcat(_path,interpname);
96
97 /*
98 * Creation/Ecriture de l'attribut MED_NOM_GEO
99 */
100 if ( _MEDattributeIntWr(_interpid,MED_NOM_GEO,&_geotype) < 0 ) {
101 MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
102 SSCRUTE(MED_NOM_GEO);ISCRUTE(_geotype);
103 goto ERROR;
104 }
105
106 /*
107 * Creation/Ecriture de l'attribut MED_NOM_NBB
108 */
109 /* if ( _MEDattributeIntWr(_interpid,MED_NOM_NBB,&nbasisfunc) < 0 ) { */
110 /* MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path); */
111 /* SSCRUTE(MED_NOM_NBB);ISCRUTE(nbasisfunc); */
112 /* goto ERROR; */
113 /* } */
114
115 /*
116 * Creation/Ecriture de l'attribut MED_NOM_NBV
117 */
118 if ( _MEDattributeIntWr(_interpid,MED_NOM_NBV,&nvariable) < 0 ) {
119 MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
120 SSCRUTE(MED_NOM_NBV);ISCRUTE(nvariable);
121 goto ERROR;
122 }
123
124 /*
125 * Creation/Ecriture de l'attribut MED_NOM_MDG
126 */
127 if ( _MEDattributeIntWr(_interpid,MED_NOM_MDG,&maxdegree) < 0 ) {
128 MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
129 SSCRUTE(MED_NOM_MDG);ISCRUTE(maxdegree);
130 goto ERROR;
131 }
132
133 /*
134 * Creation/Ecriture de l'attribut MED_NOM_MCF
135 */
136 if ( _MEDattributeIntWr(_interpid,MED_NOM_MCF,&nmaxcoef) < 0 ) {
137 MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
138 SSCRUTE(MED_NOM_MCF);ISCRUTE(nmaxcoef);
139 goto ERROR;
140 }
141
142 /*
143 * Creation/Ecriture de l'attribut MED_NOM_FCN
144 */
145 if ( _MEDattributeIntWr(_interpid,MED_NOM_FCN,&_cellnodes) < 0 ) {
146 MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
147 SSCRUTE(MED_NOM_FCN);ISCRUTE(_cellnodes);
148 goto ERROR;
149 }
150
151 _ret = 0;
152
153 ERROR:
154
155 if (_interpid>0) if (_MEDdatagroupFermer(_interpid) < 0) {
156 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_path);
157 ISCRUTE_id(_interpid);
158 }
159
160 if (_root>0) if (_MEDdatagroupFermer(_root) < 0) {
161 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,MED_INTERPOLATION_GRP);
162 ISCRUTE_id(_root);
163 }
164
165 return _ret;
166
167 }
MED_ERR_ATTRIBUTE
#define MED_ERR_ATTRIBUTE
Definition: med_err.h:99
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
MED_ERR_FILE_MSG
#define MED_ERR_FILE_MSG
Definition: med_err.h:129
MED_ERR_INVALID
#define MED_ERR_INVALID
Definition: med_err.h:37
_MEDcheckVersion30
MEDC_EXPORT med_err _MEDcheckVersion30(med_idt fid)
_MEDmodeAcces
MEDC_EXPORT med_access_mode _MEDmodeAcces(med_idt oid)
MED_INTERPOLATION_GRP
#define MED_INTERPOLATION_GRP
Definition: med_outils.h:176
med_access_mode
med_access_mode
Definition: med.h:118
MEDinterpCr
med_err MEDinterpCr(const med_idt fid, const char *const interpname, const med_geometry_type geotype, const med_bool cellnode, const med_int nvariable, const med_int maxdegree, const med_int nmaxcoef)
Cette routine permet de créer une nouvelle fonction d'interpolation polynômiale nommée interpname...
Definition: MEDinterpCr.c:43
ISCRUTE_int
#define ISCRUTE_int(entier)
Definition: med_utils.h:307
MED_ERR_ACCESSMODE
#define MED_ERR_ACCESSMODE
Definition: med_err.h:103
MED_ERR_UNRECOGNIZED
#define MED_ERR_UNRECOGNIZED
Definition: med_err.h:36
MED_ERR_WRITE
#define MED_ERR_WRITE
Definition: med_err.h:26
MED_NOM_MDG
#define MED_NOM_MDG
Definition: med_outils.h:146
med_int
int med_int
Definition: med.h:337
med_config.h
MED_ERR_CREATE
#define MED_ERR_CREATE
Definition: med_err.h:24
ISCRUTE
#define ISCRUTE(entier)
Definition: med_utils.h:306
MED_ERR_CLOSE
#define MED_ERR_CLOSE
Definition: med_err.h:27
MED_NOM_NBV
#define MED_NOM_NBV
Definition: med_outils.h:145
_MEDattributeIntWr
#define _MEDattributeIntWr(w, x, y)
Definition: med_hdfi.h:45
MED_ACC_UNDEF
Definition: med.h:122
MED_INTERPOLATION_GRP_SIZE
#define MED_INTERPOLATION_GRP_SIZE
Definition: med_outils.h:177
MED_ERR_DATAGROUP
#define MED_ERR_DATAGROUP
Definition: med_err.h:98
med_idt
hid_t med_idt
Definition: med.h:326
MED_NOM_FCN
#define MED_NOM_FCN
Definition: med_outils.h:148
_MEDdatagroupFermer
MEDC_EXPORT med_err _MEDdatagroupFermer(med_idt id)
med_outils.h
MED_NAME_SIZE
#define MED_NAME_SIZE
Definition: med.h:79
med.h
MED_NOM_MCF
#define MED_NOM_MCF
Definition: med_outils.h:147
med_bool
med_bool
Definition: med.h:257
ISCRUTE_id
#define ISCRUTE_id(entier)
Definition: med_utils.h:311
_MEDdatagroupCreer
MEDC_EXPORT med_idt _MEDdatagroupCreer(med_idt pid, const char *const nom)
med_geometry_type
int med_geometry_type
Definition: med.h:191
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)
MED_NOM_GEO
#define MED_NOM_GEO
Definition: med_outils.h:119
MED_ACC_RDONLY
Definition: med.h:118