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 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
00065
00066 _MEDmodeErreurVerrouiller();
00067
00068 strcat(_fieldpath,fieldname);
00069
00070
00071
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
00085
00086
00087
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
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
00113
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
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
00129 strcat(_meshpath,meshname);
00130
00131
00132 if ( (_meshgid = _MEDdatagroupOuvrir(fid,_meshpath)) < 0) {
00133
00134
00135 strcat(_linkpath,meshname);
00136 if ((_linkgid = _MEDdatagroupOuvrir(fid,_linkpath)) < 0) {
00137
00138
00139
00140 *localmesh = MED_FALSE;
00141 }
00142 *localmesh = MED_FALSE;
00143 } else
00144 *localmesh = MED_TRUE;
00145
00146
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 }