- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
According to The Fortran 2003 handbook (Adams, Brainerd, Hendricksson), p. 112, it should be possible to declare the type of an array as
[ type-spec :: ac-value-list ]
Apparently type specification is not supported by ifort. For instance, this code fails to compile:
>>>>>>>>>>>>>>>>>>>>>>>>>>
program test
implicit none
type a
integer :: b
end type
type(a) :: c(2)
c=[type(a) :: a(b=2),a(b=3)]
end program
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Am I doing something wrong? Are there plans to implement this feature?
According to The Fortran 2003 handbook (Adams, Brainerd, Hendricksson), p. 112, it should be possible to declare the type of an array as
[ type-spec :: ac-value-list ]
Apparently type specification is not supported by ifort. For instance, this code fails to compile:
>>>>>>>>>>>>>>>>>>>>>>>>>>
program test
implicit none
type a
integer :: b
end type
type(a) :: c(2)
c=[type(a) :: a(b=2),a(b=3)]
end program
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Am I doing something wrong? Are there plans to implement this feature?
Link Copied
7 Replies
- 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry, you are right. It should be TYPE(a). Escalated as DPD200166644.
There is no implicit type conversion in the language and the standard is quite explicit saying "C4105 (R 469) If type-spec specifies a derived type, all ac-value expressions in the array-constructor shall be of that derived type and shall have the same kind type parameters as specified by type-spec."
There is no implicit type conversion in the language and the standard is quite explicit saying "C4105 (R 469) If type-spec specifies a derived type, all ac-value expressions in the array-constructor shall be of that derived type and shall have the same kind type parameters as specified by type-spec."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for clearing that :) I guess that my first contribution was just being a bit of a quibbler...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The syntax you presented for the array-constructor in reply #1 (just "type-name ::", not "TYPE(type-name) ::") seems more consistent with the rules in the standard for an array-constructor.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is old news, but I now can confirm that the syntax that Steve mentioned ( [a ::], not [type(a) ::] ) is the correct one. So you can scrap DPD200166644.
Best regards,
Sergio
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My earlier reply was wrong. As you say, the legal syntax is a:: not type(a)::. Nevertheless, ifort doesn't like the valid syntax either, in my tests.
program U81063 type a character(3) :: s end type a type(a), dimension(2) :: c c = [a(s='FAI'),a(s='LED')] ! This is accepted c = [a :: a(s='PAS'),a(s='SED')] ! This fails print '(2A3)',c%s end program u81063
U81063.f90(10): error #5082: Syntax error, found '::' when expecting one of: , (/ : ]
c = [a :: a(s='PAS'),a(s='SED')] ! This fails
-------^
U81063.f90(10): error #6478: A type-name must not be used as a variable. c = [a :: a(s='PAS'),a(s='SED')] ! This fails

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