00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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
00034
00035
00036 med_size _nstep=0;
00037 med_int _intmeshtype=0;
00038 med_int _intaxistype=0;
00039 med_int _intsortingtype=0;
00040
00041
00042
00043
00044 _MEDmodeErreurVerrouiller();
00045
00046
00047
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
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
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
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
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
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
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
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
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
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
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 }