From 2ab6b12b552e9260e2e76640a788b5a3744c6a9f Mon Sep 17 00:00:00 2001 From: Elena Pourmal Date: Fri, 24 Jun 2005 00:00:01 -0500 Subject: [svn-r10977] Purpose: Bug fix Description: 1.7 daily tests failed in HL library when Fortran was not enabled; also long long instead of long_long declarations were used and caused failures on Windows Solution: Removed Fortran related functions (except H5IM_find_palette) from H5IM.c file and put it into fortran/src/H5IMcc.c Modified appropriate Makefile.am files, regenerated Makefile.in files, updated header files, MANIFEST, etc. Note: H5IM_find_palette should be also in H5IMcc.c, but for some unknown to me reason, linking fails if the function is included in H5IMcc.c. I will really appreciate if some C guru will look into the code and figure out what is wrong :-) Thanks! Platforms tested: mir with g95, heping with and without Fortran enabled Misc. update: --- MANIFEST | 4 +- hl/fortran/src/H5IMcc.c | 424 ++++++++++++++++++++++++++++++++++++++++++++ hl/fortran/src/H5IMcc.h | 66 +++++++ hl/fortran/src/H5LTfc.c | 4 +- hl/fortran/src/Makefile.am | 10 +- hl/fortran/src/Makefile.in | 17 +- hl/fortran/test/Makefile.am | 4 +- hl/fortran/test/Makefile.in | 10 +- hl/src/H5IM.c | 416 +------------------------------------------ hl/src/H5IM.h | 29 +-- hl/src/H5LT.c | 6 +- hl/src/H5LT.h | 2 +- 12 files changed, 525 insertions(+), 467 deletions(-) create mode 100644 hl/fortran/src/H5IMcc.c create mode 100644 hl/fortran/src/H5IMcc.h diff --git a/MANIFEST b/MANIFEST index 0984548..b098a09 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,4 +1,4 @@ -#------------------------------------------------------------------------------ +a------------------------------------------------------------------------------ # This is the list of files that are part of HDF5 source distribution. # All files have a `./' prefix and appear in lexicographic order. # Lines that end with _DO_NOT_DISTRIBUTE_ will not be included in a @@ -1665,6 +1665,8 @@ ./hl/test/earth.pal # hl fortran +./hl/fortran/src/H5IMcc.c +./hl/fortran/src/H5IMcc.h ./hl/fortran/src/H5IMfc.c ./hl/fortran/src/H5IMff.f90 ./hl/fortran/src/H5LTf90proto.h diff --git a/hl/fortran/src/H5IMcc.c b/hl/fortran/src/H5IMcc.c new file mode 100644 index 0000000..b55e242 --- /dev/null +++ b/hl/fortran/src/H5IMcc.c @@ -0,0 +1,424 @@ +/**************************************************************************** + * NCSA HDF * + * Scientific Data Technologies * + * National Center for Supercomputing Applications * + * University of Illinois at Urbana-Champaign * + * 605 E. Springfield, Champaign IL 61820 * + * * + * For conditions of distribution and use, see the accompanying * + * hdf/COPYING file. * + * * + ****************************************************************************/ +#include "H5IM.h" +#include "H5IMcc.h" +#include "H5f90i_gen.h" + + +#include +#include + + +/*------------------------------------------------------------------------- + * Function: H5IMmake_image_8bitf + * + * Purpose: Creates and writes an image an 8 bit image + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu + * + * Date: May 10, 2005 + * + * Comments: + * This function allows the creation and writing of an 8bit image on disk. + * The memory datatype is H5T_NATIVE_INT. It is supposed to be called from + * the FORTRAN interface where the image buffer is defined as type "integer" + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t H5IMmake_image_8bitf( hid_t loc_id, + const char *dset_name, + hsize_t width, + hsize_t height, + int_f *buf ) +{ + hid_t did; /* dataset ID */ + hid_t sid; /* space ID */ + hsize_t dims[IMAGE8_RANK]; /* dimensions */ + + /* initialize the image dimensions */ + dims[0] = height; + dims[1] = width; + dims[2] = 1; + +/*------------------------------------------------------------------------- + * create and write the dataset + *------------------------------------------------------------------------- + */ + + /* create the data space for the dataset. */ + if ((sid=H5Screate_simple(IMAGE8_RANK,dims,NULL))<0) + return -1; + + /* create the dataset as H5T_NATIVE_UCHAR */ + if ((did=H5Dcreate(loc_id,dset_name,H5T_NATIVE_UINT8,sid,H5P_DEFAULT))<0) + return -1; + + /* write with memory type H5T_NATIVE_INT */ + /* Use long type if Fortran integer is 8 bytes and C long long is also 8 bytes*/ + /* Fail if otherwise */ + if (buf) + { + if (sizeof(int_f) == sizeof(int)) { + if (H5Dwrite(did,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) + return -1;} + else if (sizeof(int_f) == sizeof(long)) { + if (H5Dwrite(did,H5T_NATIVE_LONG,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) + return -1;} + else if (sizeof(int_f) == sizeof(long_long)) { + if (H5Dwrite(did,H5T_NATIVE_LLONG,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) + return -1;} + else + return -1; + } + + /* close */ + if (H5Dclose(did)<0) + return -1; + if (H5Sclose(sid)<0) + return -1; + +/*------------------------------------------------------------------------- + * attach the specification attributes + *------------------------------------------------------------------------- + */ + + /* attach the CLASS attribute */ + if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", IMAGE_CLASS ) < 0 ) + return -1; + + /* attach the VERSION attribute */ + if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION ) < 0 ) + return -1; + + /* attach the IMAGE_SUBCLASS attribute */ + if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_INDEXED" ) < 0 ) + return -1; + + return 0; +} + + + +/*------------------------------------------------------------------------- + * Function: H5IMmake_image_24bitf + * + * Purpose: + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu + * + * Date: May 10, 2005 + * + * Comments: + * This function allows the creation and writing of an 8bit image on disk. + * The memory datatype is H5T_NATIVE_INT. It is supposed to be called from + * the FORTRAN interface where the image buffer is defined as type "integer" + * + * Interlace Mode Dimensions in the Dataspace + * INTERLACE_PIXEL [height][width][pixel components] + * INTERLACE_PLANE [pixel components][height][width] + * + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t H5IMmake_image_24bitf( hid_t loc_id, + const char *dset_name, + hsize_t width, + hsize_t height, + const char *interlace, + int_f *buf) +{ + hid_t did; /* dataset ID */ + hid_t sid; /* space ID */ + hsize_t dims[IMAGE24_RANK]; /* dimensions */ + +/*------------------------------------------------------------------------- + * attach the image dimensions according to the interlace mode + *------------------------------------------------------------------------- + */ + if ( strcmp( interlace, "INTERLACE_PIXEL" ) == 0 ) + { + /* Number of color planes is defined as the third dimension */ + dims[0] = height; + dims[1] = width; + dims[2] = IMAGE24_RANK; + } + else + if ( strcmp( interlace, "INTERLACE_PLANE" ) == 0 ) + { + /* Number of color planes is defined as the first dimension */ + dims[0] = IMAGE24_RANK; + dims[1] = height; + dims[2] = width; + } + else return -1; + +/*------------------------------------------------------------------------- + * create and write the dataset + *------------------------------------------------------------------------- + */ + + /* create the data space for the dataset. */ + if ((sid=H5Screate_simple(IMAGE24_RANK,dims,NULL))<0) + return -1; + + /* create the dataset as H5T_NATIVE_UCHAR */ + if ((did=H5Dcreate(loc_id,dset_name,H5T_NATIVE_UCHAR,sid,H5P_DEFAULT))<0) + return -1; + + /* write with memory type H5T_NATIVE_INT */ + if (buf) + { + if (sizeof(int_f) == sizeof(int)) { + if (H5Dwrite(did,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) + return -1;} + else if (sizeof(int_f) == sizeof(long)) { + if (H5Dwrite(did,H5T_NATIVE_LONG,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) + return -1;} + else if (sizeof(int_f) == sizeof(long_long)) { + if (H5Dwrite(did,H5T_NATIVE_LLONG,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) + return -1;} + else + return -1; + } + + /* close */ + if (H5Dclose(did)<0) + return -1; + if (H5Sclose(sid)<0) + return -1; + +/*------------------------------------------------------------------------- + * attach the specification attributes + *------------------------------------------------------------------------- + */ + + /* Attach the CLASS attribute */ + if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", IMAGE_CLASS ) < 0 ) + return -1; + + /* Attach the VERSION attribute */ + if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION ) < 0 ) + return -1; + + /* Attach the IMAGE_SUBCLASS attribute */ + if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_TRUECOLOR" ) < 0 ) + return -1; + + /* Attach the INTERLACE_MODE attribute. This attributes is only for true color images */ + if ( H5LTset_attribute_string( loc_id, dset_name, "INTERLACE_MODE", interlace ) < 0 ) + return -1; + + return 0; + +} + + +/*------------------------------------------------------------------------- + * Function: H5IMread_imagef + * + * Purpose: Reads image data from disk. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu + * + * Date: May 10, 2005 + * + * Comments: + * This function allows reading of an 8bit image on disk. + * The memory datatype is H5T_NATIVE_INT. It is supposed to be called from + * the FORTRAN interface where the image buffer is defined as type "integer" + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t H5IMread_imagef( hid_t loc_id, + const char *dset_name, + int_f *buf ) +{ + hid_t did; + + /* open the dataset */ + if ( (did = H5Dopen( loc_id, dset_name )) < 0 ) + return -1; + + /* read to memory type H5T_NATIVE_INT */ + if (sizeof(int_f) == sizeof(int)){ + if ( H5Dread( did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf ) < 0 ) + goto out;} + else if (sizeof(int_f) == sizeof(long)) { + if ( H5Dread( did, H5T_NATIVE_LONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf ) < 0 ) + goto out;} + else if (sizeof(int_f) == sizeof(long_long)) { + if ( H5Dread( did, H5T_NATIVE_LLONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf ) < 0 ) + goto out;} + else + goto out; + + /* close */ + if ( H5Dclose( did ) ) + return -1; + return 0; + +out: + H5Dclose( did ); + return -1; + +} + + +/*------------------------------------------------------------------------- + * Function: H5IMmake_palettef + * + * Purpose: Creates and writes a palette. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu + * + * Date: May 10, 2005 + * + * Comments: + * This function allows writing of an 8bit palette to disk. + * The memory datatype is H5T_NATIVE_INT. It is supposed to be called from + * the FORTRAN interface where the image buffer is defined as type "integer" + * + * based on HDF5 Image and Palette Specification + * http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t H5IMmake_palettef( hid_t loc_id, + const char *pal_name, + const hsize_t *pal_dims, + int_f *pal_data ) + +{ + + hid_t did; /* dataset ID */ + hid_t sid; /* space ID */ + int has_pal; + + /* Check if the dataset already exists */ + has_pal = H5LTfind_dataset( loc_id, pal_name ); + + /* It exists. Return */ + if ( has_pal == 1 ) + return 0; + +/*------------------------------------------------------------------------- + * create and write the dataset + *------------------------------------------------------------------------- + */ + + /* create the data space for the dataset. */ + if ((sid=H5Screate_simple(2,pal_dims,NULL))<0) + return -1; + + /* create the dataset as H5T_NATIVE_UCHAR */ + if ((did=H5Dcreate(loc_id,pal_name,H5T_NATIVE_UCHAR,sid,H5P_DEFAULT))<0) + return -1; + + /* write with memory type H5T_NATIVE_INT */ + if (pal_data) + { + if (sizeof(int_f) == sizeof(int)) { + if (H5Dwrite(did,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,pal_data)<0) + return -1;} + else if (sizeof(int_f) == sizeof(long)) { + if (H5Dwrite(did,H5T_NATIVE_LONG,H5S_ALL,H5S_ALL,H5P_DEFAULT,pal_data)<0) + return -1;} + else if (sizeof(int_f) == sizeof(long_long)) { + if (H5Dwrite(did,H5T_NATIVE_LLONG,H5S_ALL,H5S_ALL,H5P_DEFAULT,pal_data)<0) + return -1;} + else + return -1; + } + + /* close */ + if (H5Dclose(did)<0) + return -1; + if (H5Sclose(sid)<0) + return -1; + +/*------------------------------------------------------------------------- + * attach the specification attributes + *------------------------------------------------------------------------- + */ + + /* Attach the attribute "CLASS" to the >>palette<< dataset*/ + if ( H5LTset_attribute_string( loc_id, pal_name, "CLASS", PALETTE_CLASS ) < 0 ) + return -1; + + /* Attach the attribute "PAL_VERSION" to the >>palette<< dataset*/ + if ( H5LTset_attribute_string( loc_id, pal_name, "PAL_VERSION", "1.2" ) < 0 ) + return -1; + + return 0; + +} + + +/*------------------------------------------------------------------------- + * Function: H5IMget_palettef + * + * Purpose: Read palette + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu + * + * Date: May 10, 2005 + * + * Comments: + * This function allows reading of an 8bit palette from disk. + * The memory datatype is H5T_NATIVE_INT. It is supposed to be called from + * the FORTRAN interface where the image buffer is defined as type "integer" + * + * based on HDF5 Image and Palette Specification + * http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t H5IMget_palettef( hid_t loc_id, + const char *image_name, + int pal_number, + int_f *pal_data ) +{ + if(sizeof(int_f) == sizeof(int)) + return H5IM_get_palette(loc_id,image_name,pal_number,H5T_NATIVE_INT,pal_data); + else if (sizeof(int_f) == sizeof(long)) + return H5IM_get_palette(loc_id,image_name,pal_number,H5T_NATIVE_LONG,pal_data); + else if (sizeof(int_f) == sizeof(long_long)) + return H5IM_get_palette(loc_id,image_name,pal_number,H5T_NATIVE_LLONG,pal_data); + else + return -1; + +} diff --git a/hl/fortran/src/H5IMcc.h b/hl/fortran/src/H5IMcc.h new file mode 100644 index 0000000..32c79ff --- /dev/null +++ b/hl/fortran/src/H5IMcc.h @@ -0,0 +1,66 @@ + +/**************************************************************************** + * NCSA HDF * + * Scientific Data Technologies * + * National Center for Supercomputing Applications * + * University of Illinois at Urbana-Champaign * + * 605 E. Springfield, Champaign IL 61820 * + * * + * For conditions of distribution and use, see the accompanying * + * hdf/COPYING file. * + * * + ****************************************************************************/ + + +#ifndef _H5IMCC_H +#define _H5IMCC_H + +#include "H5LT.h" +#include "H5IM.h" +#include "../../fortran/src/H5f90i_gen.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define IMAGE_CLASS "IMAGE" +#define PALETTE_CLASS "PALETTE" +#define IMAGE_VERSION "1.2" +#define IMAGE8_RANK 3 +#define IMAGE24_RANK 3 + + + +herr_t H5IMmake_image_8bitf( hid_t loc_id, + const char *dset_name, + hsize_t width, + hsize_t height, + int_f *buf ); + +herr_t H5IMmake_image_24bitf( hid_t loc_id, + const char *dset_name, + hsize_t width, + hsize_t height, + const char *interlace, + int_f *buf); + +herr_t H5IMread_imagef( hid_t loc_id, + const char *dset_name, + int_f *buf ); + +herr_t H5IMmake_palettef( hid_t loc_id, + const char *pal_name, + const hsize_t *pal_dims, + int_f *pal_data ); + +herr_t H5IMget_palettef( hid_t loc_id, + const char *image_name, + int pal_number, + int_f *pal_data ); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/hl/fortran/src/H5LTfc.c b/hl/fortran/src/H5LTfc.c index 15733ab..6078b23 100755 --- a/hl/fortran/src/H5LTfc.c +++ b/hl/fortran/src/H5LTfc.c @@ -305,7 +305,7 @@ nh5ltset_attribute_int_c(hid_t_f *loc_id, ret = H5LTset_attribute_int(c_loc_id,c_name,c_attrname,buf,c_size); else if (sizeof(int_f) == sizeof(long)) ret = H5LTset_attribute_long(c_loc_id,c_name,c_attrname,buf,c_size); - else if (sizeof(int_f) == sizeof(long long)) + else if (sizeof(int_f) == sizeof(long_long)) ret = H5LTset_attribute_long_long(c_loc_id,c_name,c_attrname,buf,c_size); else return ret_value; @@ -551,7 +551,7 @@ nh5ltget_attribute_int_c(hid_t_f *loc_id, ret = H5LTget_attribute_int(c_loc_id,c_name,c_attrname,buf); else if (sizeof(int_f) == sizeof(long)) ret = H5LTget_attribute_long(c_loc_id,c_name,c_attrname,buf); - else if (sizeof(int_f) == sizeof(long long)) + else if (sizeof(int_f) == sizeof(long_long)) ret = H5LTget_attribute_long_long(c_loc_id,c_name,c_attrname,buf); else return ret_value; diff --git a/hl/fortran/src/Makefile.am b/hl/fortran/src/Makefile.am index 7d06024..1462fbb 100644 --- a/hl/fortran/src/Makefile.am +++ b/hl/fortran/src/Makefile.am @@ -22,14 +22,14 @@ AM_LDFLAGS=-static lib_LTLIBRARIES=libhdf5hl_fortran.la # Source files for the library -if BUILD_PARALLEL_CONDITIONAL - PARALLEL_COND_SRC=HDFDmpiof.c HDF5mpio.f90 -endif +#if BUILD_PARALLEL_CONDITIONAL +# PARALLEL_COND_SRC=HDFDmpiof.c HDF5mpio.f90 +#endif -libhdf5hl_fortran_la_SOURCES=H5LTfc.c H5IMfc.c H5TBfc.c H5LTff.f90 \ +libhdf5hl_fortran_la_SOURCES=H5LTfc.c H5IMfc.c H5IMcc.c H5TBfc.c H5LTff.f90 \ H5IMff.f90 H5TBff.f90 -libhdf5hl_fortran_la_LIBADD=$(LIBH5_HL) +#libhdf5hl_fortran_la_LIBADD=$(LIBH5_HL) # Fortran module files can have different extensions and different names # (e.g., different capitalizations) on different platforms. Write rules diff --git a/hl/fortran/src/Makefile.in b/hl/fortran/src/Makefile.in index a7ee379..0fdf5cf 100644 --- a/hl/fortran/src/Makefile.in +++ b/hl/fortran/src/Makefile.in @@ -65,10 +65,9 @@ am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; am__installdirs = "$(DESTDIR)$(libdir)" libLTLIBRARIES_INSTALL = $(INSTALL) LTLIBRARIES = $(lib_LTLIBRARIES) -am__DEPENDENCIES_1 = $(top_builddir)/hl/src/libhdf5_hl.la -libhdf5hl_fortran_la_DEPENDENCIES = $(am__DEPENDENCIES_1) -am_libhdf5hl_fortran_la_OBJECTS = H5LTfc.lo H5IMfc.lo H5TBfc.lo \ - H5LTff.lo H5IMff.lo H5TBff.lo +libhdf5hl_fortran_la_LIBADD = +am_libhdf5hl_fortran_la_OBJECTS = H5LTfc.lo H5IMfc.lo H5IMcc.lo \ + H5TBfc.lo H5LTff.lo H5IMff.lo H5TBff.lo libhdf5hl_fortran_la_OBJECTS = $(am_libhdf5hl_fortran_la_OBJECTS) DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/src depcomp = $(SHELL) $(top_srcdir)/bin/depcomp @@ -309,11 +308,12 @@ AM_LDFLAGS = -static lib_LTLIBRARIES = libhdf5hl_fortran.la # Source files for the library -@BUILD_PARALLEL_CONDITIONAL_TRUE@PARALLEL_COND_SRC = HDFDmpiof.c HDF5mpio.f90 -libhdf5hl_fortran_la_SOURCES = H5LTfc.c H5IMfc.c H5TBfc.c H5LTff.f90 \ +#if BUILD_PARALLEL_CONDITIONAL +# PARALLEL_COND_SRC=HDFDmpiof.c HDF5mpio.f90 +#endif +libhdf5hl_fortran_la_SOURCES = H5LTfc.c H5IMfc.c H5IMcc.c H5TBfc.c H5LTff.f90 \ H5IMff.f90 H5TBff.f90 -libhdf5hl_fortran_la_LIBADD = $(LIBH5_HL) # Automake needs to be taught how to build lib, progs, and tests targets. # These will be filled in automatically for the most part (e.g., @@ -396,6 +396,7 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5IMcc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5IMfc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5LTfc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5TBfc.Plo@am__quote@ @@ -617,6 +618,8 @@ uninstall-am: uninstall-info-am uninstall-libLTLIBRARIES \ uninstall-libLTLIBRARIES uninstall-local +#libhdf5hl_fortran_la_LIBADD=$(LIBH5_HL) + # Fortran module files can have different extensions and different names # (e.g., different capitalizations) on different platforms. Write rules # for them explicitly rather than trying to teach automake about them. diff --git a/hl/fortran/test/Makefile.am b/hl/fortran/test/Makefile.am index bbff539..8597e1f 100644 --- a/hl/fortran/test/Makefile.am +++ b/hl/fortran/test/Makefile.am @@ -11,7 +11,7 @@ include $(top_srcdir)/config/commence.am -AM_CPPFLAGS=-I$(top_srcdir)/src $(top_builddir)/src +AM_CPPFLAGS=-I$(top_srcdir)/src -I$(top_builddir)/src -I$(top_srcdir)/hl/src AM_FCFLAGS=-I$(top_builddir)/fortran/src -I$(top_builddir)/hl/fortran/src $(F9XMODFLAG)$(top_builddir)/fortran/src $(F9XMODFLAG)$(top_builddir)/hl/fortran/src # Fortran libraries are linked statically to solve a build problem. @@ -21,7 +21,7 @@ AM_LDFLAGS=-static TEST_PROG=tstlite tstimage tsttable check_PROGRAMS=$(TEST_PROG) -LDADD=$(LIBH5_HL) $(LIBH5F_HL) $(LIBH5F) $(LIBHDF5) +LDADD= $(LIBH5F_HL) $(LIBH5F) $(LIBH5_HL) $(LIBHDF5) # Source files for the programs tstlite_SOURCES=tstlite.f90 diff --git a/hl/fortran/test/Makefile.in b/hl/fortran/test/Makefile.in index a6bb76a..bcc5110 100644 --- a/hl/fortran/test/Makefile.in +++ b/hl/fortran/test/Makefile.in @@ -60,10 +60,10 @@ am__EXEEXT_1 = tstlite$(EXEEXT) tstimage$(EXEEXT) tsttable$(EXEEXT) am_tstimage_OBJECTS = tstimage.$(OBJEXT) tstimage_OBJECTS = $(am_tstimage_OBJECTS) tstimage_LDADD = $(LDADD) -am__DEPENDENCIES_1 = $(top_builddir)/hl/src/libhdf5_hl.la -am__DEPENDENCIES_2 = \ +am__DEPENDENCIES_1 = \ $(top_builddir)/hl/fortran/src/libhdf5hl_fortran.la -am__DEPENDENCIES_3 = $(top_builddir)/fortran/src/libhdf5_fortran.la +am__DEPENDENCIES_2 = $(top_builddir)/fortran/src/libhdf5_fortran.la +am__DEPENDENCIES_3 = $(top_builddir)/hl/src/libhdf5_hl.la am__DEPENDENCIES_4 = $(top_builddir)/src/libhdf5.la tstimage_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \ $(am__DEPENDENCIES_3) $(am__DEPENDENCIES_4) @@ -295,7 +295,7 @@ H5CC = $(bindir)/h5cc H5CC_PP = $(bindir)/h5pcc H5FC = $(bindir)/h5fc H5FC_PP = $(bindir)/h5pfc -AM_CPPFLAGS = -I$(top_srcdir)/src $(top_builddir)/src +AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_builddir)/src -I$(top_srcdir)/hl/src AM_FCFLAGS = -I$(top_builddir)/fortran/src -I$(top_builddir)/hl/fortran/src $(F9XMODFLAG)$(top_builddir)/fortran/src $(F9XMODFLAG)$(top_builddir)/hl/fortran/src # Fortran libraries are linked statically to solve a build problem. @@ -303,7 +303,7 @@ AM_LDFLAGS = -static # Our main target, the test programs TEST_PROG = tstlite tstimage tsttable -LDADD = $(LIBH5_HL) $(LIBH5F_HL) $(LIBH5F) $(LIBHDF5) +LDADD = $(LIBH5F_HL) $(LIBH5F) $(LIBH5_HL) $(LIBHDF5) # Source files for the programs tstlite_SOURCES = tstlite.f90 diff --git a/hl/src/H5IM.c b/hl/src/H5IM.c index a6709c0..71841a9 100644 --- a/hl/src/H5IM.c +++ b/hl/src/H5IM.c @@ -11,7 +11,6 @@ ****************************************************************************/ #include "H5IM.h" -#include "../../fortran/src/H5f90i_gen.h" #include @@ -21,13 +20,11 @@ * private functions *------------------------------------------------------------------------- */ -static herr_t H5IM_get_palette( hid_t loc_id, const char *image_name, int pal_number, hid_t tid, - int_f *pal_data); - + void *pal_data); /*------------------------------------------------------------------------- * Function: H5IMmake_image_8bit @@ -1268,412 +1265,6 @@ out: } - -/*------------------------------------------------------------------------- - * Function: H5IMmake_image_8bitf - * - * Purpose: Creates and writes an image an 8 bit image - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu - * - * Date: May 10, 2005 - * - * Comments: - * This function allows the creation and writing of an 8bit image on disk. - * The memory datatype is H5T_NATIVE_INT. It is supposed to be called from - * the FORTRAN interface where the image buffer is defined as type "integer" - * - * Modifications: - * - *------------------------------------------------------------------------- - */ - -herr_t H5IMmake_image_8bitf( hid_t loc_id, - const char *dset_name, - hsize_t width, - hsize_t height, - int_f *buf ) -{ - hid_t did; /* dataset ID */ - hid_t sid; /* space ID */ - hsize_t dims[IMAGE8_RANK]; /* dimensions */ - - /* initialize the image dimensions */ - dims[0] = height; - dims[1] = width; - dims[2] = 1; - -/*------------------------------------------------------------------------- - * create and write the dataset - *------------------------------------------------------------------------- - */ - - /* create the data space for the dataset. */ - if ((sid=H5Screate_simple(IMAGE8_RANK,dims,NULL))<0) - return -1; - - /* create the dataset as H5T_NATIVE_UCHAR */ - if ((did=H5Dcreate(loc_id,dset_name,H5T_NATIVE_UINT8,sid,H5P_DEFAULT))<0) - return -1; - - /* write with memory type H5T_NATIVE_INT */ - /* Use long type if Fortran integer is 8 bytes and C long long is also 8 bytes*/ - /* Fail if otherwise */ - if (buf) - { - if (sizeof(int_f) == sizeof(int)) { - if (H5Dwrite(did,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) - return -1;} - else if (sizeof(int_f) == sizeof(long)) { - if (H5Dwrite(did,H5T_NATIVE_LONG,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) - return -1;} - else if (sizeof(int_f) == sizeof(long long)) { - if (H5Dwrite(did,H5T_NATIVE_LLONG,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) - return -1;} - else - return -1; - } - - /* close */ - if (H5Dclose(did)<0) - return -1; - if (H5Sclose(sid)<0) - return -1; - -/*------------------------------------------------------------------------- - * attach the specification attributes - *------------------------------------------------------------------------- - */ - - /* attach the CLASS attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", IMAGE_CLASS ) < 0 ) - return -1; - - /* attach the VERSION attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION ) < 0 ) - return -1; - - /* attach the IMAGE_SUBCLASS attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_INDEXED" ) < 0 ) - return -1; - - return 0; -} - - - -/*------------------------------------------------------------------------- - * Function: H5IMmake_image_24bitf - * - * Purpose: - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu - * - * Date: May 10, 2005 - * - * Comments: - * This function allows the creation and writing of an 8bit image on disk. - * The memory datatype is H5T_NATIVE_INT. It is supposed to be called from - * the FORTRAN interface where the image buffer is defined as type "integer" - * - * Interlace Mode Dimensions in the Dataspace - * INTERLACE_PIXEL [height][width][pixel components] - * INTERLACE_PLANE [pixel components][height][width] - * - * - * Modifications: - * - *------------------------------------------------------------------------- - */ - -herr_t H5IMmake_image_24bitf( hid_t loc_id, - const char *dset_name, - hsize_t width, - hsize_t height, - const char *interlace, - int_f *buf) -{ - hid_t did; /* dataset ID */ - hid_t sid; /* space ID */ - hsize_t dims[IMAGE24_RANK]; /* dimensions */ - -/*------------------------------------------------------------------------- - * attach the image dimensions according to the interlace mode - *------------------------------------------------------------------------- - */ - if ( strcmp( interlace, "INTERLACE_PIXEL" ) == 0 ) - { - /* Number of color planes is defined as the third dimension */ - dims[0] = height; - dims[1] = width; - dims[2] = IMAGE24_RANK; - } - else - if ( strcmp( interlace, "INTERLACE_PLANE" ) == 0 ) - { - /* Number of color planes is defined as the first dimension */ - dims[0] = IMAGE24_RANK; - dims[1] = height; - dims[2] = width; - } - else return -1; - -/*------------------------------------------------------------------------- - * create and write the dataset - *------------------------------------------------------------------------- - */ - - /* create the data space for the dataset. */ - if ((sid=H5Screate_simple(IMAGE24_RANK,dims,NULL))<0) - return -1; - - /* create the dataset as H5T_NATIVE_UCHAR */ - if ((did=H5Dcreate(loc_id,dset_name,H5T_NATIVE_UCHAR,sid,H5P_DEFAULT))<0) - return -1; - - /* write with memory type H5T_NATIVE_INT */ - if (buf) - { - if (sizeof(int_f) == sizeof(int)) { - if (H5Dwrite(did,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) - return -1;} - else if (sizeof(int_f) == sizeof(long)) { - if (H5Dwrite(did,H5T_NATIVE_LONG,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) - return -1;} - else if (sizeof(int_f) == sizeof(long long)) { - if (H5Dwrite(did,H5T_NATIVE_LLONG,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) - return -1;} - else - return -1; - } - - /* close */ - if (H5Dclose(did)<0) - return -1; - if (H5Sclose(sid)<0) - return -1; - -/*------------------------------------------------------------------------- - * attach the specification attributes - *------------------------------------------------------------------------- - */ - - /* Attach the CLASS attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", IMAGE_CLASS ) < 0 ) - return -1; - - /* Attach the VERSION attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION ) < 0 ) - return -1; - - /* Attach the IMAGE_SUBCLASS attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_TRUECOLOR" ) < 0 ) - return -1; - - /* Attach the INTERLACE_MODE attribute. This attributes is only for true color images */ - if ( H5LTset_attribute_string( loc_id, dset_name, "INTERLACE_MODE", interlace ) < 0 ) - return -1; - - return 0; - -} - - -/*------------------------------------------------------------------------- - * Function: H5IMread_imagef - * - * Purpose: Reads image data from disk. - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu - * - * Date: May 10, 2005 - * - * Comments: - * This function allows reading of an 8bit image on disk. - * The memory datatype is H5T_NATIVE_INT. It is supposed to be called from - * the FORTRAN interface where the image buffer is defined as type "integer" - * - * Modifications: - * - *------------------------------------------------------------------------- - */ - -herr_t H5IMread_imagef( hid_t loc_id, - const char *dset_name, - int_f *buf ) -{ - hid_t did; - - /* open the dataset */ - if ( (did = H5Dopen( loc_id, dset_name )) < 0 ) - return -1; - - /* read to memory type H5T_NATIVE_INT */ - if (sizeof(int_f) == sizeof(int)){ - if ( H5Dread( did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf ) < 0 ) - goto out;} - else if (sizeof(int_f) == sizeof(long)) { - if ( H5Dread( did, H5T_NATIVE_LONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf ) < 0 ) - goto out;} - else if (sizeof(int_f) == sizeof(long long)) { - if ( H5Dread( did, H5T_NATIVE_LLONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf ) < 0 ) - goto out;} - else - goto out; - - /* close */ - if ( H5Dclose( did ) ) - return -1; - return 0; - -out: - H5Dclose( did ); - return -1; - -} - - -/*------------------------------------------------------------------------- - * Function: H5IMmake_palettef - * - * Purpose: Creates and writes a palette. - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu - * - * Date: May 10, 2005 - * - * Comments: - * This function allows writing of an 8bit palette to disk. - * The memory datatype is H5T_NATIVE_INT. It is supposed to be called from - * the FORTRAN interface where the image buffer is defined as type "integer" - * - * based on HDF5 Image and Palette Specification - * http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html - * - * Modifications: - * - *------------------------------------------------------------------------- - */ - -herr_t H5IMmake_palettef( hid_t loc_id, - const char *pal_name, - const hsize_t *pal_dims, - int_f *pal_data ) - -{ - - hid_t did; /* dataset ID */ - hid_t sid; /* space ID */ - int has_pal; - - /* Check if the dataset already exists */ - has_pal = H5LTfind_dataset( loc_id, pal_name ); - - /* It exists. Return */ - if ( has_pal == 1 ) - return 0; - -/*------------------------------------------------------------------------- - * create and write the dataset - *------------------------------------------------------------------------- - */ - - /* create the data space for the dataset. */ - if ((sid=H5Screate_simple(2,pal_dims,NULL))<0) - return -1; - - /* create the dataset as H5T_NATIVE_UCHAR */ - if ((did=H5Dcreate(loc_id,pal_name,H5T_NATIVE_UCHAR,sid,H5P_DEFAULT))<0) - return -1; - - /* write with memory type H5T_NATIVE_INT */ - if (pal_data) - { - if (sizeof(int_f) == sizeof(int)) { - if (H5Dwrite(did,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,pal_data)<0) - return -1;} - else if (sizeof(int_f) == sizeof(long)) { - if (H5Dwrite(did,H5T_NATIVE_LONG,H5S_ALL,H5S_ALL,H5P_DEFAULT,pal_data)<0) - return -1;} - else if (sizeof(int_f) == sizeof(long long)) { - if (H5Dwrite(did,H5T_NATIVE_LLONG,H5S_ALL,H5S_ALL,H5P_DEFAULT,pal_data)<0) - return -1;} - else - return -1; - } - - /* close */ - if (H5Dclose(did)<0) - return -1; - if (H5Sclose(sid)<0) - return -1; - -/*------------------------------------------------------------------------- - * attach the specification attributes - *------------------------------------------------------------------------- - */ - - /* Attach the attribute "CLASS" to the >>palette<< dataset*/ - if ( H5LTset_attribute_string( loc_id, pal_name, "CLASS", PALETTE_CLASS ) < 0 ) - return -1; - - /* Attach the attribute "PAL_VERSION" to the >>palette<< dataset*/ - if ( H5LTset_attribute_string( loc_id, pal_name, "PAL_VERSION", "1.2" ) < 0 ) - return -1; - - return 0; - -} - - -/*------------------------------------------------------------------------- - * Function: H5IMget_palettef - * - * Purpose: Read palette - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu - * - * Date: May 10, 2005 - * - * Comments: - * This function allows reading of an 8bit palette from disk. - * The memory datatype is H5T_NATIVE_INT. It is supposed to be called from - * the FORTRAN interface where the image buffer is defined as type "integer" - * - * based on HDF5 Image and Palette Specification - * http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html - * - * Modifications: - * - *------------------------------------------------------------------------- - */ - -herr_t H5IMget_palettef( hid_t loc_id, - const char *image_name, - int pal_number, - int_f *pal_data ) -{ - if(sizeof(int_f) == sizeof(int)) - return H5IM_get_palette(loc_id,image_name,pal_number,H5T_NATIVE_INT,pal_data); - else if (sizeof(int_f) == sizeof(long)) - return H5IM_get_palette(loc_id,image_name,pal_number,H5T_NATIVE_LONG,pal_data); - else if (sizeof(int_f) == sizeof(long long)) - return H5IM_get_palette(loc_id,image_name,pal_number,H5T_NATIVE_LLONG,pal_data); - else - return -1; - -} - /*------------------------------------------------------------------------- * Function: H5IM_get_palette * @@ -1700,13 +1291,11 @@ herr_t H5IMget_palettef( hid_t loc_id, * *------------------------------------------------------------------------- */ - -static herr_t H5IM_get_palette( hid_t loc_id, const char *image_name, int pal_number, hid_t tid, - int_f *pal_data) + void *pal_data) { hid_t image_id; int has_pal; @@ -1793,4 +1382,5 @@ out: H5Dclose( image_id ); return -1; + } diff --git a/hl/src/H5IM.h b/hl/src/H5IM.h index 27359dd..aaec421 100644 --- a/hl/src/H5IM.h +++ b/hl/src/H5IM.h @@ -16,7 +16,6 @@ #define _H5IM_H #include "H5LT.h" -#include "../../fortran/src/H5f90i_gen.h" #ifdef __cplusplus extern "C" { @@ -90,32 +89,8 @@ herr_t H5IMis_image( hid_t loc_id, herr_t H5IMis_palette( hid_t loc_id, const char *dset_name ); -herr_t H5IMmake_image_8bitf( hid_t loc_id, - const char *dset_name, - hsize_t width, - hsize_t height, - int_f *buf ); - -herr_t H5IMmake_image_24bitf( hid_t loc_id, - const char *dset_name, - hsize_t width, - hsize_t height, - const char *interlace, - int_f *buf); - -herr_t H5IMread_imagef( hid_t loc_id, - const char *dset_name, - int_f *buf ); - -herr_t H5IMmake_palettef( hid_t loc_id, - const char *pal_name, - const hsize_t *pal_dims, - int_f *pal_data ); - -herr_t H5IMget_palettef( hid_t loc_id, - const char *image_name, - int pal_number, - int_f *pal_data ); +herr_t H5IM_find_palette( hid_t loc_id ); + #ifdef __cplusplus diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c index acee4a7..8a19083 100644 --- a/hl/src/H5LT.c +++ b/hl/src/H5LT.c @@ -1571,8 +1571,7 @@ herr_t H5LTset_attribute_long( hid_t loc_id, * * Date: June 17, 2005 * - * Comments: This function was added to support 8-bytes int_f type that - * may correspond to INTEGER*8 in Fortran + * Comments: This function was added to support attributes of type long long * *------------------------------------------------------------------------- */ @@ -1580,7 +1579,7 @@ herr_t H5LTset_attribute_long( hid_t loc_id, herr_t H5LTset_attribute_long_long( hid_t loc_id, const char *obj_name, const char *attr_name, - const long long *data, + const long_long *data, size_t size ) { @@ -2495,7 +2494,6 @@ herr_t H5LTget_attribute_long_long( hid_t loc_id, } -/*------------------------------------------------------------------------- /*------------------------------------------------------------------------- * Function: H5LTget_attribute_ulong diff --git a/hl/src/H5LT.h b/hl/src/H5LT.h index 63f9c8e..9b50db3 100644 --- a/hl/src/H5LT.h +++ b/hl/src/H5LT.h @@ -214,7 +214,7 @@ herr_t H5LTset_attribute_long( hid_t loc_id, herr_t H5LTset_attribute_long_long( hid_t loc_id, const char *obj_name, const char *attr_name, - const long long *buffer, + const long_long *buffer, size_t size ); herr_t H5LTset_attribute_ulong( hid_t loc_id, -- cgit v0.12