From 60df95b10a35e2b5cf6ea67a5812e9e6932af375 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Tue, 28 Jan 2014 17:31:22 +0100 Subject: [PATCH] most missing functions added to Fortran API --- src/Fortran/H5.c | 12 +- src/Fortran/H5Block_attribs.c | 355 ++++++++++++++++++++++++++++++++ src/Fortran/H5Block_model.c | 180 ++++++++++++++-- src/Fortran/H5Part_model.c | 282 ++++++++++++++----------- src/Fortran/H5_attribs.c | 38 +++- src/Fortran/Makefile.am | 8 +- src/include/H5.f90 | 10 +- src/include/H5Block_attribs.f90 | 78 +++++++ src/include/H5Part_model.f90 | 123 ++++++----- 9 files changed, 879 insertions(+), 207 deletions(-) diff --git a/src/Fortran/H5.c b/src/Fortran/H5.c index fe6cd31..69f38c6 100644 --- a/src/Fortran/H5.c +++ b/src/Fortran/H5.c @@ -273,4 +273,14 @@ h5_abort_on_error ( H5_API_RETURN (h5_set_errorhandler (h5_abort_errorhandler)); } - +#define h5_get_error_number F77_NAME( \ + h5_get_error_number, \ + h5_get_error_number_, \ + H5_GET_ERROR_NUMBER) +h5_int64_t +h5_get_error_number ( + void + ) { + H5_API_ENTER (h5_int64_t, "%s", ""); + H5_API_RETURN (h5_get_errno ()); +} diff --git a/src/Fortran/H5Block_attribs.c b/src/Fortran/H5Block_attribs.c index 9d1ce35..5a02858 100644 --- a/src/Fortran/H5Block_attribs.c +++ b/src/Fortran/H5Block_attribs.c @@ -454,3 +454,358 @@ h5bl_readfieldattrib_i4 ( H5_I4_T, attrib_value)); } + +#define h5bl_get_fieldorigin F77_NAME ( \ + h5bl_get_fieldorigin, \ + h5bl_get_fieldorigin_, \ + H5BL_GET_FIELDORIGIN) + +h5_int64_t +h5bl_get_fieldorigin ( + const h5_int64_t* const fh, + const char* const field_name, + h5_float64_t* const x_origin, + h5_float64_t* const y_origin, + h5_float64_t* const z_origin, + const int l_field_name + ) { + h5_file_t f = h5_filehandlefor2c (fh); + H5_API_ENTER (h5_int64_t, + "fh=%p, field_name='%.*s'" + ", x_origin=%p" + ", y_origin=%p" + ", z_origin=%p", + (h5_file_p)f, + l_field_name, field_name, + x_origin, y_origin, z_origin); + h5_float64_t origin[3]; + TRY (read_field_attrib ( + f, + field_name, l_field_name, + H5BLOCK_FIELD_ORIGIN_NAME, sizeof (H5BLOCK_FIELD_ORIGIN_NAME), + H5_R8_T, + origin)); + *x_origin = origin[0]; + *y_origin = origin[1]; + *z_origin = origin[2]; + + H5_API_RETURN (H5_SUCCESS); +} + +#define h5bl_set_fieldorigin F77_NAME ( \ + h5bl_set_fieldorigin, \ + h5bl_set_fieldorigin_, \ + H5BL_SET_FIELDORIGIN) + +h5_int64_t +h5bl_set_fieldorigin ( + const h5_int64_t* const fh, + const char* const field_name, + h5_float64_t* const x_origin, + h5_float64_t* const y_origin, + h5_float64_t* const z_origin, + const int l_field_name + ) { + h5_file_t f = h5_filehandlefor2c (fh); + H5_API_ENTER (h5_int64_t, + "fh=%p, field_name='%.*s'" + ", x_origin=%g" + ", y_origin=%g" + ", z_origin=%g", + (h5_file_p)f, + l_field_name, field_name, + *x_origin, *y_origin, *z_origin); + h5_float64_t origin[3] = { *x_origin, *y_origin, *z_origin }; + TRY (write_field_attrib ( + f, + field_name, l_field_name, + H5BLOCK_FIELD_ORIGIN_NAME, sizeof (H5BLOCK_FIELD_ORIGIN_NAME), + H5_R8_T, + origin, 3)); + + H5_API_RETURN (H5_SUCCESS); +} + +#define h5bl_get_fieldspacing F77_NAME ( \ + h5bl_get_fieldspacing, \ + h5bl_get_fieldspacing_, \ + H5BL_GET_FIELDSPACING) + +h5_int64_t +h5bl_get_fieldspacing ( + const h5_int64_t* const fh, + const char* const field_name, + h5_float64_t* const x_spacing, + h5_float64_t* const y_spacing, + h5_float64_t* const z_spacing, + const int l_field_name + ) { + h5_file_t f = h5_filehandlefor2c (fh); + H5_API_ENTER (h5_int64_t, + "fh=%p, field_name='%.*s'" + ", x_spacing=%p" + ", y_spacing=%p" + ", z_spacing=%p", + (h5_file_p)f, + l_field_name, field_name, + x_spacing, y_spacing, z_spacing); + h5_float64_t spacing[3]; + TRY (read_field_attrib ( + f, + field_name, l_field_name, + H5BLOCK_FIELD_ORIGIN_NAME, sizeof (H5BLOCK_FIELD_ORIGIN_NAME), + H5_R8_T, + spacing)); + *x_spacing = spacing[0]; + *y_spacing = spacing[1]; + *z_spacing = spacing[2]; + + H5_API_RETURN (H5_SUCCESS); +} + +#define h5bl_set_fieldspacing F77_NAME ( \ + h5bl_set_fieldspacing, \ + h5bl_set_fieldspacing_, \ + H5BL_SET_FIELDSPACING) + +h5_int64_t +h5bl_set_fieldspacing ( + const h5_int64_t* const fh, + const char* const field_name, + h5_float64_t* const x_spacing, + h5_float64_t* const y_spacing, + h5_float64_t* const z_spacing, + const int l_field_name + ) { + h5_file_t f = h5_filehandlefor2c (fh); + H5_API_ENTER (h5_int64_t, + "fh=%p, field_name='%.*s'" + ", x_spacing=%g" + ", y_spacing=%g" + ", z_spacing=%g", + (h5_file_p)f, + l_field_name, field_name, + *x_spacing, *y_spacing, *z_spacing); + h5_float64_t spacing[3] = { *x_spacing, *y_spacing, *z_spacing }; + TRY (read_field_attrib ( + f, + field_name, l_field_name, + H5BLOCK_FIELD_ORIGIN_NAME, sizeof (H5BLOCK_FIELD_SPACING_NAME), + H5_R8_T, + spacing)); + + H5_API_RETURN (H5_SUCCESS); +} + + +static inline h5_int64_t +set_field_coords ( + const h5_file_t f, + int rank, + const char* field_name, + const int l_field_name, + const char* attrib_name, + const int l_attrib_name, + const h5_float64_t* coords, + const h5_int64_t n_coords + ) { + char *field_name2 = h5_strdupfor2c (field_name, l_field_name); + char *attrib_name2 = h5_strdupfor2c (attrib_name, l_attrib_name); + + h5_int64_t h5err = h5b_set_3d_field_coords ( + f, rank, + field_name2, attrib_name2, + coords, n_coords); + + free (field_name2); + free (attrib_name2); + + return (h5err); +} + +static inline h5_int64_t +get_field_coords ( + const h5_file_t f, + int rank, + const char* field_name, + const int l_field_name, + const char* attrib_name, + const int l_attrib_name, + h5_float64_t* const coords, + const h5_int64_t n_coords + ) { + char *field_name2 = h5_strdupfor2c (field_name, l_field_name); + char *attrib_name2 = h5_strdupfor2c (attrib_name, l_attrib_name); + + h5_int64_t h5err = h5b_get_3d_field_coords ( + f, rank, + field_name2, attrib_name2, + coords, n_coords); + + free (field_name2); + free (attrib_name2); + + return (h5err); +} + +#define h5bl_set_fieldxcoords F77_NAME ( \ + h5bl_set_fieldxcoords, \ + h5bl_set_fieldxcoords_, \ + H5BL_SET_FIELDXCOORDS) +h5_int64_t +h5bl_set_fieldxcoords ( + const h5_int64_t* const fh, + const char* const field_name, + h5_float64_t* const coords, + const h5_int64_t* n_coords, + const int l_field_name + ) { + h5_file_t f = h5_filehandlefor2c (fh); + H5_API_ENTER (h5_err_t, + "fh=%p, field_name='%.*s'" + "coords=%p, n_coords=%llu", + (h5_file_p)f, + l_field_name, field_name, + coords, (long long unsigned)n_coords); + H5_API_RETURN (set_field_coords ( + f, 0, + field_name, l_field_name, + H5BLOCK_FIELD_XCOORD_NAME, sizeof(H5BLOCK_FIELD_XCOORD_NAME), + coords, *n_coords)); +} + +#define h5bl_get_fieldxcoords F77_NAME ( \ + h5bl_get_fieldxcoords, \ + h5bl_get_fieldxcoords_, \ + H5BL_GET_FIELDXCOORDS) +h5_int64_t +h5bl_get_fieldxcoords ( + const h5_int64_t* const fh, + const char* const field_name, + h5_float64_t* const coords, + const h5_int64_t* n_coords, + const int l_field_name + ) { + h5_file_t f = h5_filehandlefor2c (fh); + H5_API_ENTER (h5_err_t, + "fh=%p" + ", field_name='%.*s'" + ", coords=%p, n_coords=%llu", + (h5_file_p)f, + l_field_name, field_name, + coords, (long long unsigned)n_coords); + H5_API_RETURN (get_field_coords ( + f, 0, + field_name, l_field_name, + H5BLOCK_FIELD_XCOORD_NAME, sizeof (H5BLOCK_FIELD_XCOORD_NAME), + coords, *n_coords)); +} + +#define h5bl_set_fieldycoords F77_NAME ( \ + h5bl_set_fieldycoords, \ + h5bl_set_fieldycoords_, \ + H5BL_SET_FIELDYCOORDS) +h5_int64_t +h5bl_set_fieldycoords ( + const h5_int64_t* const fh, + const char* const field_name, + h5_float64_t* const coords, + const h5_int64_t* n_coords, + const int l_field_name + ) { + h5_file_t f = h5_filehandlefor2c (fh); + H5_API_ENTER (h5_err_t, + "fh=%p" + ", field_name='%.*s'" + ", coords=%p, n_coords=%llu", + (h5_file_p)f, + l_field_name, field_name, + coords, (long long unsigned)n_coords); + H5_API_RETURN (set_field_coords ( + f, 1, + field_name, l_field_name, + H5BLOCK_FIELD_YCOORD_NAME, sizeof (H5BLOCK_FIELD_YCOORD_NAME), + coords, *n_coords)); +} + +#define h5bl_get_fieldycoords F77_NAME ( \ + h5bl_get_fieldycoords, \ + h5bl_get_fieldycoords_, \ + H5BL_GET_FIELDyCOORDS) +h5_int64_t +h5bl_get_fieldycoords ( + const h5_int64_t* const fh, + const char* const field_name, + h5_float64_t* const coords, + const h5_int64_t* n_coords, + const int l_field_name + ) { + h5_file_t f = h5_filehandlefor2c (fh); + H5_API_ENTER (h5_err_t, + "fh=%p" + ", field_name='%.*s'" + ", coords=%p, n_coords=%llu", + (h5_file_p)f, + l_field_name, field_name, + coords, (long long unsigned)n_coords); + H5_API_RETURN (get_field_coords ( + f, 1, + field_name, l_field_name, + H5BLOCK_FIELD_YCOORD_NAME, sizeof (H5BLOCK_FIELD_YCOORD_NAME), + coords, *n_coords)); +} + + +#define h5bl_set_fieldzcoords F77_NAME ( \ + h5bl_set_fieldzcoords, \ + h5bl_set_fieldzcoords_, \ + H5BL_SET_FIELDZCOORDS) +h5_int64_t +h5bl_set_fieldzcoords ( + const h5_int64_t* const fh, + const char* const field_name, + h5_float64_t* const coords, + const h5_int64_t* n_coords, + const int l_field_name + ) { + h5_file_t f = h5_filehandlefor2c (fh); + H5_API_ENTER (h5_err_t, + "fh=%p" + ", field_name='%.*s'" + ", coords=%p, n_coords=%llu", + (h5_file_p)f, + l_field_name, field_name, + coords, (long long unsigned)n_coords); + H5_API_RETURN (set_field_coords ( + f, 2, + field_name, l_field_name, + H5BLOCK_FIELD_ZCOORD_NAME, sizeof (H5BLOCK_FIELD_ZCOORD_NAME), + coords, *n_coords)); +} + +#define h5bl_get_fieldzcoords F77_NAME ( \ + h5bl_get_fieldzcoords, \ + h5bl_get_fieldzcoords_, \ + H5BL_GET_FIELDZCOORDS) +h5_int64_t +h5bl_get_fieldzcoords ( + const h5_int64_t* const fh, + const char* const field_name, + h5_float64_t* const coords, + const h5_int64_t* n_coords, + const int l_field_name + ) { + h5_file_t f = h5_filehandlefor2c (fh); + H5_API_ENTER (h5_err_t, + "fh=%p" + ", field_name='%.*s'" + "coords=%p, n_coords=%llu", + (h5_file_p)f, + l_field_name, field_name, + coords, (long long unsigned)n_coords); + H5_API_RETURN (get_field_coords ( + f, 2, + field_name, l_field_name, + H5BLOCK_FIELD_ZCOORD_NAME, sizeof (H5BLOCK_FIELD_ZCOORD_NAME), + coords, *n_coords)); +} diff --git a/src/Fortran/H5Block_model.c b/src/Fortran/H5Block_model.c index fcf089b..ec40e62 100755 --- a/src/Fortran/H5Block_model.c +++ b/src/Fortran/H5Block_model.c @@ -11,6 +11,38 @@ #include "h5core/h5_debug.h" #include "h5core/h5b_model.h" +#define h5bl_hasfielddata F77_NAME ( \ + h5bl_hasfielddata, \ + h5bl_hasdata_, \ + H5BL_HASFIELDDATA ) +h5_int64_t +h5bl_hasfielddata ( + const h5_int64_t* const fh + ) { + h5_file_t f = h5_filehandlefor2c (fh); + H5_API_ENTER (h5_int64_t, + "fh=%p", + (h5_file_p)f); + H5_API_RETURN (h5b_has_field_data ( f )); +} + + +#define h5bl_3d_hasview F77_NAME ( \ + h5bl_hasview, \ + h5bl_hasview_, \ + H5BL_HASVIEW ) +h5_int64_t +h5bl_3d_hasview ( + const h5_int64_t* const fh + ) { + h5_file_t f = h5_filehandlefor2c (fh); + H5_API_ENTER (h5_int64_t, + "fh=%p", + (h5_file_p)f); + H5_API_RETURN (h5b_3d_has_view ( f )); +} + + #define h5bl_3d_setview F77_NAME ( \ h5bl_3d_setview, \ h5bl_3d_setview_, \ @@ -120,21 +152,6 @@ h5bl_3d_getreducedview ( H5_API_RETURN (H5_SUCCESS); } -#define h5bl_3d_hasview F77_NAME ( \ - h5bl_hasview, \ - h5bl_hasview_, \ - H5BL_HASVIEW ) -h5_int64_t -h5bl_3d_hasview ( - const h5_int64_t* const fh - ) { - h5_file_t f = h5_filehandlefor2c (fh); - H5_API_ENTER (h5_int64_t, - "fh=%p", - (h5_file_p)f); - H5_API_RETURN (h5b_3d_has_view ( f )); -} - #define h5bl_3d_setchunk F77_NAME ( \ h5bl_3d_setchunk, \ h5bl_3d_setchunk_, \ @@ -149,8 +166,108 @@ h5bl_3d_setchunk ( h5_file_t f = h5_filehandlefor2c (fh); H5_API_ENTER (h5_int64_t, "fh=%p, i=%lld, j=%lld, k=%lld", - (h5_file_p)f, (long long)i, (long long)j, (long long)k); - H5_API_RETURN(h5b_3d_set_chunk ( f, *i, *j, *k )); + (h5_file_p)f, (long long)*i, (long long)*j, (long long)*k); + H5_API_RETURN(h5b_3d_set_chunk (f, *i, *j, *k)); +} + +#define h5bl_3d_getchunk F77_NAME ( \ + h5bl_3d_getchunk, \ + h5bl_3d_getchunk_, \ + H5BL_3D_GETCHUNK ) +h5_int64_t +h5bl_3d_getchunk ( + const h5_int64_t* const fh, + const char* const field_name, + h5_int64_t* const i, + h5_int64_t* const j, + h5_int64_t* const k, + const int l_field_name + ) { + h5_file_t f = h5_filehandlefor2c (fh); + H5_API_ENTER (h5_int64_t, + "fh=%p, i=%p, j=%p, k=%p", + (h5_file_p)f, i, j, k); + char *field_name2 = h5_strdupfor2c (field_name, l_field_name); + h5_int64_t h5err = h5b_3d_get_chunk (f, field_name2, (h5_size_t*)i, (h5_size_t*)j, (h5_size_t*)k); + free (field_name2); + H5_API_RETURN (h5err); +} + + +#ifdef PARALLEL_IO +#define h5bl_3d_setgrid F77_NAME ( \ + h5bl_3d_setgrid, \ + h5bl_3d_setgrid_, \ + h5bl_3d_setgrid) +h5_int64_t +h5bl_3d_setgrid ( + const h5_int64_t* const fh, + const h5_int64_t* const i, + const h5_int64_t* const j, + const h5_int64_t* const k + ) { + h5_file_t f = h5_filehandlefor2c (fh); + H5_API_ENTER (h5_int64_t, + "fh=%p, i=%lld, j=%lld, k=%lld", + (h5_file_p)f, (long long)*i, (long long)*j, (long long)*k); + H5_API_RETURN(h5b_3d_set_grid (f, *i, *j, *k)); +} + +#define h5bl_3d_getgrid F77_NAME ( \ + h5bl_3d_getgrid, \ + h5bl_3d_getgrid_, \ + H5BL_3D_GETGRID) +h5_int64_t +h5bl_3d_getgrid ( + const h5_int64_t* const fh, + const h5_int64_t* const proc, + h5_int64_t* const i, + h5_int64_t* const j, + h5_int64_t* const k + ) { + h5_file_t f = h5_filehandlefor2c (fh); + H5_API_ENTER (h5_int64_t, + "fh=%p, proc=%lld, i=%p, j=%p, k=%p", + (h5_file_p)f, (long long)proc, i, j, k); + H5_API_RETURN(h5b_3d_get_grid_coords (f, (int)*proc, i, j, k)); +} + +#define h5bl_3d_setdims F77_NAME ( \ + h5bl_3d_setdims, \ + h5bl_3d_setdims_, \ + H5BL_3D_SETDIMS) +h5_int64_t +h5bl_3d_setdims ( + const h5_int64_t* const fh, + const h5_int64_t* const i, + const h5_int64_t* const j, + const h5_int64_t* const k + ) { + h5_file_t f = h5_filehandlefor2c (fh); + H5_API_ENTER (h5_int64_t, + "fh=%p, i=%lld, j=%lld, k=%lld", + (h5_file_p)f, (long long)*i, (long long)*j, (long long)*k); + H5_API_RETURN(h5b_3d_set_dims (f, *i, *j, *k)); +} + +#endif + +#define h5bl_3d_sethalo F77_NAME ( \ + h5bl_3d_sethalo, \ + h5bl_3d_sethalo_, \ + H5BL_3D_SETHALO) +h5_int64_t +h5bl_3d_sethalo ( + const h5_int64_t* const fh, + const h5_int64_t* const i, + const h5_int64_t* const j, + const h5_int64_t* const k + ) { + h5_file_t f = h5_filehandlefor2c (fh); + H5_API_ENTER (h5_int64_t, + "fh=%p, i=%lld, j=%lld, k=%lld", + (h5_file_p)f, (long long)*i, (long long)*j, (long long)*k); + H5_API_RETURN(h5b_3d_set_halo (f, *i, *j, *k)); } #define h5bl_getnumfields F77_NAME ( \ @@ -161,7 +278,6 @@ h5_int64_t h5bl_getnumfields ( const h5_int64_t* const fh ) { - h5_file_t f = h5_filehandlefor2c (fh); H5_API_ENTER (h5_int64_t, "fh=%p", @@ -198,3 +314,31 @@ h5bl_getfieldinfo ( H5_API_RETURN(herr); } +#define h5bl_getfieldinfobyname F77_NAME ( \ + h5bl_getfieldinfobyname, \ + h5bl_getfieldinfobyname_, \ + H5BL_GETFIELDINFOBYNAME) +h5_int64_t +h5bl_getfieldinfobyname ( + const h5_int64_t* const fh, + const char* const field_name, + h5_size_t* const field_rank, + h5_size_t* const field_dims, + h5_size_t* const elem_rank, + h5_int64_t* const type, + const int l_field_name + ) { + h5_file_t f = h5_filehandlefor2c (fh); + H5_API_ENTER (h5_int64_t, + "fh=%p" + ", field_name=%*s," + ", field_rank=%p, field_dims=%p, elem_rank=%p, type=%p", + (h5_file_p)f, l_field_name, field_name, + field_rank, field_dims, elem_rank, type); + char *field_name2 = h5_strdupfor2c (field_name, l_field_name); + h5_int64_t herr = h5b_get_field_info_by_name ( + f, field_name2, + field_rank, field_dims, elem_rank, type ); + free (field_name2); + H5_API_RETURN(herr); +} diff --git a/src/Fortran/H5Part_model.c b/src/Fortran/H5Part_model.c index 6dfe367..e2562c7 100755 --- a/src/Fortran/H5Part_model.c +++ b/src/Fortran/H5Part_model.c @@ -13,131 +13,8 @@ #include "h5core/h5_syscall.h" -/*==============Reading Data Characteristics============*/ - -#define h5pt_getndatasets F77_NAME ( \ - h5pt_getndatasets, \ - h5pt_getndatasets_, \ - H5PT_GETNDATASETS ) -h5_int64_t -h5pt_getndatasets ( - const h5_int64_t* const fh - ) { - h5_file_t f = h5_filehandlefor2c (fh); - H5_API_ENTER (h5_int64_t, "fh=%p", (h5_file_p)f); - H5_API_RETURN(h5u_get_num_datasets (f)); -} - -#define h5pt_getnpoints F77_NAME ( \ - h5pt_getnpoints, \ - h5pt_getnpoints_, \ - H5PT_GETNPOINTS ) -h5_int64_t -h5pt_getnpoints ( - const h5_int64_t* const fh - ) { - h5_file_t f = h5_filehandlefor2c (fh); - H5_API_ENTER (h5_int64_t, "fh=%p", (h5_file_p)f); - H5_API_RETURN (h5u_get_num_particles (f)); -} - -#define h5pt_getdatasetname F77_NAME ( \ - h5pt_getdatasetname, \ - h5pt_getdatasetname_, \ - H5PT_GETDATASETNAME ) -h5_int64_t -h5pt_getdatasetname ( - const h5_int64_t* const fh, - const h5_int64_t* index, - char* name, - const int l_name - ) { - h5_file_t f = h5_filehandlefor2c (fh); - H5_API_ENTER (h5_int64_t, - "fh=%p, index=%lld, name='%s', l_name=%d", - (h5_file_p)f, (long long)*index, name, l_name); - h5_int64_t herr = h5u_get_dataset_info ( - f, *index - 1, name, l_name, NULL, NULL ); - h5_strc2for (name, l_name); - H5_API_RETURN (herr); -} - -#define h5pt_getdatasetinfo F77_NAME( \ - h5pt_getdatasetinfo, \ - h5pt_getdatasetinfo_, \ - H5PT_GETDATASETINFO) -h5_int64_t -h5pt_getdatasetinfo ( - const h5_int64_t* const fh, - const h5_int64_t* dataset_idx, - char* dataset_name, - h5_int64_t* dataset_type, - h5_int64_t* dataset_nelem, - const int l_dataset_name - ) { - h5_file_t f = h5_filehandlefor2c (fh); - H5_API_ENTER (h5_int64_t, - "fh=%p, " - "dataset_idx=%lld, " - "dataset_name=%p, " - "dataset_type=%p, " - "dataset_nelem=%p", - (h5_file_p)f, - (long long)*dataset_idx, - dataset_name, dataset_type, dataset_nelem); - h5_int64_t h5err = h5u_get_dataset_info ( - f, - *dataset_idx - 1, - dataset_name, l_dataset_name, - dataset_type, - (h5_size_t*)dataset_nelem); - h5_strc2for (dataset_name, l_dataset_name); - convert_type2for (dataset_type); - H5_API_RETURN (h5err); -} - /*=============Setting and getting views================*/ -#define h5pt_setview F77_NAME ( \ - h5pt_setview, \ - h5pt_setview_, \ - H5PT_SETVIEW ) -h5_int64_t -h5pt_setview ( - const h5_int64_t* const fh, - const h5_int64_t* const start, - const h5_int64_t* const end - ) { - h5_file_t f = h5_filehandlefor2c (fh); - H5_API_ENTER (h5_int64_t, - "fh=%p, start=%lld, end=%lld", - (h5_file_p)f, (long long)*start, (long long)*end); - H5_API_RETURN (h5u_set_view (f, (*start)-1, (*end)-1)); -} - -#define h5pt_setview_indices F77_NAME ( \ - h5pt_setview_indices, \ - h5pt_setview_indices_, \ - H5PT_SETVIEW_INDICES ) -h5_int64_t -h5pt_setview_indices ( - const h5_int64_t* const fh, - const h5_int64_t* const indices, - const h5_int64_t* const nelem - ) { - h5_file_t f = h5_filehandlefor2c (fh); - H5_API_ENTER (h5_int64_t, - "fh=%p, indices=%p, nelem=%lld", - (h5_file_p)f, indices, (long long)*nelem); - h5_size_t* findices; - TRY (findices = h5_calloc (*nelem, sizeof (*indices))); - for (size_t i = 0; i < *nelem; i++) - findices[i] = indices[i] - 1; - TRY (h5u_set_view_indices (f, findices, *nelem)); - TRY (h5_free (findices)); - H5_API_RETURN (H5_SUCCESS); -} - #define h5pt_setnpoints F77_NAME ( \ h5pt_setnpoints, \ h5pt_setnpoints_, \ @@ -171,6 +48,64 @@ h5pt_setnpoints_strided ( H5_API_RETURN (h5u_set_num_particles (f, *npoints, *stride)); } + + +#define h5pt_setview F77_NAME ( \ + h5pt_setview, \ + h5pt_setview_, \ + H5PT_SETVIEW ) +h5_int64_t +h5pt_setview ( + const h5_int64_t* const fh, + const h5_int64_t* const start, + const h5_int64_t* const end + ) { + h5_file_t f = h5_filehandlefor2c (fh); + H5_API_ENTER (h5_int64_t, + "fh=%p, start=%lld, end=%lld", + (h5_file_p)f, (long long)*start, (long long)*end); + H5_API_RETURN (h5u_set_view (f, (*start)-1, (*end)-1)); +} + +#define h5pt_setview_indices F77_NAME( \ + h5pt_setview_indices, \ + h5pt_setview_indices_, \ + H5PT_SETVIEW_INDICES ) +h5_int64_t +h5pt_setview_indices ( + const h5_int64_t* const fh, + const h5_int64_t* const indices, + const h5_int64_t* const nelem + ) { + h5_file_t f = h5_filehandlefor2c (fh); + H5_API_ENTER (h5_int64_t, + "fh=%p, indices=%p, nelem=%lld", + (h5_file_p)f, indices, (long long)*nelem); + h5_size_t* findices; + TRY (findices = h5_calloc (*nelem, sizeof (*indices))); + for (size_t i = 0; i < *nelem; i++) + findices[i] = indices[i] - 1; + TRY (h5u_set_view_indices (f, findices, *nelem)); + TRY (h5_free (findices)); + H5_API_RETURN (H5_SUCCESS); +} + +#define h5pt_setcanonicalview F77_NAME ( \ + h5pt_setcanonicalview, \ + h5pt_setcanonicalview_, \ + H5PT_SETCANONICALVIEW) +h5_int64_t +h5pt_setcanonicalview ( + const h5_int64_t* const fh + ) { + h5_file_t f = h5_filehandlefor2c (fh); + H5_API_ENTER (h5_int64_t, + "fh=%p", + (h5_file_p)f); + H5_API_RETURN (h5u_set_canonical_view (f)); +} + + #define h5pt_resetview F77_NAME ( \ h5pt_resetview, \ h5pt_resetview_, \ @@ -220,3 +155,104 @@ h5pt_getview ( *end += 1; H5_API_RETURN (H5_SUCCESS); } + +/*==============Reading Data Characteristics============*/ + +#define h5pt_getndatasets F77_NAME ( \ + h5pt_getndatasets, \ + h5pt_getndatasets_, \ + H5PT_GETNDATASETS ) +h5_int64_t +h5pt_getndatasets ( + const h5_int64_t* const fh + ) { + h5_file_t f = h5_filehandlefor2c (fh); + H5_API_ENTER (h5_int64_t, "fh=%p", (h5_file_p)f); + H5_API_RETURN(h5u_get_num_datasets (f)); +} + +#define h5pt_getnpoints F77_NAME ( \ + h5pt_getnpoints, \ + h5pt_getnpoints_, \ + H5PT_GETNPOINTS ) +h5_int64_t +h5pt_getnpoints ( + const h5_int64_t* const fh + ) { + h5_file_t f = h5_filehandlefor2c (fh); + H5_API_ENTER (h5_int64_t, "fh=%p", (h5_file_p)f); + H5_API_RETURN (h5u_get_num_particles (f)); +} + +#define h5pt_getdatasetname F77_NAME ( \ + h5pt_getdatasetname, \ + h5pt_getdatasetname_, \ + H5PT_GETDATASETNAME ) +h5_int64_t +h5pt_getdatasetname ( + const h5_int64_t* const fh, + const h5_int64_t* index, + char* name, + const int l_name + ) { + h5_file_t f = h5_filehandlefor2c (fh); + H5_API_ENTER (h5_int64_t, + "fh=%p, index=%lld, name='%s', l_name=%d", + (h5_file_p)f, (long long)*index, name, l_name); + h5_int64_t herr = h5u_get_dataset_info ( + f, *index - 1, name, l_name, NULL, NULL ); + h5_strc2for (name, l_name); + H5_API_RETURN (herr); +} + +#define h5pt_getdatasetinfo F77_NAME ( \ + h5pt_getdatasetinfo, \ + h5pt_getdatasetinfo_, \ + H5PT_GETDATASETINFO) +h5_int64_t +h5pt_getdatasetinfo ( + const h5_int64_t* const fh, + const h5_int64_t* dataset_idx, + char* dataset_name, + h5_int64_t* dataset_type, + h5_int64_t* dataset_nelem, + const int l_dataset_name + ) { + h5_file_t f = h5_filehandlefor2c (fh); + H5_API_ENTER (h5_int64_t, + "fh=%p, " + "dataset_idx=%lld, " + "dataset_name=%p, " + "dataset_type=%p, " + "dataset_nelem=%p", + (h5_file_p)f, + (long long)*dataset_idx, + dataset_name, dataset_type, dataset_nelem); + h5_int64_t h5err = h5u_get_dataset_info ( + f, + *dataset_idx - 1, + dataset_name, l_dataset_name, + dataset_type, + (h5_size_t*)dataset_nelem); + h5_strc2for (dataset_name, l_dataset_name); + convert_type2for (dataset_type); + H5_API_RETURN (h5err); +} + +/*===================== misc =====================*/ + +#define h5pt_setchunksize F77_NAME ( \ + h5pt_setchunksize, \ + h5pt_setchunksize_, \ + H5PT_SETCHUNKSIZE ) +h5_int64_t +h5pt_setchunksize ( + const h5_int64_t* const fh, + const h5_int64_t* const size + ) { + h5_file_t f = h5_filehandlefor2c (fh); + H5_API_ENTER (h5_int64_t, + "fh=%p, size=%lld", + (h5_file_p)f, (long long)*size); + H5_API_RETURN (h5u_set_chunk (f, *size)); +} diff --git a/src/Fortran/H5_attribs.c b/src/Fortran/H5_attribs.c index 00a9b1c..c0c8714 100644 --- a/src/Fortran/H5_attribs.c +++ b/src/Fortran/H5_attribs.c @@ -18,6 +18,7 @@ | |_| | |/ _ \ / _` | __| __| '__| | '_ \| | | | __/ _ \/ __| | _| | | __/ | (_| | |_| |_| | | | |_) | |_| | || __/\__ \ |_| |_|_|\___| \__,_|\__|\__|_| |_|_.__/ \__,_|\__\___||___/ + __ _ _ _ ___ _ __ _ _ / _` | | | |/ _ \ '__| | | | | (_| | |_| | __/ | | |_| | @@ -103,6 +104,12 @@ h5_getfileattribinfo_by_name ( } /* + __ _ _ _ _ _ _ _ + / _(_) | ___ __ _| |_| |_ _ __(_) |__ _ _| |_ ___ ___ + | |_| | |/ _ \ / _` | __| __| '__| | '_ \| | | | __/ _ \/ __| + | _| | | __/ | (_| | |_| |_| | | | |_) | |_| | || __/\__ \ + |_| |_|_|\___| \__,_|\__|\__|_| |_|_.__/ \__,_|\__\___||___/ + _ __ (_) / /__ | | / / _ \ @@ -138,14 +145,6 @@ read_file_attrib ( return herr; } -/* - _ _ - ___| |_ _ __(_)_ __ __ _ - / __| __| '__| | '_ \ / _` | - \__ \ |_| | | | | | | (_| | - |___/\__|_| |_|_| |_|\__, | - |___/ -*/ #define h5_writefileattrib_string F77_NAME ( \ h5_writefileattrib_string, \ h5_writefileattrib_string_, \ @@ -377,7 +376,13 @@ h5_readfileattrib_i4 ( \__ \ || __/ |_) | | (_| | |_| |_| | | | |_) | |_| | || __/\__ \ |___/\__\___| .__/ \__,_|\__|\__|_| |_|_.__/ \__,_|\__\___||___/ |_| - */ + + __ _ _ _ ___ _ __ _ _ + / _` | | | |/ _ \ '__| | | | + | (_| | |_| | __/ | | |_| | + \__, |\__,_|\___|_| \__, | + |_| |___/ +*/ #define h5_getnstepattribs F77_NAME( \ h5_getnstepattribs, \ h5_getnstepattribs_, \ @@ -457,6 +462,21 @@ h5_getstepattribinfo_by_name ( H5_API_RETURN (h5err); } +/* + _ _ _ _ _ _ + ___| |_ ___ _ __ __ _| |_| |_ _ __(_) |__ _ _| |_ ___ ___ + / __| __/ _ \ '_ \ / _` | __| __| '__| | '_ \| | | | __/ _ \/ __| + \__ \ || __/ |_) | | (_| | |_| |_| | | | |_) | |_| | || __/\__ \ + |___/\__\___| .__/ \__,_|\__|\__|_| |_|_.__/ \__,_|\__\___||___/ + |_| + + _ __ + (_) / /__ + | | / / _ \ + | |/ / (_) | + |_/_/ \___/ +*/ + static inline h5_int64_t write_step_attrib ( const h5_file_t fh, diff --git a/src/Fortran/Makefile.am b/src/Fortran/Makefile.am index 2d03c26..0f3f379 100644 --- a/src/Fortran/Makefile.am +++ b/src/Fortran/Makefile.am @@ -8,9 +8,9 @@ F90_FILES = \ $(top_srcdir)/src/include/H5_const.f90 \ $(top_srcdir)/src/include/H5_attribs.f90 \ $(top_srcdir)/src/include/H5_model.f90 \ - $(top_srcdir)/src/include/H5Part.f90 \ + $(top_srcdir)/src/include/H5Part_model.f90 \ $(top_srcdir)/src/include/H5Part_io.f90 \ - $(top_srcdir)/src/include/H5Block.f90 \ + $(top_srcdir)/src/include/H5Block_model.f90 \ $(top_srcdir)/src/include/H5Block_attribs.f90 \ $(top_srcdir)/src/include/H5Block_io.f90 @@ -34,9 +34,9 @@ libH5hutF_la_SOURCES = \ H5.c \ H5_attribs.c \ H5_model.c \ - H5Part.c \ + H5Part_model.c \ H5Part_io.c \ - H5Block.c \ + H5Block_model.c \ H5Block_attribs.c \ H5Block_io.c diff --git a/src/include/H5.f90 b/src/include/H5.f90 index d764e3f..5823f24 100644 --- a/src/include/H5.f90 +++ b/src/include/H5.f90 @@ -1,5 +1,5 @@ ! -! Copyright (c) 2006-2013, The Regents of the University of California, +! Copyright (c) 2006-2014, The Regents of the University of California, ! through Lawrence Berkeley National Laboratory (subject to receipt of any ! required approvals from the U.S. Dept. of Energy) and the Paul Scherrer ! Institut (Switzerland). All rights reserved.! @@ -171,4 +171,12 @@ SUBROUTINE h5_abort_on_error () END SUBROUTINE h5_abort_on_error + !> + !! \ingroup h5hut_error_f + !! Get error number. + !! \return 0 on success or error code + !< + SUBROUTINE h5_get_error_number () + END SUBROUTINE h5_get_error_number + END INTERFACE diff --git a/src/include/H5Block_attribs.f90 b/src/include/H5Block_attribs.f90 index 90350c7..6e4e397 100644 --- a/src/include/H5Block_attribs.f90 +++ b/src/include/H5Block_attribs.f90 @@ -255,5 +255,83 @@ REAL*8, INTENT(IN) :: z END FUNCTION h5bl_3d_set_field_origin + ! __ _ _ _ _ + ! / _(_) ___| | __| | ___ ___ ___ _ __ __| |___ + ! | |_| |/ _ \ |/ _` | / __/ _ \ / _ \| '__/ _` / __| + ! | _| | __/ | (_| | | (_| (_) | (_) | | | (_| \__ \ + ! |_| |_|\___|_|\__,_| \___\___/ \___/|_| \__,_|___/ + + !> + !! \ingroup h5block_attrib_f + !! See \ref H5Block3dSetFieldXCoords + !! \return 0 on success -1 on error + !< + INTEGER*8 FUNCTION h5bl_set_fieldxcoords (filehandle, field_name, coords, n_coords) + INTEGER*8, INTENT(IN) :: filehandle + CHARACTER(LEN=*), INTENT(IN) :: field_name + REAL*8, INTENT(IN) :: coords(*) + INTEGER*8, INTENT(IN) :: n_coords + END FUNCTION h5bl_set_fieldxcoords + + !> + !! \ingroup h5block_attrib_f + !! See \ref H5Block3dGetFieldXCoords + !! \return 0 on success -1 on error + !< + INTEGER*8 FUNCTION h5bl_get_fieldxcoords (filehandle, field_name, coords, n_coords) + INTEGER*8, INTENT(IN) :: filehandle + CHARACTER(LEN=*), INTENT(IN) :: field_name + REAL*8, INTENT(OUT) :: coords(*) + INTEGER*8, INTENT(IN) :: n_coords + END FUNCTION h5bl_get_fieldxcoords + + !> + !! \ingroup h5block_attrib_f + !! See \ref H5Block3dSetFieldYCoords + !! \return 0 on success -1 on error + !< + INTEGER*8 FUNCTION h5bl_set_fieldycoords (filehandle, field_name, coords, n_coords) + INTEGER*8, INTENT(IN) :: filehandle + CHARACTER(LEN=*), INTENT(IN) :: field_name + REAL*8, INTENT(IN) :: coords(*) + INTEGER*8, INTENT(IN) :: n_coords + END FUNCTION h5bl_set_fieldycoords + + !> + !! \ingroup h5block_attrib_f + !! See \ref H5Block3dGetFieldYCoords + !! \return 0 on success -1 on error + !< + INTEGER*8 FUNCTION h5bl_get_fieldycoords (filehandle, field_name, coords, n_coords) + INTEGER*8, INTENT(IN) :: filehandle + CHARACTER(LEN=*), INTENT(IN) :: field_name + REAL*8, INTENT(OUT) :: coords(*) + INTEGER*8, INTENT(IN) :: n_coords + END FUNCTION h5bl_get_fieldycoords + + !> + !! \ingroup h5block_attrib_f + !! See \ref H5Block3dSetFieldZCoords + !! \return 0 on success -1 on error + !< + INTEGER*8 FUNCTION h5bl_set_fieldzcoords (filehandle, field_name, coords, n_coords) + INTEGER*8, INTENT(IN) :: filehandle + CHARACTER(LEN=*), INTENT(IN) :: field_name + REAL*8, INTENT(IN) :: coords(*) + INTEGER*8, INTENT(IN) :: n_coords + END FUNCTION h5bl_set_fieldzcoords + + !> + !! \ingroup h5block_attrib_f + !! See \ref H5Block3dGetFieldZCoords + !! \return 0 on success -1 on error + !< + INTEGER*8 FUNCTION h5bl_get_fieldzcoords (filehandle, field_name, coords, n_coords) + INTEGER*8, INTENT(IN) :: filehandle + CHARACTER(LEN=*), INTENT(IN) :: field_name + REAL*8, INTENT(OUT) :: coords(*) + INTEGER*8, INTENT(IN) :: n_coords + END FUNCTION h5bl_get_fieldzcoords + !> @} END INTERFACE diff --git a/src/include/H5Part_model.f90 b/src/include/H5Part_model.f90 index 1a56a7f..bd44a43 100644 --- a/src/include/H5Part_model.f90 +++ b/src/include/H5Part_model.f90 @@ -30,6 +30,73 @@ INTEGER*8, INTENT(IN) :: stride !< the stride value (e.g. the number of fields in the particle data array) END FUNCTION h5pt_setnpoints_strided + + !> + !! \ingroup h5part_model_f + !! + !! 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 h5pt_setview + + !> + !! \ingroup h5part_model_f + !! + !! 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 h5pt_setview_indices + + !> + !! \ingroup h5part_model_f + !! + !! See \ref H5PartSetCanonicalView + !! \return 0 on success or error code + !< + INTEGER*8 FUNCTION h5pt_setcanonicalview (filehandle) + INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open + END FUNCTION h5pt_setcanonicalview + + !> + !! \ingroup h5part_model_f + !! + !! 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 h5pt_resetview + + !> + !! \ingroup h5part_model_f + !! + !! 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 h5pt_hasview + + !> + !! \ingroup h5part_model_f + !! + !! 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 h5pt_getview + !> !! \ingroup h5part_model_f !! @@ -79,57 +146,11 @@ !> !! \ingroup h5part_model_f !! - !! See \ref H5PartSetView - !! \return 0 on success or error code + !! See \ref H5PartSetChunkSize + !! \return 0 on success or -2 on error !< - 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 h5pt_setview - - !> - !! \ingroup h5part_model_f - !! - !! 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 h5pt_setview_indices - - !> - !! \ingroup h5part_model_f - !! - !! 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 h5pt_resetview - - !> - !! \ingroup h5part_model_f - !! - !! 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 h5pt_hasview - - !> - !! \ingroup h5part_model_f - !! - !! 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 h5pt_getview + INTEGER*8 FUNCTION h5pt_getnpoints (filehandle) + INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open + END FUNCTION h5pt_getnpoints END INTERFACE