MED fichier
medfiltercf.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 - MEDfilterEntityCr
28 - MEDfilterAllocate
29 - MEDfilterDeAllocate
30 - MEDfilterBlockOfEntityCr
31 */
32 
33 #define nmfrfall F77_FUNC(mfrfall,NMFRFALL)
34 #define nmfrfdea F77_FUNC(mfrfdea,NMFRFDEA)
35 #define nmfrfcre F77_FUNC(mfrfcre,MFRFCRE)
36 #define nmfrfblc F77_FUNC(mfrfblc,MFRFBLC)
37 
38 
39 #ifdef PPRO_NT
40 med_int
41 MFRFALL(med_int *nflt,unsigned char **flt)
42 #else
43 med_int
44 nmfrfall(med_int* nflt,unsigned char** flt)
45 #endif
46 {
47  med_filter *_filter;
48  med_err _ret=0;
49  int _i;
50 
51  _filter = MEDfilterAllocate((med_int) *nflt);
52  if (! _filter) _ret = -1;
53 
54  for (_i=0;_i<*nflt;_i++) {
55  *(flt + _i*8) =
56  (unsigned char*) &_filter[_i];
57  }
58 
59  return (_ret);
60 }
61 
62 
63 
64 
65 #ifdef PPRO_NT
66 med_int
67 MFRFDEA(med_int *nflt,unsigned char **flt)
68 #else
69 med_int
70 nmfrfdea(med_int* nflt,unsigned char** flt)
71 #endif
72 {
73  med_filter *_filter;
74  med_err _ret=0;
75  int _i;
76 
77  for (_i=0;_i<*nflt;_i++)
78  MEDfilterClose( (med_filter *) *(flt + _i*8));
79 
80  free((med_filter *)flt[0]);
81 
82  return (_ret);
83 }
84 
85 
86 
87 
88 #ifdef PPRO_NT
89 med_int
90 MFRFCRE(med_int *fid, med_int* nent, med_int *nvent, med_int *ncent,
91  med_int *cs, med_int *swm, med_int *stm, char *pname, unsigned int bidon, med_int *pnamelen,
92  med_int *fltas, med_int *flta, unsigned char **flt)
93 #else
94 med_int
95 nmfrfcre(med_int *fid, med_int* nent, med_int *nvent, med_int *ncent,
96  med_int *cs, med_int *swm,med_int *stm,char *pname, med_int *pnamelen,
97  med_int *fltas,med_int *flta, unsigned char **flt)
98 #endif
99 {
100  char *_fn=NULL;
101  med_int _ret=0;
102  med_switch_mode _swm = (med_switch_mode) *swm;
103  med_storage_mode _smode = (med_storage_mode) *stm;
104  med_filter *_filter = (med_filter*) *flt;
105  med_int *_flta=NULL;
106 
107  _fn = _MED2cstring((char *) pname, (int) *pnamelen);
108  if (!_fn)
109  return(-1);
110 
111  if (*fltas != MED_UNDEF_SIZE)
112  _flta = flta;
113 
114  _ret = (med_int) MEDfilterEntityCr((med_idt) *fid,
115  (med_int) *nent,
116  (med_int) *nvent,
117  (med_int) *ncent,
118  (med_int) *cs,
119  _swm,
120  _smode,
121  _fn,
122  (med_int) *fltas,
123  _flta,
124  _filter);
125 
126 
127  if (_fn)
128  _MEDcstringFree(_fn);
129 
130  return(_ret);
131 }
132 
133 
134 
135 
136 #ifdef PPRO_NT
137 med_int
138 MFRFBLC(med_int *fid, med_int* nent, med_int *nvent, med_int *ncent,
139  med_int *cs, med_int *swm, med_int *stm, char *pname, unsigned int bidon, med_int *pnamelen,
140  med_int *start, med_int *stride, med_int *count, med_int *bsize, med_int *lbsize,
141  unsigned char **flt)
142 #else
143 med_int
144 nmfrfblc(med_int *fid, med_int* nent, med_int *nvent, med_int *ncent,
145  med_int *cs, med_int *swm,med_int *stm,char *pname, med_int *pnamelen,
146  med_int *start, med_int *stride, med_int *count, med_int *bsize, med_int *lbsize,
147  unsigned char **flt)
148 #endif
149 {
150  char *_fn=NULL;
151  med_int _ret=0;
152  med_switch_mode _swm = (med_switch_mode) *swm;
153  med_storage_mode _smode = (med_storage_mode) *stm;
154  med_filter *_filter= (med_filter*) *flt;
155  med_size _start = (med_size) *start;
156  med_size _stride = (med_size) *stride;
157  med_size _count = (med_size) *count;
158  med_size _bsize = (med_size) *bsize;
159  med_size _lbsize = (med_size) *lbsize;
160 
161  _fn = _MED2cstring((char *) pname, (int) *pnamelen);
162  if (!_fn)
163  return(-1);
164 
165  _ret = (med_int) MEDfilterBlockOfEntityCr((med_idt) *fid,
166  (med_int) *nent,
167  (med_int) *nvent,
168  (med_int) *ncent,
169  (med_int) *cs,
170  _swm,
171  _smode,
172  _fn,
173  _start,
174  _stride,
175  _count,
176  _bsize,
177  _lbsize,
178  _filter);
179 
180 
181  if (_fn)
182  _MEDcstringFree(_fn);
183 
184  return(_ret);
185 }
186 
187 
188 
189 
190 
191 
192 
herr_t med_err
Definition: med.h:310
MEDC_EXPORT med_err _MEDcstringFree(char *chaine)
Filtre de sélection.
Definition: med.h:326
med_switch_mode
Definition: med.h:89
hsize_t med_size
Definition: med.h:307
#define nmfrfblc
Definition: medfiltercf.c:36
MEDC_EXPORT med_err MEDfilterClose(med_filter *const filter)
Désalloue les ressources hdf détenues par un filtre.
MEDC_EXPORT med_filter * MEDfilterAllocate(const int nfilter)
Alloue un tableau de filtres de taille nfilter.
int med_int
Definition: med.h:316
#define nmfrfall
Definition: medfiltercf.c:33
med_storage_mode
Definition: med.h:101
MEDC_EXPORT med_err MEDfilterEntityCr(const med_idt fid, const med_int nentity, const med_int nvaluesperentity, const med_int nconstituentpervalue, const med_int constituentselect, const med_switch_mode switchmode, const med_storage_mode storagemode, const char *const profilename, const med_int filterarraysize, const med_int *const filterarray, med_filter *const filter)
hid_t med_idt
Definition: med.h:309
#define MED_UNDEF_SIZE
Definition: med.h:286
#define nmfrfdea
Definition: medfiltercf.c:34
MEDC_EXPORT char * _MED2cstring(char *chaine, int longueur)
Definition: MED2cstring.c:35
#define nmfrfcre
Definition: medfiltercf.c:35
MEDC_EXPORT med_err MEDfilterBlockOfEntityCr(const med_idt fid, const med_int nentity, const med_int nvaluesperentity, const med_int nconstituentpervalue, const med_int constituentselect, const med_switch_mode switchmode, const med_storage_mode storagemode, const char *const profilename, const med_size start, const med_size stride, const med_size count, const med_size blocksize, const med_size lastblocksize, med_filter *const filter)
Crée un filtre en selectionnant par blocs les entités pour lesquelles on veut lire/écrire des valeurs...