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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 /*----------------------------------------------------------------------------
20 SALOME HDFPersist : implementation of HDF persitent ( save/ restore )
21 File : HDFdatasetCreate.c
23 ----------------------------------------------------------------------------*/
28 * - Name : HDFdatasetCreate
29 * - Description : creates a HDF dataset
31 * - pid (IN) : father ID
32 * - name (IN) : dataset name
33 * - type (IN) : dataset type (HDF_STRING,HDF_INT32,HDF_INT64,HDF_FLOAT64)
34 * - dimd (IN) : dataset size
35 * - order(IN) : byte order (H5T_ORDER_NONE, H5T_ORDER_LE, H5T_ORDER_BE)
37 * - if success : returns dataset ID
41 hdf_idt HDFdatasetCreate(hdf_idt pid,char *name,hdf_type type,
42 hdf_size *dimd, int ndim, hdf_byte_order order)
44 hdf_idt dataset, dataspace = 0;
46 hdf_idt type_hdf, new_type_hdf = -1;
52 type_hdf = H5T_IEEE_F64BE;
54 type_hdf = H5T_IEEE_F64LE;
60 type_hdf = H5T_STD_I32BE;
62 type_hdf = H5T_NATIVE_INT;
67 type_hdf = H5T_NATIVE_LONG;
71 if((new_type_hdf = H5Tcopy(H5T_C_S1)) < 0)
73 if((ret = H5Tset_size(new_type_hdf,1)) < 0)
82 if ( order != H5T_ORDER_ERROR &&
83 order != H5T_ORDER_NONE &&
86 if (( new_type_hdf = H5Tcopy( type_hdf )) < 0 )
88 if (( ret = H5Tset_order (new_type_hdf, order )) < 0 )
92 if ((dataset = H5Dopen(pid,name)) < 0)
94 if ((dataspace = H5Screate_simple(ndim, dimd, NULL)) < 0)
96 if ((dataset = H5Dcreate(pid,name,
97 new_type_hdf < 0 ? type_hdf : new_type_hdf,
98 dataspace, H5P_DEFAULT)) < 0)
104 if ( ! (new_type_hdf < 0) && (ret = H5Tclose(new_type_hdf)) < 0)
106 if ((ret = H5Sclose(dataspace)) < 0)