Skip to content

[stdlib_io] add disp(display variable values formatted). #520

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Ensure multi-thread safety.
  • Loading branch information
zoziha committed Nov 10, 2021
commit 710e1156e7a41f4b701f1fb973cadc91e7f6b374
12 changes: 5 additions & 7 deletions src/stdlib_io_disp.fypp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ submodule (stdlib_io) stdlib_io_disp
use stdlib_strings, only: to_string
implicit none

type(string_type) :: coloum(5)

contains

#! | string | data elem 1 | unknown width | sep | string | line 1 | defined width |
Expand Down Expand Up @@ -47,7 +45,6 @@ contains
width_ = merge(width_, 80, width_ > 80)

sep_ = optval(sep, " ")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why "two spaces" instead of "one space"?

coloum = string_type(":")

#! Prints header
if (present(header)) then
Expand Down Expand Up @@ -91,7 +88,8 @@ contains
write(unit_, "(*(A))") format_output_string(x_str(i, :), width_, brief_, sep_, max_elem_len)
end do

write(unit_, "(*(A))") format_output_string(coloum(1:merge(size(x, 2), 5, size(x, 2)<=5)), &
write(unit_, "(*(A))") format_output_string( &
string_type(spread(":", 1, merge(size(x, 2), 5, size(x, 2) < 5))), &
width_, brief_, sep_, max_elem_len)
write(unit_, "(*(A))") format_output_string(x_str(size(x, 1), :), width_, brief_, sep_, max_elem_len)

Expand Down Expand Up @@ -127,7 +125,8 @@ contains
write(unit_, "(*(A))") format_output_string(x(i, :), width_, brief_, sep_, max_elem_len)
end do

write(unit_, "(*(A))") format_output_string(coloum(1:merge(size(x, 2), 5, size(x, 2)<=5)), &
write(unit_, "(*(A))") format_output_string( &
string_type(spread(":", 1, merge(size(x, 2), 5, size(x, 2) < 5))), &
width_, brief_, sep_, max_elem_len)
write(unit_, "(*(A))") format_output_string(x(size(x, 1), :), width_, brief_, sep_, max_elem_len)

Expand Down Expand Up @@ -302,8 +301,7 @@ contains
write(unit_, "(A)") format_output_string([string_type(header)], width_, brief_, "", len(header))
end if

coloum(1) = string_type(x_)
write(unit_, "(A)") format_output_string(coloum(1:1), width_, brief_, sep_, len(coloum(1)))
write(unit_, "(A)") format_output_string([string_type(x_)], width_, brief_, sep_, len(x_))

end subroutine disp_char

Expand Down