The following program does not correctly detect the number of characters transferred during the nonadvancing read [pre] program readlen_1 implicit none integer length, ios character(len=5):: c
open(10,file='test.txt')
write(10,'(A)') '1'
write(10,'(A)') '22'
write(10,'(A)') '333'
write(10,'(A)') '4444'
write(10,'(A)') '55555'
write(10,'(A)') '666666'
write(10,'(A)') '7777777'
write(10,'(A)') '88888888'
close(10)
open(10, file='test.txt')
ios = 0
do while(ios == 0 .or. ios == -2)
read(10,'(A)', advance='NO',size=length,iostat=ios) c
if (ios == -2) then
print *,'EOR :',c,':', len_trim(c), length
elseif(ios == 0) then
print *,' :',c,':', len_trim(c), length
endif
enddo
end program readlen_1 [/pre] The output should show 'length' to be equal to len_trim but it is always zero except when 5 characters could be read This is the expected outpu [pre] EOR :1 : 1 1 EOR :22 : 2 2 EOR :333 : 3 3 EOR :4444 : 4 4 :55555: 5 5 EOR : : 0 0 :66666: 5 5 EOR :6 : 1 1 :77777: 5 5 EOR :77 : 2 2 :88888: 5 5 EOR :888 : 3 3 [/pre] and this is what I get with ftn95 readlen_1.f90 /lgo: [pre] EOR :1 : 1 0 EOR :22 : 2 0 EOR :333 : 3 0 EOR :4444 : 4 0 :55555: 5 5 EOR : : 0 0 :66666: 5 5 EOR :6 : 1 0 :77777: 5 5 EOR :77 : 2 0 :88888: 5 5 EOR :888 : 3 0 [/pre]
P.S. Just to say I'm not looking for this bugs on purpose. I'm porting a library of Fortran 77 code to Fortran 95 and trying to use a xml library (written in Fortran 95) with my Fortran programs. With both projects I'm currently experiencing a certain number of issues, and some of them I can trace back to problems with FTN95
Johny