2023-02-25 13:09:22 +05:30
|
|
|
module test_HDF5_utilities
|
|
|
|
use prec
|
|
|
|
use HDF5
|
|
|
|
use HDF5_utilities
|
|
|
|
|
|
|
|
implicit none(type,external)
|
|
|
|
|
|
|
|
private
|
2023-07-21 00:46:31 +05:30
|
|
|
public :: test_HDF5_utilities_run
|
2023-02-25 13:09:22 +05:30
|
|
|
|
|
|
|
contains
|
|
|
|
|
2023-07-21 00:46:31 +05:30
|
|
|
subroutine test_HDF5_utilities_run()
|
2023-02-25 13:09:22 +05:30
|
|
|
|
2023-07-21 00:46:31 +05:30
|
|
|
call read_write()
|
2023-02-25 13:09:22 +05:30
|
|
|
|
2023-07-21 00:46:31 +05:30
|
|
|
end subroutine test_HDF5_utilities_run
|
2023-02-25 13:09:22 +05:30
|
|
|
|
|
|
|
|
2023-07-21 00:46:31 +05:30
|
|
|
subroutine read_write()
|
2023-02-25 13:09:22 +05:30
|
|
|
|
|
|
|
integer(HID_T) :: f
|
|
|
|
|
2023-11-26 17:35:39 +05:30
|
|
|
real(pREAL), dimension(3) :: real_d1_in,real_d1_out
|
|
|
|
real(pREAL), dimension(3,3) :: real_d2_in,real_d2_out
|
|
|
|
real(pREAL), dimension(3,3,3) :: real_d3_in,real_d3_out
|
|
|
|
real(pREAL), dimension(3,3,3,3) :: real_d4_in,real_d4_out
|
|
|
|
real(pREAL), dimension(3,3,3,3,3) :: real_d5_in,real_d5_out
|
|
|
|
|
|
|
|
integer, dimension(3) :: int_d1_in,int_d1_out
|
|
|
|
integer, dimension(3,3) :: int_d2_in,int_d2_out
|
|
|
|
integer, dimension(3,3,3) :: int_d3_in,int_d3_out
|
|
|
|
integer, dimension(3,3,3,3) :: int_d4_in,int_d4_out
|
|
|
|
integer, dimension(3,3,3,3,3) :: int_d5_in,int_d5_out
|
|
|
|
|
|
|
|
|
|
|
|
call random_number(real_d1_in)
|
|
|
|
call random_number(real_d2_in)
|
|
|
|
call random_number(real_d3_in)
|
|
|
|
call random_number(real_d4_in)
|
|
|
|
call random_number(real_d5_in)
|
|
|
|
|
|
|
|
int_d1_in = int(real_d1_in*2048._pREAL)
|
|
|
|
int_d2_in = int(real_d2_in*2048._pREAL)
|
|
|
|
int_d3_in = int(real_d3_in*2048._pREAL)
|
|
|
|
int_d4_in = int(real_d4_in*2048._pREAL)
|
|
|
|
int_d5_in = int(real_d5_in*2048._pREAL)
|
2023-02-25 13:09:22 +05:30
|
|
|
|
|
|
|
|
|
|
|
f = HDF5_openFile('test.hdf5','w')
|
|
|
|
|
2023-11-26 12:46:24 +05:30
|
|
|
|
2023-11-26 17:35:39 +05:30
|
|
|
call HDF5_write(real_d1_in,f,'real_d1')
|
|
|
|
call HDF5_write(real_d2_in,f,'real_d2')
|
|
|
|
call HDF5_write(real_d3_in,f,'real_d3')
|
|
|
|
call HDF5_write(real_d4_in,f,'real_d4')
|
|
|
|
call HDF5_write(real_d5_in,f,'real_d5')
|
2023-11-26 12:46:24 +05:30
|
|
|
|
2023-11-26 17:35:39 +05:30
|
|
|
call HDF5_write(int_d1_in,f,'int_d1')
|
|
|
|
call HDF5_write(int_d2_in,f,'int_d2')
|
|
|
|
call HDF5_write(int_d3_in,f,'int_d3')
|
|
|
|
call HDF5_write(int_d4_in,f,'int_d4')
|
|
|
|
call HDF5_write(int_d5_in,f,'int_d5')
|
2023-11-26 12:46:24 +05:30
|
|
|
|
|
|
|
|
2023-11-26 17:35:39 +05:30
|
|
|
call HDF5_read(real_d1_out,f,'real_d1')
|
|
|
|
call HDF5_read(real_d2_out,f,'real_d2')
|
|
|
|
call HDF5_read(real_d3_out,f,'real_d3')
|
|
|
|
call HDF5_read(real_d4_out,f,'real_d4')
|
|
|
|
call HDF5_read(real_d5_out,f,'real_d5')
|
|
|
|
|
|
|
|
call HDF5_read(int_d1_out,f,'int_d1')
|
|
|
|
call HDF5_read(int_d2_out,f,'int_d2')
|
|
|
|
call HDF5_read(int_d3_out,f,'int_d3')
|
|
|
|
call HDF5_read(int_d4_out,f,'int_d4')
|
|
|
|
call HDF5_read(int_d5_out,f,'int_d5')
|
|
|
|
|
|
|
|
|
|
|
|
if (any(real_d1_in /= real_d1_out)) error stop 'test_read_write(w)/real_d1'
|
|
|
|
if (any(real_d2_in /= real_d2_out)) error stop 'test_read_write(w)/real_d2'
|
|
|
|
if (any(real_d3_in /= real_d3_out)) error stop 'test_read_write(w)/real_d3'
|
|
|
|
if (any(real_d4_in /= real_d4_out)) error stop 'test_read_write(w)/real_d4'
|
|
|
|
if (any(real_d5_in /= real_d5_out)) error stop 'test_read_write(w)/real_d5'
|
|
|
|
|
|
|
|
if (any(int_d1_in /= int_d1_out)) error stop 'test_read_write(w)/int_d1'
|
|
|
|
if (any(int_d2_in /= int_d2_out)) error stop 'test_read_write(w)/int_d2'
|
|
|
|
if (any(int_d3_in /= int_d3_out)) error stop 'test_read_write(w)/int_d3'
|
|
|
|
if (any(int_d4_in /= int_d4_out)) error stop 'test_read_write(w)/int_d4'
|
|
|
|
if (any(int_d5_in /= int_d5_out)) error stop 'test_read_write(w)/int_d5'
|
|
|
|
|
|
|
|
|
|
|
|
call HDF5_closeFile(f)
|
2023-11-26 12:46:24 +05:30
|
|
|
|
|
|
|
f = HDF5_openFile('test.hdf5','r')
|
|
|
|
|
2023-11-26 17:35:39 +05:30
|
|
|
|
|
|
|
call HDF5_read(real_d1_out,f,'real_d1')
|
|
|
|
call HDF5_read(real_d2_out,f,'real_d2')
|
|
|
|
call HDF5_read(real_d3_out,f,'real_d3')
|
|
|
|
call HDF5_read(real_d4_out,f,'real_d4')
|
|
|
|
call HDF5_read(real_d5_out,f,'real_d5')
|
|
|
|
|
|
|
|
call HDF5_read(int_d1_out,f,'int_d1')
|
|
|
|
call HDF5_read(int_d2_out,f,'int_d2')
|
|
|
|
call HDF5_read(int_d3_out,f,'int_d3')
|
|
|
|
call HDF5_read(int_d4_out,f,'int_d4')
|
|
|
|
call HDF5_read(int_d5_out,f,'int_d5')
|
|
|
|
|
|
|
|
|
|
|
|
if (any(real_d1_in /= real_d1_out)) error stop 'test_read_write(r)/real_d1'
|
|
|
|
if (any(real_d2_in /= real_d2_out)) error stop 'test_read_write(r)/real_d2'
|
|
|
|
if (any(real_d3_in /= real_d3_out)) error stop 'test_read_write(r)/real_d3'
|
|
|
|
if (any(real_d4_in /= real_d4_out)) error stop 'test_read_write(r)/real_d4'
|
|
|
|
if (any(real_d5_in /= real_d5_out)) error stop 'test_read_write(r)/real_d5'
|
|
|
|
|
|
|
|
if (any(int_d1_in /= int_d1_out)) error stop 'test_read_write(r)/int_d1'
|
|
|
|
if (any(int_d2_in /= int_d2_out)) error stop 'test_read_write(r)/int_d2'
|
|
|
|
if (any(int_d3_in /= int_d3_out)) error stop 'test_read_write(r)/int_d3'
|
|
|
|
if (any(int_d4_in /= int_d4_out)) error stop 'test_read_write(r)/int_d4'
|
|
|
|
if (any(int_d5_in /= int_d5_out)) error stop 'test_read_write(r)/int_d5'
|
|
|
|
|
2023-11-26 12:46:24 +05:30
|
|
|
|
|
|
|
call HDF5_closeFile(f)
|
2023-02-25 13:09:22 +05:30
|
|
|
|
|
|
|
|
2023-07-21 00:46:31 +05:30
|
|
|
end subroutine read_write
|
2023-02-25 13:09:22 +05:30
|
|
|
|
|
|
|
end module test_HDF5_utilities
|