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_300_310.h"
00026 #include "MAJ_version.h"
00027
00028 void MAJ_300_310_champs(med_idt fid)
00029 {
00030 med_err ret;
00031 med_field_type typcha;
00032 char nomcha [MED_NAME_SIZE+1]="";
00033 char _meshname [MED_NAME_SIZE+1]="";
00034 char _dtunit [MED_SNAME_SIZE+1]="";
00035 char *comp= NULL, *unit= NULL;
00036 med_int ncomp,ncha;
00037 med_int _ncstp=0;
00038 med_bool _local=MED_FALSE;
00039 htri_t _datasetexist;
00040 char _pathi[(MED_TAILLE_CHA+MED_NAME_SIZE+1)+2*MED_MAX_PARA+1 ] = MED_CHA;
00041 char _pathf[(MED_TAILLE_CHA+1+MED_NAME_SIZE+1)+2*MED_MAX_PARA+1] = "/CHA_/";
00042 char _pathtmp[MED_TAILLE_CHA+3]="/CHA__/";
00043 int i=0,_num=0;
00044 med_size _sizei=0,_sizef=0;
00045 char _cstpname[2*MED_MAX_PARA+1]="";
00046
00047 MAJ_version_num(fid,3,0,8);
00048
00049
00050 ncha = MEDnField(fid);
00051 EXIT_IF(ncha < 0,"lors de la lecture du nombre de champs",NULL);
00052
00053
00054 for (i=0;i<ncha;i++) {
00055
00056
00057 ncomp = MEDfieldnComponent(fid,i+1);
00058 if (ncomp < 0) {
00059 MESSAGE("Erreur à la lecture du nombre de composantes : "); ISCRUTE(ncomp);
00060 exit(1);
00061 }
00062
00063
00064 comp = (char*) malloc(ncomp*MED_SNAME_SIZE+1);
00065 EXIT_IF(comp == NULL,NULL,NULL);
00066 unit = (char*) malloc(ncomp*MED_SNAME_SIZE+1);
00067 EXIT_IF(unit == NULL,NULL,NULL);
00068
00069 ret = MEDfieldInfo(fid,i+1,nomcha,_meshname,&_local,&typcha,comp,unit,_dtunit,&_ncstp);
00070 MED_ERR_EXIT_IF(ret,MED_ERR_ACCESS,MED_ERR_FIELD,nomcha);
00071
00072
00073
00074
00075
00076 MAJ_version_num(fid,3,1,0);
00077
00078 EXIT_IF( H5Gmove(fid, _pathi, _pathtmp ) < 0,"Switch to ",_pathtmp);
00079
00080
00081
00082 _datasetexist=H5Lexists( fid, _pathf, H5P_DEFAULT );
00083 if (_datasetexist ) { EXIT_IF( (H5Gmove(fid, _pathf, _pathi ) < 0) ,"Switch to ",_pathi); }
00084
00085 MED_ERR_EXIT_IF( MEDfieldCr(fid,nomcha,typcha,ncomp,comp,unit,_dtunit,_meshname ) < 0,
00086 MED_ERR_CREATE,MED_ERR_FIELD,_pathf);
00087
00088 EXIT_IF( H5Gmove(fid, _pathi , _pathf ) < 0,"Switch to ",_pathf);
00089 EXIT_IF( H5Gmove(fid, _pathtmp, _pathi ) < 0,"Switch to ",_pathi);
00090
00091 strncpy(&_pathi[MED_TAILLE_CHA] ,nomcha,MED_NAME_SIZE+1);
00092 strncpy(&_pathf[MED_TAILLE_CHA+1],nomcha,MED_NAME_SIZE+1);
00093 _sizei = MED_TAILLE_CHA+strlen(nomcha);
00094 _sizef = _sizei+1;
00095 _pathi[_sizei]='/';++_sizei;
00096 _pathf[_sizef]='/';++_sizef;
00097
00098
00099 for (_num=0; _num<_ncstp; ++_num) {
00100
00101 _pathi[_sizei]='\0';
00102 _pathf[_sizef]='\0';
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114 ret = _MEDobjectGetName(fid, _pathi ,0, &_pathi[_sizei]) < 0;
00115 MED_ERR_EXIT_IF(ret,MED_ERR_ACCESS,MED_ERR_DATAGROUP,_pathi);
00116
00117 strncpy(&_pathf[_sizef],&_pathi[_sizei],2*MED_MAX_PARA+1);
00118
00119
00120
00121 EXIT_IF( H5Lmove( fid, _pathi, fid, _pathf, H5P_DEFAULT, H5P_DEFAULT ) < 0, "Failed to move field ",_pathi);
00122 }
00123
00124 _pathi[MED_TAILLE_CHA]='\0';
00125 _pathf[MED_TAILLE_CHA+1]='\0';
00126
00127
00128 MAJ_version_num(fid,3,0,8);
00129
00130 free(comp);
00131 free(unit);
00132
00133 }
00134
00135 _datasetexist=H5Lexists( fid, _pathf, H5P_DEFAULT );
00136
00137 if (_datasetexist ) {
00138 EXIT_IF( (H5Ldelete(fid,_pathi, H5P_DEFAULT) < 0) ,"Delete ",_pathi);
00139 EXIT_IF( (H5Gmove(fid, _pathf, _pathi ) < 0) ,"Switch to ",_pathf);
00140 }
00141
00142
00143
00144 }