_MEDfieldInfoByName236.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 #include <2.3.6/med23v30.h>
00025 #include <2.3.6/med23v30_proto.h>
00026 #include "2.3.6/med23v30_misc.h"
00027 
00028 void
00029 _MEDfieldInfoByName236(int dummy, ...) {
00030 
00031 
00032   med_err  _ret=-1,_err=-1;
00033   med_idt  _fieldgid=0,_meshgid=0,_linkgid=0;
00034   char     _fieldpath[MED_TAILLE_CHA+MED_TAILLE_NOM+1]=MED_CHA;
00035   char     _meshpath [MED_TAILLE_MAA+MED_TAILLE_NOM+1]=MED_MAA;
00036   char     _linkpath [MED_TAILLE_LIENS+MED_TAILLE_NOM+1]=MED_LIENS;
00037   med_size _nbofcstp=0;
00038   med_int  _n=0;
00039   med_int  _intfieldtype=0;
00040   char     _meshrefpath236[(2*MED_TAILLE_NOM_ENTITE+1)+1+ (2*MED_MAX_PARA)+1]="";
00041 
00042 
00043   MED_VARGS_DECL(const, med_idt          , , fid           );
00044   MED_VARGS_DECL(const, char * , const     , fieldname     );
00045   MED_VARGS_DECL(, char *, const           , meshname      );
00046   MED_VARGS_DECL(, med_bool *, const       , localmesh     );
00047   MED_VARGS_DECL(, med_field_type *, const , fieldtype     );
00048   MED_VARGS_DECL(, char *, const           , componentname );
00049   MED_VARGS_DECL(, char *, const           , componentunit );
00050   MED_VARGS_DECL(, char *, const           , dtunit        );
00051   MED_VARGS_DECL(, med_int *, const        , nbofcstp      );
00052   MED_VARGS_DECL(, med_err *              ,, fret          );
00053 
00054   va_list params;
00055   va_start(params,dummy);
00056 
00057   MED_VARGS_DEF(const, med_idt          , , fid           );
00058   MED_VARGS_DEF(const, char * , const     , fieldname     );
00059   MED_VARGS_DEF(, char *, const           , meshname      );
00060   MED_VARGS_DEF(, med_bool *, const       , localmesh     );
00061   MED_VARGS_DEF(, med_field_type *, const , fieldtype     );
00062   MED_VARGS_DEF(, char *, const           , componentname );
00063   MED_VARGS_DEF(, char *, const           , componentunit );
00064   MED_VARGS_DEF(, char *, const           , dtunit        );
00065   MED_VARGS_DEF(, med_int *, const        , nbofcstp      );
00066   MED_VARGS_DEF(, med_err *              ,, fret          );
00067 
00068   /*
00069    * On inhibe le gestionnaire d'erreur HDF 5
00070    */
00071   _MEDmodeErreurVerrouiller();
00072 
00073   strcat(_fieldpath,fieldname);
00074 
00075   if ((_fieldgid = _MEDdatagroupOuvrir(fid,_fieldpath)) < 0) {
00076     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,_fieldpath);
00077     goto ERROR;
00078   }
00079 
00080   /* Lecture de l'attribut MED_NOM_NCO */
00081   if ( _MEDattrEntierLire(_fieldgid,MED_NOM_NCO,&_n) < 0) {
00082     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_NOM_NCO);
00083     SSCRUTE(_fieldpath);goto ERROR;
00084   }
00085 
00086   /* Lecture de l'attribut MED_NOM_TYP */
00087   if ( _MEDattrEntierLire(_fieldgid,MED_NOM_TYP,&_intfieldtype) < 0) {
00088     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00089     SSCRUTE(fieldname);SSCRUTE(MED_NOM_TYP);
00090     goto ERROR;
00091   }
00092   *fieldtype = (med_field_type) (_intfieldtype);
00093 
00094 
00095   /*
00096    * Les infos sur les composantes du champ
00097    */
00098   if (_MEDattrStringLire(_fieldgid,MED_NOM_NOM,_n*MED_TAILLE_PNOM,
00099                          componentname) < 0) {
00100     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00101     SSCRUTE(fieldname);SSCRUTE(_fieldpath);SSCRUTE(MED_NOM_NOM);
00102     SSCRUTE(componentname);goto ERROR;
00103   }
00104 
00105   if (_MEDattrStringLire(_fieldgid,MED_NOM_UNI,_n*MED_TAILLE_PNOM,
00106                          componentunit) < 0) {
00107     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00108     SSCRUTE(fieldname);SSCRUTE(_fieldpath);SSCRUTE(MED_NOM_UNI);
00109     SSCRUTE(componentunit);goto ERROR;
00110   }
00111 
00112 
00113   /*
00114    * On recupere le nom du premier couple (entitytype,geotype)
00115    */
00116   if ( _MEDobjectGetName(_fieldgid, "." , 0, _meshrefpath236) < 0 ) {
00117     MED_ERR_(_ret,MED_ERR_ACCESS,MED_ERR_DATAGROUP,".");
00118     SSCRUTE(_meshrefpath236); goto ERROR;
00119   }
00120 
00121   /* Nombre d'étapes de calcul
00122    * La gestion d'une incohérence sur le nombre de séquences de calcul par couple (entitytype,geotype)
00123    * se fait à partir des appels :
00124    *  MEDfieldnProfile,MEDfieldnValue,MEDfieldnValueWithProfile
00125    */
00126   if ( (_err=_MEDnObjects(_fieldgid,_meshrefpath236,&_nbofcstp)) <0)
00127     if ( _err == (MED_ERR_COUNT + MED_ERR_DATAGROUP) ) {
00128       MED_ERR_(_ret,MED_ERR_COUNT,MED_ERR_DATAGROUP,_fieldpath);
00129       goto ERROR;
00130     }
00131   *nbofcstp = (med_int) _nbofcstp;
00132 
00133   /*
00134    * On recupere le nom de maillage par défaut du premier couple (entitytype,geotype)
00135    * La gestion des erreurs multimaillage 2.3.6 se fait à partir des appels :
00136    * MEDfieldnProfile,MEDfieldnValue,MEDfieldnValueWithProfile
00137    */
00138   strcat(_meshrefpath236,"/");
00139   if ( _MEDobjectGetName(_fieldgid, _meshrefpath236 , 0, &_meshrefpath236[strlen(_meshrefpath236)]) < 0 ) {
00140     MED_ERR_(_ret,MED_ERR_ACCESS,MED_ERR_DATAGROUP,_meshrefpath236);
00141     goto ERROR;
00142   }
00143 
00144 
00145   /* Lecture de l'attribut MED_NOM_UNI */
00146   if ( _MEDattributeStringRdByName(_fieldgid,_meshrefpath236,MED_NOM_UNI,MED_TAILLE_PNOM,dtunit) < 0) {
00147     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00148     SSCRUTE(fieldname);SSCRUTE(_meshrefpath236);SSCRUTE(MED_NOM_UNI);
00149     SSCRUTE(dtunit);goto ERROR;
00150   }
00151 
00152   /* Lecture de l'attribut MED_NOM_MAI */
00153   if ( _MEDattributeStringRdByName(_fieldgid,_meshrefpath236,MED_NOM_MAI,MED_NAME_SIZE,meshname) < 0) {
00154     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00155     SSCRUTE(fieldname);SSCRUTE(_meshrefpath236);SSCRUTE(MED_NOM_MAI);SSCRUTE(meshname);
00156     goto ERROR;
00157   }
00158 
00159  /* Maillage local ou distant */
00160   strcat(_meshpath,meshname);
00161 
00162   /* Le maillage est il distant */
00163   if ( (_meshgid = _MEDdatagroupOuvrir(fid,_meshpath)) < 0)  {
00164 
00165     /* Verifie que le maillage est bien référencé comme distant */
00166     strcat(_linkpath,meshname);
00167     if ((_linkgid = _MEDdatagroupOuvrir(fid,_linkpath)) < 0) {
00168 /*       MED_ERR_(_ret,MED_ERR_DOESNTEXIST,MED_ERR_MESH,MED_ERR_FIELD_MSG); */
00169 /*       SSCRUTE(fieldname);SSCRUTE(_meshpath);SSCRUTE(_linkpath); */
00170 /*       goto ERROR; */
00171       *localmesh = MED_FALSE;
00172     }
00173     *localmesh = MED_FALSE;
00174   } else
00175     *localmesh = MED_TRUE;
00176 
00177 
00178   _ret = 0;
00179 
00180  ERROR:
00181 
00182 
00183   if (_fieldgid>0)            if (_MEDdatagroupFermer(_fieldgid) < 0) {
00184     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_fieldpath);
00185     ISCRUTE_id(_fieldgid);
00186   }
00187 
00188   if (_meshgid>0)            if (_MEDdatagroupFermer(_meshgid) < 0) {
00189     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_meshpath);
00190     ISCRUTE_id(_meshgid);
00191   }
00192 
00193   if (_linkgid>0)            if (_MEDdatagroupFermer(_linkgid) < 0) {
00194     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_linkpath);
00195     ISCRUTE_id(_linkgid);
00196   }
00197 
00198   va_end(params);
00199   *fret = _ret;
00200   return;
00201 }

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