Skip to content

[Flang] Add a Fortran Standards Support doc #132195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Apr 24, 2025

Conversation

kiranchandramohan
Copy link
Contributor

No description provided.

@llvmbot llvmbot added the flang Flang issues not falling into any other category label Mar 20, 2025
Copy link
Contributor

@mjklemm mjklemm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, with the few nits that I have commented on.

I guess we should see if we can get a list of updates from J3/WG5 for 2018 and 2023 Fortran to populate the list. We also should list intrinsic functions explicitly if there are supported (or not).

Standards support is provided upto Fortran 2008 for now. It will be later extended for Fortran 2018 and Fortran 2023.

The standards support information is provided as a table with three columns that are self explanatory. The Status column uses
the letters **P**, **Y**, **N** for the various implementation status.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
the letters **P**, **Y**, **N** for the various implementation status.
the letters **P**, **Y**, **N** for the implementation status:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


-->

# Flang's Fortran standards support
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Flang's Fortran standards support
# Flang Fortran Standards Support

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

@tarunprabhu tarunprabhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Kiran. Just a few nits and comments.

Comment on lines 17 to 18
This document summarizes Flang's Fortran standards support. The information is only provided as a guideline. The compiler emits
TODOs/Not Yet Implemented messages for unimplemented features and that should be treated as the authoratative information.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This document summarizes Flang's Fortran standards support. The information is only provided as a guideline. The compiler emits
TODOs/Not Yet Implemented messages for unimplemented features and that should be treated as the authoratative information.
This document summarizes Flang's Fortran standards support. The information is only provided as a guideline. The
TODOs/Not Yet Implemented messages emitted by the compiler for unimplemented features should be treated as authoritative.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


This document summarizes Flang's Fortran standards support. The information is only provided as a guideline. The compiler emits
TODOs/Not Yet Implemented messages for unimplemented features and that should be treated as the authoratative information.
Standards support is provided upto Fortran 2008 for now. It will be later extended for Fortran 2018 and Fortran 2023.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Standards support is provided upto Fortran 2008 for now. It will be later extended for Fortran 2018 and Fortran 2023.
Standards support is provided upto Fortran 2008 for now. It will be extended later for Fortran 2018 and Fortran 2023.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"upto" should be "up to"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have removed this sentence.

- **N** : When the implementation is absent

Note 1 : No distinction is made between the support in the Parser/Semantics and MLIR or Lowering support.
Note 2 : Besides the features listed below a few intrinsics like MIN/MAX are not supported for a few cases with CHARACTER type.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a list of the intrinsics where support for CHARACTER types is incomplete? If it is not too difficult to identify these, a complete list may be better than alluding to "a few intrinsics".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not have a list of intrinsics here. The only ones I am actually aware or the MIN/MAX intrinsic. Since I was not 100% I am making a conservative statement here. Do we want to just say MIN/MAX only? Do you have additional info in the gfortran testsuite?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can check to see if there are any failures as a result of this. I don't know off the top of my head.

