- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am encountering strange behavior, probably due to optimization, in the following code:
program test
implicit none
integer :: n_x,ia
real,allocatable :: x(:)
n_x = 19
allocate(x(n_x))
do ia=1,9
x(10+ia) = real(ia-1) / real(n_x)
end do
x(1) = 0.
x(2) = 1.e-10
x(3) = 1.e-9
x(4) = 1.e-8
x(5) = 1.e-7
x(6) = 1.e-6
x(7) = 1.e-5
x(8) = 1.e-4
x(9) = 1.e-3
x(10) = 1.e-2
x(11) = 1.e-1
print *,x
end program test
When compiled with ifort test.f90, the output is
1.4699509E-39 1.4012985E-45 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 7.0064923E-45 0.0000000E+00 1.4012985E-45 0.0000000E+00
0.0000000E+00 5.2631579E-02 NaN NaN NaN
NaN 0.3157895 0.3684210 0.4210526
When compiled with ifort -O0 test.f90, the output is
0.0000000E+00 1.0000000E-10 9.9999997E-10 9.9999999E-09 1.0000000E-07
1.0000000E-06 9.9999997E-06 9.9999997E-05 1.0000000E-03 9.9999998E-03
0.0000000E+00 5.2631579E-02 0.1052632 0.1578947 0.2105263
0.2631579 0.3157895 0.3684210 0.4210526
(i.e. the correct output)
When compiled with ifort -check all test.f90 the output is also correct. Finally, if I comment out the following line:
x(11) = 1.e-1
then the code does produce the correct output when compiled with ifort test.f90:
0.0000000E+00 1.0000000E-10 9.9999997E-10 9.9999999E-09 1.0000000E-07
1.0000000E-06 9.9999997E-06 9.9999997E-05 1.0000000E-03 9.9999998E-03
0.0000000E+00 5.2631579E-02 0.1052632 0.1578947 0.2105263
0.2631579 0.3157895 0.3684210 0.4210526
Is this a compiler bug?I am using
ifort (IFORT) 11.1 20091130
Copyright (C) 1985-2009 Intel Corporation. All rights reserved.
Thanks for any help,
Thomas
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The reported behavior does not occur with 11.1.065 on Windows-32.
Are you, by some chance, running the compiler on OSX with one of the problematic versions of XCode? Please see Ron Green's sticky note at the top of the postings in this forum.
Are you, by some chance, running the compiler on OSX with one of the problematic versions of XCode? Please see Ron Green's sticky note at the top of the postings in this forum.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
mecej4 nailed it. You're using Xcode 3.2.2 and this Mac OS Fortran compiler:
$ ifort -V
Intel Fortran Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1 Build 20091130 Package ID: m_cprof_p_11.1.080
Copyright (C) 1985-2009 Intel Corporation. All rights reserved.
$ ifort --version
ifort (IFORT) 11.1 20091130
Copyright (C) 1985-2009 Intel Corporation. All rights reserved.
--version is almost inadequate, so I advise using -V
As suggested in the sticky post mecej4 referred to here, your available work arounds (also discussed in the Knowledge Base article here) are to downgrade to Xcode 3.2.1 or compile with -use-asm.
Good work mecej4!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your quick replies! Using -use-asm does indeed fix this.
Thomas
![](/skins/images/9701FEC4E90D143B667C09F3DB2F340F/responsive_peak/images/icon_anonymous_message.png)
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page