diff --git a/.gitattributes b/.gitattributes
index e1e127f..dd71303 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -23,15 +23,15 @@ doc/doxyfooter -text
/missing -text
/rules.make -text
src/H5Block.c -text
+src/H5Block.f90 -text
src/H5Block.h -text
src/H5BlockErrors.h -text
src/H5BlockF.c -text
-src/H5BlockF90.inc -text
src/H5BlockPrivate.h -text
src/H5BlockReadWrite.c -text
+src/H5BlockReadWrite.f90 -text
src/H5BlockReadWrite.h -text
src/H5BlockReadWriteF.c -text
-src/H5BlockReadWriteF90.inc -text
src/H5BlockTypes.h -text
src/H5MultiBlock.c -text
src/H5MultiBlock.h -text
@@ -41,15 +41,20 @@ src/H5MultiBlockReadWrite.c -text
src/H5MultiBlockReadWrite.h -text
src/H5MultiBlockTypes.h -text
src/H5Part.c -text
+src/H5Part.f90 -text
src/H5Part.h -text
+src/H5PartAttrib.c -text
+src/H5PartAttrib.f90 -text
+src/H5PartAttrib.h -text
+src/H5PartAttribF.c -text
src/H5PartErrors.h -text
src/H5PartF.c -text
-src/H5PartF90.inc -text
src/H5PartPrivate.h -text
src/H5PartTypes.h -text
src/Makefile.am -text
src/TestUnderscore.f -text
src/TestUnderscoreC.c -text
+src/generate-attr.py -text
src/generate-h5bl-readwrite.py -text
src/generate-h5multi-readwrite.py -text
test/Bench.c -text
@@ -68,6 +73,13 @@ test/H5test.cc -text
test/H5testF.f -text
test/H5testFpar.F90 -text
test/Makefile.am -text
+test/params.h -text
+test/test.c -text
+test/testframe.c -text
+test/testframe.h -text
+test/write.c -text
+tools/H5BlockBench.c -text
+tools/H5PartBench.c -text
tools/Makefile.am -text
tools/README -text
tools/h5pAttrib.cc -text
diff --git a/configure.ac b/configure.ac
index 252e946..9f935d4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -79,7 +79,6 @@ SAVE_MPIFC=$MPIFC
SAVE_MPILIB=$MPILIB
SAVE_MPIINC=$MPIINC
SAVE_CFLAGS=$CFLAGS
-CFLAGS=''
SAVE_FFLAGS=$FFLAGS
SAVE_MPIROOT=$MPIROOT
SAVE_HDF5ROOT=$HDF5ROOT
@@ -392,15 +391,15 @@ if test "X$USE_PARALLEL" = "Xyes"; then
fi
MTARGET="libpH5Part.a"
- TTARGET="H5PartTestP H5PartAndreasTest Bench"
- TTARGET="${TTARGET} H5BlockTestAttributes"
- TTARGET="${TTARGET} H5BlockParTestScalarField"
+ TTARGET="test"
# parallel + fortran
if test "X$USE_FORTRAN" = "Xyes"; then
AC_PATH_PROGS([MPIFC], [mpxlf_r mpif90], [], [$PATH])
+ FFLAGS="${FFLAGS} -DPARALLEL_IO"
+
if test -z "${MPIFC}" ; then
if test -e "${MPIROOT}/bin/mpif90"; then
MPIFC=${MPIROOT}/bin/mpif90
@@ -419,28 +418,29 @@ if test "X$USE_PARALLEL" = "Xyes"; then
fi
MTARGET="${MTARGET} libpH5PartF.a"
- TTARGET="${TTARGET} H5testFpar"
- TTARGET="${TTARGET} H5BlockParTestScalarFieldF"
+ TTARGET="${TTARGET} testf"
fi
else # --enable-parallel=no
AC_MSG_RESULT([no])
MTARGET="libH5Part.a"
- TTARGET="H5PartTest H5test"
- TTARGET="${TTARGET} H5BlockTestAttributes"
+ TTARGET="test"
if test "X$USE_FORTRAN" = "Xyes"; then
MTARGET="${MTARGET} libH5PartF.a"
- TTARGET="${TTARGET} H5testF"
- TTARGET="${TTARGET} H5BlockTestAttributesF"
- fi
+ TTARGET="${TTARGET} testf"
+ fi
fi
-AC_MSG_CHECKING([wheter tools are enabled])
+AC_MSG_CHECKING([whether tools are enabled])
if test "X$USE_TOOLS" = "Xyes"; then
AC_MSG_RESULT([yes])
- BUILD_TOOLS="h5pAttrib h5pToGNUplot # homdynToH5p"
+ BUILD_TOOLS="h5pAttrib h5pToGNUplot homdynToH5p"
+ # tools + parallel
+ if test "X$USE_PARALLEL" = "Xyes"; then
+ BUILD_TOOLS="${BUILD_TOOLS} H5PartBench H5BlockBench"
+ fi
else
AC_MSG_RESULT([no])
fi
@@ -506,6 +506,8 @@ if test -n "$ZLIBROOT"; then
LDFLAGS="$LDFLAGS -L$ZLIBROOT/lib"
fi
+FCFLAGS=${FFLAGS}
+
###############################################################################
#################### MISC SETTINGS - path, flags, etc #########################
@@ -570,16 +572,6 @@ if test -n "$SAVE_LDFLAGS"; then
LDFLAGS=$SAVE_LDFLAGS
fi
-if test -n "$MPICXX"; then
-TOOLS_CXX=$MPICXX
-TOOLS_H5PART_LIB="-lpH5Part"
-TOOLS_HDFLIB="-L$HDF5ROOT/lib -lhdf5"
-else
-TOOLS_CXX=$CXX
-TOOLS_H5PART_LIB="-lH5Part"
-TOOLS_HDFLIB="-L$HDF5ROOT/lib -lhdf5"
-fi
-
###############################################################################
############## EXPORTING VARIABLES & CREATING OUTPUT FILES ####################
###############################################################################
@@ -607,9 +599,6 @@ AC_SUBST(H5P_LIB_LOC)
AC_SUBST(UNDERSCORE_H)
AC_SUBST(BUILD_TOOLS)
AC_SUBST(LDFLAGS)
-AC_SUBST(TOOLS_CXX)
-AC_SUBST(TOOLS_H5PART_LIB)
-AC_SUBST(TOOLS_HDFLIB)
# Make AC_OUTPUT create each `file' by copying an input file (by default `file.in'),
# substituting the output variable values.
diff --git a/doc/Doxyfile b/doc/Doxyfile
index 8f1ad71..c06cfb8 100644
--- a/doc/Doxyfile
+++ b/doc/Doxyfile
@@ -58,8 +58,8 @@ HIDE_SCOPE_NAMES = NO
SHOW_INCLUDE_FILES = NO
INLINE_INFO = YES
SORT_MEMBER_DOCS = YES
-SORT_BRIEF_DOCS = NO
-SORT_BY_SCOPE_NAME = NO
+SORT_BRIEF_DOCS = YES
+SORT_BY_SCOPE_NAME = YES
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
@@ -83,10 +83,15 @@ WARN_LOGFILE =
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT += ../src/H5Part.c
+INPUT += ../src/H5PartAttrib.c
INPUT += ../src/H5Block.c
-INPUT += ../src/H5MultiBlock.c
INPUT += ../src/H5BlockReadWrite.c
+INPUT += ../src/H5MultiBlock.c
INPUT += ../src/H5MultiBlockReadWrite.c
+INPUT += ../src/H5Part.f90
+INPUT += ../src/H5PartAttrib.f90
+INPUT += ../src/H5Block.f90
+INPUT += ../src/H5BlockReadWrite.f90
FILE_PATTERNS =
RECURSIVE = YES
EXCLUDE =
@@ -200,7 +205,7 @@ SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::additions related to external references
#---------------------------------------------------------------------------
-TAGFILES = YES
+TAGFILES =
GENERATE_TAGFILE =
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
@@ -208,12 +213,12 @@ PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
-CLASS_DIAGRAMS = YES
-HIDE_UNDOC_RELATIONS = YES
-HAVE_DOT = YES
-CLASS_GRAPH = YES
-COLLABORATION_GRAPH = YES
-GROUP_GRAPHS = YES
+CLASS_DIAGRAMS = NO
+HIDE_UNDOC_RELATIONS = NO
+HAVE_DOT = NO
+CLASS_GRAPH = NO
+COLLABORATION_GRAPH = NO
+GROUP_GRAPHS = NO
UML_LOOK = NO
TEMPLATE_RELATIONS = NO
INCLUDE_GRAPH = NO
@@ -222,7 +227,7 @@ CALL_GRAPH = NO
GRAPHICAL_HIERARCHY = YES
DIRECTORY_GRAPH = YES
DOT_IMAGE_FORMAT = png
-DOT_PATH = /Applications/Graphviz.app/Contents/MacOS
+DOT_PATH =
DOTFILE_DIRS =
MAX_DOT_GRAPH_WIDTH = 1024
MAX_DOT_GRAPH_HEIGHT = 1024
diff --git a/src/H5Block.c b/src/H5Block.c
index 6eb9b59..b0bdaae 100644
--- a/src/H5Block.c
+++ b/src/H5Block.c
@@ -16,11 +16,11 @@
/*!
\ingroup h5block_c_api
- \defgroup h5block_write File Writing
+ \defgroup h5block_model Setting up the Data Model
*/
/*!
\ingroup h5block_c_api
- \defgroup h5block_read File Reading
+ \defgroup h5block_data Reading and Writing Datasets
*/
/*!
\ingroup h5block_c_api
@@ -81,7 +81,7 @@
*/
static h5part_int64_t
-_file_is_valid (
+_H5Block_file_is_valid (
const H5PartFile *f /*!< IN: file handle */
) {
@@ -114,7 +114,7 @@ _H5Block_init (
h5part_int64_t herr;
struct H5BlockStruct *b;
- herr = _file_is_valid ( f );
+ herr = _H5Block_file_is_valid ( f );
if ( herr == H5PART_SUCCESS ) return H5PART_SUCCESS;
if ( (f == 0) || (f->file == 0) ) return HANDLE_H5PART_BADFD_ERR;
@@ -719,7 +719,7 @@ _release_hyperslab (
}
/*!
- \ingroup h5block_write
+ \ingroup h5block_model
Define the field layout given the dense index space at the actual
time step.
@@ -770,7 +770,7 @@ H5BlockDefine3DFieldLayout(
}
/*!
- \ingroup h5block_write
+ \ingroup h5block_model
Define the chunk dimensions and enable chunking in the underlying
HDF5 dataset.
@@ -808,7 +808,7 @@ H5BlockDefine3DChunkDims(
}
/*!
- \ingroup h5block_read
+ \ingroup h5block_model
Lookup the chunk dimensions of the underlying HDF5 dataset.
@@ -867,7 +867,7 @@ H5BlockGet3DChunkDims(
}
/*!
- \ingroup h5block_read
+ \ingroup h5block_model
Return partition of processor \c proc as specified with
\c H5BlockDefine3dLayout().
@@ -907,7 +907,7 @@ H5Block3dGetPartitionOfProc (
}
/*!
- \ingroup h5block_read
+ \ingroup h5block_model
Return reduced (ghost-zone free) partition of processor \c proc
as specified with \c H5BlockDefine3dLayout().
@@ -948,7 +948,7 @@ H5Block3dGetReducedPartitionOfProc (
/*!
- \ingroup h5block_read
+ \ingroup h5block_model
Returns the processor computing the reduced (ghostzone-free)
partition given by the coordinates \c i, \c j and \c k.
@@ -1461,7 +1461,7 @@ _H5Block_write_data (
/********************** query information about available fields *************/
/*!
- \ingroup h5block_read
+ \ingroup h5block_model
Query number of fields in current time step.
@@ -1548,7 +1548,7 @@ _get_field_info (
}
/*!
- \ingroup h5block_read
+ \ingroup h5block_model
Get the name, rank and dimensions of the field specified by the
index \c idx.
@@ -1589,7 +1589,7 @@ H5BlockGetFieldInfo (
}
/*!
- \ingroup h5block_read
+ \ingroup h5block_model
Get the rank and dimensions of the field specified by its name.
@@ -1715,7 +1715,7 @@ H5BlockWriteFieldAttribString (
*/
h5part_int64_t
H5BlockGetNumFieldAttribs (
- H5PartFile *f, /*!< IN: file handle */
+ H5PartFile *f, /* \defgroup h5block_f90_api H5Block F90 API
+
+!> \ingroup h5block_f90_api
+!! \defgroup h5blockf_model Setting up the Data Model
+!<
+
+!> \ingroup h5block_f90_api
+!! \defgroup h5blockf_data Reading and Writing Datasets
+!<
+
+!> \ingroup h5block_f90_api
+!! \defgroup h5blockf_attrib Reading and Writing Attributes
+!<
+
+
+!!!!!!!! Setting up the Data Model !!!!!!!!
+
+!> \ingroup h5blockf_model
+!! See \ref H5BlockDefine3DFieldLayout
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_define3dlayout ( filehandle, i_start, i_end, j_start, j_end, k_start, k_end )
+ INTEGER*8, INTENT(IN) :: filehandle
+ INTEGER*8, INTENT(IN) :: i_start
+ INTEGER*8, INTENT(IN) :: i_end
+ INTEGER*8, INTENT(IN) :: j_start
+ INTEGER*8, INTENT(IN) :: j_end
+ INTEGER*8, INTENT(IN) :: k_start
+ INTEGER*8, INTENT(IN) :: k_end
+END FUNCTION
+
+!> \ingroup h5blockf_model
+!! See \ref H5BlockDefine3DChunkDims
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_define3dchunkdims ( filehandle, i, j, k )
+ INTEGER*8, INTENT(IN) :: filehandle
+ INTEGER*8, INTENT(IN) :: i
+ INTEGER*8, INTENT(IN) :: j
+ INTEGER*8, INTENT(IN) :: k
+END FUNCTION
+
+!> \ingroup h5blockf_model
+!! See \ref H5Block3dGetPartitionOfProc
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_get_partition_of_proc ( filehandle, proc, i_start, i_end, j_start, j_end, k_start, k_end )
+ INTEGER*8, INTENT(IN) :: filehandle
+ INTEGER*8, INTENT(OUT) :: proc
+ INTEGER*8, INTENT(OUT) :: i_start
+ INTEGER*8, INTENT(OUT) :: i_end
+ INTEGER*8, INTENT(OUT) :: j_start
+ INTEGER*8, INTENT(OUT) :: j_end
+ INTEGER*8, INTENT(OUT) :: k_start
+ INTEGER*8, INTENT(OUT) :: k_end
+ END FUNCTION
+
+!> \ingroup h5blockf_model
+!! See \ref H5Block3dGetReducedPartitionOfProc
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_get_reduced_partition_of_proc ( filehandle, proc, i_start, i_end, j_start, j_end, k_start, k_end )
+ INTEGER*8, INTENT(IN) :: filehandle
+ INTEGER*8, INTENT(OUT) :: proc
+ INTEGER*8, INTENT(OUT) :: i_start
+ INTEGER*8, INTENT(OUT) :: i_end
+ INTEGER*8, INTENT(OUT) :: j_start
+ INTEGER*8, INTENT(OUT) :: j_end
+ INTEGER*8, INTENT(OUT) :: k_start
+ INTEGER*8, INTENT(OUT) :: k_end
+END FUNCTION
+
+!> \ingroup h5blockf_model
+!! See \ref H5Block3dGetProcOf
+!! \return rank of processor error code
+!<
+INTEGER*8 FUNCTION h5bl_get_proc_of ( filehandle, i, j, k )
+ INTEGER*8, INTENT(IN) :: filehandle
+ INTEGER*8, INTENT(IN) :: i
+ INTEGER*8, INTENT(IN) :: j
+ INTEGER*8, INTENT(IN) :: k
+END FUNCTION
+
+!> \ingroup h5blockf_model
+!! See \ref H5BlockGetNumFields
+!! \return number of fields or error code
+!<
+INTEGER*8 FUNCTION h5bl_getnumfields ( filehandle )
+ INTEGER*8, INTENT(IN) :: filehandle
+END FUNCTION
+
+!> \ingroup h5blockf_model
+!! See \ref H5BlockGetFieldInfo
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_getfieldinfo ( filehandle, idx, field_name, grid_rank, grid_dims, field_dims )
+ INTEGER*8, INTENT(IN) :: filehandle
+ INTEGER*8, INTENT(IN) :: idx
+ CHARACTER(LEN=*), INTENT(OUT) :: field_name
+ INTEGER*8, INTENT(OUT) :: grid_rank
+ INTEGER*8, INTENT(OUT) :: grid_dims(*)
+ INTEGER*8, INTENT(OUT) :: field_dims
+END FUNCTION
+
+!> \ingroup h5blockf_model
+!! See \ref H5BlockHasFieldData
+!! \return 0 if false, 1 if true, or error code
+!<
+INTEGER*8 FUNCTION h5bl_has_fielddata ( filehandle )
+ INTEGER*8, INTENT(IN) :: filehandle
+END FUNCTION
+
+
+!!!!!!!! Reading and Writing Attributes !!!!!!!!
+
+!> \ingroup h5blockf_attrib
+!! See \ref H5BlockWriteFieldAttribString
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_writefieldattrib_string ( filehandle, field_name, attrib_name, attrib_value )
+ INTEGER*8, INTENT(IN) :: filehandle
+ CHARACTER(LEN=*), INTENT(IN) :: field_name ! The name of the field
+ CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! The name of the attribute
+ CHARACTER(LEN=*), INTENT(IN) :: attrib_value ! The array of data to write into the attribute
+END FUNCTION
+
+!> \ingroup h5blockf_attrib
+!! See \ref H5BlockGetNumFieldAttribs
+!! \return number of attributes or error code
+!<
+INTEGER*8 FUNCTION h5bl_getnfieldattribs ( filehandle, field_name )
+ INTEGER*8, INTENT(IN) :: filehandle
+ CHARACTER(LEN=*), INTENT(IN) :: field_name ! The name of the field
+END FUNCTION
+
+!> \ingroup h5blockf_attrib
+!! See \ref H5BlockGetFieldAttribInfo
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_getfieldattribinfo ( filehandle, field_name, idx, attrib_name, attrib_nelem)
+ INTEGER*8,INTENT(IN) :: filehandle
+ CHARACTER(LEN=*), INTENT(IN) :: field_name ! The name of the field
+ INTEGER*8,INTENT(IN) :: idx ! index of the attribute being queried
+ CHARACTER(LEN=*), INTENT(OUT):: attrib_name ! The name of the attribute
+ INTEGER*8,INTENT(OUT):: attrib_nelem ! Number of elements in the attrib array
+END FUNCTION
+
+!> \ingroup h5blockf_attrib
+!! Read the attribute \c attrib_name from the field \c field_name at the
+!! current timestep, and store the int64 value in \c attrib_value.
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_readfieldattrib_i8 ( filehandle, field_name, attrib_name, attrib_value )
+ INTEGER*8,INTENT(IN) :: filehandle
+ CHARACTER(LEN=*), INTENT(IN) :: field_name ! The name of the field
+ CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! name of the attribute to read
+ INTEGER*8,INTENT(OUT):: attrib_value(*)! the attribute data will be read into this array
+END FUNCTION
+
+!> \ingroup h5blockf_attrib
+!! Read the attribute \c attrib_name from the field \c field_name at the
+!! current timestep, and store the float64 value in \c attrib_value.
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_readfieldattrib_r8 ( filehandle, field_name, attrib_name, attrib_value )
+ INTEGER*8,INTENT(IN) :: filehandle
+ CHARACTER(LEN=*), INTENT(IN) :: field_name ! The name of the field
+ CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! name of the attribute to read
+ REAL*8, INTENT(OUT):: attrib_value(*)! the attribute data will be read into this array
+END FUNCTION
+
+!> \ingroup h5blockf_attrib
+!! Read the attribute \c attrib_name from the field \c field_name at the
+!! current timestep, and store the string value in \c attrib_value.
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_readfieldattrib_string ( filehandle, field_name, attrib_name, attrib_value )
+ INTEGER*8, INTENT(IN) :: filehandle
+ CHARACTER(LEN=*), INTENT(IN) :: field_name ! The name of the field
+ CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! name of the attribute to read
+ CHARACTER(LEN=*), INTENT(IN) :: attrib_value ! The array of data to write into the attribute
+END FUNCTION
+
+!> \ingroup h5blockf_attrib
+!! See \ref H5Block3dGetFieldSpacing
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_3d_get_field_spacing ( filehandle, name, x, y, z )
+ INTEGER*8, INTENT(IN) :: filehandle
+ CHARACTER(LEN=*), INTENT(IN) :: name
+ REAL*8, INTENT(OUT) :: x
+ REAL*8, INTENT(OUT) :: y
+ REAL*8, INTENT(OUT) :: z
+END FUNCTION
+
+!> \ingroup h5blockf_attrib
+!! See \ref H5Block3dSetFieldSpacing
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_3d_set_field_spacing ( filehandle, name, x, y, z )
+ INTEGER*8, INTENT(IN) :: filehandle
+ CHARACTER(LEN=*), INTENT(IN) :: name
+ REAL*8, INTENT(IN) :: x
+ REAL*8, INTENT(IN) :: y
+ REAL*8, INTENT(IN) :: z
+END FUNCTION
+
+!> \ingroup h5blockf_attrib
+!! See \ref H5Block3dGetFieldOrigin
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_3d_get_field_origin ( filehandle, name, x, y, z )
+ INTEGER*8, INTENT(IN) :: filehandle
+ CHARACTER(LEN=*), INTENT(IN) :: name
+ REAL*8, INTENT(OUT) :: x
+ REAL*8, INTENT(OUT) :: y
+ REAL*8, INTENT(OUT) :: z
+END FUNCTION
+
+!> \ingroup h5blockf_attrib
+!! See \ref H5Block3dSetFieldOrigin
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_3d_set_field_origin ( filehandle, name, x, y, z )
+ INTEGER*8, INTENT(IN) :: filehandle
+ CHARACTER(LEN=*), INTENT(IN) :: name
+ REAL*8, INTENT(IN) :: x
+ REAL*8, INTENT(IN) :: y
+ REAL*8, INTENT(IN) :: z
+END FUNCTION
+
+
diff --git a/src/H5Block.h b/src/H5Block.h
index 9394ebf..94ce9a5 100644
--- a/src/H5Block.h
+++ b/src/H5Block.h
@@ -1,5 +1,5 @@
-#ifndef __H5BLOCK_H
-#define __H5BLOCK_H
+#ifndef _H5BLOCK_H_
+#define _H5BLOCK_H_
#ifdef __cplusplus
extern "C" {
diff --git a/src/H5BlockErrors.h b/src/H5BlockErrors.h
index 43e39de..660913d 100644
--- a/src/H5BlockErrors.h
+++ b/src/H5BlockErrors.h
@@ -1,7 +1,7 @@
-#ifndef __H5BLOCKERRORS_H
-#define __H5BLOCKERRORS_H
+#ifndef _H5BLOCK_ERRORS_H_
+#define _H5BLOCK_ERRORS_H_
-#define _err_handler H5PartGetErrorHandler()
+extern h5part_error_handler _err_handler;
#define CHECK_LAYOUT( f ) \
if ( ! f->block->have_layout ) \
diff --git a/src/H5BlockF90.inc b/src/H5BlockF90.inc
deleted file mode 100644
index cec5ff7..0000000
--- a/src/H5BlockF90.inc
+++ /dev/null
@@ -1,143 +0,0 @@
-
-INCLUDE 'H5BlockReadWriteF90.inc'
-
-INTERFACE
-
-INTEGER*8 FUNCTION h5bl_define3dlayout ( filehandle, i_start, i_end, j_start, j_end, k_start, k_end )
- INTEGER*8, INTENT(IN) :: filehandle
- INTEGER*8, INTENT(IN) :: i_start
- INTEGER*8, INTENT(IN) :: i_end
- INTEGER*8, INTENT(IN) :: j_start
- INTEGER*8, INTENT(IN) :: j_end
- INTEGER*8, INTENT(IN) :: k_start
- INTEGER*8, INTENT(IN) :: k_end
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_define3dchunkdims ( filehandle, i, j, k )
- INTEGER*8, INTENT(IN) :: filehandle
- INTEGER*8, INTENT(IN) :: i
- INTEGER*8, INTENT(IN) :: j
- INTEGER*8, INTENT(IN) :: k
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_get_partition_of_proc ( filehandle, proc, i_start, i_end, j_start, j_end, k_start, k_end )
- INTEGER*8, INTENT(IN) :: filehandle
- INTEGER*8, INTENT(OUT) :: proc
- INTEGER*8, INTENT(OUT) :: i_start
- INTEGER*8, INTENT(OUT) :: i_end
- INTEGER*8, INTENT(OUT) :: j_start
- INTEGER*8, INTENT(OUT) :: j_end
- INTEGER*8, INTENT(OUT) :: k_start
- INTEGER*8, INTENT(OUT) :: k_end
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_get_reduced_partition_of_proc ( filehandle, proc, i_start, i_end, j_start, j_end, k_start, k_end )
- INTEGER*8, INTENT(IN) :: filehandle
- INTEGER*8, INTENT(OUT) :: proc
- INTEGER*8, INTENT(OUT) :: i_start
- INTEGER*8, INTENT(OUT) :: i_end
- INTEGER*8, INTENT(OUT) :: j_start
- INTEGER*8, INTENT(OUT) :: j_end
- INTEGER*8, INTENT(OUT) :: k_start
- INTEGER*8, INTENT(OUT) :: k_end
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_get_proc_of ( filehandle, i, j, k )
- INTEGER*8, INTENT(IN) :: filehandle
- INTEGER*8, INTENT(IN) :: i
- INTEGER*8, INTENT(IN) :: j
- INTEGER*8, INTENT(IN) :: k
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_getnumfields ( filehandle )
- INTEGER*8, INTENT(IN) :: filehandle
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_getfieldinfo ( filehandle, idx, field_name, grid_rank, grid_dims, field_dims )
- INTEGER*8, INTENT(IN) :: filehandle
- INTEGER*8, INTENT(IN) :: idx
- CHARACTER(LEN=*), INTENT(OUT) :: field_name
- INTEGER*8, INTENT(OUT) :: grid_rank
- INTEGER*8, INTENT(OUT) :: grid_dims(*)
- INTEGER*8, INTENT(OUT) :: field_dims
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_writefieldattrib_string ( filehandle, field_name, attrib_name, attrib_value )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: field_name ! The name of the field
- CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! The name of the attribute
- CHARACTER(LEN=*), INTENT(IN) :: attrib_value ! The array of data to write into the attribute
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_getnfieldattribs ( filehandle, field_name )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: field_name ! The name of the field
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_getfieldattribinfo ( filehandle, field_name, idx, attrib_name, attrib_nelem)
- INTEGER*8,INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: field_name ! The name of the field
- INTEGER*8,INTENT(IN) :: idx ! index of the attribute being queried
- CHARACTER(LEN=*), INTENT(OUT):: attrib_name ! The name of the attribute
- INTEGER*8,INTENT(OUT):: attrib_nelem ! Number of elements in the attrib array
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_readfieldattrib_i8 ( filehandle, field_name, attrib_name, attrib_value )
- INTEGER*8,INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: field_name ! The name of the field
- CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! name of the attribute to read
- INTEGER*8,INTENT(OUT):: attrib_value(*)! the attribute data will be read into this array
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_readfieldattrib_r8 ( filehandle, field_name, attrib_name, attrib_value )
- INTEGER*8,INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: field_name ! The name of the field
- CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! name of the attribute to read
- REAL*8, INTENT(OUT):: attrib_value(*)! the attribute data will be read into this array
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_readfieldattrib_string ( filehandle, field_name, attrib_name, attrib_value )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: field_name ! The name of the field
- CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! name of the attribute to read
- CHARACTER(LEN=*), INTENT(IN) :: attrib_value ! The array of data to write into the attribute
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_has_fielddata ( filehandle )
- INTEGER*8, INTENT(IN) :: filehandle
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_3d_get_field_spacing ( filehandle, name, x, y, z )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: name
- REAL*8, INTENT(OUT) :: x
- REAL*8, INTENT(OUT) :: y
- REAL*8, INTENT(OUT) :: z
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_3d_set_field_spacing ( filehandle, name, x, y, z )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: name
- REAL*8, INTENT(IN) :: x
- REAL*8, INTENT(IN) :: y
- REAL*8, INTENT(IN) :: z
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_3d_get_field_origin ( filehandle, name, x, y, z )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: name
- REAL*8, INTENT(OUT) :: x
- REAL*8, INTENT(OUT) :: y
- REAL*8, INTENT(OUT) :: z
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_3d_set_field_origin ( filehandle, name, x, y, z )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: name
- REAL*8, INTENT(IN) :: x
- REAL*8, INTENT(IN) :: y
- REAL*8, INTENT(IN) :: z
-END FUNCTION
-
-END INTERFACE
-
diff --git a/src/H5BlockPrivate.h b/src/H5BlockPrivate.h
index 167373b..e4d666c 100644
--- a/src/H5BlockPrivate.h
+++ b/src/H5BlockPrivate.h
@@ -1,5 +1,5 @@
-#ifndef __H5BLOCKPRIVATE_H
-#define __H5BLOCKPRIVATE_H
+#ifndef _H5BLOCK_PRIVATE_H_
+#define _H5BLOCK_PRIVATE_H_
#define H5BLOCK_GROUPNAME_BLOCK "Block"
diff --git a/src/H5BlockReadWrite.c b/src/H5BlockReadWrite.c
index 69b9887..5118a4a 100644
--- a/src/H5BlockReadWrite.c
+++ b/src/H5BlockReadWrite.c
@@ -13,7 +13,7 @@
#include "H5BlockErrors.h"
/*!
- \ingroup h5block_write
+ \ingroup h5block_data
Write a 3-dimensional field \c name from the buffer starting at \c data
to the current time-step using the defined field layout. Values are
@@ -49,7 +49,7 @@ H5Block3dWriteScalarFieldFloat64 (
}
/*!
- \ingroup h5block_read
+ \ingroup h5block_data
Read a 3-dimensional field \c name into the buffer starting at \c data from
the current time-step using the defined field layout. Values are
@@ -84,7 +84,7 @@ H5Block3dReadScalarFieldFloat64 (
}
/*!
- \ingroup h5block_write
+ \ingroup h5block_data
*/
/*!
Write a 3-dimensional field \c name with 3-dimensional vectors as values
@@ -128,7 +128,7 @@ H5Block3dWrite3dVectorFieldFloat64 (
}
/*!
- \ingroup h5block_read
+ \ingroup h5block_data
*/
/*!
Read a 3-dimensional field \c name with 3-dimensional vectors as values
@@ -171,7 +171,7 @@ H5Block3dRead3dVectorFieldFloat64 (
}
/*!
- \ingroup h5block_write
+ \ingroup h5block_data
Write a 3-dimensional field \c name from the buffer starting at \c data
to the current time-step using the defined field layout. Values are
@@ -207,7 +207,7 @@ H5Block3dWriteScalarFieldFloat32 (
}
/*!
- \ingroup h5block_read
+ \ingroup h5block_data
Read a 3-dimensional field \c name into the buffer starting at \c data from
the current time-step using the defined field layout. Values are
@@ -242,7 +242,7 @@ H5Block3dReadScalarFieldFloat32 (
}
/*!
- \ingroup h5block_write
+ \ingroup h5block_data
*/
/*!
Write a 3-dimensional field \c name with 3-dimensional vectors as values
@@ -286,7 +286,7 @@ H5Block3dWrite3dVectorFieldFloat32 (
}
/*!
- \ingroup h5block_read
+ \ingroup h5block_data
*/
/*!
Read a 3-dimensional field \c name with 3-dimensional vectors as values
@@ -329,7 +329,7 @@ H5Block3dRead3dVectorFieldFloat32 (
}
/*!
- \ingroup h5block_write
+ \ingroup h5block_data
Write a 3-dimensional field \c name from the buffer starting at \c data
to the current time-step using the defined field layout. Values are
@@ -365,7 +365,7 @@ H5Block3dWriteScalarFieldInt64 (
}
/*!
- \ingroup h5block_read
+ \ingroup h5block_data
Read a 3-dimensional field \c name into the buffer starting at \c data from
the current time-step using the defined field layout. Values are
@@ -400,7 +400,7 @@ H5Block3dReadScalarFieldInt64 (
}
/*!
- \ingroup h5block_write
+ \ingroup h5block_data
*/
/*!
Write a 3-dimensional field \c name with 3-dimensional vectors as values
@@ -444,7 +444,7 @@ H5Block3dWrite3dVectorFieldInt64 (
}
/*!
- \ingroup h5block_read
+ \ingroup h5block_data
*/
/*!
Read a 3-dimensional field \c name with 3-dimensional vectors as values
@@ -487,7 +487,7 @@ H5Block3dRead3dVectorFieldInt64 (
}
/*!
- \ingroup h5block_write
+ \ingroup h5block_data
Write a 3-dimensional field \c name from the buffer starting at \c data
to the current time-step using the defined field layout. Values are
@@ -523,7 +523,7 @@ H5Block3dWriteScalarFieldInt32 (
}
/*!
- \ingroup h5block_read
+ \ingroup h5block_data
Read a 3-dimensional field \c name into the buffer starting at \c data from
the current time-step using the defined field layout. Values are
@@ -558,7 +558,7 @@ H5Block3dReadScalarFieldInt32 (
}
/*!
- \ingroup h5block_write
+ \ingroup h5block_data
*/
/*!
Write a 3-dimensional field \c name with 3-dimensional vectors as values
@@ -602,7 +602,7 @@ H5Block3dWrite3dVectorFieldInt32 (
}
/*!
- \ingroup h5block_read
+ \ingroup h5block_data
*/
/*!
Read a 3-dimensional field \c name with 3-dimensional vectors as values
diff --git a/src/H5BlockReadWrite.f90 b/src/H5BlockReadWrite.f90
new file mode 100644
index 0000000..f3be29b
--- /dev/null
+++ b/src/H5BlockReadWrite.f90
@@ -0,0 +1,224 @@
+
+!> \ingroup h5blockf_data
+!! See \ref H5Block3dWriteScalarFieldFloat64
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_3d_write_scalar_field_r8 ( filehandle, name, data )
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the dataset
+ REAL*8, INTENT(IN) :: data(*) !< the array of data
+END FUNCTION
+
+!> \ingroup h5blockf_data
+!! See \ref H5Block3dReadScalarFieldFloat64
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_3d_read_scalar_field_r8 ( filehandle, name, data )
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the dataset
+ REAL*8, INTENT(OUT) :: data(*) !< buffer to read the data into
+END FUNCTION
+
+!> \ingroup h5blockf_data
+!! See \ref H5Block3dWrite3dVectorFieldFloat64
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_3d_write_3dvector_field_r8 ( filehandle, name, x, y, z )
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the dataset
+ REAL*8, INTENT(IN) :: x(*) !< the array of x data to write
+ REAL*8, INTENT(IN) :: y(*) !< the array of y data to write
+ REAL*8, INTENT(IN) :: z(*) !< the array of z data to write
+END FUNCTION
+
+!> \ingroup h5blockf_data
+!! See \ref H5Block3dRead3dVectorFieldFloat64
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_3d_read_3dvector_field_r8 ( filehandle, name, x, y, z )
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the dataset
+ REAL*8, INTENT(OUT) :: x(*) !< buffer to read the x data into
+ REAL*8, INTENT(OUT) :: y(*) !< buffer to read the y data into
+ REAL*8, INTENT(OUT) :: z(*) !< buffer to read the z data into
+END FUNCTION
+
+!> \ingroup h5blockf_data
+!! See \ref H5Block3dWriteScalarFieldFloat32
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_3d_write_scalar_field_r4 ( filehandle, name, data )
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the dataset
+ REAL*4, INTENT(IN) :: data(*) !< the array of data
+END FUNCTION
+
+!> \ingroup h5blockf_data
+!! See \ref H5Block3dReadScalarFieldFloat32
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_3d_read_scalar_field_r4 ( filehandle, name, data )
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the dataset
+ REAL*4, INTENT(OUT) :: data(*) !< buffer to read the data into
+END FUNCTION
+
+!> \ingroup h5blockf_data
+!! See \ref H5Block3dWrite3dVectorFieldFloat32
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_3d_write_3dvector_field_r4 ( filehandle, name, x, y, z )
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the dataset
+ REAL*4, INTENT(IN) :: x(*) !< the array of x data to write
+ REAL*4, INTENT(IN) :: y(*) !< the array of y data to write
+ REAL*4, INTENT(IN) :: z(*) !< the array of z data to write
+END FUNCTION
+
+!> \ingroup h5blockf_data
+!! See \ref H5Block3dRead3dVectorFieldFloat32
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_3d_read_3dvector_field_r4 ( filehandle, name, x, y, z )
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the dataset
+ REAL*4, INTENT(OUT) :: x(*) !< buffer to read the x data into
+ REAL*4, INTENT(OUT) :: y(*) !< buffer to read the y data into
+ REAL*4, INTENT(OUT) :: z(*) !< buffer to read the z data into
+END FUNCTION
+
+!> \ingroup h5blockf_data
+!! See \ref H5Block3dWriteScalarFieldInt64
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_3d_write_scalar_field_i8 ( filehandle, name, data )
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the dataset
+ INTEGER*8, INTENT(IN) :: data(*) !< the array of data
+END FUNCTION
+
+!> \ingroup h5blockf_data
+!! See \ref H5Block3dReadScalarFieldInt64
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_3d_read_scalar_field_i8 ( filehandle, name, data )
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the dataset
+ INTEGER*8, INTENT(OUT) :: data(*) !< buffer to read the data into
+END FUNCTION
+
+!> \ingroup h5blockf_data
+!! See \ref H5Block3dWrite3dVectorFieldInt64
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_3d_write_3dvector_field_i8 ( filehandle, name, x, y, z )
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the dataset
+ INTEGER*8, INTENT(IN) :: x(*) !< the array of x data to write
+ INTEGER*8, INTENT(IN) :: y(*) !< the array of y data to write
+ INTEGER*8, INTENT(IN) :: z(*) !< the array of z data to write
+END FUNCTION
+
+!> \ingroup h5blockf_data
+!! See \ref H5Block3dRead3dVectorFieldInt64
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_3d_read_3dvector_field_i8 ( filehandle, name, x, y, z )
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the dataset
+ INTEGER*8, INTENT(OUT) :: x(*) !< buffer to read the x data into
+ INTEGER*8, INTENT(OUT) :: y(*) !< buffer to read the y data into
+ INTEGER*8, INTENT(OUT) :: z(*) !< buffer to read the z data into
+END FUNCTION
+
+!> \ingroup h5blockf_data
+!! See \ref H5Block3dWriteScalarFieldInt32
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_3d_write_scalar_field_i4 ( filehandle, name, data )
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the dataset
+ INTEGER*4, INTENT(IN) :: data(*) !< the array of data
+END FUNCTION
+
+!> \ingroup h5blockf_data
+!! See \ref H5Block3dReadScalarFieldInt32
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_3d_read_scalar_field_i4 ( filehandle, name, data )
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the dataset
+ INTEGER*4, INTENT(OUT) :: data(*) !< buffer to read the data into
+END FUNCTION
+
+!> \ingroup h5blockf_data
+!! See \ref H5Block3dWrite3dVectorFieldInt32
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_3d_write_3dvector_field_i4 ( filehandle, name, x, y, z )
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the dataset
+ INTEGER*4, INTENT(IN) :: x(*) !< the array of x data to write
+ INTEGER*4, INTENT(IN) :: y(*) !< the array of y data to write
+ INTEGER*4, INTENT(IN) :: z(*) !< the array of z data to write
+END FUNCTION
+
+!> \ingroup h5blockf_data
+!! See \ref H5Block3dRead3dVectorFieldInt32
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_3d_read_3dvector_field_i4 ( filehandle, name, x, y, z )
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the dataset
+ INTEGER*4, INTENT(OUT) :: x(*) !< buffer to read the x data into
+ INTEGER*4, INTENT(OUT) :: y(*) !< buffer to read the y data into
+ INTEGER*4, INTENT(OUT) :: z(*) !< buffer to read the z data into
+END FUNCTION
+
+!> \ingroup h5blockf_attrib
+!! See \ref H5BlockWriteFieldAttribFloat64
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_writefieldattrib_r8 ( filehandle, field_name, attrib_name, attrib_value, attrib_nelem)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: field_name !< the name of the field
+ CHARACTER(LEN=*), INTENT(IN) :: attrib_name !< the name of the attribute
+ REAL*8, INTENT(IN) :: attrib_value(*) !< the array of data to write into the attribute
+ INTEGER*8, INTENT(IN) :: attrib_nelem !< the number of elements in the array
+END FUNCTION
+
+!> \ingroup h5blockf_attrib
+!! See \ref H5BlockWriteFieldAttribFloat32
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_writefieldattrib_r4 ( filehandle, field_name, attrib_name, attrib_value, attrib_nelem)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: field_name !< the name of the field
+ CHARACTER(LEN=*), INTENT(IN) :: attrib_name !< the name of the attribute
+ REAL*4, INTENT(IN) :: attrib_value(*) !< the array of data to write into the attribute
+ INTEGER*8, INTENT(IN) :: attrib_nelem !< the number of elements in the array
+END FUNCTION
+
+!> \ingroup h5blockf_attrib
+!! See \ref H5BlockWriteFieldAttribInt64
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_writefieldattrib_i8 ( filehandle, field_name, attrib_name, attrib_value, attrib_nelem)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: field_name !< the name of the field
+ CHARACTER(LEN=*), INTENT(IN) :: attrib_name !< the name of the attribute
+ INTEGER*8, INTENT(IN) :: attrib_value(*) !< the array of data to write into the attribute
+ INTEGER*8, INTENT(IN) :: attrib_nelem !< the number of elements in the array
+END FUNCTION
+
+!> \ingroup h5blockf_attrib
+!! See \ref H5BlockWriteFieldAttribInt32
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5bl_writefieldattrib_i4 ( filehandle, field_name, attrib_name, attrib_value, attrib_nelem)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: field_name !< the name of the field
+ CHARACTER(LEN=*), INTENT(IN) :: attrib_name !< the name of the attribute
+ INTEGER*4, INTENT(IN) :: attrib_value(*) !< the array of data to write into the attribute
+ INTEGER*8, INTENT(IN) :: attrib_nelem !< the number of elements in the array
+END FUNCTION
diff --git a/src/H5BlockReadWrite.h b/src/H5BlockReadWrite.h
index 8f9d9d8..9025ff4 100644
--- a/src/H5BlockReadWrite.h
+++ b/src/H5BlockReadWrite.h
@@ -1,6 +1,6 @@
-#ifndef __H5BLOCKREADWRITE_H
-#define __H5BLOCKREADWRITE_H
+#ifndef _H5BLOCK_READWRITE_H_
+#define _H5BLOCK_READWRITE_H_
#ifdef __cplusplus
extern "C" {
diff --git a/src/H5BlockReadWriteF90.inc b/src/H5BlockReadWriteF90.inc
deleted file mode 100644
index 457dd17..0000000
--- a/src/H5BlockReadWriteF90.inc
+++ /dev/null
@@ -1,148 +0,0 @@
-
-INTERFACE
-
-INTEGER*8 FUNCTION h5bl_3d_write_scalar_field_r8 ( filehandle, name, data )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: name
- REAL*8, INTENT(IN) :: data(*)
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_3d_read_scalar_field_r8 ( filehandle, name, data )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: name
- REAL*8, INTENT(OUT) :: data(*)
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_3d_write_3dvector_field_r8 ( filehandle, name, x, y, z )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: name
- REAL*8, INTENT(IN) :: x(*)
- REAL*8, INTENT(IN) :: y(*)
- REAL*8, INTENT(IN) :: z(*)
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_3d_read_3dvector_field_r8 ( filehandle, name, x, y, z )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: name
- REAL*8, INTENT(OUT) :: x(*)
- REAL*8, INTENT(OUT) :: y(*)
- REAL*8, INTENT(OUT) :: z(*)
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_3d_write_scalar_field_r4 ( filehandle, name, data )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: name
- REAL*4, INTENT(IN) :: data(*)
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_3d_read_scalar_field_r4 ( filehandle, name, data )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: name
- REAL*4, INTENT(OUT) :: data(*)
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_3d_write_3dvector_field_r4 ( filehandle, name, x, y, z )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: name
- REAL*4, INTENT(IN) :: x(*)
- REAL*4, INTENT(IN) :: y(*)
- REAL*4, INTENT(IN) :: z(*)
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_3d_read_3dvector_field_r4 ( filehandle, name, x, y, z )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: name
- REAL*4, INTENT(OUT) :: x(*)
- REAL*4, INTENT(OUT) :: y(*)
- REAL*4, INTENT(OUT) :: z(*)
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_3d_write_scalar_field_i8 ( filehandle, name, data )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: name
- INTEGER*8, INTENT(IN) :: data(*)
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_3d_read_scalar_field_i8 ( filehandle, name, data )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: name
- INTEGER*8, INTENT(OUT) :: data(*)
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_3d_write_3dvector_field_i8 ( filehandle, name, x, y, z )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: name
- INTEGER*8, INTENT(IN) :: x(*)
- INTEGER*8, INTENT(IN) :: y(*)
- INTEGER*8, INTENT(IN) :: z(*)
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_3d_read_3dvector_field_i8 ( filehandle, name, x, y, z )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: name
- INTEGER*8, INTENT(OUT) :: x(*)
- INTEGER*8, INTENT(OUT) :: y(*)
- INTEGER*8, INTENT(OUT) :: z(*)
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_3d_write_scalar_field_i4 ( filehandle, name, data )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: name
- INTEGER*4, INTENT(IN) :: data(*)
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_3d_read_scalar_field_i4 ( filehandle, name, data )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: name
- INTEGER*4, INTENT(OUT) :: data(*)
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_3d_write_3dvector_field_i4 ( filehandle, name, x, y, z )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: name
- INTEGER*4, INTENT(IN) :: x(*)
- INTEGER*4, INTENT(IN) :: y(*)
- INTEGER*4, INTENT(IN) :: z(*)
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_3d_read_3dvector_field_i4 ( filehandle, name, x, y, z )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: name
- INTEGER*4, INTENT(OUT) :: x(*)
- INTEGER*4, INTENT(OUT) :: y(*)
- INTEGER*4, INTENT(OUT) :: z(*)
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_writefieldattrib_r8 ( filehandle, field_name, attrib_name, attrib_value, attrib_nelem)
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: field_name ! The name of the field
- CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! The name of the attribute
- REAL*8, INTENT(IN) :: attrib_value(*) ! The array of data to write into the attribute
- INTEGER*8, INTENT(IN) :: attrib_nelem ! Number of elements in the attrib array
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_writefieldattrib_r4 ( filehandle, field_name, attrib_name, attrib_value, attrib_nelem)
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: field_name ! The name of the field
- CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! The name of the attribute
- REAL*4, INTENT(IN) :: attrib_value(*) ! The array of data to write into the attribute
- INTEGER*8, INTENT(IN) :: attrib_nelem ! Number of elements in the attrib array
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_writefieldattrib_i8 ( filehandle, field_name, attrib_name, attrib_value, attrib_nelem)
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: field_name ! The name of the field
- CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! The name of the attribute
- INTEGER*8, INTENT(IN) :: attrib_value(*) ! The array of data to write into the attribute
- INTEGER*8, INTENT(IN) :: attrib_nelem ! Number of elements in the attrib array
-END FUNCTION
-
-INTEGER*8 FUNCTION h5bl_writefieldattrib_i4 ( filehandle, field_name, attrib_name, attrib_value, attrib_nelem)
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: field_name ! The name of the field
- CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! The name of the attribute
- INTEGER*4, INTENT(IN) :: attrib_value(*) ! The array of data to write into the attribute
- INTEGER*8, INTENT(IN) :: attrib_nelem ! Number of elements in the attrib array
-END FUNCTION
-
-END INTERFACE
diff --git a/src/H5BlockTypes.h b/src/H5BlockTypes.h
index 40b4a70..60b2f11 100644
--- a/src/H5BlockTypes.h
+++ b/src/H5BlockTypes.h
@@ -1,5 +1,5 @@
-#ifndef __H5BLOCKTYPES_H
-#define __H5BLOCKTYPES_H
+#ifndef _H5BLOCK_TYPES_H
+#define _H5BLOCK_TYPES_H
struct H5BlockPartition {
h5part_int64_t i_start;
diff --git a/src/H5MultiBlock.c b/src/H5MultiBlock.c
index ae666e2..938fe13 100644
--- a/src/H5MultiBlock.c
+++ b/src/H5MultiBlock.c
@@ -28,12 +28,14 @@
/*!
\ingroup h5multiblock_c_api
- \defgroup h5multiblock_write File Writing
+ \defgroup h5multiblock_model Setting up the Data Model
*/
+
/*!
\ingroup h5multiblock_c_api
- \defgroup h5multiblock_read File Reading
+ \defgroup h5multiblock_data Reading and Writing Datasets
*/
+
/*!
\ingroup h5multiblock_c_api
\defgroup h5multiblock_attrib Reading and Writing Attributes
@@ -89,7 +91,7 @@
\return H5PART_SUCCESS or error code
*/
static h5part_int64_t
-_file_is_valid (
+_H5MultiBlock_file_is_valid (
const H5PartFile *f /*!< IN: file handle */
) {
@@ -1055,7 +1057,7 @@ _H5MultiBlock_write_data (
*******************************************************************************/
/*!
- \ingroup h5multiblock_write
+ \ingroup h5multiblock_model
Define the radius for halo exchanges between the blocks. Blocks on the edges
of the field will be padded with zero values out to the radius.
@@ -1083,7 +1085,7 @@ H5MultiBlock3dDefineRadius (
}
/*!
- \ingroup h5multiblock_write
+ \ingroup h5multiblock_model
Define the radii for halo exchanges between the blocks. Blocks on the edges
of the field will be padded with zero values out to the radius.
@@ -1115,7 +1117,7 @@ H5MultiBlock3dDefineRadii (
}
/*!
- \ingroup h5multiblock_write
+ \ingroup h5multiblock_model
Define the field and block dimensions for writing.
@@ -1151,7 +1153,7 @@ H5MultiBlock3dDefineDims (
}
/*!
- \ingroup h5multiblock_read
+ \ingroup h5multiblock_model
Returns the field dimensions of the last field that was read.
@@ -1180,7 +1182,7 @@ H5MultiBlock3dGetFieldDims(
}
/*!
- \ingroup h5multiblock_read
+ \ingroup h5multiblock_model
Returns the block dimensions of the last field that was read.
@@ -1210,7 +1212,7 @@ H5MultiBlock3dGetBlockDims(
}
/*!
- \ingroup h5multiblock_read
+ \ingroup h5multiblock_model
Return the offsets for the block belonging to processor \c proc.
@@ -1240,7 +1242,7 @@ H5MultiBlock3dGetOffsetsOfProc (
}
/*!
- \ingroup h5multiblock_c_api
+ \ingroup h5multiblock_model
Finds a 3D block decomposition for an arbitrary number of processors
\c nprocs.
@@ -1266,7 +1268,7 @@ H5MultiBlock3dCalculateDecomp (
}
/*!
- \ingroup h5multiblock_read
+ \ingroup h5multiblock_data
Frees a \c block that was allocated during a read.
@@ -1283,7 +1285,7 @@ H5MultiBlockFree (
}
/*!
- \ingroup h5multiblock_c_api
+ \ingroup h5multiblock_model
Shifts the assignment of procs to blocks within the field.
diff --git a/src/H5MultiBlock.h b/src/H5MultiBlock.h
index 127cc4a..978230a 100644
--- a/src/H5MultiBlock.h
+++ b/src/H5MultiBlock.h
@@ -1,5 +1,5 @@
-#ifndef __H5MULTIBLOCK_H
-#define __H5MULTIBLOCK_H
+#ifndef _H5MULTIBLOCK_H_
+#define _H5MULTIBLOCK_H_
#ifdef __cplusplus
extern "C" {
diff --git a/src/H5MultiBlockErrors.h b/src/H5MultiBlockErrors.h
index bf8a491..36b7288 100644
--- a/src/H5MultiBlockErrors.h
+++ b/src/H5MultiBlockErrors.h
@@ -1,7 +1,7 @@
-#ifndef __H5MULTIBLOCKERRORS_H
-#define __H5MULTIBLOCKERRORS_H
+#ifndef _H5MULTIBLOCK_ERRORS_H_
+#define _H5MULTIBLOCK_ERRORS_H_
-#define _err_handler H5PartGetErrorHandler()
+extern h5part_error_handler _err_handler;
#define CHECK_DECOMP( f ) \
if ( ! f->multiblock->have_decomp ) \
diff --git a/src/H5MultiBlockPrivate.h b/src/H5MultiBlockPrivate.h
index 340a95c..bbcfbea 100644
--- a/src/H5MultiBlockPrivate.h
+++ b/src/H5MultiBlockPrivate.h
@@ -1,5 +1,5 @@
-#ifndef __H5MULTIBLOCKPRIVATE_H
-#define __H5MULTIBLOCKPRIVATE_H
+#ifndef _H5MULTIBLOCK_PRIVATE_H_
+#define _H5MULTIBLOCK_PRIVATE_H_
#define MULTIBLOCK_INIT( f ) { \
h5part_int64_t herr = _H5MultiBlock_init ( f ); \
diff --git a/src/H5MultiBlockReadWrite.h b/src/H5MultiBlockReadWrite.h
index 6da6ce6..eed85ee 100644
--- a/src/H5MultiBlockReadWrite.h
+++ b/src/H5MultiBlockReadWrite.h
@@ -1,6 +1,6 @@
-#ifndef __H5MULTIBLOCKREADWRITE_H
-#define __H5MULTIBLOCKREADWRITE_H
+#ifndef _H5MULTIBLOCK_READWRITE_H_
+#define _H5MULTIBLOCK_READWRITE_H_
#ifdef __cplusplus
extern "C" {
diff --git a/src/H5MultiBlockTypes.h b/src/H5MultiBlockTypes.h
index 37305f5..d5cb158 100644
--- a/src/H5MultiBlockTypes.h
+++ b/src/H5MultiBlockTypes.h
@@ -1,5 +1,5 @@
-#ifndef __H5MULTIBLOCKTYPES_H
-#define __H5MULTIBLOCKTYPES_H
+#ifndef _H5MULTIBLOCK_TYPES_H_
+#define _H5MULTIBLOCK_TYPES_H_
struct H5MultiBlockStruct {
h5part_int64_t halo_radii[3];
diff --git a/src/H5Part.c b/src/H5Part.c
index 661d852..f7586c1 100644
--- a/src/H5Part.c
+++ b/src/H5Part.c
@@ -19,6 +19,7 @@ Developed by:
Wes Bethel (NERSC/LBNL)
John Shalf (NERSC/LBNL)
Cristina Siegerist (NERSC/LBNL)
+ Mark Howison (NERSC/LBNL)
@@ -39,8 +40,6 @@ Papers:
For further information contact: h5part
-Last modified on April 19, 2007.
-
*/
@@ -50,15 +49,15 @@ Last modified on April 19, 2007.
*/
/*!
\ingroup h5part_c_api
- \defgroup h5part_openclose File Opening and Closing
+ \defgroup h5part_open File Opening and Closing
*/
/*!
\ingroup h5part_c_api
- \defgroup h5part_write File Writing
+ \defgroup h5part_model Setting up the Data Model
*/
/*!
\ingroup h5part_c_api
- \defgroup h5part_read File Reading
+ \defgroup h5part_data Readind and Writing Datasets
*/
/*!
\ingroup h5part_c_api
@@ -90,16 +89,17 @@ Last modified on April 19, 2007.
#define close _close
#endif /* WIN32 */
-#include "H5PartTypes.h"
#include "H5Part.h"
#include "H5PartPrivate.h"
#include "H5PartErrors.h"
+/********* Global Variable Declarations *************/
+h5part_error_handler _err_handler = H5PartReportErrorHandler;
+
/********* Private Variable Declarations *************/
-static unsigned _debug = 0;
+static unsigned _debug = H5PART_VERB_ERROR;
static h5part_int64_t _h5part_errno = H5PART_SUCCESS;
-static h5part_error_handler _err_handler = H5PartReportErrorHandler;
static char *__funcname;
/********** Declaration of private functions ******/
@@ -110,8 +110,8 @@ _init(
);
static h5part_int64_t
-_file_is_valid (
- const H5PartFile *f
+_reset_view (
+ H5PartFile *f
);
/*
@@ -149,13 +149,9 @@ _H5Part_open_file (
memset (f, 0, sizeof (H5PartFile));
f->flags = flags;
- f->throttle = 0;
- f->groupname_step = strdup ( H5PART_GROUPNAME_STEP );
- if( f->groupname_step == NULL ) {
- HANDLE_H5PART_NOMEM_ERR;
- goto error_cleanup;
- }
+ /* set default step name */
+ strncpy ( f->groupname_step, H5PART_GROUPNAME_STEP, H5PART_STEPNAME_LEN );
f->stepno_width = 0;
f->xfer_prop = f->create_prop = H5P_DEFAULT;
@@ -224,19 +220,30 @@ _H5Part_open_file (
}
}
- if (flags & H5PART_FS_LUSTRE) {
+ if ( flags & H5PART_FS_LUSTRE )
+ {
/* extend the btree size so that metadata pieces are
- * close to the 1MB stripe width */
+ * close to the alignment value */
+ unsigned int btree_ik = (align - 256) / 96;
+ unsigned int btree_bytes = 64 + 96*btree_ik;
+ if ( btree_bytes > align ) {
+ HANDLE_H5PART_INVALID_ERR(
+ "btree_ik", btree_ik );
+ goto error_cleanup;
+ }
+
if (f->myproc == 0) {
_H5Part_print_info (
- "Setting HDF5 btree parameter to %d",
- H5PART_BTREE_IK );
+ "Setting HDF5 btree parameter to %u",
+ btree_ik );
_H5Part_print_info (
- "Extending HDF5 btree size to %d bytes at rank 3",
- 24+16*H5PART_BTREE_IK+40*(2*H5PART_BTREE_IK + 1) );
+ "Extending HDF5 btree size to %u bytes at rank 3",
+ btree_bytes );
}
+
f->create_prop = H5Pcreate(H5P_FILE_CREATE);
H5Pset_istore_k (f->create_prop, H5PART_BTREE_IK);
+
#ifndef H5_USE_16_API
/* defer metadata cache flushing until file close */
H5AC_cache_config_t cache_config;
@@ -249,14 +256,14 @@ _H5Part_open_file (
cache_config.flash_incr_mode = H5C_flash_incr__off;
cache_config.decr_mode = H5C_decr__off;
H5Pset_mdc_config (f->access_prop, &cache_config);
-#else
+#else // H5_USE_16_API
_H5Part_print_info (
"Unable to defer metadata write: need HDF5 1.8");
-#endif
+#endif // H5_USE_16_API
}
f->comm = comm;
-#endif
+#endif // PARALLEL_IO
} else {
f->comm = 0;
f->nprocs = 1;
@@ -326,13 +333,14 @@ _H5Part_open_file (
HANDLE_H5F_OPEN_ERR ( filename, flags );
goto error_cleanup;
}
- f->mode = flags;
+ f->nparticles = 0;
f->timegroup = -1;
- f->shape = 0;
+ f->shape = H5S_ALL;
f->diskshape = H5S_ALL;
f->memshape = H5S_ALL;
f->viewstart = -1;
f->viewend = -1;
+ f->throttle = 0;
_H5Part_print_debug (
"Proc[%d]: Opened file \"%s\" val=%lld",
@@ -344,9 +352,6 @@ _H5Part_open_file (
error_cleanup:
if (f != NULL ) {
- if (f->groupname_step) {
- free (f->groupname_step);
- }
if (f->pnparticles != NULL) {
free (f->pnparticles);
}
@@ -357,7 +362,7 @@ _H5Part_open_file (
#ifdef PARALLEL_IO
/*!
- \ingroup h5part_openclose
+ \ingroup h5part_open
Opens file with specified filename.
@@ -392,7 +397,7 @@ H5PartOpenFileParallel (
}
/*!
- \ingroup h5part_openclose
+ \ingroup h5part_open
Opens file with specified filename, and also specifices an alignment
value used for HDF5 tuning parameters.
@@ -416,7 +421,7 @@ H5PartOpenFileParallelAlign (
#endif
/*!
- \ingroup h5part_openclose
+ \ingroup h5part_open
Opens file with specified filename.
@@ -452,7 +457,7 @@ H5PartOpenFile (
}
/*!
- \ingroup h5part_openclose
+ \ingroup h5part_open
Opens file with specified filename, and also specifices an alignment
value used for HDF5 tuning parameters.
@@ -479,8 +484,8 @@ H5PartOpenFileAlign (
\return \c H5PART_SUCCESS or error code
*/
-static h5part_int64_t
-_file_is_valid (
+h5part_int64_t
+_H5Part_file_is_valid (
const H5PartFile *f /*!< filehandle to check validity of */
) {
@@ -493,7 +498,7 @@ _file_is_valid (
}
/*!
- \ingroup h5part_openclose
+ \ingroup h5part_open
Closes an open file.
@@ -524,7 +529,7 @@ H5PartCloseFile (
}
#endif
- if( f->shape > 0 ) {
+ if( f->shape != H5S_ALL ) {
r = H5Sclose( f->shape );
if ( r < 0 ) HANDLE_H5S_CLOSE_ERR;
f->shape = 0;
@@ -539,6 +544,11 @@ H5PartCloseFile (
if ( r < 0 ) HANDLE_H5S_CLOSE_ERR;
f->diskshape = 0;
}
+ if( f->memshape != H5S_ALL ) {
+ r = H5Sclose( f->memshape );
+ if ( r < 0 ) HANDLE_H5S_CLOSE_ERR;
+ f->memshape = 0;
+ }
if( f->xfer_prop != H5P_DEFAULT ) {
r = H5Pclose( f->xfer_prop );
if ( r < 0 ) HANDLE_H5P_CLOSE_ERR ( "f->xfer_prop" );
@@ -559,9 +569,6 @@ H5PartCloseFile (
if ( r < 0 ) HANDLE_H5F_CLOSE_ERR;
f->file = 0;
}
- if (f->groupname_step) {
- free (f->groupname_step);
- }
if( f->pnparticles ) {
free( f->pnparticles );
}
@@ -570,60 +577,99 @@ H5PartCloseFile (
return _h5part_errno;
}
+h5part_int64_t
+H5PartFileIsValid (
+ H5PartFile *f
+ ) {
+ return _H5Part_file_is_valid(f);
+}
+
/*============== File Writing Functions ==================== */
+h5part_int64_t
+_H5Part_get_step_name(
+ H5PartFile *f,
+ const h5part_int64_t step,
+ char *name
+ ) {
+
+ /* Work around sprintf bug on older systems */
+ if (f->stepno_width == 0 && step == 0) {
+ sprintf (
+ name,
+ "%s#%0*lld",
+ f->groupname_step, 1, (long long) step );
+ }
+ else {
+ sprintf (
+ name,
+ "%s#%0*lld",
+ f->groupname_step, f->stepno_width, (long long) step );
+ }
+
+ return H5PART_SUCCESS;
+}
+
h5part_int64_t
H5PartDefineStepName (
H5PartFile *f,
const char *name,
const h5part_int64_t width
) {
- f->groupname_step = strdup ( name );
- if( f->groupname_step == NULL ) {
- return HANDLE_H5PART_NOMEM_ERR;
+
+ CHECK_FILEHANDLE ( f );
+
+ h5part_int64_t len = H5PART_STEPNAME_LEN - width - 2;
+ if ( strlen(name) > len ) {
+ _H5Part_print_warn (
+ "Step name has been truncated to fit within %d chars.",
+ H5PART_STEPNAME_LEN );
}
+
+ strncpy ( f->groupname_step, name, len );
f->stepno_width = (int)width;
+
+ _H5Part_print_debug ( "Step name defined as '%s'", f->groupname_step );
return H5PART_SUCCESS;
}
-/*!
- \ingroup h5part_write
-
- Set number of particles for current time-step.
-
- This function's sole purpose is to prevent
- needless creation of new HDF5 DataSpace handles if the number of
- particles is invariant throughout the simulation. That's its only reason
- for existence. After you call this subroutine, all subsequent
- operations will assume this number of particles will be written.
-
-
- \return \c H5PART_SUCCESS or error code
- */
-h5part_int64_t
-H5PartSetNumParticles (
- H5PartFile *f, /*!< [in] Handle to open file */
- h5part_int64_t nparticles /*!< [in] Number of particles */
+static h5part_int64_t
+_set_num_particles (
+ H5PartFile *f, /*!< [in] Handle to open file */
+ const h5part_int64_t nparticles, /*!< [in] Number of particles */
+ const h5part_int64_t _stride
) {
- SET_FNAME ( "H5PartSetNumParticles" );
- int r;
-#ifdef PARALLEL_IO
-#ifdef HDF5V160
- hssize_t start[1];
-#else
- hsize_t start[1];
-#endif
+ int ret;
+ h5part_int64_t herr;
- hsize_t stride[1];
- hsize_t count[1];
- hsize_t total;
+ hsize_t count;
+#ifdef HDF5V160
+ hssize_t start;
+#else
+ hsize_t start;
+#endif
+ hsize_t stride;
hsize_t dmax = H5S_UNLIMITED;
+
+#ifdef PARALLEL_IO
+ hsize_t total;
register int i;
#endif
- CHECK_FILEHANDLE( f );
+ if ( nparticles <= 0 )
+ return HANDLE_H5PART_INVALID_ERR ( "nparticles", nparticles );
+
+ /* prevent invalid stride value */
+ if (_stride < 1)
+ {
+ _H5Part_print_warn (
+ "Stride < 1 was specified: changing to 1." );
+ stride = 1;
+ } else {
+ stride = (hsize_t) _stride;
+ }
#ifndef PARALLEL_IO
/*
@@ -632,28 +678,46 @@ H5PartSetNumParticles (
for parallel IO, this is going to cause problems because
we don't know if things have changed globally
*/
- if ( f->nparticles == nparticles ) {
+ if ( f->nparticles == nparticles && stride == 1 ) {
+ _H5Part_print_debug (
+ "Serial mode: skipping unnecessary view creation" );
return H5PART_SUCCESS;
}
#endif
- if ( f->diskshape != H5S_ALL ) {
- r = H5Sclose( f->diskshape );
- if ( r < 0 ) return HANDLE_H5S_CLOSE_ERR;
- f->diskshape = H5S_ALL;
+
+ herr = _reset_view ( f );
+ if ( herr < 0 ) return herr;
+
+ f->nparticles = (hsize_t) nparticles;
+
+ /* declare local memory datasize with striding */
+ count = f->nparticles * stride;
+ f->memshape = H5Screate_simple ( 1, &count, &dmax );
+ if ( f->memshape < 0 )
+ return HANDLE_H5S_CREATE_SIMPLE_ERR ( f->nparticles );
+
+ /* we need a hyperslab selection if there is striding
+ * (otherwise, the default H5S_ALL selection is ok)
+ */
+ if ( stride > 1 )
+ {
+ start = 0;
+ count = f->nparticles;
+ herr = H5Sselect_hyperslab (
+ f->memshape,
+ H5S_SELECT_SET,
+ &start,
+ &stride,
+ &count, NULL );
+ if ( herr < 0 ) return HANDLE_H5S_SELECT_HYPERSLAB_ERR;
}
- if(f->memshape != H5S_ALL) {
- r = H5Sclose( f->memshape );
- if ( r < 0 ) return HANDLE_H5S_CLOSE_ERR;
- f->memshape = H5S_ALL;
- }
- if( f->shape ) {
- r = H5Sclose(f->shape);
- if ( r < 0 ) return HANDLE_H5S_CLOSE_ERR;
- }
- f->nparticles =(hsize_t) nparticles;
+
#ifndef PARALLEL_IO
- f->shape = H5Screate_simple (1, &(f->nparticles), NULL);
- if ( f->shape < 0 ) HANDLE_H5S_CREATE_SIMPLE_ERR ( f->nparticles );
+ count = f->nparticles;
+ f->shape = H5Screate_simple ( 1, &count, NULL );
+ if ( f->shape < 0 ) HANDLE_H5S_CREATE_SIMPLE_ERR ( count );
+ f->viewstart = 0;
+ f->viewend = nparticles - 1; // view range is *inclusive*
#else /* PARALLEL_IO */
/*
The Gameplan here is to declare the overall size of the on-disk
@@ -670,27 +734,26 @@ H5PartSetNumParticles (
acquire the number of particles to be written from each MPI process
*/
- r = MPI_Allgather (
+ ret = MPI_Allgather (
&nparticles, 1, MPI_LONG_LONG,
f->pnparticles, 1, MPI_LONG_LONG,
- f->comm);
- if ( r != MPI_SUCCESS) {
- return HANDLE_MPI_ALLGATHER_ERR;
- }
+ f->comm );
+ if ( ret != MPI_SUCCESS) return HANDLE_MPI_ALLGATHER_ERR;
+
if ( f->myproc == 0 ) {
_H5Part_print_debug ( "Particle offsets:" );
- for(i=0;inprocs;i++)
+ for ( i=0; inprocs; i++ )
_H5Part_print_debug ( "\t[%d] np=%lld", i,
(long long) f->pnparticles[i] );
}
- /* should I create a selection here? */
/* compute start offsets */
- stride[0] = 1;
- start[0] = 0;
+ start = 0;
for (i=0; imyproc; i++) {
- start[0] += f->pnparticles[i];
+ start += f->pnparticles[i];
}
+ f->viewstart = start;
+ f->viewend = start + f->nparticles - 1; // view range is *inclusive*
/* compute total nparticles */
total = 0;
@@ -698,38 +761,125 @@ H5PartSetNumParticles (
total += f->pnparticles[i];
}
- /* declare overall datasize */
- f->shape = H5Screate_simple (1, &total, &total);
- if (f->shape < 0) return HANDLE_H5S_CREATE_SIMPLE_ERR ( total );
+ if ( stride > 1 ) count = stride * total;
+ else count = total;
+ /* declare overall datasize */
+ f->shape = H5Screate_simple (1, &count, NULL);
+ if ( f->shape < 0 ) return HANDLE_H5S_CREATE_SIMPLE_ERR ( count );
/* declare overall data size but then will select a subset */
- f->diskshape = H5Screate_simple (1, &total, &total);
- if (f->diskshape < 0) return HANDLE_H5S_CREATE_SIMPLE_ERR ( total );
+ f->diskshape = H5Screate_simple (1, &count, NULL);
+ if ( f->diskshape < 0 ) return HANDLE_H5S_CREATE_SIMPLE_ERR ( count );
- /* declare local memory datasize */
- f->memshape = H5Screate_simple (1, &(f->nparticles), &dmax);
- if (f->memshape < 0)
- return HANDLE_H5S_CREATE_SIMPLE_ERR ( f->nparticles );
-
- count[0] = nparticles;
- r = H5Sselect_hyperslab (
+ count = nparticles;
+ stride = 1;
+ herr = H5Sselect_hyperslab (
f->diskshape,
H5S_SELECT_SET,
- start,
- stride,
- count, NULL );
- if ( r < 0 ) return HANDLE_H5S_SELECT_HYPERSLAB_ERR;
+ &start,
+ &stride,
+ &count, NULL );
+ if ( herr < 0 ) return HANDLE_H5S_SELECT_HYPERSLAB_ERR;
if ( f->timegroup < 0 ) {
- r = _H5Part_set_step ( f, 0 );
- if ( r < 0 ) return r;
-
+ herr = _H5Part_set_step ( f, 0 );
+ if ( herr < 0 ) return herr;
}
#endif
return H5PART_SUCCESS;
}
+/*!
+ \ingroup h5part_model
+
+ Set the number of particles for the current time-step.
+ After you call this subroutine, all subsequent
+ operations will assume this number of particles will be written.
+
+ For the parallel library, the \a nparticles value is the number of
+ particles that the \e individual task will write. You can use
+ a different value on different tasks.
+ This function uses an \c MPI_Allgather
+ call to aggregate each tasks number of particles and determine
+ the appropiate offsets. Because of the use of this MPI collective,
+ it is advisable to call this function as
+ few times as possible when running at large concurrency.
+
+ This function assumes that your particles' data fields are in stored in
+ contiguous 1D arrays.
+ For instance, the fields $x$ and $y$ for your particles are stored
+ in separate arrays \c x[] and \c y[].
+
+ If instead you store your particles as tuples, so that the values
+ are arranged $x_1,y_1,x_2,y_2$... than you need to setup striding
+ (in this case with value 2) using \ref H5PartSetNumParticlesStrided.
+
+ \return \c H5PART_SUCCESS or error code
+ */
+h5part_int64_t
+H5PartSetNumParticles (
+ H5PartFile *f, /*!< [in] Handle to open file */
+ const h5part_int64_t nparticles /*!< [in] Number of particles */
+ ) {
+
+ SET_FNAME ( "H5PartSetNumParticles" );
+ CHECK_FILEHANDLE( f );
+
+ h5part_int64_t herr;
+ h5part_int64_t stride = 1;
+
+ herr = _set_num_particles ( f, nparticles, stride );
+ if ( herr < 0 ) return herr;
+
+ return H5PART_SUCCESS;
+}
+
+/*!
+ \ingroup h5part_model
+
+ Set the number of particles for the current time-step.
+ After you call this subroutine, all subsequent
+ operations will assume this number of particles will be written.
+
+ For the parallel library, the \a nparticles value is the number of
+ particles that the \e individual task will write. You can use
+ a different value on different tasks.
+ This function uses an \c MPI_Allgather
+ call to aggregate each tasks number of particles and determine
+ the appropiate offsets. Because of the use of this MPI collective,
+ it is advisable to call this function as
+ few times as possible when running at large concurrency.
+
+ This function assumes that your particles' data fields are
+ stored tuples. For instance, the fields $x$ and $y$ of your
+ particles are arranged $x_1,y_1,x_2,y_2$... in a single data
+ array. In this example, the stride value would be 2.
+
+ If you instead have a separate array for each fields,
+ such as \c x[] and \c y[],
+ use \ref H5PartSetNumParticles.
+
+ \return \c H5PART_SUCCESS or error code
+ */
+h5part_int64_t
+H5PartSetNumParticlesStrided (
+ H5PartFile *f, /*!< [in] Handle to open file */
+ const h5part_int64_t nparticles, /*!< [in] Number of particles */
+ const h5part_int64_t stride /*!< [in] Stride (e.g. number of fields in the particle array) */
+ ) {
+
+ SET_FNAME ( "H5PartSetNumParticlesStrided" );
+ CHECK_FILEHANDLE( f );
+
+ h5part_int64_t herr;
+
+ herr = _set_num_particles ( f, nparticles, stride );
+ if ( herr < 0 ) return herr;
+
+ return H5PART_SUCCESS;
+}
+
static h5part_int64_t
_write_data (
H5PartFile *f, /*!< IN: Handle to open file */
@@ -744,6 +894,13 @@ _write_data (
"timestep %lld",
name, (long long)f->timestep );
+ if ( f->shape == H5S_ALL ) {
+ _H5Part_print_warn (
+ "The view is unset or invalid: please "
+ "set the view or specify a number of particles." );
+ return HANDLE_H5PART_BAD_VIEW_ERR ( f->viewstart, f->viewend );
+ }
+
#ifndef H5_USE_16_API
htri_t exists = H5Lexists ( f->timegroup, name, H5P_DEFAULT );
if ( exists > 0 ) return HANDLE_H5D_EXISTS_ERR ( name, f->timestep );
@@ -767,9 +924,9 @@ _write_data (
if ( dataset_id < 0 )
return HANDLE_H5D_CREATE_ERR ( name, f->timestep );
-#if PARALLEL_IO
- herr = _H5Part_start_throttle( f );
- if (herr < 0) return herr;
+#ifdef PARALLEL_IO
+ herr = _H5Part_start_throttle ( f );
+ if ( herr < 0 ) return herr;
#endif
herr = H5Dwrite (
@@ -780,9 +937,9 @@ _write_data (
f->xfer_prop,
array );
-#if PARALLEL_IO
- herr = _H5Part_end_throttle( f );
- if (herr < 0) return herr;
+#ifdef PARALLEL_IO
+ herr = _H5Part_end_throttle ( f );
+ if ( herr < 0 ) return herr;
#endif
if ( herr < 0 ) return HANDLE_H5D_WRITE_ERR ( name, f->timestep );
@@ -796,7 +953,7 @@ _write_data (
}
/*!
- \ingroup h5part_write
+ \ingroup h5part_data
Write array of 64 bit floating point data to file.
@@ -842,7 +999,7 @@ H5PartWriteDataFloat64 (
}
/*!
- \ingroup h5part_write
+ \ingroup h5part_data
Write array of 32 bit floating point data to file.
@@ -888,7 +1045,7 @@ H5PartWriteDataFloat32 (
}
/*!
- \ingroup h5part_write
+ \ingroup h5part_data
Write array of 64 bit integer data to file.
@@ -935,7 +1092,7 @@ H5PartWriteDataInt64 (
}
/*!
- \ingroup h5part_write
+ \ingroup h5part_data
Write array of 32 bit integer data to file.
@@ -1009,34 +1166,34 @@ h5part_int64_t
_H5Part_normalize_h5_type (
hid_t type
) {
+
H5T_class_t tclass = H5Tget_class ( type );
int size = H5Tget_size ( type );
- switch ( tclass ){
+ switch ( tclass ) {
case H5T_INTEGER:
- if ( size==8 ) {
- return H5PART_INT64;
- }
- else if ( size==1 ) {
- return H5PART_CHAR;
- }
- break;
+ if ( size==8 ) {
+ return H5PART_INT64;
+ }
+ else if ( size==1 ) {
+ return H5PART_CHAR;
+ }
+ break;
case H5T_FLOAT:
- if ( size==8 ) {
- return H5PART_FLOAT64;
- }
- else if ( size==4 ) {
- return H5PART_FLOAT32;
- }
- break;
+ if ( size==8 ) {
+ return H5PART_FLOAT64;
+ }
+ else if ( size==4 ) {
+ return H5PART_FLOAT32;
+ }
+ break;
case H5T_STRING:
- return H5PART_STRING;
+ return H5PART_STRING;
default:
- ; /* NOP */
+ ;/* NOP */
}
- _H5Part_print_warn ( "Unknown type %d", (int)type );
- return -1;
+ return HANDLE_H5PART_TYPE_ERR;
}
h5part_int64_t
@@ -1051,8 +1208,6 @@ _H5Part_read_attrib (
hid_t attrib_id;
hid_t space_id;
hid_t type_id;
- hid_t mytype;
- hsize_t nelem;
#ifndef H5_USE_16_API
if (! H5Aexists ( id, attrib_name )) {
@@ -1070,9 +1225,6 @@ _H5Part_read_attrib (
space_id = H5Aget_space ( attrib_id );
if ( space_id < 0 ) return HANDLE_H5A_GET_SPACE_ERR;
- nelem = H5Sget_simple_extent_npoints ( space_id );
- if ( nelem < 0 ) return HANDLE_H5S_GET_SIMPLE_EXTENT_NPOINTS_ERR;
-
herr = H5Aread ( attrib_id, type_id, attrib_value );
if ( herr < 0 ) return HANDLE_H5A_READ_ERR;
@@ -1085,43 +1237,6 @@ _H5Part_read_attrib (
herr = H5Aclose ( attrib_id );
if ( herr < 0 ) return HANDLE_H5A_CLOSE_ERR;
-
-/* if ( attrib_id <= 0 ) return HANDLE_H5A_OPEN_NAME_ERR( attrib_name ); */
-
-/* mytype = H5Aget_type ( attrib_id ); */
-/* if ( mytype < 0 ) return HANDLE_H5A_GET_TYPE_ERR; */
-
-/* space_id = H5Aget_space ( attrib_id ); */
-/* if ( space_id < 0 ) return HANDLE_H5A_GET_SPACE_ERR; */
-
-/* nelem = H5Sget_simple_extent_npoints ( space_id ); */
-/* if ( nelem < 0 ) return HANDLE_H5S_GET_SIMPLE_EXTENT_NPOINTS_ERR; */
-
-/* type_id = _H5Part_normalize_h5_type ( mytype ); */
-
-/* herr = H5Aread (attrib_id, type_id, attrib_value ); */
-/* if ( herr < 0 ) return HANDLE_H5A_READ_ERR; */
-
-/* /\* _H5Part_close_h5_type( type_id ); *\/ */
-
-/* if( type_id != H5T_NATIVE_CHAR && */
-/* type_id != H5T_NATIVE_INT64 && */
-/* type_id != H5T_NATIVE_FLOAT && */
-/* type_id != H5T_NATIVE_DOUBLE ) */
-/* { */
-/* herr = H5Tclose ( type_id ); */
-/* if ( herr < 0 ) return HANDLE_H5T_CLOSE_ERR; */
-/* } */
-
-/* herr = H5Sclose ( space_id ); */
-/* if ( herr < 0 ) return HANDLE_H5S_CLOSE_ERR; */
-
-/* herr = H5Tclose ( mytype ); */
-/* if ( herr < 0 ) return HANDLE_H5T_CLOSE_ERR; */
-
-/* herr = H5Aclose ( attrib_id ); */
-/* if ( herr < 0 ) return HANDLE_H5A_CLOSE_ERR; */
-
return H5PART_SUCCESS;
}
@@ -1134,34 +1249,36 @@ _H5Part_write_attrib (
const hsize_t attrib_nelem
) {
- herr_t herr;
- h5part_int64_t h5err;
+ h5part_int64_t herr;
hid_t space_id;
hid_t attrib_id;
hid_t type = attrib_type;
- if (attrib_type == H5T_STRING) {
- h5err = _H5Part_make_string_type(&type, attrib_nelem);
- if ( h5err < 0 ) return h5err;
+ if ( attrib_type == H5PART_STRING )
+ {
+ herr = _H5Part_make_string_type ( &type, attrib_nelem );
+ if ( herr < 0 ) return herr;
+
space_id = H5Screate (H5S_SCALAR);
if ( space_id < 0 )
return HANDLE_H5S_CREATE_SCALAR_ERR;
}
else {
- space_id = H5Screate_simple (1, &attrib_nelem, NULL);
+ space_id = H5Screate_simple ( 1, &attrib_nelem, NULL );
if ( space_id < 0 )
return HANDLE_H5S_CREATE_SIMPLE_ERR ( attrib_nelem );
}
- attrib_id = H5Acreate( id,
- attrib_name,
- type,
- space_id,
- H5P_DEFAULT
+ attrib_id = H5Acreate(
+ id,
+ attrib_name,
+ type,
+ space_id,
+ H5P_DEFAULT
#ifndef H5_USE_16_API
- , H5P_DEFAULT
+ , H5P_DEFAULT
#endif
- );
+ );
if ( attrib_id < 0 ) return HANDLE_H5A_CREATE_ERR ( attrib_name );
@@ -1174,7 +1291,7 @@ _H5Part_write_attrib (
herr = H5Sclose ( space_id );
if ( herr < 0 ) return HANDLE_H5S_CLOSE_ERR;
- if (attrib_type == H5T_STRING) {
+ if ( attrib_type == H5PART_STRING ) {
herr = H5Tclose ( type );
if ( herr < 0 ) return HANDLE_H5T_CLOSE_ERR;
}
@@ -1182,6 +1299,59 @@ _H5Part_write_attrib (
return H5PART_SUCCESS;
}
+h5part_int64_t
+_H5Part_write_file_attrib (
+ H5PartFile *f,
+ const char *name,
+ const hid_t type,
+ const void *value,
+ const hsize_t nelem
+ ) {
+
+ hid_t group_id = H5Gopen ( f->file, "/"
+#ifndef H5_USE_16_API
+ , H5P_DEFAULT
+#endif
+ );
+
+ if ( group_id < 0 ) return HANDLE_H5G_OPEN_ERR( "/" );
+
+ h5part_int64_t herr = _H5Part_write_attrib (
+ group_id,
+ name,
+ type,
+ value,
+ nelem );
+ if ( herr < 0 ) return herr;
+
+ herr = H5Gclose ( group_id );
+ if ( herr < 0 ) return HANDLE_H5G_CLOSE_ERR;
+
+ return H5PART_SUCCESS;
+}
+
+h5part_int64_t
+_H5Part_write_step_attrib (
+ H5PartFile *f,
+ const char *name,
+ const hid_t type,
+ const void *value,
+ const hsize_t nelem
+ ) {
+
+ CHECK_TIMEGROUP( f );
+
+ h5part_int64_t herr = _H5Part_write_attrib (
+ f->timegroup,
+ name,
+ type,
+ value,
+ nelem );
+ if ( herr < 0 ) return herr;
+
+ return H5PART_SUCCESS;
+}
+
h5part_int64_t
_H5Part_get_attrib_info (
hid_t id,
@@ -1223,6 +1393,7 @@ _H5Part_get_attrib_info (
if ( mytype < 0 ) return HANDLE_H5A_GET_TYPE_ERR;
*attrib_type = _H5Part_normalize_h5_type ( mytype );
+ if ( *attrib_type < 0 ) return *attrib_type;
herr = H5Tclose ( mytype );
if ( herr < 0 ) return HANDLE_H5T_CLOSE_ERR;
@@ -1232,28 +1403,25 @@ _H5Part_get_attrib_info (
return H5PART_SUCCESS;
}
+/*!
+ }@
+*/
/********************** attribute API ****************************************/
/*!
\ingroup h5part_attrib
- Writes a string attribute bound to a file.
-
- This function creates a new attribute \c name with the string \c value as
- content. The attribute is bound to the file associated with the file handle
- \c f.
-
- If the attribute already exists an error will be returned. There
- is currently no way to change the content of an existing attribute.
+ Writes an attribute \c name with the string \c value to
+ the file root ("/").
\return \c H5PART_SUCCESS or error code
*/
h5part_int64_t
H5PartWriteFileAttribString (
H5PartFile *f, /*!< [in] Handle to open file */
- const char *attrib_name,/*!< [in] Name of attribute to create */
- const char *attrib_value/*!< [in] Value of attribute */
+ const char *name, /*!< [in] Name of attribute to create */
+ const char *value /*!< [in] Value of attribute */
) {
SET_FNAME ( "H5PartWriteFileAttribString" );
@@ -1261,39 +1429,25 @@ H5PartWriteFileAttribString (
CHECK_FILEHANDLE ( f );
CHECK_WRITABLE_MODE( f );
- hid_t group_id = H5Gopen ( f->file, "/"
-#ifndef H5_USE_16_API
- , H5P_DEFAULT
-#endif
- );
-
- if ( group_id < 0 ) return HANDLE_H5G_OPEN_ERR( "/" );
-
- h5part_int64_t herr = _H5Part_write_attrib (
- group_id,
- attrib_name,
- H5T_STRING,
- attrib_value,
- strlen ( attrib_value ) + 1 );
+ h5part_int64_t herr = _H5Part_write_file_attrib (
+ f,
+ name,
+ H5PART_STRING,
+ value,
+ strlen ( value ) + 1 );
if ( herr < 0 ) return herr;
- herr = H5Gclose ( group_id );
- if ( herr < 0 ) return HANDLE_H5G_CLOSE_ERR;
-
return H5PART_SUCCESS;
}
/*!
\ingroup h5part_attrib
- Writes a string attribute bound to the current time-step.
-
- If the attribute already exists an error will be returned. There
- is currently no way to change the content of an existing attribute.
+ Writes an attribute \c name with the string \c value to
+ the current timestep.
\return \c H5PART_SUCCESS or error code
*/
-
h5part_int64_t
H5PartWriteStepAttribString (
H5PartFile *f, /*!< [in] Handle to open file */
@@ -1305,12 +1459,11 @@ H5PartWriteStepAttribString (
CHECK_FILEHANDLE ( f );
CHECK_WRITABLE_MODE( f );
- CHECK_TIMEGROUP( f );
- h5part_int64_t herr = _H5Part_write_attrib (
- f->timegroup,
+ h5part_int64_t herr = _H5Part_write_step_attrib (
+ f,
name,
- H5T_STRING,
+ H5PART_STRING,
value,
strlen ( value ) + 1 );
if ( herr < 0 ) return herr;
@@ -1321,115 +1474,43 @@ H5PartWriteStepAttribString (
/*!
\ingroup h5part_attrib
- Writes an int32 attribute bound to the current time-step.
+ Writes an attribute \c name with values in the array \c data
+ of \c nelem elements to
+ the current timestep.
- If the attribute already exists an error will be returned. There
- is currently no way to change the content of an existing attribute.
+ The type of \c data must ve specified using one of the folowing
+ macros:
+
+ - \c H5PART_FLOAT64 (for \c h5part_float64_t)
+ - \c H5PART_FLOAT32 (for \c h5part_float32_t)
+ - \c H5PART_INT64 (for \c h5part_int64_t)
+ - \c H5PART_INT32 (for \c h5part_int32_t)
+ - \c H5PART_CHAR (for \c char)
+ - \c H5PART_STRING (for \c char*)
\return \c H5PART_SUCCESS or error code
*/
-
-h5part_int64_t
-H5PartWriteStepAttribInt32 (
- H5PartFile *f, /*!< [in] Handle to open file */
- const char *name, /*!< [in] Name of attribute to create */
- const h5part_int32_t value /*!< [in] Value of attribute */
- ) {
-
- SET_FNAME ( "H5PartWriteStepAttribInt32" );
-
- CHECK_FILEHANDLE ( f );
- CHECK_WRITABLE_MODE( f );
- CHECK_TIMEGROUP( f );
-
- h5part_int64_t herr = _H5Part_write_attrib (
- f->timegroup,
- name,
- H5T_NATIVE_INT32,
- &value,
- 1 );
- if ( herr < 0 ) return herr;
-
- return H5PART_SUCCESS;
-}
-
-/*!
- \ingroup h5part_attrib
-
- Writes a float32 attribute bound to the current time-step.
-
- If the attribute already exists an error will be returned. There
- is currently no way to change the content of an existing attribute.
-
- \return \c H5PART_SUCCESS or error code
-*/
-
-h5part_int64_t
-H5PartWriteStepAttribFloat32 (
- H5PartFile *f, /*!< [in] Handle to open file */
- const char *name, /*!< [in] Name of attribute to create */
- const h5part_float32_t value /*!< [in] Value of attribute */
- ) {
-
- SET_FNAME ( "H5PartWriteStepAttribFloat32" );
-
- CHECK_FILEHANDLE ( f );
- CHECK_WRITABLE_MODE( f );
- CHECK_TIMEGROUP( f );
-
- h5part_int64_t herr = _H5Part_write_attrib (
- f->timegroup,
- name,
- H5T_NATIVE_FLOAT,
- &value,
- 1 );
- if ( herr < 0 ) return herr;
-
- return H5PART_SUCCESS;
-}
-
-/*!
- \ingroup h5part_attrib
-
- Writes a attribute bound to the current time-step.
-
- This function creates a new attribute \c name with the string \c value as
- content. The attribute is bound to the current time step in the file given
- by the file handle \c f.
-
- The value of the attribute is given the parameter \c type, which must be one
- of \c H5T_NATIVE_DOUBLE, \c H5T_NATIVE_INT64 of \c H5T_NATIVE_CHAR, the array
- \c value and the number of elements \c nelem in the array.
-
- If the attribute already exists an error will be returned. There
- is currently no way to change the content of an existing attribute.
-
- \return \c H5PART_SUCCESS or error code
-*/
-
h5part_int64_t
H5PartWriteStepAttrib (
H5PartFile *f, /*!< [in] Handle to open file */
- const char *attrib_name, /*!< [in] Name of attribute */
- const h5part_int64_t attrib_type,/*!< [in] Type of value. */
- const void *attrib_value, /*!< [in] Value of attribute */
- const h5part_int64_t attrib_nelem/*!< [in] Number of elements */
+ const char *name, /*!< [in] Name of attribute */
+ const h5part_int64_t type, /*!< [in] Type of values */
+ const void *data, /*!< [in] Array of attribute values */
+ const h5part_int64_t nelem /*!< [in] Number of array elements */
){
SET_FNAME ( "H5PartWriteStepAttrib" );
- h5part_int64_t herr;
-
CHECK_FILEHANDLE ( f );
CHECK_WRITABLE_MODE( f );
CHECK_TIMEGROUP( f );
- herr = _H5Part_write_attrib (
- f->timegroup,
- attrib_name,
- (const hid_t)attrib_type,
- attrib_value,
- attrib_nelem );
+ h5part_int64_t herr = _H5Part_write_step_attrib (
+ f,
+ name,
+ (const hid_t)type,
+ data,
+ nelem );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
@@ -1438,58 +1519,44 @@ H5PartWriteStepAttrib (
/*!
\ingroup h5part_attrib
- Writes a attribute bound to a file.
+ Writes an attribute \c name with values in the array \c data
+ of \c nelem elements to
+ the file root ("/").
- This function creates a new attribute \c name with the string \c value as
- content. The attribute is bound to the file file given by the file handle
- \c f.
+ The type of \c data must ve specified using one of the folowing
+ macros:
- The value of the attribute is given the parameter \c type, which must be one
- of H5T_NATIVE_DOUBLE, H5T_NATIVE_INT64 of H5T_NATIVE_CHAR, the array \c value
- and the number of elements \c nelem in the array.
-
- If the attribute already exists an error will be returned. There
- is currently no way to change the content of an existing attribute.
+ - \c H5PART_FLOAT64 (for \c h5part_float64_t)
+ - \c H5PART_FLOAT32 (for \c h5part_float32_t)
+ - \c H5PART_INT64 (for \c h5part_int64_t)
+ - \c H5PART_INT32 (for \c h5part_int32_t)
+ - \c H5PART_CHAR (for \c char)
+ - \c H5PART_STRING (for \c char*)
\return \c H5PART_SUCCESS or error code
*/
-
h5part_int64_t
H5PartWriteFileAttrib (
H5PartFile *f, /*!< [in] Handle to open file */
- const char *attrib_name, /*!< [in] Name of attribute */
- const h5part_int64_t attrib_type,/*!< [in] Type of value. */
- const void *attrib_value, /*!< [in] Value of attribute */
- const h5part_int64_t attrib_nelem/*!< [in] Number of elements */
+ const char *name, /*!< [in] Name of attribute */
+ const h5part_int64_t type, /*!< [in] Type of values */
+ const void *data, /*!< [in] Array of attribute values */
+ const h5part_int64_t nelem /*!< [in] Number of array elements */
) {
SET_FNAME ( "H5PartWriteFileAttrib" );
- h5part_int64_t herr;
- hid_t group_id;
-
CHECK_FILEHANDLE ( f );
CHECK_WRITABLE_MODE ( f );
- group_id = H5Gopen(f->file,"/"
-#ifndef H5_USE_16_API
- , H5P_DEFAULT
-#endif
- );
-
- if ( group_id < 0 ) return HANDLE_H5G_OPEN_ERR( "/" );
-
- herr = _H5Part_write_attrib (
- group_id,
- attrib_name,
- (const hid_t)attrib_type,
- attrib_value,
- attrib_nelem );
+ h5part_int64_t herr = _H5Part_write_file_attrib (
+ f,
+ name,
+ (const hid_t)type,
+ data,
+ nelem );
if ( herr < 0 ) return herr;
- herr = H5Gclose ( group_id );
- if ( herr < 0 ) return HANDLE_H5G_CLOSE_ERR;
-
return H5PART_SUCCESS;
}
@@ -1506,10 +1573,10 @@ H5PartGetNumStepAttribs (
) {
SET_FNAME ( "H5PartGetNumStepAttribs" );
- h5part_int64_t nattribs;
-
CHECK_FILEHANDLE ( f );
+ h5part_int64_t nattribs;
+
nattribs = H5Aget_num_attrs(f->timegroup);
if ( nattribs < 0 ) HANDLE_H5A_GET_NUM_ATTRS_ERR;
@@ -1664,13 +1731,11 @@ H5PartReadStepAttrib (
) {
SET_FNAME ( "H5PartReadStepAttrib" );
+ CHECK_FILEHANDLE( f );
h5part_int64_t herr;
- CHECK_FILEHANDLE( f );
-
- herr = _H5Part_read_attrib ( f->timegroup,
- attrib_name, attrib_value );
+ herr = _H5Part_read_attrib ( f->timegroup, attrib_name, attrib_value );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
@@ -1733,23 +1798,10 @@ _H5Part_set_step (
const h5part_int64_t step /*!< [in] Time-step to set. */
) {
- char name[128];
+ char stepname[H5PART_STEPNAME_LEN];
+ _H5Part_get_step_name(f, step, stepname);
- /* Work around sprintf bug on older systems */
- if (f->stepno_width == 0 && step == 0) {
- sprintf (
- name,
- "%s#%0*lld",
- f->groupname_step, 1, (long long) step );
- }
- else {
- sprintf (
- name,
- "%s#%0*lld",
- f->groupname_step, f->stepno_width, (long long) step );
- }
-
- if ( (!(f->mode & H5PART_READ)) && _H5Part_have_group ( f->file, name ) ) {
+ if ( (!(f->flags & H5PART_READ)) && _H5Part_have_group ( f->file, stepname ) ) {
return HANDLE_H5PART_STEP_EXISTS_ERR ( step );
}
@@ -1760,20 +1812,20 @@ _H5Part_set_step (
f->timegroup = -1;
f->timestep = step;
- if( f->mode & H5PART_READ ) {
+ if ( f->flags & H5PART_READ ) {
_H5Part_print_debug (
"Proc[%d]: Set step to #%lld for file %lld",
f->myproc,
(long long)step,
(long long)(size_t) f );
- f->timegroup = H5Gopen ( f->file, name
+ f->timegroup = H5Gopen ( f->file, stepname
#ifndef H5_USE_16_API
, H5P_DEFAULT
#endif
);
if ( f->timegroup < 0 )
- return HANDLE_H5G_OPEN_ERR( name );
+ return HANDLE_H5G_OPEN_ERR( stepname );
}
else {
_H5Part_print_debug (
@@ -1783,7 +1835,7 @@ _H5Part_set_step (
(long long)(size_t) f );
f->timegroup = H5Gcreate( f->file,
- name,
+ stepname,
0
#ifndef H5_USE_16_API
, H5P_DEFAULT, H5P_DEFAULT
@@ -1791,14 +1843,14 @@ _H5Part_set_step (
);
if ( f->timegroup < 0 )
- return HANDLE_H5G_CREATE_ERR ( name );
+ return HANDLE_H5G_CREATE_ERR ( stepname );
}
return H5PART_SUCCESS;
}
/*!
- \ingroup h5part_read
+ \ingroup h5part_model
Set the current time-step.
@@ -1856,11 +1908,12 @@ _H5Part_have_group (
#ifndef H5_USE_16_API
herr_t
_H5Part_iteration_operator2 (
- hid_t group_id, /*!< [in] parent object id */
- const char *member_name, /*!< [in] child object name */
- const H5L_info_t *linfo, /*!< link info */
- void *operator_data ) /*!< [in,out] data passed to the iterator */
-{
+ hid_t group_id, /*!< [in] parent object id */
+ const char *member_name, /*!< [in] child object name */
+ const H5L_info_t *linfo, /*!< link info */
+ void *operator_data /*!< [in,out] data passed to the iterator */
+ ) {
+
struct _iter_op_data *data = (struct _iter_op_data*)operator_data;
herr_t herr = 0;
@@ -1891,6 +1944,7 @@ _H5Part_iteration_operator2 (
case H5L_TYPE_EXTERNAL: {
char *targbuf = (char*) malloc( linfo->u.val_size );
+ if ( targbuf == NULL ) return (herr_t)HANDLE_H5PART_NOMEM_ERR;
if(H5Lget_val(group_id, member_name, targbuf, linfo->u.val_size,
H5P_DEFAULT) < 0) {
@@ -1966,52 +2020,53 @@ _H5Part_iteration_operator (
hid_t group_id, /*!< [in] parent object id */
const char *member_name,/*!< [in] child object name */
void *operator_data /*!< [in,out] data passed to the iterator */
- )
-{
- struct _iter_op_data *data = (struct _iter_op_data*)operator_data;
- herr_t herr;
+ ) {
+
+ struct _iter_op_data *data = (struct _iter_op_data*)operator_data;
+ herr_t herr;
/* printf( "%d GROUP ITERATOR %s %d\n", __LINE__, member_name, data->type ); */
- if ( data->type != H5G_UNKNOWN ) {
-
+ if ( data->type != H5G_UNKNOWN )
+ {
#ifndef H5_USE_16_API
- H5O_info_t objinfo;
+ H5O_info_t objinfo;
- hid_t obj_id = H5Oopen(group_id, member_name, H5P_DEFAULT);
- if ( obj_id < 0 )
- return (herr_t)HANDLE_H5G_OPEN_ERR ( member_name );
+ hid_t obj_id = H5Oopen(group_id, member_name, H5P_DEFAULT);
+ if ( obj_id < 0 )
+ return (herr_t)HANDLE_H5G_OPEN_ERR ( member_name );
- herr = H5Oget_info ( obj_id, &objinfo );
- if ( herr < 0 )
- return (herr_t)HANDLE_H5G_GET_OBJINFO_ERR ( member_name );
+ herr = H5Oget_info ( obj_id, &objinfo );
+ if ( herr < 0 )
+ return (herr_t)HANDLE_H5G_GET_OBJINFO_ERR ( member_name );
- H5Oclose( obj_id );
+ H5Oclose( obj_id );
#else
- H5G_stat_t objinfo;
- herr = H5Gget_objinfo( group_id, member_name, 1, &objinfo );
- if ( herr < 0 ) return (herr_t)HANDLE_H5G_GET_OBJINFO_ERR ( member_name );
+ H5G_stat_t objinfo;
+ herr = H5Gget_objinfo( group_id, member_name, 1, &objinfo );
+ if ( herr < 0 )
+ return (herr_t)HANDLE_H5G_GET_OBJINFO_ERR ( member_name );
#endif
+ if ( objinfo.type != data->type )
+ return 0; /* don't count, continue iteration */
+ }
- if ( objinfo.type != data->type )
- {
- return 0;/* don't count, continue iteration */
- }
- }
-
- if ( data->name && (data->stop_idx == data->count) ) {
- memset ( data->name, 0, data->len );
- strncpy ( data->name, member_name, data->len-1 );
+ if ( data->name && (data->stop_idx == data->count) )
+ {
+ memset ( data->name, 0, data->len );
+ strncpy ( data->name, member_name, data->len-1 );
- return 1; /* stop iteration */
- }
- /* count only if pattern is NULL or member name matches */
- if ( !data->pattern ||
- (strncmp (member_name, data->pattern, strlen(data->pattern)) == 0)
- ) {
- data->count++;
- }
- return 0; /* continue iteration */
+ return 1; /* stop iteration */
+ }
+
+ /* count only if pattern is NULL or member name matches */
+ if ( !data->pattern ||
+ (strncmp (member_name, data->pattern, strlen(data->pattern)) == 0)
+ ) {
+ data->count++;
+ }
+
+ return 0; /* continue iteration */
}
/*!
@@ -2054,9 +2109,6 @@ _H5Part_get_num_objects_matching_pattern (
data.type = type;
data.pattern = pattern;
-/* herr = H5Giterate ( group_id, group_name, &idx, */
-/* _H5Part_iteration_operator, &data ); */
-
#ifndef H5_USE_16_API
hid_t child_id = H5Gopen( group_id, group_name, H5P_DEFAULT );
if ( child_id < 0 ) return child_id;
@@ -2079,7 +2131,8 @@ _H5Part_get_num_objects_matching_pattern (
/*!
\ingroup h5part_kernel
- Iterator for \c H5Giterate().
+ \return 1 on success
+ 0 for no entry
*/
h5part_int64_t
_H5Part_get_object_name (
@@ -2101,40 +2154,35 @@ _H5Part_get_object_name (
data.name = obj_name;
data.len = (size_t)len_obj_name;
-/* herr = H5Giterate ( group_id, group_name, &iterator_idx, */
-/* _H5Part_iteration_operator, &data ); */
-
#ifndef H5_USE_16_API
- hid_t child_id = H5Gopen( group_id, group_name, H5P_DEFAULT );
+ hid_t child_id = H5Gopen ( group_id, group_name, H5P_DEFAULT );
if ( child_id < 0 ) return child_id;
- herr = H5Literate( child_id, H5_INDEX_NAME, H5_ITER_INC, 0,
+ herr = H5Literate ( child_id, H5_INDEX_NAME, H5_ITER_INC, 0,
_H5Part_iteration_operator2, &data );
#else
herr = H5Giterate ( group_id, group_name, &iterator_idx,
_H5Part_iteration_operator, &data );
#endif
-
- if ( herr < 0 ) return (h5part_int64_t)herr;
-
- if ( herr == 0 ) HANDLE_H5PART_NOENTRY_ERR( group_name,
- type, idx );
+ if ( herr < 0 ) {
+ return HANDLE_H5L_ITERATE_ERR;
+ }
+ else if ( herr == 0 ) return 0;
#ifndef H5_USE_16_API
- H5Gclose( child_id );
+ herr = H5Gclose ( child_id );
+ if ( herr < 0 ) return HANDLE_H5G_CLOSE_ERR;
#endif
- return H5PART_SUCCESS;
+ return 1;
}
/*!
- \ingroup h5part_read
+ \ingroup h5part_model
- Query whether a particular step already exists in the file
- \c f.
+ Query whether a particular \a step already exists in
+ the file \a f.
- It works for both reading and writing of files
-
- \return true or false
+ \return 0 or 1
*/
h5part_int64_t
H5PartHasStep (
@@ -2146,20 +2194,15 @@ H5PartHasStep (
CHECK_FILEHANDLE( f );
- char name[128];
- /* Work around sprintf bug on older systems */
- if (f->stepno_width == 0 && step == 0) {
- sprintf ( name, "%s#%0*lld", f->groupname_step, 1, (long long) step );
- }
- else {
- sprintf ( name, "%s#%0*lld", f->groupname_step, f->stepno_width, (long long) step );
- }
- return _H5Part_have_group ( f->file, name );
+ char stepname[H5PART_STEPNAME_LEN];
+ _H5Part_get_step_name(f, step, stepname);
+
+ return _H5Part_have_group ( f->file, stepname );
}
/*!
- \ingroup h5part_read
+ \ingroup h5part_model
Get the number of time-steps that are currently stored in the file
\c f.
@@ -2186,7 +2229,7 @@ H5PartGetNumSteps (
}
/*!
- \ingroup h5part_read
+ \ingroup h5part_model
Get the number of datasets that are stored at the current time-step.
@@ -2200,29 +2243,16 @@ H5PartGetNumDatasets (
SET_FNAME ( "H5PartGetNumDatasets" );
- char stepname[128];
-
CHECK_FILEHANDLE( f );
-
- /* Work around sprintf bug on older systems */
- if (f->stepno_width == 0 && f->timestep == 0) {
- sprintf (
- stepname,
- "%s#%0*lld",
- f->groupname_step, 1, (long long) f->timestep );
- }
- else {
- sprintf (
- stepname,
- "%s#%0*lld",
- f->groupname_step, f->stepno_width, (long long) f->timestep );
- }
+
+ char stepname[H5PART_STEPNAME_LEN];
+ _H5Part_get_step_name(f, f->timestep, stepname);
return _H5Part_get_num_objects ( f->file, stepname, H5G_DATASET );
}
/*!
- \ingroup h5part_read
+ \ingroup h5part_model
This reads the name of a dataset specified by it's index in the current
time-step.
@@ -2241,41 +2271,40 @@ H5PartGetDatasetName (
SET_FNAME ( "H5PartGetDatasetName" );
- char stepname[128];
-
CHECK_FILEHANDLE ( f );
CHECK_TIMEGROUP ( f );
- /* Work around sprintf bug on older systems */
- if (f->stepno_width == 0 && f->timestep == 0) {
- sprintf (
- stepname,
- "%s#%0*lld",
- f->groupname_step, 1, (long long) f->timestep );
- }
- else {
- sprintf (
- stepname,
- "%s#%0*lld",
- f->groupname_step, f->stepno_width, (long long) f->timestep );
- }
+ char stepname[H5PART_STEPNAME_LEN];
+ _H5Part_get_step_name(f, f->timestep, stepname);
- return _H5Part_get_object_name (
+ h5part_int64_t herr = _H5Part_get_object_name (
f->file,
stepname,
H5G_DATASET,
idx,
name,
len_of_name );
+ if ( herr == 0 ) HANDLE_H5PART_NOENTRY_ERR(
+ stepname, H5G_DATASET, idx );
+ if ( herr < 0 ) return herr;
+
+ return H5PART_SUCCESS;
}
/*!
- \ingroup h5part_read
+ \ingroup h5part_model
- Gets the name, type and number of elements of a dataset specified by it's
- index in the current time-step.
+ Gets the name, type and number of elements of a dataset based on its
+ index in the current timestep.
- Type is one of \c H5T_NATIVE_DOUBLE or \c H5T_NATIVE_INT64.
+ Type is one of the following macros:
+
+ - \c H5PART_FLOAT64 (for \c h5part_float64_t)
+ - \c H5PART_FLOAT32 (for \c h5part_float32_t)
+ - \c H5PART_INT64 (for \c h5part_int64_t)
+ - \c H5PART_INT32 (for \c h5part_int32_t)
+ - \c H5PART_CHAR (for \c char)
+ - \c H5PART_STRING (for \c char*)
\return \c H5PART_SUCCESS
*/
@@ -2293,127 +2322,69 @@ H5PartGetDatasetInfo (
SET_FNAME ( "H5PartGetDatasetInfo" );
h5part_int64_t herr;
- hid_t dataset_id;
- hid_t mytype;
- char step_name[128];
+ hid_t dataset;
+ hid_t space;
+ hid_t h5type;
CHECK_FILEHANDLE ( f );
CHECK_TIMEGROUP ( f );
- /* Work around sprintf bug on older systems */
- if (f->stepno_width == 0 && f->timestep == 0) {
- sprintf (
- step_name,
- "%s#%0*lld",
- f->groupname_step, 1, (long long) f->timestep );
- }
- else {
- sprintf (
- step_name,
- "%s#%0*lld",
- f->groupname_step, f->stepno_width, (long long) f->timestep );
- }
+ char stepname[H5PART_STEPNAME_LEN];
+ _H5Part_get_step_name(f, f->timestep, stepname);
herr = _H5Part_get_object_name (
f->file,
- step_name,
+ stepname,
H5G_DATASET,
idx,
dataset_name,
len_dataset_name );
- if ( herr < 0 ) return herr;
+ if ( herr == 0 ) {
+ return HANDLE_H5PART_NOENTRY_ERR( stepname, H5G_DATASET, idx );
+ }
+ else if ( herr < 0 ) return herr;
- *nelem = _H5Part_get_num_particles ( f );
- if ( *nelem < 0 ) return *nelem;
-
- dataset_id = H5Dopen( f->timegroup, dataset_name
+ dataset = H5Dopen( f->timegroup, dataset_name
#ifndef H5_USE_16_API
- , H5P_DEFAULT
+ , H5P_DEFAULT
#endif
- );
+ );
+ if ( dataset < 0 ) HANDLE_H5D_OPEN_ERR ( dataset_name );
- if ( dataset_id < 0 ) HANDLE_H5D_OPEN_ERR ( dataset_name );
+ h5type = H5Dget_type ( dataset );
+ if ( h5type < 0 ) HANDLE_H5D_GET_TYPE_ERR;
- mytype = H5Dget_type ( dataset_id );
- if ( mytype < 0 ) HANDLE_H5D_GET_TYPE_ERR;
+ if ( type ) *type = _H5Part_normalize_h5_type ( h5type );
+ if ( *type < 0 ) return *type;
- if ( type ) *type = _H5Part_normalize_h5_type ( mytype );
+ if ( nelem )
+ {
+ space = H5Dget_space ( dataset );
+ if ( space < 0 ) return HANDLE_H5D_GET_SPACE_ERR;
- herr = H5Tclose(mytype);
+ *nelem = H5Sget_simple_extent_npoints ( space );
+ if ( *nelem < 0 )
+ return HANDLE_H5S_GET_SIMPLE_EXTENT_NPOINTS_ERR;
+
+ herr = H5Sclose ( space );
+ if ( herr < 0 ) return HANDLE_H5S_CLOSE_ERR;
+ }
+
+ herr = H5Tclose ( h5type );
if ( herr < 0 ) HANDLE_H5T_CLOSE_ERR;
- herr = H5Dclose(dataset_id);
+ herr = H5Dclose ( dataset );
if ( herr < 0 ) HANDLE_H5D_CLOSE_ERR;
return H5PART_SUCCESS;
}
-static hid_t
-_get_diskshape_for_reading (
- H5PartFile *f,
- hid_t dataset
+static h5part_int64_t
+_H5Part_has_view (
+ H5PartFile *f
) {
- herr_t r;
-
- hid_t space = H5Dget_space(dataset);
- if ( space < 0 ) return (hid_t)HANDLE_H5D_GET_SPACE_ERR;
-
- if ( H5PartHasView(f) ){
- hsize_t stride;
- hsize_t count;
-#ifdef HDF5V160
- hssize_t start;
-#else
- hsize_t start;
-#endif
- _H5Part_print_debug ( "Selection is available" );
-
- /* so, is this selection inclusive or exclusive? */
- start = f->viewstart;
- count = f->viewend - f->viewstart; /* to be inclusive */
- stride=1;
-
- /* now we select a subset */
- if ( f->diskshape > 0 ) {
- r = H5Sselect_hyperslab (
- f->diskshape, H5S_SELECT_SET,
- &start, &stride, &count, NULL);
- if ( r < 0 ) return (hid_t)HANDLE_H5S_SELECT_HYPERSLAB_ERR;
- }
- /* now we select a subset */
- r = H5Sselect_hyperslab (
- space,H5S_SELECT_SET,
- &start, &stride, &count, NULL );
- if ( r < 0 ) return (hid_t)HANDLE_H5S_SELECT_HYPERSLAB_ERR;
-
- _H5Part_print_debug (
- "Selection: range=%d:%d, npoints=%d s=%d",
- (int)f->viewstart,(int)f->viewend,
- (int)H5Sget_simple_extent_npoints(space),
- (int)H5Sget_select_npoints(space) );
- } else {
- _H5Part_print_debug ( "Selection" );
- }
- return space;
-}
-
-static hid_t
-_get_memshape_for_reading (
- H5PartFile *f,
- hid_t dataset
- ) {
-
- if(H5PartHasView(f)) {
- hsize_t dmax=H5S_UNLIMITED;
- hsize_t len = f->viewend - f->viewstart;
- hid_t r = H5Screate_simple(1,&len,&dmax);
- if ( r < 0 ) return (hid_t)HANDLE_H5S_CREATE_SIMPLE_ERR ( len );
- return r;
- }
- else {
- return H5S_ALL;
- }
+ return ( f->viewstart >= 0 ) && ( f->viewend >= 0 );
}
h5part_int64_t
@@ -2425,30 +2396,24 @@ _H5Part_get_num_particles (
hid_t space_id;
hid_t dataset_id;
char dataset_name[128];
- char step_name[128];
hsize_t nparticles;
- /* Get first dataset in current time-step */
- if (f->stepno_width == 0 && f->timestep == 0) {
- sprintf (
- step_name,
- "%s#%0*lld",
- f->groupname_step, 1, (long long) f->timestep );
- }
- else {
- sprintf (
- step_name,
- "%s#%0*lld",
- f->groupname_step, f->stepno_width, (long long) f->timestep );
- }
+ char stepname[H5PART_STEPNAME_LEN];
+ _H5Part_get_step_name(f, f->timestep, stepname);
herr = _H5Part_get_object_name (
f->file,
- step_name,
+ stepname,
H5G_DATASET,
0,
dataset_name, sizeof (dataset_name) );
if ( herr < 0 ) return herr;
+ else if ( herr == 0 ) {
+ _H5Part_print_warn (
+ "There are no datasets in timestep %s: "
+ "reporting 0 particles.", stepname );
+ return 0;
+ }
dataset_id = H5Dopen ( f->timegroup, dataset_name
#ifndef H5_USE_16_API
@@ -2459,22 +2424,31 @@ _H5Part_get_num_particles (
if ( dataset_id < 0 )
return HANDLE_H5D_OPEN_ERR ( dataset_name );
- space_id = _get_diskshape_for_reading ( f, dataset_id );
- if ( space_id < 0 ) return (h5part_int64_t)space_id;
-
- if ( H5PartHasView ( f ) ) {
- nparticles = H5Sget_select_npoints ( space_id );
+ /* if a view exists, use its size as the number of particles */
+ if ( _H5Part_has_view ( f ) ) {
+ nparticles = H5Sget_select_npoints ( f->diskshape );
if ( nparticles < 0 ) return HANDLE_H5S_GET_SELECT_NPOINTS_ERR;
+ if ( nparticles != f->viewend - f->viewstart + 1 )
+ _H5Part_print_warn (
+ "Number of particles (%lld) does not agree "
+ "with view range.", nparticles );
+ return HANDLE_H5PART_BAD_VIEW_ERR (
+ f->viewstart, f->viewend);
}
+ /* otherwise, report all particles on disk in the first dataset
+ * for this timestep */
else {
+ space_id = H5Dget_space ( dataset_id );
+ if ( space_id < 0 ) return HANDLE_H5D_GET_SPACE_ERR;
+
nparticles = H5Sget_simple_extent_npoints ( space_id );
if ( nparticles < 0 )
return HANDLE_H5S_GET_SIMPLE_EXTENT_NPOINTS_ERR;
- }
- if ( space_id != H5S_ALL ) {
+
herr = H5Sclose ( space_id );
if ( herr < 0 ) return HANDLE_H5S_CLOSE_ERR;
}
+
herr = H5Dclose ( dataset_id );
if ( herr < 0 ) return HANDLE_H5D_CLOSE_ERR;
@@ -2482,11 +2456,18 @@ _H5Part_get_num_particles (
}
/*!
- \ingroup h5part_read
+ \ingroup h5part_model
- This gets the number of particles stored in the current timestep.
- It will arbitrarily select a time-step if you haven't already set
- the timestep with \c H5PartSetStep().
+ This function returns the number of particles in the first dataset of
+ the current timestep (or in the first timestep if none has been set).
+
+ If you have neither set the number of particles (read or write)
+ nor set a view (read-only), then this returns the total number of
+ elements on disk of the first dataset if is exists. Otherwise,
+ it returns 0.
+
+ If you have set a view, this return the number of particles
+ in the view.
\return number of particles in current timestep or an error
code.
@@ -2511,33 +2492,36 @@ H5PartGetNumParticles (
static h5part_int64_t
_reset_view (
H5PartFile *f /*!< [in] Handle to open file */
- ) {
+ ) {
herr_t herr = 0;
f->viewstart = -1;
f->viewend = -1;
- if ( f->shape != 0 ){
- herr = H5Sclose(f->shape);
+
+ if ( f->shape != H5S_ALL ) {
+ herr = H5Sclose ( f->shape );
if ( herr < 0 ) return HANDLE_H5S_CLOSE_ERR;
- f->shape=0;
+ f->shape = H5S_ALL;
}
- if(f->diskshape!=0 && f->diskshape!=H5S_ALL){
- herr = H5Sclose(f->diskshape);
+
+ if ( f->diskshape != H5S_ALL ) {
+ herr = H5Sclose ( f->diskshape );
if ( herr < 0 ) return HANDLE_H5S_CLOSE_ERR;
- f->diskshape=H5S_ALL;
+ f->diskshape = H5S_ALL;
}
- f->diskshape = H5S_ALL;
- if(f->memshape!=0 && f->memshape!=H5S_ALL){
+
+ if ( f->memshape != H5S_ALL ){
herr = H5Sclose ( f->memshape );
if ( herr < 0 ) return HANDLE_H5S_CLOSE_ERR;
- f->memshape=H5S_ALL;
+ f->memshape = H5S_ALL;
}
+
return H5PART_SUCCESS;
}
/*!
- \ingroup h5part_read
+ \ingroup h5part_model
*/
h5part_int64_t
H5PartResetView (
@@ -2552,7 +2536,7 @@ H5PartResetView (
}
/*!
- \ingroup h5part_read
+ \ingroup h5part_model
*/
h5part_int64_t
H5PartHasView (
@@ -2560,10 +2544,10 @@ H5PartHasView (
) {
SET_FNAME ( "H5PartHasView" );
- CHECK_FILEHANDLE( f );
+ CHECK_FILEHANDLE ( f );
CHECK_READONLY_MODE ( f );
- return ( f->viewstart >= 0 ) && ( f->viewend >= 0 );
+ return _H5Part_has_view ( f );
}
static h5part_int64_t
@@ -2572,9 +2556,11 @@ _set_view (
h5part_int64_t start, /*!< [in] Start particle */
h5part_int64_t end /*!< [in] End particle */
) {
+
h5part_int64_t herr = 0;
hsize_t total;
hsize_t stride = 1;
+ hsize_t hstart;
hsize_t dmax = H5S_UNLIMITED;
_H5Part_print_debug (
@@ -2596,11 +2582,13 @@ _set_view (
total = (hsize_t) _H5Part_get_num_particles ( f );
if ( total < 0 ) return HANDLE_H5PART_GET_NUM_PARTICLES_ERR ( total );
- if ( start == -1 ) start = 0;
- if ( end == -1 ) end = total;
-
_H5Part_print_debug ( "Total nparticles=%lld", (long long)total );
+ if ( total == 0 ) return H5PART_SUCCESS;
+
+ if ( start == -1 ) start = 0;
+ if ( end == -1 ) end = total - 1; // range is *inclusive*
+
/* so, is this selection inclusive or exclusive?
it appears to be inclusive for both ends of the range.
*/
@@ -2617,38 +2605,115 @@ _set_view (
f->nparticles = end - start + 1;
/* declare overall datasize */
- f->shape = H5Screate_simple ( 1, &total, &total );
+ f->shape = H5Screate_simple ( 1, &total, NULL );
if ( f->shape < 0 )
return HANDLE_H5S_CREATE_SIMPLE_ERR ( total );
- /* declare overall data size but then will select a subset */
- f->diskshape = H5Screate_simple ( 1, &total, &total );
+ /* declare overall data size but then select a subset */
+ f->diskshape = H5Screate_simple ( 1, &total, NULL );
if ( f->diskshape < 0 )
return HANDLE_H5S_CREATE_SIMPLE_ERR ( total );
- /* declare local memory datasize */
- f->memshape = H5Screate_simple(1,&(f->nparticles),&dmax);
- if ( f->memshape < 0 )
- return HANDLE_H5S_CREATE_SIMPLE_ERR ( f->nparticles );
-
+ total = (hsize_t)f->nparticles;
+ hstart = (size_t)start;
herr = H5Sselect_hyperslab (
f->diskshape,
H5S_SELECT_SET,
- (hsize_t*)&start,
+ &hstart,
&stride,
&total,
NULL );
if ( herr < 0 ) return HANDLE_H5S_SELECT_HYPERSLAB_ERR;
+ /* declare local memory datasize */
+ f->memshape = H5Screate_simple ( 1, &total, &dmax );
+ if ( f->memshape < 0 )
+ return HANDLE_H5S_CREATE_SIMPLE_ERR ( f->nparticles );
+
+ return H5PART_SUCCESS;
+}
+
+static h5part_int64_t
+_set_view_indices (
+ H5PartFile *f, /*!< [in] Handle to open file */
+ const hsize_t *indices, /*!< [in] List of indices */
+ h5part_int64_t nelems /*!< [in] Size of list */
+ ) {
+
+ h5part_int64_t herr = 0;
+ hsize_t total;
+ hsize_t dmax = H5S_UNLIMITED;
+
+ herr = _reset_view ( f );
+ if ( herr < 0 ) return herr;
+
+ if ( indices == NULL ) {
+ _H5Part_print_warn (
+ "View indices array is null: reseting view." );
+ return H5PART_SUCCESS;
+ }
+
+ /*
+ View has been reset so H5PartGetNumParticles will tell
+ us the total number of particles.
+
+ For now, we interpret start=-1 to mean 0 and
+ end==-1 to mean end of file
+ */
+ total = (hsize_t) _H5Part_get_num_particles ( f );
+ if ( total < 0 ) return HANDLE_H5PART_GET_NUM_PARTICLES_ERR ( total );
+
+ _H5Part_print_debug ( "Total nparticles=%lld", (long long)total );
+
+ if ( total == 0 ) return H5PART_SUCCESS;
+
+ /* check length of list */
+ if ( nelems < 0 ) {
+ _H5Part_print_warn (
+ "Array of view indices has length < 0: "
+ "resetting view.");
+ f->nparticles = 0;
+ } else {
+ f->nparticles = (hsize_t) nelems;
+ }
+
+ /* declare overall datasize */
+ f->shape = H5Screate_simple ( 1, &total, NULL );
+ if ( f->shape < 0 )
+ return HANDLE_H5S_CREATE_SIMPLE_ERR ( total );
+
+ /* declare overall data size but then will select a subset */
+ f->diskshape = H5Screate_simple ( 1, &total, NULL );
+ if ( f->diskshape < 0 )
+ return HANDLE_H5S_CREATE_SIMPLE_ERR ( total );
+
+ /* declare local memory datasize */
+ total = (size_t)f->nparticles;
+ f->memshape = H5Screate_simple (1, &total, &dmax );
+ if ( f->memshape < 0 )
+ return HANDLE_H5S_CREATE_SIMPLE_ERR ( f->nparticles );
+
+ if ( nelems > 0 ) {
+ herr = H5Sselect_elements (
+ f->diskshape,
+ H5S_SELECT_SET,
+ nelems,
+ indices );
+ } else {
+ herr = H5Sselect_none ( f->diskshape );
+ }
+ if ( herr < 0 ) return HANDLE_H5S_SELECT_ELEMENTS_ERR;
+
return H5PART_SUCCESS;
}
/*!
- \ingroup h5part_read
+ \ingroup h5part_model
For parallel I/O or for subsetting operations on the datafile, the
\c H5PartSetView() function allows you to define a subset of the total
- particle dataset to read. The concept of "view" works for both serial
+ particle dataset to operate on.
+ The concept of "view" works for both serial
and for parallel I/O. The "view" will remain in effect until a new view
is set, or the number of particles in a dataset changes, or the view is
"unset" by calling \c H5PartSetView(file,-1,-1);
@@ -2658,7 +2723,8 @@ _set_view (
reads). However, after you set a view, it will return the number of
particles contained in the view.
- The range is inclusive (the start and the end index).
+ The range is \e inclusive: the end value is the last index of the
+ data.
\return \c H5PART_SUCCESS or error code
*/
@@ -2672,7 +2738,6 @@ H5PartSetView (
SET_FNAME ( "H5PartSetView" );
CHECK_FILEHANDLE( f );
- CHECK_READONLY_MODE ( f );
if ( f->timegroup < 0 ) {
h5part_int64_t herr = _H5Part_set_step ( f, 0 );
@@ -2683,14 +2748,51 @@ H5PartSetView (
}
/*!
- \ingroup h5part_read
+ \ingroup h5part_model
+
+ For parallel I/O or for subsetting operations on the datafile,
+ this function allows you to define a subset of the total
+ dataset to operate on by specifying a list of indices.
+ The concept of "view" works for both serial
+ and for parallel I/O. The "view" will remain in effect until a new view
+ is set, or the number of particles in a dataset changes, or the view is
+ "unset" by calling \c H5PartSetViewIndices(NULL,0);
+
+ Before you set a view, the \c H5PartGetNumParticles() will return the
+ total number of particles in the current time-step (even for the parallel
+ reads). However, after you set a view, it will return the number of
+ particles contained in the view.
+
+ \return \c H5PART_SUCCESS or error code
+*/
+h5part_int64_t
+H5PartSetViewIndices (
+ H5PartFile *f, /*!< [in] Handle to open file */
+ const hsize_t *indices, /*!< [in] List of indices */
+ h5part_int64_t nelems /*!< [in] Size of list */
+ ) {
+
+ SET_FNAME ( "H5PartSetViewIndices" );
+
+ CHECK_FILEHANDLE( f );
+
+ if ( f->timegroup < 0 ) {
+ h5part_int64_t herr = _H5Part_set_step ( f, 0 );
+ if ( herr < 0 ) return herr;
+ }
+
+ return _set_view_indices ( f, indices, nelems );
+}
+
+/*!
+ \ingroup h5part_model
Allows you to query the current view. Start and End
will be \c -1 if there is no current view established.
Use \c H5PartHasView() to see if the view is smaller than the
total dataset.
- \return the number of elements in the view
+ \return the number of elements in the view
*/
h5part_int64_t
H5PartGetView (
@@ -2724,13 +2826,13 @@ H5PartGetView (
}
if ( start ) *start = viewstart;
- if ( end ) *end = viewend;
+ if ( end ) *end = viewend;
- return viewend - viewstart;
+ return viewend - viewstart + 1; // view range is *inclusive*
}
/*!
- \ingroup h5part_read
+ \ingroup h5part_model
If it is too tedious to manually set the start and end coordinates
for a view, the \c H5SetCanonicalView() will automatically select an
@@ -2756,7 +2858,6 @@ H5PartSetCanonicalView (
h5part_int64_t herr;
CHECK_FILEHANDLE( f );
- CHECK_READONLY_MODE ( f )
herr = _reset_view ( f );
if ( herr < 0 ) return HANDLE_H5PART_SET_VIEW_ERR( herr, -1, -1 );
@@ -2764,17 +2865,22 @@ H5PartSetCanonicalView (
#ifdef PARALLEL_IO
h5part_int64_t start = 0;
h5part_int64_t end = 0;
- h5part_int64_t n = 0;
+ h5part_int64_t total = 0;
+ h5part_int64_t pertask = 0;
int i = 0;
if ( f->timegroup < 0 ) {
herr = _H5Part_set_step ( f, 0 );
if ( herr < 0 ) return herr;
}
- n = _H5Part_get_num_particles ( f );
- if ( n < 0 ) return HANDLE_H5PART_GET_NUM_PARTICLES_ERR ( n );
- /*
- now lets query the attributes for this group to see if there
+
+ /* returns all particles (aggregated across all tasks) */
+ total = _H5Part_get_num_particles ( f );
+ if ( total < 0 )
+ return HANDLE_H5PART_GET_NUM_PARTICLES_ERR ( total );
+
+#if 0
+ /* now lets query the attributes for this group to see if there
is a 'pnparticles' group that contains the offsets for the
processors.
*/
@@ -2790,6 +2896,12 @@ H5PartSetCanonicalView (
f->pnparticles[i] = n;
}
}
+#endif
+
+ total /= f->nprocs;
+ for ( i=0; inprocs; i++ ) {
+ f->pnparticles[i] = total;
+ }
for ( i = 0; i < f->myproc; i++ ){
start += f->pnparticles[i];
@@ -2811,7 +2923,8 @@ _read_data (
const hid_t type
) {
- herr_t herr;
+ h5part_int64_t herr;
+ hsize_t ndisk, nread, nmem;
hid_t dataset_id;
hid_t space_id;
hid_t memspace_id;
@@ -2820,6 +2933,7 @@ _read_data (
h5part_int64_t h5err = _H5Part_set_step ( f, f->timestep );
if ( h5err < 0 ) return h5err;
}
+
dataset_id = H5Dopen ( f->timegroup, name
#ifndef H5_USE_16_API
, H5P_DEFAULT
@@ -2828,15 +2942,69 @@ _read_data (
if ( dataset_id < 0 ) return HANDLE_H5D_OPEN_ERR ( name );
- space_id = _get_diskshape_for_reading ( f, dataset_id );
- if ( space_id < 0 ) return (h5part_int64_t)space_id;
+ /* default spaces, if not using a view selection */
+ memspace_id = H5S_ALL;
+ space_id = H5Dget_space ( dataset_id );
+ if ( space_id < 0 ) return HANDLE_H5D_GET_SPACE_ERR;
- memspace_id = _get_memshape_for_reading ( f, dataset_id );
- if ( memspace_id < 0 ) return (h5part_int64_t)memspace_id;
+ /* get the number of elements on disk for the datset */
+ ndisk = H5Sget_simple_extent_npoints ( space_id );
+ if ( ndisk < 0 ) return HANDLE_H5S_GET_SIMPLE_EXTENT_NPOINTS_ERR;
-#if PARALLEL_IO
- herr = _H5Part_start_throttle( f );
- if (herr < 0) return herr;
+ if ( f->diskshape != H5S_ALL )
+ {
+ nread = H5Sget_select_npoints ( f->diskshape );
+ if ( nread < 0 ) return HANDLE_H5S_GET_SELECT_NPOINTS_ERR;
+
+ /* make sure the disk space selected by the view doesn't
+ * exceed the size of the dataset */
+ if ( nread <= ndisk ) {
+ /* we no longer need the dataset space... */
+ herr = H5Sclose ( space_id );
+ if ( herr < 0 ) HANDLE_H5S_CLOSE_ERR;
+ /* ...because it's safe to use the view selection */
+ space_id = f->diskshape;
+ } else {
+ /* the view selection is too big?
+ * fall back to using the dataset space */
+ _H5Part_print_warn (
+ "Ignoring view: dataset[%s] has fewer "
+ "elements on disk (%lld) than are selected "
+ "(%lld).",
+ name, (long long)ndisk, (long long)nread );
+ nread = ndisk;
+ }
+ }
+ else {
+ /* since the view selection is H5S_ALL, we will
+ * read all available elements in the dataset space */
+ nread = ndisk;
+ }
+
+ if ( f->memshape != H5S_ALL )
+ {
+ nmem = H5Sget_select_npoints ( f->memshape );
+ if ( nmem < 0 ) return HANDLE_H5S_GET_SELECT_NPOINTS_ERR;
+
+ /* make sure the memory space selected by the view has
+ * enough capacity for the read */
+ if ( nmem >= nread ) {
+ memspace_id = f->memshape;
+ } else {
+ /* the view selection is too small?
+ * fall back to using H5S_ALL */
+ _H5Part_print_warn (
+ "Ignoring view: dataset[%s] has more "
+ "elements selected (%lld) than are available "
+ "in memory (%lld).",
+ name, (long long)nread, (long long)nmem );
+ memspace_id == H5S_ALL;
+ }
+ }
+
+#ifdef PARALLEL_IO
+ herr = _H5Part_start_throttle ( f );
+ if ( herr < 0 ) return herr;
#endif
herr = H5Dread (
@@ -2848,23 +3016,18 @@ _read_data (
(get hyperslab if needed) */
f->xfer_prop, /* ignore... its for parallel reads */
array );
-
-#if PARALLEL_IO
- herr = _H5Part_end_throttle( f );
- if (herr < 0) return herr;
-#endif
-
if ( herr < 0 ) return HANDLE_H5D_READ_ERR ( name, f->timestep );
- if ( space_id != H5S_ALL ) {
- herr = H5Sclose (space_id );
+#ifdef PARALLEL_IO
+ herr = _H5Part_end_throttle ( f );
+ if ( herr < 0 ) return herr;
+#endif
+
+ if ( space_id != f->diskshape ) {
+ herr = H5Sclose ( space_id );
if ( herr < 0 ) return HANDLE_H5S_CLOSE_ERR;
}
- if ( memspace_id != H5S_ALL )
- herr = H5Sclose ( memspace_id );
- if ( herr < 0 ) return HANDLE_H5S_CLOSE_ERR;
-
herr = H5Dclose ( dataset_id );
if ( herr < 0 ) return HANDLE_H5D_CLOSE_ERR;
@@ -2872,7 +3035,7 @@ _read_data (
}
/*!
- \ingroup h5part_read
+ \ingroup h5part_data
Read array of 64 bit floating point data from file.
@@ -2903,7 +3066,7 @@ H5PartReadDataFloat64 (
}
/*!
- \ingroup h5part_read
+ \ingroup h5part_data
Read array of 32 bit floating point data from file.
@@ -2934,7 +3097,7 @@ H5PartReadDataFloat32 (
}
/*!
- \ingroup h5part_read
+ \ingroup h5part_data
Read array of 64 bit integer data from file.
@@ -2965,7 +3128,7 @@ H5PartReadDataInt64 (
}
/*!
- \ingroup h5part_read
+ \ingroup h5part_data
Read array of 32 bit integer data from file.
@@ -2996,16 +3159,12 @@ H5PartReadDataInt32 (
}
/*!
- \ingroup h5part_read
+ \ingroup h5part_data
- This is the mongo read function that pulls in all of the data for a
- given timestep in one shot. It also takes the timestep as an argument
- and will call \c H5PartSetStep() internally so that you don't have to
- make that call separately.
-
- \note
- See also \c H5PartReadDataInt64() and \c H5PartReadDataFloat64() if you want
- to just read in one of the many datasets.
+ This is an aggregate read function that pulls in all of the data for a
+ typical particle timestep in one shot.
+ It also takes the timestep as an argument
+ and will call \ref H5PartSetStep internally.
\return \c H5PART_SUCCESS or error code
*/
@@ -3067,10 +3226,12 @@ H5PartReadParticleStep (
parallel file system.
Throttling only works with the H5PART_VFD_MPIPOSIX or
- H5PART_VFD_MPIIO_IND drivers.
+ H5PART_VFD_MPIIO_IND drivers and is only available in
+ the parallel library.
\return \c H5PART_SUCCESS
*/
+#ifdef PARALLEL_IO
h5part_int64_t
H5PartSetThrottle (
H5PartFile *f,
@@ -3080,16 +3241,19 @@ H5PartSetThrottle (
SET_FNAME( "H5PartSetThrottle" );
CHECK_FILEHANDLE ( f );
- if (f->flags & H5PART_VFD_MPIIO_IND || f->flags & H5PART_VFD_MPIPOSIX) {
+ if ( f->flags & H5PART_VFD_MPIIO_IND || f->flags & H5PART_VFD_MPIPOSIX ) {
f->throttle = factor;
+ _H5Part_print_info (
+ "Throttling set with factor '%d'", f->throttle );
} else {
- _H5Part_print_warn ("Throttling is not permitted in MPI-IO collective mode.");
+ _H5Part_print_warn (
+ "Throttling is only permitted with the MPI-POSIX "
+ "or MPI-IO Independent VFD." );
}
return H5PART_SUCCESS;
}
-#if PARALLEL_IO
h5part_int64_t
_H5Part_start_throttle (
H5PartFile *f
@@ -3147,10 +3311,10 @@ _H5Part_end_throttle (
}
return H5PART_SUCCESS;
}
-#endif
+#endif // PARALLEL_IO
/*!
- \ingroup h5part_errhandle
+ \ingroup h5part_open
Set verbosity level to \c level.
@@ -3256,7 +3420,7 @@ H5PartAbortErrorHandler (
vfprintf ( stderr, fmt, ap );
fprintf ( stderr, "\n" );
}
- exit (-(int)_h5part_errno);
+ exit ( (int)_h5part_errno );
}
/*!
diff --git a/src/H5Part.f90 b/src/H5Part.f90
new file mode 100644
index 0000000..e44b82d
--- /dev/null
+++ b/src/H5Part.f90
@@ -0,0 +1,439 @@
+! Declaration of subroutines for Fortran Bindings
+
+!> \defgroup h5part_f90_api H5Part F90 API
+
+!> \ingroup h5part_f90_api
+!! \defgroup h5partf_open File Opening and Closing
+!<
+
+!> \ingroup h5part_f90_api
+!! \defgroup h5partf_model Setting up the Data Model
+!<
+
+!> \ingroup h5part_f90_api
+!! \defgroup h5partf_data Reading and Writing Datasets
+!<
+
+!> \ingroup h5part_f90_api
+!! \defgroup h5partf_attrib Reading and Writing Attributes
+!<
+
+
+!!!!!!!! File Opening and Closing !!!!!!!!
+
+!> \ingroup h5partf_open
+!! Opens a file for reading. See \ref H5PartOpenFile
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_openr ( filename )
+ CHARACTER(LEN=*), INTENT(IN) :: filename !< the filename to open for reading
+END FUNCTION
+
+!> \ingroup h5partf_open
+!! Opens a file for writing in truncate mode. See \ref H5PartOpenFile
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_openw ( filename )
+ CHARACTER(LEN=*), INTENT(IN) :: filename !< the filename to open for writing
+END FUNCTION
+
+!> \ingroup h5partf_open
+!! Opens a file for writing in append mode. See \ref H5PartOpenFile
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_opena ( filename )
+ CHARACTER(LEN=*), INTENT(IN) :: filename !< the filename to open for appending
+END FUNCTION
+
+!> \ingroup h5partf_open
+!! Opens a parallel file for reading.
+!! See \ref H5PartOpenFileParallel
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_openr_par ( filename, mpi_communicator )
+ CHARACTER(LEN=*), INTENT(IN) :: filename !< the filename to open for reading
+ INTEGER, INTENT(IN) :: mpi_communicator !< the MPI communicator used by the program
+END FUNCTION
+
+!> \ingroup h5partf_open
+!! Opens a parallel file for writing in truncate mode.
+!! See \ref H5PartOpenFileParallel
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_openw_par ( filename, mpi_communicator )
+ CHARACTER(LEN=*), INTENT(IN) :: filename !< the filename to open for writing
+ INTEGER, INTENT(IN) :: mpi_communicator !< the MPI_Communicator used by the program
+END FUNCTION
+
+!> \ingroup h5partf_open
+!! Opens a parallel file for writing in append mode.
+!! See \ref H5PartOpenFileParallel
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_opena_par ( filename, mpi_communicator )
+ CHARACTER(LEN=*), INTENT(IN) :: filename !< the filename to open for appending
+ INTEGER, INTENT(IN) :: mpi_communicator !< the MPI_Communicator used by the program
+END FUNCTION
+
+!> \ingroup h5partf_open
+!! Opens a file for reading and specifies an HDF5 alignment.
+!! See \ref H5PartOpenFileAlign
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_openr_align ( filename, align )
+ CHARACTER(LEN=*), INTENT(IN) :: filename !< the filename to open for reading
+ INTEGER*8, INTENT(IN) :: align !< alignment value in bytes
+END FUNCTION
+
+!> \ingroup h5partf_open
+!! Opens a file for writing in truncate mode and specifies an HDF5 alignment.
+!! See \ref H5PartOpenFileAlign
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_openw_align ( filename, align )
+ CHARACTER(LEN=*), INTENT(IN) :: filename !< the filename to open for writing
+ INTEGER*8, INTENT(IN) :: align !< alignment value in bytes
+END FUNCTION
+
+!> \ingroup h5partf_open
+!! Opens a file for writing in append mode and specifies an HDF5 alignment.
+!! See \ref H5PartOpenFileAlign
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_opena_align ( filename, align )
+ CHARACTER(LEN=*), INTENT(IN) :: filename !< the filename to open for appending
+ INTEGER*8, INTENT(IN) :: align !< alignment value in bytes
+END FUNCTION
+
+!> \ingroup h5partf_open
+!! Opens a parallel file for reading and specifies an HDF5 alignment.
+!! See \ref H5PartOpenFileParallelAlign
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_openr_par_align ( filename, mpi_communicator, align )
+ CHARACTER(LEN=*), INTENT(IN) :: filename !< the filename to open for reading
+ INTEGER, INTENT(IN) :: mpi_communicator !< the MPI_Communicator used by the program
+ INTEGER*8, INTENT(IN) :: align !< alignment value in bytes
+END FUNCTION
+
+!> \ingroup h5partf_open
+!! Opens a parallel file for writing in truncate mode and specifies
+!! an HDF5 alignment.
+!! See \ref H5PartOpenFileParallelAlign
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_openw_par_align ( filename, mpi_communicator, align, flags )
+ CHARACTER(LEN=*), INTENT(IN) :: filename !< the filename to open for writing
+ INTEGER, INTENT(IN) :: mpi_communicator !< the MPI_Communicator used by the program
+ INTEGER*8, INTENT(IN) :: align !< alignment value in bytes
+ CHARACTER(LEN=*), INTENT(IN) :: flags !< additional flags
+END FUNCTION
+
+!> \ingroup h5partf_open
+!! Opens a parallel file for writing in append mode and specifies
+!! an HDF5 alignment.
+!! See \ref H5PartOpenFileParallelAlign
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_opena_par_align ( filename, mpi_communicator, align, flags )
+ CHARACTER(LEN=*), INTENT(IN) :: filename !< the filename to open for appending
+ INTEGER, INTENT(IN) :: mpi_communicator !< the MPI_Communicator used by the program
+ INTEGER*8, INTENT(IN) :: align !< alignment value in bytes
+ CHARACTER(LEN=*), INTENT(IN) :: flags !< additional flags
+END FUNCTION
+
+!> \ingroup h5partf_open
+!! Closes a file. See \ref H5PartCloseFile
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_close ( filehandle )
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open
+END FUNCTION
+
+!> \ingroup h5partf_open
+!! See \ref H5PartSetVerbosityLevel
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_set_verbosity_level ( level )
+ INTEGER*8, INTENT(IN) :: level !< the level from 0 (no output) to 5 (most detailed)
+END FUNCTION
+
+
+!!!!!!!! Setting up the Data Model !!!!!!!!
+
+!> \ingroup h5partf_model
+!! See \ref H5PartSetNumParticles
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_setnpoints ( filehandle, npoints )
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open
+ INTEGER*8, INTENT(IN) :: npoints !< the number of particles on *this* processor
+END FUNCTION
+
+!> \ingroup h5partf_model
+!! See \ref H5PartSetNumParticlesStrided
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_setnpoints_strided ( filehandle, npoints, stride )
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open
+ INTEGER*8, INTENT(IN) :: npoints !< the number of particles on *this* processor
+ INTEGER*8, INTENT(IN) :: stride !< the stride value (e.g. the number of fields in the particle data array)
+END FUNCTION
+
+!> \ingroup h5partf_model
+!! See \ref H5PartSetStep
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_setstep (filehandle,step)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open
+ INTEGER*8, INTENT(IN) :: step !< a timestep value >= 1
+END FUNCTION
+
+!> \ingroup h5partf_model
+!! See \ref H5PartGetNumSteps
+!! \return the number of steps or error code
+!<
+INTEGER*8 FUNCTION h5pt_getnsteps (filehandle)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open
+END FUNCTION
+
+!> \ingroup h5partf_model
+!! See \ref H5PartGetNumDatasets
+!! \return the number of datasets or error code
+!<
+INTEGER*8 FUNCTION h5pt_getndatasets (filehandle)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open
+END FUNCTION
+
+!> \ingroup h5partf_model
+!! See \ref H5PartGetNumParticles
+!! \return the number of particles or error code
+!<
+INTEGER*8 FUNCTION h5pt_getnpoints (filehandle)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open
+END FUNCTION
+
+!> \ingroup h5partf_model
+!! See \ref H5PartGetDatasetName
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_getdatasetname (filehandle,index,name)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open
+ INTEGER*8, INTENT(IN) :: index !< index of dataset to query (starting from 0)
+ CHARACTER(LEN=*), INTENT(OUT) :: name !< buffer to read the dataset name into
+END FUNCTION
+
+!> \ingroup h5partf_model
+!! See \ref H5PartSetView
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_setview (filehandle,start,end)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open
+ INTEGER*8, INTENT(IN) :: start !< offset of the first particle in the view
+ INTEGER*8, INTENT(IN) :: end !< offset of the last particle in the view (inclusive)
+END FUNCTION
+
+!> \ingroup h5partf_model
+!! See \ref H5PartSetViewIndices
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_setview_indices (filehandle,indices,nelem)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open
+ INTEGER*8, INTENT(IN) :: indices(*) !< list of indicies to select in this view
+ INTEGER*8, INTENT(IN) :: nelem !< number of particles in the list
+END FUNCTION
+
+!> \ingroup h5partf_model
+!! See \ref H5PartResetView
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_resetview (filehandle)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open
+END FUNCTION
+
+!> \ingroup h5partf_model
+!! See \ref H5PartResetView
+!! \return 1 if true, 0 if false, or error code
+!<
+INTEGER*8 FUNCTION h5pt_hasview (filehandle)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open
+END FUNCTION
+
+!> \ingroup h5partf_model
+!! See \ref H5PartGetView
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_getview (filehandle,start,end)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open
+ INTEGER*8, INTENT(OUT) :: start !< buffer to store the offset of the first particle in the view
+ INTEGER*8, INTENT(OUT) :: end !< buffer to store the offset of the last particle in the view (inclusive)
+END FUNCTION
+
+
+!!!!!!!! Reading and Writing Datasets !!!!!!!!
+
+!> \ingroup h5partf_data
+!! See \ref H5PartWriteDataFloat64
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_writedata_r8 ( filehandle, name, data )
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the dataset
+ REAL*8, INTENT(IN) :: data(*) !< the array of float64 data to write
+END FUNCTION
+
+!> \ingroup h5partf_data
+!! See \ref H5PartWriteDataFloat32
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_writedata_r4 ( filehandle, name, data )
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the dataset
+ REAL, INTENT(IN) :: data(*) !< the array of float32 data to write
+END FUNCTION
+
+!> \ingroup h5partf_data
+!! See \ref H5PartWriteDataInt64
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_writedata_i8 ( filehandle, name, data )
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the dataset
+ INTEGER*8, INTENT(IN) :: data(*) !< the array of int64 data to write
+END FUNCTION
+
+!> \ingroup h5partf_data
+!! See \ref H5PartWriteDataInt32
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_writedata_i4 ( filehandle, name, data )
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the dataset
+ INTEGER, INTENT(IN) :: data(*) !< the array of int32 data to write
+END FUNCTION
+
+
+!> \ingroup h5partf_data
+!! See \ref H5PartReadDataFloat64
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_readdata_r8 (filehandle,name,data)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the dataset
+ REAL*8, INTENT(OUT) :: data(*) !< array to read float64 data into
+END FUNCTION
+
+!> \ingroup h5partf_data
+!! See \ref H5PartReadDataFloat32
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_readdata_r4 (filehandle,name,data)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the dataset
+ REAL, INTENT(OUT) :: data(*) !< array to read float32 data into
+END FUNCTION
+
+!> \ingroup h5partf_data
+!! See \ref H5PartReadDataInt64
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_readdata_i8 (filehandle,name,data)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the dataset
+ INTEGER*8, INTENT(OUT) :: data(*) !< array to read int64 data into
+END FUNCTION
+
+!> \ingroup h5partf_data
+!! See \ref H5PartReadDataInt32
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_readdata_i4 (filehandle,name,data)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the dataset
+ INTEGER, INTENT(OUT) :: data(*) !< array to read int32 data into
+END FUNCTION
+
+
+!!!!!!!! Reading and Writing Attributes !!!!!!!!
+
+!> \ingroup h5partf_attrib
+!! See \ref H5PartWriteFileAttribString
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_writefileattrib_string (filehandle,attrib_name,attrib_value)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the attribute
+ CHARACTER(LEN=*), INTENT(IN) :: value !< the string value to store
+END FUNCTION
+
+!> \ingroup h5partf_attrib
+!! See \ref H5PartWriteStepAttribString
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_writestepattrib_string (filehandle,attrib_name,attrib_value)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the attribute
+ CHARACTER(LEN=*), INTENT(IN) :: value !< the string value to store
+END FUNCTION
+
+!> \ingroup h5partf_attrib
+!! Reads the attribute \c name in the file root ("/")
+!! into the string buffer \c value.
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_readfileattrib_string (filehandle,attrib_name,attrib_value)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the attribute
+ CHARACTER(LEN=*), INTENT(OUT) :: value !< buffer to read the string value into
+END FUNCTION
+
+!> \ingroup h5partf_attrib
+!! Reads the attribute \c name in the current step
+!! into the string buffer \c value.
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_readstepattrib_string (filehandle,attrib_name,attrib_value)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the attribute
+ CHARACTER(LEN=*), INTENT(OUT) :: value !< buffer to read the string value into
+END FUNCTION
+
+!> \ingroup h5partf_attrib
+!! See \ref H5PartGetNumStepAttribs
+!! \return number of attributes or error code
+!<
+INTEGER*8 FUNCTION h5pt_getnstepattribs (filehandle)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open
+END FUNCTION
+
+!> \ingroup h5partf_attrib
+!! See \ref H5PartGetNumFileAttribs
+!! \return number of attributes or error code
+!<
+INTEGER*8 FUNCTION h5pt_getnfileattribs (filehandle)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open
+END FUNCTION
+
+!> \ingroup h5partf_attrib
+!! See \ref H5PartGetStepAttribInfo
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_getstepattribinfo (filehandle,idx,attrib_name,attrib_nelem)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open
+ INTEGER*8, INTENT(IN) :: index !< index of the attribute to query (starting from 0)
+ CHARACTER(LEN=*), INTENT(OUT) :: name !< buffer to read the attribute name into
+ INTEGER*8, INTENT(OUT) :: nelem !< number of elements in the attribute's array
+END FUNCTION
+
+!> \ingroup h5partf_attrib
+!! See \ref H5PartGetFileAttribInfo
+!! \return 0 on success or error code
+!<
+INTEGER*8 FUNCTION h5pt_getfileattribinfo (filehandle,idx,attrib_name,attrib_nelem)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open
+ INTEGER*8, INTENT(IN) :: index !< index of the attribute to query (starting from 0)
+ CHARACTER(LEN=*), INTENT(OUT) :: name !< buffer to read the attribute name into
+ INTEGER*8, INTENT(OUT) :: nelem !< number of elements in the attribute's array
+END FUNCTION
+
+
diff --git a/src/H5Part.h b/src/H5Part.h
index 735bde7..f39b9d7 100644
--- a/src/H5Part.h
+++ b/src/H5Part.h
@@ -10,12 +10,17 @@ extern "C" {
#endif
#include "H5PartTypes.h"
-
+#include "H5PartAttrib.h"
#include "H5Block.h"
#ifdef PARALLEL_IO
#include "H5MultiBlock.h"
#endif
+#define H5PART_VER_STRING "1.5.0"
+#define H5PART_VER_MAJOR 1
+#define H5PART_VER_MINOR 5
+#define H5PART_VER_RELEASE 0
+
/* error values */
#define H5PART_SUCCESS 0
#define H5PART_ERR_NOMEM -12
@@ -24,6 +29,8 @@ extern "C" {
#define H5PART_ERR_INIT -200
#define H5PART_ERR_NOENTRY -201
+#define H5PART_ERR_NOTYPE -210
+#define H5PART_ERR_BAD_VIEW -220
#define H5PART_ERR_MPI -300
#define H5PART_ERR_HDF5 -400
@@ -50,7 +57,7 @@ extern "C" {
#define H5PART_FLOAT64 ((h5part_int64_t)H5T_NATIVE_DOUBLE)
#define H5PART_FLOAT32 ((h5part_int64_t)H5T_NATIVE_FLOAT)
#define H5PART_CHAR ((h5part_int64_t)H5T_NATIVE_CHAR)
-#define H5PART_STRING ((h5part_int64_t)H5T_STRING)
+#define H5PART_STRING ((h5part_int64_t)H5T_C_S1)
/*========== File Opening/Closing ===============*/
H5PartFile*
@@ -107,6 +114,13 @@ H5PartSetNumParticles (
const h5part_int64_t nparticles
);
+h5part_int64_t
+H5PartSetNumParticlesStrided (
+ H5PartFile *f, /*!< [in] Handle to open file */
+ const h5part_int64_t nparticles, /*!< [in] Number of particles */
+ const h5part_int64_t stride /*!< [in] Stride (e.g. number of fields in the particle array) */
+ );
+
h5part_int64_t
H5PartWriteDataFloat64 (
H5PartFile *f,
@@ -188,6 +202,12 @@ H5PartSetView (
const h5part_int64_t end
);
+h5part_int64_t
+H5PartSetViewIndices (
+ H5PartFile *f, /*!< [in] Handle to open file */
+ const hsize_t *indices, /*!< [in] List of indices */
+ h5part_int64_t nelems /*!< [in] Size of list */
+ );
h5part_int64_t
H5PartGetView (
@@ -292,20 +312,6 @@ H5PartWriteStepAttribString (
const char *value
);
-h5part_int64_t
-H5PartWriteStepAttribInt32 (
- H5PartFile *f,
- const char *name,
- const h5part_int32_t value
- );
-
-h5part_int64_t
-H5PartWriteStepAttribFloat32 (
- H5PartFile *f,
- const char *name,
- const h5part_float32_t value
- );
-
h5part_int64_t
H5PartGetNumStepAttribs ( /* for current filestep */
H5PartFile *f
diff --git a/src/H5PartAttrib.c b/src/H5PartAttrib.c
new file mode 100644
index 0000000..57735a7
--- /dev/null
+++ b/src/H5PartAttrib.c
@@ -0,0 +1,265 @@
+
+#include
+#include
+
+#include
+#include "H5Part.h"
+#include "H5PartErrors.h"
+#include "H5PartPrivate.h"
+
+
+/*!
+ \ingroup h5part_attrib
+
+ Writes a \c value of type floating points (64-bit)
+ to the root ("/") of the file
+ as attribute \c name.
+
+ \return \c H5PART_SUCCESS or error code
+*/
+h5part_int64_t
+H5PartWriteFileAttribFloat64 (
+ H5PartFile *f, /*!< IN: file handle */
+ const char *name, /*!< IN: attribute name */
+ const h5part_float64_t value /*!< IN: attribute value */
+ ) {
+
+ SET_FNAME ( "H5PartWriteFileAttribFloat64" );
+
+ CHECK_FILEHANDLE ( f );
+ CHECK_WRITABLE_MODE( f );
+
+ h5part_int64_t herr = _H5Part_write_file_attrib (
+ f,
+ name,
+ H5T_NATIVE_DOUBLE,
+ (void*)&value,
+ 1 );
+ if ( herr < 0 ) return herr;
+
+ return H5PART_SUCCESS;
+}
+
+/*!
+ \ingroup h5part_attrib
+
+ Writes a \c value of type floating points (32-bit)
+ to the root ("/") of the file
+ as attribute \c name.
+
+ \return \c H5PART_SUCCESS or error code
+*/
+h5part_int64_t
+H5PartWriteFileAttribFloat32 (
+ H5PartFile *f, /*!< IN: file handle */
+ const char *name, /*!< IN: attribute name */
+ const h5part_float32_t value /*!< IN: attribute value */
+ ) {
+
+ SET_FNAME ( "H5PartWriteFileAttribFloat32" );
+
+ CHECK_FILEHANDLE ( f );
+ CHECK_WRITABLE_MODE( f );
+
+ h5part_int64_t herr = _H5Part_write_file_attrib (
+ f,
+ name,
+ H5T_NATIVE_FLOAT,
+ (void*)&value,
+ 1 );
+ if ( herr < 0 ) return herr;
+
+ return H5PART_SUCCESS;
+}
+
+/*!
+ \ingroup h5part_attrib
+
+ Writes a \c value of type integers (64-bit)
+ to the root ("/") of the file
+ as attribute \c name.
+
+ \return \c H5PART_SUCCESS or error code
+*/
+h5part_int64_t
+H5PartWriteFileAttribInt64 (
+ H5PartFile *f, /*!< IN: file handle */
+ const char *name, /*!< IN: attribute name */
+ const h5part_int64_t value /*!< IN: attribute value */
+ ) {
+
+ SET_FNAME ( "H5PartWriteFileAttribInt64" );
+
+ CHECK_FILEHANDLE ( f );
+ CHECK_WRITABLE_MODE( f );
+
+ h5part_int64_t herr = _H5Part_write_file_attrib (
+ f,
+ name,
+ H5T_NATIVE_INT64,
+ (void*)&value,
+ 1 );
+ if ( herr < 0 ) return herr;
+
+ return H5PART_SUCCESS;
+}
+
+/*!
+ \ingroup h5part_attrib
+
+ Writes a \c value of type integers (32-bit)
+ to the root ("/") of the file
+ as attribute \c name.
+
+ \return \c H5PART_SUCCESS or error code
+*/
+h5part_int64_t
+H5PartWriteFileAttribInt32 (
+ H5PartFile *f, /*!< IN: file handle */
+ const char *name, /*!< IN: attribute name */
+ const h5part_int32_t value /*!< IN: attribute value */
+ ) {
+
+ SET_FNAME ( "H5PartWriteFileAttribInt32" );
+
+ CHECK_FILEHANDLE ( f );
+ CHECK_WRITABLE_MODE( f );
+
+ h5part_int64_t herr = _H5Part_write_file_attrib (
+ f,
+ name,
+ H5T_NATIVE_INT32,
+ (void*)&value,
+ 1 );
+ if ( herr < 0 ) return herr;
+
+ return H5PART_SUCCESS;
+}
+
+/*!
+ \ingroup h5part_attrib
+
+ Writes a \c value of type floating points (64-bit)
+ to the root ("/") of the file
+ as attribute \c name.
+
+ \return \c H5PART_SUCCESS or error code
+*/
+h5part_int64_t
+H5PartWriteStepAttribFloat64 (
+ H5PartFile *f, /*!< IN: file handle */
+ const char *name, /*!< IN: attribute name */
+ const h5part_float64_t value /*!< IN: attribute value */
+ ) {
+
+ SET_FNAME ( "H5PartWriteStepAttribFloat64" );
+
+ CHECK_FILEHANDLE ( f );
+ CHECK_WRITABLE_MODE( f );
+
+ h5part_int64_t herr = _H5Part_write_step_attrib (
+ f,
+ name,
+ H5T_NATIVE_DOUBLE,
+ (void*)&value,
+ 1 );
+ if ( herr < 0 ) return herr;
+
+ return H5PART_SUCCESS;
+}
+
+/*!
+ \ingroup h5part_attrib
+
+ Writes a \c value of type floating points (32-bit)
+ to the root ("/") of the file
+ as attribute \c name.
+
+ \return \c H5PART_SUCCESS or error code
+*/
+h5part_int64_t
+H5PartWriteStepAttribFloat32 (
+ H5PartFile *f, /*!< IN: file handle */
+ const char *name, /*!< IN: attribute name */
+ const h5part_float32_t value /*!< IN: attribute value */
+ ) {
+
+ SET_FNAME ( "H5PartWriteStepAttribFloat32" );
+
+ CHECK_FILEHANDLE ( f );
+ CHECK_WRITABLE_MODE( f );
+
+ h5part_int64_t herr = _H5Part_write_step_attrib (
+ f,
+ name,
+ H5T_NATIVE_FLOAT,
+ (void*)&value,
+ 1 );
+ if ( herr < 0 ) return herr;
+
+ return H5PART_SUCCESS;
+}
+
+/*!
+ \ingroup h5part_attrib
+
+ Writes a \c value of type integers (64-bit)
+ to the root ("/") of the file
+ as attribute \c name.
+
+ \return \c H5PART_SUCCESS or error code
+*/
+h5part_int64_t
+H5PartWriteStepAttribInt64 (
+ H5PartFile *f, /*!< IN: file handle */
+ const char *name, /*!< IN: attribute name */
+ const h5part_int64_t value /*!< IN: attribute value */
+ ) {
+
+ SET_FNAME ( "H5PartWriteStepAttribInt64" );
+
+ CHECK_FILEHANDLE ( f );
+ CHECK_WRITABLE_MODE( f );
+
+ h5part_int64_t herr = _H5Part_write_step_attrib (
+ f,
+ name,
+ H5T_NATIVE_INT64,
+ (void*)&value,
+ 1 );
+ if ( herr < 0 ) return herr;
+
+ return H5PART_SUCCESS;
+}
+
+/*!
+ \ingroup h5part_attrib
+
+ Writes a \c value of type integers (32-bit)
+ to the root ("/") of the file
+ as attribute \c name.
+
+ \return \c H5PART_SUCCESS or error code
+*/
+h5part_int64_t
+H5PartWriteStepAttribInt32 (
+ H5PartFile *f, /*!< IN: file handle */
+ const char *name, /*!< IN: attribute name */
+ const h5part_int32_t value /*!< IN: attribute value */
+ ) {
+
+ SET_FNAME ( "H5PartWriteStepAttribInt32" );
+
+ CHECK_FILEHANDLE ( f );
+ CHECK_WRITABLE_MODE( f );
+
+ h5part_int64_t herr = _H5Part_write_step_attrib (
+ f,
+ name,
+ H5T_NATIVE_INT32,
+ (void*)&value,
+ 1 );
+ if ( herr < 0 ) return herr;
+
+ return H5PART_SUCCESS;
+}
diff --git a/src/H5PartAttrib.f90 b/src/H5PartAttrib.f90
new file mode 100644
index 0000000..23fb8b6
--- /dev/null
+++ b/src/H5PartAttrib.f90
@@ -0,0 +1,168 @@
+
+!< \ingroup h5partf_attrib
+!! See \ref H5PartWritefileAttribFloat64
+!! \return 0 on success or error code
+!>
+INTEGER*8 FUNCTION h5pt_writefileattrib_r8 ( filehandle, field_name, attrib_name, attrib_value, attrib_nelem)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the attribute
+ REAL*8, INTENT(IN) :: data(*) !< the array of data to write into the attribute
+ INTEGER*8, INTENT(IN) :: nelem !< the number of elements in the array
+END FUNCTION
+
+!< \ingroup h5partf_attrib
+!! Read the attribute \c name into the buffer \c data.
+!! \return 0 on success or error code
+!>
+INTEGER*8 FUNCTION h5pt_readfileattrib_r8 ( filehandle, name, data )
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the attribute
+ REAL*8, INTENT(OUT) :: data(*) !< buffer to read value into
+END FUNCTION
+
+!< \ingroup h5partf_attrib
+!! See \ref H5PartWritefileAttribFloat32
+!! \return 0 on success or error code
+!>
+INTEGER*8 FUNCTION h5pt_writefileattrib_r4 ( filehandle, field_name, attrib_name, attrib_value, attrib_nelem)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the attribute
+ REAL*4, INTENT(IN) :: data(*) !< the array of data to write into the attribute
+ INTEGER*8, INTENT(IN) :: nelem !< the number of elements in the array
+END FUNCTION
+
+!< \ingroup h5partf_attrib
+!! Read the attribute \c name into the buffer \c data.
+!! \return 0 on success or error code
+!>
+INTEGER*8 FUNCTION h5pt_readfileattrib_r4 ( filehandle, name, data )
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the attribute
+ REAL*4, INTENT(OUT) :: data(*) !< buffer to read value into
+END FUNCTION
+
+!< \ingroup h5partf_attrib
+!! See \ref H5PartWritefileAttribInt64
+!! \return 0 on success or error code
+!>
+INTEGER*8 FUNCTION h5pt_writefileattrib_i8 ( filehandle, field_name, attrib_name, attrib_value, attrib_nelem)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the attribute
+ INTEGER*8, INTENT(IN) :: data(*) !< the array of data to write into the attribute
+ INTEGER*8, INTENT(IN) :: nelem !< the number of elements in the array
+END FUNCTION
+
+!< \ingroup h5partf_attrib
+!! Read the attribute \c name into the buffer \c data.
+!! \return 0 on success or error code
+!>
+INTEGER*8 FUNCTION h5pt_readfileattrib_i8 ( filehandle, name, data )
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the attribute
+ INTEGER*8, INTENT(OUT) :: data(*) !< buffer to read value into
+END FUNCTION
+
+!< \ingroup h5partf_attrib
+!! See \ref H5PartWritefileAttribInt32
+!! \return 0 on success or error code
+!>
+INTEGER*8 FUNCTION h5pt_writefileattrib_i4 ( filehandle, field_name, attrib_name, attrib_value, attrib_nelem)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the attribute
+ INTEGER*4, INTENT(IN) :: data(*) !< the array of data to write into the attribute
+ INTEGER*8, INTENT(IN) :: nelem !< the number of elements in the array
+END FUNCTION
+
+!< \ingroup h5partf_attrib
+!! Read the attribute \c name into the buffer \c data.
+!! \return 0 on success or error code
+!>
+INTEGER*8 FUNCTION h5pt_readfileattrib_i4 ( filehandle, name, data )
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the attribute
+ INTEGER*4, INTENT(OUT) :: data(*) !< buffer to read value into
+END FUNCTION
+
+!< \ingroup h5partf_attrib
+!! See \ref H5PartWritestepAttribFloat64
+!! \return 0 on success or error code
+!>
+INTEGER*8 FUNCTION h5pt_writestepattrib_r8 ( filehandle, field_name, attrib_name, attrib_value, attrib_nelem)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the attribute
+ REAL*8, INTENT(IN) :: data(*) !< the array of data to write into the attribute
+ INTEGER*8, INTENT(IN) :: nelem !< the number of elements in the array
+END FUNCTION
+
+!< \ingroup h5partf_attrib
+!! Read the attribute \c name into the buffer \c data.
+!! \return 0 on success or error code
+!>
+INTEGER*8 FUNCTION h5pt_readstepattrib_r8 ( filehandle, name, data )
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the attribute
+ REAL*8, INTENT(OUT) :: data(*) !< buffer to read value into
+END FUNCTION
+
+!< \ingroup h5partf_attrib
+!! See \ref H5PartWritestepAttribFloat32
+!! \return 0 on success or error code
+!>
+INTEGER*8 FUNCTION h5pt_writestepattrib_r4 ( filehandle, field_name, attrib_name, attrib_value, attrib_nelem)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the attribute
+ REAL*4, INTENT(IN) :: data(*) !< the array of data to write into the attribute
+ INTEGER*8, INTENT(IN) :: nelem !< the number of elements in the array
+END FUNCTION
+
+!< \ingroup h5partf_attrib
+!! Read the attribute \c name into the buffer \c data.
+!! \return 0 on success or error code
+!>
+INTEGER*8 FUNCTION h5pt_readstepattrib_r4 ( filehandle, name, data )
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the attribute
+ REAL*4, INTENT(OUT) :: data(*) !< buffer to read value into
+END FUNCTION
+
+!< \ingroup h5partf_attrib
+!! See \ref H5PartWritestepAttribInt64
+!! \return 0 on success or error code
+!>
+INTEGER*8 FUNCTION h5pt_writestepattrib_i8 ( filehandle, field_name, attrib_name, attrib_value, attrib_nelem)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the attribute
+ INTEGER*8, INTENT(IN) :: data(*) !< the array of data to write into the attribute
+ INTEGER*8, INTENT(IN) :: nelem !< the number of elements in the array
+END FUNCTION
+
+!< \ingroup h5partf_attrib
+!! Read the attribute \c name into the buffer \c data.
+!! \return 0 on success or error code
+!>
+INTEGER*8 FUNCTION h5pt_readstepattrib_i8 ( filehandle, name, data )
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the attribute
+ INTEGER*8, INTENT(OUT) :: data(*) !< buffer to read value into
+END FUNCTION
+
+!< \ingroup h5partf_attrib
+!! See \ref H5PartWritestepAttribInt32
+!! \return 0 on success or error code
+!>
+INTEGER*8 FUNCTION h5pt_writestepattrib_i4 ( filehandle, field_name, attrib_name, attrib_value, attrib_nelem)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the attribute
+ INTEGER*4, INTENT(IN) :: data(*) !< the array of data to write into the attribute
+ INTEGER*8, INTENT(IN) :: nelem !< the number of elements in the array
+END FUNCTION
+
+!< \ingroup h5partf_attrib
+!! Read the attribute \c name into the buffer \c data.
+!! \return 0 on success or error code
+!>
+INTEGER*8 FUNCTION h5pt_readstepattrib_i4 ( filehandle, name, data )
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the attribute
+ INTEGER*4, INTENT(OUT) :: data(*) !< buffer to read value into
+END FUNCTION
diff --git a/src/H5PartAttrib.h b/src/H5PartAttrib.h
new file mode 100644
index 0000000..a625d1d
--- /dev/null
+++ b/src/H5PartAttrib.h
@@ -0,0 +1,71 @@
+
+#ifndef _H5PART_ATTRIB_H_
+#define _H5PART_ATTRIB_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+h5part_int64_t
+H5PartWriteFileAttribFloat64 (
+ H5PartFile *f,
+ const char *name,
+ const h5part_float64_t data
+ );
+
+h5part_int64_t
+H5PartWriteFileAttribFloat32 (
+ H5PartFile *f,
+ const char *name,
+ const h5part_float32_t data
+ );
+
+h5part_int64_t
+H5PartWriteFileAttribInt64 (
+ H5PartFile *f,
+ const char *name,
+ const h5part_int64_t data
+ );
+
+h5part_int64_t
+H5PartWriteFileAttribInt32 (
+ H5PartFile *f,
+ const char *name,
+ const h5part_int32_t data
+ );
+
+h5part_int64_t
+H5PartWriteStepAttribFloat64 (
+ H5PartFile *f,
+ const char *name,
+ const h5part_float64_t data
+ );
+
+h5part_int64_t
+H5PartWriteStepAttribFloat32 (
+ H5PartFile *f,
+ const char *name,
+ const h5part_float32_t data
+ );
+
+h5part_int64_t
+H5PartWriteStepAttribInt64 (
+ H5PartFile *f,
+ const char *name,
+ const h5part_int64_t data
+ );
+
+h5part_int64_t
+H5PartWriteStepAttribInt32 (
+ H5PartFile *f,
+ const char *name,
+ const h5part_int32_t data
+ );
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/H5PartAttribF.c b/src/H5PartAttribF.c
new file mode 100644
index 0000000..64c3e07
--- /dev/null
+++ b/src/H5PartAttribF.c
@@ -0,0 +1,421 @@
+
+#include "H5Part.h"
+#include "H5PartPrivate.h"
+#include "Underscore.h"
+
+#if defined(F77_SINGLE_UNDERSCORE)
+#define F77NAME(a,b) a
+#elif defined(F77_CRAY_UNDERSCORE)
+#define F77NAME(a,b) b
+#elif defined(F77_NO_UNDERSCORE)
+#else
+#error Error, no way to determine how to construct fortran bindings
+#endif
+
+#if ! defined(F77_NO_UNDERSCORE)
+#define h5pt_writefileattrib_r8 F77NAME ( \
+ h5pt_writefileattrib_r8_, \
+ H5PT_WRITEFILEATTRIB_R8 )
+#endif
+
+h5part_int64_t
+h5pt_writefileattrib_r8 (
+ h5part_int64_t *f,
+ const char *name,
+ const h5part_float64_t *data,
+ const h5part_float64_t *nelem,
+ const int l_name
+ ) {
+
+ H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
+
+ char *name2 =_H5Part_strdupfor2c ( name, l_name );
+
+ h5part_int64_t herr = H5PartWriteFileAttrib (
+ filehandle, name2, H5PART_FLOAT64, data, *nelem);
+
+ free ( name2 );
+ return herr;
+}
+
+#if ! defined(F77_NO_UNDERSCORE)
+#define h5pt_writefileattrib_r8 F77NAME ( \
+ h5pt_writefileattrib_r8_, \
+ H5PT_WRITEFILEATTRIB_R8 )
+#endif
+
+h5part_int64_t
+h5pt_readfileattrib_r8 (
+ h5part_int64_t *f,
+ const char *name,
+ const h5part_float64_t *data,
+ const int l_name
+ ) {
+
+ H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
+
+ char *name2 =_H5Part_strdupfor2c ( name, l_name );
+
+ h5part_int64_t herr = H5PartReadFileAttrib (
+ filehandle, name2, (void*)data);
+
+ free ( name2 );
+ return herr;
+}
+
+#if ! defined(F77_NO_UNDERSCORE)
+#define h5pt_writefileattrib_r4 F77NAME ( \
+ h5pt_writefileattrib_r4_, \
+ H5PT_WRITEFILEATTRIB_R4 )
+#endif
+
+h5part_int64_t
+h5pt_writefileattrib_r4 (
+ h5part_int64_t *f,
+ const char *name,
+ const h5part_float32_t *data,
+ const h5part_float32_t *nelem,
+ const int l_name
+ ) {
+
+ H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
+
+ char *name2 =_H5Part_strdupfor2c ( name, l_name );
+
+ h5part_int64_t herr = H5PartWriteFileAttrib (
+ filehandle, name2, H5PART_FLOAT32, data, *nelem);
+
+ free ( name2 );
+ return herr;
+}
+
+#if ! defined(F77_NO_UNDERSCORE)
+#define h5pt_writefileattrib_r4 F77NAME ( \
+ h5pt_writefileattrib_r4_, \
+ H5PT_WRITEFILEATTRIB_R4 )
+#endif
+
+h5part_int64_t
+h5pt_readfileattrib_r4 (
+ h5part_int64_t *f,
+ const char *name,
+ const h5part_float32_t *data,
+ const int l_name
+ ) {
+
+ H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
+
+ char *name2 =_H5Part_strdupfor2c ( name, l_name );
+
+ h5part_int64_t herr = H5PartReadFileAttrib (
+ filehandle, name2, (void*)data);
+
+ free ( name2 );
+ return herr;
+}
+
+#if ! defined(F77_NO_UNDERSCORE)
+#define h5pt_writefileattrib_i8 F77NAME ( \
+ h5pt_writefileattrib_i8_, \
+ H5PT_WRITEFILEATTRIB_I8 )
+#endif
+
+h5part_int64_t
+h5pt_writefileattrib_i8 (
+ h5part_int64_t *f,
+ const char *name,
+ const h5part_int64_t *data,
+ const h5part_int64_t *nelem,
+ const int l_name
+ ) {
+
+ H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
+
+ char *name2 =_H5Part_strdupfor2c ( name, l_name );
+
+ h5part_int64_t herr = H5PartWriteFileAttrib (
+ filehandle, name2, H5PART_INT64, data, *nelem);
+
+ free ( name2 );
+ return herr;
+}
+
+#if ! defined(F77_NO_UNDERSCORE)
+#define h5pt_writefileattrib_i8 F77NAME ( \
+ h5pt_writefileattrib_i8_, \
+ H5PT_WRITEFILEATTRIB_I8 )
+#endif
+
+h5part_int64_t
+h5pt_readfileattrib_i8 (
+ h5part_int64_t *f,
+ const char *name,
+ const h5part_int64_t *data,
+ const int l_name
+ ) {
+
+ H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
+
+ char *name2 =_H5Part_strdupfor2c ( name, l_name );
+
+ h5part_int64_t herr = H5PartReadFileAttrib (
+ filehandle, name2, (void*)data);
+
+ free ( name2 );
+ return herr;
+}
+
+#if ! defined(F77_NO_UNDERSCORE)
+#define h5pt_writefileattrib_i4 F77NAME ( \
+ h5pt_writefileattrib_i4_, \
+ H5PT_WRITEFILEATTRIB_I4 )
+#endif
+
+h5part_int64_t
+h5pt_writefileattrib_i4 (
+ h5part_int64_t *f,
+ const char *name,
+ const h5part_int32_t *data,
+ const h5part_int32_t *nelem,
+ const int l_name
+ ) {
+
+ H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
+
+ char *name2 =_H5Part_strdupfor2c ( name, l_name );
+
+ h5part_int64_t herr = H5PartWriteFileAttrib (
+ filehandle, name2, H5PART_INT32, data, *nelem);
+
+ free ( name2 );
+ return herr;
+}
+
+#if ! defined(F77_NO_UNDERSCORE)
+#define h5pt_writefileattrib_i4 F77NAME ( \
+ h5pt_writefileattrib_i4_, \
+ H5PT_WRITEFILEATTRIB_I4 )
+#endif
+
+h5part_int64_t
+h5pt_readfileattrib_i4 (
+ h5part_int64_t *f,
+ const char *name,
+ const h5part_int32_t *data,
+ const int l_name
+ ) {
+
+ H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
+
+ char *name2 =_H5Part_strdupfor2c ( name, l_name );
+
+ h5part_int64_t herr = H5PartReadFileAttrib (
+ filehandle, name2, (void*)data);
+
+ free ( name2 );
+ return herr;
+}
+
+#if ! defined(F77_NO_UNDERSCORE)
+#define h5pt_writestepattrib_r8 F77NAME ( \
+ h5pt_writestepattrib_r8_, \
+ H5PT_WRITESTEPATTRIB_R8 )
+#endif
+
+h5part_int64_t
+h5pt_writestepattrib_r8 (
+ h5part_int64_t *f,
+ const char *name,
+ const h5part_float64_t *data,
+ const h5part_float64_t *nelem,
+ const int l_name
+ ) {
+
+ H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
+
+ char *name2 =_H5Part_strdupfor2c ( name, l_name );
+
+ h5part_int64_t herr = H5PartWriteStepAttrib (
+ filehandle, name2, H5PART_FLOAT64, data, *nelem);
+
+ free ( name2 );
+ return herr;
+}
+
+#if ! defined(F77_NO_UNDERSCORE)
+#define h5pt_writestepattrib_r8 F77NAME ( \
+ h5pt_writestepattrib_r8_, \
+ H5PT_WRITESTEPATTRIB_R8 )
+#endif
+
+h5part_int64_t
+h5pt_readstepattrib_r8 (
+ h5part_int64_t *f,
+ const char *name,
+ const h5part_float64_t *data,
+ const int l_name
+ ) {
+
+ H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
+
+ char *name2 =_H5Part_strdupfor2c ( name, l_name );
+
+ h5part_int64_t herr = H5PartReadStepAttrib (
+ filehandle, name2, (void*)data);
+
+ free ( name2 );
+ return herr;
+}
+
+#if ! defined(F77_NO_UNDERSCORE)
+#define h5pt_writestepattrib_r4 F77NAME ( \
+ h5pt_writestepattrib_r4_, \
+ H5PT_WRITESTEPATTRIB_R4 )
+#endif
+
+h5part_int64_t
+h5pt_writestepattrib_r4 (
+ h5part_int64_t *f,
+ const char *name,
+ const h5part_float32_t *data,
+ const h5part_float32_t *nelem,
+ const int l_name
+ ) {
+
+ H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
+
+ char *name2 =_H5Part_strdupfor2c ( name, l_name );
+
+ h5part_int64_t herr = H5PartWriteStepAttrib (
+ filehandle, name2, H5PART_FLOAT32, data, *nelem);
+
+ free ( name2 );
+ return herr;
+}
+
+#if ! defined(F77_NO_UNDERSCORE)
+#define h5pt_writestepattrib_r4 F77NAME ( \
+ h5pt_writestepattrib_r4_, \
+ H5PT_WRITESTEPATTRIB_R4 )
+#endif
+
+h5part_int64_t
+h5pt_readstepattrib_r4 (
+ h5part_int64_t *f,
+ const char *name,
+ const h5part_float32_t *data,
+ const int l_name
+ ) {
+
+ H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
+
+ char *name2 =_H5Part_strdupfor2c ( name, l_name );
+
+ h5part_int64_t herr = H5PartReadStepAttrib (
+ filehandle, name2, (void*)data);
+
+ free ( name2 );
+ return herr;
+}
+
+#if ! defined(F77_NO_UNDERSCORE)
+#define h5pt_writestepattrib_i8 F77NAME ( \
+ h5pt_writestepattrib_i8_, \
+ H5PT_WRITESTEPATTRIB_I8 )
+#endif
+
+h5part_int64_t
+h5pt_writestepattrib_i8 (
+ h5part_int64_t *f,
+ const char *name,
+ const h5part_int64_t *data,
+ const h5part_int64_t *nelem,
+ const int l_name
+ ) {
+
+ H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
+
+ char *name2 =_H5Part_strdupfor2c ( name, l_name );
+
+ h5part_int64_t herr = H5PartWriteStepAttrib (
+ filehandle, name2, H5PART_INT64, data, *nelem);
+
+ free ( name2 );
+ return herr;
+}
+
+#if ! defined(F77_NO_UNDERSCORE)
+#define h5pt_writestepattrib_i8 F77NAME ( \
+ h5pt_writestepattrib_i8_, \
+ H5PT_WRITESTEPATTRIB_I8 )
+#endif
+
+h5part_int64_t
+h5pt_readstepattrib_i8 (
+ h5part_int64_t *f,
+ const char *name,
+ const h5part_int64_t *data,
+ const int l_name
+ ) {
+
+ H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
+
+ char *name2 =_H5Part_strdupfor2c ( name, l_name );
+
+ h5part_int64_t herr = H5PartReadStepAttrib (
+ filehandle, name2, (void*)data);
+
+ free ( name2 );
+ return herr;
+}
+
+#if ! defined(F77_NO_UNDERSCORE)
+#define h5pt_writestepattrib_i4 F77NAME ( \
+ h5pt_writestepattrib_i4_, \
+ H5PT_WRITESTEPATTRIB_I4 )
+#endif
+
+h5part_int64_t
+h5pt_writestepattrib_i4 (
+ h5part_int64_t *f,
+ const char *name,
+ const h5part_int32_t *data,
+ const h5part_int32_t *nelem,
+ const int l_name
+ ) {
+
+ H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
+
+ char *name2 =_H5Part_strdupfor2c ( name, l_name );
+
+ h5part_int64_t herr = H5PartWriteStepAttrib (
+ filehandle, name2, H5PART_INT32, data, *nelem);
+
+ free ( name2 );
+ return herr;
+}
+
+#if ! defined(F77_NO_UNDERSCORE)
+#define h5pt_writestepattrib_i4 F77NAME ( \
+ h5pt_writestepattrib_i4_, \
+ H5PT_WRITESTEPATTRIB_I4 )
+#endif
+
+h5part_int64_t
+h5pt_readstepattrib_i4 (
+ h5part_int64_t *f,
+ const char *name,
+ const h5part_int32_t *data,
+ const int l_name
+ ) {
+
+ H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
+
+ char *name2 =_H5Part_strdupfor2c ( name, l_name );
+
+ h5part_int64_t herr = H5PartReadStepAttrib (
+ filehandle, name2, (void*)data);
+
+ free ( name2 );
+ return herr;
+}
diff --git a/src/H5PartErrors.h b/src/H5PartErrors.h
index aa62179..5c1d2f9 100644
--- a/src/H5PartErrors.h
+++ b/src/H5PartErrors.h
@@ -1,22 +1,23 @@
-#ifndef __H5PARTERRORS_H
-#define __H5PARTERRORS_H
+#ifndef __H5PART_ERRORS_H
+#define __H5PART_ERRORS_H
+extern h5part_error_handler _err_handler;
/***************** Error Handling ***************/
#define CHECK_FILEHANDLE( f ) \
- if ( _file_is_valid ( f ) != H5PART_SUCCESS ) \
+ if ( _H5Part_file_is_valid ( f ) != H5PART_SUCCESS ) \
return HANDLE_H5PART_BADFD_ERR;
#define CHECK_WRITABLE_MODE( f ) \
- if ( f->mode==H5PART_READ ) \
+ if ( f->flags & H5PART_READ ) \
return (*_err_handler) ( \
_H5Part_get_funcname(), \
H5PART_ERR_INVAL, \
- "Attempting to write to read-only file" );
+ "Attempting to write to read-only file." );
#define CHECK_READONLY_MODE( f ) \
- if ( ! f->mode==H5PART_READ ) \
+ if ( ! (f->flags & H5PART_READ) ) \
return (*_err_handler) ( \
_H5Part_get_funcname(), \
H5PART_ERR_INVAL, \
@@ -43,6 +44,13 @@
H5PART_ERR_INIT, \
"Cannot initialize H5Part." );
+#define HANDLE_H5PART_INVALID_ERR( name, value ) \
+ (*_err_handler) ( \
+ _H5Part_get_funcname(), \
+ H5PART_ERR_INVAL, \
+ "Invalid value '%lld' for '%s'.", \
+ (long long)value, name);
+
#define HANDLE_H5PART_NOMEM_ERR \
(*_err_handler) ( \
_H5Part_get_funcname(), \
@@ -75,6 +83,13 @@
"Cannot set view to (%lld, %lld).", \
(long long)start, (long long)end );
+#define HANDLE_H5PART_BAD_VIEW_ERR( start, end ) \
+ (*_err_handler) ( \
+ _H5Part_get_funcname(), \
+ H5PART_ERR_BAD_VIEW, \
+ "Problem with existing view (%lld, %lld).", \
+ (long long)start, (long long)end );
+
#define HANDLE_H5PART_GET_NUM_PARTICLES_ERR( rc ) \
(*_err_handler) ( \
_H5Part_get_funcname(), \
@@ -88,6 +103,12 @@
"No entry with index %lld and type %d in group %s!", \
(long long)idx, type, group_name );
+#define HANDLE_H5PART_TYPE_ERR \
+ (*_err_handler) ( \
+ _H5Part_get_funcname(), \
+ H5PART_ERR_NOTYPE, \
+ "Encountered unkown data type!");
+
/**************** HDF5 *********************/
/* H5A: Attribute */
#define HANDLE_H5A_CLOSE_ERR \
@@ -318,7 +339,7 @@
(*_err_handler) ( \
_H5Part_get_funcname(), \
H5PART_ERR_HDF5, \
- "Cannot determine the number of elements in dataspace selection." );
+ "Cannot determine number of elements in dataspace selection." );
#define HANDLE_H5S_GET_SIMPLE_EXTENT_NPOINTS_ERR \
(*_err_handler) ( \
@@ -330,7 +351,13 @@
(*_err_handler) ( \
_H5Part_get_funcname(), \
H5PART_ERR_HDF5, \
- "Cannot set select hyperslap region or add the specified region" );
+ "Cannot select hyperslap region of dataspace." );
+
+#define HANDLE_H5S_SELECT_ELEMENTS_ERR \
+ (*_err_handler) ( \
+ _H5Part_get_funcname(), \
+ H5PART_ERR_HDF5, \
+ "Cannot select elements in dataspace." );
/* H5T: type */
#define HANDLE_H5T_STRING_ERR \
@@ -345,6 +372,12 @@
H5PART_ERR_HDF5, \
"Cannot release datatype." );
+/* H5L */
+#define HANDLE_H5L_ITERATE_ERR \
+ (*_err_handler) ( \
+ _H5Part_get_funcname(), \
+ H5PART_ERR_HDF5, \
+ "Cannot iterate through group." );
/* MPI */
#define HANDLE_MPI_ALLGATHER_ERR \
diff --git a/src/H5PartF.c b/src/H5PartF.c
index 6f13a4d..9b85b9f 100755
--- a/src/H5PartF.c
+++ b/src/H5PartF.c
@@ -60,6 +60,9 @@
#define h5pt_setnpoints F77NAME ( \
h5pt_setnpoints_, \
H5PT_SETNPOINTS )
+#define h5pt_setnpoints_strided F77NAME ( \
+ h5pt_setnpoints_strided_, \
+ H5PT_SETNPOINTS_STRIDED )
#define h5pt_setstep F77NAME ( \
h5pt_setstep_, \
H5PT_SETSTEP )
@@ -89,14 +92,14 @@
#define h5pt_getdatasetname F77NAME ( \
h5pt_getdatasetname_, \
H5PT_GETDATASETNAME )
-#define h5pt_getnumpoints F77NAME ( \
- h5pt_getnumpoints_, \
- H5PT_GETNUMPOINTS )
/* Views and parallelism */
#define h5pt_setview F77NAME ( \
h5pt_setview_, \
H5PT_SETVIEW )
+#define h5pt_setview_indices F77NAME ( \
+ h5pt_setview_indices_, \
+ H5PT_SETVIEW_INDICES )
#define h5pt_resetview F77NAME ( \
h5pt_resetview_, \
H5PT_RESETVIEW )
@@ -122,21 +125,9 @@
H5PT_READDATA_I4 )
/* Writing attributes */
-#define h5pt_writefileattrib_r8 F77NAME ( \
- h5pt_writefileattrib_r8_, \
- H5PT_WRITEFILEATTRIB_R8 )
-#define h5pt_writefileattrib_i8 F77NAME ( \
- h5pt_writefileattrib_i8_, \
- H5PT_WRITEFILEATTRIB_I8 )
#define h5pt_writefileattrib_string F77NAME ( \
h5pt_writefileattrib_string_, \
H5PT_writefileattrib_string )
-#define h5pt_writestepattrib_r8 F77NAME ( \
- h5pt_writestepattrib_r8_, \
- H5PT_WRITESTEPATTRIB_R8 )
-#define h5pt_writestepattrib_i8 F77NAME ( \
- h5pt_writestepattrib_i8_, \
- H5PT_WRITESTEPATTRIB_I8 )
#define h5pt_writestepattrib_string F77NAME ( \
h5pt_writestepattrib_string_, \
H5PT_WRITESTEPATTRIB_STRING )
@@ -154,27 +145,9 @@
#define h5pt_getfileattribinfo F77NAME ( \
h5pt_getfileattribinfo_, \
H5PT_GETFILEATTRIBINFO )
-#define h5pt_readstepattrib F77NAME ( \
- h5pt_readstepattrib_, \
- H5PT_READSTEPATTRIB )
-#define h5pt_readstepattrib_r8 F77NAME ( \
- h5pt_readstepattrib_r8_, \
- H5PT_READSTEPATTRIB_R8 )
-#define h5pt_readstepattrib_i8 F77NAME ( \
- h5pt_readstepattrib_i8_, \
- H5PT_READSTEPATTRIB_I8 )
#define h5pt_readstepattrib_string F77NAME ( \
h5pt_readstepattrib_string_, \
H5PT_READSTEPATTRIB_STRING )
-#define h5pt_readfileattrib F77NAME ( \
- h5pt_readfileattrib_, \
- H5PT_READFILEATTRIB )
-#define h5pt_readfileattrib_r8 F77NAME ( \
- h5pt_readfileattrib_r8_, \
- H5PT_READFILEATTRIB_R8 )
-#define h5pt_readfileattrib_i8 F77NAME ( \
- h5pt_readfileattrib_i8_, \
- H5PT_READFILEATTRIB_I8 )
#define h5pt_readfileattrib_string F77NAME ( \
h5pt_readfileattrib_string_, \
H5PT_READFILEATTRIB_STRING )
@@ -480,6 +453,18 @@ h5pt_setnpoints (
return H5PartSetNumParticles ( filehandle, *np );
}
+h5part_int64_t
+h5pt_setnpoints_strided (
+ const h5part_int64_t *f,
+ h5part_int64_t *np,
+ h5part_int64_t *stride
+ ) {
+
+ H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
+
+ return H5PartSetNumParticlesStrided ( filehandle, *np, *stride );
+}
+
h5part_int64_t
h5pt_setstep (
const h5part_int64_t *f,
@@ -615,16 +600,6 @@ h5pt_getdatasetname (
return herr;
}
-h5part_int64_t
-h5pt_getnumpoints (
- const h5part_int64_t *f
- ) {
-
- H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
-
- return H5PartGetNumParticles( filehandle );
-}
-
/*=============Setting and getting views================*/
h5part_int64_t
@@ -639,6 +614,18 @@ h5pt_setview (
return H5PartSetView ( filehandle, *start, *end );
}
+h5part_int64_t
+h5pt_setview_indices (
+ const h5part_int64_t *f,
+ const h5part_int64_t *indices,
+ const h5part_int64_t *nelem
+ ) {
+
+ H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
+
+ return H5PartSetViewIndices ( filehandle, indices, *nelem );
+}
+
h5part_int64_t
h5pt_resetview (
const h5part_int64_t *f
@@ -749,49 +736,6 @@ h5pt_readdata_i4 (
/*=================== Attributes ================*/
-/* Writeing attributes */
-h5part_int64_t
-h5pt_writefileattrib_r8 (
- const h5part_int64_t *f,
- const char *attrib_name,
- const h5part_float64_t *attrib_value,
- const h5part_int64_t *attrib_nelem,
- const int l_attrib_name
- ) {
-
- H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
-
- char *attrib_name2 = _H5Part_strdupfor2c (attrib_name,l_attrib_name);
-
- h5part_int64_t herr = H5PartWriteFileAttrib (
- filehandle,
- attrib_name2, H5T_NATIVE_DOUBLE, attrib_value, *attrib_nelem );
-
- free ( attrib_name2 );
- return herr;
-}
-
-h5part_int64_t
-h5pt_writefileattrib_i8 (
- const h5part_int64_t *f,
- const char *attrib_name,
- const h5part_int64_t *attrib_value,
- const h5part_int64_t *attrib_nelem,
- const int l_attrib_name
- ) {
-
- H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
-
- char *attrib_name2 = _H5Part_strdupfor2c (attrib_name,l_attrib_name);
-
- h5part_int64_t herr = H5PartWriteFileAttrib (
- filehandle,
- attrib_name2, H5T_NATIVE_INT64, attrib_value, *attrib_nelem );
-
- free ( attrib_name2 );
- return herr;
-}
-
h5part_int64_t
h5pt_writefileattrib_string (
const h5part_int64_t *f,
@@ -814,48 +758,6 @@ h5pt_writefileattrib_string (
return herr;
}
-h5part_int64_t
-h5pt_writestepattrib_r8 (
- const h5part_int64_t *f,
- const char *attrib_name,
- const h5part_float64_t *attrib_value,
- const h5part_int64_t *attrib_nelem,
- const int l_attrib_name
- ) {
-
- H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
-
- char *attrib_name2 = _H5Part_strdupfor2c ( attrib_name, l_attrib_name );
-
- h5part_int64_t herr = H5PartWriteStepAttrib (
- filehandle,
- attrib_name2, H5T_NATIVE_DOUBLE, attrib_value, *attrib_nelem );
-
- free ( attrib_name2 );
- return herr;
-}
-
-h5part_int64_t
-h5pt_writestepattrib_i8 (
- const h5part_int64_t *f,
- const char *attrib_name,
- const h5part_int64_t *attrib_value,
- const h5part_int64_t *attrib_nelem,
- const int l_attrib_name
- ) {
-
- H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
-
- char *attrib_name2 = _H5Part_strdupfor2c ( attrib_name, l_attrib_name );
-
- h5part_int64_t herr = H5PartWriteStepAttrib (
- filehandle,
- attrib_name2, H5T_NATIVE_INT64, attrib_value, *attrib_nelem );
-
- free ( attrib_name2 );
- return herr;
-}
-
h5part_int64_t
h5pt_writestepattrib_string (
const h5part_int64_t *f,
@@ -937,49 +839,6 @@ h5pt_getfileattribinfo (
return herr;
}
-h5part_int64_t
-h5pt_readstepattrib (
- const h5part_int64_t *f,
- const char *attrib_name,
- void *attrib_value,
- const int l_attrib_name
- ) {
-
- H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
-
- char * attrib_name2 = _H5Part_strdupfor2c (attrib_name,l_attrib_name);
-
- h5part_int64_t herr = H5PartReadStepAttrib (
- filehandle, attrib_name2, attrib_value );
-
- free ( attrib_name2 );
- return herr;
-}
-
-h5part_int64_t
-h5pt_readstepattrib_r8 (
- const h5part_int64_t *f,
- const char *attrib_name,
- h5part_float64_t *attrib_value,
- const int l_attrib_name
- ) {
-
- return h5pt_readstepattrib (
- f, attrib_name, attrib_value, l_attrib_name );
-}
-
-h5part_int64_t
-h5pt_readstepattrib_i8 (
- const h5part_int64_t *f,
- const char *attrib_name,
- h5part_int64_t *attrib_value,
- const int l_attrib_name
- ) {
-
- return h5pt_readstepattrib (
- f, attrib_name, attrib_value, l_attrib_name );
-}
-
h5part_int64_t
h5pt_readstepattrib_string (
const h5part_int64_t *f,
@@ -988,56 +847,20 @@ h5pt_readstepattrib_string (
const int l_attrib_name,
const int l_attrib_value
) {
-
- h5part_int64_t herr = h5pt_readstepattrib (
- f, attrib_name, attrib_value, l_attrib_name );
- _H5Part_strc2for ( attrib_value, l_attrib_value );
- return herr;
-}
-
-
-h5part_int64_t
-h5pt_readfileattrib (
- const h5part_int64_t *f,
- const char *attrib_name,
- void *attrib_value,
- const int l_attrib_name
- ) {
-
H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
char * attrib_name2 = _H5Part_strdupfor2c (attrib_name,l_attrib_name);
- h5part_int64_t herr = H5PartReadFileAttrib (
+ h5part_int64_t herr = H5PartReadStepAttrib (
filehandle, attrib_name2, attrib_value );
+ _H5Part_strc2for ( attrib_value, l_attrib_value );
+
free ( attrib_name2 );
return herr;
}
-h5part_int64_t
-h5pt_readfileattrib_r8 (
- const h5part_int64_t *f,
- const char *attrib_name,
- h5part_float64_t *attrib_value,
- const int l_attrib_name
- ) {
- return h5pt_readfileattrib (
- f, attrib_name, attrib_value, l_attrib_name );
-}
-
-h5part_int64_t
-h5pt_readfileattrib_i8 (
- const h5part_int64_t *f,
- const char *attrib_name,
- h5part_int64_t *attrib_value,
- const int l_attrib_name
- ) {
- return h5pt_readfileattrib (
- f, attrib_name, attrib_value, l_attrib_name );
-}
-
h5part_int64_t
h5pt_readfileattrib_string (
const h5part_int64_t *f,
@@ -1046,11 +869,17 @@ h5pt_readfileattrib_string (
const int l_attrib_name,
const int l_attrib_value
) {
-
- h5part_int64_t herr = h5pt_readfileattrib (
- f, attrib_name, attrib_value, l_attrib_name );
+
+ H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
+
+ char * attrib_name2 = _H5Part_strdupfor2c (attrib_name,l_attrib_name);
+
+ h5part_int64_t herr = H5PartReadFileAttrib (
+ filehandle, attrib_name2, attrib_value );
_H5Part_strc2for ( attrib_value, l_attrib_value );
+
+ free ( attrib_name2 );
return herr;
}
diff --git a/src/H5PartF90.inc b/src/H5PartF90.inc
deleted file mode 100644
index 3ac5c68..0000000
--- a/src/H5PartF90.inc
+++ /dev/null
@@ -1,291 +0,0 @@
-! Declaration of subroutines for Fortran Bindings
-! open/close interface
-
-INTERFACE
- INTEGER*8 FUNCTION h5pt_openr ( filename )
- CHARACTER(LEN=*), INTENT(IN) :: filename ! the filename to open for reading
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_openw ( filename )
- CHARACTER(LEN=*), INTENT(IN) :: filename ! the filename to open for writing
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_opena ( filename )
- CHARACTER(LEN=*), INTENT(IN) :: filename ! the filename to open for appending
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_openr_par ( filename, mpi_communicator )
- CHARACTER(LEN=*), INTENT(IN) :: filename ! the filename to open for reading
- INTEGER, INTENT(IN) :: mpi_communicator ! the MPI_Communicator used by the program
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_openw_par ( filename, mpi_communicator )
- CHARACTER(LEN=*), INTENT(IN) :: filename ! the filename to open for writing
- INTEGER, INTENT(IN) :: mpi_communicator ! the MPI_Communicator used by the program
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_opena_par ( filename, mpi_communicator )
- CHARACTER(LEN=*), INTENT(IN) :: filename ! the filename to open for appending
- INTEGER, INTENT(IN) :: mpi_communicator ! the MPI_Communicator used by the program
- END FUNCTION
-
-
- INTEGER*8 FUNCTION h5pt_openr_align ( filename, align )
- CHARACTER(LEN=*), INTENT(IN) :: filename ! the filename to open for reading
- INTEGER*8, INTENT(IN) :: align ! alignment value in bytes
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_openw_align ( filename, align )
- CHARACTER(LEN=*), INTENT(IN) :: filename ! the filename to open for writing
- INTEGER*8, INTENT(IN) :: align ! alignment value in bytes
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_opena_align ( filename, align )
- CHARACTER(LEN=*), INTENT(IN) :: filename ! the filename to open for appending
- INTEGER*8, INTENT(IN) :: align ! alignment value in bytes
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_openr_par_align ( filename, mpi_communicator, align )
- CHARACTER(LEN=*), INTENT(IN) :: filename ! the filename to open for reading
- INTEGER, INTENT(IN) :: mpi_communicator ! the MPI_Communicator used by the program
- INTEGER*8, INTENT(IN) :: align ! alignment value in bytes
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_openw_par_align ( filename, mpi_communicator, align, flags )
- CHARACTER(LEN=*), INTENT(IN) :: filename ! the filename to open for writing
- INTEGER, INTENT(IN) :: mpi_communicator ! the MPI_Communicator used by the program
- INTEGER*8, INTENT(IN) :: align ! alignment value in bytes
- CHARACTER(LEN=*), INTENT(IN) :: flags ! additional flags
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_opena_par_align ( filename, mpi_communicator, align, flags )
- CHARACTER(LEN=*), INTENT(IN) :: filename ! the filename to open for appending
- INTEGER, INTENT(IN) :: mpi_communicator ! the MPI_Communicator used by the program
- INTEGER*8, INTENT(IN) :: align ! alignment value in bytes
- CHARACTER(LEN=*), INTENT(IN) :: flags ! additional flags
- END FUNCTION
-
-
- INTEGER*8 FUNCTION h5pt_close ( filehandle )
- INTEGER*8, INTENT(IN) :: filehandle ! close this open filehandle
- END FUNCTION
-
-!==============Writing and Setting Dataset info========
-
- INTEGER*8 FUNCTION h5pt_setnpoints ( filehandle, npoints )
- INTEGER*8, INTENT(IN) :: filehandle
- INTEGER*8, INTENT(IN) :: npoints ! The number of particles on *this* processor
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_setstep (filehandle,step)
- INTEGER*8, INTENT(IN) :: filehandle
- INTEGER*8, INTENT(IN) :: step ! Set the current timestep in the file to this
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_writedata_r8 ( filehandle, name, data )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: name ! The name of the data we are writing
- REAL*8, INTENT(IN) :: data(*) ! The dataarray to write. The number of
- ! elements is presumably set earlier with
- ! h5pt_setnpoints(f,npoints)
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_writedata_r4 ( filehandle, name, data )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: name ! The name of the data we are writing
- REAL, INTENT(IN) :: data(*) ! The dataarray to write. The number of
- ! elements is presumably set earlier with
- ! h5pt_setnpoints(f,npoints)
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_writedata_i8 ( filehandle, name, data )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: name ! The name of the data we are writing
- INTEGER*8, INTENT(IN) :: data(*)
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_writedata_i4 ( filehandle, name, data )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: name ! The name of the data we are writing
- INTEGER, INTENT(IN) :: data(*)
- END FUNCTION
-
-!==============Reading Data Characteristics============
-
- INTEGER*8 FUNCTION h5pt_getnsteps (filehandle)
- INTEGER*8, INTENT(IN) :: filehandle
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_getndatasets (filehandle)
- INTEGER*8, INTENT(IN) :: filehandle
- END FUNCTION
-
-! returns total number of points in this timestep
-! If a "view" has been set using h5pt_setview()
-! then it returns the number of points that are
-! in the current view.
- INTEGER*8 FUNCTION h5pt_getnpoints (filehandle)
- INTEGER*8, INTENT(IN) :: filehandle
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_getdatasetname (filehandle,index,name)
- INTEGER*8, INTENT(IN) :: filehandle
- INTEGER*8, INTENT(IN) :: index ! Index for a given dataset name
- CHARACTER(LEN=*), INTENT(OUT) :: name ! returns the name of the dataset at that index
- END FUNCTION
-
-!=============Setting and getting views================
- INTEGER*8 FUNCTION h5pt_setview (filehandle,start,end)
- INTEGER*8, INTENT(IN) :: filehandle
- INTEGER*8, INTENT(IN) :: start ! offset of the first particle in the view
- INTEGER*8, INTENT(IN) :: end ! offset of the first particle after the end of the view
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_resetview (filehandle)
- INTEGER*8, INTENT(IN) :: filehandle ! reset the view on this filehandle to default
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_hasview (filehandle)
- INTEGER*8, INTENT(IN) :: filehandle
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_getview (filehandle,start,end)
- INTEGER*8, INTENT(IN) :: filehandle
- INTEGER*8, INTENT(OUT) :: start ! offset of first particle in the view
- INTEGER*8, INTENT(OUT) :: end ! offset of first particle beyond the current view
- END FUNCTION
-
-!==============Reading Data=========================
-
- INTEGER*8 FUNCTION h5pt_readdata_r8 (filehandle,name,data)
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: name ! The name of the data we are writing
- REAL*8, INTENT(OUT) :: data(*) ! The dataarray to read. Number of points
- ! read is either the number within the view set
- ! by h5pt_setview() or the default (the total
- ! number of particles in the file.
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_readdata_r4 (filehandle,name,data)
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: name ! The name of the data we are writing
- REAL, INTENT(OUT) :: data(*) ! The dataarray to read. Number of points
- ! read is either the number within the view set
- ! by h5pt_setview() or the default (the total
- ! number of particles in the file.
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_readdata_i8 (filehandle,name,data)
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: name ! The name of the data we are writing
- INTEGER*8, INTENT(OUT) :: data(*) ! The dataarray to read. Number of points
- ! read is either the number within the view set
- ! by h5pt_setview() or the default (the total
- ! number of particles in the file.
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_readdata_i4 (filehandle,name,data)
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: name ! The name of the data we are writing
- INTEGER, INTENT(OUT) :: data(*) ! The dataarray to read. Number of points
- ! read is either the number within the view set
- ! by h5pt_setview() or the default (the total
- ! number of particles in the file.
- END FUNCTION
-
-
-!=================== Attributes ================
-
- INTEGER*8 FUNCTION h5pt_writefileattrib_r8 (filehandle,attrib_name,attrib_value,attrib_nelem)
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! The name of the attribute
- REAL*8, INTENT(IN) :: attrib_value(*) ! The array of data to write into the attribute
- INTEGER*8, INTENT(IN) :: attrib_nelem ! Number of elements in the attrib array
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_writefileattrib_i8 (filehandle,attrib_name,attrib_value,attrib_nelem)
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! The name of the attribute
- INTEGER*8, INTENT(IN) :: attrib_value(*) ! The array of data to write into the attribute
- INTEGER*8, INTENT(IN) :: attrib_nelem ! Number of elements in the attrib array
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_writefileattrib_string (filehandle,attrib_name,attrib_value)
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! The name of the attribute
- CHARACTER(LEN=*), INTENT(IN) :: attrib_value ! The array of data to write into the attribute
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_writestepattrib_r8 (filehandle,attrib_name,attrib_value,attrib_nelem)
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! The name of the attribute
- REAL*8, INTENT(IN) :: attrib_value(*) ! The array of data to write into the attribute
- INTEGER*8, INTENT(IN) :: attrib_nelem ! Number of elements in the attrib array
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_writestepattrib_i8 (filehandle,attrib_name,attrib_value,attrib_nelem)
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! The name of the attribute
- INTEGER*8, INTENT(IN) :: attrib_value(*) ! The array of data to write into the attribute
- INTEGER*8, INTENT(IN) :: attrib_nelem ! Number of elements in the attrib array
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_writestepattrib_string (filehandle,attrib_name,attrib_value)
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! The name of the attribute
- CHARACTER(LEN=*), INTENT(IN) :: attrib_value ! The array of data to write into the attribute
- END FUNCTION
-
-
- INTEGER*8 FUNCTION h5pt_getnstepattribs (filehandle)
- INTEGER*8, INTENT(IN) :: filehandle
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_getnfileattribs (filehandle)
- INTEGER*8, INTENT(IN) :: filehandle
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_getstepattribinfo (filehandle,idx,attrib_name,attrib_nelem)
- INTEGER*8, INTENT(IN) :: filehandle
- INTEGER*8, INTENT(IN) :: idx ! index of the attribute being queried
- CHARACTER(LEN=*), INTENT(OUT) :: attrib_name ! The name of the attribute
- INTEGER*8, INTENT(OUT) :: attrib_nelem ! Number of elements in the attrib array
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_getfileattribinfo (filehandle,idx,attrib_name,attrib_nelem)
- INTEGER*8, INTENT(IN) :: filehandle
- INTEGER*8, INTENT(IN) :: idx ! index of the attribute being queried
- CHARACTER(LEN=*), INTENT(OUT) :: attrib_name ! The name of the attribute
- INTEGER*8, INTENT(OUT) :: attrib_nelem ! Number of elements in the attrib array
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_readstepattrib_i8 ( filehandle, attrib_name, attrib_value )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! name of the attribute to read
- INTEGER*8, INTENT(OUT) :: attrib_value(*) ! the attribute data will be read into this array
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_readstepattrib_r8 ( filehandle, attrib_name, attrib_value )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! name of the attribute to read
- REAL*8, INTENT(OUT) :: attrib_value(*) ! the attribute data will be read into this array
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_readfileattrib_i8 (filehandle, attrib_name, attrib_value )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! name of the attribute to read
- INTEGER*8, INTENT(OUT) :: attrib_value(*) ! the attribute data will be read into this array
- END FUNCTION
-
- INTEGER*8 FUNCTION h5pt_readfileattrib_r8 (filehandle, attrib_name, attrib_value )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! name of the attribute to read
- REAL*8, INTENT(OUT) :: attrib_value(*) ! the attribute data will be read into this array
- END FUNCTION
-
-
- INTEGER*8 FUNCTION h5pt_set_verbosity_level ( level )
- INTEGER*8, INTENT(IN) :: level
- END FUNCTION
-
-END INTERFACE
diff --git a/src/H5PartPrivate.h b/src/H5PartPrivate.h
index 15bdf1d..1328154 100644
--- a/src/H5PartPrivate.h
+++ b/src/H5PartPrivate.h
@@ -1,5 +1,5 @@
-#ifndef __H5PARTPRIVATE_H
-#define __H5PARTPRIVATE_H
+#ifndef __H5PART_PRIVATE_H
+#define __H5PART_PRIVATE_H
#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 6
#define H5_USE_16_API
@@ -9,6 +9,11 @@
#define H5PART_BTREE_IK 10000
+h5part_int64_t
+_H5Part_file_is_valid (
+ const H5PartFile *f
+ );
+
/*!
The functions declared here are not part of the API, but may be used
in extensions like H5Block. We name these functions "private".
@@ -33,6 +38,13 @@ _H5Part_set_step (
const h5part_int64_t step
);
+h5part_int64_t
+_H5Part_get_step_name(
+ H5PartFile *f,
+ const h5part_int64_t step,
+ char *name
+ );
+
h5part_int64_t
_H5Part_get_num_particles (
H5PartFile *f
@@ -150,6 +162,11 @@ _H5Part_end_throttle (
H5PartFile *f
);
+h5part_error_handler
+_H5Part_get_err_handle (
+ void
+ );
+
void
_H5Part_vprint_error (
const char *fmt,
diff --git a/src/H5PartTypes.h b/src/H5PartTypes.h
index 6606f7a..60e8288 100644
--- a/src/H5PartTypes.h
+++ b/src/H5PartTypes.h
@@ -2,8 +2,8 @@
System dependend definitions
*/
-#ifndef _H5PARTTYPES_H_
-#define _H5PARTTYPES_H_
+#ifndef _H5PART_TYPES_H_
+#define _H5PART_TYPES_H_
#ifdef WIN32
typedef __int64 int64_t;
@@ -23,6 +23,8 @@ __attribute__ ((format (printf, 3, 4)))
typedef unsigned long MPI_Comm;
#endif
+#define H5PART_STEPNAME_LEN 64
+
struct H5BlockFile;
/**
@@ -35,22 +37,26 @@ struct H5BlockFile;
*/
struct H5PartFile {
hid_t file;
- char *groupname_step;
+ char groupname_step[H5PART_STEPNAME_LEN];
int stepno_width;
int empty;
+ char flags;
+
h5part_int64_t timestep;
hsize_t nparticles;
-
+
hid_t timegroup;
hid_t shape;
- unsigned mode;
hid_t xfer_prop;
hid_t create_prop;
hid_t access_prop;
+
+ /* the dataspace on disk for the current view */
hid_t diskshape;
- hid_t memshape; /* for parallel I/O (this is on-disk) H5S_ALL
- if serial I/O */
+ /* the dataspace in memory for the current view */
+ hid_t memshape;
+
h5part_int64_t viewstart; /* -1 if no view is available: A "view" looks */
h5part_int64_t viewend; /* at a subset of the data. */
@@ -75,11 +81,10 @@ struct H5PartFile {
int myproc;
/**
- MPI comnunicator
+ MPI communicator
*/
MPI_Comm comm;
- char flags;
int throttle;
struct H5BlockStruct *block;
diff --git a/src/Makefile.am b/src/Makefile.am
index eeba89e..213f5c7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,37 +1,22 @@
# src level Makefile.am
-# PATH SETTING (IMPORTED FROM CONFIGURE)
-HDF5ROOT = @HDF5ROOT@
+OBJEXT=o
-# COMPILERS
-CC = @CC@
-
-#INCLUDES
-HDFINC = -I$(HDF5ROOT)/include
-MPIINC = @MPIINC@
-
-INC = $(HDFINC) ${MPIINC}
-
-# H5Part header file location
-H5PINC = -I@prefix@/include
-
-# COMPILER FLAGS
-CFLAGS = @CFLAGS@ ${INC}
-
-# H5Part compiled library location
-H5PLIB = -L@prefix@/lib
-
-# HDF5 LIBRARY
-HDFLIB = -L$(HDF5ROOT)/lib -lhdf5 -lz $(SZLIB) @LDFLAGS@
-
-# SZ LIBRARY
-SZLIB = @SZLIB@
+INCLUDES = -I@HDF5ROOT@/include @MPIINC@
# Extra files that I wish to include in the dist tar ball.
-EXTRA_DIST = TestUnderscoreC.c TestUnderscore.f $(EXTRA_HEADERS)
+EXTRA_DIST = TestUnderscoreC.c \
+ TestUnderscore.f \
+ generate-attr.py \
+ generate-h5bl-readwrite.py \
+ generate-h5multi-readwrite.py \
+ H5Part.f90 \
+ H5PartAttrib.f90 \
+ H5Block.f90 \
+ H5BlockReadWrite.f90
# Files that I don't want to include in the dist tar ball
-nodist_include_HEADERS = @UNDERSCORE_H@
+nodist_include_HEADERS = H5PartF.h @UNDERSCORE_H@
# What to build... Will be determined by configure script.
lib_LIBRARIES = @MTARGET@
@@ -40,64 +25,51 @@ lib_LIBRARIES = @MTARGET@
EXTRA_LIBRARIES = libH5Part.a libH5PartF.a
# Header files that I wish to install in $(prefix)/include
-include_HEADERS = H5Part.h H5PartTypes.h H5PartErrors.h \
- H5Block.h H5BlockReadWrite.h H5BlockTypes.h H5BlockErrors.h \
- H5MultiBlock.h H5MultiBlockReadWrite.h H5MultiBlockTypes.h H5MultiBlockErrors.h \
- H5Part.inc H5PartF90.inc \
- H5BlockF90.inc H5BlockReadWriteF90.inc \
- @UNDERSCORE_H@
+include_HEADERS = H5Part.h \
+ H5PartTypes.h \
+ H5PartErrors.h \
+ H5PartAttrib.h \
+ H5Block.h \
+ H5BlockTypes.h \
+ H5BlockErrors.h \
+ H5BlockReadWrite.h \
+ H5MultiBlock.h \
+ H5MultiBlockTypes.h \
+ H5MultiBlockErrors.h \
+ H5MultiBlockReadWrite.h \
+ H5PartF.h \
+ @UNDERSCORE_H@
# Listing of all possible headers that I may include
-EXTRA_HEADERS = H5PartPrivate.h H5BlockPrivate.h H5MultiBlockPrivate.h
+EXTRA_HEADERS = H5PartPrivate.h \
+ H5BlockPrivate.h \
+ H5MultiBlockPrivate.h \
+ H5PartAttrib.h
# Listing of sources
-libH5Part_a_SOURCES = H5Part.c H5Block.c H5BlockReadWrite.c H5MultiBlock.c H5MultiBlockReadWrite.c
-libH5PartF_a_SOURCES = H5PartF.c H5BlockF.c H5BlockReadWriteF.c
+libH5Part_a_SOURCES = H5Part.c \
+ H5PartAttrib.c \
+ H5Block.c \
+ H5BlockReadWrite.c \
+ H5MultiBlock.c \
+ H5MultiBlockReadWrite.c
+libH5PartF_a_SOURCES = H5PartF.c \
+ H5PartAttribF.c \
+ H5BlockF.c \
+ H5BlockReadWriteF.c
-H5Part.inc: H5PartF90.inc
- grep "INTEGER.* FUNCTION" $< | while read type func name rest; do echo " $$type $$name"; done > $@
+H5PartF.h: H5Part.f90 H5PartAttrib.f90 H5Block.f90 H5BlockReadWrite.f90
+ awk '/INTEGER\*8 FUNCTION/{print "\t" $$1 " " $$3}' $^ >$@
-# Specific building instruction (What compilers to use...)
-# ------------ Serial Lib build commands ------------
-libH5Part.a: H5Part.o H5Block.o H5BlockReadWrite.o H5MultiBlock.o H5MultiBlockReadWrite.o
- ${AR} rucs $@ $^
-
-libH5PartF.a: H5Part.o H5PartF.o H5Block.o H5BlockF.o H5BlockReadWrite.o H5BlockReadWriteF.o
- ${AR} rucs $@ $^
-
-%.o : %.c
- $(CC) $(CFLAGS) $(INC) -c $<
-
-H5Part.o: H5Part.c H5Part.h H5PartPrivate.h H5PartTypes.h
-H5PartF.o: H5PartF.c Underscore.h H5Part.h
-H5Block.o: H5Block.c H5Part.h H5PartPrivate.h H5PartTypes.h H5Block.h H5BlockTypes.h
-H5BlockF.o: H5BlockF.c Underscore.h H5Block.h
-H5BlockReadWrite.o: H5BlockReadWrite.c H5Part.h H5PartPrivate.h H5PartTypes.h H5Block.h H5BlockPrivate.h H5BlockReadWrite.h H5BlockTypes.h
-H5BlockReadWriteF.o: H5BlockF.c Underscore.h H5Block.h H5BlockReadWrite.h
-H5MultiBlock.o: H5MultiBlock.c
-H5MultiBlockF.o: H5MultiBlockF.c
-H5MultiBlockReadWrite.o: H5MultiBlockReadWrite.c
-H5MultiBlockReadWriteF.o: H5MultiBlockReadWriteF.c
-
-# ----------- Build Parallel H5Part Stuff ------------
+.c.o:
+ $(CC) $(CFLAGS) $(INCLUDES) -c $<
libpH5Part.a: libH5Part.a
- ${RM} $@
+ $(RM) $@
ln -s $^ $@
libpH5PartF.a: libH5PartF.a
- ${RM} $@
+ $(RM) $@
ln -s $^ $@
-clean:
- rm -f *~ *.o *.a *.so
-
-distclean: clean
- rm -f *.a
- rm -rf .deps
- rm -rf .libs
- rm -f Underscore.h
- rm -f H5Part_py_wrap.c
- rm -f H5Part.py
- rm -f Makefile
diff --git a/src/generate-attr.py b/src/generate-attr.py
new file mode 100755
index 0000000..1a2946e
--- /dev/null
+++ b/src/generate-attr.py
@@ -0,0 +1,218 @@
+#!/usr/bin/python
+
+c_head = """
+#include
+#include
+
+#include
+#include "H5Part.h"
+#include "H5PartErrors.h"
+#include "H5PartPrivate.h"
+
+"""
+
+h_head = """
+#ifndef _H5PART_ATTRIB_H_
+#define _H5PART_ATTRIB_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+"""
+
+h_tail = """
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+"""
+
+fc_head = """
+#include "H5Part.h"
+#include "H5PartPrivate.h"
+#include "Underscore.h"
+
+#if defined(F77_SINGLE_UNDERSCORE)
+#define F77NAME(a,b) a
+#elif defined(F77_CRAY_UNDERSCORE)
+#define F77NAME(a,b) b
+#elif defined(F77_NO_UNDERSCORE)
+#else
+#error Error, no way to determine how to construct fortran bindings
+#endif
+"""
+
+write_attr_h = """
+h5part_int64_t
+H5PartWrite#LEVEL#Attrib#TYPE_ABV# (
+ H5PartFile *f,
+ const char *name,
+ const h5part_#TYPE_H5P#_t data
+ );
+"""
+
+write_attr_c = """
+/*!
+ \\ingroup h5part_attrib
+
+ Writes a \\c value of type #TYPE_FULL#
+ to the root ("/") of the file
+ as attribute \\c name.
+
+ \\return \\c H5PART_SUCCESS or error code
+*/
+h5part_int64_t
+H5PartWrite#LEVEL#Attrib#TYPE_ABV# (
+ H5PartFile *f, /*!< IN: file handle */
+ const char *name, /*!< IN: attribute name */
+ const h5part_#TYPE_H5P#_t value /*!< IN: attribute value */
+ ) {
+
+ SET_FNAME ( "H5PartWrite#LEVEL#Attrib#TYPE_ABV#" );
+
+ CHECK_FILEHANDLE ( f );
+ CHECK_WRITABLE_MODE( f );
+
+ h5part_int64_t herr = _H5Part_write_#LEVELLC#_attrib (
+ f,
+ name,
+ #TYPE_HDF5#,
+ (void*)&value,
+ 1 );
+ if ( herr < 0 ) return herr;
+
+ return H5PART_SUCCESS;
+}
+"""
+
+write_attr_fi = """
+!< \\ingroup h5partf_attrib
+!! See \\ref H5PartWrite#LEVELLC#Attrib#TYPE_ABV#
+!! \\return 0 on success or error code
+!>
+INTEGER*8 FUNCTION h5pt_write#LEVELLC#attrib_#TYPE_F90_ABV# ( filehandle, field_name, attrib_name, attrib_value, attrib_nelem)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the attribute
+ #TYPE_F90#, INTENT(IN) :: data(*) !< the array of data to write into the attribute
+ INTEGER*8, INTENT(IN) :: nelem !< the number of elements in the array
+END FUNCTION
+"""
+
+write_attr_fc = """
+#if ! defined(F77_NO_UNDERSCORE)
+#define h5pt_write#LEVELLC#attrib_#TYPE_F90_ABV# F77NAME ( \\
+ h5pt_write#LEVELLC#attrib_#TYPE_F90_ABV#_, \\
+ H5PT_WRITE#LEVELUC#ATTRIB_#TYPE_F90_ABVC# )
+#endif
+
+h5part_int64_t
+h5pt_write#LEVELLC#attrib_#TYPE_F90_ABV# (
+ h5part_int64_t *f,
+ const char *name,
+ const h5part_#TYPE_H5P#_t *data,
+ const h5part_#TYPE_H5P#_t *nelem,
+ const int l_name
+ ) {
+
+ H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
+
+ char *name2 =_H5Part_strdupfor2c ( name, l_name );
+
+ h5part_int64_t herr = H5PartWrite#LEVEL#Attrib (
+ filehandle, name2, #TYPE_ATTRIB#, data, *nelem);
+
+ free ( name2 );
+ return herr;
+}
+"""
+
+read_attr_fi = """
+!< \\ingroup h5partf_attrib
+!! Read the attribute \c name into the buffer \c data.
+!! \\return 0 on success or error code
+!>
+INTEGER*8 FUNCTION h5pt_read#LEVELLC#attrib_#TYPE_F90_ABV# ( filehandle, name, data )
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the attribute
+ #TYPE_F90#, INTENT(OUT) :: data(*) !< buffer to read value into
+END FUNCTION
+"""
+
+read_attr_fc = """
+#if ! defined(F77_NO_UNDERSCORE)
+#define h5pt_write#LEVELLC#attrib_#TYPE_F90_ABV# F77NAME ( \\
+ h5pt_write#LEVELLC#attrib_#TYPE_F90_ABV#_, \\
+ H5PT_WRITE#LEVELUC#ATTRIB_#TYPE_F90_ABVC# )
+#endif
+
+h5part_int64_t
+h5pt_read#LEVELLC#attrib_#TYPE_F90_ABV# (
+ h5part_int64_t *f,
+ const char *name,
+ const h5part_#TYPE_H5P#_t *data,
+ const int l_name
+ ) {
+
+ H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
+
+ char *name2 =_H5Part_strdupfor2c ( name, l_name );
+
+ h5part_int64_t herr = H5PartRead#LEVEL#Attrib (
+ filehandle, name2, (void*)data);
+
+ free ( name2 );
+ return herr;
+}
+"""
+
+
+levels = ["File", "Step"]
+types = [
+ ["floating points (64-bit)", "Float64", "float64", "H5T_NATIVE_DOUBLE", "REAL*8", "r8", "R8", "H5PART_FLOAT64"],
+ ["floating points (32-bit)", "Float32", "float32", "H5T_NATIVE_FLOAT", "REAL*4", "r4", "R4", "H5PART_FLOAT32"],
+ ["integers (64-bit)", "Int64", "int64", "H5T_NATIVE_INT64", "INTEGER*8", "i8", "I8", "H5PART_INT64"],
+ ["integers (32-bit)", "Int32", "int32", "H5T_NATIVE_INT32", "INTEGER*4", "i4", "I4", "H5PART_INT32"]
+]
+
+def create_call(template, type, level):
+ fcn = template
+ fcn = fcn.replace('#LEVEL#',level)\
+ .replace('#LEVELLC#',level.lower())\
+ .replace('#LEVELUC#',level.upper())\
+ .replace('#TYPE_FULL#',type[0])\
+ .replace('#TYPE_ABV#',type[1])\
+ .replace('#TYPE_H5P#',type[2])\
+ .replace('#TYPE_HDF5#',type[3])\
+ .replace('#TYPE_F90#',type[4])\
+ .replace('#TYPE_F90_ABV#',type[5])\
+ .replace('#TYPE_F90_ABVC#',type[6])\
+ .replace('#TYPE_ATTRIB#',type[7])
+ return fcn
+
+def write_calls():
+ cfile = file('H5PartAttrib.c','w')
+ cfile.write(c_head)
+ hfile = file('H5PartAttrib.h','w')
+ hfile.write(h_head)
+ fcfile = file('H5PartAttribF.c','w')
+ fcfile.write(fc_head)
+ fifile = file('H5PartAttrib.f90','w')
+ for level in levels:
+ for type in types:
+ cfile.write(create_call(write_attr_c,type,level));
+ hfile.write(create_call(write_attr_h,type,level));
+ fifile.write(create_call(write_attr_fi,type,level));
+ fcfile.write(create_call(write_attr_fc,type,level));
+ fifile.write(create_call(read_attr_fi,type,level));
+ fcfile.write(create_call(read_attr_fc,type,level));
+ cfile.close()
+ hfile.write(h_tail)
+ hfile.close()
+ fcfile.close()
+ fifile.close()
+
+write_calls()
+
diff --git a/src/generate-h5bl-readwrite.py b/src/generate-h5bl-readwrite.py
index 7cdf06f..ab4f797 100755
--- a/src/generate-h5bl-readwrite.py
+++ b/src/generate-h5bl-readwrite.py
@@ -16,8 +16,8 @@ c_head = """
"""
h_head = """
-#ifndef __H5BLOCKREADWRITE_H
-#define __H5BLOCKREADWRITE_H
+#ifndef _H5BLOCK_READWRITE_H_
+#define _H5BLOCK_READWRITE_H_
#ifdef __cplusplus
extern "C" {
@@ -51,14 +51,6 @@ fc_head = """
#endif
"""
-fi_head = """
-INTERFACE
-"""
-
-fi_tail = """
-END INTERFACE
-"""
-
write_scalar_h = """
h5part_int64_t
H5Block#DIM#dWriteScalarField#TYPE_ABV# (
@@ -79,7 +71,7 @@ H5Block#DIM#dReadScalarField#TYPE_ABV# (
write_scalar_c = """
/*!
- \\ingroup h5block_write
+ \\ingroup h5block_data
Write a 3-dimensional field \\c name from the buffer starting at \\c data
to the current time-step using the defined field layout. Values are
@@ -117,7 +109,7 @@ H5Block#DIM#dWriteScalarField#TYPE_ABV# (
read_scalar_c = """
/*!
- \\ingroup h5block_read
+ \\ingroup h5block_data
Read a 3-dimensional field \\c name into the buffer starting at \\c data from
the current time-step using the defined field layout. Values are
@@ -153,18 +145,26 @@ H5Block#DIM#dReadScalarField#TYPE_ABV# (
"""
write_scalar_fi = """
+!> \\ingroup h5blockf_data
+!! See \\ref H5Block#DIM#dWriteScalarField#TYPE_ABV#
+!! \\return 0 on success or error code
+!<
INTEGER*8 FUNCTION h5bl_#DIM#d_write_scalar_field_#TYPE_F90_ABV# ( filehandle, name, data )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: name
- #TYPE_F90#, INTENT(IN) :: data(*)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the dataset
+ #TYPE_F90#, INTENT(IN) :: data(*) !< the array of data
END FUNCTION
"""
read_scalar_fi = """
+!> \\ingroup h5blockf_data
+!! See \\ref H5Block#DIM#dReadScalarField#TYPE_ABV#
+!! \\return 0 on success or error code
+!<
INTEGER*8 FUNCTION h5bl_#DIM#d_read_scalar_field_#TYPE_F90_ABV# ( filehandle, name, data )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: name
- #TYPE_F90#, INTENT(OUT) :: data(*)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the dataset
+ #TYPE_F90#, INTENT(OUT) :: data(*) !< buffer to read the data into
END FUNCTION
"""
@@ -246,7 +246,7 @@ H5Block#DIM#dRead3dVectorField#TYPE_ABV# (
write_vector_c = """
/*!
- \\ingroup h5block_write
+ \\ingroup h5block_data
*/
/*!
Write a 3-dimensional field \\c name with 3-dimensional vectors as values
@@ -292,7 +292,7 @@ H5Block#DIM#dWrite3dVectorField#TYPE_ABV# (
read_vector_c = """
/*!
- \\ingroup h5block_read
+ \\ingroup h5block_data
*/
/*!
Read a 3-dimensional field \\c name with 3-dimensional vectors as values
@@ -335,23 +335,31 @@ H5Block#DIM#dRead3dVectorField#TYPE_ABV# (
}
"""
-write_vector_fi = """
+write_vector_fi = """
+!> \\ingroup h5blockf_data
+!! See \\ref H5Block#DIM#dWrite3dVectorField#TYPE_ABV#
+!! \\return 0 on success or error code
+!<
INTEGER*8 FUNCTION h5bl_#DIM#d_write_3dvector_field_#TYPE_F90_ABV# ( filehandle, name, x, y, z )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: name
- #TYPE_F90#, INTENT(IN) :: x(*)
- #TYPE_F90#, INTENT(IN) :: y(*)
- #TYPE_F90#, INTENT(IN) :: z(*)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the dataset
+ #TYPE_F90#, INTENT(IN) :: x(*) !< the array of x data to write
+ #TYPE_F90#, INTENT(IN) :: y(*) !< the array of y data to write
+ #TYPE_F90#, INTENT(IN) :: z(*) !< the array of z data to write
END FUNCTION
"""
read_vector_fi = """
+!> \\ingroup h5blockf_data
+!! See \\ref H5Block#DIM#dRead3dVectorField#TYPE_ABV#
+!! \\return 0 on success or error code
+!<
INTEGER*8 FUNCTION h5bl_#DIM#d_read_3dvector_field_#TYPE_F90_ABV# ( filehandle, name, x, y, z )
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: name
- #TYPE_F90#, INTENT(OUT) :: x(*)
- #TYPE_F90#, INTENT(OUT) :: y(*)
- #TYPE_F90#, INTENT(OUT) :: z(*)
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: name !< the name of the dataset
+ #TYPE_F90#, INTENT(OUT) :: x(*) !< buffer to read the x data into
+ #TYPE_F90#, INTENT(OUT) :: y(*) !< buffer to read the y data into
+ #TYPE_F90#, INTENT(OUT) :: z(*) !< buffer to read the z data into
END FUNCTION
"""
@@ -458,12 +466,16 @@ H5BlockWriteFieldAttrib#TYPE_ABV# (
"""
write_attr_fi = """
+!> \\ingroup h5blockf_attrib
+!! See \\ref H5BlockWriteFieldAttrib#TYPE_ABV#
+!! \\return 0 on success or error code
+!<
INTEGER*8 FUNCTION h5bl_writefieldattrib_#TYPE_F90_ABV# ( filehandle, field_name, attrib_name, attrib_value, attrib_nelem)
- INTEGER*8, INTENT(IN) :: filehandle
- CHARACTER(LEN=*), INTENT(IN) :: field_name ! The name of the field
- CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! The name of the attribute
- #TYPE_F90#, INTENT(IN) :: attrib_value(*) ! The array of data to write into the attribute
- INTEGER*8, INTENT(IN) :: attrib_nelem ! Number of elements in the attrib array
+ INTEGER*8, INTENT(IN) :: filehandle !< the handle returned at file open
+ CHARACTER(LEN=*), INTENT(IN) :: field_name !< the name of the field
+ CHARACTER(LEN=*), INTENT(IN) :: attrib_name !< the name of the attribute
+ #TYPE_F90#, INTENT(IN) :: attrib_value(*) !< the array of data to write into the attribute
+ INTEGER*8, INTENT(IN) :: attrib_nelem !< the number of elements in the array
END FUNCTION
"""
@@ -528,8 +540,7 @@ def write_calls():
hfile.write(h_head)
fcfile = file('H5BlockReadWriteF.c','w')
fcfile.write(fc_head)
- fifile = file('H5BlockReadWriteF90.inc','w')
- fifile.write(fi_head)
+ fifile = file('H5BlockReadWrite.f90','w')
for dim in dims:
for type in types:
cfile.write(create_call(write_scalar_c,type,dim));
@@ -557,7 +568,6 @@ def write_calls():
hfile.write(h_tail)
hfile.close()
fcfile.close()
- fifile.write(fi_tail)
fifile.close()
write_calls()
diff --git a/src/generate-h5multi-readwrite.py b/src/generate-h5multi-readwrite.py
index 530e76a..25dc793 100755
--- a/src/generate-h5multi-readwrite.py
+++ b/src/generate-h5multi-readwrite.py
@@ -14,8 +14,8 @@ c_head = """
"""
h_head = """
-#ifndef __H5MULTIBLOCKREADWRITE_H
-#define __H5MULTIBLOCKREADWRITE_H
+#ifndef _H5MULTIBLOCK_READWRITE_H_
+#define _H5MULTIBLOCK_READWRITE_H_
#ifdef __cplusplus
extern "C" {
@@ -49,14 +49,6 @@ fc_head = """
#endif
"""
-fi_head = """
-INTERFACE
-"""
-
-fi_tail = """
-END INTERFACE
-"""
-
write_h = """
h5part_int64_t
H5MultiBlock#DIM#dWriteField#TYPE_ABV# (
@@ -77,7 +69,7 @@ H5MultiBlock#DIM#dReadField#TYPE_ABV# (
write_c = """
/*!
- \\ingroup h5multiblock_write
+ \\ingroup h5multiblock_data
Write a multiblock field \\c name from the buffer starting at \\c data
to the current time-step using the defined block decomposition and dimensions.
@@ -107,7 +99,7 @@ H5MultiBlock#DIM#dWriteField#TYPE_ABV# (
read_c = """
/*!
- \\ingroup h5multiblock_read
+ \\ingroup h5multiblock_data
Allocate a buffer to hold a block from a multiblock field and place the
pointer in \\c data, then read the block into the buffer. Uses the block
diff --git a/test/Makefile.am b/test/Makefile.am
index 80e02a9..9f7ff88 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,171 +1,30 @@
# test level Makefile.am
-# PATH SETTING
-HDF5ROOT = @HDF5ROOT@
+OBJEXT=o
-# COMPILER SETTING
-CXX = @CXX@
-FC = @FC@
-MPIFC = @MPIFC@
-MPICXX = @MPICXX@
-MPICC = @MPICC@
+HDFLIB = -L@HDF5ROOT@/lib -lhdf5 -lz @SZLIB@
+LIBS = -L@H5P_LIB_LOC@ -lH5PartF -lH5Part $(HDFLIB) -lm
-# COMPILER FLAG SETTING
-CFLAGS = @CFLAGS@
-FFLAGS = @FFLAGS@ @MPIINC@
+INCLUDES = -I@H5P_LIB_LOC@ -I@HDF5ROOT@/include @MPIINC@
-# LIBRARIES
-SZLIB = @SZLIB@
-HDFLIB = -L$(HDF5ROOT)/lib -lhdf5 -lz $(SZLIB) @LDFLAGS@
-MPILIB = @MPILIB@
-H5LIB = -L@H5P_LIB_LOC@ -lH5Part
+noinst_PROGRAMS = @TTARGET@
-LIBS = ${H5LIB} $(HDFLIB) $(MPILIB) -lm @STDCXX@
+TESTS_ENVIRONMENT = env LD_LIBRARY_PATH=@HDF5ROOT@/lib:$(LD_LIBRARY_PATH)
+TESTS = @TTARGET@
-# H5Part compiled library location
-# H5PLIB = -L@prefix@/lib
+EXTRA_PROGRAMS = test testf
-# INCLUDES
-HDFINC = -I$(HDF5ROOT)/include
-MPIINC = @MPIINC@
-H5INC = -I@H5P_LIB_LOC@
+test_SOURCES = test.c \
+ testframe.c \
+ write.c \
+ read.c \
+ testframe.h
-INC = $(HDFINC) $(MPIINC) $(H5INC)
-
-
-# What to build... make install will place these files in the $(prefix)/bin directory.
-bin_PROGRAMS = @TTARGET@
-
-# Some useful scripts that I wish to place in the $(prefix)/bin directory.
-bin_SCRIPTS =
-#bin_SCRIPTS = JAC_H5PartTestP_script.scr JAC_H5testFpar_script.scr JAC_RUN_ALL_script.scr
-
-
-# Listing of all programs that maybe built. (Has to know statically...)
-EXTRA_PROGRAMS =
-
-# Extra files that I wish to include in the dist tar ball.
-EXTRA_DIST = Bench.c \
- H5ParallelTest.cc \
- H5PartTest.cc H5PartTestParallel.cc \
- H5PartAndreasTest.cc \
- H5test.cc H5testF.f \
- H5testFpar.F90 \
- H5BlockParTestScalarField.c H5BlockParTestScalarFieldF.F90 \
- H5BlockTestAttributes.c H5BlockTestAttributesF.F90 \
- H5PartBench.c H5BlockBench.c \
- $(bin_SCRIPTS)
-
-# Specific building instruction (What compilers to use...)
-# ------------ Build Tests ------------
-
-Bench: Bench.c
- $(CC) $(CFLAGS) $(INC) -o $@ $< $(H5PLIB) -lH5Part $(LIBS)
-
-H5PartBench: H5PartBench.c
- $(CC) $(CFLAGS) $(INC) -o $@ $< $(H5PLIB) -lpH5Part $(LIBS)
-
-H5BlockBench: H5BlockBench.c
- $(CC) $(CFLAGS) $(INC) -o $@ $< $(H5PLIB) -lpH5Part $(LIBS)
-
-###############################################################################
-
-H5PartTest: H5PartTest.o
- $(CXX) -o $@ $< $(H5PLIB) -lH5Part $(LIBS)
-
-H5PartTest.o: H5PartTest.cc
- $(CXX) $(CFLAGS) $(INC) -DREGRESSIONTEST -g -c $<
-
-###############################################################################
-
-H5PartTestP: H5PartTestP.o
- $(CXX) $(INC) -o $@ $< $(H5LIB) -lH5Part $(LIBS)
-
-H5PartTestP.o: H5PartTest.cc
- $(CXX) $(CFLAGS) $(INC) -DREGRESSIONTEST -c $< -o $@
-
-###############################################################################
-
-H5PartTestParallel: H5PartTestParallel.o
- $(CXX) -o $@ $< $(H5LIB) -lH5Part $(LIBS)
-
-H5PartTestParallel.o: H5PartTestParallel.cc
- $(CXX) $(CFLAGS) $(INC) -c $<
-
-###############################################################################
-
-H5PartAndreasTest: H5PartAndreasTest.o
- $(CXX) -o $@ $< $(H5LIB) -lpH5Part $(LIBS)
-
-H5PartAndreasTest.o: H5PartAndreasTest.cc
- $(CXX) $(CFLAGS) $(INC) -c $<
-
-###############################################################################
-
-H5testF: H5testF.o
- $(FC) -o $@ $< $(H5LIB) -lH5PartF -lH5Part $(LIBS)
-
-H5testF.o: H5testF.f
- $(FC) $(FFLAGS) -c $(H5INC) $<
-
-###############################################################################
-
-H5testFpar: H5testFpar.o
- $(MPIFC) -o $@ $< $(H5LIB) -lpH5PartF -lpH5Part $(LIBS)
-
-H5testFpar.o: H5testFpar.F90
- $(MPIFC) $(FFLAGS) -c $(H5INC) $<
-
-###############################################################################
-
-H5test: H5test.o
- $(CXX) -o $@ $< $(H5LIB) $(LIBS)
-
-H5test.o: H5test.cc
- $(CXX) $(CFLAGS) $(INC) -DREGRESSIONTEST -g -c $<
-
-###############################################################################
-% : %.o
- $(CC) -o $@ $< $(H5LIB) $(LIBS)
-
-%.o : %.c
- $(CC) $(CFLAGS) $(INC) -g -c $<
-
-%.o : %.F90
- ${FC} $(FFLAGS) -c $(H5INC) $<
-
-H5BlockTestAttributes.o: H5BlockTestAttributes.c
-
-H5BlockTestAttributes: H5BlockTestAttributes.o
-
-H5BlockTestAttributesF.o: H5BlockTestAttributesF.F90
-
-H5BlockTestAttributesF: H5BlockTestAttributesF.o
- $(FC) -o $@ $< $(H5LIB) -lH5PartF -lH5Part $(LIBS)
-
-H5BlockParTestScalarField.o: H5BlockParTestScalarField.c
-
-H5BlockParTestScalarField: H5BlockParTestScalarField.o
-
-H5BlockParTestScalarFieldF.o: H5BlockParTestScalarFieldF.F90
-
-H5BlockParTestScalarFieldF: H5BlockParTestScalarFieldF.o
- $(FC) -o $@ $< $(H5LIB) -lH5PartF -lH5Part $(LIBS)
-
-H5BlockDissolveGhosts.o: H5BlockDissolveGhosts.c
-
-H5BlockDissolveGhosts: H5BlockDissolveGhosts.o
-
-
-###############################################################################
-clean:
- ${RM} -f *~ *.o ${bin_PROGRAMS}
-
-distclean: clean
- ${RM} -rf .deps
- ${RM} -rf .libs
- ${RM} -f parttest.h5
- ${RM} -rf config.status config.log config.h Makefile
+testf_SOURCES = testf.F90
+.c.o:
+ $(CC) $(CFLAGS) $(INCLUDES) -c $<
+clean: clean-am
+ rm -f *.h5
diff --git a/test/params.h b/test/params.h
new file mode 100644
index 0000000..854f2de
--- /dev/null
+++ b/test/params.h
@@ -0,0 +1,22 @@
+#ifndef _H5PART_TEST_PARAMS_H_
+#define _H5PART_TEST_PARAMS_H_
+
+#define FILENAME "test.h5"
+#define LONGSTEPNAME "thisisaverylongstepnamethatshouldexceedthelimitof64charcausingawarningtoprint"
+#define NTIMESTEPS 10
+
+/* do not decrease this value below 99, or it will break assumptions
+ * made in the read tests! */
+#define NPARTICLES 99
+
+/* do not increase this value past 32! */
+#define MAX_MPI_TASKS 32
+
+#define ATTR_NAME_SIZE 16
+#define ATTR_STR_VAL "test"
+#define ATTR_INT32_VAL -2147483648
+#define ATTR_INT64_VAL 2147483648
+#define ATTR_FLOAT_VAL 3.14159265F
+
+#endif
+
diff --git a/test/test.c b/test/test.c
new file mode 100644
index 0000000..4552a5e
--- /dev/null
+++ b/test/test.c
@@ -0,0 +1,70 @@
+#include
+#include
+
+#include "testframe.h"
+#include "params.h"
+
+/* from write.c */
+void test_write1(void);
+void test_write2(void);
+void test_write3(void);
+void test_write4(void);
+
+/* from read.c */
+void test_read1(void);
+void test_read2(void);
+void test_read3(void);
+void test_read4(void);
+
+int main(int argc, char **argv)
+{
+#ifdef PARALLEL_IO
+ MPI_Init(&argc, &argv);
+ int procs;
+ MPI_Comm_size(MPI_COMM_WORLD, &procs);
+ if (procs > MAX_MPI_TASKS) {
+ fprintf(stderr, "ERROR: please use <= %d MPI tasks for the test.",
+ MAX_MPI_TASKS);
+ MPI_Abort(MPI_COMM_WORLD, -1);
+ }
+#endif
+
+ /* Initialize testing framework */
+ TestInit(argv[0], NULL, NULL);
+
+ /* Tests are generally arranged from least to most complexity... */
+ AddTest("write1", test_write1, NULL, "Write 32-bit data", NULL);
+ AddTest("read1", test_read1, NULL, "Read 32-bit data", NULL);
+ AddTest("write2", test_write2, NULL, "Write 32-bit strided data", NULL);
+ AddTest("read2", test_read2, NULL, "Read 32-bit strided data", NULL);
+ AddTest("write3", test_write3, NULL, "Write 64-bit strided data", NULL);
+ AddTest("read3", test_read3, NULL, "Read 64-bit strided data", NULL);
+ AddTest("write4", test_write4, NULL, "Write 64-bit data", NULL);
+ AddTest("read4", test_read4, NULL, "Read 64-bit data", NULL);
+
+ /* Display testing information */
+ TestInfo(argv[0]);
+
+ /* Parse command line arguments */
+ TestParseCmdLine(argc, argv);
+
+ H5PartSetVerbosityLevel(GetTestVerbosity());
+
+ /* Perform requested testing */
+ PerformTests();
+
+ /* Display test summary, if requested */
+ if (GetTestSummary())
+ TestSummary();
+
+ /* Clean up test files, if allowed */
+ //if (GetTestCleanup() && !getenv("HDF5_NOCLEANUP"))
+ // TestCleanup();
+
+ //return GetTestNumErrs();
+
+#ifdef PARALLEL_IO
+ return MPI_Finalize();
+#endif
+}
+
diff --git a/test/testframe.c b/test/testframe.c
new file mode 100644
index 0000000..41f6fcc
--- /dev/null
+++ b/test/testframe.c
@@ -0,0 +1,651 @@
+/* Test framework borrowed from HDF5 1.8.3:
+ * test/testframe.c
+ */
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Programmer: Quincey Koziol
+ * Tuesday, January 6, 2004
+ *
+ * Purpose: Provides support functions for the testing framework.
+ *
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include "testframe.h"
+
+/*
+ * Definitions for the testing structure.
+ */
+#define MAXNUMOFTESTS 64
+#define MAXTESTNAME 16
+#define MAXTESTDESC 64
+
+typedef struct TestStruct {
+ int NumErrors;
+ char Description[MAXTESTDESC];
+ int SkipFlag;
+ char Name[MAXTESTNAME];
+ void (*Call)(void);
+ void (*Cleanup)(void);
+ const void *Parameters;
+} TestStruct;
+
+
+/*
+ * Variables used by testing framework.
+ */
+static int num_errs = 0; /* Total number of errors during testing */
+static int Verbosity = VERBO_DEF; /* Default Verbosity is Low */
+static int Summary = 0; /* Show test summary. Default is no. */
+static int CleanUp = 1; /* Do cleanup or not. Default is yes. */
+static int TestExpress = -1; /* Do TestExpress or not. -1 means not set yet. */
+static TestStruct Test[MAXNUMOFTESTS];
+static int Index = 0;
+static const void *Test_parameters = NULL;
+static const char *TestProgName = NULL;
+static void (*TestPrivateUsage)(void) = NULL;
+static int (*TestPrivateParser)(int ac, char *av[]) = NULL;
+
+
+/*
+ * Setup a test function and add it to the list of tests.
+ * It must have no parameters and returns void.
+ * TheName--short test name.
+ * If the name starts with '-', do not run it by default.
+ * TheCall--the test routine.
+ * Cleanup--the cleanup routine for the test.
+ * TheDescr--Long description of the test.
+ * Parameters--pointer to extra parameters. Use NULL if none used.
+ * Since only the pointer is copied, the contents should not change.
+ */
+void
+AddTest(const char *TheName, void (*TheCall) (void), void (*Cleanup) (void), const char *TheDescr, const void *Parameters)
+{
+ /* Sanity checking */
+ if (Index >= MAXNUMOFTESTS) {
+ printf("Too many tests added, increase MAXNUMOFTEST(%d).\n",
+ MAXNUMOFTESTS);
+ exit(-1);
+ } /* end if */
+ if (strlen(TheDescr) >= MAXTESTDESC) {
+ printf("Test description too long, increase MAXTESTDESC(%d).\n",
+ MAXTESTDESC);
+ exit(-1);
+ } /* end if */
+ if (strlen(TheName) >= MAXTESTNAME) {
+ printf("Test name too long, increase MAXTESTNAME(%d).\n",
+ MAXTESTNAME);
+ exit(-1);
+ } /* end if */
+
+ /* Set up test function */
+ strcpy(Test[Index].Description, TheDescr);
+ if (*TheName != '-'){
+ strcpy(Test[Index].Name, TheName);
+ Test[Index].SkipFlag = 0;
+ }
+ else { /* skip test by default */
+ strcpy(Test[Index].Name, TheName+1);
+ Test[Index].SkipFlag = 1;
+ }
+ Test[Index].Call = TheCall;
+ Test[Index].Cleanup = Cleanup;
+ Test[Index].NumErrors = -1;
+ Test[Index].Parameters = Parameters;
+
+ /* Increment test count */
+ Index++;
+}
+
+
+/*
+ * Initialize testing framework
+ *
+ * ProgName: Name of test program.
+ * private_usage: Optional routine provided by test program to print the
+ * private portion of usage page. Default to NULL which means none is
+ * provided.
+ * private_parser: Optional routine provided by test program to parse the
+ * private options. Default to NULL which means none is provided.
+ *
+ * Modifications:
+ * Albert Cheng 2004/08/17
+ * Added the ProgName, private_usage and private_parser arguments.
+ */
+void TestInit(const char *ProgName, void (*private_usage)(void), int (*private_parser)(int ac, char *av[]))
+{
+#if !(defined MAC || defined SYMANTEC_C)
+ /* Un-buffer the stdout and stderr */
+ setbuf(stderr, NULL);
+ setbuf(stdout, NULL);
+#endif
+
+ /*
+ * Turn off automatic error reporting since we do it ourselves. Besides,
+ * half the functions this test calls are private, so automatic error
+ * reporting wouldn't do much good since it's triggered at the API layer.
+ */
+ //H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
+
+ /*
+ * Record the program name and private routines if provided.
+ */
+ TestProgName = ProgName;
+ if (NULL != private_usage)
+ TestPrivateUsage = private_usage;
+ if (NULL != private_parser)
+ TestPrivateParser = private_parser;
+}
+
+
+/*
+ * Print test usage.
+ * First print the common test options, then the extra options if provided.
+ *
+ * Modification:
+ * 2004/08/18 Albert Cheng. Add TestPrivateUsage feature.
+ */
+void TestUsage(void)
+{
+ int i;
+
+ printf("Usage: %s [-v[erbose] (l[ow]|m[edium]|h[igh]|0-9)] %s\n",
+ TestProgName, (TestPrivateUsage ? "" : ""));
+ printf(" [-[e]x[clude] name+] \n");
+ printf(" [-o[nly] name+] \n");
+ printf(" [-b[egin] name] \n");
+ printf(" [-s[ummary]] \n");
+ printf(" [-c[leanoff]] \n");
+ printf(" [-h[elp]] \n");
+ printf("\n\n");
+ printf("verbose controls the amount of information displayed\n");
+ printf("exclude to exclude tests by name\n");
+ printf("only to name tests which should be run\n");
+ printf("begin start at the name of the test givin\n");
+ printf("summary prints a summary of test results at the end\n");
+ printf("cleanoff does not delete *.hdf files after execution of tests\n");
+ printf("help print out this information\n");
+ if (TestPrivateUsage){
+ printf("\nExtra options\n");
+ TestPrivateUsage();
+ }
+ printf("\n\n");
+ printf("This program currently tests the following: \n\n");
+ printf("%16s %s\n", "Name", "Description");
+ printf("%16s %s\n", "----", "-----------");
+
+ for (i = 0; i < Index; i++)
+ printf("%16s %s\n", Test[i].Name, Test[i].Description);
+
+ printf("\n\n");
+}
+
+
+/*
+ * Print test info.
+ */
+void TestInfo(const char *ProgName)
+{
+ unsigned major, minor, release;
+
+ H5get_libversion(&major, &minor, &release);
+
+ printf("\nFor help use: %s -help\n",ProgName);
+ printf("Linked with hdf5 version %u.%u release %u\n", major, minor, release);
+ printf("Linked with H5Part version %s\n", H5PART_VER_STRING);
+}
+
+
+/*
+ * Parse command line information.
+ * argc, argv: the usual command line argument count and strings
+ *
+ * Modification:
+ * 2004/08/18 Albert Cheng. Add extra_parse feature.
+ */
+void TestParseCmdLine(int argc, char *argv[])
+{
+ int ret_code;
+
+ while (argv++, --argc > 0){
+ if ((strcmp(*argv, "-verbose") == 0) ||
+ (strcmp(*argv, "-v") == 0)) {
+ if (argc > 0){
+ --argc; ++argv;
+ ParseTestVerbosity(*argv);
+ }else{
+ TestUsage();
+ exit(1);
+ }
+ }
+ else if (((strcmp(*argv, "-exclude") == 0) ||
+ (strcmp(*argv, "-x") == 0))) {
+ if (argc > 0){
+ --argc; ++argv;
+ SetTest(*argv, SKIPTEST);
+ }else{
+ TestUsage();
+ exit(1);
+ }
+ }
+ else if (((strcmp(*argv, "-begin") == 0) ||
+ (strcmp(*argv, "-b") == 0))) {
+ if (argc > 0){
+ --argc; ++argv;
+ SetTest(*argv, BEGINTEST);
+ }else{
+ TestUsage();
+ exit(1);
+ }
+ }
+ else if (((strcmp(*argv, "-only") == 0) ||
+ (strcmp(*argv, "-o") == 0))) {
+ if (argc > 0){
+ int Loop;
+ --argc; ++argv;
+ /* Skip all tests, then activate only one. */
+ for (Loop = 0; Loop < Index; Loop++)
+ Test[Loop].SkipFlag = 1;
+ SetTest(*argv, ONLYTEST);
+ }else{
+ TestUsage();
+ exit(1);
+ }
+ }
+ else if ((strcmp(*argv, "-summary") == 0) || (strcmp(*argv, "-s") == 0))
+ Summary = 1;
+ else if ((strcmp(*argv, "-help") == 0) || (strcmp(*argv, "-h") == 0)) {
+ TestUsage();
+ exit(0);
+ }
+ else if ((strcmp(*argv, "-cleanoff") == 0) || (strcmp(*argv, "-c") == 0))
+ SetTestNoCleanup();
+ else {
+ /* non-standard option. Break out. */
+ break;
+ }
+
+ }
+
+ /* Call extra parsing function if provided. */
+ if (NULL != TestPrivateParser){
+ ret_code=TestPrivateParser(argc+1, argv-1);
+ if (ret_code != 0)
+ exit(-1);
+ }
+}
+
+
+/*
+ * Perform Tests.
+ */
+void PerformTests(void)
+{
+ int Loop;
+
+ for (Loop = 0; Loop < Index; Loop++)
+ if (Test[Loop].SkipFlag) {
+ MESSAGE(2, ("Skipping -- %s (%s) \n", Test[Loop].Description, Test[Loop].Name));
+ } else {
+ MESSAGE(2, ("Testing -- %s (%s) \n", Test[Loop].Description, Test[Loop].Name));
+ MESSAGE(5, ("===============================================\n"));
+ Test[Loop].NumErrors = num_errs;
+ Test_parameters = Test[Loop].Parameters;
+ //ALARM_ON;
+ Test[Loop].Call();
+ //ALARM_OFF;
+ Test[Loop].NumErrors = num_errs - Test[Loop].NumErrors;
+ MESSAGE(5, ("===============================================\n"));
+ MESSAGE(5, ("There were %d errors detected.\n\n", (int)Test[Loop].NumErrors));
+ }
+
+ Test_parameters = NULL; /* clear it. */
+ MESSAGE(2, ("\n\n"));
+
+ if (num_errs)
+ printf("!!! %d Error(s) were detected !!!\n\n", (int) num_errs);
+ else
+ printf("All tests were successful. \n\n");
+}
+
+
+/*
+ * Display test summary.
+ */
+void TestSummary(void)
+{
+ int Loop;
+
+ printf("Summary of Test Results:\n");
+ printf("Name of Test Errors Description of Test\n");
+ printf("---------------- ------ --------------------------------------\n");
+
+ for (Loop = 0; Loop < Index; Loop++) {
+ if (Test[Loop].NumErrors == -1)
+ printf("%16s %6s %s\n", Test[Loop].Name, "N/A", Test[Loop].Description);
+ else
+ printf("%16s %6d %s\n", Test[Loop].Name, (int)Test[Loop].NumErrors, Test[Loop].Description);
+ }
+
+ printf("\n\n");
+}
+
+
+/*
+ * Cleanup files from testing
+ */
+void TestCleanup(void)
+{
+ int Loop;
+
+ MESSAGE(2, ("\nCleaning Up temp files...\n\n"));
+
+ /* call individual cleanup routines in each source module */
+ for (Loop = 0; Loop < Index; Loop++)
+ if (!Test[Loop].SkipFlag && Test[Loop].Cleanup!=NULL)
+ Test[Loop].Cleanup();
+}
+
+
+/*
+ * Retrieve the verbosity level for the testing framework
+ */
+int GetTestVerbosity(void)
+{
+ return(Verbosity);
+}
+
+/*
+ * Set the verbosity level for the testing framework.
+ * Return previous verbosity level.
+ */
+int SetTestVerbosity(int newval)
+{
+ int oldval;
+
+ oldval = Verbosity;
+ Verbosity = newval;
+ return(oldval);
+}
+
+/*
+ * Retrieve the TestExpress mode for the testing framework
+ Values:
+ 0: Exhaustive run
+ Tests should take as long as necessary
+ 1: Full run. Default if HDF5TestExpress is not defined
+ Tests should take no more than 30 minutes
+ 2: Quick run
+ Tests should take no more than 10 minutes
+ 3: Smoke test. Default if HDF5TestExpress is set to a value other than 0-3
+ Tests should take less than 1 minute
+
+ Design:
+ If the environment variable $HDF5TestExpress is defined,
+ then test programs should skip some tests so that they
+ complete sooner.
+
+ Terms:
+ A "test" is a single executable, even if it contains multiple
+ sub-tests.
+ The standard system for test times is a Linux machine running in
+ NFS space (to catch tests that involve a great deal of disk I/O).
+
+ Implementation:
+ I think this can be easily implemented in the test library (libh5test.a)
+ so that all tests can just call it to check the status of $HDF5TestExpress.
+ */
+int GetTestExpress(void)
+{
+ char * env_val;
+
+ /* set it here for now. Should be done in something like h5test_init(). */
+ if(TestExpress==-1)
+ {
+ env_val = getenv("HDF5TestExpress");
+
+ if(env_val == NULL)
+ SetTestExpress(1);
+ else if(strcmp(env_val, "0") == 0)
+ SetTestExpress(0);
+ else if(strcmp(env_val, "1") == 0)
+ SetTestExpress(1);
+ else if(strcmp(env_val, "2") == 0)
+ SetTestExpress(2);
+ else
+ SetTestExpress(3);
+ }
+
+ return(TestExpress);
+}
+
+/*
+ * Set the TestExpress mode for the testing framework.
+ * Return previous TestExpress mode.
+ * Values: non-zero means TestExpress mode is on, 0 means off.
+ */
+int SetTestExpress(int newval)
+{
+ int oldval;
+
+ oldval = TestExpress;
+ TestExpress = newval;
+ return(oldval);
+}
+
+/*
+ * Retrieve Summary request value.
+ * 0 means no summary, 1 means yes.
+ */
+int GetTestSummary(void)
+{
+ return(Summary);
+}
+
+/*
+ * Retrieve Cleanup request value.
+ * 0 means no Cleanup, 1 means yes.
+ */
+int GetTestCleanup(void)
+{
+ return(CleanUp);
+}
+
+/*
+ * Set cleanup to no.
+ * Return previous cleanup value.
+ */
+int SetTestNoCleanup(void)
+{
+ int oldval;
+
+ oldval = CleanUp;
+ CleanUp = 0;
+ return(oldval);
+}
+
+/*
+ * Parse an argument string for verbosity level and set it.
+ */
+void ParseTestVerbosity(char *argv)
+{
+ if (*argv == 'l')
+ SetTestVerbosity(VERBO_LO);
+ else if (*argv == 'm')
+ SetTestVerbosity(VERBO_MED);
+ else if (*argv == 'h')
+ SetTestVerbosity(VERBO_HI);
+ else
+ SetTestVerbosity(atoi(argv));
+}
+
+
+/*
+ * Retrieve the number of testing errors for the testing framework
+ */
+int GetTestNumErrs(void)
+{
+ return(num_errs);
+}
+
+
+/*
+ * Increment the number of testing errors
+ */
+void IncTestNumErrs(void)
+{
+ num_errs++;
+}
+
+
+/*
+ * Retrieve the current Test Parameters pointer.
+ */
+const void *GetTestParameters(void)
+{
+ return(Test_parameters);
+}
+
+int
+TestPrintf(const char *format, ...)
+{
+ va_list arglist;
+ int ret_value;
+
+#if PARALLEL_IO
+ int nproc;
+ MPI_Comm_rank(MPI_COMM_WORLD, &nproc);
+ if ( nproc == 0 || VERBOSE_HI ) {
+ char *format2 = malloc(strlen(format)+8);
+ sprintf(format2, "[%d] %s", nproc, format);
+ va_start(arglist, format);
+ ret_value = vprintf(format2, arglist);
+ va_end(arglist);
+ }
+#else
+ va_start(arglist, format);
+ ret_value = vprintf(format, arglist);
+ va_end(arglist);
+#endif
+
+ /* Return the length of the string produced (like printf() does) */
+ return ret_value;
+}
+
+
+/*
+ * This routine is designed to provide equivalent functionality to 'printf'
+ * and also increment the error count for the testing framework.
+ */
+int
+TestErrPrintf(const char *format, ...)
+{
+ va_list arglist;
+ int ret_value;
+
+ /* Increment the error count */
+ num_errs++;
+
+#if PARALLEL_IO
+ int nproc;
+ MPI_Comm_rank(MPI_COMM_WORLD, &nproc);
+ if ( nproc == 0 || VERBOSE_HI ) {
+ char *format2 = malloc(strlen(format)+8);
+ sprintf(format2, "[%d] %s", nproc, format);
+ va_start(arglist, format);
+ ret_value = vfprintf(stderr, format2, arglist);
+ va_end(arglist);
+ }
+#else
+ va_start(arglist, format);
+ ret_value = vfprintf(stderr, format, arglist);
+ va_end(arglist);
+#endif
+
+ /* Return the length of the string produced (like printf() does) */
+ return ret_value;
+}
+
+
+/*
+ * Set (control) which test will be tested.
+ * SKIPTEST: skip this test
+ * ONLYTEST: do only this test
+ * BEGINETEST: skip all tests before this test
+ *
+ */
+void SetTest(const char *testname, int action)
+{
+ int Loop;
+ switch (action){
+ case SKIPTEST:
+ for (Loop = 0; Loop < Index; Loop++)
+ if (strcmp(testname, Test[Loop].Name) == 0){
+ Test[Loop].SkipFlag = 1;
+ break;
+ }
+ break;
+ case BEGINTEST:
+ for (Loop = 0; Loop < Index; Loop++) {
+ if (strcmp(testname, Test[Loop].Name) != 0)
+ Test[Loop].SkipFlag = 1;
+ else{
+ /* Found it. Set it to run. Done. */
+ Test[Loop].SkipFlag = 0;
+ break;
+ }
+ }
+ break;
+ case ONLYTEST:
+ for (Loop = 0; Loop < Index; Loop++) {
+ if (strcmp(testname, Test[Loop].Name) != 0)
+ Test[Loop].SkipFlag = 1;
+ else {
+ /* Found it. Set it to run. Break to skip the rest. */
+ Test[Loop].SkipFlag = 0;
+ break;
+ }
+ }
+ /* skip the rest */
+ while (++Loop < Index)
+ Test[Loop].SkipFlag = 1;
+ break;
+ default:
+ /* error */
+ printf("*** ERROR: Unknown action (%d) for SetTest\n", action);
+ break;
+ }
+}
+
+void
+get_attr_name(char *name, char *tag, int id)
+{
+ sprintf(name, "Attr%d%s", id, tag);
+}
+
+void
+test_is_valid(H5PartFile *file)
+{
+ h5part_int64_t status = H5PartFileIsValid(file);
+ RETURN(status, H5PART_SUCCESS, "H5PartFileIsValid");
+}
+
diff --git a/test/testframe.h b/test/testframe.h
new file mode 100644
index 0000000..858c4c4
--- /dev/null
+++ b/test/testframe.h
@@ -0,0 +1,188 @@
+/* Test framework borrowed from HDF5 1.8.3:
+ * test/h5test.h
+ * test/testhdf5.h
+ */
+
+#ifndef _H5PART_TESTFRAME_H_
+#define _H5PART_TESTFRAME_H_
+
+#ifdef PARALLEL_IO
+#define OPEN(file,mode) \
+ H5PartOpenFileParallel(file,mode,MPI_COMM_WORLD)
+#define OPENALIGN(file,mode,align) \
+ H5PartOpenFileParallelAlign(file,mode,MPI_COMM_WORLD,align)
+#else
+#define OPEN(file,mode) H5PartOpenFile(file,mode)
+#define OPENALIGN(file,mode,align) H5PartOpenFileAlign(file,mode,align)
+#endif
+
+/*
+ * Predefined test verbosity levels.
+ *
+ * Convention:
+ *
+ * The higher the verbosity value, the more information printed.
+ * So, output for higher verbosity also include output of all lower
+ * verbosity.
+ *
+ * Value Description
+ * 0 None: No informational message.
+ * 1 "All tests passed"
+ * 2 Header of overall test
+ * 3 Default: header and results of individual test
+ * 4
+ * 5 Low: Major category of tests.
+ * 6
+ * 7 Medium: Minor category of tests such as functions called.
+ * 8
+ * 9 High: Highest level. All information.
+ */
+#define VERBO_DEF 0 /* Default */
+#define VERBO_LO 2 /* Low */
+#define VERBO_MED 3 /* Medium */
+#define VERBO_HI 4 /* High */
+
+/*
+ * Verbose queries
+ * Only None needs an exact match. The rest are at least as much.
+ */
+#define VERBOSE_DEF (GetTestVerbosity()>=VERBO_DEF)
+#define VERBOSE_LO (GetTestVerbosity()>=VERBO_LO)
+#define VERBOSE_MED (GetTestVerbosity()>=VERBO_MED)
+#define VERBOSE_HI (GetTestVerbosity()>=VERBO_HI)
+
+#define SKIPTEST 1
+#define ONLYTEST 2
+#define BEGINTEST 3
+
+/*
+ * Print the current location on the standard output stream.
+ */
+#define AT() TestPrintf (" at %s:%d in %s()...\n", \
+ __FILE__, __LINE__, __FUNCTION__);
+
+/*
+ * The name of the test is printed by saying TESTING("something") which will
+ * result in the string `Testing something' being flushed to standard output.
+ * If a test passes, fails, or is skipped then the PASSED(), H5_FAILED(), or
+ * SKIPPED() macro should be called. After H5_FAILED() or SKIPPED() the caller
+ * should print additional information to stdout indented by at least four
+ * spaces. If the h5_errors() is used for automatic error handling then
+ * the H5_FAILED() macro is invoked automatically when an API function fails.
+ */
+#define TESTING(WHAT) {TestPrintf("Testing %-62s",WHAT); fflush(stdout);}
+#define TESTING_2(WHAT) {TestPrintf(" Testing %-62s",WHAT); fflush(stdout);}
+#define PASSED() {TestPrintf(" PASSED");fflush(stdout);}
+#define H5_FAILED() {TestPrintf("*FAILED*");fflush(stdout);}
+#define H5_WARNING() {TestPrintf("*WARNING*");fflush(stdout);}
+#define SKIPPED() {TestPrintf(" -SKIP-");fflush(stdout);}
+#define TEST_ERROR {H5_FAILED(); AT(); goto error;}
+//#define STACK_ERROR {H5Eprint2(H5E_DEFAULT, stdout); goto error;}
+//#define FAIL_STACK_ERROR {H5_FAILED(); AT(); H5Eprint2(H5E_DEFAULT, stdout); \
+// goto error;}
+#define FAIL_PUTS_ERROR(s) {H5_FAILED(); AT(); TestPrintf(s); goto error;}
+
+/* Use %ld to print the value because long should cover most cases. */
+/* Used to make certain a return value _is_not_ a value */
+#define RETURN(ret, val, where) do { \
+ if (VERBOSE_HI) TestPrintf( " Call to routine %15s at line %4d " \
+ "in %s returned %ld \n", \
+ where, (int)__LINE__, __FILE__, \
+ (long)(ret)); \
+ if ((ret) != (val)) { \
+ TestErrPrintf("*** UNEXPECTED RETURN from %s is %ld at line %4d " \
+ "in %s\n", where, (long)(ret), (int)__LINE__, __FILE__); \
+ } \
+} while(0)
+
+#define VALUE(val, expected, what) do { \
+ if ((val) != (expected)) { \
+ TestErrPrintf( "*** INCORRECT VALUE of %s at line " \
+ "%d in %s\n", what, (int)__LINE__, \
+ __FILE__); \
+ } \
+} while(0)
+
+#define IVALUE(val, expected, what) do { \
+ if (VERBOSE_HI) TestPrintf( " Value of int %15s at line %4d " \
+ "in %s is %ld =? %ld\n", what, \
+ (int)__LINE__, __FILE__, \
+ (long)(val), (long)(expected)); \
+ VALUE(val, expected, what); \
+} while(0)
+
+#define FVALUE(val, expected, what) do { \
+ if (VERBOSE_HI) TestPrintf( " Value of float %15s at line %4d " \
+ "in %s is %g =? %g\n", what, \
+ (int)__LINE__, __FILE__, \
+ (val), (expected)); \
+ VALUE(val, expected, what); \
+} while(0)
+
+#define CVALUE(val, expected, what) do { \
+ if (VERBOSE_HI) TestPrintf( " Value of char %15s at line %4d " \
+ "in %s is %c =? %c\n", what, \
+ (int)__LINE__, __FILE__, \
+ (val), (expected)); \
+ VALUE(val, expected, what); \
+} while(0)
+
+
+#define SVALUE(val, expected, what) do { \
+ if (VERBOSE_HI) TestPrintf( " Value of string %15s at line %4d " \
+ "in %s is %s =? %s\n", what, \
+ (int)__LINE__, __FILE__, \
+ (val), (expected)); \
+ if (strcmp(val,expected) != 0) { \
+ TestErrPrintf( "*** INCORRECT VALUE of %d at line " \
+ "%4d in %s\n", what, (int)__LINE__, \
+ __FILE__); \
+ } \
+} while(0)
+
+/* Used to document process through a test */
+#define MESSAGE(V,A) do { \
+ if (V) TestPrintf A; \
+} while(0)
+
+#define TEST(WHAT) MESSAGE(VERBOSE_DEF,(WHAT "\n"))
+
+/* definitions for command strings */
+#define VERBOSITY_STR "Verbosity"
+#define SKIP_STR "Skip"
+#define TEST_STR "Test"
+#define CLEAN_STR "Cleanup"
+
+void TestUsage(void);
+void AddTest(const char *TheName, void (*TheCall) (void),
+ void (*Cleanup) (void), const char *TheDescr,
+ const void *Parameters);
+void TestInfo(const char *ProgName);
+void TestParseCmdLine(int argc, char *argv[]);
+void PerformTests(void);
+void TestSummary(void);
+void TestCleanup(void);
+void TestInit(const char *ProgName, void (*private_usage)(void), int (*private_parser)(int ac, char *av[]));
+int GetTestVerbosity(void);
+int SetTestVerbosity(int newval);
+int GetTestSummary(void);
+int GetTestCleanup(void);
+int SetTestNoCleanup(void);
+int GetTestExpress(void);
+int SetTestExpress(int newval);
+void ParseTestVerbosity(char *argv);
+int GetTestNumErrs(void);
+void IncTestNumErrs(void);
+const void *GetTestParameters(void);
+int TestPrintf(const char *format, ...);
+int TestErrPrintf(const char *format, ...);
+void SetTest(const char *testname, int action);
+
+void
+get_attr_name(char *name, char *tag, int id);
+
+void
+test_is_valid(H5PartFile *file);
+
+#endif
+
diff --git a/test/write.c b/test/write.c
new file mode 100644
index 0000000..41334bb
--- /dev/null
+++ b/test/write.c
@@ -0,0 +1,418 @@
+#include
+
+#include "testframe.h"
+#include "params.h"
+
+static void
+test_write_file_attribs(H5PartFile *file, int position)
+{
+ h5part_int64_t status;
+ char name[ATTR_NAME_SIZE];
+
+ TEST("Writing file attributes");
+
+ get_attr_name(name, "str", position);
+ status = H5PartWriteFileAttribString(file, name, ATTR_STR_VAL);
+ RETURN(status, H5PART_SUCCESS, "H5PartWriteFileAttribString");
+
+ get_attr_name(name, "i32", position);
+ status = H5PartWriteFileAttribInt32(file, name, ATTR_INT32_VAL);
+ RETURN(status, H5PART_SUCCESS, "H5PartWriteFileAttribInt32");
+
+ get_attr_name(name, "i64", position);
+ status = H5PartWriteFileAttribInt64(file, name, ATTR_INT64_VAL);
+ RETURN(status, H5PART_SUCCESS, "H5PartWriteFileAttribInt64");
+
+ get_attr_name(name, "f32", position);
+ status = H5PartWriteFileAttribFloat32(file, name, ATTR_FLOAT_VAL);
+ RETURN(status, H5PART_SUCCESS, "H5PartWriteFileAttribFloat32");
+
+ get_attr_name(name, "f64", position);
+ status = H5PartWriteFileAttribFloat64(file, name, ATTR_FLOAT_VAL);
+ RETURN(status, H5PART_SUCCESS, "H5PartWriteFileAttribFloat64");
+}
+
+static void
+test_write_step_attribs(H5PartFile *file, int position)
+{
+ h5part_int64_t status;
+ char name[ATTR_NAME_SIZE];
+
+ TEST("Writing step attributes");
+
+ get_attr_name(name, "str", position);
+ status = H5PartWriteStepAttribString(file, name, ATTR_STR_VAL);
+ RETURN(status, H5PART_SUCCESS, "H5PartWriteStepAttribString");
+
+ get_attr_name(name, "i32", position);
+ status = H5PartWriteStepAttribInt32(file, name, ATTR_INT32_VAL);
+ RETURN(status, H5PART_SUCCESS, "H5PartWriteStepAttribInt32");
+
+ get_attr_name(name, "i64", position);
+ status = H5PartWriteStepAttribInt64(file, name, ATTR_INT64_VAL);
+ RETURN(status, H5PART_SUCCESS, "H5PartWriteStepAttribInt64");
+
+ get_attr_name(name, "f32", position);
+ status = H5PartWriteStepAttribFloat32(file, name, ATTR_FLOAT_VAL);
+ RETURN(status, H5PART_SUCCESS, "H5PartWriteStepAttribFloat32");
+
+ get_attr_name(name, "f64", position);
+ status = H5PartWriteStepAttribFloat64(file, name, ATTR_FLOAT_VAL);
+ RETURN(status, H5PART_SUCCESS, "H5PartWriteStepAttribFloat64");
+}
+
+static void
+test_write_data64(H5PartFile *file, int nparticles, int step)
+{
+ int i,t;
+ h5part_int64_t status;
+
+ double *x,*y,*z;
+ double *px,*py,*pz;
+ h5part_int64_t *id;
+
+ x=(double*)malloc(nparticles*sizeof(double));
+ y=(double*)malloc(nparticles*sizeof(double));
+ z=(double*)malloc(nparticles*sizeof(double));
+ px=(double*)malloc(nparticles*sizeof(double));
+ py=(double*)malloc(nparticles*sizeof(double));
+ pz=(double*)malloc(nparticles*sizeof(double));
+ id=(h5part_int64_t*)malloc(nparticles*sizeof(h5part_int64_t));
+
+ /* invalid stride will produce a warning */
+ status = H5PartSetNumParticlesStrided(file, nparticles, -1);
+ RETURN(status, H5PART_SUCCESS, "H5PartSetNumParticlesStrided");
+
+#if PARALLEL_IO
+ TEST("Setting throttle");
+ status = H5PartSetThrottle(file, 2);
+ RETURN(status, H5PART_SUCCESS, "H5PartSetThrottle");
+#endif
+
+ TEST("Writing 64-bit data");
+
+ for (t=step; t
+#include
+#include
+#include
+#include
+#include
+#include
+
+#define VERBOSITY_LOW 1
+#define VERBOSITY_MEDIUM 3
+#define VERBOSITY_HIGH 5
+
+#define ONE_MEGABYTE 1048576.0
+
+#ifdef PARALLEL_IO
+
+/* Parameters ***********************************************************/
+struct Params {
+int rank; // MPI
+int procs; // MPI
+int segments; // number of segments (i.e. time steps)
+int repetitions; // number of times to repeat the test
+int read; // enable read test
+int write; // enable write test
+int nofillvals; // disable fill values in HDF5
+int verbosity; // verbosity level
+char* filename; // path to the test file
+char flags; // file open flags
+double aggregate_size; // aggregate size in MB
+h5part_int64_t alignment; // HDF5 alignment in bytes
+h5part_int64_t block_size; // size of the block data
+h5part_int64_t bdims[3]; // block dimensions
+h5part_int64_t cdims[3]; // chunk dimensions
+h5part_int64_t layout[6]; // H5Block layout
+};
+typedef struct Params Params;
+
+
+/************************************************************************/
+/* Argument helper functions */
+/************************************************************************/
+
+void print_usage ()
+{
+ printf ("Usage:\n");
+ printf (" -a\talignment in bytes [1048576]\n");
+ printf (" -b\tblock dimensions [64 64 64]\n");
+ printf (" -c\tchunk dimentions [0 0 0]\n");
+ printf (" -i\trepetitions [1]\n");
+ printf (" -n\tHDF5 no fill [0]\n");
+ printf (" -o\toutput dir [output]\n");
+ printf (" -r\tperform read test [0]\n");
+ printf (" -s\tsegments [1]\n");
+ printf (" -v\tverbosity level [1]\n");
+ printf (" -w\tpreform write test [0]\n");
+ printf (" -lustre\tenable lustre-specific tuning\n");
+ printf (" -posix\tuse the MPI-POSIX VFD\n");
+}
+
+void parse_args (int argc, char** argv, Params* p)
+{
+ int i;
+
+ if (argc < 2) {
+ if (p->rank == 0) print_usage();
+ MPI_Finalize();
+ exit (EXIT_SUCCESS);
+ }
+
+ // default values
+ p->bdims[0] = 64;
+ p->bdims[1] = 64;
+ p->bdims[2] = 64;
+ p->cdims[0] = 0;
+ p->cdims[1] = 0;
+ p->cdims[2] = 0;
+ p->segments = 1;
+ p->repetitions = 1;
+ p->read = 0;
+ p->write = 0;
+ p->alignment = 1048576;
+ p->nofillvals = 0;
+ p->verbosity = VERBOSITY_MEDIUM;
+ p->filename = "output";
+ p->flags = H5PART_WRITE;
+
+ i = 1;
+ while (i < argc)
+ {
+ // block dimensions
+ if (strcmp(argv[i],"-b") == 0)
+ {
+ i++;
+ p->bdims[0] = atoi (argv[i]);
+ i++;
+ p->bdims[1] = atoi (argv[i]);
+ i++;
+ p->bdims[2] = atoi (argv[i]);
+ }
+ // chunk dimensions
+ else if (strcmp(argv[i],"-c") == 0)
+ {
+ i++;
+ p->cdims[0] = atoi (argv[i]);
+ i++;
+ p->cdims[1] = atoi (argv[i]);
+ i++;
+ p->cdims[2] = atoi (argv[i]);
+ }
+ // segments
+ else if (strcmp(argv[i],"-s") == 0)
+ {
+ i++;
+ p->segments = atoi (argv[i]);
+ }
+ // repetitions
+ else if (strcmp(argv[i],"-i") == 0)
+ {
+ i++;
+ p->repetitions = atoi (argv[i]);
+ }
+ // read
+ else if (strcmp(argv[i],"-r") == 0)
+ {
+ p->read = 1;
+ }
+ // write
+ else if (strcmp(argv[i],"-w") == 0)
+ {
+ p->write = 1;
+ }
+ // alignment
+ else if (strcmp(argv[i],"-a") == 0)
+ {
+ i++;
+ p->alignment = atoi (argv[i]);
+ }
+ // nofillvals
+ else if (strcmp(argv[i],"-n") == 0)
+ {
+ p->nofillvals = 1;
+ }
+ // verbosity level
+ else if (strcmp(argv[i],"-v") == 0)
+ {
+ i++;
+ p->verbosity = atoi (argv[i]);
+ }
+ // filename
+ else if (strcmp(argv[i],"-o") == 0)
+ {
+ i++;
+ p->filename = (char*) malloc (strlen (argv[i]) + 1);
+ strcpy (p->filename, argv[i]);
+ }
+ else if (strcmp(argv[i],"-lustre") == 0)
+ {
+ p->flags |= H5PART_FS_LUSTRE;
+ }
+ else if (strcmp(argv[i],"-posix") == 0)
+ {
+ p->flags |= H5PART_VFD_MPIPOSIX;
+ }
+ // print usage
+ else if (strcmp(argv[i],"--help") == 0)
+ {
+ if (p->rank == 0) print_usage();
+ MPI_Finalize();
+ exit (EXIT_SUCCESS);
+ }
+ else
+ {
+ if (p->rank == 0) {
+ fprintf (stderr, "%s: unrecognized argument %s \n",
+ argv[0], argv[i]);
+ print_usage();
+ }
+ MPI_Finalize();
+ exit (EXIT_FAILURE);
+ }
+ i++;
+ }
+}
+
+
+/************************************************************************/
+/* Layout functions */
+/************************************************************************/
+
+int nth_root_int_divisor (const int m, const int n)
+{
+ int i, root;
+ double p;
+
+ p = 1.0 / (double) n;
+ root = (int) ceil ( pow ((double) m, p) );
+ for (i=root; i<=m; i++)
+ {
+ if (m % i == 0) return i;
+ }
+
+ return i;
+}
+
+void set_layout (Params* p)
+{
+ int i, j, k;
+ int x, y, z;
+
+ x = nth_root_int_divisor (p->procs, 3);
+ y = nth_root_int_divisor (p->procs / x, 2);
+ z = p->procs / x / y;
+
+ if (p->verbosity >= VERBOSITY_HIGH && p->rank == 0) {
+ printf ("creating (%d,%d,%d) layout\n", x, y, z);
+ }
+
+ i = p->rank % x;
+ j = (p->rank / x) % y;
+ k = p->rank / (x * y);
+
+ p->layout[0] = i * p->bdims[0];
+ p->layout[1] = (i + 1) * p->bdims[0] - 1;
+ p->layout[2] = j * p->bdims[1];
+ p->layout[3] = (j + 1) * p->bdims[1] - 1;
+ p->layout[4] = k * p->bdims[2];
+ p->layout[5] = (k + 1) * p->bdims[2] - 1;
+
+ if (p->verbosity >= VERBOSITY_HIGH) {
+ printf ("rank %d: (%d,%d,%d) [%lld,%lld]x[%lld,%lld]x[%lld,%lld]\n",
+ p->rank, i, j, k,
+ (long long)p->layout[0], (long long)p->layout[1],
+ (long long)p->layout[2], (long long)p->layout[3],
+ (long long)p->layout[4], (long long)p->layout[5]);
+ }
+}
+
+void check_cdims (Params* p)
+{
+ int i;
+
+ for (i=0; i<3; i++) {
+ if (p->bdims[i] % p->cdims[i] != 0) {
+ if (p->rank == 0) {
+ fprintf (stderr,
+ "Chunk dim %d does not divide block dim %d!\n",
+ i, i);
+ }
+ MPI_Barrier (MPI_COMM_WORLD);
+ exit (EXIT_FAILURE);
+ }
+ }
+}
+
+
+/************************************************************************/
+/* Data functions */
+/************************************************************************/
+
+void create_data (float* data, Params* p)
+{
+ int i;
+
+ if (p->verbosity >= VERBOSITY_HIGH) {
+ printf ("rank %d: creating random data\n", p->rank);
+ }
+
+ for (i=0; iblock_size; i++) {
+ data[i] = (float) random();
+ }
+}
+
+double write_data (float* data, int iter, Params* p)
+{
+ int i;
+ double start_time;
+ double open_time;
+ double write_time;
+ double close_time;
+ double total_time;
+ double sum_time;
+ double open_mean;
+ double write_mean;
+ double close_mean;
+ double bandwidth;
+ float* segment;
+ char* filename;
+ H5PartFile* file;
+ h5part_int64_t status;
+
+ if (p->verbosity >= VERBOSITY_HIGH) {
+ printf ("rank %d: writing data\n", p->rank);
+ }
+
+ start_time = MPI_Wtime();
+
+ filename = (char*) malloc (strlen (p->filename) + 64);
+ sprintf (filename, "%s/%d.h5", p->filename, iter);
+
+ file = H5PartOpenFileParallelAlign (filename,
+ p->flags, MPI_COMM_WORLD, p->alignment);
+ if (!file) {
+ fprintf (stderr,
+ "rank %d: could not open H5Part file!\n", p->rank);
+ MPI_Barrier (MPI_COMM_WORLD);
+ exit (EXIT_FAILURE);
+ }
+
+ open_time = MPI_Wtime() - start_time;
+
+ if (p->cdims[0] > 0 && p->cdims[1] > 0 && p->cdims[2] > 0) {
+ status = H5BlockDefine3DChunkDims (file,
+ p->cdims[0], p->cdims[1], p->cdims[2]);
+ if (status != H5PART_SUCCESS) {
+ fprintf (stderr,
+ "rank %d: H5Block chunk error!", p->rank);
+ }
+ }
+
+ status = H5BlockDefine3DFieldLayout (file,
+ p->layout[0], p->layout[1],
+ p->layout[2], p->layout[3],
+ p->layout[4], p->layout[5]);
+ if (status != H5PART_SUCCESS) {
+ fprintf (stderr,
+ "rank %d: H5Block layout error!", p->rank);
+ }
+
+ segment = data;
+
+ for (i=0; isegments; i++) {
+ status = H5PartSetStep (file, i);
+ if (status != H5PART_SUCCESS) {
+ fprintf (stderr, "rank %d: H5PartSetStep error!", p->rank);
+ }
+
+ status = H5Block3dWriteScalarFieldFloat32 (file, "test", segment);
+ if (status != H5PART_SUCCESS) {
+ fprintf (stderr, "rank %d: H5Block write error!", p->rank);
+ }
+
+ segment += p->block_size;
+ }
+
+ write_time = (MPI_Wtime() - start_time) - open_time;
+
+ H5PartCloseFile (file);
+
+ close_time = (MPI_Wtime() - start_time) - write_time - open_time;
+
+ total_time = open_time + write_time + close_time;
+
+ if (p->verbosity >= VERBOSITY_HIGH) {
+ printf ("rank %d: write\t%.3f\t%.3f\t%.3f\t%.3f\n", p->rank,
+ open_time, write_time, close_time, total_time);
+ }
+
+ MPI_Barrier (MPI_COMM_WORLD);
+ MPI_Reduce (&open_time, &sum_time, 1, MPI_DOUBLE,
+ MPI_SUM, 0, MPI_COMM_WORLD);
+ open_mean = sum_time / p->procs;
+ MPI_Reduce (&write_time, &sum_time, 1, MPI_DOUBLE,
+ MPI_SUM, 0, MPI_COMM_WORLD);
+ write_mean = sum_time / p->procs;
+ MPI_Reduce (&close_time, &sum_time, 1, MPI_DOUBLE,
+ MPI_SUM, 0, MPI_COMM_WORLD);
+ close_mean = sum_time / p->procs;
+ bandwidth = p->aggregate_size / total_time;
+
+ if (p->verbosity >= VERBOSITY_MEDIUM && p->rank == 0) {
+ printf ("write\t%.1f\t%.3f\t%.3f\t%.3f\t%.3f\n", bandwidth,
+ open_mean, write_mean, close_mean, total_time);
+ }
+
+ return bandwidth;
+}
+
+
+/************************************************************************/
+/* Main procedure */
+/************************************************************************/
+
+int main (int argc, char** argv)
+{
+ int i;
+ Params p;
+ float* data;
+ double chunk_size;
+ double data_size;
+ double bandwidth;
+ double write_max;
+ double write_min;
+ double write_mean;
+ double read_max;
+ double read_min;
+ double read_mean;
+ time_t rawtime;
+ struct tm * timeinfo;
+
+ // initialize MPI
+ MPI_Init (&argc, &argv);
+ MPI_Comm_rank (MPI_COMM_WORLD, &p.rank);
+ MPI_Comm_size (MPI_COMM_WORLD, &p.procs);
+
+ parse_args (argc, argv, &p);
+ //check_cdims (&p);
+
+ H5PartSetVerbosityLevel (p.verbosity);
+
+ if (p.verbosity >= VERBOSITY_MEDIUM && p.rank == 0) {
+ time (&rawtime);
+ timeinfo = localtime (&rawtime);
+ printf ("Started: %s", asctime (timeinfo));
+ printf ("Command line:\n");
+ for (i=0; i= VERBOSITY_MEDIUM && p.rank == 0) {
+ printf ("chunk_size\t\t= %.1f MB\n", chunk_size);
+ printf ("block_size\t\t= %.1f MB\n",
+ p.block_size * sizeof(float) / 1048576.0);
+ printf (" x %5d segment(s)\t= %.1f MB per proc\n",
+ p.segments, data_size);
+ printf (" x %5d procs\t\t= %.1f MB aggregate\n",
+ p.procs, p.aggregate_size);
+ }
+
+ if (p.verbosity >= VERBOSITY_HIGH) {
+ printf ("rank %d: mallocing block data\n", p.rank);
+ }
+
+ data = (float*) malloc (p.segments * p.block_size * sizeof(float));
+ if (!data) {
+ fprintf (stderr,
+ "rank %d: could not malloc block data!\n", p.rank);
+ MPI_Barrier (MPI_COMM_WORLD);
+ exit (EXIT_FAILURE);
+ }
+
+ if (p.verbosity >= VERBOSITY_MEDIUM && p.rank == 0) {
+ printf ("access\tbw\topen\twr/rd\tclose\ttotal\n");
+ printf ("(wr/rd)\t(MB/s)\t(s)\t(s)\t(s)\t(s)\n");
+ printf ("------\t--\t----\t-----\t-----\t-----\n");
+ }
+
+ write_max = 0.0;
+ write_min = 10e300;
+ for (i=0; i write_max) write_max = bandwidth;
+ if (bandwidth < write_min) write_min = bandwidth;
+ write_mean += bandwidth;
+ }
+ }
+ write_mean /= p.repetitions;
+
+ if (p.verbosity >= VERBOSITY_LOW && p.rank == 0) {
+ printf ("********************************\n");
+ printf ("** Aggregate Bandwidth (MB/s) **\n");
+ printf ("access max min mean \n");
+ printf ("------ --- --- ---- \n");
+ if (p.write) {
+ printf ("write\t%.1f\t%.1f\t%.1f\n",
+ write_max, write_min, write_mean);
+ }
+ if (p.read) {
+ printf ("read\t%.1f\t%.1f\t%.1f\n",
+ read_max, read_min, read_mean);
+ }
+ printf ("********************************\n");
+ time (&rawtime);
+ timeinfo = localtime (&rawtime);
+ printf ("Finished: %s", asctime (timeinfo));
+ }
+
+ if (p.verbosity >= VERBOSITY_HIGH) {
+ printf ("rank %d: Exiting!\n", p.rank);
+ }
+
+ MPI_Finalize();
+ return (EXIT_SUCCESS);
+}
+
+#else
+#error This file only works when PARALLEL_IO is enabled.
+#endif
diff --git a/tools/H5PartBench.c b/tools/H5PartBench.c
new file mode 100644
index 0000000..e9338e8
--- /dev/null
+++ b/tools/H5PartBench.c
@@ -0,0 +1,412 @@
+/*
+ * File: H5PartBench.c
+ * Author: Mark Howison
+ * Created: 11-29-2008
+ * Description: Benchmark application for H5Part, with similar
+ * functionality to IOR.
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#define VERBOSITY_LOW 1
+#define VERBOSITY_MEDIUM 3
+#define VERBOSITY_HIGH 5
+
+#define ONE_MEGABYTE 1048576.0
+
+#ifdef PARALLEL_IO
+
+/* Parameters ***********************************************************/
+struct Params {
+int rank; // MPI
+int procs; // MPI
+int segments; // number of segments (i.e. time steps)
+int repetitions; // number of times to repeat the test
+int read; // enable read test
+int write; // enable write test
+int nofillvals; // disable fill values in HDF5
+int verbosity; // verbosity level
+char* filename; // path to the test file
+char flags; // file open flags
+double aggregate_size; // aggregate size in MB
+h5part_int64_t alignment; // HDF5 alignment in bytes
+h5part_int64_t particles; // number of particles to write per block
+h5part_int64_t blocks; // number of blocks to write per segment
+};
+typedef struct Params Params;
+
+
+/************************************************************************/
+/* Argument helper functions */
+/************************************************************************/
+
+void print_usage ()
+{
+ printf ("Usage:\n");
+ printf (" -a\talignment in bytes\n");
+ printf (" -b\tblocks per segment (i.e. chunks per timestep)\n");
+ printf (" -i\trepetitions\n");
+ printf (" -n\tHDF5 no fill\n");
+ printf (" -o\toutput dir\n");
+ printf (" -p\tparticles per block\n");
+ printf (" -r\tperform read test\n");
+ printf (" -s\tsegments (i.e. H5Part timesteps)\n");
+ printf (" -v\tverbosity level\n");
+ printf (" -w\tpreform write test\n");
+ printf (" -lustre\tenable lustre-specific tuning\n");
+ printf (" -posix\tuse the MPI-POSIX VFD\n");
+}
+
+void parse_args (int argc, char** argv, Params* p)
+{
+ int i;
+
+ if (argc < 2) {
+ if (p->rank == 0) print_usage();
+ MPI_Finalize();
+ exit (EXIT_SUCCESS);
+ }
+
+ // default values
+ p->blocks = 1;
+ p->particles = 262144;
+ p->segments = 1;
+ p->repetitions = 1;
+ p->read = 0;
+ p->write = 0;
+ p->alignment = 1048576;
+ p->nofillvals = 0;
+ p->verbosity = VERBOSITY_MEDIUM;
+ p->filename = "output";
+ p->flags = H5PART_WRITE;
+
+ i = 1;
+ while (i < argc)
+ {
+ // blocks
+ if (strcmp(argv[i],"-b") == 0)
+ {
+ i++;
+ p->blocks = atoi (argv[i]);
+ }
+ // particles
+ else if (strcmp(argv[i],"-p") == 0)
+ {
+ i++;
+ p->particles = atoi (argv[i]);
+ }
+ // segments
+ else if (strcmp(argv[i],"-s") == 0)
+ {
+ i++;
+ p->segments = atoi (argv[i]);
+ }
+ // repetitions
+ else if (strcmp(argv[i],"-i") == 0)
+ {
+ i++;
+ p->repetitions = atoi (argv[i]);
+ }
+ // read
+ else if (strcmp(argv[i],"-r") == 0)
+ {
+ p->read = 1;
+ }
+ // write
+ else if (strcmp(argv[i],"-w") == 0)
+ {
+ p->write = 1;
+ }
+ // alignment
+ else if (strcmp(argv[i],"-a") == 0)
+ {
+ i++;
+ p->alignment = atoi (argv[i]);
+ }
+ // nofillvals
+ else if (strcmp(argv[i],"-n") == 0)
+ {
+ p->nofillvals = 1;
+ }
+ // verbosity level
+ else if (strcmp(argv[i],"-v") == 0)
+ {
+ i++;
+ p->verbosity = atoi (argv[i]);
+ }
+ // filename
+ else if (strcmp(argv[i],"-o") == 0)
+ {
+ i++;
+ p->filename = (char*) malloc (strlen (argv[i]) + 1);
+ strcpy (p->filename, argv[i]);
+ }
+ else if (strcmp(argv[i],"-lustre") == 0)
+ {
+ p->flags |= H5PART_FS_LUSTRE;
+ }
+ else if (strcmp(argv[i],"-posix") == 0)
+ {
+ p->flags |= H5PART_VFD_MPIPOSIX;
+ }
+ // print usage
+ else if (strcmp(argv[i],"--help") == 0)
+ {
+ if (p->rank == 0) print_usage();
+ MPI_Finalize();
+ exit (EXIT_SUCCESS);
+ }
+ else
+ {
+ if (p->rank == 0) {
+ fprintf (stderr, "%s: unrecognized argument %s \n",
+ argv[0], argv[i]);
+ print_usage();
+ }
+ MPI_Finalize();
+ exit (EXIT_FAILURE);
+ }
+ i++;
+ }
+}
+
+
+/************************************************************************/
+/* Data functions */
+/************************************************************************/
+
+void create_data (float* data, Params* p)
+{
+ int i;
+
+ if (p->verbosity >= VERBOSITY_HIGH) {
+ printf ("rank %d: creating random data\n", p->rank);
+ }
+
+ for (i=0; i<(p->blocks * p->particles); i++) {
+ data[i] = (float) random();
+ }
+}
+
+double write_data (float* data, int iter, Params* p)
+{
+ int i,j;
+ double start_time;
+ double open_time;
+ double write_time;
+ double close_time;
+ double total_time;
+ double sum_time;
+ double open_mean;
+ double write_mean;
+ double close_mean;
+ double bandwidth;
+ float* segment;
+ char var_name[64];
+ char* filename;
+ H5PartFile* file;
+ h5part_int64_t status;
+
+ if (p->verbosity >= VERBOSITY_HIGH) {
+ printf ("rank %d: writing data\n", p->rank);
+ }
+
+ start_time = MPI_Wtime();
+
+ filename = (char*) malloc (strlen (p->filename) + 64);
+ sprintf (filename, "%s/%d.h5", p->filename, iter);
+
+ file = H5PartOpenFileParallelAlign (filename,
+ p->flags, MPI_COMM_WORLD, p->alignment);
+ if (!file) {
+ fprintf (stderr,
+ "rank %d: could not open H5Part file!\n", p->rank);
+ MPI_Barrier (MPI_COMM_WORLD);
+ exit (EXIT_FAILURE);
+ }
+
+ H5PartSetNumParticles (file, p->particles);
+ if (p->verbosity >= VERBOSITY_HIGH) {
+ printf ("rank %d: %ld particles\n", p->rank, p->particles);
+ }
+
+ open_time = MPI_Wtime() - start_time;
+
+ segment = data;
+
+ for (i=1; i<=p->segments; i++) {
+ status = H5PartSetStep (file, i);
+ if (status != H5PART_SUCCESS) {
+ fprintf (stderr, "rank %d: H5PartSetStep error!", p->rank);
+ }
+ for (j=0; jblocks; j++) {
+ sprintf (var_name, "test%d", j);
+ status = H5PartWriteDataFloat32 (file, var_name, segment);
+ if (status != H5PART_SUCCESS) {
+ fprintf (stderr,
+ "rank %d: H5PartWriteDataFloat32 error!", p->rank);
+ }
+ segment += p->particles;
+ }
+ }
+
+ write_time = (MPI_Wtime() - start_time) - open_time;
+
+ H5PartCloseFile (file);
+
+ close_time = (MPI_Wtime() - start_time) - write_time - open_time;
+
+ total_time = open_time + write_time + close_time;
+
+ if (p->verbosity >= VERBOSITY_HIGH) {
+ printf ("rank %d: write\t%.3f\t%.3f\t%.3f\t%.3f\n", p->rank,
+ open_time, write_time, close_time, total_time);
+ }
+
+ MPI_Barrier (MPI_COMM_WORLD);
+ MPI_Reduce (&open_time, &sum_time, 1, MPI_DOUBLE,
+ MPI_SUM, 0, MPI_COMM_WORLD);
+ open_mean = sum_time / p->procs;
+ MPI_Reduce (&write_time, &sum_time, 1, MPI_DOUBLE,
+ MPI_SUM, 0, MPI_COMM_WORLD);
+ write_mean = sum_time / p->procs;
+ MPI_Reduce (&close_time, &sum_time, 1, MPI_DOUBLE,
+ MPI_SUM, 0, MPI_COMM_WORLD);
+ close_mean = sum_time / p->procs;
+ bandwidth = p->aggregate_size / total_time;
+
+ if (p->verbosity >= VERBOSITY_MEDIUM && p->rank == 0) {
+ printf ("write\t%.1f\t%.3f\t%.3f\t%.3f\t%.3f\n", bandwidth,
+ open_mean, write_mean, close_mean, total_time);
+ }
+
+ free (filename);
+
+ return bandwidth;
+}
+
+
+/************************************************************************/
+/* Main procedure */
+/************************************************************************/
+
+int main (int argc, char** argv)
+{
+ int i;
+ Params p;
+ float* data;
+ double block_size;
+ double data_size;
+ double bandwidth;
+ double write_max;
+ double write_min;
+ double write_mean;
+ double read_max;
+ double read_min;
+ double read_mean;
+ time_t rawtime;
+ struct tm * timeinfo;
+
+ // initialize MPI
+ MPI_Init (&argc, &argv);
+ MPI_Comm_rank (MPI_COMM_WORLD, &p.rank);
+ MPI_Comm_size (MPI_COMM_WORLD, &p.procs);
+
+ parse_args (argc, argv, &p);
+
+ H5PartSetVerbosityLevel (p.verbosity);
+
+ if (p.verbosity >= VERBOSITY_MEDIUM && p.rank == 0) {
+ time (&rawtime);
+ timeinfo = localtime (&rawtime);
+ printf ("Started: %s", asctime (timeinfo));
+ printf ("Command line:\n");
+ for (i=0; i= VERBOSITY_MEDIUM && p.rank == 0) {
+ printf ("block_size\t\t= %.1f MB\n", block_size);
+ printf ("segment_size\t\t= %.1f MB\n",
+ p.blocks * block_size);
+ printf (" x %5d segment(s)\t= %.1f MB per proc\n",
+ p.segments, data_size);
+ printf (" x %5d procs\t\t= %.1f MB aggregate\n",
+ p.procs, p.aggregate_size);
+ }
+
+ if (p.verbosity >= VERBOSITY_HIGH) {
+ printf ("rank %d: mallocing block data\n", p.rank);
+ }
+
+ data = (float*) malloc (p.segments * p.blocks * p.particles
+ * sizeof(float));
+ if (!data) {
+ fprintf (stderr,
+ "rank %d: could not malloc block data!\n", p.rank);
+ MPI_Barrier (MPI_COMM_WORLD);
+ exit (EXIT_FAILURE);
+ }
+
+ if (p.verbosity >= VERBOSITY_MEDIUM && p.rank == 0) {
+ printf ("access\tbw\topen\twr/rd\tclose\ttotal\n");
+ printf ("(wr/rd)\t(MB/s)\t(s)\t(s)\t(s)\t(s)\n");
+ printf ("------\t--\t----\t-----\t-----\t-----\n");
+ }
+
+ write_max = 0.0;
+ write_min = 10e300;
+ for (i=0; i write_max) write_max = bandwidth;
+ if (bandwidth < write_min) write_min = bandwidth;
+ write_mean += bandwidth;
+ }
+ }
+ write_mean /= p.repetitions;
+
+ if (p.verbosity >= VERBOSITY_LOW && p.rank == 0) {
+ printf ("********************************\n");
+ printf ("** Aggregate Bandwidth (MB/s) **\n");
+ printf ("access max min mean \n");
+ printf ("------ --- --- ---- \n");
+ if (p.write) {
+ printf ("write\t%.1f\t%.1f\t%.1f\n",
+ write_max, write_min, write_mean);
+ }
+ if (p.read) {
+ printf ("read\t%.1f\t%.1f\t%.1f\n",
+ read_max, read_min, read_mean);
+ }
+ printf ("********************************\n");
+ time (&rawtime);
+ timeinfo = localtime (&rawtime);
+ printf ("Finished: %s", asctime (timeinfo));
+ }
+
+ if (p.verbosity >= VERBOSITY_HIGH) {
+ printf ("rank %d: Exiting!\n", p.rank);
+ }
+
+ MPI_Finalize();
+ return (EXIT_SUCCESS);
+}
+
+#else
+#error This file only works when PARALLEL_IO is enabled.
+#endif
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 9f3c610..ec23bed 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -1,83 +1,32 @@
# tools level Makefile.am
-# PATH SETTING
-HDF5ROOT = @HDF5ROOT@
+OBJEXT=o
-# COMPILER SETTING
-CXX = @CXX@
-TOOLS_CXX = @TOOLS_CXX@
+HDFLIB = -L@HDF5ROOT@/lib -lhdf5 -lz @SZLIB@
+LIBS = -L@H5P_LIB_LOC@ -lH5Part $(HDFLIB) -lm @STDCXX@
-# COMPILER FLAG SETTING
-CFLAGS = @CFLAGS@
-
-# # -L$(HDF5ROOT)/lib -lhdf5
-
-# LIBRARIES
-SZLIB = @SZLIB@
-HDFLIB = @TOOLS_HDFLIB@ -lz $(SZLIB)
-LIBS = $(HDFLIB) $(MPILIB) -lm @STDCXX@ @LDFLAGS@
-
-# H5Part compiled library location
-# H5PLIB = -L@prefix@/lib
-H5PLIB = -L@H5P_LIB_LOC@ @TOOLS_H5PART_LIB@
-
-# INCLUDES
-HDFINC = -I$(HDF5ROOT)/include
-INC = $(HDFINC) $(H5PINC) $(MPIINC)
-
-# H5Part header file location
-# H5PINC = -I@prefix@/include
-H5PINC = -I@H5P_LIB_LOC@
+INCLUDES = -I@H5P_LIB_LOC@ -I@HDF5ROOT@/include @MPIINC@
# What to build... make install will place these files in the $(prefix)/bin directory.
bin_PROGRAMS = @BUILD_TOOLS@
# Listing of all programs that maybe built. (Has to know statically...)
-EXTRA_PROGRAMS = h5pAttrib h5pToGNUplot # homdynToH5p
-
-# Extra files that I wish to include in the dist tar ball.
-EXTRA_DIST = h5pAttrib.cc h5pToGNUplot.cc## TO BE TAILORED LATER...
+EXTRA_PROGRAMS = h5pAttrib \
+ h5pToGNUplot \
+ homdynToH5p \
+ H5PartBench \
+ H5BlockBench
# Listing of sources
-h5pAttrib_SOURCES = h5pAttrib.cc
+h5pAttrib_SOURCES = h5pAttrib.cc
+h5pToGNUplot_SOURCES = h5pToGNUplot.cc
+homdynToH5p_SOURCES = homdynToH5p.cc
+H5PartBench_SOURCES = H5PartBench.c
+H5BlockBench_SOURCES = H5BlockBench.c
-h5pToGNUplot_SOURCES = h5pToGNUplot.cc
+.o.cc:
+ $(CXX) $(CFLAGS) $(INCLUDES) -c $<
-#homdynToH5p_SOURCES = homdynToH5p.cc
+.o.c:
+ $(CC) $(CFLAGS) $(INCLUDES) -c $<
-# Specific building instruction (What compilers to use...)
-# ------------ Build Tools ------------
-
-h5pAttrib: h5pAttrib.o
- $(TOOLS_CXX) -o h5pAttrib h5pAttrib.o $(H5PLIB) $(LIBS)
-
-h5pAttrib.o: h5pAttrib.cc
- $(TOOLS_CXX) $(CFLAGS) $(INC) -g -c h5pAttrib.cc
-
-
-h5pToGNUplot: h5pToGNUplot.o
- $(TOOLS_CXX) -o h5pToGNUplot h5pToGNUplot.o $(H5PLIB) $(LIBS)
-
-h5pToGNUplot.o: h5pToGNUplot.cc
- $(TOOLS_CXX) $(CFLAGS) $(INC) -g -c $<
-
-homdynToH5p : homdynToH5p.o
- $(TOOLS_CXX) -o $@ $< $(H5PLIB) $(LIBS)
-
-homdynToH5p.o: homdynToH5p.cc
- $(TOOLS_CXX) $(CFLAGS) $(INC) -g -c $<
-
-
-clean:
- rm -f *~ *.o h5pAttrib h5pToGNUplot
-
-distclean: clean
- rm -rf .deps
- rm -rf Makefile
-
-
-# # bash-3.00$ /usr/bin/mpcc_r -g -O2 -I/scratch/scratchdirs/cristina/hdf5/hdf5_par/include -I/u2/antino/trunk/src -c h5pAttrib.cc
-# # bash-3.00$ /usr/bin/mpcc_r -o h5pAttrib h5pAttrib.o -L/u2/antino/trunk/src -lpH5Part -L/scratch/scratchdirs/cristina/hdf5/hdf5_par/lib -lhdf5 -lz -lm
-
-
-#####################################################################################################################