summaryrefslogtreecommitdiffstats
path: root/fortran/src
diff options
context:
space:
mode:
authorScot Breitenfeld <brtnfld@hdfgroup.org>2023-05-22 23:17:14 (GMT)
committerGitHub <noreply@github.com>2023-05-22 23:17:14 (GMT)
commita888742959249605f83a00f1fd769c15b515969b (patch)
tree4811ce7bac3364f346cc5cac2371d2ce1bd36bf6 /fortran/src
parent8186a8ded043b383004160ec4ad239687c60d5dd (diff)
downloadhdf5-a888742959249605f83a00f1fd769c15b515969b.zip
hdf5-a888742959249605f83a00f1fd769c15b515969b.tar.gz
hdf5-a888742959249605f83a00f1fd769c15b515969b.tar.bz2
Updated H5Ovisit_f and H5Ovisit_by_name_f wrappers internals. (#2987)
* * Removed C wrappers for H5Ovisit_f and H5Ovist_by_name_f, modifying the Fortran source accordingly. * The intent for op_data was declared INOUT, even though the pointer address INTENT is, in actuality, IN. gfortran was optimizing out op_data in tests where the values were repeatedly reset to the same value. The values were reset in the test because the data the pointer targeted was updated in the callback. * Made use of the 'verify' function to check value correctness. * changed to useing INTEGER(C_INT) instead of C_BOOL, updated the documentation
Diffstat (limited to 'fortran/src')
-rw-r--r--fortran/src/H5Aff.F905
-rw-r--r--fortran/src/H5Lff.F904
-rw-r--r--fortran/src/H5Of.c97
-rw-r--r--fortran/src/H5Off.F9078
-rw-r--r--fortran/src/H5f90proto.h5
5 files changed, 46 insertions, 143 deletions
diff --git a/fortran/src/H5Aff.F90 b/fortran/src/H5Aff.F90
index 8159731..23bfaea 100644
--- a/fortran/src/H5Aff.F90
+++ b/fortran/src/H5Aff.F90
@@ -238,7 +238,6 @@ CONTAINS
TYPE(C_PTR) :: file_default = C_NULL_PTR
TYPE(C_PTR) :: func_default = C_NULL_PTR
INTEGER(KIND=C_INT) :: line_default = 0
-
CHARACTER(LEN=LEN_TRIM(name)+1,KIND=C_CHAR) :: c_name
INTERFACE
@@ -1644,7 +1643,9 @@ CONTAINS
!!
!! \param obj_id Object identifier
!! \param attr_name Attribute name
-!! \param attr_exists Pointer to attribute exists status, must be of type LOGICAL(C_BOOL) and initialize to .FALSE.
+!! \param attr_exists Pointer to attribute exists status. It should be declared INTEGER(C_INT) and initialized
+!! to zero (false) for portability. It will return one when true. LOGICAL(C_BOOL) is also
+!! acceptable but may encounter atypical anomalies. It should be initialized to false when used.
!! \param es_id \es_id
!! \param hdferr \fortran_error
!! \param file \fortran_file
diff --git a/fortran/src/H5Lff.F90 b/fortran/src/H5Lff.F90
index 790a65d..2340ce4 100644
--- a/fortran/src/H5Lff.F90
+++ b/fortran/src/H5Lff.F90
@@ -765,7 +765,9 @@ CONTAINS
!!
!! \param loc_id Identifier of the file or group to query.
!! \param name Link name to check.
-!! \param link_exists Pointer to Link exists status, must be of type LOGICAL(C_BOOL) and initialize to .FALSE.
+!! \param link_exists Pointer to link exists status. It should be declared INTEGER(C_INT) and initialized
+!! to zero (false) for portability. It will return one when true. LOGICAL(C_BOOL) is also
+!! acceptable but may encounter atypical anomalies. It should be initialized to false when used.
!! \param es_id \es_id
!! \param hdferr \fortran_error
!! \param lapl_id Link access property list identifier.
diff --git a/fortran/src/H5Of.c b/fortran/src/H5Of.c
index 186a9a2..54e5187 100644
--- a/fortran/src/H5Of.c
+++ b/fortran/src/H5Of.c
@@ -132,50 +132,6 @@ done:
return ret_value;
}
-/****if* H5Of/h5ovisit_c
- * NAME
- * h5ovisit_c
- * PURPOSE
- * Calls H5Ovisit
- * INPUTS
- * object_id - Identifier specifying subject group
- * index_type - Type of index which determines the order
- * order - Order within index
- * idx - Iteration position at which to start
- * op - Callback function passing data regarding the link to the calling application
- * op_data - User-defined pointer to data required by the application for its processing of the link
- * fields - Flags specifying the fields to include in object_info.
- *
- * OUTPUTS
- * idx - Position at which an interrupted iteration may be restarted
- *
- * RETURNS
- * >0 on success, 0< on failure
- * AUTHOR
- * M. Scot Breitenfeld
- * November 19, 2008
- * SOURCE
- */
-int_f
-h5ovisit_c(hid_t_f *group_id, int_f *index_type, int_f *order, H5O_iterate2_t op, void *op_data,
- int_f *fields)
-/******/
-{
- int_f ret_value = -1; /* Return value */
- herr_t func_ret_value; /* H5Linterate return value */
-
- /*
- * Call H5Ovisit
- */
-
- func_ret_value = H5Ovisit3((hid_t)*group_id, (H5_index_t)*index_type, (H5_iter_order_t)*order, op,
- op_data, (unsigned)*fields);
-
- ret_value = (int_f)func_ret_value;
-
- return ret_value;
-}
-
/****if* H5Of/h5oopen_by_token_c
* NAME
* h5oopen_by_token_c
@@ -358,59 +314,6 @@ done:
return ret_value;
}
-/****if* H5Of/h5ovisit_by_name_c
- * NAME
- * h5ovisit_by_name_c
- * PURPOSE
- * Calls H5Ovisit_by_name
- * INPUTS
- * object_id - Identifier specifying subject group.
- * index_type - Type of index which determines the order.
- * order - Order within index.
- * idx - Iteration position at which to start.
- * op - Callback function passing data regarding the link to the calling application.
- * op_data - User-defined pointer to data required by the application for its processing of the link.
- * fields - Flags specifying the fields to include in object_info.
- *
- * OUTPUTS
- * idx - Position at which an interrupted iteration may be restarted.
- *
- * RETURNS
- * >0 on success, 0< on failure
- * AUTHOR
- * M. Scot Breitenfeld
- * May 16, 2012
- * SOURCE
- */
-int_f
-h5ovisit_by_name_c(hid_t_f *loc_id, _fcd object_name, size_t_f *namelen, int_f *index_type, int_f *order,
- H5O_iterate2_t op, void *op_data, hid_t_f *lapl_id, int_f *fields)
-/******/
-{
- int_f ret_value = -1; /* Return value */
- herr_t func_ret_value; /* H5Linterate return value */
- char *c_object_name = NULL; /* Buffer to hold C string */
-
- /*
- * Convert FORTRAN name to C name
- */
- if ((c_object_name = HD5f2cstring(object_name, (size_t)*namelen)) == NULL)
- HGOTO_DONE(FAIL);
-
- /*
- * Call H5Ovisit_by_name
- */
- func_ret_value =
- H5Ovisit_by_name3((hid_t)*loc_id, c_object_name, (H5_index_t)*index_type, (H5_iter_order_t)*order, op,
- op_data, (unsigned)*fields, (hid_t)*lapl_id);
- ret_value = (int_f)func_ret_value;
-
-done:
- if (c_object_name)
- HDfree(c_object_name);
- return ret_value;
-}
-
/****if* H5Of/h5odecr_refcount_c
* NAME
* h5odecr_refcount_c
diff --git a/fortran/src/H5Off.F90 b/fortran/src/H5Off.F90
index 84a1590..d0bb459 100644
--- a/fortran/src/H5Off.F90
+++ b/fortran/src/H5Off.F90
@@ -1025,33 +1025,35 @@ CONTAINS
INTEGER(HID_T), INTENT(IN) :: object_id
INTEGER, INTENT(IN) :: index_type
INTEGER, INTENT(IN) :: order
-
TYPE(C_FUNPTR), INTENT(IN) :: op
- TYPE(C_PTR), INTENT(IN) :: op_data
+ TYPE(C_PTR), INTENT(INOUT) :: op_data ! Declare INOUT to bypass gfortran 4.8.5 issue
INTEGER, INTENT(OUT) :: return_value
INTEGER, INTENT(OUT) :: hdferr
- INTEGER, INTENT(IN), OPTIONAL :: fields
- INTEGER :: fields_c
+ INTEGER, INTENT(IN), OPTIONAL :: fields
+
+ INTEGER(C_INT) :: fields_c
+ INTEGER(C_INT) :: return_value_c
INTERFACE
- INTEGER FUNCTION h5ovisit_c(object_id, index_type, order, op, op_data, fields) &
- BIND(C, NAME='h5ovisit_c')
- IMPORT :: C_FUNPTR, C_PTR
+ INTEGER(C_INT) FUNCTION H5Ovisit3(object_id, index_type, order, op, op_data, fields) &
+ BIND(C, NAME='H5Ovisit3')
+ IMPORT :: C_FUNPTR, C_PTR, C_INT
IMPORT :: HID_T
IMPLICIT NONE
- INTEGER(HID_T):: object_id
- INTEGER :: index_type
- INTEGER :: order
+ INTEGER(HID_T), VALUE :: object_id
+ INTEGER(C_INT), VALUE :: index_type
+ INTEGER(C_INT), VALUE :: order
TYPE(C_FUNPTR), VALUE :: op
- TYPE(C_PTR), VALUE :: op_data
- INTEGER :: fields
- END FUNCTION h5ovisit_c
+ TYPE(C_PTR) , VALUE :: op_data
+ INTEGER(C_INT), VALUE :: fields
+ END FUNCTION H5Ovisit3
END INTERFACE
- fields_c = H5O_INFO_ALL_F
- IF(PRESENT(fields)) fields_c = fields
+ fields_c = INT(H5O_INFO_ALL_F,C_INT)
+ IF(PRESENT(fields)) fields_c = INT(fields,C_INT)
- return_value = h5ovisit_c(object_id, index_type, order, op, op_data, fields_c)
+ return_value_c = H5Ovisit3(object_id, INT(index_type,C_INT), INT(order, C_INT), op, op_data, fields_c)
+ return_value = INT(return_value_c)
IF(return_value.GE.0)THEN
hdferr = 0
@@ -1327,44 +1329,44 @@ CONTAINS
INTEGER , INTENT(IN) :: order
TYPE(C_FUNPTR) , INTENT(IN) :: op
- TYPE(C_PTR) , INTENT(IN) :: op_data
+ TYPE(C_PTR) , INTENT(INOUT) :: op_data ! Declare INOUT to bypass gfortran 4.8.5 issue
INTEGER , INTENT(OUT) :: return_value
INTEGER , INTENT(OUT) :: hdferr
INTEGER(HID_T) , INTENT(IN) , OPTIONAL :: lapl_id
INTEGER , INTENT(IN) , OPTIONAL :: fields
- INTEGER(SIZE_T) :: namelen
- INTEGER(HID_T) :: lapl_id_default
- INTEGER :: fields_c
+ INTEGER(HID_T) :: lapl_id_c
+ INTEGER(C_INT) :: fields_c
+ INTEGER(C_INT) :: return_value_c
+ CHARACTER(LEN=LEN_TRIM(object_name)+1,KIND=C_CHAR) :: object_name_c
INTERFACE
- INTEGER FUNCTION h5ovisit_by_name_c(loc_id, object_name, namelen, index_type, order, &
- op, op_data, lapl_id, fields) BIND(C, NAME='h5ovisit_by_name_c')
- IMPORT :: C_CHAR, C_PTR, C_FUNPTR
+ INTEGER(C_INT) FUNCTION H5Ovisit_by_name3(loc_id, object_name, index_type, order, &
+ op, op_data, fields, lapl_id) BIND(C, NAME='H5Ovisit_by_name3')
+ IMPORT :: C_CHAR, C_PTR, C_FUNPTR, C_INT
IMPORT :: HID_T, SIZE_T
IMPLICIT NONE
- INTEGER(HID_T) :: loc_id
+ INTEGER(HID_T), VALUE :: loc_id
CHARACTER(KIND=C_CHAR), DIMENSION(*) :: object_name
- INTEGER(SIZE_T) :: namelen
- INTEGER :: index_type
- INTEGER :: order
+ INTEGER(C_INT), VALUE :: index_type
+ INTEGER(C_INT), VALUE :: order
TYPE(C_FUNPTR), VALUE :: op
TYPE(C_PTR) , VALUE :: op_data
- INTEGER(HID_T) :: lapl_id
- INTEGER :: fields
- END FUNCTION h5ovisit_by_name_c
+ INTEGER(C_INT), VALUE :: fields
+ INTEGER(HID_T), VALUE :: lapl_id
+ END FUNCTION H5Ovisit_by_name3
END INTERFACE
- fields_c = H5O_INFO_ALL_F
- IF(PRESENT(fields)) fields_c = fields
-
- namelen = LEN(object_name)
+ fields_c = INT(H5O_INFO_ALL_F, C_INT)
+ IF(PRESENT(fields)) fields_c = INT(fields, C_INT)
+ object_name_c = TRIM(object_name)//C_NULL_CHAR
- lapl_id_default = H5P_DEFAULT_F
- IF(PRESENT(lapl_id)) lapl_id_default = lapl_id
+ lapl_id_c = INT(H5P_DEFAULT_F, C_INT)
+ IF(PRESENT(lapl_id)) lapl_id_c = INT(lapl_id, C_INT)
- return_value = h5ovisit_by_name_c(loc_id, object_name, namelen, index_type, order, &
- op, op_data, lapl_id_default, fields_c)
+ return_value_c = H5Ovisit_by_name3(loc_id, object_name_c, INT(index_type, C_INT), INT(order, C_INT), &
+ op, op_data, fields_c, lapl_id_c)
+ return_value = INT(return_value_c)
IF(return_value.GE.0)THEN
hdferr = 0
diff --git a/fortran/src/H5f90proto.h b/fortran/src/H5f90proto.h
index 11addfa..9085ae5 100644
--- a/fortran/src/H5f90proto.h
+++ b/fortran/src/H5f90proto.h
@@ -344,11 +344,6 @@ H5_FCDLL int_f h5oclose_c(hid_t_f *object_id);
H5_FCDLL int_f h5oopen_by_token_c(hid_t_f *loc_id, H5O_token_t *token, hid_t_f *obj_id);
H5_FCDLL int_f h5olink_c(hid_t_f *object_id, hid_t_f *new_loc_id, _fcd name, size_t_f *namelen,
hid_t_f *lcpl_id, hid_t_f *lapl_id);
-H5_FCDLL int_f h5ovisit_c(hid_t_f *group_id, int_f *index_type, int_f *order, H5O_iterate2_t op,
- void *op_data, int_f *fields);
-H5_FCDLL int_f h5ovisit_by_name_c(hid_t_f *loc_id, _fcd object_name, size_t_f *namelen, int_f *index_type,
- int_f *order, H5O_iterate2_t op, void *op_data, hid_t_f *lapl_id,
- int_f *fields);
H5_FCDLL int_f h5oget_info_c(hid_t_f *object_id, H5O_info_t_f *object_info, int_f *fields);
H5_FCDLL int_f h5oget_info_by_idx_c(hid_t_f *loc_id, _fcd group_name, size_t_f *namelen, int_f *index_field,
int_f *order, hsize_t_f *n, hid_t_f *lapl_id, H5O_info_t_f *object_info,