- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
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?
- Balises:
- Intel® Fortran Compiler
Lien copié
2 Réponses
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
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
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Too bad. I preferred the "incorrect" implementation.

Répondre
Options du sujet
- S'abonner au fil RSS
- Marquer le sujet comme nouveau
- Marquer le sujet comme lu
- Placer ce Sujet en tête de liste pour l'utilisateur actuel
- Marquer
- S'abonner
- Page imprimable