# MED21attrNumLire.c

Aller à la documentation de ce fichier.

    00001 /*  This file is part of MED.
    00002  *
    00003  *  COPYRIGHT (C) 1999 - 2011  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 #ifndef MESGERR
    00020 #define MESGERR 1
    00021 #endif
    00022
    00023 #include <med.h>
    00024 #include <med_config.h>
    00025 #include <med_outils.h>
    00026 #include <hdf5.h>
    00027
    00028 med_err _MED21attrNumLire(med_idt pere,med_type_champ type,char *nom,
    00029                           unsigned char *val,hid_t hdf_file)
    00030 {
    00031   med_idt attid;
    00032   med_err ret;
    00033   int type_hdf;
    00034
    00035   if ((attid = H5Aopen_name(pere,nom)) < 0)
    00036     return -1;
    00037
    00038   switch(type)
    00039     {
    00040     case MED_FLOAT64 :
    00041       if (H5Tequal(hdf_file,H5T_IEEE_F64BE))
    00042         type_hdf = H5T_IEEE_F64LE;
    00043       if (H5Tequal(hdf_file,H5T_IEEE_F64LE))
    00044         type_hdf = H5T_IEEE_F64BE;
    00045       break;
    00046
    00047     case MED_INT :
    00048 #if defined(HAVE_F77INT64)
    00049       type_hdf = H5T_NATIVE_LONG;
    00050 #else
    00051       type_hdf = H5T_NATIVE_INT;
    00052 #endif
    00053       break;
    00054
    00055     default :
    00056       return -1;
    00057     }
    00058
    00059   if ((ret = H5Aread(attid,type_hdf,val)) < 0)
    00060     return -1;
    00061
    00062   if ((ret = H5Aclose(attid)) < 0)
    00063     return -1;
    00064
    00065   return 0;
    00066 }