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
20 #include <med.h>
21 #include <med_config.h>
22 #include <med_outils.h>
23 #include <hdf5.h>
24
25 /*
26 * - Nom de la fonction : _MEDattrNumLire
27 * - Description : lecture d'un attribut entier
28 * - Parametres :
29 * - pere (IN) : l'ID de l'objet HDF pere ou placer l'attribut
30 * - type (IN) : le type du champ {MED_FLOAT64,MED_INT}
31 * - nom (IN) : le nom de l'attribut
32 * - val (OUT) : la valeur de l'attribut
33 * - Resultat : 0 en cas de succes, -1 sinon
34 */
_MEDattrNumLire(med_idt pere,med_field_type type,const char * const nom,unsigned char * val)35 med_err _MEDattrNumLire(med_idt pere,med_field_type type,const char * const nom,unsigned char *val)
36 {
37 med_idt attid;
38 med_err ret;
39 hid_t type_hdf;
40
41 /* ISCRUTE(sizeof(med_int)); */
42 /* ISCRUTE_id(pere); */
43 /* SSCRUTE(nom); */
44
45 if ((attid = H5Aopen_name(pere,nom)) < 0)
46 return -1;
47
48 switch(type)
49 {
50 case MED_FLOAT64 :
51 type_hdf = H5T_NATIVE_DOUBLE;
52 break;
53
54 case MED_INT :
55 #if defined(HAVE_F77INT64)
56 type_hdf = H5T_NATIVE_LONG;
57 #else
58 type_hdf = H5T_NATIVE_INT;
59 #endif
60 break;
61
62 default :
63 return -1;
64 }
65
66 if ((ret = H5Aread(attid,type_hdf, val)) < 0)
67 return -1;
68
69 if ((ret = H5Aclose(attid)) < 0)
70 return -1;
71
72 return 0;
73 }
74
75
76
77