Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
22 Views

2018 unformatted read grabbing multiple records

We have some code that attempts to determine how many entries are in a record by attempting to read the record and looking at the IOSTAT value to determine if we have read too many values.  This code behaves differently with ifort 18, apparently reading multiple records to try and fill the provided array and not giving any indication of an error.  The code below is a simple test case:

program iotest
    implicit none

    integer :: iErr, tmpData(10)

    tmpData = [1,2,3,4,5,6,7,8,9,10]

    open(unit=1, file='testfile.tmp', status='NEW', form='UNFORMATTED')
    write(1) tmpData(1:5) ! Record 1 has 5 values
    write(1) tmpData(3:10) ! Record 2 has 8 values
    close(1)

    tmpData = -1
    open(unit=2, file='testfile.tmp', status='OLD', form='UNFORMATTED')
    read(2, IOSTAT=iErr) tmpData(1:10) ! Try to read 10 values from record 1
    close(2)
    print *, iErr, tmpData
end program

When run with previous versions of ifort, iErr will contain a value of 67 and tmpData will only have its first 5 entries overwritten.  With ifort 18, iErr is 0 and all 10 values of tmpData are populated, pulling the last 5 values from the second record:

Compiler is ifort (IFORT) 15.0.7 20160518
Copyright (C) 1985-2016 Intel Corporation.  All rights reserved.
Compile flags are '-O0'
          67           1           2           3           4           5
          -1          -1          -1          -1          -1

Compiler is ifort (IFORT) 16.0.4 20160811
Copyright (C) 1985-2016 Intel Corporation.  All rights reserved.
Compile flags are '-O0'
          67           1           2           3           4           5
          -1          -1          -1          -1          -1

Compiler is ifort (IFORT) 17.0.3 20170404
Copyright (C) 1985-2017 Intel Corporation.  All rights reserved.
Compile flags are '-O0'
          67           1           2           3           4           5
          -1          -1          -1          -1          -1

Compiler is ifort (IFORT) 18.0.1 20171018
Copyright (C) 1985-2017 Intel Corporation.  All rights reserved.
Compile flags are '-O0'
           0           1           2           3           4           5
           3           4           5           6           7

I'm not sure if this is a bug or I'm just misunderstanding something (I rarely use Fortran) so any insight would be appreciated.

0 Kudos
2 Replies
Highlighted
Black Belt Retired Employee
22 Views

Your understanding is correct - the 18.0 behavior is not. Please report this at the Intel Online Service Center.

0 Kudos
Highlighted
Beginner
22 Views

Thanks for the quick response.  I have reported it as requested (I think ... those forms don't seem well suited to technical bug reports).

0 Kudos