Skip to content

Commit

Permalink
added hdf5 reading interfaces for datasets with 2 and 3 dimensions
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://qeforge.qe-forge.org/svnroot/q-e/trunk/espresso@13813 c92efa57-630b-4861-b058-cf58834340f0
  • Loading branch information
pietrodelugas committed Aug 31, 2017
1 parent 4978be0 commit 429eba6
Showing 1 changed file with 125 additions and 1 deletion.
126 changes: 125 additions & 1 deletion Modules/qeh5_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ MODULE qeh5_base_module


INTERFACE qeh5_read_dataset
MODULE PROCEDURE qeh5_read_real, qeh5_read_complex, qeh5_read_integer
MODULE PROCEDURE qeh5_read_real, qeh5_read_complex, qeh5_read_integer,&
qeh5_read_real_2, qeh5_read_complex_2, qeh5_read_integer_2,&
qeh5_read_real_3, qeh5_read_complex_3, qeh5_read_integer_3
END INTERFACE


Expand Down Expand Up @@ -422,6 +424,46 @@ SUBROUTINE qeh5_read_real ( real_data, h5_dataset)
!IF ( ierr /=0) CALL errore( 'qeh5_read_dataset', 'error reading '//TRIM(h5_descriptor%filename), ierr)
END SUBROUTINE qeh5_read_real

!----------------------------------------------------------
SUBROUTINE qeh5_read_real_2 ( real_data, h5_dataset)
!--------------------------------------------------------
IMPLICIT NONE
REAL(DP), TARGET, INTENT(INOUT) :: real_data(1,1)
TYPE (qeh5_dataset),INTENT(IN) :: h5_dataset
!
TYPE(C_PTR) :: ptr
INTEGER(HID_T) :: mem_hid, file_hid
INTEGER :: ierr
ptr = C_LOC(real_data)
mem_hid = H5S_ALL_F
file_hid = H5S_ALL_F
IF (ALLOCATED(h5_dataset%filespace%offset)) file_hid = h5_dataset%filespace%id
IF ( h5_dataset%memspace_ispresent ) mem_hid = h5_dataset%memspace%id
CALL H5Dread_f( h5_dataset%id, h5_realdp_type, ptr, ierr, mem_hid, file_hid, H5P_DEFAULT_F )
!IF ( ierr /=0) CALL errore( 'qeh5_read_dataset', 'error reading '//TRIM(h5_descriptor%filename), ierr)
END SUBROUTINE qeh5_read_real_2

!----------------------------------------------------------
SUBROUTINE qeh5_read_real_3 ( real_data, h5_dataset)
!--------------------------------------------------------
IMPLICIT NONE
REAL(DP), TARGET, INTENT(INOUT) :: real_data(1,1,1)
TYPE (qeh5_dataset),INTENT(IN) :: h5_dataset
!
TYPE(C_PTR) :: ptr
INTEGER(HID_T) :: mem_hid, file_hid
INTEGER :: ierr
ptr = C_LOC(real_data)
mem_hid = H5S_ALL_F
file_hid = H5S_ALL_F
IF (ALLOCATED(h5_dataset%filespace%offset)) file_hid = h5_dataset%filespace%id
IF ( h5_dataset%memspace_ispresent ) mem_hid = h5_dataset%memspace%id
CALL H5Dread_f( h5_dataset%id, h5_realdp_type, ptr, ierr, mem_hid, file_hid, H5P_DEFAULT_F )
!IF ( ierr /=0) CALL errore( 'qeh5_read_dataset', 'error reading '//TRIM(h5_descriptor%filename), ierr)
END SUBROUTINE qeh5_read_real_3



!----------------------------------------------------------
SUBROUTINE qeh5_read_complex ( complex_data, h5_dataset)
!--------------------------------------------------------
Expand All @@ -441,6 +483,45 @@ SUBROUTINE qeh5_read_complex ( complex_data, h5_dataset)
!IF ( ierr /=0) CALL errore( 'qeh5_read_dataset', 'error reading '//TRIM(h5_descriptor%filename), ierr)
END SUBROUTINE qeh5_read_complex

!----------------------------------------------------------
SUBROUTINE qeh5_read_complex_2 ( complex_data, h5_dataset)
!--------------------------------------------------------
IMPLICIT NONE
COMPLEX(DP), TARGET, INTENT(INOUT) :: complex_data(1,1)
TYPE (qeh5_dataset),INTENT(IN) :: h5_dataset
INTEGER(HID_T) :: mem_hid, file_hid
!
TYPE(C_PTR) :: ptr
INTEGER :: ierr
ptr = C_LOC(complex_data)
file_hid = H5S_ALL_F
mem_hid = H5S_ALL_F
IF (ALLOCATED(h5_dataset%filespace%offset)) file_hid = h5_dataset%filespace%id
IF ( h5_dataset%memspace_ispresent ) mem_hid = h5_dataset%memspace%id
CALL H5Dread_f( h5_dataset%id, H5_REALDP_TYPE, ptr, ierr, mem_hid, file_hid, H5P_DEFAULT_F )
!IF ( ierr /=0) CALL errore( 'qeh5_read_dataset', 'error reading '//TRIM(h5_descriptor%filename), ierr)
END SUBROUTINE qeh5_read_complex_2

!----------------------------------------------------------
SUBROUTINE qeh5_read_complex_3 ( complex_data, h5_dataset)
!--------------------------------------------------------
IMPLICIT NONE
COMPLEX(DP), TARGET, INTENT(INOUT) :: complex_data(1,1,1)
TYPE (qeh5_dataset),INTENT(IN) :: h5_dataset
INTEGER(HID_T) :: mem_hid, file_hid
!
TYPE(C_PTR) :: ptr
INTEGER :: ierr
ptr = C_LOC(complex_data)
file_hid = H5S_ALL_F
mem_hid = H5S_ALL_F
IF (ALLOCATED(h5_dataset%filespace%offset)) file_hid = h5_dataset%filespace%id
IF ( h5_dataset%memspace_ispresent ) mem_hid = h5_dataset%memspace%id
CALL H5Dread_f( h5_dataset%id, H5_REALDP_TYPE, ptr, ierr, mem_hid, file_hid, H5P_DEFAULT_F )
!IF ( ierr /=0) CALL errore( 'qeh5_read_dataset', 'error reading '//TRIM(h5_descriptor%filename), ierr)
END SUBROUTINE qeh5_read_complex_3


!-----------------------------------------------------------
SUBROUTINE qeh5_read_integer ( integer_data, h5_dataset)
!---------------------------------------------------------
Expand All @@ -462,6 +543,49 @@ SUBROUTINE qeh5_read_integer ( integer_data, h5_dataset)
!IF ( ierr /=0) CALL errore( 'qeh5_read_dataset', 'error reading '//TRIM(h5_descriptor%filename), ierr)
END SUBROUTINE qeh5_read_integer

!-----------------------------------------------------------
SUBROUTINE qeh5_read_integer_2 ( integer_data, h5_dataset)
!---------------------------------------------------------
IMPLICIT NONE
INTEGER, TARGET, INTENT(INOUT) :: integer_data(1,1)
TYPE (qeh5_dataset),INTENT(IN) :: h5_dataset
INTEGER(HID_T) :: mem_hid, file_hid
!
TYPE(C_PTR) :: ptr
INTEGER :: ierr
LOGICAL :: is_valid
ptr = C_LOC(integer_data)
!
file_hid = H5S_ALL_F
mem_hid = H5S_ALL_F
IF (ALLOCATED(h5_dataset%filespace%offset)) file_hid = h5_dataset%filespace%id
IF ( h5_dataset%memspace_ispresent ) mem_hid = h5_dataset%memspace%id
CALL H5Dread_f( h5_dataset%id, H5T_NATIVE_INTEGER , ptr, ierr, mem_hid, file_hid, H5P_DEFAULT_F )
!IF ( ierr /=0) CALL errore( 'qeh5_read_dataset', 'error reading '//TRIM(h5_descriptor%filename), ierr)
END SUBROUTINE qeh5_read_integer_2

!-----------------------------------------------------------
SUBROUTINE qeh5_read_integer_3 ( integer_data, h5_dataset)
!---------------------------------------------------------
IMPLICIT NONE
INTEGER, TARGET, INTENT(INOUT) :: integer_data(1,1,1)
TYPE (qeh5_dataset),INTENT(IN) :: h5_dataset
INTEGER(HID_T) :: mem_hid, file_hid
!
TYPE(C_PTR) :: ptr
INTEGER :: ierr
LOGICAL :: is_valid
ptr = C_LOC(integer_data)
!
file_hid = H5S_ALL_F
mem_hid = H5S_ALL_F
IF (ALLOCATED(h5_dataset%filespace%offset)) file_hid = h5_dataset%filespace%id
IF ( h5_dataset%memspace_ispresent ) mem_hid = h5_dataset%memspace%id
CALL H5Dread_f( h5_dataset%id, H5T_NATIVE_INTEGER , ptr, ierr, mem_hid, file_hid, H5P_DEFAULT_F )
!IF ( ierr /=0) CALL errore( 'qeh5_read_dataset', 'error reading '//TRIM(h5_descriptor%filename), ierr)
END SUBROUTINE qeh5_read_integer_3


!--------------------------------------------------------
SUBROUTINE qeh5_write_real( real_data, h5_dataset )
!------------------------------------------------------
Expand Down

0 comments on commit 429eba6

Please sign in to comment.