- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I just stumbled upon some weird behavior in ifort 19.1.0.166 on CentOS 7. I am not entirely sure if this is a bug with the compiler or if it's non-standard Fortran so I wanted to ask here. Below is a MWE that illustrates the issue:
program test
implicit none
integer, allocatable :: a(:), b1(:), b2(:, :)
b1 = [2, 1]
b2 = reshape([1, -1, -2, -3, -4, 2, -5, -6, -7, -8], [5, 2])
a = b1(b2(1, :))
write(*, *) shape(a), "|", a
end program test
What's important is that the output of this program depends on whether one uses runtime checks (-C) or not. Basically, we use b2(1,
2 | 2 1
However, after enabling runtime checks, the output changes to:
1 | 2
Is there something wrong with the code? I do believe all of this should be valid Fortran (2003).
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would say it is conforming. I can also confirm that the program works with Intel Fortran 2018, with and without -C (or -check:all). I get the same answer. gfortran also accepts it and produces the same output.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I traced the issue down to -check shape. It's embedded in -C.
Here's a workaround
+ ifort -C -check noshape c.f90
+ a.out
2 | 2 1
I filed a bug on your behalf, CMPLRIL0-33624. I'll let you know when there's a fix.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is fixed in the latest compiler release, 2021.2.0. It was made available last week. Please give it a try.
$ GO
ifort (IFORT) 2021.2.0 20210228
Copyright (C) 1985-2021 Intel Corporation. All rights reserved.
+ ifort -C c.f90
+ a.out
2 | 2 1
+ ifort -C -check noshape c.f90
+ a.out
2 | 2 1
+ ifort -check shape c.f90
+ a.out
2 | 2 1

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page