00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef MESGERR
00020 #define MESGERR 1
00021 #endif
00022
00023 #include "med_config.h"
00024 #include "med_outils.h"
00025 #include "med.h"
00026
00027 #include <string.h>
00028
00029 #include "MAJ_236_300.h"
00030 #include "MAJ_version.h"
00031
00032 void MAJ_236_300_champs(med_idt fid)
00033 {
00034 med_err lret,ret;
00035
00036 med_field_type typcha;
00037 char nomcha [MED_NAME_SIZE+1]="";
00038 char _meshname [MED_NAME_SIZE+1]="";
00039 char _dtunit [MED_SNAME_SIZE+1]="";
00040 char *comp= NULL, *unit= NULL;
00041 med_int ncomp,ncha;
00042 med_int _ncstp=0;
00043 med_bool _local=MED_FALSE;
00044 htri_t _datasetexist;
00045 char _pathi[MED_TAILLE_CHA+1+MED_NAME_SIZE+1]=MED_CHA;
00046 char _pathf[MED_TAILLE_CHA+2+MED_NAME_SIZE+1]="/CHA_/";
00047 char _pathtmp[MED_TAILLE_CHA+3]="/CHA__/";
00048 int i,j;
00049
00050 char nomlien[MED_NAME_SIZE+1]="";
00051 char * lien = NULL;
00052 med_int nln,nval;
00053
00054 med_int _nloc,_intgeotype,_sdim;
00055 char _pathloc[MED_TAILLE_GAUSS+MED_NAME_SIZE+1]=MED_GAUSS;
00056
00057 med_int _npar,_numdt,_numit;
00058 char _pathpari[MED_TAILLE_NUM_DATA+MED_NAME_SIZE+1+2*MED_MAX_PARA+1+1]=MED_NUM_DATA;
00059 char _pathparf[MED_TAILLE_NUM_DATA+MED_NAME_SIZE+1+2*MED_MAX_PARA+1+1]=MED_NUM_DATA;
00060 int _pathparlen;
00061 med_size _n=0;
00062 char _cpstnamei[2*MED_MAX_PARA+1]="";
00063 char _cpstnamef[2*MED_MAX_PARA+1]="";
00064 char _uniname[MED_SNAME_SIZE+1]="";
00065
00066 hid_t _lcp_plist_id;
00067 hid_t _ocp_plist_id;
00068 med_bool _createunt = MED_TRUE;
00069
00070 MAJ_version_num(fid,2,3,6);
00071
00072
00073 _npar = MEDnParameter(fid);
00074 if (_npar > 0) {
00075 fprintf(stdout," >>> Normalisation des paramètres scalaires\n");
00076 _pathparf[MED_TAILLE_NUM_DATA-2]='_';
00077
00078 _ocp_plist_id = H5Pcreate( H5P_OBJECT_COPY );
00079 _lcp_plist_id = H5Pcreate( H5P_LINK_CREATE );
00080 H5Pset_create_intermediate_group( _lcp_plist_id, 1 );
00081 H5Pset_copy_object( _ocp_plist_id, H5O_COPY_SHALLOW_HIERARCHY_FLAG);
00082 }
00083
00084 for (i=0 ; i < _npar ; i++ ) {
00085
00086 MED_ERR_EXIT_IF (_MEDobjectGetName(fid, _pathpari ,i, &_pathpari[MED_TAILLE_NUM_DATA]) < 0,
00087 MED_ERR_ACCESS,MED_ERR_DATAGROUP,_pathpari);
00088
00089
00090 strcpy(&_pathparf[MED_TAILLE_NUM_DATA],&_pathpari[MED_TAILLE_NUM_DATA]);
00091
00092
00093
00094
00095 ret = H5Ocopy(fid,_pathpari,fid,_pathparf,_ocp_plist_id,_lcp_plist_id);
00096
00097 EXIT_IF(ret < 0,"Copie du datagroup",_pathpari);
00098
00099 _pathparlen=strlen(_pathpari);
00100 _pathpari[_pathparlen]='/';_pathparf[_pathparlen]='/';
00101 ++_pathparlen;
00102 _pathpari[_pathparlen]='\0';_pathparf[_pathparlen]='\0';
00103
00104
00105
00106
00107 ret =_MEDnObjects(fid,_pathpari, &_n);
00108 MED_ERR_EXIT_IF( (ret == (MED_ERR_COUNT + MED_ERR_DATAGROUP)), MED_ERR_COUNT,MED_ERR_PARAMETER,_pathpari);
00109
00110 for (j=0 ; j < _n ; ++j ) {
00111 MED_ERR_EXIT_IF (_MEDobjectGetName(fid, _pathpari ,j, &_pathpari[_pathparlen]) < 0,
00112 MED_ERR_ACCESS,MED_ERR_DATAGROUP,_pathpari);
00113
00114 MED_ERR_EXIT_IF (_MEDattributeNumRdByName(fid,_pathpari,MED_NOM_NOR,
00115 MED_INTERNAL_INT,(unsigned char * const ) &_numit) < 0,
00116 MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_NOM_NOR);
00117
00118 MED_ERR_EXIT_IF (_MEDattributeNumRdByName(fid,_pathpari,MED_NOM_NDT,
00119 MED_INTERNAL_INT,(unsigned char * const ) &_numdt) < 0,
00120 MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_NOM_NDT);
00121
00122 MED_ERR_EXIT_IF (_MEDattributeStringRdByName(fid,_pathpari,MED_NOM_UNI,
00123 MED_SNAME_SIZE,_uniname) < 0,
00124 MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_NOM_NDT);
00125
00126 _MEDgetComputationStepName(MED_SORT_DTIT,_numdt,_numit,&_pathparf[_pathparlen]);
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138 _pathpari[MED_TAILLE_NUM_DATA-2]='_';
00139
00140
00141 ret = H5Gmove(fid, _pathpari, _pathparf );
00142 EXIT_IF(ret < 0,"Renommage de l'étape de calcul",_pathpari);
00143 _pathpari[MED_TAILLE_NUM_DATA-2]='A';
00144
00145
00146 MED_ERR_EXIT_IF(H5Adelete_by_name( fid, _pathparf, MED_NOM_UNI, H5P_DEFAULT ) < 0,
00147 MED_ERR_DELETE,MED_ERR_ATTRIBUTE,_pathparf);
00148
00149 _pathparf[_pathparlen]='\0';
00150 _pathpari[_pathparlen]='\0';
00151 if ( _createunt ) {
00152 MED_ERR_EXIT_IF (_MEDattributeStringWrByName(fid,_pathparf,MED_NOM_UNT, MED_SNAME_SIZE,_uniname) < 0,
00153 MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_NOM_UNT);
00154 _createunt = MED_FALSE;
00155 }
00156 }
00157 _createunt = MED_TRUE;
00158 _pathpari[MED_TAILLE_NUM_DATA]='\0';
00159 }
00160
00161 if ( _npar > 0 ) {
00162
00163 _pathpari[MED_TAILLE_NUM_DATA]='\0';
00164 _pathparf[MED_TAILLE_NUM_DATA]='\0';
00165 MED_ERR_EXIT_IF ( H5Ldelete(fid,_pathpari,H5P_DEFAULT) < 0 ,
00166 MED_ERR_DELETE,MED_ERR_LINK,_pathpari);
00167
00168 ret = H5Gmove(fid, _pathparf, _pathpari );
00169 EXIT_IF(ret < 0,"Renommage du group de paramètres scalaires",_pathparf);
00170
00171 }
00172
00173
00174 _nloc = MEDnLocalization(fid);
00175
00176 if (_nloc > 0)
00177 fprintf(stdout," >>> Normalisation des localisations des points d'intégration\n");
00178 for (i=0 ; i < _nloc ; i++ ) {
00179
00180
00181 MED_ERR_EXIT_IF (_MEDobjectGetName(fid, _pathloc ,i, &_pathloc[MED_TAILLE_GAUSS]) < 0,
00182 MED_ERR_ACCESS,MED_ERR_DATAGROUP,_pathloc);
00183
00184 MED_ERR_EXIT_IF (_MEDattributeNumRdByName(fid,_pathloc,MED_NOM_GEO,
00185 MED_INTERNAL_INT,(unsigned char * const ) &_intgeotype) < 0,
00186 MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_NOM_GEO);
00187 _sdim = (_intgeotype/100);
00188
00189 MED_ERR_EXIT_IF (_MEDattributeNumWrByName(fid,_pathloc,MED_NOM_DIM,
00190 MED_INTERNAL_INT,(const unsigned char * const) &_sdim) < 0,
00191 MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_NOM_DIM);
00192
00193 MED_ERR_EXIT_IF ( _MEDattributeStringWrByName(fid,_pathloc,MED_NOM_INM,MED_NAME_SIZE,"") < 0,
00194 MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_NOM_INM);
00195 _pathloc[MED_TAILLE_GAUSS]='\0';
00196
00197 }
00198
00199
00200 nln = MEDnLink(fid);
00201 if (nln > 0)
00202 fprintf(stdout," >>> Normalisation des liens\n");
00203 for (i=1 ; i <= nln ; i++ ) {
00204
00205
00206 ret = MEDlinkInfo(fid, i, nomlien, &nval);
00207 EXIT_IF(ret,"Erreur a la demande d'information sur le lien",NULL);
00208
00209
00210
00211 lien = (char *) malloc((nval+1)*sizeof(char));
00212 EXIT_IF(lien == NULL,NULL,NULL);
00213
00214 ret = MEDlinkRd(fid, nomlien, lien );
00215 EXIT_IF(ret,"Erreur a la lecture du lien : ",nomlien);
00216
00217 MAJ_version(fid);
00218 ret = MED30linkWr(fid,nomlien,lien);
00219 EXIT_IF(ret,"Erreur a l'écrtiure du lien : ",nomlien);
00220 MAJ_version_num(fid,2,3,6);
00221
00222 lien[nval] = '\0';
00223
00224
00225 free(lien);
00226 }
00227
00228
00229 ncha = MEDnField(fid);
00230 EXIT_IF(ncha < 0,"lors de la lecture du nombre de champs",NULL);
00231
00232
00233 for (i =0;i<ncha;i++) {
00234 lret = 0;
00235
00236
00237 ncomp = MEDfieldnComponent(fid,i+1);
00238 if (ncomp < 0) {
00239 MESSAGE("Erreur à la lecture du nombre de composantes : "); ISCRUTE(ncomp);
00240 exit(1);
00241 }
00242
00243
00244 comp = (char*) malloc(ncomp*MED_SNAME_SIZE+1);
00245 EXIT_IF(comp == NULL,NULL,NULL);
00246 unit = (char*) malloc(ncomp*MED_SNAME_SIZE+1);
00247 EXIT_IF(unit == NULL,NULL,NULL);
00248
00249
00250 ret = MEDfieldInfo(fid,i+1,nomcha,_meshname,&_local,&typcha,comp,unit,_dtunit,&_ncstp);
00251 if ( ret < 0 ) {
00252 MESSAGE("Erreur à la demande d'information sur les champs ");
00253 exit(1);
00254 }
00255
00256
00257
00258
00259
00260
00261 MAJ_version(fid);
00262
00263 EXIT_IF( H5Gmove(fid, _pathi, _pathtmp ) < 0,"Switch to ",_pathtmp);
00264 _datasetexist=H5Lexists( fid, _pathf, H5P_DEFAULT );
00265
00266 if (_datasetexist ) { EXIT_IF( (H5Gmove(fid, _pathf, _pathi ) < 0) ,"Switch to ",_pathi); }
00267
00268 MED_ERR_EXIT_IF( MEDfieldCr(fid,nomcha,typcha,ncomp,comp,unit,_dtunit,_meshname ) < 0,
00269 MED_ERR_CREATE,MED_ERR_FIELD,_pathf);
00270 EXIT_IF( H5Gmove(fid, _pathi , _pathf ) < 0,"Switch to ",_pathf);
00271 EXIT_IF( H5Gmove(fid, _pathtmp, _pathi ) < 0,"Switch to ",_pathi);
00272
00273 MAJ_version_num(fid,2,3,6);
00274
00275
00276 free(comp);
00277 free(unit);
00278
00279
00280 lret = MAJ_236_300_fieldOnEntity( fid, nomcha, _meshname, typcha, ncomp, MED_NODE,_ncstp, _pathi, _pathf);
00281 if (lret != 0) {
00282 MESSAGE("Erreur à la lecture des champs aux noeuds "); exit(1);
00283 }
00284
00285 lret = MAJ_236_300_fieldOnEntity( fid, nomcha, _meshname, typcha, ncomp, MED_CELL,_ncstp, _pathi, _pathf);
00286 if (lret != 0) {
00287 MESSAGE("Erreur à la lecture des champs aux mailles "); exit(1);
00288 }
00289
00290 lret = MAJ_236_300_fieldOnEntity( fid, nomcha, _meshname, typcha, ncomp, MED_DESCENDING_FACE,_ncstp, _pathi, _pathf);
00291 if (lret != 0) {
00292 MESSAGE("Erreur à la lecture des champs aux faces "); exit(1);
00293 }
00294
00295 lret = MAJ_236_300_fieldOnEntity( fid, nomcha, _meshname, typcha, ncomp, MED_DESCENDING_EDGE,_ncstp, _pathi, _pathf);
00296 if (lret != 0) {
00297 MESSAGE("Erreur à la lecture des champs aux aretes "); exit(1);
00298 }
00299
00300 lret = MAJ_236_300_fieldOnEntity( fid, nomcha, _meshname, typcha, ncomp, MED_NODE_ELEMENT,_ncstp, _pathi, _pathf);
00301 if (lret != 0) {
00302 MESSAGE("Erreur à la lecture des champs aux aretes "); exit(1);
00303 }
00304
00305 }
00306
00307
00308 _datasetexist=H5Lexists( fid, _pathf, H5P_DEFAULT );
00309
00310
00311 if (_datasetexist ) {
00312
00313
00314 EXIT_IF( (H5Ldelete(fid,_pathi, H5P_DEFAULT) < 0) ,"Delete ",_pathi);
00315 EXIT_IF( (H5Gmove(fid, _pathf, _pathi ) < 0) ,"Switch to ",_pathi);
00316 }
00317
00318
00319 }