output_write_csv_header Subroutine

public subroutine output_write_csv_header(fid, space, variables)

Arguments

Type IntentOptional AttributesName
integer, intent(in) :: fid
character(len=identifier_max_length), intent(in) :: space
character(len=identifier_max_length), intent(in) :: variables(:)

Called by

proc~~output_write_csv_header~~CalledByGraph proc~output_write_csv_header output_write_csv_header proc~output_open_files output_open_files proc~output_open_files->proc~output_write_csv_header proc~output_initialise_storage output_initialise_storage proc~output_initialise_storage->proc~output_open_files proc~output_initialise output_initialise proc~output_initialise->proc~output_initialise_storage proc~initialise initialise proc~initialise->proc~output_initialise program~swim swim program~swim->proc~initialise

Contents


Source Code

  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