MED fichier
MEDinterpCr.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 #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;
56  med_int _cellnodes = cellnode;
57  med_int _geotype = geotype;
58  /*
59  * On inhibe le gestionnaire d'erreur
60  */
62  if (_MEDcheckVersion30(fid) < 0) goto ERROR;
63 
64  if ( (_MED_ACCESS_MODE = _MEDmodeAcces(fid) ) == MED_ACC_UNDEF ) {
66  goto ERROR;
67  }
68 
69  if ( _MED_ACCESS_MODE == MED_ACC_RDONLY) {
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) {
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 ) {
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 ) {
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 ) {
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 ) {
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 ) {
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) {
157  ISCRUTE_id(_interpid);
158  }
159 
160  if (_root>0) if (_MEDdatagroupFermer(_root) < 0) {
162  ISCRUTE_id(_root);
163  }
164 
165  return _ret;
166 
167 }
MED_ACC_RDONLY
Definition: med.h:122
MED_ERR_CREATE
#define MED_ERR_CREATE
Definition: med_err.h:27
ISCRUTE_id
#define ISCRUTE_id(entier)
Definition: med_utils.h:319
med_geometry_type
int med_geometry_type
Definition: med.h:196
_MEDattributeIntWr
#define _MEDattributeIntWr(w, x, y)
Definition: med_hdfi.h:45
ISCRUTE_int
#define ISCRUTE_int(entier)
Definition: med_utils.h:314
_MEDmodeAcces
MEDC_EXPORT med_access_mode _MEDmodeAcces(med_idt oid)
med_idt
hid_t med_idt
Definition: med.h:333
MED_ERR_
#define MED_ERR_(rt, r1, r2, r3)
Definition: med_utils.h:160
_MEDdatagroupOpen
MEDC_EXPORT med_idt _MEDdatagroupOpen(const med_idt pid, const char *const name)
MED_ERR_ATTRIBUTE
#define MED_ERR_ATTRIBUTE
Definition: med_err.h:100
MED_ERR_INVALID
#define MED_ERR_INVALID
Definition: med_err.h:40
med_err
herr_t med_err
Definition: med.h:334
MED_NOM_MDG
#define MED_NOM_MDG
Definition: med_outils.h:152
med_outils.h
MED_ERR_CLOSE
#define MED_ERR_CLOSE
Definition: med_err.h:30
MED_NOM_GEO
#define MED_NOM_GEO
Definition: med_outils.h:133
med_int
int med_int
Definition: med.h:344
ISCRUTE
#define ISCRUTE(entier)
Definition: med_utils.h:313
MED_NOM_NBV
#define MED_NOM_NBV
Definition: med_outils.h:151
MED_ERR_WRITE
#define MED_ERR_WRITE
Definition: med_err.h:29
med_config.h
med_bool
med_bool
Definition: med.h:262
MED_ACC_UNDEF
Definition: med.h:126
med_access_mode
med_access_mode
Definition: med.h:122
MED_ERR_DATAGROUP
#define MED_ERR_DATAGROUP
Definition: med_err.h:99
_MEDdatagroupCreer
MEDC_EXPORT med_idt _MEDdatagroupCreer(med_idt pid, const char *const nom)
MED_INTERPOLATION_GRP
#define MED_INTERPOLATION_GRP
Definition: med_outils.h:179
SSCRUTE
#define SSCRUTE(chaine)
Definition: med_utils.h:323
MED_ERR_ACCESSMODE
#define MED_ERR_ACCESSMODE
Definition: med_err.h:104
MED_NAME_SIZE
#define MED_NAME_SIZE
Definition: med.h:83
_MEDcheckVersion30
MEDC_EXPORT med_err _MEDcheckVersion30(med_idt fid)
med.h
NOFINALBLANK
#define NOFINALBLANK(chaine, label)
Definition: med_utils.h:311
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
MED_ERR_UNRECOGNIZED
#define MED_ERR_UNRECOGNIZED
Definition: med_err.h:39
MED_NOM_MCF
#define MED_NOM_MCF
Definition: med_outils.h:153
_MEDmodeErreurVerrouiller
MEDC_EXPORT void _MEDmodeErreurVerrouiller(void)
MED_ERR_FILE_MSG
#define MED_ERR_FILE_MSG
Definition: med_err.h:132
MED_INTERPOLATION_GRP_SIZE
#define MED_INTERPOLATION_GRP_SIZE
Definition: med_outils.h:180
MED_NOM_FCN
#define MED_NOM_FCN
Definition: med_outils.h:154
_MEDdatagroupFermer
MEDC_EXPORT med_err _MEDdatagroupFermer(med_idt id)