-
Notifications
You must be signed in to change notification settings - Fork 189
[stdlib_io] disp
(display your data)
#445
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
Closed
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
fec8c68
add:
zoziha c0506ff
Merge branch 'zoziha/feature/format_string' into zoziha/feature/disp
zoziha df88c55
Fix stdlib_io_disp routines.
zoziha 2653a3c
Merge branch 'zoziha/feature/format_string' into zoziha/feature/disp
zoziha cb4cecc
Update `format_to_string` things;
zoziha 10a8003
Merge branch 'master' into zoziha/feature/disp
zoziha 3b0f0bc
Update `disp`: add optional `unit` and `brief`.
zoziha 652aad8
an other -> another
zoziha f10333d
Add a valid `test_io_disp.f90`
zoziha 4e94891
Correct spelling errors
zoziha 328ea75
Add a valid `test_io_disp.f90`
zoziha fce189c
Add support for `string_type` type initially.
zoziha c6906f0
Update src/Makefile.manual
zoziha 314f9b9
Update src/Makefile.manual
zoziha dfc2006
Fix a bug in test_io_disp.f90 for `string_type` test.
zoziha 3c24a75
Update stdlib_io%disp.md
zoziha d9520b7
Improve `brief` in `disp` routines.
zoziha b2335e2
Merge branch 'master' into zoziha/feature/disp
zoziha 92fe853
Meger `to_string` to `disp`, update `disp` routines.
zoziha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
#:include "common.fypp" | ||
#:set RIL_KINDS_TYPES = REAL_KINDS_TYPES + INT_KINDS_TYPES + LOG_KINDS_TYPES | ||
|
||
submodule (stdlib_io) stdlib_io_disp | ||
|
||
use, non_intrinsic :: stdlib_strings, only: format_string | ||
zoziha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
implicit none | ||
character(len=*), parameter :: fmt_r = '(*(g11.4, 1x))' | ||
character(len=*), parameter :: fmt_c = '(*(g23.4, 1x))' | ||
|
||
contains | ||
|
||
#:for kind, type in RIL_KINDS_TYPES | ||
module procedure disp_0_${type[0]}$${kind}$ | ||
if(present(string)) print *, trim(string) | ||
zoziha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
print fmt_r, val | ||
zoziha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
end procedure disp_0_${type[0]}$${kind}$ | ||
|
||
module procedure disp_1_${type[0]}$${kind}$ | ||
integer :: i, m | ||
m = size(val) | ||
if(present(string)) print *, trim(string) | ||
print fmt_r, (val(i), i=1,m) | ||
end procedure disp_1_${type[0]}$${kind}$ | ||
|
||
module procedure disp_2_${type[0]}$${kind}$ | ||
integer :: i, j, m, n | ||
m = size(val, 1) | ||
n = size(val, 2) | ||
if(present(string)) print *, trim(string) | ||
do i = 1, m | ||
print fmt_r, (val(i,j), j=1, n) | ||
zoziha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
end do | ||
end procedure disp_2_${type[0]}$${kind}$ | ||
|
||
module procedure disp_3_${type[0]}$${kind}$ | ||
integer :: i, dim1, dim2, dim3 | ||
dim1 = size(val, 1) | ||
dim2 = size(val, 2) | ||
dim3 = size(val, 3) | ||
if(present(string)) print *, trim(string) | ||
if(dim == 1) then | ||
zoziha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
do i = 1, dim1 | ||
print *, 'Slice ('//format_string(i)//',:,:):' | ||
zoziha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
call disp_2_${type[0]}$${kind}$(val(i, :, :)) | ||
end do | ||
elseif(dim == 2) then | ||
do i = 1, dim2 | ||
print *, 'Slice (:,'//format_string(i)//',:):' | ||
call disp_2_${type[0]}$${kind}$(val(:, i, :)) | ||
end do | ||
elseif (dim == 3) then | ||
do i = 1, dim3 | ||
print *, 'Slice (:,:,'//format_string(i)//'):' | ||
call disp_2_${type[0]}$${kind}$(val(:, :, i)) | ||
end do | ||
else | ||
call error_stop('Error(disp): wrong dimension') | ||
end if | ||
end procedure disp_3_${type[0]}$${kind}$ | ||
#:endfor | ||
|
||
#:for kind, type in CMPLX_KINDS_TYPES | ||
module procedure disp_0_${type[0]}$${kind}$ | ||
if(present(string)) print *, trim(string) | ||
print fmt_c, format_string(cmplx(real(val), & | ||
zoziha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
aimag(val)), '(g11,4)') | ||
zoziha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
end procedure disp_0_${type[0]}$${kind}$ | ||
|
||
module procedure disp_1_${type[0]}$${kind}$ | ||
integer :: i, m | ||
m = size(val) | ||
if(present(string)) print *, trim(string) | ||
print fmt_c, (format_string(cmplx(real(val(i)), & | ||
aimag(val(i))), '(g11.4)'), i=1, m) | ||
end procedure disp_1_${type[0]}$${kind}$ | ||
|
||
module procedure disp_2_${type[0]}$${kind}$ | ||
integer :: i, j, m, n | ||
m = size(val, 1) | ||
n = size(val, 2) | ||
if(present(string)) print *, trim(string) | ||
do i = 1, m | ||
print fmt_c, (format_string(cmplx(real(val(i, j)), & | ||
aimag(val(i, j))), '(g11.4)'), j=1, n) | ||
end do | ||
end procedure disp_2_${type[0]}$${kind}$ | ||
|
||
module procedure disp_3_${type[0]}$${kind}$ | ||
integer :: i, dim1, dim2, dim3 | ||
dim1 = size(val, 1) | ||
dim2 = size(val, 2) | ||
dim3 = size(val, 3) | ||
if(present(string)) print *, trim(string) | ||
if(dim == 1) then | ||
do i = 1, dim1 | ||
print *, 'Slice ('//format_string(i)//',:,:):' | ||
call disp_2_${type[0]}$${kind}$(val(i, :, :)) | ||
end do | ||
elseif(dim == 2) then | ||
do i = 1, dim2 | ||
print *, 'Slice (:,'//format_string(i)//',:):' | ||
call disp_2_${type[0]}$${kind}$(val(:, i, :)) | ||
end do | ||
elseif (dim == 3) then | ||
do i = 1, dim3 | ||
print *, 'Slice (:,:,'//format_string(i)//'):' | ||
call disp_2_${type[0]}$${kind}$(val(:, :, i)) | ||
end do | ||
else | ||
call error_stop('Error(disp): wrong dimension') | ||
end if | ||
end procedure disp_3_${type[0]}$${kind}$ | ||
#:endfor | ||
|
||
module procedure disp_str | ||
if(present(string)) print *, trim(string) | ||
if(present(val)) then | ||
print *, trim(val) | ||
else | ||
print *, '' | ||
end if | ||
end procedure disp_str | ||
|
||
end submodule stdlib_io_disp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
program test_io_disp | ||
zoziha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
use, non_intrinsic :: stdlib_io, only: disp | ||
implicit none | ||
real :: r(2, 3) | ||
complex :: c(2, 3), c_3d(2, 3, 2) | ||
integer :: i(2, 3) | ||
logical :: l(2, 3) | ||
|
||
r = 1.; c = 1.; c_3d = 2.; i = 1; l = .true. | ||
r(1, 1) = (1.e-11, 1.0e-4) | ||
c(2, 2) = 10.e5 | ||
c_3d(1,3,1) = (1000, 0.001) | ||
call disp('string', 'disp(string):') | ||
call disp('It is a note.') | ||
call disp() | ||
|
||
call disp(r, 'disp(r):') | ||
call disp(c, 'disp(c):') | ||
call disp(i, 'disp(i):') | ||
call disp(l, 'disp(l):') | ||
|
||
call disp(c_3d, 3, 'disp(c_3d, 3):') | ||
call disp(c_3d, 2, 'disp(c_3d, 2):') | ||
end program test_io_disp |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.