subroutine output_write_space_time_csv(file_id, array, space_ix, time_label, &
space_label)
! Write a 3D (vars, space, time) array with time, space index to tidy csv
integer, intent(in) :: file_id
integer, intent(in), optional :: space_ix(:)
character(len=*), intent(in) :: time_label(:)
character(len=*), intent(in), optional :: space_label(:)
real, intent(in) :: array(:, :, :)
integer it
if (present(space_ix)) then
do it = 1, size(time_label)
call output_array_to_csv(file_id, array(:, :, it), space_ix, time_label(it:it))
end do
else if (present(space_label)) then
do it = 1, size(time_label)
call output_array_to_csv(file_id, array(:, :, it), &
time_label=time_label(it:it), space_label=space_label)
end do
else
call log_error("output_write_space_time_csv", &
"space_ix or space_label have to be given.")
end if
end subroutine output_write_space_time_csv