Quantcast
Channel: Intel® Fortran Compiler for Linux* and macOS*
Viewing all articles
Browse latest Browse all 2583

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

$
0
0

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.


Viewing all articles
Browse latest Browse all 2583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>