- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
% ifort -o bob bob.f90; ./bob
1.000000 -2.000000 3.000000 -4.000000 5.000000
-6.000000
All the numbers should be positive.
program bob
real, dimension(6) :: ta
ta(1)=-1
ta(2)=-2
ta(3)=-3
ta(4)=-4
ta(5)=-5
ta(6)=-6
ta(6)=6
ta(5)=5
ta(4)=4
ta(3)=3
ta(2)=2
ta(1)=1
write(*,*) ta(1), ta(2), ta(3), ta(4), ta(5), ta(6)
end program bob
Link Copied
- 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
user@fwhpctest:~> /appserv/intel/fce/10.1.021/bin/ifort -o bob bob.f90
user@fwhpctest:~> ./bob
1.000000 2.000000 -3.000000 4.000000 -5.000000
6.000000
user@fwhpctest:~> uname -a
Linux fwhpctest 2.6.16.60-0.42.10-smp #1 SMP Tue Apr 27 05:11:27 UTC 2010 x86_64 x86_64 x86_64 GNU/Linux
- 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
A 'regular user' caught this problem and made a big stink, so I thought I'd try to do some damage control by offering a reasonable explanation, followed by "upgrade to 11.x and it will fix the problem".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The root cause is a defect in the middle-end optimizer (at O1 and higher which is why O0 works) that incorrectly reorders the assignments.
Depending on the 10.1 version used the re-ordering may differ slightly (note that your 10.1.008 and 10.1.021 results are both incorrect but different). The line numbers below are the original line numbers as reordered when using 10.1.008.
1program bob
2 real, dimension(6) :: ta
3 ta(1)=-1
14ta(1)=1
13ta(2)=2
4 ta(2)=-2
5 ta(3)=-3
12 ta(3)=3
11 ta(4)=4
6 ta(4)=-4
7 ta(5)=-5
10 ta(5)=5
9 ta(6)=6
8 ta(6)=-6
15 write(*,*) ta(1), ta(2), ta(3), ta(4), ta(5), ta(6)
16 end program bob
Note the incorrect placement of lines 13, 11, and 8 leading to negative values. Which produces the following incorrect results.
$ ifort -V -o bob bob.f90;./bob
Intel Fortran Compiler for applications running on Intel 64, Version 10.1 Build 20070913 Package ID: l_fc_p_10.1.008
Copyright (C) 1985-2007 Intel Corporation. All rights reserved.
Intel Fortran 10.0-2024
GNU ld version 2.17.50.0.6-5.el5 20061020
1.000000 -2.000000 3.000000 -4.000000 5.000000
-6.000000
From testing many compilers it appears this was fixed in the initial 11.1 Release, Version 11.1 Build 20090630 (Linux:l_cprof_p_11.1.046)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page