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

Généré le Mon May 16 17:10:22 2011 pour MED fichier par  doxygen 1.6.1