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

Consider eliminating type(*) in the collective subroutines #132

Open
rouson opened this issue Sep 6, 2024 · 3 comments · May be fixed by #158
Open

Consider eliminating type(*) in the collective subroutines #132

rouson opened this issue Sep 6, 2024 · 3 comments · May be fixed by #158

Comments

@rouson
Copy link
Collaborator

rouson commented Sep 6, 2024

Fortran 2023 18.3.7 item 7 in the list on page 515 prohibits assumed-type, assumed-rank arguments without the value attribute.

@everythingfunctional
Copy link
Member

Based on reading of the standard, it looks like the path forward here has to do with separate procedures for different types, and to use select rank internally to dispatch to different bind(c) procedures. There's still work to do in figuring out exactly what that looks like, and is probably worth some conversations with some other committee members as well.

@bonachea
Copy link
Member

bonachea commented Sep 11, 2024

Some of my notes from today's meeting:

  • Probably need to bifurcate prif_co_{min,max} into _numeric and _character variants
  • a argument to _numeric can probably remain contiguous type(*)
  • a argument to _character is probably contiguous character with assumed-length
  • For ALL prif_co_*: internally we may need to use select rank to handle the assumed-rank at the Fortran level before hitting C
    • Which means we need 16 versions of each BIND(C) caf_ call, one for each possible rank
  • POST-CALL question:
    • can we just leverage the TARGET attribute and call C_LOC on the contiguous assumed-rank dummy arg to bypass the select rank mess?

@everythingfunctional
Copy link
Member

Taking a fresh look at this, I don't think it's a problem.

A Fortran procedure interface is interoperable with a C function prototype if
...
(5) any dummy argument without the VALUE attribute corresponds to a formal parameter of the prototype that is of a pointer type, and
...

  • the dummy argument is ... assumed-rank ..., and the formal parameter is a pointer to CFI_cdesc_t

That doesn't say that the dummy argument can't be assumed-type.

C716 An assumed-type actual argument that corresponds to an assumed-rank dummy argument shall be assumed-shape or assumed-rank.

That certainly implies that assumed-type dummy arguments can be assumed-rank.

If flang seems to have a problem with this, we should file a bug report.

@bonachea bonachea linked a pull request Dec 23, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants