|
1 | 1 | program test_loadtxt
|
2 |
| -use iso_fortran_env, only: dp=>real64 |
| 2 | +use iso_fortran_env, only: sp=>real32, dp=>real64 |
3 | 3 | use stdlib_experimental_io, only: loadtxt, savetxt
|
4 | 4 | use stdlib_experimental_error, only: assert
|
5 | 5 | implicit none
|
6 | 6 |
|
7 |
| -call test1() |
| 7 | +call test_sp() |
| 8 | +call test_dp() |
8 | 9 |
|
9 | 10 | contains
|
10 | 11 |
|
11 |
| - subroutine test1() |
| 12 | + subroutine test_sp() |
| 13 | + real(sp) :: d(3, 2), e(2, 3) |
| 14 | + real(sp), allocatable :: d2(:, :) |
| 15 | + d = reshape([1, 2, 3, 4, 5, 6], [3, 2]) |
| 16 | + call savetxt("tmp.dat", d) |
| 17 | + call loadtxt("tmp.dat", d2) |
| 18 | + call assert(all(shape(d2) == [3, 2])) |
| 19 | + call assert(all(abs(d-d2) < epsilon(1._sp))) |
| 20 | + |
| 21 | + e = reshape([1, 2, 3, 4, 5, 6], [2, 3]) |
| 22 | + call savetxt("tmp.dat", e) |
| 23 | + call loadtxt("tmp.dat", d2) |
| 24 | + call assert(all(shape(d2) == [2, 3])) |
| 25 | + call assert(all(abs(e-d2) < epsilon(1._sp))) |
| 26 | + end subroutine |
| 27 | + |
| 28 | + |
| 29 | + subroutine test_dp() |
12 | 30 | real(dp) :: d(3, 2), e(2, 3)
|
13 | 31 | real(dp), allocatable :: d2(:, :)
|
14 | 32 | d = reshape([1, 2, 3, 4, 5, 6], [3, 2])
|
|
0 commit comments