00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <med.h>
00020 #include <med_config.h>
00021 #include <med_outils.h>
00022 #include <string.h>
00023
00024 void
00025 _MEDfield23nProfile30(int dummy, ...) {
00026
00027 va_list params;
00028 va_start(params,dummy);
00029
00030
00031 const med_idt fid = va_arg(params, const med_idt );
00032 const char * const fieldname = va_arg(params, const char * const );
00033 const med_int numdt = va_arg(params, const med_int );
00034 const med_int numit = va_arg(params, const med_int );
00035 const med_entity_type entitype = va_arg(params, const med_entity_type );
00036 const med_geometry_type geotype = va_arg(params, const med_geometry_type );
00037 const int meshit = va_arg(params, const int );
00038 char * const meshname = va_arg(params, char * const );
00039 char * const defaultprofilename = va_arg(params, char * const );
00040 char * const defaultlocalizationname = va_arg(params, char * const );
00041 med_int * fret = va_arg(params, med_int * );
00042
00043 med_int _ret=-1,_err=-1;
00044 med_idt _gid=0,_datagroup1=0;
00045 char _path[(MED_TAILLE_CHA+MED_NAME_SIZE+1)+(2*MED_MAX_PARA+1)+1]=MED_CHA;
00046 char _datagroupname1[2*MED_TAILLE_NOM_ENTITE+2]="";
00047 char _geotypename [MED_TAILLE_NOM_ENTITE+1]="";
00048 char _profilename [MED_NAME_SIZE+1]="";
00049 med_int _numdt=0, _numit=0;
00050 med_size _n=0;
00051
00052
00053
00054
00055 _MEDmodeErreurVerrouiller();
00056
00057 NOFINALBLANK(fieldname,ERROR);
00058
00059 if (meshit != 1 ) {
00060 MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_PARAMETER,"meshit");
00061 ISCRUTE_int(meshit);
00062 goto ERROR;
00063 }
00064
00065
00066
00067
00068 strcat(_path,fieldname);
00069
00070
00071 if ( _MEDattributeStringRdByName(fid,_path,MED_NOM_MAI,MED_NAME_SIZE,meshname) < 0) {
00072 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00073 SSCRUTE(_path);SSCRUTE(MED_NOM_MAI);SSCRUTE(meshname);
00074 goto ERROR;
00075 }
00076
00077 strcat(_path,"/");
00078 _MEDgetComputationStepName(MED_SORT_DTIT,numdt,numit,&_path[strlen(_path)]);
00079 strcat(_path,"/");
00080
00081 if ((_gid = _MEDdatagroupOuvrir(fid,_path)) < 0) {
00082 MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,MED_ERR_FIELD_MSG);
00083 SSCRUTE(fieldname);SSCRUTE(_path); goto ERROR;
00084 }
00085
00086
00087
00088 if ( _MEDattrEntierLire(_gid,MED_NOM_NDT, &_numdt) < 0) {
00089 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00090 SSCRUTE(fieldname);SSCRUTE(_path);SSCRUTE(MED_NOM_NDT);
00091 ISCRUTE(_numdt);goto ERROR;
00092 }
00093
00094 if ( _numdt != numdt) {
00095 MED_ERR_(_ret,MED_ERR_NOTEQUAL,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00096 SSCRUTE(fieldname);ISCRUTE(_numdt);ISCRUTE(numdt);goto ERROR;
00097 }
00098
00099
00100 if ( _MEDattrEntierLire(_gid,MED_NOM_NOR, &_numit) < 0) {
00101 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00102 SSCRUTE(fieldname);SSCRUTE(_path);SSCRUTE(MED_NOM_NOR);
00103 ISCRUTE(_numit); goto ERROR;
00104 }
00105
00106 if ( _numit != numit) {
00107 MED_ERR_(_ret,MED_ERR_NOTEQUAL,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00108 SSCRUTE(fieldname);ISCRUTE(_numit);ISCRUTE(numit);goto ERROR;
00109 }
00110
00111
00112
00113
00114
00115 if (_MEDgetEntityTypeName(_datagroupname1,entitype) < 0) {
00116 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ENTITY,_datagroupname1);
00117 goto ERROR;
00118 }
00119
00120 if (entitype != MED_NODE) {
00121 if ( entitype == MED_STRUCT_ELEMENT ) {
00122 if ( MEDstructElementName(fid,geotype,_geotypename) < 0 ) {
00123 MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDstructElementName");
00124 ISCRUTE_int(geotype);goto ERROR;
00125 }
00126 } else {
00127 if (_MEDgetGeometryTypeName(_geotypename,geotype) < 0) {
00128 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_GEOMETRIC,_geotypename);
00129 goto ERROR;
00130 }
00131 }
00132 strcat(_datagroupname1,".");
00133 strcat(_datagroupname1,_geotypename);
00134 }
00135
00136
00137
00138
00139 if ((_datagroup1 = _MEDdatagroupOuvrir(_gid,_datagroupname1)) < 0) {
00140 *defaultprofilename='\0';
00141 *defaultlocalizationname='\0';
00142 _ret = 0;
00143 goto ERROR;
00144 }
00145
00146 if ((_err=_MEDnObjects(_datagroup1,".",&_n)) <0)
00147 if ( _err == (MED_ERR_COUNT + MED_ERR_DATAGROUP) ) {
00148 MED_ERR_(_ret,MED_ERR_COUNT,MED_ERR_DATAGROUP,_datagroupname1);
00149 goto ERROR;
00150 }
00151
00152
00153 if ( _MEDattrStringLire(_datagroup1,MED_NOM_PFL,MED_NAME_SIZE,_profilename) < 0 ) {
00154 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00155 SSCRUTE(fieldname);SSCRUTE(_path);SSCRUTE(MED_NOM_PFL);
00156 goto ERROR;
00157 }
00158
00159 if ( strcmp(_profilename,MED_NO_PROFILE_INTERNAL) ) {
00160 strncpy(defaultprofilename,_profilename,MED_NAME_SIZE+1);
00161 defaultprofilename[MED_NAME_SIZE]='\0';
00162 } else {
00163 defaultprofilename[0]='\0';
00164 }
00165
00166
00167 if ( _MEDattrStringLire(_datagroup1,MED_NOM_GAU,MED_NAME_SIZE,defaultlocalizationname) < 0 ) {
00168 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00169 SSCRUTE(fieldname);SSCRUTE(_path);SSCRUTE(MED_NOM_GAU);
00170 goto ERROR;
00171 }
00172
00173 _ret = (med_int) _n;
00174
00175 ERROR:
00176
00177
00178 if (_datagroup1>0) if (_MEDdatagroupFermer(_datagroup1) < 0) {
00179 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_path);
00180 SSCRUTE(_datagroupname1); ISCRUTE_id(_datagroup1);
00181 }
00182
00183 if (_gid>0) if (_MEDdatagroupFermer(_gid) < 0) {
00184 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_path);
00185 ISCRUTE_id(_gid);
00186 }
00187
00188 va_end(params);
00189 *fret = _ret;
00190 return;
00191 }