Salome HOME
Removed CASCatch
[modules/kernel.git] / src / HDFPersist / HDFdatasetGetDim.c
1 // Copyright (C) 2005  OPEN CASCADE, CEA, EDF R&D, LEG
2 //           PRINCIPIA R&D, EADS CCR, Lip6, BV, CEDRAT
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either 
6 // version 2.1 of the License.
7 // 
8 // This library is distributed in the hope that it will be useful 
9 // but 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  
14 // License along with this library; if not, write to the Free Software 
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 // 
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 // 
19 /*----------------------------------------------------------------------------
20 SALOME HDFPersist : implementation of HDF persitent ( save/ restore )
21   File   : HDFdatasetGetDim.c
22   Module : SALOME
23 ----------------------------------------------------------------------------*/
24
25 #include <hdf5.h>
26 #include "hdfi.h"
27 #include <stdlib.h>
28
29 hdf_err 
30 HDFdatasetGetDim(hdf_idt id,hdf_size dim[])
31 {
32   hdf_err ret = 0;
33   hdf_size *tmp;
34   int ndim;
35   hdf_idt space_id;
36
37   if ((space_id = H5Dget_space(id)) < 0)
38     return -1;
39
40   if ((ndim = H5Sget_simple_extent_ndims(space_id)) < 0)
41     return -1;
42
43   tmp = (hdf_size *) malloc(sizeof(hdf_size)*ndim);
44   ret = H5Sget_simple_extent_dims(space_id, dim, tmp);
45   ret =  H5Sclose(space_id);
46   
47  free (tmp);
48
49   return ret;
50 }
51
52