Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | fid | |||
character(len=identifier_max_length), | intent(in) | :: | space | |||
character(len=identifier_max_length), | intent(in) | :: | variables(:) |
subroutine output_write_csv_header(fid, space, variables)
! Write csv header <time> <space> <variables>
integer, intent(in) :: fid
character(len=identifier_max_length), intent(in) :: space, variables(:)
character(len=identifier_max_length) :: fmt
integer i, ffl
! Format lengths as int
read(output_float_format(2:index(output_float_format, ".") - 1), *) ffl
! time
write(fid, "(a)", advance="no") "time, "
! space
write(fid, "(a)", advance="no") trim(space)//","
! variables
do i = 1, size(variables) - 1
! Make sure variable name fits into the size of real format
write(fmt, "('(a',i4,')')") max(ffl, len(trim(variables(i)))+1) + 1
write(fid, trim(fmt), advance="no") trim(variables(i))//","
end do
! Last column
write(fmt, "('(a',i4,')')") max(ffl, len(trim(variables(size(variables))))+1)
write(fid, fmt) trim(variables(size(variables)))
end subroutine output_write_csv_header