summaryrefslogtreecommitdiffstats
path: root/fortran/src/H5Dff.f90
diff options
context:
space:
mode:
authorElena Pourmal <epourmal@hdfgroup.org>2000-10-10 04:13:14 (GMT)
committerElena Pourmal <epourmal@hdfgroup.org>2000-10-10 04:13:14 (GMT)
commit02092cd24e8cb79c66903d5556515bd755deeeeb (patch)
treebf4cc467138236ae3dbf8d531e1ef4ae4eaee60a /fortran/src/H5Dff.f90
parenta1e44979edfe671a6c7f8278a8798d9a834476c3 (diff)
downloadhdf5-02092cd24e8cb79c66903d5556515bd755deeeeb.zip
hdf5-02092cd24e8cb79c66903d5556515bd755deeeeb.tar.gz
hdf5-02092cd24e8cb79c66903d5556515bd755deeeeb.tar.bz2
[svn-r2648]
Purpose: Reimplemented references to the objects and dataset regions. Description: Previous implementation was not portable. This implementation should work on UNIX workstations and Crays, but is very inefficient since it uses memcpy to repack Fortran buffers with references to C buffers and vice versa. Solution: I used fortran derived datatype with integer fields. h5dwrite_f and h5dread_f have extra parameter when references are written or read. This parameter describes size of the buffer that holds references. Platforms tested: J90 and Solaris 2.6 H5Pf.c Some of the functions do not exist now in the development branch. Commented those out, so one does not need to apply patch in order to build Fortran Library.
Diffstat (limited to 'fortran/src/H5Dff.f90')
-rw-r--r--fortran/src/H5Dff.f9097
1 files changed, 77 insertions, 20 deletions
diff --git a/fortran/src/H5Dff.f90 b/fortran/src/H5Dff.f90
index 5af83b8..000dd40 100644
--- a/fortran/src/H5Dff.f90
+++ b/fortran/src/H5Dff.f90
@@ -137,13 +137,14 @@
END SUBROUTINE h5dclose_f
- SUBROUTINE h5dwrite_reference_obj(dset_id, mem_type_id, buf, hdferr, &
+ SUBROUTINE h5dwrite_reference_obj(dset_id, mem_type_id, buf, n, hdferr, &
mem_space_id, file_space_id, xfer_prp)
IMPLICIT NONE
INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier
INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier
- TYPE(hobj_ref_t_f), DIMENSION(:), INTENT(IN) :: buf ! Data buffer
+ TYPE(hobj_ref_t_f), DIMENSION(N), INTENT(IN) :: buf ! Data buffer
+ INTEGER, INTENT(IN) :: n ! size of the bufffer buf
INTEGER, INTENT(OUT) :: hdferr ! Error code
INTEGER(HID_T), OPTIONAL, INTENT(IN) :: mem_space_id
! Memory dataspace identfier
@@ -155,7 +156,9 @@
INTEGER(HID_T) :: xfer_prp_default
INTEGER(HID_T) :: mem_space_id_default
INTEGER(HID_T) :: file_space_id_default
- INTEGER, EXTERNAL :: h5dwrite_c
+ INTEGER, ALLOCATABLE, DIMENSION(:) :: ref_buf
+ INTEGER :: i,j
+ INTEGER, EXTERNAL :: h5dwrite_ref_obj_c
xfer_prp_default = H5P_DEFAULT_F
mem_space_id_default = H5S_ALL_F
@@ -164,19 +167,32 @@
if (present(xfer_prp)) xfer_prp_default = xfer_prp
if (present(mem_space_id)) mem_space_id_default = mem_space_id
if (present(file_space_id)) file_space_id_default = file_space_id
-
- hdferr = h5dwrite_c(dset_id, mem_type_id, mem_space_id_default, &
- file_space_id_default, xfer_prp_default, buf)
+
+ allocate(ref_buf(REF_OBJ_BUF_LEN*n), stat=hdferr)
+ if (hdferr .NE. 0 ) then
+ hdferr = -1
+ return
+ else
+ do j = 1, n
+ do i = 1, REF_OBJ_BUF_LEN
+ ref_buf(REF_OBJ_BUF_LEN*(j-1) + i ) = buf(j)%ref(i)
+ enddo
+ enddo
+ endif
+ hdferr = h5dwrite_ref_obj_c(dset_id, mem_type_id, mem_space_id_default, &
+ file_space_id_default, xfer_prp_default, ref_buf, n)
+ deallocate(ref_buf)
END SUBROUTINE h5dwrite_reference_obj
- SUBROUTINE h5dwrite_reference_dsetreg(dset_id, mem_type_id, buf, hdferr, &
+ SUBROUTINE h5dwrite_reference_dsetreg(dset_id, mem_type_id, buf, n, hdferr, &
mem_space_id, file_space_id, xfer_prp)
IMPLICIT NONE
INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier
INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier
TYPE(hdset_reg_ref_t_f), DIMENSION(:), INTENT(IN) :: buf ! Data buffer
+ INTEGER, INTENT(IN) :: n ! size of the bufffer buf
INTEGER, INTENT(OUT) :: hdferr ! Error code
INTEGER(HID_T), OPTIONAL, INTENT(IN) :: mem_space_id
! Memory dataspace identfier
@@ -188,7 +204,9 @@
INTEGER(HID_T) :: xfer_prp_default
INTEGER(HID_T) :: mem_space_id_default
INTEGER(HID_T) :: file_space_id_default
- INTEGER, EXTERNAL :: h5dwrite_c
+ INTEGER, ALLOCATABLE, DIMENSION(:) :: ref_buf
+ INTEGER :: i,j
+ INTEGER, EXTERNAL :: h5dwrite_ref_reg_c
xfer_prp_default = H5P_DEFAULT_F
mem_space_id_default = H5S_ALL_F
@@ -198,8 +216,20 @@
if (present(mem_space_id)) mem_space_id_default = mem_space_id
if (present(file_space_id)) file_space_id_default = file_space_id
- hdferr = h5dwrite_c(dset_id, mem_type_id, mem_space_id_default, &
- file_space_id_default, xfer_prp_default, buf)
+ allocate(ref_buf(REF_REG_BUF_LEN*n), stat=hdferr)
+ if (hdferr .NE. 0 ) then
+ hdferr = -1
+ return
+ else
+ do j = 1, n
+ do i = 1, REF_REG_BUF_LEN
+ ref_buf(REF_REG_BUF_LEN*(j-1) + i) = buf(j)%ref(i)
+ enddo
+ enddo
+ endif
+ hdferr = h5dwrite_ref_reg_c(dset_id, mem_type_id, mem_space_id_default, &
+ file_space_id_default, xfer_prp_default, ref_buf, n)
+ deallocate(ref_buf)
END SUBROUTINE h5dwrite_reference_dsetreg
@@ -1265,13 +1295,14 @@
END SUBROUTINE h5dwrite_double_7
- SUBROUTINE h5dread_reference_obj(dset_id, mem_type_id, buf, hdferr, &
+ SUBROUTINE h5dread_reference_obj(dset_id, mem_type_id, buf, n, hdferr, &
mem_space_id, file_space_id, xfer_prp)
IMPLICIT NONE
INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier
INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier
- TYPE(hobj_ref_t_f), DIMENSION(:), INTENT(INOUT) :: buf ! Data buffer
+ TYPE(hobj_ref_t_f), DIMENSION(N), INTENT(INOUT) :: buf ! Data buffer
+ INTEGER, INTENT(IN) :: n ! Size of the budffer buf
INTEGER, INTENT(OUT) :: hdferr ! Error code
INTEGER(HID_T), OPTIONAL, INTENT(IN) :: mem_space_id
! Memory dataspace identfier
@@ -1283,7 +1314,14 @@
INTEGER(HID_T) :: xfer_prp_default
INTEGER(HID_T) :: mem_space_id_default
INTEGER(HID_T) :: file_space_id_default
- INTEGER, EXTERNAL :: h5dread_c
+ INTEGER, EXTERNAL :: h5dread_ref_obj_c
+ INTEGER, ALLOCATABLE, DIMENSION(:) :: ref_buf
+ INTEGER :: i,j
+ allocate(ref_buf(REF_OBJ_BUF_LEN*n), stat=hdferr)
+ if (hdferr .NE. 0) then
+ hdferr = -1
+ return
+ endif
xfer_prp_default = H5P_DEFAULT_F
mem_space_id_default = H5S_ALL_F
@@ -1293,18 +1331,24 @@
if (present(mem_space_id)) mem_space_id_default = mem_space_id
if (present(file_space_id)) file_space_id_default = file_space_id
- hdferr = h5dread_c(dset_id, mem_type_id, mem_space_id_default, &
- file_space_id_default, xfer_prp_default, buf)
-
+ hdferr = h5dread_ref_obj_c(dset_id, mem_type_id, mem_space_id_default, &
+ file_space_id_default, xfer_prp_default, ref_buf, n)
+ do j = 1, n
+ do i = 1, REF_OBJ_BUF_LEN
+ buf(j)%ref(i) = ref_buf(REF_OBJ_BUF_LEN*(j-1) + i)
+ enddo
+ enddo
+ deallocate(ref_buf)
END SUBROUTINE h5dread_reference_obj
- SUBROUTINE h5dread_reference_dsetreg(dset_id, mem_type_id, buf, hdferr, &
+ SUBROUTINE h5dread_reference_dsetreg(dset_id, mem_type_id, buf, n, hdferr, &
mem_space_id, file_space_id, xfer_prp)
IMPLICIT NONE
INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier
INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier
TYPE(hdset_reg_ref_t_f), DIMENSION(:), INTENT(INOUT) :: buf ! Data buffer
+ INTEGER, INTENT(IN) :: n ! Size of the buffer buf
INTEGER, INTENT(OUT) :: hdferr ! Error code
INTEGER(HID_T), OPTIONAL, INTENT(IN) :: mem_space_id
! Memory dataspace identfier
@@ -1316,7 +1360,14 @@
INTEGER(HID_T) :: xfer_prp_default
INTEGER(HID_T) :: mem_space_id_default
INTEGER(HID_T) :: file_space_id_default
- INTEGER, EXTERNAL :: h5dread_c
+ INTEGER, ALLOCATABLE, DIMENSION(:) :: ref_buf
+ INTEGER :: i,j
+ INTEGER, EXTERNAL :: h5dread_ref_reg_c
+ allocate(ref_buf(REF_REG_BUF_LEN*n), stat=hdferr)
+ if (hdferr .NE. 0) then
+ hdferr = -1
+ return
+ endif
xfer_prp_default = H5P_DEFAULT_F
mem_space_id_default = H5S_ALL_F
@@ -1326,9 +1377,15 @@
if (present(mem_space_id)) mem_space_id_default = mem_space_id
if (present(file_space_id)) file_space_id_default = file_space_id
- hdferr = h5dread_c(dset_id, mem_type_id, mem_space_id_default, &
- file_space_id_default, xfer_prp_default, buf)
+ hdferr = h5dread_ref_reg_c(dset_id, mem_type_id, mem_space_id_default, &
+ file_space_id_default, xfer_prp_default, ref_buf, n)
+ do j = 1, n
+ do i = 1, REF_REG_BUF_LEN
+ buf(j)%ref(i) = ref_buf(REF_REG_BUF_LEN*(j-1) + i)
+ enddo
+ enddo
+ deallocate(ref_buf)
END SUBROUTINE h5dread_reference_dsetreg