MED fichier
medparametercf.c
Aller à la documentation de ce fichier.
1 /* This file is part of MED.
2  *
3  * COPYRIGHT (C) 1999 - 2016 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 <string.h>
23 #include <stdlib.h>
24 
25 /*
26 From Fortran call of following C functions :
27 - MEDnParameter.c
28 - MEDparameterComputationStepInfo.c
29 - MEDparameterCr.c
30 - MEDparameterInfoByName.c
31 - MEDparameterInfo.c
32 - MEDparameterValueRd.c
33 - MEDparameterValueWr.c
34 */
35 
36 #define nmprfcre F77_FUNC(mprfcre,MPRFCRE)
37 #define nmprfrvw F77_FUNC(mprfrvw,MPRFRVW)
38 #define nmprfivw F77_FUNC(mprfivw,MPRFIVW)
39 #define nmprfrvr F77_FUNC(mprfrvr,MPRFRVR)
40 #define nmprfivr F77_FUNC(mprfivr,MPRFIVR)
41 #define nmprfpri F77_FUNC(mprfpri,MPRFPRI)
42 #define nmprfpin F77_FUNC(mprfpin,MPRFPIN)
43 #define nmprfcsi F77_FUNC(mprfcsi,MPRFCSI)
44 #define nmprfnpr F77_FUNC(mprfnpr,MPRFNPR)
45 
46 #ifdef PPRO_NT
47 med_int
48 MPRFCRE(med_int *fid, char *pname, unsigned int bidon1, med_int *lon1,
49  med_int *type, char *desc, unsigned int bidon2, med_int *lon2,
50  char *dtunit, unsigned int bidon3, med_int *lon3)
51 #else
52 med_int
53 nmprfcre(med_int *fid, char *pname, med_int *lon1,
54  med_int *type, char *desc, med_int *lon2,
55  char *dtunit, med_int *lon3)
56 #endif
57 {
58  med_int _ret;
59  char *_fn1, *_fn2, *_fn3;
60  med_parameter_type _type = (med_parameter_type) *type;
61 
62  _fn1 = _MED2cstring(pname, (int) * lon1);
63  _fn2 = _MED1cstring(desc, (int) * lon2,MED_COMMENT_SIZE);
64  _fn3 = _MED2cstring(dtunit, (int) * lon3);
65 
66  if (!_fn1 || !_fn2 || !_fn3)
67  return(-1);
68 
69  _ret = (med_int) MEDparameterCr((med_idt) *fid,
70  _fn1,
71  _type,
72  _fn2,
73  _fn3);
74 
75  _MEDcstringFree(_fn1);
76  _MEDcstringFree(_fn2);
77  _MEDcstringFree(_fn3);
78 
79  return(_ret);
80 }
81 
82 
83 
84 #ifdef PPRO_NT
85 med_int
86 MPRFRVW(med_idt *fid, char *name, unsigned int bidon1, med_int *namelen,
87  med_int *numdt, med_int *numit, med_float *dt,
88  med_float *val)
89 #else
90 med_int
91 nmprfrvw(med_idt *fid, char *name, med_int *namelen,
92  med_int *numdt, med_int *numit, med_float *dt,
93  med_float *val)
94 #endif
95 {
96  med_err _ret=0;
97  char *_fn1;
98 
99  _fn1 = _MED2cstring((char *) name, (int) *namelen);
100  if (!_fn1)
101  return(-1);
102 
103  _ret = (med_int) MEDparameterValueWr((const med_idt) *fid,
104  _fn1,
105  (med_int) *numdt,
106  (med_int) *numit,
107  (med_float) *dt,
108  (unsigned char *) val);
109 
110 
111  _MEDcstringFree(_fn1);
112 
113  return (_ret);
114 }
115 
116 
117 #ifdef PPRO_NT
118 med_int
119 MPRFIVW(med_idt *fid, char *name, unsigned int bidon1, med_int *namelen,
120  med_int *numdt, med_int *numit, med_float *dt,
121  med_int *val)
122 #else
123 med_int
124 nmprfivw(med_idt *fid, char *name, med_int *namelen,
125  med_int *numdt, med_int *numit, med_float *dt,
126  med_int *val)
127 #endif
128 {
129  med_err _ret=0;
130  char *_fn1;
131 
132  _fn1 = _MED2cstring((char *) name, (int) *namelen);
133  if (!_fn1)
134  return(-1);
135 
136  _ret = (med_int) MEDparameterValueWr((const med_idt) *fid,
137  _fn1,
138  (med_int) *numdt,
139  (med_int) *numit,
140  (med_float) *dt,
141  (unsigned char *) val);
142 
143 
144  _MEDcstringFree(_fn1);
145 
146  return (_ret);
147 }
148 
149 
150 
151 #ifdef PPRO_NT
152 med_int
153 MPRFRVR(med_idt *fid, char *name, unsigned int bidon1, med_int *namelen,
154  med_int *numdt, med_int *numit, med_float *val)
155 #else
156 med_int
157 nmprfrvr(med_idt *fid, char *name, med_int *namelen,
158  med_int *numdt, med_int *numit, med_float *val)
159 #endif
160 {
161  med_err _ret=0;
162  char *_fn1;
163 
164  _fn1 = _MED2cstring((char *) name, (int) *namelen);
165  if (!_fn1)
166  return(-1);
167 
168  _ret = (med_int) MEDparameterValueRd((const med_idt) *fid,
169  _fn1,
170  (med_int) *numdt,
171  (med_int) *numit,
172  (unsigned char *) val);
173 
174 
175  _MEDcstringFree(_fn1);
176 
177  return (_ret);
178 }
179 
180 
181 #ifdef PPRO_NT
182 med_int
183 MPRFIVR(med_idt *fid, char *name, unsigned int bidon1, med_int *namelen,
184  med_int *numdt, med_int *numit, med_int *val)
185 #else
186 med_int
187 nmprfivr(med_idt *fid, char *name, med_int *namelen,
188  med_int *numdt, med_int *numit, med_int *val)
189 #endif
190 {
191  med_err _ret=0;
192  char *_fn1;
193 
194  _fn1 = _MED2cstring((char *) name, (int) *namelen);
195  if (!_fn1)
196  return(-1);
197 
198  _ret = (med_int) MEDparameterValueRd((const med_idt) *fid,
199  _fn1,
200  (med_int) *numdt,
201  (med_int) *numit,
202  (unsigned char *) val);
203 
204 
205  _MEDcstringFree(_fn1);
206 
207  return (_ret);
208 }
209 
210 #ifdef PPRO_NT
211 med_int
212 MPRFNPR(med_int *fid)
213 #else
214 med_int
216 #endif
217 {
218  med_int _ret;
219 
220  _ret = (med_int) MEDnParameter((const med_idt) *fid);
221 
222  return(_ret);
223 }
224 
225 
226 
227 #ifdef PPRO_NT
228 med_int
229 MPRFPRI(med_int *fid, med_int *it, char *name, unsigned int bidon1,
230  med_int *type, char *desc, unsigned int bidon2,
231  char *dtunit, unsigned int bidon3, med_int *nstep)
232 #else
233 med_int
234 nmprfpri(med_int *fid, med_int *it, char *name,
235  med_int *type, char *desc,
236  char *dtunit, med_int *nstep)
237 #endif
238 {
239  med_int _ret;
240  char _fs1[MED_NAME_SIZE+1]="";
241  char _fs2[MED_COMMENT_SIZE+1]="";
242  char _fs3[MED_SNAME_SIZE+1]="";
243  med_parameter_type _type;
244 
245  _ret = (med_int) MEDparameterInfo((const med_idt)*fid,
246  (const med_int) *it,
247  _fs1,
248  &_type,
249  _fs2,
250  _fs3,
251  (med_int *) nstep);
252 
253 
254  *type = (med_int) _type;
255 
256  _MEDc2fString(_fs1,name,MED_NAME_SIZE);
257  _MEDc2fString(_fs2,desc,MED_COMMENT_SIZE);
258  _MEDc2fString(_fs3,dtunit,MED_SNAME_SIZE);
259 
260  return _ret;
261 }
262 
263 
264 #ifdef PPRO_NT
265 med_int
266 MPRFPIN(med_int *fid, char *name, unsigned int bidon1, med_int *namelen,
267  med_int *type, char *desc, unsigned int bidon2,
268  char *dtunit, unsigned int bidon3,
269  med_int *nstep)
270 #else
271 med_int
272 nmprfpin(med_int *fid, char *name, med_int *namelen,
273  med_int *type, char *desc,
274  char *dtunit, med_int *nstep)
275 #endif
276 {
277  med_int _ret;
278  char *_fn1;
279  char _fs2[MED_COMMENT_SIZE+1]="";
280  char _fs3[MED_SNAME_SIZE+1];
281  med_parameter_type _type;
282 
283  _fn1 = _MED2cstring(name, (int) *namelen);
284  if (!_fn1)
285  return(-1);
286 
287  _ret = (med_int) MEDparameterInfoByName((const med_idt)*fid,
288  _fn1,
289  &_type,
290  _fs2,
291  _fs3,
292  (med_int *) nstep);
293 
294 
295  *type = (med_int) _type;
296 
297  _MEDc2fString(_fs2,desc,MED_COMMENT_SIZE);
298  _MEDc2fString(_fs3,dtunit,MED_SNAME_SIZE);
299 
300  _MEDcstringFree(_fn1);
301 
302  return _ret;
303 }
304 
305 
306 
307 #ifdef PPRO_NT
308 med_int
309 MPRFCSI(med_int *fid, char* name, unsigned int bidon1, med_int *namelen,
310  med_int *it, med_int *numdt, med_int *numit, med_float *dt)
311 #else
312 med_int
313 nmprfcsi(med_int *fid, char *name, med_int *namelen,
314  med_int *it, med_int *numdt, med_int *numit, med_float *dt)
315 #endif
316 {
317  med_int _ret;
318  char *_fn1;
319 
320  _fn1 = _MED2cstring((char *) name, (int) *namelen);
321  if (!_fn1)
322  return(-1);
323 
325  _fn1,
326  (med_int) *it,
327  (med_int *) numdt,
328  (med_int *) numit,
329  (med_float *) dt);
330 
331  _MEDcstringFree(_fn1);
332 
333  return _ret;
334 }
MEDC_EXPORT med_int MEDnParameter(const med_idt fid)
Cette routine permet la lecture du nombre de paramètre numérique scalaire dans un fichier...
Definition: MEDnParameter.c:34
#define nmprfpin
herr_t med_err
Definition: med.h:310
MEDC_EXPORT med_err _MEDcstringFree(char *chaine)
#define nmprfivr
double med_float
Definition: med.h:314
MEDC_EXPORT med_err MEDparameterCr(const med_idt fid, const char *const paramname, const med_parameter_type paramtype, const char *const description, const char *const dtunit)
Cette routine permet la création d'un paramètre numérique scalaire.
MEDC_EXPORT med_err MEDparameterComputationStepInfo(const med_idt fid, const char *const paramname, const int csit, med_int *const numdt, med_int *const numit, med_float *const dt)
Cette routine permet la lecture des informations relatives à une séquence de calcul du paramètre numé...
MEDC_EXPORT med_err MEDparameterInfoByName(const med_idt fid, const char *const paramname, med_parameter_type *const paramtype, char *const description, char *const dtunit, med_int *const nstep)
Cette routine permet la lecture des informations relatives à un paramètre scalaire.
#define nmprfcsi
MEDC_EXPORT med_err MEDparameterInfo(const med_idt fid, const int paramit, char *const paramname, med_parameter_type *const paramtype, char *const description, char *const dtunit, med_int *const nstep)
Cette routine permet la lecture des informations relatives à un paramètre scalaire via un itérateur...
#define nmprfnpr
#define nmprfpri
int med_int
Definition: med.h:316
MEDC_EXPORT char * _MED1cstring(char *chaine, int longueur_reelle, int longueur_fixee)
Definition: MED1cstring.c:37
med_field_type
Definition: med.h:155
#define MED_COMMENT_SIZE
Definition: med.h:72
#define nmprfcre
#define nmprfrvr
MEDC_EXPORT med_err _MEDc2fString(const char *const chainec, char *const chainef, med_int longueur_buffer77)
#define nmprfivw
hid_t med_idt
Definition: med.h:309
#define MED_SNAME_SIZE
Definition: med.h:75
#define MED_NAME_SIZE
Definition: med.h:74
#define nmprfrvw
MEDC_EXPORT char * _MED2cstring(char *chaine, int longueur)
Definition: MED2cstring.c:35
med_field_type med_parameter_type
Definition: med.h:163
MEDC_EXPORT med_err MEDparameterValueRd(const med_idt fid, const char *const paramname, const med_int numdt, const med_int numit, unsigned char *const value)
Cette routine permet la lecture de la valeur d'un paramètre numérique scalaire.
MEDC_EXPORT med_err MEDparameterValueWr(const med_idt fid, const char *const paramname, const med_int numdt, const med_int numit, const med_float dt, const unsigned char *const value)
Cette routine permet l'écriture de la valeur d'un paramètre numérique scalaire.