-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from certik/quad
Split the loadtxt qp tests and skip them on Win
- Loading branch information
Showing
6 changed files
with
94 additions
and
32 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,30 @@ | ||
program test_loadtxt_qp | ||
use iso_fortran_env, only: qp=>real128 | ||
use stdlib_experimental_io, only: loadtxt | ||
implicit none | ||
|
||
real(qp), allocatable :: q(:, :) | ||
|
||
call loadtxt("array4.dat", q) | ||
call print_array(q) | ||
|
||
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(real(qp)) | ||
do i = 1, size(a, 1) | ||
print *, a(i, :) | ||
end do | ||
class default | ||
write(*,'(a)')'The proposed type is not supported' | ||
error stop | ||
end select | ||
|
||
end subroutine | ||
|
||
end program |
This file contains 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 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,45 @@ | ||
program test_savetxt_qp | ||
use iso_fortran_env, only: qp=>real128 | ||
use stdlib_experimental_io, only: loadtxt, savetxt | ||
use stdlib_experimental_error, only: assert | ||
implicit none | ||
|
||
character(:), allocatable :: outpath | ||
|
||
outpath = get_outpath() // "/tmp_qp.dat" | ||
|
||
call test_qp(outpath) | ||
|
||
contains | ||
|
||
function get_outpath() result(outpath) | ||
integer :: ierr | ||
character(256) :: argv | ||
character(:), allocatable :: outpath | ||
|
||
call get_command_argument(1, argv, status=ierr) | ||
if (ierr==0) then | ||
outpath = trim(argv) | ||
else | ||
outpath = '.' | ||
endif | ||
end function get_outpath | ||
|
||
subroutine test_qp(outpath) | ||
character(*), intent(in) :: outpath | ||
real(qp) :: d(3, 2), e(2, 3) | ||
real(qp), allocatable :: d2(:, :) | ||
d = reshape([1, 2, 3, 4, 5, 6], [3, 2]) | ||
call savetxt(outpath, d) | ||
call loadtxt(outpath, d2) | ||
call assert(all(shape(d2) == [3, 2])) | ||
call assert(all(abs(d-d2) < epsilon(1._qp))) | ||
|
||
e = reshape([1, 2, 3, 4, 5, 6], [2, 3]) | ||
call savetxt(outpath, e) | ||
call loadtxt(outpath, d2) | ||
call assert(all(shape(d2) == [2, 3])) | ||
call assert(all(abs(e-d2) < epsilon(1._qp))) | ||
end subroutine | ||
|
||
end program |