_MEDfieldInfoByName30.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_config.h"
00020 #include <med.h>
00021 #include "med_outils.h"
00022 #include <string.h>
00023 
00024 void
00025 _MEDfieldInfoByName30(int dummy, ...) {
00026 
00027 
00028   med_err  _ret=-1,_err=-1;
00029   med_idt  _fieldgid=0,_meshgid=0,_linkgid=0;
00030   char     _fieldpath[MED_TAILLE_CHA+MED_NAME_SIZE+1]=MED_CHA;
00031   char     _meshpath [MED_TAILLE_MAA+MED_NAME_SIZE+1]=MED_MAA;
00032   char     _linkpath [MED_TAILLE_LIENS+MED_NAME_SIZE+1]=MED_LIENS;
00033   med_size _nbofcstp=0;
00034   med_int  _n=0;
00035   med_int  _intfieldtype=0;
00036 
00037 
00038   MED_VARGS_DECL(const, med_idt           , , fid           );
00039   MED_VARGS_DECL(const, char * , const     , fieldname     );
00040   MED_VARGS_DECL(, char *, const           , meshname      );
00041   MED_VARGS_DECL(, med_bool *, const       , localmesh     );
00042   MED_VARGS_DECL(, med_field_type *, const , fieldtype     );
00043   MED_VARGS_DECL(, char *, const           , componentname );
00044   MED_VARGS_DECL(, char *, const           , componentunit );
00045   MED_VARGS_DECL(, char *, const           , dtunit        );
00046   MED_VARGS_DECL(, med_int *, const        , nbofcstp      );
00047   MED_VARGS_DECL(, med_err *              ,, fret          );
00048 
00049   va_list params;
00050   va_start(params,dummy);
00051 
00052   MED_VARGS_DEF(const, med_idt           , , fid           );
00053   MED_VARGS_DEF(const, char * , const     , fieldname     );
00054   MED_VARGS_DEF(, char *, const           , meshname      );
00055   MED_VARGS_DEF(, med_bool *, const       , localmesh     );
00056   MED_VARGS_DEF(, med_field_type *, const , fieldtype     );
00057   MED_VARGS_DEF(, char *, const           , componentname );
00058   MED_VARGS_DEF(, char *, const           , componentunit );
00059   MED_VARGS_DEF(, char *, const           , dtunit        );
00060   MED_VARGS_DEF(, med_int *, const        , nbofcstp      );
00061   MED_VARGS_DEF(, med_err *              ,, fret          );
00062 
00063   /*
00064    * On inhibe le gestionnaire d'erreur HDF 5
00065    */
00066   _MEDmodeErreurVerrouiller();
00067 
00068   strcat(_fieldpath,fieldname);
00069 
00070   /*
00071    * On recupere le nombre de composants
00072    */
00073   if ((_fieldgid = _MEDdatagroupOuvrir(fid,_fieldpath)) < 0) {
00074     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,_fieldpath);
00075     goto ERROR;
00076   }
00077 
00078   if ( _MEDattrEntierLire(_fieldgid,MED_NOM_NCO,&_n) < 0) {
00079     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_NOM_NCO);
00080     SSCRUTE(_fieldpath);goto ERROR;
00081   }
00082 
00083   /*
00084    * La liste des attributs
00085    */
00086 
00087   /* Lecture de l'attribut MED_NOM_TYP */
00088   if ( _MEDattrEntierLire(_fieldgid,MED_NOM_TYP,&_intfieldtype) < 0) {
00089     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00090     SSCRUTE(fieldname);SSCRUTE(MED_NOM_TYP);
00091     goto ERROR;
00092   }
00093   *fieldtype = (med_field_type) (_intfieldtype);
00094 
00095 
00096   /*
00097    * Les infos sur les composantes du champ
00098    */
00099   if (_MEDattrStringLire(_fieldgid,MED_NOM_NOM,_n*MED_SNAME_SIZE,
00100                          componentname) < 0) {
00101     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00102     SSCRUTE(fieldname);SSCRUTE(_fieldpath);SSCRUTE(MED_NOM_NOM);
00103     SSCRUTE(componentname);goto ERROR;
00104   }
00105 
00106   if (_MEDattrStringLire(_fieldgid,MED_NOM_UNI,_n*MED_SNAME_SIZE,
00107                          componentunit) < 0) {
00108     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00109     SSCRUTE(fieldname);SSCRUTE(_fieldpath);SSCRUTE(MED_NOM_UNI);
00110     SSCRUTE(componentunit);goto ERROR;
00111   }
00112   /*MODEL : MED_NOM_UNI vient du niveau en dessous
00113     Cree ou ouvre l'attribut  MED_NOM_UNI pour écriture
00114   */
00115   if ( _MEDattrStringLire(_fieldgid,MED_NOM_UNT,MED_SNAME_SIZE,dtunit) < 0) {
00116    MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00117     SSCRUTE(fieldname);SSCRUTE(_fieldpath);SSCRUTE(MED_NOM_UNT);
00118     SSCRUTE(dtunit);goto ERROR;
00119   }
00120 
00121   /* Lecture de l'attribut MED_NOM_MAI */
00122   if ( _MEDattrStringLire(_fieldgid,MED_NOM_MAI,MED_NAME_SIZE,meshname) < 0) {
00123     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00124     SSCRUTE(fieldname);SSCRUTE(MED_NOM_MAI);SSCRUTE(meshname);
00125     goto ERROR;
00126   }
00127 
00128  /* Maillage local ou distant */
00129   strcat(_meshpath,meshname);
00130 
00131   /* Le maillage est il distant */
00132   if ( (_meshgid = _MEDdatagroupOuvrir(fid,_meshpath)) < 0)  {
00133 
00134     /* Verifie que le maillage est bien référencé comme distant */
00135     strcat(_linkpath,meshname);
00136     if ((_linkgid = _MEDdatagroupOuvrir(fid,_linkpath)) < 0) {
00137 /*       MED_ERR_(_ret,MED_ERR_DOESNTEXIST,MED_ERR_MESH,MED_ERR_FIELD_MSG); */
00138 /*       SSCRUTE(fieldname);SSCRUTE(_meshpath);SSCRUTE(_linkpath); */
00139 /*       goto ERROR; */
00140       *localmesh = MED_FALSE;
00141     }
00142     *localmesh = MED_FALSE;
00143   } else
00144     *localmesh = MED_TRUE;
00145 
00146   /* Nombre d'étapes de calcul*/
00147   if ( (_err=_MEDnObjects(_fieldgid,".",&_nbofcstp)) <0)
00148     if ( _err == (MED_ERR_COUNT + MED_ERR_DATAGROUP) ) {
00149       MED_ERR_(_ret,MED_ERR_COUNT,MED_ERR_DATAGROUP,_fieldpath);
00150       goto ERROR;
00151     }
00152 
00153   *nbofcstp = (med_int) _nbofcstp;
00154 
00155   _ret = 0;
00156 
00157  ERROR:
00158 
00159 
00160   if (_fieldgid>0)            if (_MEDdatagroupFermer(_fieldgid) < 0) {
00161     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_fieldpath);
00162     ISCRUTE_id(_fieldgid);
00163   }
00164 
00165   if (_meshgid>0)            if (_MEDdatagroupFermer(_meshgid) < 0) {
00166     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_meshpath);
00167     ISCRUTE_id(_meshgid);
00168   }
00169 
00170   if (_linkgid>0)            if (_MEDdatagroupFermer(_linkgid) < 0) {
00171     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_linkpath);
00172     ISCRUTE_id(_linkgid);
00173   }
00174 
00175   va_end(params);
00176   *fret = _ret;
00177   return;
00178 }

Généré le Mon Nov 7 16:21:23 2011 pour MED fichier par  doxygen 1.6.1