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

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