- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I believe this program should produce an error and it does not
program testit
implicit none
character(len=:),allocatable :: s(:)
integer,allocatable :: i(:)
real,allocatable :: r(:)
allocate(character(len=20) :: s(10), i(10), r(10))
write(*,*)size(i),size(r),size(s),len(s)
end program testit
(test1) urbanjs@venus:~/github/bugs$ ifort x1.f90
(test1) urbanjs@venus:~/github/bugs$ ./a.out
10 10 10 20
If I try something with other mixed types in an ALLOCATE like
allocate(integer :: i(10),r(10))
I get an error like:
! x1.f90(7): error #8235: If type specification appears, the type and kind
! type parameters of each object being allocated must be the same as type
! and kind type parameters of the type specification. [R]
- Tags:
- Bug
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This bug is fixed in the latest Intel Fortran compiler:
$ ifort test.f90
test.f90(3): error #8235: If type specification appears, the type and kind type parameters of each object being allocated must be the same as type and kind type parameters of the type specification. [I]
allocate( character :: s, i )
--------------------------^
compilation aborted for test.f90 (code 1)
$ ifort -V
Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.8.0 Build 20221119_000000
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
allocate(integer :: size(i), size(r)) does not make sense to me, is that what you intended to write?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No. Something like "allocate(integer :: i(10), r(10))" where
integer,allocatable :: i(:)
real,allocatable :: r(:)
Just noting that other ALLOCATE(3f) statements do produce an error when a type-spec is present, but the one in the example code does not.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well, the first allocate you showed (allocate (character(30) :: ... ) allocates two character arrays, the type specification is for the length of the character strings, but each array is of the same basic type. That is not the case with the second one: you specify the type as integer, but the second array is a real array, so a different basic type.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
allocate(character(len=20) :: s(10), i(10), r(10))
is the line I am saying is non-standard, where S is character, I is integer, R is real, but there is a type-spec. Per the cited statement from the standard and after discussion on other forums that line is non-standard. If Ifort was providing an extension then I would expect other statements with mixed types to work also, but instead get an error message if the type-spec is INTEGER or REAL; indicating the line with the CHARACTER type-spec is being ignored inadvertently and that this is not an intentional extension.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Readers are encouraged to read this thread at Fortran Discourse site.
I do wish OP had gone with a really short illustration of the issue e.g.,
character(len=:), allocatable :: s
integer, allocatable :: i
allocate( character :: s, i )
end
Intel team: please note a support request #05231947 has already been submitted with this short case at the Intel OSC.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It is escalated to the Intel Fortran development team and should be fixed. Note that same behaviour is observed with ifx (LLVM based Fortran compiler).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This bug is fixed in the latest Intel Fortran compiler:
$ ifort test.f90
test.f90(3): error #8235: If type specification appears, the type and kind type parameters of each object being allocated must be the same as type and kind type parameters of the type specification. [I]
allocate( character :: s, i )
--------------------------^
compilation aborted for test.f90 (code 1)
$ ifort -V
Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.8.0 Build 20221119_000000

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page