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

Formatted stream access - part II

IanH
Honored Contributor III
617 Views
(Part one was a while back...)

I think formatted stream input is still rather sick with 12.1.1. Consider the following variant that goes from one character at a time to four characters at a time:

[fortran]PROGRAM FormattedStream2
  IMPLICIT NONE
  INTEGER, PARAMETER :: unit = 10
  CHARACTER(4) :: c
  INTEGER :: stat
  !****
  OPEN( UNIT=unit, FILE='FormattedStream2.f90', ACTION='READ',  &
      FORM='FORMATTED', ACCESS='STREAM', STATUS='OLD', IOSTAT=stat )
  IF (stat /= 0) STOP "Couldn't open the file :("
  READ(unit, 100, IOSTAT=stat, ADVANCE='NO') c
  IF (stat /= 0) STOP "Couldn't read the first four chars :("
  WRITE (*, 100) 'The first four chars were "' // c // '" :)'
  READ(unit, 100, IOSTAT=stat, ADVANCE='NO') c
  IF (stat /= 0) STOP "Couldn't read the second four chars :("
  WRITE (*, 100) 'The next four chars were "' // c // '" :)'
  CLOSE(unit)    
  100 FORMAT(A)
END PROGRAM FormattedStream2
[/fortran]
I get....

[plain]>ifort /check:all /warn:all /standard-semantics FormattedStream2.f90
Intel Visual Fortran Compiler XE for applications running on IA-32, Version 12.1.1.258 Build 20111011
Copyright (C) 1985-2011 Intel Corporation.  All rights reserved.

Microsoft  Incremental Linker Version 10.00.40219.01
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:FormattedStream2.exe
-subsystem:console
FormattedStream2.obj

>FormattedStream2.exe
The first four chars were "PROG" :)
The next four chars were "ROGR" :)[/plain]
which doesn't seem right to me.

Even when you hit end of record, things still go awry...

formatted-stream-input.f90
test.txt



0 Kudos
2 Replies
Steven_L_Intel1
Employee
617 Views
I agree - things are definitely awry. I will let the developers know. Issue ID is DPD200176211.
0 Kudos
Steven_L_Intel1
Employee
617 Views
I expect the fix for this in Update 9.
0 Kudos
Reply