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

Question on inquire(pos=...) for stream access I/O

SH
Beginner
1,007 Views

Hello,

I am using ifort (IFORT) 12.0.0 at our linux server, and I am experiencing a strange behavior with stream access I/O.

A minimal-size sample code would look as follows:

program inq_pos_test

  implicit none

! integer,parameter :: nbuf=2**14-1

  integer,parameter :: nbuf=2**14

  integer :: offset

  character(len=nbuf) :: str

  offset=1

  open(11,file='./input.txt',form='unformatted',access='stream')

  read(11,pos=offset) str(1:nbuf)

  inquire(11,pos=offset)

  write(*,'(a,i8,a,i8)') 'pos after reading ',nbuf,' bytes=',offset

  close(11)

end program inq_pos_test

where './input.txt' is a 2MB ascii file. Definately I would expect the final value of offset to be (nbuf+1). This is true when nbuf = 2**14 - 1 (= 16383):

pos after reading    16383 bytes=   16384

However, it returns a strange value if nbuf = 2**14 (= 16384):

pos after reading    16384 bytes=    8193

where 8193 = 2**13 + 1. Seems like offset is always 8193 for any values of nbuf >= 2**14.

First of all, I would like to know whether this is our system-specific problem or not. Could anyone check whether this could be reproduced?

Thanks in advance.

ps. gfortran seems to work as expected for any values of nbuf.

0 Kudos
1 Solution
Ron_Green
Moderator
1,007 Views

This appears to be a bug prevalent in the 12.x and 13.0 compilers.  It is fixed in the first 13.1 compiler, 13.1.0.146 build 20130121 and all compilers thereafter ( all 13.1.x and 14.x compilers).

Nothing wrong with the code that I see.  Latest compilers from 13.1 onwards gives:

$ ifort -V -O0 -o inq inq.f90 ; ./inq
Intel(R) Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 13.1.0.146 Build 20130121
Copyright (C) 1985-2013 Intel Corporation.  All rights reserved.

 Intel(R) Fortran 13.1-2134
GNU ld version 2.20.51.0.2-5.34.el6 20100205
pos after reading    16384 bytes=   16385

I would recommend updating to a 13.1 or 14.0 compiler.  There currently are no more planned releases for the 13.0 or 12.x compilers.

ron

 

View solution in original post

0 Kudos
2 Replies
Ron_Green
Moderator
1,008 Views

This appears to be a bug prevalent in the 12.x and 13.0 compilers.  It is fixed in the first 13.1 compiler, 13.1.0.146 build 20130121 and all compilers thereafter ( all 13.1.x and 14.x compilers).

Nothing wrong with the code that I see.  Latest compilers from 13.1 onwards gives:

$ ifort -V -O0 -o inq inq.f90 ; ./inq
Intel(R) Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 13.1.0.146 Build 20130121
Copyright (C) 1985-2013 Intel Corporation.  All rights reserved.

 Intel(R) Fortran 13.1-2134
GNU ld version 2.20.51.0.2-5.34.el6 20100205
pos after reading    16384 bytes=   16385

I would recommend updating to a 13.1 or 14.0 compiler.  There currently are no more planned releases for the 13.0 or 12.x compilers.

ron

 

0 Kudos
SH
Beginner
1,007 Views

Hi Ron,

Many thanks for the clarification. I'll talk to our system administrator about the compiler update.

Thanks again.

0 Kudos
Reply