Salome HOME
Issue 20509: EDF 1065 OTHER : Add the Salome version in the header of the dump
[modules/kernel.git] / src / HDFPersist / test1.c
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 /*----------------------------------------------------------------------------
23 SALOME HDFPersist : implementation of HDF persitent ( save/ restore )
24   File   : test1.c
25   Module : SALOME
26 ----------------------------------------------------------------------------*/
27
28 #include"hdfi.h"
29 #include<stdlib.h>
30
31 #define MESSAGE(msg) printf(msg);
32 //__FILE__,":[",__LINE__,"]: ",
33
34 int main() {
35   hdf_idt fid,gid,did,atid;
36   hdf_err ret;
37   hdf_size size[1];
38   hdf_int32 data[10] = { 1,2,3,4,5,6,7,8,9,10};
39   hdf_int32 attr_val = 2; 
40   
41   system("rm titi.HDF");
42
43   HDFerrorModeLock();
44   
45   if  ((fid = HDFfileCreate("titi.HDF")) < 0)
46     return -1;
47   MESSAGE("Creation du fichier")
48
49   if ((gid = HDFgroupCreate(fid,"GROUP")) < 0)
50     return -1;
51   MESSAGE("Creation d'un groupe")
52
53   if ((atid = HDFattrCreate(gid,"ATTR",HDF_INT32))< 0)
54     return -1;
55   MESSAGE("Creation d'un attribut")
56
57   if ((ret = HDFattrWrite(atid,&attr_val)) < 0)
58     return -1;
59   MESSAGE("Ecriture de l'attribut")
60  
61   if ((ret = HDFattrClose(atid))  < 0)
62     return -1;
63   MESSAGE("Fermeture de l'attribut")
64
65   size[0] = 10;
66   if ((did = HDFdatasetCreate(gid,"DATASET",HDF_INT32,size)) < 0)
67     return -1;
68   MESSAGE("Creation d'un dataset")
69
70   if ((ret = HDFdatasetWrite(did,data)) < 0)
71     return -1;
72   MESSAGE("Ecriture du dataset")
73
74   if ((ret = HDFdatasetClose(did)) < 0)
75     return -1;
76   MESSAGE("Fermeture du datset")
77
78   if ((ret = HDFgroupClose(gid)) < 0)
79     return -1;
80   MESSAGE("Fermeture du groupe")
81
82   if ((ret = HDFfileClose(fid)) < 0)
83     return ret; 
84   MESSAGE("Fermeture du fichier")
85
86   if  ((fid = HDFfileCreate("toto.HDF")) < 0)
87     return -1;
88   MESSAGE("Creation du fichier")
89
90   if ((ret = HDFfileClose(fid)) < 0)
91     return ret; 
92   MESSAGE("Fermeture du fichier")
93   
94   
95   return 0;
96 }