summaryrefslogtreecommitdiffstats
path: root/fortran
diff options
context:
space:
mode:
Diffstat (limited to 'fortran')
-rw-r--r--fortran/src/H5Ff.c46
-rw-r--r--fortran/src/H5Fff.F90100
-rw-r--r--fortran/src/H5f90proto.h1
-rw-r--r--fortran/src/hdf5_fortrandll.def.in1
-rw-r--r--fortran/test/tH5F.F9019
5 files changed, 105 insertions, 62 deletions
diff --git a/fortran/src/H5Ff.c b/fortran/src/H5Ff.c
index 2d5f6ed..a4e786e 100644
--- a/fortran/src/H5Ff.c
+++ b/fortran/src/H5Ff.c
@@ -402,52 +402,6 @@ h5fget_access_plist_c (hid_t_f *file_id, hid_t_f *access_id)
return ret_value;
}
-/****if* H5Ff/h5fis_hdf5_c
- * NAME
- * h5fis_hdf5_c
- * PURPOSE
- * Call H5Fis_hdf5 to determone if the file is an HDF5 file
- * INPUTS
- * name - name of the file
- * namelen - name length
- * OUTPUTS
- * flag - 0 if file is not HDF5 file , positive if a file
- * is an HDF5 file, and negative on failure.
- * RETURNS
- * 0 on success, -1 on failure
- * AUTHOR
- * Elena Pourmal
- * Tuesday, August 3, 1999
- * HISTORY
- *
- * SOURCE
-*/
-int_f
-h5fis_hdf5_c (_fcd name, int_f *namelen, int_f *flag)
-/******/
-{
- int ret_value = -1;
- char *c_name;
- int_f c_namelen;
- htri_t status;
-
- /*
- * Convert FORTRAN name to C name
- */
- c_namelen = *namelen;
- c_name = (char *)HD5f2cstring(name, (size_t)c_namelen);
- if (c_name == NULL) return ret_value;
-
- /*
- * Call H5Fopen function.
- */
- status = H5Fis_hdf5(c_name);
- *flag = (int_f)status;
- if (status >= 0) ret_value = 0;
-
- HDfree(c_name);
- return ret_value;
-}
/****if* H5Ff/h5fclose_c
* NAME
* h5fclose_c
diff --git a/fortran/src/H5Fff.F90 b/fortran/src/H5Fff.F90
index 358e421..9c8b941 100644
--- a/fortran/src/H5Fff.F90
+++ b/fortran/src/H5Fff.F90
@@ -45,6 +45,18 @@ MODULE H5F
! Number of objects opened in H5open_f
INTEGER(SIZE_T) :: H5OPEN_NUM_OBJ
+ INTERFACE
+ INTEGER(C_INT) FUNCTION h5fis_accessible(name, &
+ access_prp_default) BIND(C,NAME='H5Fis_accessible')
+ IMPORT :: C_CHAR
+ IMPORT :: HID_T
+ IMPORT :: C_INT
+ IMPLICIT NONE
+ CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(IN) :: name
+ INTEGER(HID_T), INTENT(IN), VALUE :: access_prp_default
+ END FUNCTION h5fis_accessible
+ END INTERFACE
+
CONTAINS
!****s* H5F/h5fcreate_f
!
@@ -486,6 +498,63 @@ CONTAINS
END SUBROUTINE h5fget_access_plist_f
+!****s* H5F/h5fis_accessible_f
+!
+! NAME
+! h5fis_accessible_f
+!
+! PURPOSE
+! Determines whether a file can be accessed as HDF5.
+!
+! INPUTS
+! name - name of the file to check
+! OUTPUTS
+! status - indicates if file is and HDF5 file
+! hdferr - Returns 0 if successful and -1 if fails
+! OPTIONAL PARAMETERS
+! access_prp - file access property list identifier
+! AUTHOR
+! Dana Robinson
+! September 2018
+!
+! HISTORY
+! Explicit Fortran interfaces were added for
+! called C functions (it is needed for Windows
+! port). February 28, 2001
+!
+! SOURCE
+ SUBROUTINE h5fis_accessible_f(name, status, hdferr, access_prp)
+ IMPLICIT NONE
+ CHARACTER(LEN=*), INTENT(IN) :: name ! Name of the file
+ LOGICAL, INTENT(OUT) :: status ! Indicates if file
+ ! is an HDF5 file
+ INTEGER, INTENT(OUT) :: hdferr ! Error code
+ INTEGER(HID_T), OPTIONAL, INTENT(IN) :: access_prp
+ ! File access property list
+ ! identifier
+!*****
+ INTEGER(HID_T) :: access_prp_default
+ CHARACTER(LEN=LEN_TRIM(name)+1,KIND=C_CHAR) :: c_name
+ INTEGER(C_INT) :: flag ! "TRUE/FALSE/ERROR" flag from C routine
+
+ access_prp_default = H5P_DEFAULT_F
+ IF (PRESENT(access_prp)) access_prp_default = access_prp
+
+ c_name = TRIM(name)//C_NULL_CHAR
+
+ flag = H5Fis_accessible(c_name, access_prp_default)
+
+ hdferr = 0
+ IF(flag.LT.0) hdferr = -1
+
+ status = .TRUE.
+ IF (flag .EQ. 0) status = .FALSE.
+
+ END SUBROUTINE h5fis_accessible_f
+
+! XXX (VOL_MERGE): This function should probably be marked as
+! deprecated since H5Fis_hdf5() is deprecated.
+
!****s* H5F/h5fis_hdf5_f
!
! NAME
@@ -503,6 +572,12 @@ CONTAINS
! Elena Pourmal
! August 12, 1999
!
+! NOTES
+! The underlying HDF5 C API call (H5Fis_hdf5) has been deprecated
+! in favor of the VOL-capable H5Fis_accessible(). New code should
+! use h5fis_accessible_f() instead of this function in case this
+! function is deprecated in the future.
+!
! HISTORY
! Explicit Fortran interfaces were added for
! called C functions (it is needed for Windows
@@ -516,26 +591,23 @@ CONTAINS
! is an HDF5 file
INTEGER, INTENT(OUT) :: hdferr ! Error code
!*****
- INTEGER :: namelen ! Length of the name character string
- INTEGER :: flag ! "TRUE/FALSE" flag from C routine
- ! to define status value.
+ INTEGER(HID_T) :: access_prp_default
+ CHARACTER(LEN=LEN_TRIM(name)+1,KIND=C_CHAR) :: c_name
+ INTEGER(C_INT) :: flag ! "TRUE/FALSE/ERROR" flag from C routine
+ ! to define status value.
- INTERFACE
- INTEGER FUNCTION h5fis_hdf5_c(name, namelen, flag) BIND(C,NAME='h5fis_hdf5_c')
- IMPORT :: C_CHAR
- IMPLICIT NONE
- CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(IN) :: name
- INTEGER :: namelen
- INTEGER :: flag
- END FUNCTION h5fis_hdf5_c
- END INTERFACE
+ c_name = TRIM(name)//C_NULL_CHAR
+
+ flag = H5Fis_accessible(c_name, H5P_DEFAULT_F)
+
+ hdferr = 0
+ IF(flag.LT.0) hdferr = -1
- namelen = LEN_TRIM(name)
- hdferr = h5fis_hdf5_c(name, namelen, flag)
status = .TRUE.
IF (flag .EQ. 0) status = .FALSE.
END SUBROUTINE h5fis_hdf5_f
+
!****s* H5F/h5fclose_f
!
! NAME
diff --git a/fortran/src/H5f90proto.h b/fortran/src/H5f90proto.h
index 46ef8ef..0884eb6 100644
--- a/fortran/src/H5f90proto.h
+++ b/fortran/src/H5f90proto.h
@@ -78,7 +78,6 @@ typedef struct H5O_info_t_f {
*/
H5_FCDLL int_f h5fcreate_c(_fcd name, int_f *namelen, int_f *access_flags, hid_t_f *crt_prp, hid_t_f *acc_prp, hid_t_f *file_id);
H5_FCDLL int_f h5fopen_c(_fcd name, int_f *namelen, int_f *access_flags, hid_t_f *acc_prp, hid_t_f *file_id);
-H5_FCDLL int_f h5fis_hdf5_c(_fcd name, int_f *namelen, int_f *flag);
H5_FCDLL int_f h5fclose_c(hid_t_f *file_id);
H5_FCDLL int_f h5fmount_c(hid_t_f *loc_id, _fcd dsetname, int_f *namelen, hid_t_f *file_id, hid_t_f *acc_prp);
H5_FCDLL int_f h5funmount_c(hid_t_f *loc_id, _fcd dsetname, int_f *namelen);
diff --git a/fortran/src/hdf5_fortrandll.def.in b/fortran/src/hdf5_fortrandll.def.in
index 3a5a91f..2edba5a 100644
--- a/fortran/src/hdf5_fortrandll.def.in
+++ b/fortran/src/hdf5_fortrandll.def.in
@@ -94,6 +94,7 @@ H5F_mp_H5FOPEN_F
H5F_mp_H5FREOPEN_F
H5F_mp_H5FGET_CREATE_PLIST_F
H5F_mp_H5FGET_ACCESS_PLIST_F
+H5F_mp_H5FIS_ACCESSIBLE_F
H5F_mp_H5FIS_HDF5_F
H5F_mp_H5FGET_NAME_F
H5F_mp_H5FGET_FILESIZE_F
diff --git a/fortran/test/tH5F.F90 b/fortran/test/tH5F.F90
index ee386dd..d51803b 100644
--- a/fortran/test/tH5F.F90
+++ b/fortran/test/tH5F.F90
@@ -232,7 +232,24 @@ CONTAINS
CALL check("h5fclose_f",error,total_error)
!
- !test whether files are in hdf5 format
+ !test whether files are accessible as HDF5 (new, VOL-safe, way)
+ !
+ CALL h5fis_accessible_f(fix_filename1, status, error)
+ CALL check("h5fis_accessible_f",error,total_error)
+ IF ( .NOT. status ) THEN
+ write(*,*) "File ", fix_filename1, " is not accessible as hdf5"
+ stop
+ END IF
+
+ CALL h5fis_accessible_f(fix_filename2, status, error)
+ CALL check("h5fis_accessible_f",error,total_error)
+ IF ( .NOT. status ) THEN
+ write(*,*) "File ", fix_filename2, " is not accessible as hdf5"
+ stop
+ END IF
+
+ !
+ !test whether files are in hdf5 format (old way)
!
CALL h5fis_hdf5_f(fix_filename1, status, error)
CALL check("h5fis_hdf5_f",error,total_error)