MEDstructElementConstAttInfoByName.c
Aller à la documentation de ce fichier.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
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 
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 
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 
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 
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 
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 }