---
```

This document summarizes Flang's Fortran standards support. The information is only provided as a guideline. The compiler emits
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we take the suggested change above, should we also remove 's here? Or just rephrase it to:

This document summarizes Fortran standards support in Flang.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Note 1 : No distinction is made between the support in the Parser/Semantics and MLIR or Lowering support.
Note 2 : Besides the features listed below a few intrinsics like MIN/MAX are not supported for a few cases with CHARACTER type.

## Fortran 77
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FORTRAN 77 - consistent with what we use in FortranFeatureHistory.md

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


Note 1 : No distinction is made between the support in the Parser/Semantics and MLIR or Lowering support.
Note 2 : Besides the features listed below a few intrinsics like MIN/MAX are not supported for a few cases with CHARACTER type.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since all the contents in the first three sections are the same, I suggest to consolidate to the FORTRAN77, Fortran 90 and Fortran 95 section. In addition, if we take Michael's suggestion to populate the Fortran 2018 and Fortran 2023 sections, I suggest to re-order the sections to start with Fortran 2023 first. I think people are more interested in which newer features that flang support nowadays.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reorganized in descending order of standards. I do not have entries for 2018 and 2023 now. If it is OK, we can add that in subsequent PRs.
I have not consolidated FORTRAN77, Fortran 90 and Fortran 95. I can do so before submitting if there are no reports of unsupported features in this review.

Copy link
Contributor

@DanielCChen DanielCChen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. A couple of nits added inline.


| Feature | Status | Comments |
|------------------------------------------------------------|--------|---------------------------------------------------------|
| Parameterized Derived Types | P | PDT with length type is not supported. See [Proposal](ParameterizedDerivedTypes.md) |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

length type => length type parameters

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

| Parameterized Derived Types | P | PDT with length type is not supported. See [Proposal](ParameterizedDerivedTypes.md) |
| Assignment to allocatable | P | Assignment to whole allocatable in FORALL is not implemented |
| Pointer Assignment | P | Polymorphic assignment in FORALL is not implemented |
| The VOLATILE attribute | P | Volatile in procedure interfaces is not implemented |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Volatile => VOLATILE
as it refers to the attribute.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@klausler klausler removed their request for review March 20, 2025 16:09
@ceseo
Copy link
Contributor

ceseo commented Mar 20, 2025

This looks very good! Do you plan to do the same for Flang+OpenMP as well?

Copy link
Contributor

@tblah tblah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for putting this together Kiran

Copy link
Contributor Author

@kiranchandramohan kiranchandramohan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed review comments.


-->

# Flang's Fortran standards support
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

---
```

This document summarizes Flang's Fortran standards support. The information is only provided as a guideline. The compiler emits
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 17 to 18
This document summarizes Flang's Fortran standards support. The information is only provided as a guideline. The compiler emits
TODOs/Not Yet Implemented messages for unimplemented features and that should be treated as the authoratative information.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


This document summarizes Flang's Fortran standards support. The information is only provided as a guideline. The compiler emits
TODOs/Not Yet Implemented messages for unimplemented features and that should be treated as the authoratative information.
Standards support is provided upto Fortran 2008 for now. It will be later extended for Fortran 2018 and Fortran 2023.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Standards support is provided upto Fortran 2008 for now. It will be later extended for Fortran 2018 and Fortran 2023.

The standards support information is provided as a table with three columns that are self explanatory. The Status column uses
the letters **P**, **Y**, **N** for the various implementation status.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

- **N** : When the implementation is absent

Note 1 : No distinction is made between the support in the Parser/Semantics and MLIR or Lowering support.
Note 2 : Besides the features listed below a few intrinsics like MIN/MAX are not supported for a few cases with CHARACTER type.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not have a list of intrinsics here. The only ones I am actually aware or the MIN/MAX intrinsic. Since I was not 100% I am making a conservative statement here. Do we want to just say MIN/MAX only? Do you have additional info in the gfortran testsuite?

Note 1 : No distinction is made between the support in the Parser/Semantics and MLIR or Lowering support.
Note 2 : Besides the features listed below a few intrinsics like MIN/MAX are not supported for a few cases with CHARACTER type.

## Fortran 77
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


| Feature | Status | Comments |
|------------------------------------------------------------|--------|---------------------------------------------------------|
| Parameterized Derived Types | P | PDT with length type is not supported. See [Proposal](ParameterizedDerivedTypes.md) |
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

| Parameterized Derived Types | P | PDT with length type is not supported. See [Proposal](ParameterizedDerivedTypes.md) |
| Assignment to allocatable | P | Assignment to whole allocatable in FORALL is not implemented |
| Pointer Assignment | P | Polymorphic assignment in FORALL is not implemented |
| The VOLATILE attribute | P | Volatile in procedure interfaces is not implemented |
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@kiranchandramohan
Copy link
Contributor Author

I guess we should see if we can get a list of updates from J3/WG5 for 2018 and 2023 Fortran to populate the list.

I am leaving this for a future patch. 2023 should be fairly straightforward. I do not have the data for Fortran 2018.

We also should list intrinsic functions explicitly if there are supported (or not).

Agree, ATM I do not have this data.

