_MEDmeshInfoByName.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 med_err
00025 _MEDmeshInfoByName(const med_idt fid, const char * const root,const char * const meshname,
00026                    med_int *const spacedim, med_int * const meshdim,  med_mesh_type * const meshtype,
00027                    char * const description,  char * const dtunit,med_sorting_type * const sortingtype,
00028                    med_int * const nstep,  med_axis_type * const axistype,  char * const axisname,
00029                    char * const axisunit)
00030 {
00031   med_err  _ret=-1,_err=-1;
00032   med_idt  _root=0,_meshid=0;
00033 /*   char     _meshpath[MED_TAILLE_CHA+MED_TAILLE_NOM+1]=MED_CHA; */
00034 /*   char     _meshpath [MED_TAILLE_MAA+MED_TAILLE_NOM+1]=MED_MAA; */
00035 /*   char     _linkpath [MED_TAILLE_LIENS+MED_TAILLE_NOM+1]=MED_LIENS; */
00036   med_size _nstep=0;
00037   med_int  _intmeshtype=0;
00038   med_int  _intaxistype=0;
00039   med_int  _intsortingtype=0;
00040 
00041   /*
00042    * On inhibe le gestionnaire d'erreur HDF 5
00043    */
00044   _MEDmodeErreurVerrouiller();
00045 
00046   /*
00047    * Si le DataGroup root n'existe pas => erreur
00048    */
00049   if ((_root = _MEDdatagroupOuvrir(fid,root)) < 0) {
00050     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,root);
00051     ISCRUTE_id(_root);goto ERROR;
00052   }
00053 
00054 
00055   if ((_meshid = _MEDdatagroupOuvrir(_root,meshname)) < 0) {
00056     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,meshname);
00057     SSCRUTE(root);goto ERROR;
00058   }
00059 
00060   /* Lecture de l'attribut MED_NOM_ESP */
00061   if ( _MEDattrEntierLire(_meshid,MED_NOM_ESP,spacedim) < 0) {
00062     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_NOM_ESP);
00063     SSCRUTE(root);SSCRUTE(meshname);goto ERROR;
00064   }
00065 
00066   /* Lecture de l'attribut MED_NOM_DIM */
00067   if ( _MEDattrEntierLire(_meshid,MED_NOM_DIM,meshdim) < 0) {
00068     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_NOM_DIM);
00069     SSCRUTE(root);SSCRUTE(meshname);goto ERROR;
00070   }
00071 
00072   /* Lecture de l'attribut MED_NOM_TYP */
00073   if ( _MEDattrEntierLire(_meshid,MED_NOM_TYP,&_intmeshtype) < 0) {
00074     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG);
00075     SSCRUTE(meshname);SSCRUTE(MED_NOM_TYP); goto ERROR;
00076   }
00077   *meshtype = (med_mesh_type) (_intmeshtype);
00078 
00079 
00080    /* Lecture de l'attribut MED_NOM_DES */
00081   if (_MEDattrStringLire(_meshid,MED_NOM_DES,MED_COMMENT_SIZE, description) < 0) {
00082     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG);
00083     SSCRUTE(root);SSCRUTE(meshname);SSCRUTE(MED_NOM_DES);SSCRUTE(description);goto ERROR;
00084   }
00085 
00086    /* Lecture de l'attribut MED_NOM_UNT */
00087   if (_MEDattrStringLire(_meshid,MED_NOM_UNT,MED_SNAME_SIZE, dtunit) < 0) {
00088     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG);
00089     SSCRUTE(root);SSCRUTE(meshname);SSCRUTE(MED_NOM_UNT);
00090     SSCRUTE(dtunit);goto ERROR;
00091   }
00092 
00093   /* Lecture de l'attribut MED_NOM_SRT */
00094   if ( _MEDattrEntierLire(_meshid,MED_NOM_SRT,&_intsortingtype) < 0) {
00095     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG);
00096     SSCRUTE(root);SSCRUTE(meshname);SSCRUTE(MED_NOM_SRT);
00097     ISCRUTE(_intsortingtype);goto ERROR;
00098   }
00099   *sortingtype = (med_sorting_type) (_intsortingtype);
00100 
00101   /* Lecture de l'attribut MED_NOM_REP */
00102   if ( _MEDattrEntierLire(_meshid,MED_NOM_REP,&_intaxistype) < 0) {
00103     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG);
00104     SSCRUTE(root);SSCRUTE(meshname);SSCRUTE(MED_NOM_REP);
00105     ISCRUTE(_intaxistype);goto ERROR;
00106   }
00107   *axistype = (med_mesh_type) (_intaxistype);
00108 
00109 
00110   /* Lecture de l'attribut MED_NOM_NOM */
00111   if (_MEDattrStringLire(_meshid,MED_NOM_NOM,*spacedim*MED_SNAME_SIZE, axisname) < 0) {
00112     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG);
00113     SSCRUTE(root);SSCRUTE(meshname);SSCRUTE(MED_NOM_NOM);
00114     SSCRUTE(axisname);goto ERROR;
00115   }
00116 
00117   /* Lecture de l'attribut MED_NOM_UNI */
00118   if (_MEDattrStringLire(_meshid,MED_NOM_UNI,*spacedim*MED_SNAME_SIZE, axisunit) < 0) {
00119     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG);
00120     SSCRUTE(root);SSCRUTE(meshname);SSCRUTE(MED_NOM_UNI);
00121     SSCRUTE(axisunit);goto ERROR;
00122   }
00123 
00124   /* Nombre d'étapes de calcul*/
00125   if ((_err=_MEDnObjects(_meshid,".",&_nstep)) <0) 
00126     if ( _err == (MED_ERR_COUNT + MED_ERR_DATAGROUP) ) {
00127       MED_ERR_(_ret,MED_ERR_COUNT,MED_ERR_DATAGROUP,meshname);
00128       goto ERROR;
00129     }
00130 
00131   *nstep = (med_int) _nstep;
00132 
00133   _ret = 0;
00134 
00135  ERROR:
00136 
00137 
00138   if (_meshid>0)            if (_MEDdatagroupFermer(_meshid) < 0) {
00139     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,meshname);
00140     ISCRUTE_id(_meshid);
00141   }
00142 
00143   if (_root>0)            if (_MEDdatagroupFermer(_root) < 0) {
00144     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,root);
00145     ISCRUTE_id(_root);
00146   }
00147 
00148   return _ret;
00149 }

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