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 #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 va_list params;
00032 va_start(params,dummy);
00033
00034 const med_idt fid = va_arg(params, const med_idt );
00035 const char * const fieldname = va_arg(params, const char * const );
00036 char * const meshname = va_arg(params, char * const );
00037 med_bool * const localmesh = va_arg(params, med_bool * const );
00038 med_field_type * const fieldtype = va_arg(params, med_field_type * const );
00039 char * const componentname = va_arg(params, char * const );
00040 char * const componentunit = va_arg(params, char * const );
00041 char * const dtunit = va_arg(params, char * const );
00042 med_int * const nbofcstp = va_arg(params, med_int * const );
00043 med_err * fret = va_arg(params, med_err* );
00044
00045 med_err _ret=-1,_err=-1;
00046 med_idt _fieldgid=0,_meshgid=0,_linkgid=0;
00047 char _fieldpath[MED_TAILLE_CHA+MED_TAILLE_NOM+1]=MED_CHA;
00048 char _meshpath [MED_TAILLE_MAA+MED_TAILLE_NOM+1]=MED_MAA;
00049 char _linkpath [MED_TAILLE_LIENS+MED_TAILLE_NOM+1]=MED_LIENS;
00050 med_size _nbofcstp=0;
00051 med_int _n=0;
00052 med_int _intfieldtype=0;
00053 char _meshrefpath236[(2*MED_TAILLE_NOM_ENTITE+1)+1+ (2*MED_MAX_PARA)+1]="";
00054
00055
00056
00057
00058 _MEDmodeErreurVerrouiller();
00059
00060 strcat(_fieldpath,fieldname);
00061
00062 if ((_fieldgid = _MEDdatagroupOuvrir(fid,_fieldpath)) < 0) {
00063 MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,_fieldpath);
00064 goto ERROR;
00065 }
00066
00067
00068 if ( _MEDattrEntierLire(_fieldgid,MED_NOM_NCO,&_n) < 0) {
00069 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_NOM_NCO);
00070 SSCRUTE(_fieldpath);goto ERROR;
00071 }
00072
00073
00074 if ( _MEDattrEntierLire(_fieldgid,MED_NOM_TYP,&_intfieldtype) < 0) {
00075 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00076 SSCRUTE(fieldname);SSCRUTE(MED_NOM_TYP);
00077 goto ERROR;
00078 }
00079 *fieldtype = (med_field_type) (_intfieldtype);
00080
00081
00082
00083
00084
00085 if (_MEDattrStringLire(_fieldgid,MED_NOM_NOM,_n*MED_TAILLE_PNOM,
00086 componentname) < 0) {
00087 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00088 SSCRUTE(fieldname);SSCRUTE(_fieldpath);SSCRUTE(MED_NOM_NOM);
00089 SSCRUTE(componentname);goto ERROR;
00090 }
00091
00092 if (_MEDattrStringLire(_fieldgid,MED_NOM_UNI,_n*MED_TAILLE_PNOM,
00093 componentunit) < 0) {
00094 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00095 SSCRUTE(fieldname);SSCRUTE(_fieldpath);SSCRUTE(MED_NOM_UNI);
00096 SSCRUTE(componentunit);goto ERROR;
00097 }
00098
00099
00100
00101
00102
00103 if ( _MEDobjectGetName(_fieldgid, "." , 0, _meshrefpath236) < 0 ) {
00104 MED_ERR_(_ret,MED_ERR_ACCESS,MED_ERR_DATAGROUP,".");
00105 SSCRUTE(_meshrefpath236); goto ERROR;
00106 }
00107
00108
00109
00110
00111
00112
00113 if ( (_err=_MEDnObjects(_fieldgid,_meshrefpath236,&_nbofcstp)) <0)
00114 if ( _err == (MED_ERR_COUNT + MED_ERR_DATAGROUP) ) {
00115 MED_ERR_(_ret,MED_ERR_COUNT,MED_ERR_DATAGROUP,_fieldpath);
00116 goto ERROR;
00117 }
00118 *nbofcstp = (med_int) _nbofcstp;
00119
00120
00121
00122
00123
00124
00125 strcat(_meshrefpath236,"/");
00126 if ( _MEDobjectGetName(_fieldgid, _meshrefpath236 , 0, &_meshrefpath236[strlen(_meshrefpath236)]) < 0 ) {
00127 MED_ERR_(_ret,MED_ERR_ACCESS,MED_ERR_DATAGROUP,_meshrefpath236);
00128 goto ERROR;
00129 }
00130
00131
00132
00133 if ( _MEDattributeStringRdByName(_fieldgid,_meshrefpath236,MED_NOM_UNI,MED_TAILLE_PNOM,dtunit) < 0) {
00134 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00135 SSCRUTE(fieldname);SSCRUTE(_meshrefpath236);SSCRUTE(MED_NOM_UNI);
00136 SSCRUTE(dtunit);goto ERROR;
00137 }
00138
00139
00140 if ( _MEDattributeStringRdByName(_fieldgid,_meshrefpath236,MED_NOM_MAI,MED_NAME_SIZE,meshname) < 0) {
00141 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00142 SSCRUTE(fieldname);SSCRUTE(_meshrefpath236);SSCRUTE(MED_NOM_MAI);SSCRUTE(meshname);
00143 goto ERROR;
00144 }
00145
00146
00147 strcat(_meshpath,meshname);
00148
00149
00150 if ( (_meshgid = _MEDdatagroupOuvrir(fid,_meshpath)) < 0) {
00151
00152
00153 strcat(_linkpath,meshname);
00154 if ((_linkgid = _MEDdatagroupOuvrir(fid,_linkpath)) < 0) {
00155
00156
00157
00158 *localmesh = MED_FALSE;
00159 }
00160 *localmesh = MED_FALSE;
00161 } else
00162 *localmesh = MED_TRUE;
00163
00164
00165 _ret = 0;
00166
00167 ERROR:
00168
00169
00170 if (_fieldgid>0) if (_MEDdatagroupFermer(_fieldgid) < 0) {
00171 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_fieldpath);
00172 ISCRUTE_id(_fieldgid);
00173 }
00174
00175 if (_meshgid>0) if (_MEDdatagroupFermer(_meshgid) < 0) {
00176 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_meshpath);
00177 ISCRUTE_id(_meshgid);
00178 }
00179
00180 if (_linkgid>0) if (_MEDdatagroupFermer(_linkgid) < 0) {
00181 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_linkpath);
00182 ISCRUTE_id(_linkgid);
00183 }
00184
00185 va_end(params);
00186 *fret = _ret;
00187 return;
00188 }