This looks very good! Do you plan to do the same for Flang+OpenMP as well?

Yes.

@klausler
Copy link
Contributor

I guess we should see if we can get a list of updates from J3/WG5 for 2018 and 2023 Fortran to populate the list.

I am leaving this for a future patch. 2023 should be fairly straightforward. I do not have the data for Fortran 2018.

f18 has all of F'2018 except coshape intrinsic lowering.

F'2023 support is completely absent and nobody is working on it.

@kiranchandramohan
Copy link
Contributor Author

Thanks @klausler for the info. I will add sections for Fortran 2018 and 2023.

I guess we should see if we can get a list of updates from J3/WG5 for 2018 and 2023 Fortran to populate the list.

I am leaving this for a future patch. 2023 should be fairly straightforward. I do not have the data for Fortran 2018.

f18 has all of F'2018 except coshape intrinsic lowering.

Is there a specific reason you called out the coshape intrinsic? I see the other coarray extensions in Fortran 2018 hitting TODOs in lowering.

F'2023 support is completely absent and nobody is working on it.

A few of them seem to have support
-> Allow much longer statement lines and overall statement length
-> selected_logical_kind
-> do-concurrent reduction

@klausler
Copy link
Contributor

Thanks @klausler for the info. I will add sections for Fortran 2018 and 2023.

I guess we should see if we can get a list of updates from J3/WG5 for 2018 and 2023 Fortran to populate the list.

I am leaving this for a future patch. 2023 should be fairly straightforward. I do not have the data for Fortran 2018.

f18 has all of F'2018 except coshape intrinsic lowering.

Is there a specific reason you called out the coshape intrinsic? I see the other coarray extensions in Fortran 2018 hitting TODOs in lowering.

I skimmed my notes of F'2018 additions and coshape stood out as the one item that I know isn't fully supported. If other coarray features from F'2018 are incomplete, please note them as well. Some were added as part of a TS between F'2008 and F'2018 so that makes them a little harder to find.

F'2023 support is completely absent and nobody is working on it.

A few of them seem to have support -> Allow much longer statement lines and overall statement length -> selected_logical_kind -> do-concurrent reduction

Fair enough. The lack of limits on continuation lines and statement length have always been present, so I never thought of them as new features. But F'2023 was a minor revision, and includes some weird features (e.g. @ subscripts) and a breaking change that don't appear in any compiler or (obviously) application yet, and that probably won't get any attention from me -- although I did add a portability warning for the breaking change. If you add a section for F'2023, it's going to be largely unpopulated.

Copy link
Collaborator

@kkwli kkwli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.


## Fortran 2018
All features except those listed in the following table are supported. Almost all of the unsupported features are related to
coarrays.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
coarrays.
multi-image execution.

Many multi-image parallel features have do not necessarily involve coarrays (e.g., collective subroutines and teams).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly to how the parallel support for do concurrent is described below as in progress, please state the support for multi-image features is in progress.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I now have the following sentence:

 Almost all of the unsupported features are related to the additional parallel features (coarrays/teams/collectives).

The support status of collectives and teams are individually called out in the status table for Fortran 2018.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kiranchandramohan thanks for making the edits. "Parallel features" could be interpreted to include parallelization of do concurrent so I'd still suggest "multi-image" to replace "parallel."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Made the suggested change.

@rouson
Copy link
Contributor

rouson commented Mar 24, 2025

I guess we should see if we can get a list of updates from J3/WG5 for 2018 and 2023 Fortran to populate the list. We also should list intrinsic functions explicitly if there are supported (or not).

@mjklemm the list of changes is in the Introduction to the Fortran 2023 Interpretation Document.


## Fortran 2018
All features except those listed in the following table are supported. Almost all of the unsupported features are related to
coarrays.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly to how the parallel support for do concurrent is described below as in progress, please state the support for multi-image features is in progress.

| Using integer arrays to specify subscripts | N | |
| Using integer arrays to specify rank and bound of an array | N | |
| Using an integer constant to specify rank | N | |
| Reduction specifier for do concurrent | Y | |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is still in progress. @ergawy can confirm. Should the status be N or P?

