Quantcast
Channel: Recent posts
Viewing all articles
Browse latest Browse all 415

Bug with write and pos= in stream access

$
0
0

Hello,

Up to now I was using the following version of the Intel Fortran compiler:
Intel(R) Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 14.0.2.144 Build 20140120
Copyright (C) 1985-2014 Intel Corporation.  All rights reserved.

I am currently testing the last version of the Intel Fortran compiler:
Intel(R) Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 17.0.1.132 Build 20161005
Copyright (C) 1985-2016 Intel Corporation.  All rights reserved.

I encounter what seems to be a bug when writing to a formatted file in Stream access and using the pos= functionality to write at different positions of the output file.

Here is a test program which behaves differently with the two versions of the compiler.

program TEST

    implicit none

    integer :: UNIT, I, POSITION1, POSITION2, IOK

    open(newunit=UNIT, file="test_stream", status="new", form="formatted", access="stream", iostat=IOK)
    write(6,*) IOK

    do I = 1, 2

       if (I == 1) then
          write(UNIT,"(A)") "a"
          inquire(unit=UNIT, pos=POSITION1)
       endif

       write(UNIT,"(I10)",pos=POSITION1) 2 * I

       if (I == 1) then
          write(UNIT,*)
          write(UNIT,"(A)") "a"
          inquire(unit=UNIT, pos=POSITION2)
       endif

       write(UNIT,"(I10)",pos=POSITION2) 2 * I + 1

    enddo

end program TEST

The expected output is what I get with the older version:

a
         4
 
a
         5

Here is what I get whith the last version:

a
         4
^@^@^@^@         5

Best regards.

Olivier

 


Viewing all articles
Browse latest Browse all 415

Trending Articles