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_310_320.h"
00026 #include "MAJ_version.h"
00027
00028 static void _move_families(med_idt fid, char * const _pathi,char * const _pathf) {
00029 med_err _ret=0;
00030 med_int _nfam=0;
00031 med_int _sizei,_sizef;
00032 med_size _size=0;
00033 int i=0;
00034
00035 _ret=_MEDnObjects(fid,_pathi,&_size);
00036 MED_ERR_EXIT_IF(_ret,MED_ERR_COUNT,MED_ERR_DATAGROUP,_pathi);
00037 _nfam = (med_int ) _size;
00038
00039 _sizef=strlen(_pathf); _sizei =_sizef-1;
00040
00041
00042 for (i=0;i<_nfam;i++) {
00043
00044 _pathi[_sizei]='/';
00045 _pathf[_sizef]='/';
00046 _pathi[++_sizei]='\0';
00047 _pathf[++_sizef]='\0';
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 _ret = _MEDobjectGetName(fid, _pathi ,0, &_pathi[_sizei]) < 0;
00060 MED_ERR_EXIT_IF(_ret,MED_ERR_ACCESS,MED_ERR_DATAGROUP,_pathi);
00061
00062 strncpy(&_pathf[_sizef],&_pathi[_sizei],MED_NAME_SIZE+1);
00063
00064
00065
00066
00067 EXIT_IF( H5Lmove( fid, _pathi, fid, _pathf, H5P_DEFAULT, H5P_DEFAULT ) < 0, "Failed to move family ",_pathi);
00068 --_sizei;--_sizef;
00069 }
00070 }
00071
00072
00073 void MAJ_310_320_familles(med_idt fid)
00074 {
00075 med_err _ret=0;
00076 htri_t _datasetexist;
00077 char _pathi[(MED_TAILLE_FAS+MED_NAME_SIZE+1) + MED_TAILLE_FAS_ENTITE+MED_NAME_SIZE+1] = MED_FAS;
00078 char _pathf[(MED_TAILLE_FAS+1+MED_NAME_SIZE+1)+ MED_TAILLE_FAS_ENTITE+MED_NAME_SIZE+1] = "/FAS_/";
00079
00080 int _meshi=0;
00081 med_size _sizei=0,_sizef=0,_size=0,_nmesh=0;
00082 med_idt _famId=0,_famMeshId=0,_famZeId=0,_famElId=0,_famNoeId=0;
00083 MAJ_version_num(fid,3,1,0);
00084
00085
00086 _ret=_MEDnObjects(fid,_pathi,&_nmesh);
00087 MED_ERR_EXIT_IF(_ret,MED_ERR_COUNT,MED_ERR_DATAGROUP,_pathi);
00088
00089 for (_meshi=0;_meshi<_nmesh;_meshi++) {
00090
00091
00092
00093
00094 _pathi[MED_TAILLE_FAS ]='\0';
00095 _pathf[MED_TAILLE_FAS+1]='\0';
00096
00097 _ret = _MEDobjectGetName(fid, _pathi ,_meshi, &_pathi[MED_TAILLE_FAS]) < 0;
00098 MED_ERR_EXIT_IF(_ret,MED_ERR_ACCESS,MED_ERR_DATAGROUP,_pathi);
00099
00100
00101
00102 _datasetexist=H5Lexists( fid, _pathf, H5P_DEFAULT );
00103 if(!_datasetexist) {
00104 _famId = _MEDdatagroupCreer(fid,_pathf);
00105 MED_ERR_EXIT_IF(_famId < 0, MED_ERR_CREATE,MED_ERR_FAMILY,_pathf);
00106 if (_famId>0) _ret=_MEDdatagroupFermer(_famId);
00107 MED_ERR_EXIT_IF(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_pathf);
00108 }
00109
00110 strncpy(&_pathf[MED_TAILLE_FAS+1],&_pathi[MED_TAILLE_FAS],MED_NAME_SIZE+1);
00111 _datasetexist=H5Lexists( fid, _pathf, H5P_DEFAULT );
00112 if(!_datasetexist) {
00113 _famMeshId = _MEDdatagroupCreer(fid,_pathf);
00114 MED_ERR_EXIT_IF(_famMeshId < 0, MED_ERR_CREATE,MED_ERR_FAMILY,_pathf);
00115 if (_famMeshId>0) _ret=_MEDdatagroupFermer(_famMeshId);
00116 MED_ERR_EXIT_IF(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_pathf);
00117 }
00118
00119 _sizef=strlen(_pathf);_sizei =_sizef-1;
00120
00121
00122 strncpy(&_pathi[_sizei],MED_FAS_NOEUD,MED_TAILLE_FAS_ENTITE-1);
00123 _pathi[_sizei+(MED_TAILLE_FAS_ENTITE-1)]='\0';
00124 _datasetexist=H5Lexists( fid, _pathi, H5P_DEFAULT );
00125 if (_datasetexist) {
00126 strncpy(&_pathf[_sizef],MED_FAS_NOEUD,MED_TAILLE_FAS_ENTITE-1);
00127 _pathf[_sizef+(MED_TAILLE_FAS_ENTITE-1)]='\0';
00128 _famNoeId = _MEDdatagroupCrOrderCr(fid,_pathf);
00129 MED_ERR_EXIT_IF(_famNoeId < 0, MED_ERR_CREATE,MED_ERR_FAMILY,_pathf);
00130 if (_famNoeId>0) _ret=_MEDdatagroupFermer(_famNoeId);
00131 MED_ERR_EXIT_IF(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_pathf);
00132 _move_families( fid, _pathi,_pathf);
00133 }
00134
00135
00136
00137 strncpy(&_pathi[_sizei],MED_FAS_ELEME,MED_TAILLE_FAS_ENTITE-1);
00138 _pathi[_sizei+(MED_TAILLE_FAS_ENTITE-1)]='\0';
00139 _datasetexist=H5Lexists( fid, _pathi, H5P_DEFAULT );
00140 if (_datasetexist) {
00141 strncpy(&_pathf[_sizef],MED_FAS_ELEME,MED_TAILLE_FAS_ENTITE-1);
00142 _pathf[_sizef+(MED_TAILLE_FAS_ENTITE-1)]='\0';
00143 _famElId = _MEDdatagroupCrOrderCr(fid,_pathf);
00144 MED_ERR_EXIT_IF(_famElId < 0, MED_ERR_CREATE,MED_ERR_FAMILY,_pathf);
00145 if (_famElId>0) _ret=_MEDdatagroupFermer(_famElId);
00146 MED_ERR_EXIT_IF(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_pathf);
00147 _move_families( fid, _pathi,_pathf);
00148 }
00149
00150
00151 strncpy(&_pathf[_sizef],MED_FAS_ZERO,MED_TAILLE_FAS_ZERO-1);
00152 _pathf[_sizef+(MED_TAILLE_FAS_ZERO-1)]='\0';
00153 _famZeId = _MEDdatagroupCrOrderCr(fid,_pathf);
00154 MED_ERR_EXIT_IF(_famZeId < 0, MED_ERR_CREATE,MED_ERR_FAMILY,_pathf);
00155 if (_famZeId>0) _ret=_MEDdatagroupFermer(_famZeId);
00156 MED_ERR_EXIT_IF(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_pathf);
00157 }
00158
00159 _pathi[MED_TAILLE_FAS ]='\0';
00160 _pathf[MED_TAILLE_FAS+1]='\0';
00161 _datasetexist=H5Lexists( fid, _pathf, H5P_DEFAULT );
00162
00163 if (_datasetexist ) {
00164 EXIT_IF( (H5Ldelete(fid,_pathi, H5P_DEFAULT) < 0) ,"Delete ",_pathi);
00165 EXIT_IF( (H5Gmove(fid, _pathf, _pathi ) < 0) ,"Switch to ",_pathf);
00166 }
00167
00168
00169
00170
00171
00172 }