summaryrefslogtreecommitdiffstats
path: root/fortran
diff options
context:
space:
mode:
authorElena Pourmal <epourmal@hdfgroup.org>2004-07-08 16:45:40 (GMT)
committerElena Pourmal <epourmal@hdfgroup.org>2004-07-08 16:45:40 (GMT)
commitc19e495c00193859a9cb3d0d25b52e6d9b379784 (patch)
tree5f11fba0f056c59cb9ad6f2a3fa7c28a8d2b1bb3 /fortran
parent828b55a90944e3286a129e61db7277a1d7722f39 (diff)
downloadhdf5-c19e495c00193859a9cb3d0d25b52e6d9b379784.zip
hdf5-c19e495c00193859a9cb3d0d25b52e6d9b379784.tar.gz
hdf5-c19e495c00193859a9cb3d0d25b52e6d9b379784.tar.bz2
[svn-r8836]
Purpose: Maintenance Description: Added h5fget_name_f and h5fget_filesize_f subroutines and tests. Solution: N/A Platforms tested: arabica (32-bit), sol (64-bit) parallle build on copper failed for the C library with the the following error: ld: 0711-317 ERROR: Undefined symbol: .H5FD_stdio_term Since this change doesn't affect the C library, I am cheking it in and will retest the fresh CVS copy after this check-in. Misc. update:
Diffstat (limited to 'fortran')
-rw-r--r--fortran/src/H5Ff.c70
-rw-r--r--fortran/src/H5Fff.f90103
-rw-r--r--fortran/src/H5f90proto.h6
-rw-r--r--fortran/test/tH5F.f9016
4 files changed, 195 insertions, 0 deletions
diff --git a/fortran/src/H5Ff.c b/fortran/src/H5Ff.c
index e486698..9ad8de7 100644
--- a/fortran/src/H5Ff.c
+++ b/fortran/src/H5Ff.c
@@ -15,6 +15,7 @@
/* This files contains C stubs for H5F Fortran APIs */
#include "H5f90.h"
+#include "H5Eprivate.h"
/*----------------------------------------------------------------------------
* Name: h5fcreate_c
@@ -475,3 +476,72 @@ nh5fget_freespace_c ( hid_t_f *file_id , hssize_t_f *free_space)
*free_space=(hssize_t_f)c_free_space;
return ret_value;
}
+
+/*----------------------------------------------------------------------------
+ * Name: h5fget_name_c
+ * Purpose: Call H5Fget_name to get file's name
+ * Inputs: obj_id - object identifier
+ * buflen -size of the buffer
+ * Outputs: buf - buffer to hold the name
+ * size - size of the file's name
+ * Returns: 0 on success, -1 on failure
+ * Programmer: Elena Pourmal
+ * Tuesday, July 6, 2004
+ * Modifications:
+ *---------------------------------------------------------------------------*/
+int_f
+nh5fget_name_c(hid_t_f *obj_id, size_t_f *size, _fcd buf, size_t_f *buflen)
+{
+ char *c_buf=NULL; /* Buffer to hold C string */
+ ssize_t size_c;
+ int_f ret_value=0; /* Return value */
+
+ /*
+ * Allocate buffer to hold name of an attribute
+ */
+ if ((c_buf = HDmalloc((size_t)*buflen +1)) == NULL)
+ HGOTO_DONE(FAIL);
+
+ /*
+ * Call H5Aget_name function
+ */
+ if ((size_c = (size_t_f)H5Fget_name((hid_t)*obj_id, c_buf, (size_t)*buflen)) < 0)
+ HGOTO_DONE(FAIL);
+
+ /*
+ * Convert C name to FORTRAN and place it in the given buffer
+ */
+ HD5packFstring(c_buf, _fcdtocp(buf), (size_t)*buflen);
+
+done:
+ *size = (size_t_f)size_c;
+ if(c_buf) HDfree(c_buf);
+ return ret_value;
+}
+
+/*----------------------------------------------------------------------------
+ * Name: h5fget_filesize_c
+ * Purpose: Call H5Fget_filesize to get file size
+ * Inputs: file_id - file identifier
+ * Outputs: size - size of the file
+ * Returns: 0 on success, -1 on failure
+ * Programmer: Elena Pourmal
+ * Wednesday, July 7, 2004
+ * Modifications:
+ *---------------------------------------------------------------------------*/
+int_f
+nh5fget_filesize_c(hid_t_f *file_id, hsize_t_f *size)
+{
+ hsize_t size_c;
+ herr_t ret_value=0; /* Return value */
+
+ /*
+ * Call H5Fget_filesize function
+ */
+ if ((ret_value = H5Fget_filesize((hid_t)*file_id, &size_c)) < 0)
+ HGOTO_DONE(FAIL);
+ *size = (hsize_t_f)size_c;
+
+done:
+ return ret_value;
+}
diff --git a/fortran/src/H5Fff.f90 b/fortran/src/H5Fff.f90
index 24e3945..4fbeba9 100644
--- a/fortran/src/H5Fff.f90
+++ b/fortran/src/H5Fff.f90
@@ -854,4 +854,107 @@
hdferr = h5fget_freespace_c(file_id, free_space)
END SUBROUTINE h5fget_freespace_f
+
+!----------------------------------------------------------------------
+! Name: h5fget_name_f
+!
+! Purpose: Gets the name of the file from the object identifier
+!
+! Inputs:
+! obj_id - object identifier
+! Inputs/Outputs:
+! buf - buffer to read name in
+! Outputs:
+! size - actual size of the name
+! hdferr: - error code
+! Success: 0
+! Failure: -1
+! Optional parameters:
+!
+! Programmer: Elena Pourmal
+! July 6, 2004
+!
+!----------------------------------------------------------------------
+
+
+ SUBROUTINE h5fget_name_f(obj_id, buf, size, hdferr)
+!This definition is needed for Windows DLLs
+!DEC$if defined(BUILD_HDF5_DLL)
+!DEC$attributes dllexport :: h5fget_name_f
+!DEC$endif
+ IMPLICIT NONE
+ INTEGER(HID_T), INTENT(IN) :: obj_id ! Object identifier
+ CHARACTER(LEN=*), INTENT(INOUT) :: buf
+ ! Buffer to hold file name
+ INTEGER(SIZE_T), INTENT(OUT) :: size ! Size of the file name
+ INTEGER, INTENT(OUT) :: hdferr ! Error code: 0 on success,
+ ! -1 if fail
+ INTEGER(SIZE_T) :: buflen
+! INTEGER, EXTERNAL :: h5fget_name_c
+! MS FORTRAN needs explicit interface for C functions called here.
+!
+ INTERFACE
+ INTEGER FUNCTION h5fget_name_c(obj_id, size, buf, buflen)
+ USE H5GLOBAL
+ !DEC$ IF DEFINED(HDF5F90_WINDOWS)
+ !MS$ATTRIBUTES C,reference,alias:'_H5FGET_NAME_C'::h5fget_name_c
+ !DEC$ ENDIF
+ !DEC$ATTRIBUTES reference :: buf
+ INTEGER(HID_T), INTENT(IN) :: obj_id
+ INTEGER(SIZE_T), INTENT(OUT) :: size
+ INTEGER(SIZE_T) :: buflen
+ CHARACTER(LEN=*), INTENT(OUT) :: buf
+ END FUNCTION h5fget_name_c
+ END INTERFACE
+ buflen = LEN(buf)
+ hdferr = h5fget_name_c(obj_id, size, buf, buflen)
+ END SUBROUTINE h5fget_name_f
+
+!----------------------------------------------------------------------
+! Name: h5fget_filesize_f
+!
+! Purpose: Retrieves the file size of the HDF5 file.
+!
+! Inputs:
+! file_id - file identifier
+! Outputs:
+! size - file size
+! hdferr: - error code
+! Success: 0
+! Failure: -1
+! Optional parameters:
+!
+! Programmer: Elena Pourmal
+! July 7, 2004
+!
+!----------------------------------------------------------------------
+
+
+ SUBROUTINE h5fget_filesize_f(file_id, size, hdferr)
+!This definition is needed for Windows DLLs
+!DEC$if defined(BUILD_HDF5_DLL)
+!DEC$attributes dllexport :: h5fget_filesize_f
+!DEC$endif
+ IMPLICIT NONE
+ INTEGER(HID_T), INTENT(IN) :: file_id ! file identifier
+ INTEGER(HSIZE_T), INTENT(OUT) :: size ! Size of the file
+ INTEGER, INTENT(OUT) :: hdferr ! Error code: 0 on success,
+ ! -1 if fail
+! INTEGER, EXTERNAL :: h5fget_filesize_c
+! MS FORTRAN needs explicit interface for C functions called here.
+!
+ INTERFACE
+ INTEGER FUNCTION h5fget_filesize_c(file_id, size)
+ USE H5GLOBAL
+ !DEC$ IF DEFINED(HDF5F90_WINDOWS)
+ !MS$ATTRIBUTES C,reference,alias:'_H5FGET_FILESIZE_C'::h5fget_filesize_c
+ !DEC$ ENDIF
+ INTEGER(HID_T), INTENT(IN) :: file_id
+ INTEGER(HSIZE_T), INTENT(OUT) :: size
+ END FUNCTION h5fget_filesize_c
+ END INTERFACE
+ hdferr = h5fget_filesize_c(file_id, size)
+ END SUBROUTINE h5fget_filesize_f
+
+
END MODULE H5F
diff --git a/fortran/src/H5f90proto.h b/fortran/src/H5f90proto.h
index 83ca366..f6636d6 100644
--- a/fortran/src/H5f90proto.h
+++ b/fortran/src/H5f90proto.h
@@ -38,6 +38,8 @@ H5_FCDLL void HD5packFstring(char *src, char *dest, size_t len);
# define nh5fget_obj_count_c FNAME(H5FGET_OBJ_COUNT_C)
# define nh5fget_obj_ids_c FNAME(H5FGET_OBJ_IDS_C)
# define nh5fget_freespace_c FNAME(H5FGET_FREESPACE_C)
+# define nh5fget_name_c FNAME(H5FGET_NAME_C)
+# define nh5fget_filesize_c FNAME(H5FGET_FILESIZE_C)
#else /* !DF_CAPFNAMES */
# define nh5fcreate_c FNAME(h5fcreate_c)
# define nh5fflush_c FNAME(h5fflush_c)
@@ -52,6 +54,8 @@ H5_FCDLL void HD5packFstring(char *src, char *dest, size_t len);
# define nh5fget_obj_count_c FNAME(h5fget_obj_count_c)
# define nh5fget_obj_ids_c FNAME(h5fget_obj_ids_c)
# define nh5fget_freespace_c FNAME(h5fget_freespace_c)
+# define nh5fget_name_c FNAME(h5fget_name_c)
+# define nh5fget_filesize_c FNAME(h5fget_filesize_c)
#endif /* DF_CAPFNAMES */
#endif /* H5Ff90_FNAMES */
@@ -80,6 +84,8 @@ H5_FCDLL int_f nh5fget_obj_count_c (hid_t_f *file_id, int_f *obj_type, int_f *ob
H5_FCDLL int_f nh5fget_obj_ids_c (hid_t_f *file_id, int_f *obj_type, int_f *max_objs, int_f *obj_ids);
H5_FCDLL int_f nh5fget_freespace_c (hid_t_f *file_id, hssize_t_f *free_space);
H5_FCDLL int_f nh5fflush_c (hid_t_f *obj_id, int_f *scope);
+H5_FCDLL int_f nh5fget_name_c(hid_t_f *obj_id, size_t_f *size, _fcd buf, size_t_f *buflen);
+H5_FCDLL int_f nh5fget_filesize_c(hid_t_f *file_id, hsize_t_f *size);
/*
* Functions from H5Sf.c
diff --git a/fortran/test/tH5F.f90 b/fortran/test/tH5F.f90
index d37d94a..d1e0064 100644
--- a/fortran/test/tH5F.f90
+++ b/fortran/test/tH5F.f90
@@ -327,6 +327,9 @@
!
INTEGER, DIMENSION(4,6) :: dset_data, data_out
INTEGER(HSIZE_T), DIMENSION(2) :: data_dims
+ INTEGER(HSIZE_T) :: file_size
+ CHARACTER(LEN=80) :: file_name
+ INTEGER(SIZE_T) :: name_size
!
!initialize the dset_data array which will be written to the "/dset"
@@ -393,12 +396,25 @@
!
CALL h5freopen_f(file_id, reopen_id, error)
CALL check("h5freopen_f",error,total_error)
+ !
+ !Check file size
+ !
+ CALL h5fget_filesize_f(file_id, file_size, error)
+ CALL check("h5fget_filesize_f",error,total_error)
!
!Open the dataset based on the reopen_id.
!
CALL h5dopen_f(reopen_id, dsetname, dset_id, error)
CALL check("h5dopen_f",error,total_error)
+ !
+ !Get file name from the dataset identifier
+ !
+ CALL h5fget_name_f(dset_id, file_name, name_size, error)
+ CALL check("h5fget_name_f",error,total_error)
+ IF(file_name(1:name_size) .NE. fix_filename(1:name_size)) THEN
+ write(*,*) "file name obtained from the dataset id is incorrect"
+ END IF
!
!Read the dataset.