-
Notifications
You must be signed in to change notification settings - Fork 193
Added complex to io #138
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
Merged
Merged
Added complex to io #138
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
38ebcd0
Added support for complex numbers in loadtxt and savetxt
fiolj c1a7956
Added support and tests for complex numbers in loadtxt, savetxt
fiolj fafd229
Reverted formatting changes. Complex support for loadtxt and savetxt
fiolj ff46b12
Changed along suggestions by reviewers
fiolj 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
Reverted formatting changes. Complex support for loadtxt and savetxt
- Loading branch information
commit fafd22931f9ce229f6e871e93b9df88b133609e1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,63 @@ | ||
program test_loadtxt | ||
use stdlib_experimental_kinds, only: int32, sp, dp | ||
use stdlib_experimental_io, only: loadtxt | ||
use stdlib_experimental_error, only: error_stop | ||
implicit none | ||
use stdlib_experimental_kinds, only: int32, sp, dp | ||
use stdlib_experimental_io, only: loadtxt | ||
use stdlib_experimental_error, only: error_stop | ||
implicit none | ||
|
||
integer(int32), allocatable :: i(:, :) | ||
real(sp), allocatable :: s(:, :) | ||
real(dp), allocatable :: d(:, :) | ||
complex(dp), allocatable :: z(:, :) | ||
integer(int32), allocatable :: i(:, :) | ||
real(sp), allocatable :: s(:, :) | ||
real(dp), allocatable :: d(:, :) | ||
complex(dp), allocatable :: z(:, :) | ||
|
||
call loadtxt("array1.dat", i) | ||
call print_array(i) | ||
call loadtxt("array1.dat", i) | ||
call print_array(i) | ||
|
||
call loadtxt("array1.dat", s) | ||
call print_array(s) | ||
call loadtxt("array1.dat", s) | ||
call print_array(s) | ||
|
||
call loadtxt("array1.dat", d) | ||
call print_array(d) | ||
call loadtxt("array1.dat", d) | ||
call print_array(d) | ||
|
||
call loadtxt("array2.dat", d) | ||
call print_array(d) | ||
call loadtxt("array2.dat", d) | ||
call print_array(d) | ||
|
||
call loadtxt("array3.dat", d) | ||
call print_array(d) | ||
call loadtxt("array3.dat", d) | ||
call print_array(d) | ||
|
||
call loadtxt("array4.dat", d) | ||
call print_array(d) | ||
call loadtxt("array4.dat", d) | ||
call print_array(d) | ||
|
||
call loadtxt("array5.dat", z) | ||
call print_array(z) | ||
call loadtxt("array5.dat", z) | ||
call print_array(z) | ||
|
||
contains | ||
|
||
subroutine print_array(a) | ||
class(*),intent(in) :: a(:, :) | ||
integer :: i | ||
print *, "Array, shape=(", size(a, 1), ",", size(a, 2), ")" | ||
|
||
select type(a) | ||
type is(integer(int32)) | ||
do i = 1, size(a, 1) | ||
print *, a(i, :) | ||
end do | ||
type is(real(sp)) | ||
do i = 1, size(a, 1) | ||
print *, a(i, :) | ||
end do | ||
type is(real(dp)) | ||
do i = 1, size(a, 1) | ||
print *, a(i, :) | ||
end do | ||
type is(complex(dp)) | ||
do i = 1, size(a, 1) | ||
print *, a(i, :) | ||
end do | ||
class default | ||
call error_stop('The proposed type is not supported') | ||
end select | ||
|
||
end subroutine print_array | ||
|
||
end program test_loadtxt | ||
subroutine print_array(a) | ||
class(*),intent(in) :: a(:, :) | ||
integer :: i | ||
print *, "Array, shape=(", size(a, 1), ",", size(a, 2), ")" | ||
|
||
select type(a) | ||
type is(integer(int32)) | ||
do i = 1, size(a, 1) | ||
print *, a(i, :) | ||
end do | ||
type is(real(sp)) | ||
do i = 1, size(a, 1) | ||
print *, a(i, :) | ||
end do | ||
type is(real(dp)) | ||
do i = 1, size(a, 1) | ||
print *, a(i, :) | ||
end do | ||
type is(complex(dp)) | ||
do i = 1, size(a, 1) | ||
print *, a(i, :) | ||
end do | ||
class default | ||
call error_stop('The proposed type is not supported') | ||
end select | ||
|
||
end subroutine | ||
|
||
end program |
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
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.