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 <string.h>
00022 #include <stdlib.h>
00023 #include <med_outils.h>
00024
00025
00026 void
00027 _MEDfieldnValue30(int dummy, ...)
00028 {
00029
00030
00031 med_int _ret=-1;
00032 med_idt _gid=0,_locgid=0,_datagroup1=0,_datagroup2=0;
00033 char _path[(MED_TAILLE_CHA+MED_NAME_SIZE+1)+(2*MED_MAX_PARA+1)+1]=MED_CHA;
00034 char _datagroupname1[2*MED_TAILLE_NOM_ENTITE+2]="";
00035 char _datagroupname2[MED_NAME_SIZE+1]="";
00036 char _tmpprofilename[MED_NAME_SIZE+1]="", *_profilename=0;
00037 char _geotypename [MED_TAILLE_NOM_ENTITE+1]="";
00038 char _locgidname [MED_TAILLE_GAUSS+MED_NAME_SIZE+1]="";
00039 char _sectionmeshname [MED_NAME_SIZE+1]="";
00040 char _sectiongeotypename [MED_NAME_SIZE+1]="";
00041 char _localizationname [MED_NAME_SIZE+1]="";
00042 med_int _nbofconstituentpervalue=0,_nbofvaluesperentityfromloc=0;
00043 med_int _numdt=0, _numit=0;
00044 med_int _profilearraysize=0,_nbofvaluesperentity=0;
00045 med_int _nbofsectiongeotype=0,_nbofsectioncell=1;
00046 med_size _n=0;
00047 med_int _intn=0;
00048 med_geometry_type _locgeotype =0,_sectiongeotype=0;
00049 med_int _intlocgeotype=0;
00050 int _num;
00051 med_bool _anyprofile=MED_FALSE;
00052 med_bool _chgt=MED_FALSE,_trsf=MED_FALSE;
00053
00054
00055 MED_VARGS_DECL(const, med_idt , , fid );
00056 MED_VARGS_DECL(const, char * , const , fieldname );
00057 MED_VARGS_DECL(const, med_int , , numdt );
00058 MED_VARGS_DECL(const, med_int , , numit );
00059 MED_VARGS_DECL(const, med_entity_type , , entitytype );
00060 MED_VARGS_DECL(const, med_geometry_type , , geotype );
00061 MED_VARGS_DECL(, char *, const , profilename );
00062 MED_VARGS_DECL(const, int , , profileit );
00063 MED_VARGS_DECL(const, med_storage_mode , , storagemode );
00064 MED_VARGS_DECL(, med_int *, const , profilesize );
00065 MED_VARGS_DECL(, char *, const , localizationname );
00066 MED_VARGS_DECL(, med_int *, const , nbofintegrationpoint );
00067 MED_VARGS_DECL(, med_int * ,, fret );
00068
00069 va_list params;
00070 va_start(params,dummy);
00071
00072 MED_VARGS_DEF(const, med_idt , , fid );
00073 MED_VARGS_DEF(const, char * , const , fieldname );
00074 MED_VARGS_DEF(const, med_int , , numdt );
00075 MED_VARGS_DEF(const, med_int , , numit );
00076 MED_VARGS_DEF(const, med_entity_type , , entitytype );
00077 MED_VARGS_DEF(const, med_geometry_type , , geotype );
00078 MED_VARGS_DEF(, char *, const , profilename );
00079 MED_VARGS_DEF(const, int , , profileit );
00080 MED_VARGS_DEF(const, med_storage_mode , , storagemode );
00081 MED_VARGS_DEF(, med_int *, const , profilesize );
00082 MED_VARGS_DEF(, char *, const , localizationname );
00083 MED_VARGS_DEF(, med_int *, const , nbofintegrationpoint );
00084 MED_VARGS_DEF(, med_int * ,, fret );
00085
00086 _num = profileit -1;
00087
00088
00089
00090
00091 _MEDmodeErreurVerrouiller();
00092
00093 NOFINALBLANK(fieldname,ERROR);
00094
00095
00096
00097
00098 strcat(_path,fieldname);
00099 strcat(_path,"/");
00100 _MEDgetComputationStepName(MED_SORT_DTIT,numdt,numit,&_path[strlen(_path)]);
00101 strcat(_path,"/");
00102
00103 if ((_gid = _MEDdatagroupOuvrir(fid,_path)) < 0) {
00104 MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,MED_ERR_FIELD_MSG);
00105 SSCRUTE(_path); goto ERROR;
00106 }
00107
00108
00109
00110 if ( _MEDattrEntierLire(_gid,MED_NOM_NDT, &_numdt) < 0) {
00111 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00112 SSCRUTE(_path);SSCRUTE(MED_NOM_NDT);
00113 ISCRUTE(_numdt);goto ERROR;
00114 }
00115
00116 if ( _numdt != numdt ) {
00117 MED_ERR_(_ret,MED_ERR_NOTEQUAL,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00118 SSCRUTE(_path);ISCRUTE(_numdt);ISCRUTE(numdt);goto ERROR;
00119 }
00120
00121
00122 if ( _MEDattrEntierLire(_gid,MED_NOM_NOR, &_numit) < 0) {
00123 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00124 SSCRUTE(fieldname);SSCRUTE(_path);SSCRUTE(MED_NOM_NOR);
00125 ISCRUTE(_numit); goto ERROR;
00126 }
00127
00128 if ( _numit != numit) {
00129 MED_ERR_(_ret,MED_ERR_NOTEQUAL,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00130 SSCRUTE(fieldname);ISCRUTE(_numit);ISCRUTE(numit);goto ERROR;
00131 }
00132
00133
00134
00135
00136
00137 if (_MEDgetEntityTypeName(_datagroupname1,entitytype) < 0) {
00138 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ENTITY,_datagroupname1);
00139 goto ERROR;
00140 }
00141
00142 if (entitytype != MED_NODE) {
00143 if ( entitytype == MED_STRUCT_ELEMENT ) {
00144 if ( MEDstructElementName(fid, geotype,_geotypename) < 0 ) {
00145 MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDstructElementName");
00146 ISCRUTE_int(geotype);goto ERROR;
00147 }
00148 } else {
00149 if (_MEDgetInternalGeometryTypeName(_geotypename,geotype) < 0) {
00150 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_GEOMETRIC,_geotypename);
00151 goto ERROR;
00152 }
00153 }
00154 strcat(_datagroupname1,".");
00155 strcat(_datagroupname1,_geotypename);
00156 }
00157
00158
00159
00160
00161 if ((_datagroup1 = _MEDdatagroupOuvrir(_gid,_datagroupname1)) < 0) {
00162 _n=0;
00163 } else {
00164 if (strlen(profilename) && (profileit >=0)) {
00165 MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_PARAMETER,MED_ERR_FIELD_MSG);
00166 SSCRUTE(fieldname);SSCRUTE(_path);SSCRUTE(_datagroupname1);
00167 SSCRUTE(profilename); ISCRUTE_int(profileit); goto ERROR;
00168 }
00169
00170 if ( profileit <0 ) {
00171
00172 if ( !strlen(profilename)) {
00173 _profilename = MED_NO_PROFILE_INTERNAL;
00174 }
00175 else {
00176 _profilename=profilename;
00177 _anyprofile=MED_TRUE;
00178 }
00179 } else {
00180 _profilename=_tmpprofilename;
00181 if ( _MEDobjectGetName(_datagroup1, "." ,_num, _profilename) < 0 ) {
00182 MED_ERR_(_ret,MED_ERR_ACCESS,MED_ERR_DATAGROUP,_path);
00183 SSCRUTE(_datagroupname1);ISCRUTE_int(profileit);
00184 goto ERROR;
00185 }
00186 if ( strcmp(_profilename,MED_NO_PROFILE_INTERNAL) ) {
00187 strncpy(profilename,_profilename,MED_NAME_SIZE+1);
00188 profilename[MED_NAME_SIZE]='\0';
00189 _anyprofile=MED_TRUE;
00190 } else {
00191 profilename[0]='\0';
00192 }
00193 }
00194
00195 if ((_datagroup2 = _MEDdatagroupOuvrir(_datagroup1,_profilename)) < 0) {
00196 MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,MED_ERR_FIELD_MSG);
00197 SSCRUTE(fieldname);SSCRUTE(_path);SSCRUTE(_datagroupname1); SSCRUTE(_profilename);goto ERROR;
00198 goto ERROR;
00199 }
00200
00201
00202 if ( _MEDattrEntierLire(_datagroup2,MED_NOM_NBR,&_intn) < 0) {
00203 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00204 SSCRUTE(fieldname);SSCRUTE(_path);SSCRUTE(_datagroupname1); SSCRUTE(_profilename);
00205 SSCRUTE(MED_NOM_NBR);ISCRUTE_size(_n);goto ERROR;
00206 }
00207 _n = _intn;
00208
00209 if ( _anyprofile ) {
00210 if ( (_profilearraysize=MEDprofileSizeByName(fid, _profilename)) < 0) {
00211 MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,MED_ERR_FIELD_MSG);
00212 SSCRUTE(fieldname);SSCRUTE(_path);SSCRUTE(_datagroupname1); SSCRUTE(_profilename);
00213 SSCRUTE("MEDprofileSizeByName");goto ERROR;
00214 }
00215 } else {
00216 _profilearraysize = (med_int) _n;
00217 }
00218
00219 *profilesize=_profilearraysize;
00220
00221 switch(storagemode) {
00222
00223 case MED_GLOBAL_PFLMODE :
00224
00225 break;
00226
00227 case MED_COMPACT_PFLMODE :
00228
00229 _n=_profilearraysize;
00230
00231 break;
00232
00233 default :
00234 MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_STORAGEMODE,MED_ERR_VALUE_MSG);
00235 ISCRUTE_int(storagemode);goto ERROR;
00236 break;
00237
00238 }
00239
00240
00241 if ( _MEDattrStringLire(_datagroup2,MED_NOM_GAU,MED_NAME_SIZE,_localizationname) < 0) {
00242 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00243 SSCRUTE(fieldname);SSCRUTE(_path);SSCRUTE(_datagroupname1);SSCRUTE(_profilename);
00244 SSCRUTE(MED_NOM_GAU);SSCRUTE(_localizationname);goto ERROR;
00245 }
00246 strncpy(localizationname,_localizationname,MED_NAME_SIZE+1);
00247 localizationname[MED_NAME_SIZE]='\0';
00248
00249
00250 if ( _MEDattrEntierLire(_datagroup2,MED_NOM_NGA,&_nbofvaluesperentity) < 0) {
00251 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00252 SSCRUTE(fieldname);SSCRUTE(_path);SSCRUTE(_datagroupname1);
00253 SSCRUTE(_profilename); SSCRUTE(MED_NOM_NGA);ISCRUTE(_nbofvaluesperentity);goto ERROR;
00254 }
00255
00256
00257
00258 if (entitytype == MED_NODE_ELEMENT ) {
00259 if ( strlen( _localizationname) ) {
00260 MED_ERR_(_ret,MED_ERR_NOTEQUAL,MED_ERR_PARAMETER,_localizationname);
00261 SSCRUTE(MED_NO_LOCALIZATION);ISCRUTE_int(entitytype);goto ERROR;
00262 }
00263 _nbofvaluesperentityfromloc = geotype % 100;
00264 } else if (! strcmp(_localizationname,MED_GAUSS_ELNO)) {
00265
00266
00267 _nbofvaluesperentityfromloc = geotype % 100;
00268 } else if ( strlen( _localizationname) ) {
00269 strcpy(_locgidname,MED_GAUSS);
00270 strcat(_locgidname,_localizationname);
00271
00272 if ((_locgid = _MEDdatagroupOuvrir(fid,_locgidname)) < 0) {
00273 MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,_locgidname);
00274 goto ERROR;
00275 }
00276
00277 if (_MEDattrEntierLire(_locgid,MED_NOM_NBR,&_nbofvaluesperentityfromloc) < 0) {
00278 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_LOCALIZATION_MSG);
00279 SSCRUTE(_localizationname);SSCRUTE(MED_NOM_NBR);ISCRUTE(_nbofvaluesperentity);goto ERROR;
00280 }
00281
00282 if ( entitytype == MED_STRUCT_ELEMENT ) {
00283
00284
00285
00286
00287 if ( _MEDattrStringLire(_locgid,MED_NOM_NOM,MED_NAME_SIZE,_sectionmeshname) < 0) {
00288 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_locgidname);
00289 SSCRUTE(MED_NOM_NOM);SSCRUTE(_sectionmeshname);
00290 goto ERROR;
00291 }
00292
00293 if (strlen(_sectionmeshname) ) {
00294
00295 if ( (_nbofsectiongeotype = MEDmeshnEntity(fid,_sectionmeshname,MED_NO_DT,MED_NO_IT,
00296 MED_CELL,MED_ALL_GEOTYPE,MED_CONNECTIVITY,MED_NODAL,
00297 &_chgt,&_trsf) ) < 0) {
00298 MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDmeshnEntity");
00299 ISCRUTE(_nbofsectiongeotype);goto ERROR;
00300 }
00301
00302 if ( (_nbofsectiongeotype != 1 ) ) {
00303 MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_RANGE,""); ISCRUTE(_nbofsectiongeotype); goto ERROR;
00304 }
00305
00306
00307 if ( MEDmeshEntityInfo( fid,_sectionmeshname,MED_NO_DT,MED_NO_IT,
00308 MED_CELL, 1, _sectiongeotypename,
00309 &_sectiongeotype ) < 0 ) {
00310 MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDmeshEntityInfo");
00311 SSCRUTE(_sectiongeotypename);ISCRUTE_int(_sectiongeotype);goto ERROR;
00312 }
00313
00314 if ( (_nbofsectioncell = MEDmeshnEntity(fid,_sectionmeshname,MED_NO_DT,MED_NO_IT,
00315 MED_CELL,_sectiongeotype,MED_CONNECTIVITY,MED_NODAL,
00316 &_chgt,&_trsf) ) < 0) {
00317 MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDmeshnEntity");
00318 ISCRUTE(_nbofsectioncell);goto ERROR;
00319 }
00320 }
00321 }
00322
00323 _nbofvaluesperentityfromloc*=_nbofsectioncell;
00324
00325 if (_MEDattrEntierLire(_locgid,MED_NOM_GEO,&_intlocgeotype) < 0) {
00326 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_LOCALIZATION_MSG);
00327 SSCRUTE(_localizationname);SSCRUTE(MED_NOM_GEO);ISCRUTE(_intlocgeotype);goto ERROR;
00328 }
00329 _locgeotype = (med_geometry_type) _intlocgeotype;
00330
00331 if ( _locgeotype != geotype ) {
00332 MED_ERR_(_ret,MED_ERR_NOTEQUAL,MED_ERR_ATTRIBUTE,MED_ERR_LOCALIZATION_MSG);
00333 SSCRUTE(_localizationname);SSCRUTE(MED_NOM_GEO);ISCRUTE_int(_locgeotype);ISCRUTE_int(geotype);
00334 goto ERROR;
00335 }
00336
00337 } else {
00338 _nbofvaluesperentityfromloc = 1;
00339 }
00340
00341 if ( _nbofvaluesperentityfromloc != _nbofvaluesperentity ) {
00342 MED_ERR_(_ret,MED_ERR_NOTEQUAL,MED_ERR_ATTRIBUTE,MED_ERR_LOCALIZATION_MSG);
00343 SSCRUTE(_localizationname);SSCRUTE(MED_NOM_GEO);ISCRUTE(_nbofvaluesperentityfromloc);
00344 ISCRUTE(_nbofvaluesperentity);goto ERROR;
00345 }
00346
00347 *nbofintegrationpoint = _nbofvaluesperentity;
00348
00349 }
00350
00351 _ret = _n;
00352 ERROR:
00353
00354 if (_datagroup2>0) if (_MEDdatagroupFermer(_datagroup2) < 0) {
00355 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_path);
00356 SSCRUTE(_datagroupname1); SSCRUTE(_profilename); ISCRUTE_id(_datagroup2);
00357 }
00358
00359 if (_datagroup1>0) if (_MEDdatagroupFermer(_datagroup1) < 0) {
00360 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_path);
00361 SSCRUTE(_datagroupname1); ISCRUTE_id(_datagroup1);
00362 }
00363
00364 if (_gid>0) if (_MEDdatagroupFermer(_gid) < 0) {
00365 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_path);
00366 ISCRUTE_id(_gid);
00367 }
00368
00369 if (_locgid>0) if (_MEDdatagroupFermer(_locgid) < 0) {
00370 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_locgidname);
00371 ISCRUTE_id(_locgid);
00372 }
00373
00374 va_end(params);
00375 *fret = _ret;
00376
00377 return;
00378 }