@@ -8,9 +8,11 @@ program test_savetxt
8
8
9
9
outpath = get_outpath() // " /tmp.dat"
10
10
11
- call test_int32(outpath)
12
- call test_sp(outpath)
13
- call test_dp(outpath)
11
+ call test_iint32(outpath)
12
+ call test_rsp(outpath)
13
+ call test_rdp(outpath)
14
+ call test_csp(outpath)
15
+ call test_cdp(outpath)
14
16
15
17
contains
16
18
@@ -27,7 +29,7 @@ function get_outpath() result(outpath)
27
29
endif
28
30
end function get_outpath
29
31
30
- subroutine test_int32 (outpath )
32
+ subroutine test_iint32 (outpath )
31
33
character (* ), intent (in ) :: outpath
32
34
integer (int32) :: d(3 , 2 ), e(2 , 3 )
33
35
integer (int32), allocatable :: d2(:, :)
@@ -45,7 +47,7 @@ subroutine test_int32(outpath)
45
47
end subroutine
46
48
47
49
48
- subroutine test_sp (outpath )
50
+ subroutine test_rsp (outpath )
49
51
character (* ), intent (in ) :: outpath
50
52
real (sp) :: d(3 , 2 ), e(2 , 3 )
51
53
real (sp), allocatable :: d2(:, :)
@@ -60,10 +62,10 @@ subroutine test_sp(outpath)
60
62
call loadtxt(outpath, d2)
61
63
call assert(all (shape (d2) == [2 , 3 ]))
62
64
call assert(all (abs (e- d2) < epsilon (1._sp )))
63
- end subroutine
65
+ end subroutine test_rsp
64
66
65
67
66
- subroutine test_dp (outpath )
68
+ subroutine test_rdp (outpath )
67
69
character (* ), intent (in ) :: outpath
68
70
real (dp) :: d(3 , 2 ), e(2 , 3 )
69
71
real (dp), allocatable :: d2(:, :)
@@ -78,6 +80,40 @@ subroutine test_dp(outpath)
78
80
call loadtxt(outpath, d2)
79
81
call assert(all (shape (d2) == [2 , 3 ]))
80
82
call assert(all (abs (e- d2) < epsilon (1._dp )))
81
- end subroutine
83
+ end subroutine test_rdp
84
+
85
+ subroutine test_csp (outpath )
86
+ character (* ), intent (in ) :: outpath
87
+ complex (sp) :: d(3 , 2 ), e(2 , 3 )
88
+ complex (sp), allocatable :: d2(:, :)
89
+ d = cmplx (1 , 1 )* reshape ([1 , 2 , 3 , 4 , 5 , 6 ], [3 , 2 ])
90
+ call savetxt(outpath, d)
91
+ call loadtxt(outpath, d2)
92
+ call assert(all (shape (d2) == [3 , 2 ]))
93
+ call assert(all (abs (d- d2) < epsilon (1._sp )))
94
+
95
+ e = cmplx (1 , 1 )* reshape ([1 , 2 , 3 , 4 , 5 , 6 ], [2 , 3 ])
96
+ call savetxt(outpath, e)
97
+ call loadtxt(outpath, d2)
98
+ call assert(all (shape (d2) == [2 , 3 ]))
99
+ call assert(all (abs (e- d2) < epsilon (1._sp )))
100
+ end subroutine test_csp
101
+
102
+ subroutine test_cdp (outpath )
103
+ character (* ), intent (in ) :: outpath
104
+ complex (dp) :: d(3 , 2 ), e(2 , 3 )
105
+ complex (dp), allocatable :: d2(:, :)
106
+ d = cmplx (1._dp , 1._dp )* reshape ([1 , 2 , 3 , 4 , 5 , 6 ], [3 , 2 ])
107
+ call savetxt(outpath, d)
108
+ call loadtxt(outpath, d2)
109
+ call assert(all (shape (d2) == [3 , 2 ]))
110
+ call assert(all (abs (d- d2) < epsilon (1._dp )))
111
+
112
+ e = cmplx (1 , 1 )* reshape ([1 , 2 , 3 , 4 , 5 , 6 ], [2 , 3 ])
113
+ call savetxt(outpath, e)
114
+ call loadtxt(outpath, d2)
115
+ call assert(all (shape (d2) == [2 , 3 ]))
116
+ call assert(all (abs (e- d2) < epsilon (1._dp )))
117
+ end subroutine test_cdp
82
118
83
- end program
119
+ end program test_savetxt
0 commit comments