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

List directed read - character length limit?

Les_Neilson
Valued Contributor II
550 Views

Is there a limits to the number of characters that can be read using list directed input ?

I have a text file :

999
7.7
'A very long character string (2144 characters) terminated with a single quote'

A hex view of the file shows each record ends with CR/LF pairs (0D0A)
There are no "special" characters in the third line which is a concatenation of a filename, some other text and alist of labels all 40 characters long and currently containing the word "null" followed by 36 spaces. (The labels were originally 16 characters long I havejust changed them to 40)

The file is read using the following code :

spfline = 0 ! A line counter
! read the '999' card
spfline = spfline + 1
read (spfunit,*,iostat=ier) ilen ! No problem : reads 999
if (ier/=0) goto 99999

! version number
spfline = spfline + 1
read (spfunit,*,iostat=ier) ver ! No problem : reads 7.7
if (ier/=0) goto 99999

! name
spfline = spfline + 1
read (spfunit,*,iostat=ier) name ! It is failing here with ier = 59
if (ier/=0) goto 99999

Name is declared as character(3072)
and the help says that error code 59 is :

"severe (59): List-directed I/O syntax error
FOR$IOS_LISIO_SYN. The data in a list-directed input record had an invalid format, or the type of the constant was incompatible with the corresponding variable. The value of the variable was unchanged."

I have attached a cut down version of the text file.
If, in debug mode, I alterIER to be zero after the failed read, the code then goes on to correctly read the remainder of the file.

Is there a limit on list directed read of a character string?
Or is there something in the third line that I have missed?

Les

0 Kudos
2 Replies
Steven_L_Intel1
Employee
550 Views
The documented limit is 2048 characters. (Building Applications > Reference Information > Compiler Limits)
0 Kudos
Les_Neilson
Valued Contributor II
550 Views

Thanks Steve I was looking under the IO sections in the language reference. I didn't realise it could be a compiler limit. Fortunately changing the format from * to (a) works in this instance.

Les

0 Kudos
Reply