# MED21attrNumLire.c

Aller à la documentation de ce fichier.

    00001 /*  This file is part of MED.
    00002  *
    00003  *  COPYRIGHT (C) 1999 - 2012  EDF R&D, CEA/DEN
    00004  *  MED is free software: you can redistribute it and/or modify
    00005  *  it under the terms of the GNU Lesser General Public License as published by
    00006  *  the Free Software Foundation, either version 3 of the License, or
    00007  *  (at your option) any later version.
    00008  *
    00009  *  MED is distributed in the hope that it will be useful,
    00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00012  *  GNU Lesser General Public License for more details.
    00013  *
    00014  *  You should have received a copy of the GNU Lesser General Public License
    00015  *  along with MED.  If not, see <http://www.gnu.org/licenses/>.
    00016  */
    00017
    00018
    00019 #include <med_config.h>
    00020 #include <med.h>
    00021 #include <med_outils.h>
    00022 #include <hdf5.h>
    00023
    00024 med_err _MED21attrNumLire(med_idt pere,med_type_champ type,char *nom,
    00025                           unsigned char *val,hid_t hdf_file)
    00026 {
    00027   med_idt attid;
    00028   med_err ret;
    00029   int type_hdf;
    00030
    00031   if ((attid = H5Aopen_name(pere,nom)) < 0)
    00032     return -1;
    00033
    00034   switch(type)
    00035     {
    00036     case MED_FLOAT64 :
    00037       if (H5Tequal(hdf_file,H5T_IEEE_F64BE))
    00038         type_hdf = H5T_IEEE_F64LE;
    00039       if (H5Tequal(hdf_file,H5T_IEEE_F64LE))
    00040         type_hdf = H5T_IEEE_F64BE;
    00041       break;
    00042
    00043     case MED_INT :
    00044 #if defined(HAVE_F77INT64)
    00045       type_hdf = H5T_NATIVE_LONG;
    00046 #else
    00047       type_hdf = H5T_NATIVE_INT;
    00048 #endif
    00049       break;
    00050
    00051     default :
    00052       return -1;
    00053     }
    00054
    00055   if ((ret = H5Aread(attid,type_hdf,val)) < 0)
    00056     return -1;
    00057
    00058   if ((ret = H5Aclose(attid)) < 0)
    00059     return -1;
    00060
    00061   return 0;
    00062 }