Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29273 Discussions

iostat error reading long characters with free format

alegarra
Beginner
1,679 Views
Hi,
I am trying to read long chains from file using

read(1,*iostat=io)my_chain

but I got iostat error 59 for long chains.
I don't know if this is a compiler bug or there is something concerning free format (or open(recl=)) that would not allow me to do that. I cannnot find anything on the docs or my Fortran95/2003 explained. Any help is most welcome.

The following example program starts showing reading errors from n >= about 2500.
Thanks
Andres

[plain]program test
! features of free-format reading for data100.txt
implicit none
integer,parameter:: n=2500
character(len=n):: genome
integer:: io,i

integer:: snp(n)

snp=1
open(unit=1,file='kk.txt',status='replace',recl=12000)
do i=1,100
  write(1,'(12000i1)')snp
enddo
close(1)

do i =1,n
  genome(i:i)='A'
enddo
print *,genome(1:20)
open(unit=1,file='kk.txt',status='old',recl=12000)
i=0
do
  i=i+1
  read(1,*,iostat=io)genome
  print *, genome(1:20),io,i
  read(*,*)
enddo
end

[/plain]


0 Kudos
1 Solution
Steven_L_Intel1
Employee
1,679 Views
The documented limit (Building Applications > Reference Information > Compiler Limits) is 2048 characters for list-directed input.

View solution in original post

0 Kudos
2 Replies
TimP
Honored Contributor III
1,679 Views
In past compilers, the limit on length of a character string has been as low as 254, so this is clearly implementation dependent. I don't know whether the information in the ifort docs under BUFFERCOUNT may be relevant, or whether you should consider access='stream'
0 Kudos
Steven_L_Intel1
Employee
1,680 Views
The documented limit (Building Applications > Reference Information > Compiler Limits) is 2048 characters for list-directed input.
0 Kudos
Reply