Get an individual value from the csv_data
structure in the CSV class.
The output val
can be an integer(ip)
, real(wp)
,
logical
, or character(len=*)
variable.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(csv_file), | intent(inout) | :: | me | |||
integer, | intent(in) | :: | row |
row number |
||
integer, | intent(in) | :: | col |
column number |
||
class(*), | intent(out) | :: | val |
the returned value |
||
logical, | intent(out) | :: | status_ok |
status flag |
subroutine csv_get_value(me,row,col,val,status_ok) implicit none class(csv_file),intent(inout) :: me integer,intent(in) :: row !! row number integer,intent(in) :: col !! column number class(*),intent(out) :: val !! the returned value logical,intent(out) :: status_ok !! status flag select type (val) type is (integer(ip)) call to_integer(me%csv_data(row,col)%str,val,status_ok) type is (real(sp)) call to_real_sp(me%csv_data(row,col)%str,val,status_ok) type is (real(wp)) call to_real_wp(me%csv_data(row,col)%str,val,status_ok) type is (logical) call to_logical(me%csv_data(row,col)%str,val,status_ok) type is (character(len=*)) status_ok = .true. if (allocated(me%csv_data(row,col)%str)) then val = me%csv_data(row,col)%str else val = '' end if type is (csv_string) status_ok = .true. val = me%csv_data(row,col) class default status_ok = .false. end select end subroutine csv_get_value