Copy link
Member

@ergawy ergawy Mar 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is supported for the pure Fortran case, for the do concurrent -> OpenMP case (or do concurrent parallelization in general), this is not supported yet. So I think @kiranchandramohan is indeed correct here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @ergawy mentions, this is supported for the sequential Fortran case.
But I understand @rouson 's point that this might cause a user to think that reduction works in a parallel sense. So I am changing it to P (partial).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kiranchandramohan actually I hadn't thought about the difference between serial support and parallel support. My point was that I didn't even realize that serial support for reduce existed yet on the main branch of llvm-project. I'm building flang now and will try it out. If serial support works, then I think either "Y" or "P" is fine and I leave it up to you to decide.

Copy link
Contributor

@mleair mleair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Looks like you used the following document for the Fortran 2023 features:

https://wg5-fortran.org/N2201-N2250/N2212.pdf

You may also want to pull in the features from the Fortran 2008/2018 Compiler
Conformance charts that Ian Chivers and Jane Sleightholme were compiling. You can find them at https://www.fortranplus.co.uk/fortran-information/

@kiranchandramohan
Copy link
Contributor Author

LGTM. Looks like you used the following document for the Fortran 2023 features:

https://wg5-fortran.org/N2201-N2250/N2212.pdf

You may also want to pull in the features from the Fortran 2008/2018 Compiler Conformance charts that Ian Chivers and Jane Sleightholme were compiling. You can find them at https://www.fortranplus.co.uk/fortran-information/

Thanks, Mark. I have added references to the What is new in Fortran 2023 and 2018 Fortran documents. I believe the Compiler Conformance charts are based on these documents.

I plan to submit this PR on Tuesday if there are no objections.

@sscalpone sscalpone requested a review from klausler April 19, 2025 17:59
@sscalpone
Copy link
Contributor

Hi Kiran, apologies for late comments. I hope they are relatively minor additions if you choose to incorporate them.

For the missing 2018 features, in the comment column, it would help to add "coarrays" or similar to highlight that the major missing feature is coarrays and a lot of gaps.

It might be nice to call out at the top of the doc that the major missing features are coarrays and PDT with length type parameters. If you agree these are the only major missing features.

Thank you!

@kiranchandramohan
Copy link
Contributor Author

Thanks Steve for the review.

For the missing 2018 features, in the comment column, it would help to add "coarrays" or similar to highlight that the major missing feature is coarrays and a lot of gaps.

Added "Multi-image/Coarray feature" in the comment column.

It might be nice to call out at the top of the doc that the major missing features are coarrays and PDT with length type parameters. If you agree these are the only major missing features.

Added a Note in the first section.

Note: The two major missing features in Flang at present are coarrays and parameterized derived types (PDTs) with length type parameters.

Changes are in 04fb498

- **Y** : When the implementation is complete
- **N** : When the implementation is absent

There is no distinction made between support in the Parser/Semantics and the MLIR or Lowering stages.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence is now repeated (just above the P/Y/N there's an equivalent one).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Removed the former occurence.

Comment on lines 22 to 25
the letters **P**, **Y**, **N** for the implementation status:
- **P** : When the implementation is incomplete for a few cases
- **Y** : When the implementation is complete
- **N** : When the implementation is absent
Copy link
Contributor

@h-vetinari h-vetinari Apr 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think we should make this easier for readers (explain the letters, order them by degree of completion)

Suggested change
the letters **P**, **Y**, **N** for the implementation status:
- **P** : When the implementation is incomplete for a few cases
- **Y** : When the implementation is complete
- **N** : When the implementation is absent
the letters **Y**, **P**, **N** for the implementation status:
- **Y** (Yes): When the implementation is complete
- **P** (Partial): When the implementation is incomplete
- **N** (No): When the implementation is absent

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. The following format was used.

- **Y** : Yes. When the implementation is complete

@kiranchandramohan kiranchandramohan merged commit 45a3056 into llvm:main Apr 24, 2025
12 checks passed
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
Ankur-0429 pushed a commit to Ankur-0429/llvm-project that referenced this pull request May 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.