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

List-directed unformatted read problems

NotThatItMatters
Principiante
694 Visualizações

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 Respostas
TimP
Colaborador honorário III
694 Visualizações

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

Steven_L_Intel1
Funcionário
694 Visualizações

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.

NotThatItMatters
Principiante
694 Visualizações

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?

Steven_L_Intel1
Funcionário
694 Visualizações

Unmatched quotes would be a problem, yes.

Responder