MED fichier
medprofilecf.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 - MEDprofileWr
28 - MEDnProfile
29 - MEDprofileInfo
30 - MEDprofileRd
31 - MEDprofileSizeByName
32 */
33 
34 #define nmpffprw F77_FUNC(mpffprw,MPFFPRW)
35 #define nmpffnpf F77_FUNC(mpffnpf,MPFFNPF)
36 #define nmpffpfi F77_FUNC(mpffpfi,MPFFPFI)
37 #define nmpffprr F77_FUNC(mpffprr,MPFFPRR)
38 #define nmpffpsn F77_FUNC(mpffpsn,MPFFPSN)
39 
40 
41 #ifdef PPRO_NT
42 med_int
43 MPFFPRW(med_idt *fid, char *pname, unsigned int bidon1, med_int *pnamelen,
44  med_int *psize, med_int *profil)
45 #else
46 med_int
47 nmpffprw(med_idt *fid, char *pname, med_int *pnamelen, med_int *psize, med_int *profil)
48 #endif
49 {
50  med_err _ret=0;
51  char *_fn1;
52 
53  _fn1 = _MED2cstring((char *) pname, (int) *pnamelen);
54  if (!_fn1)
55  return(-1);
56 
57  _ret = (med_int) MEDprofileWr((const med_idt) *fid,
58  _fn1,
59  (med_int) *psize,
60  (med_int *) profil);
61 
62  _MEDcstringFree(_fn1);
63 
64  return (_ret);
65 }
66 
67 
68 #ifdef PPRO_NT
69 med_int
70 MPFFNPF(med_int *fid)
71 #else
72 med_int
74 #endif
75 {
76  med_int _ret;
77 
78  _ret = (med_int) MEDnProfile((const med_idt) *fid);
79 
80  return(_ret);
81 }
82 
83 
84 
85 #ifdef PPRO_NT
86 med_int
87 MPFFPFI(med_int *fid, med_int *it, char*pname, unsigned int bidon1,
88  med_int *psize)
89 #else
90 med_int
91 nmpffpfi(med_int *fid, med_int *it, char*pname, med_int *psize)
92 #endif
93 {
94  med_int _ret;
95  char _fs1[MED_NAME_SIZE+1]="";
96 
97  _ret = (med_int) MEDprofileInfo((const med_idt)*fid,
98  (const med_int) *it,
99  _fs1,
100  (med_int *) psize);
101 
102  _MEDc2fString(_fs1,pname,MED_NAME_SIZE);
103 
104  return _ret;
105 }
106 
107 
108 #ifdef PPRO_NT
109 med_int
110 MPFFPSN(med_int *fid, char*pname, unsigned int bidon1, med_int *pnamelen,
111  med_int *psize)
112 #else
113 med_int
114 nmpffpsn(med_int *fid, char*pname, med_int *pnamelen, med_int *psize)
115 #endif
116 {
117  med_int _ret=0;
118  char *_fn1;
119  med_int _psize;
120 
121  _fn1 = _MED2cstring((char *) pname, (int) *pnamelen);
122  if (!_fn1)
123  return(-1);
124 
125  _psize = (med_int) MEDprofileSizeByName((med_idt)*fid,
126  _fn1);
127 
128  *psize = (med_int) _psize;
129  if (_psize < 0)
130  _ret = _psize;
131 
132  _MEDcstringFree(_fn1);
133 
134  return _ret;
135 }
136 
137 
138 
139 #ifdef PPRO_NT
140 med_int
141 MPFFPRR(med_idt *fid, char *pname, unsigned int bidon1, med_int *pnamelen,
142  med_int *profil)
143 #else
144 med_int
145 nmpffprr(med_idt *fid, char *pname, med_int *pnamelen, med_int *profil)
146 #endif
147 {
148  med_err _ret=0;
149  char *_fn1;
150 
151  _fn1 = _MED2cstring((char *) pname, (int) *pnamelen);
152  if (!_fn1)
153  return(-1);
154 
155  _ret = (med_int) MEDprofileRd((med_idt) *fid,
156  _fn1,
157  (med_int *) profil);
158 
159  _MEDcstringFree(_fn1);
160 
161  return (_ret);
162 }
herr_t med_err
Definition: med.h:310
MEDC_EXPORT med_err _MEDcstringFree(char *chaine)
#define nmpffprr
Definition: medprofilecf.c:37
MEDC_EXPORT med_int MEDnProfile(const med_idt fid)
Cette routine permet de lire le nombre de profil dans un fichier MED.
Definition: MEDnProfile.c:37
MEDC_EXPORT med_err MEDprofileInfo(const med_idt fid, const int profileit, char *const profilename, med_int *const profilesize)
Cette routine permet de lire les informations sur un profil dans un fichier MED.
MEDC_EXPORT med_err MEDprofileRd(const med_idt fid, const char *const profilename, med_int *const profilearray)
Cette routine permet de lire un profil dans un fichier MED.
Definition: MEDprofileRd.c:39
int med_int
Definition: med.h:316
MEDC_EXPORT med_int MEDprofileSizeByName(const med_idt fid, const char *const profilename)
Cette routine permet de lire la taille d'un profil dont on connait le nom.
#define nmpffpsn
Definition: medprofilecf.c:38
#define nmpffprw
Definition: medprofilecf.c:34
MEDC_EXPORT med_err _MEDc2fString(const char *const chainec, char *const chainef, med_int longueur_buffer77)
#define nmpffpfi
Definition: medprofilecf.c:36
hid_t med_idt
Definition: med.h:309
#define MED_NAME_SIZE
Definition: med.h:74
MEDC_EXPORT char * _MED2cstring(char *chaine, int longueur)
Definition: MED2cstring.c:35
MEDC_EXPORT med_err MEDprofileWr(const med_idt fid, const char *const profilename, const med_int profilesize, const med_int *const profilearray)
Cette routine permet d'écrire un profil dans un fichier MED.
Definition: MEDprofileWr.c:40
#define nmpffnpf
Definition: medprofilecf.c:35