Skip to content

savetxt and loadtxt are not portable #505

Closed
@milancurcic

Description

@milancurcic

While porting stdlib_io tests to the new testing framework (PR in progress in #494), it occurred to me that the loadtxt tests were not testing values, but merely loading the data and printing them to stdout. When I re-wrote the tests to compare the values, though the tests passed for GFortran, they failed for ifort (see awvwgk#87).

We should be able to round-trip the data without loss of information, i.e.

call random_number(a)
call savetxt('data.txt', a)
call loadtxt('data.txt', b)
print *, all(a == b) ! should print T

Currently it seems that doesn't generally work because both loadtxt and savetxt use list-directed input and output, which is not generally portable. We should use specific formats with field widths wide enough so that we can both round-trip the data and so that the files are in the same format between different compilers.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtopic: IOCommon input/output related features

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions