From 75de0e27546c4066f45760b255e49d87697232b3 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Thu, 22 Nov 2007 11:02:52 +0000 Subject: [PATCH] src/bindings/Fortran * dirs added * Fortran bindings moved to bindings/Fortran --- .gitattributes | 6 + src/bindings/Fortran/H5BlockF.c | 581 +++++++++++++++++ src/bindings/Fortran/H5BlockF90.inc | 176 ++++++ src/bindings/Fortran/H5PartF.c | 825 +++++++++++++++++++++++++ src/bindings/Fortran/H5PartF90.inc | 223 +++++++ src/bindings/Fortran/TestUnderscore.f | 12 + src/bindings/Fortran/TestUnderscoreC.c | 36 ++ 7 files changed, 1859 insertions(+) create mode 100755 src/bindings/Fortran/H5BlockF.c create mode 100644 src/bindings/Fortran/H5BlockF90.inc create mode 100755 src/bindings/Fortran/H5PartF.c create mode 100644 src/bindings/Fortran/H5PartF90.inc create mode 100755 src/bindings/Fortran/TestUnderscore.f create mode 100755 src/bindings/Fortran/TestUnderscoreC.c diff --git a/.gitattributes b/.gitattributes index 4caf171..97e8361 100644 --- a/.gitattributes +++ b/.gitattributes @@ -38,6 +38,12 @@ src/H5PartTypes.h -text src/Makefile.am -text src/TestUnderscore.f -text src/TestUnderscoreC.c -text +src/bindings/Fortran/H5BlockF.c -text +src/bindings/Fortran/H5BlockF90.inc -text +src/bindings/Fortran/H5PartF.c -text +src/bindings/Fortran/H5PartF90.inc -text +src/bindings/Fortran/TestUnderscore.f -text +src/bindings/Fortran/TestUnderscoreC.c -text test/Bench.c -text test/BlockTestSpecs.txt -text test/H5BlockDissolveGhosts.c -text diff --git a/src/bindings/Fortran/H5BlockF.c b/src/bindings/Fortran/H5BlockF.c new file mode 100755 index 0000000..b7c319c --- /dev/null +++ b/src/bindings/Fortran/H5BlockF.c @@ -0,0 +1,581 @@ +#include "H5Part.h" +#include "H5PartPrivate.h" +#include "H5Block.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 h5bl_define3dlayout F77NAME ( \ + h5bl_define3dlayout_, \ + H5BL_DEFINE3DLAYOUT ) +#define h5bl_get_partition_of_proc F77NAME ( \ + h5bl_get_partition_of_proc_, \ + H5BL_GET_PARTITION_OF_PROC ) +#define h5bl_get_reduced_partition_of_proc F77NAME ( \ + h5bl_get_reduced_partition_of_proc_,\ + H5BL_GET_REDUCED_PARTITION_OF_PROC ) +#define h5bl_get_proc_of F77NAME ( \ + h5bl_get_proc_of_, \ + H5BL_GET_PROC_OF ) +#define h5bl_3d_read_scalar_field F77NAME ( \ + h5bl_3d_read_scalar_field_, \ + H5BL_3D_READ_SCALAR_FIELD ) +#define h5bl_3d_write_scalar_field F77NAME ( \ + h5bl_3d_write_scalar_field_, \ + H5BL_3D_WRITE_SCALAR_FIELD ) +#define h5bl_3d_read_3dvector_field F77NAME ( \ + h5bl_3d_read_3dvector_field_, \ + H5BL_3D_READ_3DVECTOR_FIELD ) +#define h5bl_3d_write_3dvector_field F77NAME ( \ + h5bl_3d_write_3dvector_field_, \ + H5BL_3D_WRITE_3DVECTOR_FIELD ) +#define h5bl_getnumfields F77NAME ( \ + h5bl_getnumfields_, \ + H5BL_GETNUMFIELDS ) +#define h5bl_getfieldinfo F77NAME ( \ + h5bl_getfieldinfo_, \ + H5BL_GETFIELDINFO ) +#define h5bl_writefieldattrib_r8 F77NAME ( \ + h5bl_writefieldattrib_r8_, \ + H5BL_WRITEFIELDATTRIB_R8 ) +#define h5bl_writefieldattrib_i8 F77NAME ( \ + h5bl_writefieldattrib_i8_, \ + H5BL_WRITEFIELDATTRIB_I8 ) +#define h5bl_writefieldattrib_string F77NAME ( \ + h5bl_writefieldattrib_string_, \ + H5BL_WRITEFIELDATTRIB_STRING ) +#define h5bl_getnfieldattribs F77NAME ( \ + h5bl_getnfieldattribs_, \ + H5BL_GETNFIELDATTRIBS ) +#define h5bl_getfieldattribinfo F77NAME ( \ + h5bl_getfieldattribinfo_, \ + h5bl_getfieldattribinfo ) +#define h5bl_readfieldattrib_i8 F77NAME ( \ + h5bl_readfieldattrib_i8_, \ + H5BL_READFIELDATTRIB_I8 ) +#define h5bl_readfieldattrib_r8 F77NAME ( \ + h5bl_readfieldattrib_r8_, \ + H5BL_READFIELDATTRIB_R8 ) +#define h5bl_readfieldattrib_string F77NAME ( \ + h5bl_readfieldattrib_string_, \ + H5BL_READFIELDATTRIB_STRING ) +#define h5bl_has_fielddata F77NAME ( \ + h5bl_has_fielddata_, \ + H5BL_HAS_FIELDDATA ) +#define h5bl_3d_set_field_spacing F77NAME ( \ + h5bl_3d_set_field_spacing_, \ + H5BL_3D_SET_FIELD_SPACING ) +#define h5bl_3d_get_field_spacing F77NAME ( \ + h5bl_3d_get_field_spacing_, \ + H5BL_3D_GET_FIELD_SPACING ) +#define h5bl_3d_set_field_origin F77NAME ( \ + h5bl_3d_set_field_origin_, \ + H5BL_3D_SET_FIELD_ORIGIN ) +#define h5bl_3d_get_field_origin F77NAME ( \ + h5bl_3d_get_field_origin_, \ + H5BL_3D_GET_FIELD_origin ) +#endif + +h5part_int64_t +h5bl_define3dlayout ( + h5part_int64_t *f, + const h5part_int64_t *i_start, /*!< start index of i */ + const h5part_int64_t *i_end, /*!< end index of i */ + const h5part_int64_t *j_start, /*!< start index of j */ + const h5part_int64_t *j_end, /*!< end index of j */ + const h5part_int64_t *k_start, /*!< start index of k */ + const h5part_int64_t *k_end /*!< end index of k */ + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + return H5BlockDefine3DFieldLayout ( + filehandle, + *i_start-1, *i_end-1, + *j_start-1, *j_end-1, + *k_start-1, *k_end-1 ); +} + +h5part_int64_t +h5bl_get_partition_of_proc ( + h5part_int64_t *f, /*!< file handle */ + const h5part_int64_t *proc, + h5part_int64_t *i_start, /*!< start index of i */ + h5part_int64_t *i_end, /*!< end index of i */ + h5part_int64_t *j_start, /*!< start index of j */ + h5part_int64_t *j_end, /*!< end index of j */ + h5part_int64_t *k_start, /*!< start index of k */ + h5part_int64_t *k_end /*!< end index of k */ + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + h5part_int64_t herr = H5Block3dGetPartitionOfProc ( + filehandle, + *proc, + i_start, i_end, j_start, j_end, k_start, k_end ); + if ( herr < 0 ) return herr; + + (*i_start)++; + (*i_end)++; + (*j_start)++; + (*j_end)++; + (*k_start)++; + (*k_end)++; + + return H5PART_SUCCESS; +} + +h5part_int64_t +h5bl_get_reduced_partition_of_proc ( + h5part_int64_t *f, + const h5part_int64_t *proc, + h5part_int64_t *i_start, + h5part_int64_t *i_end, + h5part_int64_t *j_start, + h5part_int64_t *j_end, + h5part_int64_t *k_start, + h5part_int64_t *k_end + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + h5part_int64_t herr = H5Block3dGetReducedPartitionOfProc ( + filehandle, + *proc, + i_start, i_end, j_start, j_end, k_start, k_end ); + if ( herr < 0 ) return herr; + + (*i_start)++; + (*i_end)++; + (*j_start)++; + (*j_end)++; + (*k_start)++; + (*k_end)++; + + return H5PART_SUCCESS; +} + +h5part_int64_t +h5bl_get_proc_of ( + h5part_int64_t *f, + const h5part_int64_t *i, + const h5part_int64_t *j, + const h5part_int64_t *k + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + return H5Block3dGetProcOf ( filehandle, (*i)-1, (*j)-1, (*k)-1 ); +} + +h5part_int64_t +h5bl_3d_read_scalar_field ( + h5part_int64_t *f, + const char *field_name, + h5part_float64_t *data, + const int l_field_name + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name ); + + h5part_int64_t herr = H5Block3dReadScalarField ( + filehandle, field_name2, data ); + + free ( field_name2 ); + return herr; +} + +h5part_int64_t +h5bl_3d_write_scalar_field ( + h5part_int64_t *f, + const char *field_name, + const h5part_float64_t *data, + const int l_field_name + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name ); + + h5part_int64_t herr = H5Block3dWriteScalarField ( + filehandle, field_name2, data ); + + free ( field_name2 ); + return herr; +} + +h5part_int64_t +h5bl_3d_read_3dvector_field ( + h5part_int64_t *f, /*!< file handle */ + const char *field_name, /*!< name of the data set */ + h5part_float64_t *xval, /*!< array of x component data */ + h5part_float64_t *yval, /*!< array of y component data */ + h5part_float64_t *zval, /*!< array of z component data */ + const int l_field_name + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name ); + + h5part_int64_t herr = H5Block3dRead3dVectorField ( + filehandle, field_name2, xval, yval, zval ); + + free ( field_name2 ); + return herr; +} + +h5part_int64_t +h5bl_3d_write_3dvector_field ( + h5part_int64_t *f, /*!< file handle */ + const char *field_name, /*!< name of the data set */ + const h5part_float64_t *xval, /*!< array of x component data */ + const h5part_float64_t *yval, /*!< array of y component data */ + const h5part_float64_t *zval, /*!< array of z component data */ + const int l_field_name + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name ); + + h5part_int64_t herr = H5Block3dWrite3dVectorField ( + filehandle, field_name2, xval, yval, zval ); + + free ( field_name2 ); + return herr; +} + +h5part_int64_t +h5bl_getnumfields ( + h5part_int64_t *f /*!< file handle */ + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + return H5BlockGetNumFields ( filehandle ); +} + +h5part_int64_t +h5bl_getfieldinfo ( + h5part_int64_t *f, + const h5part_int64_t *idx, + char *field_name, + h5part_int64_t *grid_rank, + h5part_int64_t *grid_dims, + h5part_int64_t *field_dims, + const int l_field_name + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + h5part_int64_t herr = H5BlockGetFieldInfo ( + filehandle, *idx, field_name, l_field_name, + grid_rank, grid_dims, field_dims ); + _H5Part_strc2for ( field_name, l_field_name ); + return herr; +} + +h5part_int64_t +h5bl_writefieldattrib_r8 ( + h5part_int64_t *f, + const char *field_name, + const char *attrib_name, + const h5part_float64_t *attrib_value, + const h5part_int64_t *attrib_nelem, + const int l_field_name, + const int l_attrib_name + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name ); + char *attrib_name2 =_H5Part_strdupfor2c ( attrib_name, l_attrib_name ); + + h5part_int64_t herr = H5BlockWriteFieldAttrib ( + filehandle, field_name2, attrib_name2, H5PART_FLOAT64, + attrib_value, *attrib_nelem ); + + free ( field_name2 ); + free ( attrib_name2 ); + return herr; +} + + +h5part_int64_t +h5bl_writefieldattrib_i8 ( + h5part_int64_t *f, + const char *field_name, + const char *attrib_name, + const h5part_int64_t *attrib_value, + const h5part_int64_t *attrib_nelem, + const int l_field_name, + const int l_attrib_name + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name ); + char *attrib_name2 =_H5Part_strdupfor2c ( attrib_name, l_attrib_name ); + + h5part_int64_t herr = H5BlockWriteFieldAttrib ( + filehandle, field_name2, attrib_name2, H5PART_INT64, + attrib_value, *attrib_nelem ); + + free ( field_name2 ); + free ( attrib_name2 ); + return herr; +} + +h5part_int64_t +h5bl_writefieldattrib_string ( + h5part_int64_t *f, + const char *field_name, + const char *attrib_name, + const char *attrib_value, + const int l_field_name, + const int l_attrib_name, + const int l_attrib_value + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + char *field_name2 =_H5Part_strdupfor2c ( field_name, l_field_name ); + char *attrib_name2=_H5Part_strdupfor2c ( attrib_name, l_attrib_name ); + char *attrib_value2=_H5Part_strdupfor2c( attrib_value,l_attrib_value ); + + h5part_int64_t herr = H5BlockWriteFieldAttribString ( + filehandle, field_name2, attrib_name2, attrib_value2 ); + + free ( field_name2 ); + free ( attrib_name2 ); + free ( attrib_value2 ); + return herr; +} + + +h5part_int64_t +h5bl_getnfieldattribs ( + h5part_int64_t *f, + const char *field_name, + const int l_field_name + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name ); + + h5part_int64_t herr = H5BlockGetNumFieldAttribs ( + filehandle, field_name2 ); + + free ( field_name2 ); + return herr; +} + +h5part_int64_t +h5bl_getfieldattribinfo ( + h5part_int64_t *f, + const char *field_name, + const h5part_int64_t *attrib_idx, + char *attrib_name, + h5part_int64_t *attrib_nelem, + const int l_field_name, + const int l_attrib_name + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + h5part_int64_t attrib_type; + + char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name ); + + h5part_int64_t herr = H5BlockGetFieldAttribInfo ( + filehandle, field_name2, *attrib_idx, + attrib_name, l_attrib_name, + &attrib_type, + attrib_nelem ); + + _H5Part_strc2for ( attrib_name, l_attrib_name ); + + free ( field_name2 ); + return herr; +} + + +h5part_int64_t +h5bl_readfieldattrib_i8 ( + h5part_int64_t *f, + const char *field_name, + const char *attrib_name, + h5part_int64_t *attrib_value, + const int l_field_name, + const int l_attrib_name + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + char *field_name2 =_H5Part_strdupfor2c ( field_name, l_field_name ); + char *attrib_name2=_H5Part_strdupfor2c ( attrib_name, l_attrib_name ); + + h5part_int64_t herr = H5BlockReadFieldAttrib ( + filehandle, field_name2, attrib_name2, attrib_value ); + + free ( field_name2 ); + free ( attrib_name2 ); + return herr; +} + +h5part_int64_t +h5bl_readfieldattrib_r8 ( + h5part_int64_t *f, + const char *field_name, + const char *attrib_name, + h5part_float64_t *attrib_value, + const int l_field_name, + const int l_attrib_name + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + char *field_name2 =_H5Part_strdupfor2c ( field_name, l_field_name ); + char *attrib_name2=_H5Part_strdupfor2c ( attrib_name, l_attrib_name ); + + h5part_int64_t herr = H5BlockReadFieldAttrib ( + filehandle, field_name2, attrib_name2, attrib_value ); + + free ( field_name2 ); + free ( attrib_name2 ); + return herr; +} + +h5part_int64_t +h5bl_readfieldattrib_string ( + h5part_int64_t *f, + const char *field_name, + const char *attrib_name, + char *attrib_value, + const int l_field_name, + const int l_attrib_name, + const int l_attrib_value + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + char *field_name2 =_H5Part_strdupfor2c ( field_name, l_field_name ); + char *attrib_name2=_H5Part_strdupfor2c ( attrib_name, l_attrib_name ); + + h5part_int64_t herr = H5BlockReadFieldAttrib ( + filehandle, field_name2, attrib_name2, attrib_value ); + + _H5Part_strc2for ( attrib_value, l_attrib_value ); + + free ( field_name2 ); + free ( attrib_name2 ); + return herr; +} + +h5part_int64_t +h5bl_has_fielddata ( + h5part_int64_t *f + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + return H5BlockHasFieldData ( filehandle ); +} + +h5part_int64_t +h5b_3d_get_field_spacing ( + h5part_int64_t *f, + const char *field_name, + h5part_float64_t *x, + h5part_float64_t *y, + h5part_float64_t *z, + const int l_field_name + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name ); + + h5part_int64_t herr = H5Block3dGetFieldSpacing ( + filehandle, field_name2, x, y, z ); + + free ( field_name2 ); + return herr; +} + +h5part_int64_t +h5b_3d_set_field_spacing ( + h5part_int64_t *f, + const char *field_name, + const h5part_float64_t *x, + const h5part_float64_t *y, + const h5part_float64_t *z, + const int l_field_name + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name ); + + h5part_int64_t herr = H5Block3dSetFieldSpacing ( + filehandle, field_name2, *x, *y, *z ); + + free ( field_name2 ); + return herr; +} + +h5part_int64_t +h5b_3d_get_field_origin ( + h5part_int64_t *f, + const char *field_name, + h5part_float64_t *x, + h5part_float64_t *y, + h5part_float64_t *z, + const int l_field_name + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name ); + + h5part_int64_t herr = H5Block3dGetFieldOrigin ( + filehandle, field_name2, x, y, z ); + + free ( field_name2 ); + return herr; +} + +h5part_int64_t +h5b_3d_set_field_origin ( + h5part_int64_t *f, + const char *field_name, + const h5part_float64_t *x, + const h5part_float64_t *y, + const h5part_float64_t *z, + const int l_field_name + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name ); + + h5part_int64_t herr = H5Block3dSetFieldOrigin ( + filehandle, field_name2, *x, *y, *z ); + + free ( field_name2 ); + return herr; +} diff --git a/src/bindings/Fortran/H5BlockF90.inc b/src/bindings/Fortran/H5BlockF90.inc new file mode 100644 index 0000000..ff5c91e --- /dev/null +++ b/src/bindings/Fortran/H5BlockF90.inc @@ -0,0 +1,176 @@ + 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_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_3d_read_scalar_field ( 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_scalar_field ( 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_3dvector_field ( 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_3dvector_field ( 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_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_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_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_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/bindings/Fortran/H5PartF.c b/src/bindings/Fortran/H5PartF.c new file mode 100755 index 0000000..17f1681 --- /dev/null +++ b/src/bindings/Fortran/H5PartF.c @@ -0,0 +1,825 @@ +#include "H5Part.h" +#include "Underscore.h" +#include + +#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) + +/* open/close interface */ +#define h5pt_openr F77NAME ( \ + h5pt_openr_, \ + H5PT_OPENR ) +#define h5pt_openw F77NAME ( \ + h5pt_openw_, \ + H5PT_OPENW ) +#define h5pt_opena F77NAME ( \ + h5pt_opena_, \ + H5PT_OPENA ) +#define h5pt_openr_par F77NAME ( \ + h5pt_openr_par_, \ + H5PT_OPENR_PAR ) +#define h5pt_openw_par F77NAME ( \ + h5pt_openw_par_, \ + H5PT_OPENW_PAR ) +#define h5pt_opena_par F77NAME ( \ + h5pt_opena_par_, \ + H5PT_OPENA_PAR ) +#define h5pt_close F77NAME ( \ + h5pt_close_, \ + H5PT_CLOSE) + +/* writing interface */ +#define h5pt_setnpoints F77NAME ( \ + h5pt_setnpoints_, \ + H5PT_SETNPOINTS ) +#define h5pt_setstep F77NAME ( \ + h5pt_setstep_, \ + H5PT_SETSTEP ) +#define h5pt_writedata_r8 F77NAME ( \ + h5pt_writedata_r8_, \ + H5PT_WRITEDATA_R8 ) +#define h5pt_writedata_i8 F77NAME ( \ + h5pt_writedata_i8_, \ + H5PT_WRITEDATA_I8 ) + +/* Reading interface (define dataset, step, particles, attributes) */ +#define h5pt_getnsteps F77NAME ( \ + h5pt_getnsteps_, \ + H5PT_GETNSTEPS ) +#define h5pt_getndatasets F77NAME ( \ + h5pt_getndatasets_, \ + H5PT_GETNDATASETS ) +#define h5pt_getnpoints F77NAME ( \ + h5pt_getnpoints_, \ + H5PT_GETNPOINTS ) +#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_resetview F77NAME ( \ + h5pt_resetview_, \ + H5PT_RESETVIEW ) +#define h5pt_hasview F77NAME ( \ + h5pt_hasview_, \ + H5PT_HASVIEW ) +#define h5pt_getview F77NAME ( \ + h5pt_getview_, \ + H5PT_GETVIEW ) + +/* Reading data */ +#define h5pt_readdata_r8 F77NAME ( \ + h5pt_readdata_r8_, \ + H5PT_READDATA_R8 ) +#define h5pt_readdata_i8 F77NAME ( \ + h5pt_readdata_i8_, \ + H5PT_READDATA_I8 ) +#define h5pt_readdata F77NAME ( \ + h5pt_readdata_, \ + H5PT_READDATA ) + +/* 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 ) + +/* Reading attributes */ +#define h5pt_getnstepattribs F77NAME ( \ + h5pt_getnstepattribs_, \ + H5PT_GETNSTEPATTRIBS ) +#define h5pt_getnfileattribs F77NAME ( \ + h5pt_getnfileattribs_, \ + H5PT_GETNFILEATTRIBS ) +#define h5pt_getstepattribinfo F77NAME ( \ + h5pt_getstepattribinfo_, \ + H5PT_GETSTEPATTRIBINFO ) +#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 ) + +/* error handling */ +#define h5pt_set_verbosity_level F77NAME ( \ + h5pt_set_verbosity_level_, \ + H5PT_SET_VERBOSITY_LEVEL ) + +#endif + +char * +_H5Part_strdupfor2c ( + const char *s, + const ssize_t len + ) { + + char *dup = (char*)malloc ( len + 1 ); + strncpy ( dup, s, len ); + char *p = dup + len; + do { + *p-- = '\0'; + } while ( *p == ' ' ); + return dup; +} + +char * +_H5Part_strc2for ( + char * const str, + const ssize_t l_str + ) { + + size_t len = strlen ( str ); + memset ( str+len, ' ', l_str-len ); + + return str; +} + +/* open/close interface */ +h5part_int64_t +h5pt_openr ( + const char *file_name, + const int l_file_name + ) { + + char *file_name2 = _H5Part_strdupfor2c ( file_name, l_file_name ); + + H5PartFile* f = H5PartOpenFile ( file_name2, H5PART_READ ); + + free ( file_name2 ); + return (h5part_int64_t)(size_t)f; +} + +h5part_int64_t +h5pt_openw ( + const char *file_name, + const int l_file_name + ) { + + char *file_name2 = _H5Part_strdupfor2c ( file_name, l_file_name ); + + H5PartFile* f = H5PartOpenFile ( file_name2, H5PART_WRITE ); + + free ( file_name2 ); + return (h5part_int64_t)(size_t)f; +} + +h5part_int64_t +h5pt_opena ( + const char *file_name, + const int l_file_name + ) { + + char *file_name2 = _H5Part_strdupfor2c ( file_name, l_file_name ); + + H5PartFile* f = H5PartOpenFile ( file_name2, H5PART_APPEND ); + + free ( file_name2 ); + return (h5part_int64_t)(size_t)f; +} + +#ifdef PARALLEL_IO +h5part_int64_t +h5pt_openr_par ( + const char *file_name, + MPI_Comm *comm, + const int l_file_name + ) { + + char *file_name2 = _H5Part_strdupfor2c ( file_name, l_file_name ); + + H5PartFile* f = H5PartOpenFileParallel ( + file_name2, H5PART_READ, *comm ); + + free ( file_name2 ); + return (h5part_int64_t)(size_t)f; +} + +h5part_int64_t +h5pt_openw_par ( + const char *file_name, + MPI_Comm *comm, + const int l_file_name + ) { + + char *file_name2 = _H5Part_strdupfor2c ( file_name, l_file_name ); + + H5PartFile* f = H5PartOpenFileParallel ( + file_name2, H5PART_WRITE, *comm ); + + free ( file_name2 ); + return (h5part_int64_t)(size_t)f; +} + +h5part_int64_t +h5pt_opena_par ( + const char *file_name, + MPI_Comm *comm, + const int l_file_name + ) { + + char *file_name2 = _H5Part_strdupfor2c ( file_name, l_file_name ); + + H5PartFile* f = H5PartOpenFileParallel ( + file_name2, H5PART_APPEND, *comm ); + + free ( file_name2 ); + return (h5part_int64_t)(size_t)f; +} +#endif + +h5part_int64_t +h5pt_close ( + const h5part_int64_t *f + ) { + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + return H5PartCloseFile ( filehandle ); +} + +/*==============Writing and Setting Dataset info========*/ + +h5part_int64_t +h5pt_readstep ( + const h5part_int64_t *f, + const h5part_int64_t *step, + h5part_float64_t *x, + h5part_float64_t *y, + h5part_float64_t *z, + h5part_float64_t *px, + h5part_float64_t *py, + h5part_float64_t *pz, + h5part_int64_t *id + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + return H5PartReadParticleStep ( + filehandle,(*step)-1,x,y,z,px,py,pz,id); +} + + +h5part_int64_t +h5pt_setnpoints ( + const h5part_int64_t *f, + h5part_int64_t *np + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + return H5PartSetNumParticles ( filehandle, *np ); +} + +h5part_int64_t +h5pt_setstep ( + const h5part_int64_t *f, + h5part_int64_t *step ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + return H5PartSetStep ( filehandle, (*step)-1 ); +} + +h5part_int64_t +h5pt_writedata_r8 ( + const 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 = H5PartWriteDataFloat64 ( + filehandle, name2, data ); + + free ( name2 ); + + return herr; +} + +h5part_int64_t +h5pt_writedata_i8 ( + const 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 = H5PartWriteDataInt64 ( + filehandle, name2, data ); + + free ( name2 ); + + return herr; +} + +/*==============Reading Data Characteristics============*/ + +h5part_int64_t +h5pt_getnsteps ( + const h5part_int64_t *f + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + return H5PartGetNumSteps ( filehandle ); +} + +h5part_int64_t +h5pt_getndatasets ( + const h5part_int64_t *f + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + return H5PartGetNumDatasets ( filehandle ); +} + +h5part_int64_t +h5pt_getnpoints ( + const h5part_int64_t *f + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + return H5PartGetNumParticles ( filehandle ); +} + +h5part_int64_t +h5pt_getdatasetname ( + const h5part_int64_t *f, + const h5part_int64_t *index, + char *name, + const int l_name + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + h5part_int64_t herr = H5PartGetDatasetName ( + filehandle, *index, name, l_name ); + + _H5Part_strc2for ( name, l_name ); + 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 +h5pt_setview ( + const h5part_int64_t *f, + const h5part_int64_t *start, + const h5part_int64_t *end + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + return H5PartSetView ( filehandle, *start, *end ); +} + +h5part_int64_t +h5pt_resetview ( + const h5part_int64_t *f + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + return H5PartResetView ( filehandle ); +} + +h5part_int64_t +h5pt_hasview ( + const h5part_int64_t *f + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + return H5PartHasView ( filehandle ); +} + +h5part_int64_t +h5pt_getview ( + const h5part_int64_t *f, + h5part_int64_t *start, + h5part_int64_t *end + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + return H5PartGetView ( filehandle, start, end); +} +/*==================Reading data ============*/ +h5part_int64_t +h5pt_readdata_r8 ( + const h5part_int64_t *f, + const char *name, + h5part_float64_t *array, + const int l_name + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + char *name2 = _H5Part_strdupfor2c ( name, l_name ); + + h5part_int64_t herr = H5PartReadDataFloat64 ( + filehandle, name2, array ); + + free ( name2 ); + return herr; +} + +h5part_int64_t +h5pt_readdata_i8 ( + const h5part_int64_t *f, + const char *name, + h5part_int64_t *array, + const int l_name + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + char *name2 = _H5Part_strdupfor2c ( name, l_name ); + + h5part_int64_t herr = H5PartReadDataInt64 ( + filehandle, name2, array ); + + free ( name2 ); + return herr; +} + +/*=================== 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, + const char *attrib_name, + const char *attrib_value, + const int l_attrib_name, + const int l_attrib_value + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + char *attrib_name2 = _H5Part_strdupfor2c (attrib_name,l_attrib_name); + char *attrib_value2= _H5Part_strdupfor2c (attrib_value,l_attrib_value); + + h5part_int64_t herr = H5PartWriteFileAttribString ( + filehandle, attrib_name2, attrib_value2 ); + + free ( attrib_name2 ); + free ( attrib_value2 ); + 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, + const char *attrib_name, + const char *attrib_value, + const int l_attrib_name, + const int l_attrib_value + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + char *attrib_name2 = _H5Part_strdupfor2c (attrib_name,l_attrib_name); + char *attrib_value2= _H5Part_strdupfor2c (attrib_value,l_attrib_value); + + h5part_int64_t herr = H5PartWriteStepAttribString ( + filehandle, attrib_name2, attrib_value2 ); + + free ( attrib_name2 ); + free ( attrib_value2 ); + return herr; +} + +/* Reading attributes ************************* */ + +h5part_int64_t +h5pt_getnstepattribs ( + const h5part_int64_t *f + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + return H5PartGetNumStepAttribs ( filehandle ); +} + +h5part_int64_t +h5pt_getnfileattribs ( + const h5part_int64_t *f + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + + return H5PartGetNumFileAttribs ( filehandle ); +} + +h5part_int64_t +h5pt_getstepattribinfo ( + const h5part_int64_t *f, + const h5part_int64_t *idx, + char *name, + h5part_int64_t *nelem, + const int l_name + ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + h5part_int64_t type; + + h5part_int64_t herr = H5PartGetStepAttribInfo ( + filehandle, *idx, name, l_name, &type, nelem); + + _H5Part_strc2for( name, l_name ); + return herr; +} + +h5part_int64_t +h5pt_getfileattribinfo ( + const h5part_int64_t *f, + const h5part_int64_t *idx, + char *name, + h5part_int64_t *nelem, + const int l_name ) { + + H5PartFile *filehandle = (H5PartFile*)(size_t)*f; + h5part_int64_t type; + + h5part_int64_t herr = H5PartGetFileAttribInfo ( + filehandle, *idx, name, l_name, &type, nelem); + + _H5Part_strc2for( name, l_name ); + 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, + const char *attrib_name, + char *attrib_value, + 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 ( + filehandle, attrib_name2, 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, + const char *attrib_name, + char *attrib_value, + const int l_attrib_name, + const int l_attrib_value + ) { + + h5part_int64_t herr = h5pt_readfileattrib ( + f, attrib_name, attrib_value, l_attrib_name ); + + _H5Part_strc2for ( attrib_value, l_attrib_value ); + return herr; +} + +h5part_int64_t +h5pt_set_verbosity_level ( + const h5part_int64_t *level + ) { + return H5PartSetVerbosityLevel ( *level ); +} diff --git a/src/bindings/Fortran/H5PartF90.inc b/src/bindings/Fortran/H5PartF90.inc new file mode 100644 index 0000000..12f533d --- /dev/null +++ b/src/bindings/Fortran/H5PartF90.inc @@ -0,0 +1,223 @@ +! 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_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_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 + +!==============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_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 + + +!=================== 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/bindings/Fortran/TestUnderscore.f b/src/bindings/Fortran/TestUnderscore.f new file mode 100755 index 0000000..4de2c6e --- /dev/null +++ b/src/bindings/Fortran/TestUnderscore.f @@ -0,0 +1,12 @@ +c ============== +c +c Simple Fortran program works in conjunction with C program +c to determine how many underscores are generated +c by the fortran compiler +c +c ============== + + program TestUnderscoreF + implicit none + call FindUnderscores + end diff --git a/src/bindings/Fortran/TestUnderscoreC.c b/src/bindings/Fortran/TestUnderscoreC.c new file mode 100755 index 0000000..0beafb7 --- /dev/null +++ b/src/bindings/Fortran/TestUnderscoreC.c @@ -0,0 +1,36 @@ +#include + +void findunderscores(void){ + printf("#ifndef F77_NO_UNDERSCORE\n"); + printf("#define F77_NO_UNDERSCORE\n"); + printf("#endif\n"); + printf("#ifndef F77_NO_CAPS\n"); + printf("#define F77_NO_CAPS\n"); + printf("#endif\n"); +} + +void FindUnderscores(void){ + printf("#ifndef F77_NO_UNDERSCORE\n"); + printf("#define F77_NO_UNDERSCORE\n"); + printf("#endif\n"); +} + +void FindUnderscores_(void){ + printf("#ifndef F77_SINGLE_UNDERSCORE\n"); + printf("#define F77_SINGLE_UNDERSCORE\n"); + printf("#endif\n"); +} + +void findunderscores_(void){ + printf("#ifndef F77_SINGLE_UNDERSCORE\n"); + printf("#define F77_SINGLE_UNDERSCORE\n"); + printf("#endif\n"); + printf("#ifndef F77_NO_CAPS\n"); + printf("#define F77_NO_CAPS\n"); + printf("#endif\n"); +} +void FINDUNDERSCORES(void){ + printf("#ifndef F77_CRAY_UNDERSCORE\n"); + printf("#define F77_CRAY_UNDERSCORE\n"); + printf("#endif\n"); +}