# MEDstructElementConstAttInfoByName.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.h>
    00020 #include <med_config.h>
    00021 #include <med_outils.h>
    00022
    00023 #include <stdlib.h>
    00024 #include <string.h>
    00025
    00043 med_err
    00044 MEDstructElementConstAttInfoByName(const med_idt             fid,
    00045                                    const char*         const modelname,
    00046                                    const char*         const constattname,
    00047                                    med_attribute_type* const constatttype,
    00048                                    med_int*            const ncomponent,
    00049                                    med_entity_type*    const sentitytype,
    00050                                    char*               const profilename,
    00051                                    med_int*            const profilesize
    00052                                    )
    00053 {
    00054
    00055   med_err           _ret=-1;
    00056   med_idt           _attid=0;
    00057   char              _path[MED_TAILLE_STRCT+MED_NAME_SIZE+1+MED_TAILLE_CSTATR+MED_NAME_SIZE+1]=MED_STRCT;
    00058   med_int           _intsentitytype = MED_UNDEF_ENTITY_TYPE;
    00059   med_int           _profilesize=0;
    00060   med_int           _medintconstatttype;
    00061
    00062   strcat(_path,modelname);
    00063   strcat(_path,MED_CSTATR);
    00064   strcat(_path,constattname);
    00065
    00066   /*
    00067    * Si le DataGroup /STRUCT/<modelname>/CSTATT/<constattributename> n'existe pas => erreur
    00068    */
    00069   if ((_attid = _MEDdatagroupOpen(fid,_path)) < 0)  {
    00070     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,_path);
    00071     goto ERROR;
    00072   }
    00073
    00074   /*
    00075    * Lecture de l'attribut MED_NOM_ATT (type des valeurs de l'attribut.)
    00076    */
    00077   if ( _MEDattrEntierLire(_attid,MED_NOM_ATT,&_medintconstatttype) < 0 ) {
    00078     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_path);
    00079     SSCRUTE(MED_NOM_ATT);ISCRUTE(_medintconstatttype);
    00080     goto ERROR;
    00081   }
    00082   *constatttype=_medintconstatttype;
    00083
    00084   /*
    00085    * Lecture de l'attribut MED_NOM_NCO (nombre de composantes des valeurs de l'attribut.)
    00086    */
    00087   if ( _MEDattrEntierLire(_attid,MED_NOM_NCO,ncomponent) < 0 ) {
    00088     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_path);
    00089     SSCRUTE(MED_NOM_NCO);ISCRUTE(*ncomponent);
    00090     goto ERROR;
    00091   }
    00092
    00093   /*
    00094    * Lecture de l'attribut MED_NOM_ENT (type d'entité support concerné par l'attribut)
    00095    */
    00096   if ( _MEDattrEntierLire(_attid,MED_NOM_ENT,&_intsentitytype) < 0 ) {
    00097     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_path);
    00098     SSCRUTE(MED_NOM_ENT);ISCRUTE(_intsentitytype);
    00099     goto ERROR;
    00100   }
    00101   *sentitytype = (med_entity_type) _intsentitytype;
    00102
    00103   /*
    00104    * Lecture de l'attribut MED_NOM_PFL
    00105    */
    00106   if ( _MEDattrStringLire(_attid,MED_NOM_PFL,MED_NAME_SIZE,profilename) < 0) {
    00107     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_path);
    00108     SSCRUTE(MED_NOM_PFL);SSCRUTE(profilename);
    00109     goto ERROR;
    00110   }
    00111
    00112   if ( (_profilesize=MEDprofileSizeByName(fid, profilename) ) < 0 ) {
    00113     MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,MED_ERR_STRUCT_MSG);
    00114     SSCRUTE(modelname);SSCRUTE(_path);SSCRUTE("MEDprofileSizeByName");
    00115     goto ERROR;
    00116   }
    00117   *profilesize=_profilesize;
    00118
    00119   _ret=0;
    00120  ERROR:
    00121
    00122   if (_attid>0)            if (_MEDdatagroupFermer(_attid) < 0) {
    00123     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,modelname);
    00124     ISCRUTE_id(_attid);
    00125   }
    00126
    00127   return _ret;
    00128 }