]> SALOME platform Git repositories - modules/med.git/blob - src/MEDWrapper/V2_1/Core/MEDattrNumLire.cxx
Salome HOME
Mantis issue 0021668: [CEA 564] MED2.1 to MED2.3
[modules/med.git] / src / MEDWrapper / V2_1 / Core / MEDattrNumLire.cxx
1 /*************************************************************************
2 * COPYRIGHT (C) 1999 - 2002  EDF R&D
3 * THIS LIBRARY IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY
4 * IT UNDER THE TERMS OF THE GNU LESSER GENERAL PUBLIC LICENSE 
5 * AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION; 
6 * EITHER VERSION 2.1 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
7 *  
8 * THIS LIBRARY IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT
9 * WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF
10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU
11 * LESSER GENERAL PUBLIC LICENSE FOR MORE DETAILS.
12 *
13 * YOU SHOULD HAVE RECEIVED A COPY OF THE GNU LESSER GENERAL PUBLIC LICENSE
14 * ALONG WITH THIS LIBRARY; IF NOT, WRITE TO THE FREE SOFTWARE FOUNDATION,
15 * INC., 59 TEMPLE PLACE, SUITE 330, BOSTON, MA 02111-1307 USA
16 *
17 *************************************************************************/
18
19
20 #include "med.hxx"
21 #include "med_outils.hxx"
22
23 #include <cstring>
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_REEL64,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  */ 
35
36 namespace med_2_1{
37
38 med_err 
39 _MEDattrNumLire(med_idt pere,med_type_champ type,char *nom,unsigned char *val)
40 {
41   med_idt attid;
42   med_err ret;
43   int type_hdf;
44
45   if ((attid = H5Aopen_name(pere,nom)) < 0)
46     return -1;
47
48   switch(type) 
49     {
50     case MED_REEL64 :
51 #if defined(PCLINUX) || defined(OSF1) || defined(PPRO_NT) || defined(PCLINUX64) || defined(PCLINUX64_32)
52       type_hdf = H5T_IEEE_F64BE;
53 #else 
54       type_hdf = H5T_IEEE_F64LE;
55 #endif
56       break;
57       
58     case MED_INT :
59 #if defined(HAVE_F77INT64)
60       type_hdf = H5T_NATIVE_LONG; 
61 #else
62       type_hdf = H5T_NATIVE_INT;
63 #endif
64       break;
65       
66     default :
67       return -1;
68     }
69
70   if ((ret = H5Aread(attid,type_hdf,val)) < 0)
71     return -1;
72
73   if (strcmp(nom, MED_NOM_NGA) == 0 ) {
74     med_int* ngauss = (med_int*)val;
75     if( *ngauss <= 0 || *ngauss > 128) 
76       *ngauss =1;
77   }
78
79   if ((ret = H5Aclose(attid)) < 0)
80     return -1;
81
82   return 0;
83 }
84
85 }