Back to index

salome-kernel  6.5.0
test2.c
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 /*----------------------------------------------------------------------------
00024 SALOME HDFPersist : implementation of HDF persitent ( save/ restore )
00025   File   : test2.c
00026   Module : SALOME
00027 ----------------------------------------------------------------------------*/
00028 
00029 #include"hdfi.h"
00030 #include<stdlib.h>
00031 
00032 int main() {
00033   hdf_idt fid,gid,did,atid;
00034   hdf_err ret;
00035   hdf_size size[1];
00036   hdf_int32 data[10];
00037   int attr_val;
00038   int i;
00039 
00040   HDFerrorModeLock();
00041   
00042   if  ((fid = HDFfileOpen("titi.HDF",HDF_RDONLY)) < 0)
00043     return -1;
00044   MESSAGE("Ouverture du fichier")
00045 
00046   if ((gid = HDFgroupOpen(fid,"GROUP")) < 0)
00047     return -1;
00048   MESSAGE("Ouverture du goupe")
00049 
00050   if ((atid = HDFattrOpen(gid,"ATTR"))< 0)
00051     return -1;
00052   MESSAGE("Ouverture de l'attribut du goupe")
00053 
00054   if ((ret = HDFattrRead(atid,&attr_val)) < 0) 
00055     return -1;
00056   MESSAGE("Lecture de l'attribut du goupe : " << attr_val)
00057 
00058   if ((ret = HDFattrClose(atid))  < 0)
00059     return -1;
00060   MESSAGE("Fermeture de l'attribut du goupe")
00061 
00062   if ((did = HDFdatasetOpen(gid,"DATASET")) < 0)
00063     return -1;
00064   MESSAGE("Ouverture du dataset")
00065 
00066   if ((ret = HDFdatasetRead(did,data)) < 0)
00067     return -1;
00068   MESSAGE("Lecture du dataset")
00069   for (i=0;i<10;i++)
00070     MESSAGE(data[i])
00071 
00072   if ((ret = HDFdatasetClose(did)) < 0)
00073     return -1;
00074   MESSAGE("Fermeture du dataset")
00075 
00076   if ((ret = HDFgroupClose(gid)) < 0)
00077     return -1;
00078   MESSAGE("Fermeture du groupe")
00079   
00080   if ((ret = HDFfileClose(fid)) < 0)
00081     return ret;
00082   MESSAGE("Fermeture du fichier")
00083   
00084   return 0;
00085 }