@@ -14,6 +14,8 @@ program csv_test3
14
14
character (len= 30 ),dimension (:),allocatable :: header, col1
15
15
integer :: i
16
16
character (len= 100 ) :: tmp_str
17
+ integer ,dimension (:),allocatable :: int_col
18
+ logical ,dimension (:),allocatable :: log_col
17
19
18
20
write (* ,* ) ' '
19
21
write (* ,* ) ' ============================'
@@ -25,27 +27,37 @@ program csv_test3
25
27
call f% initialize(verbose = .true. )
26
28
27
29
! open the file
28
- call f% open (' test.csv' ,n_cols= 4 ,status_ok= status_ok)
30
+ call f% open (' test.csv' ,n_cols= 6 ,status_ok= status_ok)
29
31
30
32
! add header
31
- call f% add([' x' ,' y' ,' z' ,' t' ])
33
+ call f% add([' x ' ,' y ' ,' z ' ,' t ' , ' int ' , ' str ' ])
32
34
call f% next_row()
33
35
34
36
! add some data:
35
37
call f% add([1.0_wp ,2.0_wp ,3.0_wp ],real_fmt= ' (F5.3)' )
36
38
call f% add(.true. )
39
+ call f% add(1 )
40
+ call f% add(' a' )
37
41
call f% next_row()
38
42
call f% add([2.0_wp ,5.0_wp ,6.0_wp ],real_fmt= ' (F5.3)' )
39
43
call f% add(.false. )
44
+ call f% add(1 )
45
+ call f% add(' b' )
40
46
call f% next_row()
41
47
call f% add([3.0_wp ,5.0_wp ,6.0_wp ],real_fmt= ' (F5.3)' )
42
48
call f% add(.false. )
49
+ call f% add(1 )
50
+ call f% add(' c' )
43
51
call f% next_row()
44
52
call f% add([4.0_wp ,5.0_wp ,6.0_wp ],real_fmt= ' (F5.3)' )
45
53
call f% add(.false. )
54
+ call f% add(1 )
55
+ call f% add(' d' )
46
56
call f% next_row()
47
57
call f% add([5.0_wp ,5.0_wp ,6.0_wp ],real_fmt= ' (F5.3)' )
48
58
call f% add(.false. )
59
+ call f% add(1 )
60
+ call f% add(' e' )
49
61
call f% next_row()
50
62
51
63
! finished
@@ -70,12 +82,17 @@ program csv_test3
70
82
do i = 1 , size (col1)
71
83
print " (*(g0))" , " >" ,trim (col1(i))," <"
72
84
end do
73
-
74
85
do i = 1 , 5
75
86
write (tmp_str,' (F5.3)' ) real (i,wp)
76
87
if (col1(i) /= tmp_str) error stop ' error converting cell to string:' // tmp_str
77
88
end do
78
89
90
+ call f% get(4 ,log_col,status_ok)
91
+ if (.not. all (log_col .eqv. [.true. ,.false. ,.false. ,.false. ,.false. ])) error stop ' error getting logical column'
92
+
93
+ call f% get(5 ,int_col,status_ok)
94
+ if (.not. all (int_col== 1 )) error stop ' error getting integer column'
95
+
79
96
! destroy the file
80
97
call f% destroy()
81
98
0 commit comments