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