Salome HOME
Initialisation de la base KERNEL avec la version operationnelle de KERNEL_SRC issue...
[modules/kernel.git] / src / HDFPersist / test2.c
1 #include"hdfi.h"
2 #include<stdlib.h>
3
4 int main() {
5   hdf_idt fid,gid,did,atid;
6   hdf_err ret;
7   hdf_size size[1];
8   hdf_int32 data[10];
9   int attr_val;
10   int i;
11
12   HDFerrorModeLock();
13   
14   if  ((fid = HDFfileOpen("titi.HDF",HDF_RDONLY)) < 0)
15     return -1;
16   MESSAGE("Ouverture du fichier")
17
18   if ((gid = HDFgroupOpen(fid,"GROUP")) < 0)
19     return -1;
20   MESSAGE("Ouverture du goupe")
21
22   if ((atid = HDFattrOpen(gid,"ATTR"))< 0)
23     return -1;
24   MESSAGE("Ouverture de l'attribut du goupe")
25
26   if ((ret = HDFattrRead(atid,&attr_val)) < 0) 
27     return -1;
28   MESSAGE("Lecture de l'attribut du goupe : " << attr_val)
29
30   if ((ret = HDFattrClose(atid))  < 0)
31     return -1;
32   MESSAGE("Fermeture de l'attribut du goupe")
33
34   if ((did = HDFdatasetOpen(gid,"DATASET")) < 0)
35     return -1;
36   MESSAGE("Ouverture du dataset")
37
38   if ((ret = HDFdatasetRead(did,data)) < 0)
39     return -1;
40   MESSAGE("Lecture du dataset")
41   for (i=0;i<10;i++)
42     MESSAGE(data[i])
43
44   if ((ret = HDFdatasetClose(did)) < 0)
45     return -1;
46   MESSAGE("Fermeture du dataset")
47
48   if ((ret = HDFgroupClose(gid)) < 0)
49     return -1;
50   MESSAGE("Fermeture du groupe")
51   
52   if ((ret = HDFfileClose(fid)) < 0)
53     return ret;
54   MESSAGE("Fermeture du fichier")
55   
56   return 0;
57 }