Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29282 Discussions

How to get read of interpreting Cntrl/M and Cntrl/Z in sequenial READ?

user1
Beginner
716 Views
Hi, Fortran-fans,

When I read a sequential file, I see two abnormalities:
1) If a record consists of one byte Cntrl/Z (decimal 26),
READ returns EOF, i.e. IOSTAT variable is -1.
2) If the last character of the record is Cntrl/M (decimal 13), READ
does not return this character. But it does return if Cntrl/M
is not the last character of the record.

Documentation claims that situation (1) should occur when -vms
flag is on, which is by default is off. So, if you do not use -vms
flag, you should expect READ should not return EOF in that case.

I did not find anything related to situation (2) in documentation.
One should expect that RECORDTYPE='STREAM_LF' uses character LF
(decimal code 10) as a record delimiter, all other character being
considered as a record body.

Is there any trick which would allow to get rid of these "features"?

/tmp> /opt/intel/fortran/bin/ifort -V
Intel Fortran Compiler for 32-bit applications, Version 8.1
Build 20040803Z Package ID: l_fc_p_8.1.018

Leonid
13-FEB-2005 13:58:45
0 Kudos
3 Replies
Steven_L_Intel1
Employee
716 Views
What exactly are you trying to do? Might you be better served by opening the file FORM='BINARY' and reading the bytes directly?
0 Kudos
user1
Beginner
716 Views
Steve,

I want to read a file with records separated by a delimiter:
character LF (10 decimal). All characters which are not delimiters,
i.e in the range (-128-9, 11-127), are considered as a part of records.
Of course, I can use system call read or something like that, but I wonder
is there a way to implement this using ordinary sequential READ? How to
turn off special interpretation of Cntrl/Z, Cntrl/M?

Leonid
16-FEB-2005 21:23:23
0 Kudos
Steven_L_Intel1
Employee
716 Views
You can't "turn off" recognition of CTRL-Z, but I would have expected that saying that the file is STREAM_LF would do what you want. The problem with formatted reads is that data can be interpreted as delimiters. I suggest using unformatted reads with FORM='BINARY' into a buffer and look for the LF yourself.
0 Kudos
Reply