Skip to content
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

Remove duplicate declarations for external statements (fix #57) #404

Conversation

reuterbal
Copy link
Collaborator

Fortran's external-stmt allows to declare procedure symbols as external separate to their return type declaration. That makes it virtually impossible to determine that this return type declaration refers to a procedure rather than a local variable until the corresponding EXTERNAL statement has been encountered.

Because Fortran allows to represent this also as an attribute in the same declaration, we chose to represent this in Loki as external procedures in all cases. This means, we are replacing

        REAL :: ext_func
        EXTERNAL ext_func

by the equivalent representation

        REAL, EXTERNAL :: ext_func

The frontends already translated external statements to the procedure declaration with the EXTERNAL attribute but also left the original variable declaration in place, thus triggering the problem reported in #57.
In this PR, this behaviour is fixed via a sanitzation processing step that drops relevant symbols from the variable declarations.

@reuterbal reuterbal linked an issue Oct 14, 2024 that may be closed by this pull request
Copy link

Documentation for this branch can be viewed at https://sites.ecmwf.int/docs/loki/404/index.html

@reuterbal reuterbal force-pushed the 57-external-procedures-possibly-trigger-assertion-in-fgen-backend branch from a86376f to 0a7f68f Compare October 14, 2024 22:37
Copy link

codecov bot commented Oct 14, 2024

Codecov Report

Attention: Patch coverage is 96.87500% with 1 line in your changes missing coverage. Please review.

Project coverage is 96.02%. Comparing base (d90b5a7) to head (79e36b0).
Report is 20 commits behind head on main.

Files with missing lines Patch % Lines
loki/frontend/util.py 90.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #404   +/-   ##
=======================================
  Coverage   96.02%   96.02%           
=======================================
  Files         197      197           
  Lines       39023    39046   +23     
=======================================
+ Hits        37472    37495   +23     
  Misses       1551     1551           
Flag Coverage Δ
lint_rules 96.39% <ø> (ø)
loki 96.02% <96.87%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@mlange05 mlange05 left a comment

Choose a reason for hiding this comment

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

Looks good. GTG :shipit:

@mlange05 mlange05 added the ready for merge This PR has been approved and is ready to be merged label Oct 16, 2024
@reuterbal reuterbal force-pushed the 57-external-procedures-possibly-trigger-assertion-in-fgen-backend branch from 0a7f68f to 79e36b0 Compare October 17, 2024 08:58
@reuterbal reuterbal merged commit 1492d43 into main Oct 17, 2024
13 checks passed
@reuterbal reuterbal deleted the 57-external-procedures-possibly-trigger-assertion-in-fgen-backend branch October 17, 2024 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for merge This PR has been approved and is ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EXTERNAL (procedures) possibly trigger assertion in fgen backend
2 participants