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