11 HDFdataset *hdf_dataset1, *hdf_dataset2;
13 char name[HDF_NAME_MAX_LEN+1];
23 // a new HDFfile object
24 hdf_file = new HDFfile("file_test3.hdf");
25 MESSAGE( ">> A HDFfile object is created" );
27 hdf_file->OpenOnDisk(HDF_RDONLY);
28 MESSAGE(">> The HDF file is opened on Disk with HDF_RDONLY access mode")
29 // It is possible to read the name of all (objects) sons in the file
30 n = hdf_file->nInternalObjects();
33 hdf_file->InternalObjectIndentify(i,name);
34 MESSAGE( "--> First Level Internal Object Name : " << name );
37 // Or it is possible to ask if an object is in the file
38 if (hdf_file->ExistInternalObject("MESH"))
39 MESSAGE( "--> The object naming 'MESH' is in the file " );
41 // it is possible to determine the type of an object
42 type = hdf_file->InternalObjectType("MESH");
46 MESSAGE( "--> Its type is HDF_GROUP" );
50 MESSAGE( "--> Its type is HDF_DATASET" );
54 MESSAGE( "--> !!!! PANIC !!!" );
57 hdf_group = new HDFgroup(name,hdf_file);
58 MESSAGE( ">> A new HDF group object " << name << " is created in memory")
60 hdf_group->OpenOnDisk();
61 MESSAGE( ">> The group " << name << " is opened on disk" );
63 // object inside the group ?
64 n = hdf_group->nInternalObjects();
65 MESSAGE( ">> There are " << n << " objects in this group " );
68 hdf_group->InternalObjectIndentify(i,name);
69 type = hdf_group->InternalObjectType(name);
70 MESSAGE( "--> First Level Internal Object Name : " << name );
74 MESSAGE( "--> Its type is HDF_GROUP" );
78 MESSAGE( "--> Its type is HDF_DATASET" );
82 MESSAGE( "--> !!!! PANIC !!!" );
86 // The first dataset object 'COORDINATES'
87 hdf_dataset1 = new HDFdataset("COORDINATES",hdf_group);
88 MESSAGE( ">> The dataset object 'COORDINATES' is created in memory " );
90 hdf_dataset1->OpenOnDisk();
91 MESSAGE( ">> The dataset object 'COORDINATES' is opened on disk " );
93 data_type = hdf_dataset1->GetType();
97 MESSAGE( "--> Type of data : HDF_INT32 " );
100 MESSAGE( "--> Type of data : HDF_INT64 " );
103 MESSAGE( "--> Type of data : HDF_FLOAT64 " );
106 MESSAGE( "--> Type of data : HDF_STRING " );
109 ndim = hdf_dataset1->nDim();
110 MESSAGE( "--> Number of dimensions : " << ndim );
112 dim = new hdf_size[ndim];
113 hdf_dataset1->GetDim(dim);
115 MESSAGE( "--> Dimension " << i+1 << " of size : " << dim[i] );
118 size = hdf_dataset1->GetSize();
119 val1 = new hdf_float64[size];
120 hdf_dataset1->ReadFromDisk(val1);
121 MESSAGE( "--> The values are : ");
123 MESSAGE( " " << val1[i]);
127 hdf_dataset1->CloseOnDisk();
128 MESSAGE( ">> The dataset object 'COORDINATES' is closed on disk " );
130 // The second dataset 'UNIT'
131 hdf_dataset2 = new HDFdataset("UNIT",hdf_group);
132 MESSAGE( ">> The dataset object 'UNIT' is created in memory " );
134 hdf_dataset2->OpenOnDisk();
135 MESSAGE( ">> The dataset object 'UNIT' is opened on disk " );
137 data_type = hdf_dataset2->GetType();
141 MESSAGE( "--> Type of data : HDF_INT32 " );
144 MESSAGE( "--> Type of data : HDF_INT64 " );
147 MESSAGE( "--> Type of data : HDF_FLOAT64 " );
150 MESSAGE( "--> Type of data : HDF_STRING " );
153 ndim = hdf_dataset2->nDim();
154 MESSAGE( "--> Number of dimensions : " << ndim );
156 dim = new hdf_size[ndim];
157 hdf_dataset2->GetDim(dim);
159 MESSAGE( "--> Dimension " << i+1 << " of size : " << dim[i] );
162 size = hdf_dataset2->GetSize();
163 val2 = new hdf_int32[size];
164 hdf_dataset2->ReadFromDisk(val2);
165 MESSAGE( "--> The values are : ");
167 MESSAGE( " " << val2[i]);
171 hdf_dataset2->CloseOnDisk();
172 MESSAGE( ">> The dataset object 'UNIT' is closed on disk " );
174 hdf_group->CloseOnDisk();
175 MESSAGE( ">> The group is closed on file" );
177 hdf_file->CloseOnDisk();
178 MESSAGE(">> The HDF file is closed on Disk" )
185 MESSAGE( ">> MEMORY CLEAN : all HDF objects have been deleted" );
189 MESSAGE( "!!! HDFexception !!! " )