@@ -8,9 +8,11 @@ program test_savetxt
88
99outpath = get_outpath() // " /tmp.dat"
1010
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)
1416
1517contains
1618
@@ -27,7 +29,7 @@ function get_outpath() result(outpath)
2729 endif
2830 end function get_outpath
2931
30- subroutine test_int32 (outpath )
32+ subroutine test_iint32 (outpath )
3133 character (* ), intent (in ) :: outpath
3234 integer (int32) :: d(3 , 2 ), e(2 , 3 )
3335 integer (int32), allocatable :: d2(:, :)
@@ -45,7 +47,7 @@ subroutine test_int32(outpath)
4547 end subroutine
4648
4749
48- subroutine test_sp (outpath )
50+ subroutine test_rsp (outpath )
4951 character (* ), intent (in ) :: outpath
5052 real (sp) :: d(3 , 2 ), e(2 , 3 )
5153 real (sp), allocatable :: d2(:, :)
@@ -60,10 +62,10 @@ subroutine test_sp(outpath)
6062 call loadtxt(outpath, d2)
6163 call assert(all (shape (d2) == [2 , 3 ]))
6264 call assert(all (abs (e- d2) < epsilon (1._sp )))
63- end subroutine
65+ end subroutine test_rsp
6466
6567
66- subroutine test_dp (outpath )
68+ subroutine test_rdp (outpath )
6769 character (* ), intent (in ) :: outpath
6870 real (dp) :: d(3 , 2 ), e(2 , 3 )
6971 real (dp), allocatable :: d2(:, :)
@@ -78,6 +80,40 @@ subroutine test_dp(outpath)
7880 call loadtxt(outpath, d2)
7981 call assert(all (shape (d2) == [2 , 3 ]))
8082 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
82118
83- end program
119+ end program test_savetxt
0 commit comments