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

List-directed unformatted read problems

NotThatItMatters
Beginner
695 Views

I was just reading jm-nichols post on some "old code" and unformatted reads and noted a similar problem I was having with somewhat similar code:

REAL TIME
CHARACTER (LEN = 8) NAME
INTEGER IX, IY, IZ, IDX, ITYPE
! INPUT_CODE is an input parameter, the UNIT number
READ(INPUT_CODE,*) NAME, TIME, IX, IY, IZ, IDX, ITYPE

I was getting a cold hard crash when the input stream had a forward slash in the name.  Are the admissible characters you can read into a character string with an unformatted READ documented somewhere?  Might this behavior have something to do with my compiler settings?

0 Kudos
4 Replies
TimP
Honored Contributor III
695 Views

List directed technically is formatted. List directed read into a character variable is notoriously unreliable, although quote marks may help.

0 Kudos
Steven_L_Intel1
Employee
695 Views

First, some terminology. This is a list-directed formatted read, not unformatted. The Fortran standard indicates what is valid input for list-directed. though Intel Fortran is a bit more lenient. In the case you mention, read of an undelimited character value stops when a "value separator) is seen.  The value separators are slash, comma and blank (or tab in our implementation). Slash causes input termination, so that is probably why your reads fail.

You can enclose the name string in quotes in the input to get around this, if the name has separators in it.

0 Kudos
NotThatItMatters
Beginner
695 Views

Thank you.  Yes, unfortunately I misnamed the topic.  What I was trying to point out was that there was not an explicit FMT given with the READ.  Thank you for the list of "value separators" and the workaround.  I will inform our UI team of the limitation.  I suppose then one other limitation might be unmatched quote marks?

0 Kudos
Steven_L_Intel1
Employee
695 Views

Unmatched quotes would be a problem, yes.

0 Kudos
Reply