summaryrefslogtreecommitdiffstats
path: root/fortran/src
diff options
context:
space:
mode:
authorScot Breitenfeld <brtnfld@hdfgroup.org>2022-10-11 12:25:05 (GMT)
committerGitHub <noreply@github.com>2022-10-11 12:25:05 (GMT)
commit64e69d9291e58f56152f91e58b847deb2c172e26 (patch)
tree7daebcbec09e89f282ff9896c9877b41608f02bc /fortran/src
parent306db409d44cccbeaff1cd5acb1a99173ac8b185 (diff)
downloadhdf5-64e69d9291e58f56152f91e58b847deb2c172e26.zip
hdf5-64e69d9291e58f56152f91e58b847deb2c172e26.tar.gz
hdf5-64e69d9291e58f56152f91e58b847deb2c172e26.tar.bz2
Implemented C matching (and general) H5Dfill Fortran wrappers (#2152)
Diffstat (limited to 'fortran/src')
-rw-r--r--fortran/src/H5Df.c45
-rw-r--r--fortran/src/H5Dff.F9095
-rw-r--r--fortran/src/H5f90proto.h2
-rw-r--r--fortran/src/hdf5_fortrandll.def.in6
4 files changed, 79 insertions, 69 deletions
diff --git a/fortran/src/H5Df.c b/fortran/src/H5Df.c
index ba3e5d4..75dd014 100644
--- a/fortran/src/H5Df.c
+++ b/fortran/src/H5Df.c
@@ -1047,51 +1047,6 @@ DONE:
return ret_value;
}
-/****if* H5Df/h5dfill_c
- * NAME
- * h5dfill_c
- * PURPOSE
- * Call H5Dfill to fill memory buffer with a fill value
- * INPUTS
- * fill_value - fill value
- * fill_type_id - fill value datatype identifier
- * space_id - memory space selection identifier
- * buf - memory buffer to fill
- * mem_type_id - memory buffer dtatype identifier
- * RETURNS
- * 0 on success, -1 on failure
- * AUTHOR
- * Elena Pourmal
- * Wednesday, March 12, 2003
- * HISTORY
- *
- * SOURCE
- */
-int_f
-h5dfill_c(void *fill_value, hid_t_f *fill_type_id, hid_t_f *space_id, void *buf, hid_t_f *mem_type_id)
-/******/
-{
- int ret_value = -1;
- herr_t ret;
- hid_t c_fill_type_id;
- hid_t c_mem_type_id;
- hid_t c_space_id;
-
- c_fill_type_id = (hid_t)*fill_type_id;
- c_mem_type_id = (hid_t)*mem_type_id;
- c_space_id = (hid_t)*space_id;
-
- /*
- * Call H5Dfill function.
- */
- ret = H5Dfill(fill_value, c_fill_type_id, buf, c_mem_type_id, c_space_id);
-
- if (ret < 0)
- return ret_value;
- ret_value = 0;
- return ret_value;
-}
-
/****if* H5Df/h5dget_space_status_c
* NAME
* h5dget_space_status_c
diff --git a/fortran/src/H5Dff.F90 b/fortran/src/H5Dff.F90
index 0da0092..1a2c9f3 100644
--- a/fortran/src/H5Dff.F90
+++ b/fortran/src/H5Dff.F90
@@ -93,7 +93,7 @@ MODULE H5D
PRIVATE h5dwrite_vl_integer, h5dwrite_vl_real, h5dwrite_vl_string
PRIVATE h5dwrite_reference_obj, h5dwrite_reference_dsetreg, h5dwrite_char_scalar, h5dwrite_ptr
PRIVATE h5dread_reference_obj, h5dread_reference_dsetreg, h5dread_char_scalar, h5dread_ptr
- PRIVATE h5dfill_integer, h5dfill_c_float, h5dfill_c_double, h5dfill_char
+ PRIVATE h5dfill_integer, h5dfill_c_float, h5dfill_c_double, h5dfill_char, h5dfill_ptr
#if H5_FORTRAN_C_LONG_DOUBLE_IS_UNIQUE!=0
PRIVATE h5dfill_c_long_double
#endif
@@ -183,6 +183,7 @@ MODULE H5D
MODULE PROCEDURE h5dfill_c_long_double
#endif
MODULE PROCEDURE h5dfill_char
+ MODULE PROCEDURE h5dfill_ptr
END INTERFACE
! Interface for the function used to pass the C pointer of the buffer
@@ -1220,6 +1221,8 @@ CONTAINS
!! Only INTEGER, CHARACTER, REAL and DOUBLE PRECISION datatypes of the fillvalues and buffers are supported.
!! Buffer and fillvalue are assumed to have the same datatype. Only one-dimesional buffers are supported.
!!
+!! \attention \fortran_obsolete
+!!
!! \param fill_value Fill value.
!! \param space_id Identifier of the memory datatype.
!! \param buf Buffer to receive data read from file.
@@ -1233,6 +1236,31 @@ CONTAINS
TYPE(TYPE), INTENT(OUT), DIMENSION(*) :: buf
INTEGER, INTENT(OUT) :: hdferr
END SUBROUTINE h5dfill_f
+!>
+!! \ingroup FH5D
+!!
+!! \brief Fills dataspace elements with a fill value in a memory buffer.
+!!
+!! \attention \fortran_approved
+!!
+!! \param fill_value Pointer to the fill value to be used.
+!! \param fill_type_id Fill value datatype identifier,
+!! \param buf Pointer to the memory buffer containing the selection to be filled.
+!! \param buf_type_id Datatype of dataspace elements to be filled.
+!! \param space_id Dataspace identifier.
+!! \param hdferr \fortran_error
+!!
+!! See C API: @ref herr_t H5Dfill(const void *fill, hid_t fill_type_id, void *buf, hid_t buf_type_id, hid_t space_id);
+!!
+ SUBROUTINE h5dfill_f(fill_value, fill_type_id, buf, buf_type_id, space_id, hdferr)
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
+ IMPLICIT NONE
+ TYPE(C_PTR) :: fill_value
+ INTEGER(HID_T), INTENT(IN) :: fill_type_id
+ TYPE(C_PTR) :: buf
+ INTEGER(HID_T), INTENT(IN) :: buf_type_id
+ INTEGER(HID_T), INTENT(IN) :: space_id
+ END SUBROUTINE h5dfill_f
#else
@@ -1587,12 +1615,39 @@ CONTAINS
END SUBROUTINE h5dread_ptr
+ SUBROUTINE h5dfill_ptr(fill_value, fill_type_id, buf, buf_type_id, space_id, hdferr)
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
+ IMPLICIT NONE
+ TYPE(C_PTR) :: fill_value
+ INTEGER(HID_T), INTENT(IN) :: fill_type_id
+ TYPE(C_PTR) :: buf
+ INTEGER(HID_T), INTENT(IN) :: buf_type_id
+ INTEGER(HID_T), INTENT(IN) :: space_id
+ INTEGER, INTENT(OUT) :: hdferr
+
+ INTERFACE
+ INTEGER FUNCTION h5dfill(fill_value, fill_type_id, buf, buf_type_id, space_id) &
+ BIND(C,NAME='H5Dfill')
+ IMPORT :: HID_T, C_PTR
+ IMPLICIT NONE
+ TYPE(C_PTR) , VALUE :: fill_value
+ INTEGER(HID_T), VALUE :: fill_type_id
+ TYPE(C_PTR) , VALUE :: buf
+ INTEGER(HID_T), VALUE :: buf_type_id
+ INTEGER(HID_T), VALUE :: space_id
+ END FUNCTION h5dfill
+ END INTERFACE
+
+ hdferr = INT(h5dfill(fill_value, fill_type_id, buf, buf_type_id, space_id))
+
+ END SUBROUTINE h5dfill_ptr
+
SUBROUTINE h5dfill_integer(fill_value, space_id, buf, hdferr)
USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
IMPLICIT NONE
INTEGER, INTENT(IN), TARGET :: fill_value ! Fill value
INTEGER(HID_T), INTENT(IN) :: space_id ! Memory dataspace selection identifier
- INTEGER, INTENT(IN), DIMENSION(*), TARGET :: buf ! Memory buffer to fill in
+ INTEGER, INTENT(OUT), DIMENSION(*), TARGET :: buf ! Memory buffer to fill in
INTEGER, INTENT(OUT) :: hdferr ! Error code
INTEGER(HID_T) :: fill_type_id ! Fill value datatype identifier
@@ -1607,15 +1662,14 @@ CONTAINS
fill_type_id = H5T_NATIVE_INTEGER
mem_type_id = H5T_NATIVE_INTEGER
- hdferr = h5dfill_c(f_ptr_fill_value, fill_type_id, space_id, &
- f_ptr_buf, mem_type_id)
+ CALL h5dfill_ptr(f_ptr_fill_value, fill_type_id, f_ptr_buf, mem_type_id, space_id, hdferr)
END SUBROUTINE h5dfill_integer
- SUBROUTINE h5dfill_c_float(fill_valuer, space_id, buf, hdferr)
+ SUBROUTINE h5dfill_c_float(fill_value, space_id, buf, hdferr)
USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
IMPLICIT NONE
- REAL(KIND=C_FLOAT), INTENT(IN), TARGET :: fill_valuer
+ REAL(KIND=C_FLOAT), INTENT(IN), TARGET :: fill_value
INTEGER(HID_T), INTENT(IN) :: space_id
REAL(KIND=C_FLOAT), INTENT(OUT), DIMENSION(*), TARGET :: buf
INTEGER, INTENT(OUT) :: hdferr
@@ -1623,17 +1677,16 @@ CONTAINS
INTEGER(HID_T) :: fill_type_id ! Fill value datatype identifier
INTEGER(HID_T) :: mem_type_id ! Buffer dadtype identifier
- TYPE(C_PTR) :: f_ptr_fill_valuer ! C pointer to fill_value
+ TYPE(C_PTR) :: f_ptr_fill_value ! C pointer to fill_value
TYPE(C_PTR) :: f_ptr_buf ! C pointer to buf
- f_ptr_fill_valuer = C_LOC(fill_valuer)
+ f_ptr_fill_value = C_LOC(fill_value)
f_ptr_buf = C_LOC(buf(1))
fill_type_id = H5T_NATIVE_REAL
mem_type_id = H5T_NATIVE_REAL
- hdferr = h5dfill_c(f_ptr_fill_valuer, fill_type_id, space_id, &
- f_ptr_buf, mem_type_id)
+ CALL h5dfill_ptr(f_ptr_fill_value, fill_type_id, f_ptr_buf, mem_type_id, space_id, hdferr)
END SUBROUTINE h5dfill_c_float
@@ -1647,17 +1700,16 @@ CONTAINS
INTEGER(HID_T) :: fill_type_id ! Fill value datatype identifier
INTEGER(HID_T) :: mem_type_id ! Buffer dadtype identifier
- TYPE(C_PTR) :: f_ptr_fill_valuer ! C pointer to fill_value
+ TYPE(C_PTR) :: f_ptr_fill_value ! C pointer to fill_value
TYPE(C_PTR) :: f_ptr_buf ! C pointer to buf
- f_ptr_fill_valuer = C_LOC(fill_value)
+ f_ptr_fill_value = C_LOC(fill_value)
f_ptr_buf = C_LOC(buf(1))
fill_type_id = H5T_NATIVE_DOUBLE
mem_type_id = H5T_NATIVE_DOUBLE
- hdferr = h5dfill_c(f_ptr_fill_valuer, fill_type_id, space_id, &
- f_ptr_buf, mem_type_id)
+ CALL h5dfill_ptr(f_ptr_fill_value, fill_type_id, f_ptr_buf, mem_type_id, space_id, hdferr)
END SUBROUTINE h5dfill_c_double
@@ -1672,22 +1724,21 @@ CONTAINS
INTEGER(HID_T) :: fill_type_id ! Fill value datatype identifier
INTEGER(HID_T) :: mem_type_id ! Buffer dadtype identifier
- TYPE(C_PTR) :: f_ptr_fill_valuer ! C pointer to fill_value
+ TYPE(C_PTR) :: f_ptr_fill_value ! C pointer to fill_value
TYPE(C_PTR) :: f_ptr_buf ! C pointer to buf
- f_ptr_fill_valuer = C_LOC(fill_value)
+ f_ptr_fill_value = C_LOC(fill_value)
f_ptr_buf = C_LOC(buf(1))
fill_type_id = H5T_NATIVE_DOUBLE
mem_type_id = H5T_NATIVE_DOUBLE
- hdferr = h5dfill_c(f_ptr_fill_valuer, fill_type_id, space_id, &
- f_ptr_buf, mem_type_id)
+ CALL h5dfill_ptr(f_ptr_fill_value, fill_type_id, f_ptr_buf, mem_type_id, space_id, hdferr)
END SUBROUTINE h5dfill_c_long_double
#endif
- SUBROUTINE h5dfill_char(fill_value, space_id, buf, hdferr)
+ SUBROUTINE h5dfill_char(fill_value, space_id, buf, hdferr)
USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
IMPLICIT NONE
CHARACTER, INTENT(IN), TARGET :: fill_value
@@ -1704,8 +1755,10 @@ CONTAINS
f_ptr_fill_value = C_LOC(fill_value)
f_ptr_buf = C_LOC(buf(1))
- hdferr = h5dfill_c(f_ptr_fill_value, fill_type_id, space_id, &
- f_ptr_buf, mem_type_id)
+ fill_type_id = H5T_NATIVE_CHARACTER
+ mem_type_id = H5T_NATIVE_CHARACTER
+
+ CALL h5dfill_ptr(f_ptr_fill_value, fill_type_id, f_ptr_buf, mem_type_id, space_id, hdferr)
END SUBROUTINE h5dfill_char
diff --git a/fortran/src/H5f90proto.h b/fortran/src/H5f90proto.h
index 3cfba71..1a9a854 100644
--- a/fortran/src/H5f90proto.h
+++ b/fortran/src/H5f90proto.h
@@ -175,8 +175,6 @@ H5_FCDLL int_f h5dget_create_plist_c(hid_t_f *dset_id, hid_t_f *plist_id);
H5_FCDLL int_f h5dset_extent_c(hid_t_f *dset_id, hsize_t_f *dims);
H5_FCDLL int_f h5dvlen_get_max_len_c(hid_t_f *dataset_id, hid_t_f *type_id, hid_t_f *space_id, size_t_f *len);
H5_FCDLL int_f h5dget_storage_size_c(hid_t_f *dataset_id, hsize_t_f *size);
-H5_FCDLL int_f h5dfill_c(void *fill_value, hid_t_f *fill_type_id, hid_t_f *space_id, void *buf,
- hid_t_f *mem_type_id);
H5_FCDLL int_f h5dget_space_status_c(hid_t_f *dset_id, int_f *flag);
H5_FCDLL int_f h5dcreate_anon_c(hid_t_f *loc_id, hid_t_f *type_id, hid_t_f *space_id, hid_t_f *dcpl_id,
hid_t_f *dapl_id, hid_t_f *dset_id);
diff --git a/fortran/src/hdf5_fortrandll.def.in b/fortran/src/hdf5_fortrandll.def.in
index f61f74b..7743579 100644
--- a/fortran/src/hdf5_fortrandll.def.in
+++ b/fortran/src/hdf5_fortrandll.def.in
@@ -61,8 +61,12 @@ H5D_mp_H5DWRITE_VL_REAL
H5D_mp_H5DREAD_VL_REAL
H5D_mp_H5DWRITE_VL_STRING
H5D_mp_H5DREAD_VL_STRING
-H5D_mp_H5DFILL_CHAR
+H5D_mp_H5DFILL_PTR
H5D_mp_H5DFILL_INTEGER
+H5D_mp_H5DFILL_C_FLOAT
+H5D_mp_H5DFILL_C_DOUBLE
+H5D_mp_H5DFILL_C_LONG_DOUBLE
+H5D_mp_H5DFILL_CHAR
H5D_mp_H5DGET_SPACE_STATUS_F
H5D_mp_H5DCREATE_ANON_F
H5D_mp_H5DGET_OFFSET_F