# _MEDfieldnProfile30.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 #include <med.h>
    00020 #include <med_config.h>
    00021 #include <med_outils.h>
    00022 #include <string.h>
    00023
    00024 void
    00025 _MEDfieldnProfile30(int dummy, ...) {
    00026
    00027
    00028   med_int  _ret=-1,_err=-1;
    00029   med_idt  _gid=0,_datagroup1=0;
    00030   char     _path[(MED_TAILLE_CHA+MED_NAME_SIZE+1)+(2*MED_MAX_PARA+1)+1]=MED_CHA;
    00031   char     _datagroupname1[2*MED_TAILLE_NOM_ENTITE+2]="";
    00032   char     _geotypename      [MED_TAILLE_NOM_ENTITE+1]="";
    00033   char     _profilename  [MED_NAME_SIZE+1]="";
    00034   med_int  _numdt=0, _numit=0;
    00035   med_size _n=0;
    00036
    00037
    00038   MED_VARGS_DECL(const, med_idt           , , fid                     );
    00039   MED_VARGS_DECL(const, char * , const      , fieldname               );
    00040   MED_VARGS_DECL(const, med_int           , , numdt                   );
    00041   MED_VARGS_DECL(const, med_int           , , numit                   );
    00042   MED_VARGS_DECL(const, med_entity_type   , , entitype                );
    00043   MED_VARGS_DECL(const, med_geometry_type , , geotype                 );
    00044   MED_VARGS_DECL(, char *, const      , defaultprofilename            );
    00045   MED_VARGS_DECL(, char *, const      , defaultlocalizationname       );
    00046   MED_VARGS_DECL(, med_int *         ,, fret                          );
    00047
    00048   va_list params;
    00049   va_start(params,dummy);
    00050
    00051   MED_VARGS_DEF(const, med_idt           , , fid                     );
    00052   MED_VARGS_DEF(const, char * , const      , fieldname               );
    00053   MED_VARGS_DEF(const, med_int           , , numdt                   );
    00054   MED_VARGS_DEF(const, med_int           , , numit                   );
    00055   MED_VARGS_DEF(const, med_entity_type   , , entitype                );
    00056   MED_VARGS_DEF(const, med_geometry_type , , geotype                 );
    00057   MED_VARGS_DEF(, char *, const      , defaultprofilename            );
    00058   MED_VARGS_DEF(, char *, const      , defaultlocalizationname       );
    00059   MED_VARGS_DEF(, med_int *         ,, fret                          );
    00060
    00061   /*
    00062    * On inhibe le gestionnaire d'erreur HDF 5
    00063    */
    00064   _MEDmodeErreurVerrouiller();
    00065
    00066   NOFINALBLANK(fieldname,ERROR);
    00067
    00068   /*
    00069    * On construit le chemin d'acc�s jusqu'aux groupes <type_ent>[.<type_geo>]
    00070    */
    00071   strcat(_path,fieldname);
    00072   strcat(_path,"/");
    00073   _MEDgetComputationStepName(MED_SORT_DTIT,numdt,numit,&_path[strlen(_path)]);
    00074   strcat(_path,"/");
    00075
    00076   if ((_gid = _MEDdatagroupOuvrir(fid,_path)) < 0) {
    00077     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,MED_ERR_FIELD_MSG);
    00078     SSCRUTE(fieldname);SSCRUTE(_path); goto ERROR;
    00079   }
    00080
    00081
    00082   /*Lit l'attribut MED_NOM_NDT  */
    00083   if ( _MEDattrEntierLire(_gid,MED_NOM_NDT, &_numdt) < 0) {
    00084     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
    00085     SSCRUTE(fieldname);SSCRUTE(_path);SSCRUTE(MED_NOM_NDT);
    00086     ISCRUTE(_numdt);goto ERROR;
    00087   }
    00088
    00089   if ( _numdt != numdt) {
    00090     MED_ERR_(_ret,MED_ERR_NOTEQUAL,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
    00091     SSCRUTE(fieldname);ISCRUTE(_numdt);ISCRUTE(numdt);goto ERROR;
    00092   }
    00093
    00094   /*Lit l'attribut MED_NOM_NOR */
    00095   if ( _MEDattrEntierLire(_gid,MED_NOM_NOR, &_numit) < 0) {
    00096     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
    00097     SSCRUTE(fieldname);SSCRUTE(_path);SSCRUTE(MED_NOM_NOR);
    00098     ISCRUTE(_numit); goto ERROR;
    00099   }
    00100
    00101   if ( _numit != numit) {
    00102     MED_ERR_(_ret,MED_ERR_NOTEQUAL,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
    00103     SSCRUTE(fieldname);ISCRUTE(_numit);ISCRUTE(numit);goto ERROR;
    00104   }
    00105
    00106   /*
    00107    * Si le Data Group  de niveau <type_ent>[.<type_geo>] n'existe pas retroune 0
    00108    */
    00109
    00110   if (_MEDgetEntityTypeName(_datagroupname1,entitype) < 0) {
    00111     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ENTITY,_datagroupname1);
    00112     goto ERROR;
    00113   }
    00114
    00115   if (entitype != MED_NODE) {
    00116     if ( entitype == MED_STRUCT_ELEMENT ) {
    00117       if ( MEDstructElementName(fid,geotype,_geotypename) < 0 ) {
    00118         MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDstructElementName");
    00119         ISCRUTE_int(geotype);goto ERROR;
    00120       }
    00121     } else {
    00122       if (_MEDgetInternalGeometryTypeName(_geotypename,geotype) < 0) {
    00123         MED_ERR_(_ret,MED_ERR_READ,MED_ERR_GEOMETRIC,_geotypename);
    00124         goto ERROR;
    00125       }
    00126     }
    00127     strcat(_datagroupname1,".");
    00128     strcat(_datagroupname1,_geotypename);
    00129   }
    00130 /*   strcat(_path,_datagroupname1); */
    00131 /*   strcat(_path,"/"); */
    00132
    00133
    00134   if ((_datagroup1 = _MEDdatagroupOuvrir(_gid,_datagroupname1)) < 0) {
    00135     *defaultprofilename='\0';
    00136     *defaultlocalizationname='\0';
    00137     _ret = 0;
    00138     goto ERROR;
    00139   }
    00140
    00141   if ((_err=_MEDnObjects(_datagroup1,".",&_n)) <0)
    00142     if ( _err == (MED_ERR_COUNT + MED_ERR_DATAGROUP) ) {
    00143       MED_ERR_(_ret,MED_ERR_COUNT,MED_ERR_DATAGROUP,_datagroupname1);
    00144       goto ERROR;
    00145     }
    00146
    00147   /* Lit le nom du profil associ� s'il en existe d�j� un */
    00148   if ( _MEDattrStringLire(_datagroup1,MED_NOM_PFL,MED_NAME_SIZE,_profilename) < 0 ) {
    00149     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
    00150     SSCRUTE(fieldname);SSCRUTE(_path);SSCRUTE(MED_NOM_PFL);
    00151     goto ERROR;
    00152   }
    00153
    00154   if ( strcmp(_profilename,MED_NO_PROFILE_INTERNAL) ) {
    00155     strncpy(defaultprofilename,_profilename,MED_NAME_SIZE+1);
    00156     defaultprofilename[MED_NAME_SIZE]='\0';
    00157   } else {
    00158     defaultprofilename[0]='\0';
    00159   }
    00160
    00161   /* Lit le nom de la localization associ� s'il en existe d�j� une */
    00162   if ( _MEDattrStringLire(_datagroup1,MED_NOM_GAU,MED_NAME_SIZE,defaultlocalizationname) < 0 ) {
    00163     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
    00164     SSCRUTE(fieldname);SSCRUTE(_path);SSCRUTE(MED_NOM_GAU);
    00165     goto ERROR;
    00166   }
    00167
    00168   _ret = (med_int) _n;
    00169
    00170  ERROR:
    00171
    00172
    00173   if (_datagroup1>0)            if (_MEDdatagroupFermer(_datagroup1) < 0) {
    00174     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_path);
    00175     SSCRUTE(_datagroupname1); ISCRUTE_id(_datagroup1);
    00176   }
    00177
    00178   if (_gid>0)            if (_MEDdatagroupFermer(_gid) < 0) {
    00179     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_path);
    00180     ISCRUTE_id(_gid);
    00181   }
    00182
    00183   va_end(params);
    00184   *fret = _ret;
    00185   return;
    00186 }