- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm dealing with code that has heavy amount of declarations such as
integer(4) :: x[allocatable](:),i
where attributes are put in square brackets after the identifier, and several identifiers that may not share the same attributes are grouped together.
I firstly wanted to make sure the example above is 1-to-1 desugaring into:
integer(4), allocatable:: x(:)
integer(4) :: i
or if I'm misunderstanding something.
I'd also like to understand which attributes are valid in the context shown in the first example and if there is documentation about the compiler even supporting this syntax.
For example, this page of the documentation doesn't seem to indicate this placement is possible:
How does the parser disambiguates with things that can also appear in square bracket after the identifier? I think co-array notation fits this, and maybe there are other things.
How is this notation called?
The reason I'm trying to understand this is that I intend to contribute updates to https://github.com/camfort/fortran-src so it can support parsing properly the code leveraging this into the AST, and if users desires, pretty-print the appropriate standard notation.
I'm sorry if I'm misguided, thanks for any insights!
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have never seen that syntax before and the use of square brackets like this would probably introduce an ambiguity, as square brackets are also used for coarrays. Do you know where the code originated? More specifically, what compiler?
As far as I can tell, not knowing this peculiar syntax, your desugared example seems correct. The allocatable argument is definitely for x only. It resembles in that respect the specification of string lengths:
character*20 x, y*40
you can find in FORTRAN 77 code - the attributes stick to the variable, they do not carry over to all other variables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Arjen, It is proprietary codebase that probably stem from being built with DEC Visual Fortran lineage.
Now that I prompted ChatGPT, apparently, those attributes are supported in same placement:
allocatable, automatic, static, volatile, asynchronous and threadprivate.
I think things are lining up so my understanding is at least a bit more self confident
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Definitely not standard Fortran. Ifort gives a standards warning BTW. Never seen that before.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It actually comes from Microsoft Fortran PowerStation; I had thought that had been removed from the Intel compiler years ago, but I guess not.

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