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

PUBLIC statement disappear, USE module chain failing #97

Open
clementval opened this issue Oct 26, 2018 · 1 comment
Open

PUBLIC statement disappear, USE module chain failing #97

clementval opened this issue Oct 26, 2018 · 1 comment

Comments

@clementval
Copy link
Collaborator

clementval commented Oct 26, 2018

Original code

The following modules can be compiled without error by gfortran-7

MODULE mo_math_types
    IMPLICIT NONE
    PRIVATE
    PUBLIC :: t_cartesian_coordinates
    TYPE t_cartesian_coordinates
        REAL :: x(3)
    END TYPE t_cartesian_coordinates
END MODULE mo_math_types
MODULE mo_math_utilities
  USE mo_math_types
  IMPLICIT NONE
  PRIVATE
  PUBLIC :: t_cartesian_coordinates
CONTAINS
  FUNCTION cc2tv(xx) result (tt)
    TYPE(t_cartesian_coordinates), INTENT(in) :: xx
    REAL :: tt
  END FUNCTION cc2tv
END MODULE mo_math_utilities
MODULE mod1
  USE mo_math_utilities,      ONLY: t_cartesian_coordinates
END MODULE mod1

Transformed code

After transformation, the type t_cartesian_coordinates is not seen anymore in the module mod1 because the PUBLIC :: t_cartesian_coordinates from the module mo_math_utilities has been removed.

MODULE mo_math_types
 TYPE , PUBLIC :: t_cartesian_coordinates
  REAL :: x ( 1 : 3 )
 END TYPE t_cartesian_coordinates
END MODULE mo_math_types
MODULE mo_math_utilities
 USE mo_math_types
 PRIVATE :: cc2tv
CONTAINS
 FUNCTION cc2tv ( xx ) RESULT(tt)
  TYPE ( t_cartesian_coordinates ) , INTENT(IN) :: xx
  REAL :: tt
 END FUNCTION cc2tv
END MODULE mo_math_utilities
MODULE mod1
  USE mo_math_utilities,      ONLY: t_cartesian_coordinates
END MODULE mod1

All the tests are using the -fmodule-private flags as it is the case in ICON.

Solution

The single PUBLIC statements should be kept in the transformed code as they have an important meaning in the USE modules chain.

@clementval
Copy link
Collaborator Author

clementval commented Oct 26, 2018

@h-murai any idea how we could tackle this problem?

My first idea would be to have explicit PUBLIC/PRIVATE statement declaration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant