Open
Description
I have the following simple program that writes three lines to a file and then reads the same three lines using string_type
UDDTIO:
module test_mod
use stdlib_string_type
implicit none
contains
subroutine write_file()
integer :: fh
open(newunit=fh,file="scratch.txt",status="unknown")
write(fh,*) 'This is line one'
write(fh,*) 'This is line two'
write(fh,*) 'This is line three'
close(fh)
end subroutine write_file
subroutine read_file()
integer :: fh, ios
type(string_type) :: line
open(newunit=fh,file="scratch.txt",status="unknown")
do
read(fh,*,iostat=ios) line
if (ios /= 0) exit
write(*,*) line
end do
close(fh)
end subroutine read_file
end module test_mod
program test
use test_mod
implicit none
call write_file()
call read_file()
end program test
With gfortran (10.1.0) only the first line is printed back, whereas Intel fortran (2021.1.2) prints all three lines.
Is this a bug in stdlib_string_type, a bug in gfortran UDDTIO, or have I done something wrong with my use of string_type
?
(I'm using the stdlib-fpm package which is at stdlib commit b522bbb).