@@ -91,6 +91,7 @@ module csv_module
91
91
csv_get_value,&
92
92
get_real_sp_column,&
93
93
get_real_wp_column,&
94
+ get_real_qp_column,&
94
95
get_integer_column,&
95
96
get_logical_column,&
96
97
get_character_column,&
@@ -99,6 +100,7 @@ module csv_module
99
100
procedure :: csv_get_value
100
101
procedure :: get_real_sp_column
101
102
procedure :: get_real_wp_column
103
+ procedure :: get_real_qp_column
102
104
procedure :: get_integer_column
103
105
procedure :: get_logical_column
104
106
procedure :: get_character_column
@@ -441,15 +443,23 @@ subroutine add_cell(me,val,int_fmt,real_fmt,trim_str)
441
443
if (present (real_fmt)) then
442
444
rfmt = trim (adjustl (real_fmt))
443
445
else
444
- rfmt = default_real_fmt
446
+ rfmt = default_sp_fmt
445
447
end if
446
448
write (real_val,fmt= rfmt,iostat= istat) val
447
449
write (me% iunit,fmt= ' (A)' ,advance= ' NO' ,iostat= istat) trim (adjustl (real_val))
448
450
type is (real (wp))
449
451
if (present (real_fmt)) then
450
452
rfmt = trim (adjustl (real_fmt))
451
453
else
452
- rfmt = default_real_fmt
454
+ rfmt = default_wp_fmt
455
+ end if
456
+ write (real_val,fmt= rfmt,iostat= istat) val
457
+ write (me% iunit,fmt= ' (A)' ,advance= ' NO' ,iostat= istat) trim (adjustl (real_val))
458
+ type is (real (qp))
459
+ if (present (real_fmt)) then
460
+ rfmt = trim (adjustl (real_fmt))
461
+ else
462
+ rfmt = default_qp_fmt
453
463
end if
454
464
write (real_val,fmt= rfmt,iostat= istat) val
455
465
write (me% iunit,fmt= ' (A)' ,advance= ' NO' ,iostat= istat) trim (adjustl (real_val))
@@ -756,6 +766,31 @@ pure elemental subroutine to_real_wp(str,val,status_ok)
756
766
end subroutine to_real_wp
757
767
! *****************************************************************************************
758
768
769
+ ! *****************************************************************************************
770
+ ! >
771
+ ! Convert a string to a `real(qp)`
772
+
773
+ pure elemental subroutine to_real_qp(str,val,status_ok)
774
+
775
+ implicit none
776
+
777
+ character (len=* ),intent (in ) :: str
778
+ real (qp),intent (out ) :: val
779
+ logical ,intent (out ) :: status_ok
780
+
781
+ integer :: istat ! ! read `iostat` error code
782
+
783
+ read (str,fmt=* ,iostat= istat) val
784
+ if (istat== 0 ) then
785
+ status_ok = .true.
786
+ else
787
+ status_ok = .false.
788
+ val = zero
789
+ end if
790
+
791
+ end subroutine to_real_qp
792
+ ! *****************************************************************************************
793
+
759
794
! *****************************************************************************************
760
795
! >
761
796
! Convert a string to a `integer(ip)`
@@ -924,6 +959,8 @@ subroutine csv_get_value(me,row,col,val,status_ok)
924
959
call to_real_sp(me% csv_data(row,col)% str,val,status_ok)
925
960
type is (real (wp))
926
961
call to_real_wp(me% csv_data(row,col)% str,val,status_ok)
962
+ type is (real (qp))
963
+ call to_real_qp(me% csv_data(row,col)% str,val,status_ok)
927
964
type is (logical )
928
965
call to_logical(me% csv_data(row,col)% str,val,status_ok)
929
966
type is (character (len=* ))
@@ -1003,6 +1040,10 @@ subroutine get_column(me,icol,r,status_ok)
1003
1040
if (me% verbose) write (error_unit,' (A)' ) &
1004
1041
' Error converting string to real(real64): ' // trim (me% csv_data(i,icol)% str)
1005
1042
r(i) = zero
1043
+ type is (real (qp))
1044
+ if (me% verbose) write (error_unit,' (A)' ) &
1045
+ ' Error converting string to real(real128): ' // trim (me% csv_data(i,icol)% str)
1046
+ r(i) = zero
1006
1047
type is (logical )
1007
1048
if (me% verbose) write (error_unit,' (A)' ) &
1008
1049
' Error converting string to logical: ' // trim (me% csv_data(i,icol)% str)
@@ -1068,6 +1109,30 @@ subroutine get_real_wp_column(me,icol,r,status_ok)
1068
1109
end subroutine get_real_wp_column
1069
1110
! *****************************************************************************************
1070
1111
1112
+ ! *****************************************************************************************
1113
+ ! >
1114
+ ! Return a column from a CSV file as a `real(qp)` vector.
1115
+
1116
+ subroutine get_real_qp_column (me ,icol ,r ,status_ok )
1117
+
1118
+ implicit none
1119
+
1120
+ class(csv_file),intent (inout ) :: me
1121
+ integer ,intent (in ) :: icol ! ! column number
1122
+ real (qp),dimension (:),allocatable ,intent (out ) :: r
1123
+ logical ,intent (out ) :: status_ok
1124
+
1125
+ if (allocated (me% csv_data)) then
1126
+ allocate (r(me% n_rows)) ! size the output vector
1127
+ call me% get_column(icol,r,status_ok)
1128
+ else
1129
+ if (me% verbose) write (error_unit,' (A,1X,I5)' ) ' Error: class has not been initialized'
1130
+ status_ok = .false.
1131
+ end if
1132
+
1133
+ end subroutine get_real_qp_column
1134
+ ! *****************************************************************************************
1135
+
1071
1136
! *****************************************************************************************
1072
1137
! >
1073
1138
! Return a column from a CSV file as a `integer(ip)` vector.
0 commit comments