- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When I use the program
program subscript_array_test IMPLICIT NONE integer, allocatable :: mat (:, :) INTEGER :: loop allocate (mat (5, 5)) mat = reshape ([(loop, loop = 1, 25)], [5, 5]) print *, mat print *, [mat([3, 1, 5, 4, 2], 1 : 5)] mat = mat([3, 1, 5, 4, 2], 1 : 5) print *, mat if (allocated (mat)) deallocate (mat) end program subscript_array_test
with compiler options
ifort -m64 -O0 -g -traceback -check all -warn all -debug all -ftrapuv -stand f18 -c subscript_array_test.f90 ifort subscript_array_test.o -m64 -O0 -g -traceback -check all -warn all -debug all -ftrapuv -stand f18 -o subscript_array_test.x
in version 19.0.4.243 of the ifort compiler, I get the result
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 3 1 5 4 2 8 6 10 9 7 13 11 15 14 12 18 16 20 19 17 23 21 25 24 22 3 1 5 4 2 -858993460 -858993460 -858993460 -858993460 -858993460 -858993460 -858993460 -858993460 -858993460 -858993460 -858993460 -858993460 -858993460 -858993460 -858993460 -858993460 -858993460 -858993460 -858993460 -858993460
This is surprising to me, I would have expected the same output from the second and third print statement, or at least a warning. Is there an elegant way to change the order of columns in a matrix, or do I have to do it with a loop over all rows?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try: mat = [mat([3, 1, 5, 4, 2], 1 : 5)]
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@jimdempseyatthecove: That can't work because you are trying to assign a 1-d expression to a 2-d array.
Both gfortran and ifort 16.0 get this right so the results as displayed are a regression.
BTW, the code given permutes rows, not columns.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Repeat Offender wrote:Both gfortran and ifort 16.0 get this right so the results as displayed are a regression.
Indeed, I remember this working as intended some time back. So is this a bug in ifort version 19?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, PSXE2019u3 and u5 (Windows) as well as gfortran 9.2 (Linux) print the expected results. I compiled with default compiler options. I never have installed u4, so I can't check. Mighbe only u4 has this regression? Have you tried to compile with default compiler options?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
johannes k. wrote:Hi, PSXE2019u3 and u5 (Windows) as well as gfortran 9.2 (Linux) print the expected results. I compiled with default compiler options. I never have installed u4, so I can't check. Mighbe only u4 has this regression? Have you tried to compile with default compiler options?
I just checked.
The
-check all
flag causes the unexpected behaviour.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oops, replace the enclosing []'s with ()'s
mat = (mat([3, 1, 5, 4, 2], 1 : 5))
This works...
... note, 2019u3 it also works without the ()'s, but the ()'s compile without error.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
*** adding -check all causes the error to show up even with the ()'s
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
jimdempseyatthecove (Blackbelt) wrote:Oops, replace the enclosing []'s with ()'s
mat = (mat([3, 1, 5, 4, 2], 1 : 5))
This works...
... note, 2019u3 it also works without the ()'s, but the ()'s compile without error.
Jim Dempsey
This is now valid code, but it still outputs the same as in the original post.
The issue here lies in the -check all compiler flag
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Strange that this compiler flag corrupts the results. In PSXE2019u5 the bug is still present. PSXE2017u6 and PSXE2018u3 works fine. The regression seems to be introduced with PSXE2019 family.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page