From 3c62af3fe5120729d1f65dd2e2f26e4f3c009ee7 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 26 Nov 2023 08:16:24 +0100 Subject: [PATCH] test 2D arrays and read-only file opening --- src/test/test_HDF5_utilities.f90 | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/test/test_HDF5_utilities.f90 b/src/test/test_HDF5_utilities.f90 index fb43de8e2..b4d6f39a3 100644 --- a/src/test/test_HDF5_utilities.f90 +++ b/src/test/test_HDF5_utilities.f90 @@ -20,17 +20,37 @@ end subroutine test_HDF5_utilities_run subroutine read_write() integer(HID_T) :: f - real(pREAL), dimension(3) :: d_in,d_out + real(pREAL), dimension(3) :: d1_in,d1_out + real(pREAL), dimension(3,3) :: d2_in,d2_out - call random_number(d_in) + call random_number(d1_in) + call random_number(d2_in) f = HDF5_openFile('test.hdf5','w') - call HDF5_write(d_in,f,'test') - call HDF5_read(d_out,f,'test') + call HDF5_write(d1_in,f,'d1') + call HDF5_write(d2_in,f,'d2') + + call HDF5_read(d1_out,f,'d1') + call HDF5_read(d2_out,f,'d2') + + if (any(d1_in /= d1_out)) error stop 'test_read_write(w)/d1' + if (any(d2_in /= d2_out)) error stop 'test_read_write(w)/d2' + + call HDF5_closeFile(f) + + + f = HDF5_openFile('test.hdf5','r') + + call HDF5_read(d1_out,f,'d1') + call HDF5_read(d2_out,f,'d2') + + if (any(d1_in /= d1_out)) error stop 'test_read_write(r)/d1' + if (any(d2_in /= d2_out)) error stop 'test_read_write(r)/d2' + + call HDF5_closeFile(f) - if (any(d_in /= d_out)) error stop 'test_read_write' end subroutine read_write