Fixes for flang in MOM_remapping.F90#1692
Conversation
adcroft
left a comment
There was a problem hiding this comment.
I agree that it fixes #1689 and I get the gist of the change. It's short and sweet, but it could be even shorter. How about if renaming the local variables in remapping_unit_tests()? There, they are declared once and used once, whereas this PR currently renames the import at the top of the module, changes the allocation in setReconstructionType(), and then changes the local declaration remapping_unit_tests().
src/ALE/MOM_remapping.F90
Outdated
| type(PPM_hybgen) :: PPM_hybgen | ||
| type(PPM_CWK) :: PPM_CWK | ||
| type(EPPM_CWK) :: EPPM_CWK | ||
| type(PCM_t) :: PCM |
There was a problem hiding this comment.
This variable is used once at line 2727. If (e.g.) you changed this line (2098) to
type(PCM) :: PCM_r
then line 2727 becomes
call test%test( PCM_r%unit_tests(verbose, test%stdout, test%stderr), 'PCM unit test')
and there will be overall fewer changes, and no need to rename types when importing them or allocating them.
There was a problem hiding this comment.
@adcroft Since I wasn't sure of the right style you'd like, for now I've pushed:
type(PCM) :: PCM_instanceso I don't forget. I can change it to whatever you'd like easily
When something like this came up for AMD a year or so ago, this is how we decided to resolve the issue. As for the naming, I'd prefer not to see |
Ohhh. As a non C-programmer, I didn't think of that. Well, if you all can figure out a good strategy, I'm willing to try it out. NOTE: I haven't actually tried to run MOM6 yet. I've been fiddling with compile flags with our boring data-ocean model at the moment trying to get some sort of performance I like. I'm going to try today as I think I figured out a good first set of flags. |
|
That is, I can test whatever you'd like as a rename:
I just wasn't sure if there was an "official" MOM standard of how to name instances of types, etc. 🙂 |
Well, I just tried and it failed, but not due to MOM. I think I'm made a mistake using MPICH on discover. With MOM6 I got: Maybe GEOS + MOM6 does enough comm_dup's to kill off MPICH? Not sure. Time for Open MPI! |
|
As background, this usage (host-associated type name followed by local declaration of the same name) is intentionally not allowed in flang-new. It's just not because it's non-conforming (there's 100s of things in Fortran that aren't, but are portable and unambiguous), but because it seems inherently unsafe. Fortran allows the name of a type to appear in |
|
@klausler It might actually be a Standards Violation. Per Steve Lionel on the ifx forum:
So I think flang is doing the right thing! Just some compilers aren't. |
Well, I'm doing the conforming thing, yes though that's not often the right thing in all cases for Fortran. The language is really defined by what its eight or more surviving compilers actually do than it is by its standard document. I'm dubious anyway that derived type names really need to be in the same "class" as most other things, since one can always tell from syntax whether a name is being used as one or not (and other kinds of names could also be their own classes for the same reason, like construct names). And even standard Fortran allows some names to coexist in the same scope and mean more than one thing, which is really troublesome for implementors while not being terribly useful for users. The problem here for me is entirely about a host-associated name conflicting with a local definition. If some compiler allowed a type name and variable name to be the same in some scope without misusing host association, I'd have to handle it. But none does. |
|
Thanks for the detailed explanation @klausler. As you say, the value of |
Closes #1689
This PR fixes #1689 by renaming the instance of a type. Fortran does not allow (or is unhappy with):
type(PCM) :: PCMBoth
ifort/ifxand GNU seem to allow this, but stricter compilers likenagforandflangdo not.So we do:
type(PCM) :: PCM_instanceand then rename the variable use below, e.g.:
NOTE: GEOS does not build all of MOM6, for example, the NUOPC code, but we do a good chunk. This was the only error Flang flagged.