From: jfa Date: Tue, 17 Jan 2006 14:27:15 +0000 (+0000) Subject: PAL11269: Portability hdf>=1.6.4 and compatibility hdf<=1.6.3. A fix by Erwan ADAM. X-Git-Tag: T2_2_9pre~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d5da13a0a9713a2fe2171475b011420951fcfbee;p=modules%2Fkernel.git PAL11269: Portability hdf>=1.6.4 and compatibility hdf<=1.6.3. A fix by Erwan ADAM. --- diff --git a/src/MEDWrapper/V2_1/MEDdatasetNumEcrire.cxx b/src/MEDWrapper/V2_1/MEDdatasetNumEcrire.cxx index 846ea206a..0ac27825b 100644 --- a/src/MEDWrapper/V2_1/MEDdatasetNumEcrire.cxx +++ b/src/MEDWrapper/V2_1/MEDdatasetNumEcrire.cxx @@ -19,6 +19,7 @@ #include "med.hxx" #include "med_outils.hxx" #include +#include "hdf5_version2api.hxx" /* * - Nom de la fonction : _MEDdatasetNumEcrire @@ -51,7 +52,11 @@ _MEDdatasetNumEcrire(med_idt pere,char *nom, med_type_champ type, med_size *size, unsigned char *val, med_mode_acces mode) { med_idt dataset, dataspace = 0, memspace = 0; +#ifdef HDF_NEW_API + med_size start_mem[1],start_data[1],*pflmem,*pfldsk; +#else med_ssize start_mem[1],start_data[1],*pflmem,*pfldsk; +#endif med_size stride[1],count[1],pcount[1],pflsize[1]; med_err ret; int i,j,index,type_hdf; @@ -82,7 +87,7 @@ _MEDdatasetNumEcrire(med_idt pere,char *nom, med_type_champ type, case MED_INT32 : #if defined(PCLINUX) type_hdf = H5T_STD_I32BE; - if ((H5Tconvert(H5T_NATIVE_INT,H5T_STD_I32BE,(hsize_t)*size,(void *)val,NULL,NULL)) < 0) + if ((H5Tconvert(H5T_NATIVE_INT,H5T_STD_I32BE,(hsize_t)*size,(void *)val,NULL,(hid_t)0)) < 0) return -1; #else type_hdf = H5T_NATIVE_INT; @@ -169,8 +174,13 @@ _MEDdatasetNumEcrire(med_idt pere,char *nom, med_type_champ type, pflsize [0] = psize*ngauss*nbdim; pcount [0] = psize*ngauss*dimutil; +#ifdef HDF_NEW_API + pflmem = (med_size *) malloc (sizeof(med_size)*pcount[0]); + pfldsk = (med_size *) malloc (sizeof(med_size)*pcount[0]); +#else pflmem = (med_ssize *) malloc (sizeof(med_ssize)*pcount[0]); pfldsk = (med_ssize *) malloc (sizeof(med_ssize)*pcount[0]); +#endif switch(pflmod) { /* switch pflmod pout FULL_INTERLACE*/ @@ -190,11 +200,19 @@ _MEDdatasetNumEcrire(med_idt pere,char *nom, med_type_champ type, } } +#ifdef HDF_NEW_API + if ( (ret = H5Sselect_elements(memspace,H5S_SELECT_SET, pcount[0], (const hsize_t **) pflmem ) ) <0) + return -1; + + if ( (ret = H5Sselect_elements(dataspace,H5S_SELECT_SET, pcount[0], (const hsize_t **) pfldsk ) ) <0) + return -1; +#else if ( (ret = H5Sselect_elements(memspace,H5S_SELECT_SET, pcount[0], (const hssize_t **) pflmem ) ) <0) return -1; if ( (ret = H5Sselect_elements(dataspace,H5S_SELECT_SET, pcount[0], (const hssize_t **) pfldsk ) ) <0) return -1; +#endif break; @@ -217,11 +235,19 @@ _MEDdatasetNumEcrire(med_idt pere,char *nom, med_type_champ type, } } +#ifdef HDF_NEW_API + if ( (ret = H5Sselect_elements(memspace,H5S_SELECT_SET, pcount[0], (const hsize_t **) pflmem ) ) <0) + return -1; + + if ( (ret = H5Sselect_elements(dataspace,H5S_SELECT_SET, pcount[0], (const hsize_t **) pfldsk ) ) <0) + return -1; +#else if ( (ret = H5Sselect_elements(memspace,H5S_SELECT_SET, pcount[0], (const hssize_t **) pflmem ) ) <0) return -1; if ( (ret = H5Sselect_elements(dataspace,H5S_SELECT_SET, pcount[0], (const hssize_t **) pfldsk ) ) <0) return -1; +#endif break; @@ -277,7 +303,11 @@ _MEDdatasetNumEcrire(med_idt pere,char *nom, med_type_champ type, pflsize [0] = psize*ngauss*nbdim; pcount [0] = psize*ngauss*dimutil; /* nom pas très coherent avec count !!! A revoir */ +#ifdef HDF_NEW_API + pfldsk = (med_size *) malloc(sizeof(med_size)*pcount[0]); +#else pfldsk = (med_ssize *) malloc(sizeof(med_ssize)*pcount[0]); +#endif switch(pflmod) { /*switch plfmod pour NO_INTERLACE */ @@ -292,8 +322,13 @@ _MEDdatasetNumEcrire(med_idt pere,char *nom, med_type_champ type, } } +#ifdef HDF_NEW_API + if ( (ret = H5Sselect_elements(dataspace,H5S_SELECT_SET,pcount[0], (const hsize_t **) pfldsk ) ) <0) + return -1; +#else if ( (ret = H5Sselect_elements(dataspace,H5S_SELECT_SET,pcount[0], (const hssize_t **) pfldsk ) ) <0) return -1; +#endif if ((ret = H5Dwrite(dataset,type_hdf,dataspace,dataspace,H5P_DEFAULT, val)) < 0) return -1; @@ -309,7 +344,11 @@ _MEDdatasetNumEcrire(med_idt pere,char *nom, med_type_champ type, if ( (memspace = H5Screate_simple (1, pflsize, NULL)) <0) return -1; +#ifdef HDF_NEW_API + pflmem = (med_size *) malloc (sizeof(med_size)*pcount[0]); +#else pflmem = (med_ssize *) malloc (sizeof(med_ssize)*pcount[0]); +#endif /* Le profil COMPACT est contigüe, mais il est possible que l'on selectionne uniquemenent une dimension*/ @@ -323,11 +362,19 @@ _MEDdatasetNumEcrire(med_idt pere,char *nom, med_type_champ type, } } +#ifdef HDF_NEW_API + if ( (ret = H5Sselect_elements(memspace ,H5S_SELECT_SET,pcount[0], (const hsize_t **) pflmem ) ) <0) + return -1; + + if ( (ret = H5Sselect_elements(dataspace,H5S_SELECT_SET,pcount[0], (const hsize_t **) pfldsk ) ) <0) + return -1; +#else if ( (ret = H5Sselect_elements(memspace ,H5S_SELECT_SET,pcount[0], (const hssize_t **) pflmem ) ) <0) return -1; if ( (ret = H5Sselect_elements(dataspace,H5S_SELECT_SET,pcount[0], (const hssize_t **) pfldsk ) ) <0) return -1; +#endif if ((ret = H5Dwrite(dataset,type_hdf,memspace,dataspace,H5P_DEFAULT, val)) < 0) return -1; @@ -364,7 +411,7 @@ _MEDdatasetNumEcrire(med_idt pere,char *nom, med_type_champ type, #if defined(PCLINUX) if (type == MED_INT32) - if ((H5Tconvert(H5T_STD_I32BE,H5T_NATIVE_INT,(hsize_t)*size,(void *)val,NULL,NULL)) < 0) + if ((H5Tconvert(H5T_STD_I32BE,H5T_NATIVE_INT,(hsize_t)*size,(void *)val,NULL,(hid_t)0)) < 0) return -1; #endif diff --git a/src/MEDWrapper/V2_1/MEDdatasetNumLire.cxx b/src/MEDWrapper/V2_1/MEDdatasetNumLire.cxx index 8eef19f6c..159c195a0 100644 --- a/src/MEDWrapper/V2_1/MEDdatasetNumLire.cxx +++ b/src/MEDWrapper/V2_1/MEDdatasetNumLire.cxx @@ -19,6 +19,7 @@ #include "med.hxx" #include "med_outils.hxx" #include +#include "hdf5_version2api.hxx" /* * - Nom de la fonction : _MEDdatasetNumLire @@ -48,7 +49,11 @@ _MEDdatasetNumLire(med_idt pere,char *nom,med_type_champ type, unsigned char *val) { med_idt dataset, dataspace = 0, memspace = 0; +#ifdef HDF_NEW_API + med_size start_mem[1],start_data[1],*pflmem=0,*pfldsk=0; +#else med_ssize start_mem[1],start_data[1],*pflmem=0,*pfldsk=0; +#endif med_size stride[1],count[1],pcount[1],size[1],pflsize[1]; med_err ret; int i,j,index,type_hdf; @@ -153,8 +158,13 @@ _MEDdatasetNumLire(med_idt pere,char *nom,med_type_champ type, pflsize [0] = psize*ngauss*nbdim; pcount [0] = psize*ngauss*dimutil; +#ifdef HDF_NEW_API + pflmem = (med_size *) malloc (sizeof(med_size)*pcount[0]); + pfldsk = (med_size *) malloc (sizeof(med_size)*pcount[0]); +#else pflmem = (med_ssize *) malloc (sizeof(med_ssize)*pcount[0]); pfldsk = (med_ssize *) malloc (sizeof(med_ssize)*pcount[0]); +#endif switch(pflmod) { /* switch pflmod pour FULL_INTERLACE*/ @@ -174,11 +184,19 @@ _MEDdatasetNumLire(med_idt pere,char *nom,med_type_champ type, } } +#ifdef HDF_NEW_API + if ( (ret = H5Sselect_elements(memspace ,H5S_SELECT_SET, pcount[0], (const hsize_t **) pflmem ) ) <0) + return -1; + + if ( (ret = H5Sselect_elements(dataspace,H5S_SELECT_SET, pcount[0], (const hsize_t **) pfldsk ) ) <0) + return -1; +#else if ( (ret = H5Sselect_elements(memspace ,H5S_SELECT_SET, pcount[0], (const hssize_t **) pflmem ) ) <0) return -1; if ( (ret = H5Sselect_elements(dataspace,H5S_SELECT_SET, pcount[0], (const hssize_t **) pfldsk ) ) <0) return -1; +#endif break; @@ -201,11 +219,19 @@ _MEDdatasetNumLire(med_idt pere,char *nom,med_type_champ type, } } +#ifdef HDF_NEW_API + if ( (ret = H5Sselect_elements(memspace ,H5S_SELECT_SET, pcount[0], (const hsize_t **) pflmem ) ) <0) + return -1; + + if ( (ret = H5Sselect_elements(dataspace,H5S_SELECT_SET, pcount[0], (const hsize_t **) pfldsk ) ) <0) + return -1; +#else if ( (ret = H5Sselect_elements(memspace ,H5S_SELECT_SET, pcount[0], (const hssize_t **) pflmem ) ) <0) return -1; if ( (ret = H5Sselect_elements(dataspace,H5S_SELECT_SET, pcount[0], (const hssize_t **) pfldsk ) ) <0) return -1; +#endif break; @@ -260,7 +286,11 @@ _MEDdatasetNumLire(med_idt pere,char *nom,med_type_champ type, pflsize [0] = psize*ngauss*nbdim; pcount [0] = psize*ngauss*dimutil; /* nom pas très coherent avec count !!! A revoir */ +#ifdef HDF_NEW_API + pfldsk = (med_size *) malloc(sizeof(med_size)*pcount[0]); +#else pfldsk = (med_ssize *) malloc(sizeof(med_ssize)*pcount[0]); +#endif switch(pflmod) { /*switch plfmod pour NO_INTERLACE */ @@ -275,8 +305,13 @@ _MEDdatasetNumLire(med_idt pere,char *nom,med_type_champ type, } } +#ifdef HDF_NEW_API + if ( (ret = H5Sselect_elements(dataspace,H5S_SELECT_SET,pcount[0], (const hsize_t **) pfldsk ) ) <0) + return -1; +#else if ( (ret = H5Sselect_elements(dataspace,H5S_SELECT_SET,pcount[0], (const hssize_t **) pfldsk ) ) <0) return -1; +#endif if ((ret = H5Dread(dataset,type_hdf,dataspace,dataspace,H5P_DEFAULT, val)) < 0) return -1; @@ -292,7 +327,11 @@ _MEDdatasetNumLire(med_idt pere,char *nom,med_type_champ type, if ( (memspace = H5Screate_simple (1, pflsize, NULL)) <0) return -1; +#ifdef HDF_NEW_API + pflmem = (med_size *) malloc (sizeof(med_size)*pcount[0]); +#else pflmem = (med_ssize *) malloc (sizeof(med_ssize)*pcount[0]); +#endif /* Le profil COMPACT est contigüe, mais il est possible que l'on selectionne uniquemenent une dimension*/ @@ -306,11 +345,19 @@ _MEDdatasetNumLire(med_idt pere,char *nom,med_type_champ type, } } +#ifdef HDF_NEW_API + if ( (ret = H5Sselect_elements(memspace ,H5S_SELECT_SET, pcount[0], (const hsize_t **) pflmem ) ) <0) + return -1; + + if ( (ret = H5Sselect_elements(dataspace,H5S_SELECT_SET,pcount[0], (const hsize_t **) pfldsk ) ) <0) + return -1; +#else if ( (ret = H5Sselect_elements(memspace ,H5S_SELECT_SET, pcount[0], (const hssize_t **) pflmem ) ) <0) return -1; if ( (ret = H5Sselect_elements(dataspace,H5S_SELECT_SET,pcount[0], (const hssize_t **) pfldsk ) ) <0) return -1; +#endif if ((ret = H5Dread(dataset,type_hdf,memspace,dataspace,H5P_DEFAULT, val)) < 0) return -1; diff --git a/src/MEDWrapper/V2_1/Makefile.in b/src/MEDWrapper/V2_1/Makefile.in index 778b27267..373ede70c 100644 --- a/src/MEDWrapper/V2_1/Makefile.in +++ b/src/MEDWrapper/V2_1/Makefile.in @@ -155,7 +155,8 @@ LIB_SRC = \ EXPORT_HEADERS = \ MED_V2_1_Wrapper.hxx \ med.hxx \ - med_proto.hxx + med_proto.hxx \ + hdf5_version2api.hxx # Executables targets BIN = mdump_V2_1 test1_V2_1 diff --git a/src/MEDWrapper/V2_1/hdf5_version2api.hxx b/src/MEDWrapper/V2_1/hdf5_version2api.hxx new file mode 100644 index 000000000..5a40aa426 --- /dev/null +++ b/src/MEDWrapper/V2_1/hdf5_version2api.hxx @@ -0,0 +1,26 @@ + +#ifndef _hdf5_version2api_hxx_ +#define _hdf5_version2api_hxx_ + +#include + +#if H5_VERS_MAJOR < 1 +#elif H5_VERS_MAJOR == 1 + +#if H5_VERS_MINOR < 6 +#elif H5_VERS_MINOR == 6 + +#if H5_VERS_RELEASE < 4 +#else +#define HDF_NEW_API +#endif + +#else /* H5_VERS_MINOR >= 7 */ +#define HDF_NEW_API +#endif /* H5_VERS_MINOR */ + +#else /* H5_VERS_MAJOR >= 2 */ +#define HDF_NEW_API +#endif /* H5_VERS_MAJOR */ + +#endif