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

Strange end-of-file in unformatted read (compiler bug?) in ifort 16.0.3 on Linux 64

Melven_R_
Beginner
438 Views

Dear Intel support team,

for the example below I always obtain end-of-file errors even though the code seems correct to me.

program test
  implicit none
  integer :: nA, nU, nR, nB
  real(kind=8), allocatable :: r(:,:,:,:)

  ! file created with (works if not commented out!)
  !open(unit=201, file='mn_wake00350.000.dat', action='write', form='unformatted')
  !na=36;nu=4;nr=11;nb=4
  !write(201) nA, nU, nR, nB
  !allocate(r(na*nu+1,nr,nb,3))
  !call random_number(r)
  !write(201) r(:,:,:,1)
  !write(201) r(:,:,:,2)
  !write(201) r(:,:,:,3)
  !deallocate(r)
  !close(201)

  open(unit=201, file='mn_wake00350.000.dat', action='read', status='old', form='unformatted')

  read(201) nA, nU, nR, nB
  write(*,*) nA, nU, nR, nB
  allocate(r(na*nu+1,nr,nb,3))

  ! this strangely works with ifort, but not with gfortran
  !read(201) r

  ! This should work, but fails with ifort. This is exactly the way the data is written...
  read(201) r(:,:,:,1)
  read(201) r(:,:,:,2)
  read(201) r(:,:,:,3)

  close(201)

  write(*,*) minval(r), maxval(r), norm2(r)

end program test

Here is the binary file (zipped) that is also generated by the code that is comment out above: 520005

I obtain the following output:

> ifort -V
Intel(R) Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 16.0.3.210 Build 20160415
Copyright (C) 1985-2016 Intel Corporation.  All rights reserved.

> ifort test.f90
> ./a.out
          36           4          11           4
forrtl: severe (24): end-of-file during read, unit 201, file .../mn_wake00350.000.dat
Image              PC                Routine            Line        Source
a.out              0000000000405E19  Unknown               Unknown  Unknown
a.out              000000000041A7E4  Unknown               Unknown  Unknown
a.out              0000000000402B21  Unknown               Unknown  Unknown
a.out              00000000004025AE  Unknown               Unknown  Unknown
libc.so.6          00002AF5B95B8B25  Unknown               Unknown  Unknown
a.out              00000000004024A9  Unknown               Unknown  Unknown

 

What is even more strange: It works when not commenting out the file generation or when reading the array r at once.
(But this is not possible in my software - so I don't have any workaround...)

Regards

Melven

0 Kudos
1 Solution
Kevin_D_Intel
Employee
438 Views

This is a known issue that will be corrected in the next PSXE 2016 Update 4 release in the coming month. https://software.intel.com/en-us/articles/read-failure-unformatted-file-io-psxe-16-update-3

I don't know whether rolling back your version to Update 2 is a viable work around.

We apologize for the inconvenience.

View solution in original post

0 Kudos
1 Reply
Kevin_D_Intel
Employee
439 Views

This is a known issue that will be corrected in the next PSXE 2016 Update 4 release in the coming month. https://software.intel.com/en-us/articles/read-failure-unformatted-file-io-psxe-16-update-3

I don't know whether rolling back your version to Update 2 is a viable work around.

We apologize for the inconvenience.

0 Kudos
Reply