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 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
00052
00053 _MEDmodeErreurVerrouiller();
00054
00055 strcat(_fieldpath,fieldname);
00056
00057
00058
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
00072
00073
00074
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
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
00100
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
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
00116 strcat(_meshpath,meshname);
00117
00118
00119 if ( (_meshgid = _MEDdatagroupOuvrir(fid,_meshpath)) < 0) {
00120
00121
00122 strcat(_linkpath,meshname);
00123 if ((_linkgid = _MEDdatagroupOuvrir(fid,_linkpath)) < 0) {
00124
00125
00126
00127 *localmesh = MED_FALSE;
00128 }
00129 *localmesh = MED_FALSE;
00130 } else
00131 *localmesh = MED_TRUE;
00132
00133
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 }