- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There seems to be a bug with Intel Fortran 12.0.0 that didn't exist in version 11.1 with Allocate & the Source clause. With version 11.1 you could allocate an array with the source clause by defining bounds and have those bounds carry over into the new array. This doesn't happen with version 12.0.0. In version 12.0.0 the array bounds of the newly allocated array always start at 1. Please see the example code and the execution below:
david@david-GA:~/workspace/test$ ifort -v
Version 11.1
david@david-GA:~/workspace/test$ ifort test.f90
david@david-GA:~/workspace/test$ ./a.out
11 20
11 20
david@david-GA:~/workspace/test$ ifort -v
Version 12.0.0
david@david-GA:~/workspace/test$ ifort test.f90
david@david-GA:~/workspace/test$ ./a.out
1 10
11 20
Any thoughts?
[fortran]program test
implicit none
integer, allocatable, dimension(:) :: a, b
! ALLOCATE ARRAY A
allocate (a(10:20))
! ALLOCATE B WITH FORTRAN 2003 SOURCE CLAUSE
allocate (b, source=a(11:20))
print *,lbound(b,dim=1),ubound(b,dim=1) ! PRINT ARRAY BOUNDS (should be 11 to 20)
! DEALLOCATE TO START OVER
deallocate (b)
! ALLOCATE B FORTRAN 90 WAY WITHOUT SOURCE CLAUSE
allocate (b(11:20))
b = a(11:20)
print *,lbound(b,dim=1),ubound(b,dim=1) ! PRINT ARRAY BOUNDS (should be 11 to 20)
end program test[/fortran]
david@david-GA:~/workspace/test$ ifort -v
Version 11.1
david@david-GA:~/workspace/test$ ifort test.f90
david@david-GA:~/workspace/test$ ./a.out
11 20
11 20
david@david-GA:~/workspace/test$ ifort -v
Version 12.0.0
david@david-GA:~/workspace/test$ ifort test.f90
david@david-GA:~/workspace/test$ ./a.out
1 10
11 20
Any thoughts?
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It looks like ifort had a bug in version 11.1 that was fixed in version 12.0.0.
a(11:20) is an array section. The lbound of any array section is 1; the ubound of any array section is the size of the array in the corresponding dimension. Version 12.0.0 allocated b with the same lbound and ubound as the supplied source; version 11.1 didn't!
The fact that lbound(a(11:20)) is 1 rather than 11 surprises many people. That may be why the original implementation made that error.
-Kurt
a(11:20) is an array section. The lbound of any array section is 1; the ubound of any array section is the size of the array in the corresponding dimension. Version 12.0.0 allocated b with the same lbound and ubound as the supplied source; version 11.1 didn't!
The fact that lbound(a(11:20)) is 1 rather than 11 surprises many people. That may be why the original implementation made that error.
-Kurt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Too bad. I preferred the "incorrect" implementation.
![](/skins/images/3344F5B3B76C91485ED0E980FD0CA95E/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