Goddard-Fortran-Ecosystem / pFUnit

Parallel Fortran Unit Testing Framework
Other
169 stars 45 forks source link

compiler error: v1 and v2 getting mixed together? #463

Closed cferenba closed 6 days ago

cferenba commented 2 months ago

I'm trying to get pFunit compiling using the Cray CCE compiler, and I'm getting an odd error in the compile of FUnit_Core.F90:

ftn-487 ftn: ERROR FUNIT_CORE, File = ../../../../usr/WS2/cferenba/pFUnit/pFUnit-4.8.0/src/funit/core/FUnit_Core.F90, Line = 29, Column = 8 
  The specific interfaces for "M_NEW_MAP_EMPTY" and "MAP_NEW_MAP_EMPTY" make the GENERIC interface "STRINGUNLIMITEDMAP" ambiguous.

The offending source line is:

   use gFTL_StringUnlimitedMap

and the compile line that gave the error is:

/opt/cray/pe/craype/2.7.31.11/bin/ftn \
  -I/usr/WS2/cferenba/pFUnit/pFUnit-4.8.0/src/funit/core \
  -I/usr/WS2/cferenba/pFUnit/pFUnit-4.8.0/build-cce-17.0.1-ninja/src/funit/mod \
  -I/usr/WS2/cferenba/pFUnit/pFUnit-4.8.0/include \
  -I/usr/WS2/cferenba/pFUnit/pFUnit-4.8.0/build-cce-17.0.1-ninja/src/funit/core \
  -I/usr/WS2/cferenba/pFUnit/pFUnit-4.8.0/build-cce-17.0.1-ninja/extern/fArgParse/extern/gFTL-shared/extern/gFTL/include/v1 \
  -I/usr/WS2/cferenba/pFUnit/pFUnit-4.8.0/build-cce-17.0.1-ninja/extern/fArgParse/extern/gFTL-shared/src/v1/mod \
  -I/usr/WS2/cferenba/pFUnit/pFUnit-4.8.0/build-cce-17.0.1-ninja/extern/fArgParse/mod \
  -I/usr/WS2/cferenba/pFUnit/pFUnit-4.8.0/build-cce-17.0.1-ninja/extern/fArgParse/extern/gFTL-shared/extern/gFTL/include/v2 \
  -I/usr/WS2/cferenba/pFUnit/pFUnit-4.8.0/extern/fArgParse/extern/gFTL-shared/extern/gFTL/include/v2 \
  -I/usr/WS2/cferenba/pFUnit/pFUnit-4.8.0/build-cce-17.0.1-ninja/extern/fArgParse/extern/gFTL-shared/src/v2/mod \
  -g \
  -eZ \
  -O0 \
  -em \
  -em \
  -Jsrc/funit/mod \
  -h PIC \
  -c src/funit/core/CMakeFiles/funit-core.dir/FUnit_Core.F90-pp.f90 \
  -o src/funit/core/CMakeFiles/funit-core.dir/FUnit_Core.F90.o

As best I can tell, the issue is that there are two different (and incompatible) versions of the StringUnlimitedMap module being generated:

./extern/fArgParse/extern/gFTL-shared/src/v1/mod/GFTL_STRINGUNLIMITEDMAP.mod
./extern/fArgParse/extern/gFTL-shared/src/v2/mod/GFTL_STRINGUNLIMITEDMAP.mod

and somehow both of these are getting pulled into the build (note that the v1/mod and v2/mod paths are both showing up as include directories in the compile line above).

I'm not sure what to do about this. Is the build really supposed to include both v1 and v2 directories? And if so, how is the compiler supposed to disambiguate between them?

cferenba commented 2 months ago

I've done some more digging and I think I've found (at least part of) the answer to my own question:

I can see several ways the mismatch could be resolved. @tclune do you have a recommendation?

tclune commented 2 months ago

The build really is using both, but probably just for historical reasons. There is no Fortran issue with involving both v1 and v2 containers in the same executable so long as they are not both referenced in the same scope. (And even then, I've used Fortran rename without any major issues.) So this is definitely a compiler bug.

But I suspect a simple fix is to simply update FUnit to only use the V2 interfaces. Let me know if you want to attempt that yourself. The main difference with V2 for map is that instead of %key() and %value() it is now %first() and %second() to be more compatible with C++ STL. (But there are a few other gotchas.) If not, I can probably try it this weekend.

cferenba commented 2 months ago

But I suspect a simple fix is to simply update FUnit to only use the V2 interfaces. Let me know if you want to attempt that yourself.

I can try that. I'll let you know what happens.

cferenba commented 2 months ago

The conversion to V2 fixed the issue, thanks for the suggestion! I'll make a PR with the changes soon.

tclune commented 2 months ago

Great. I'm torn as to whether this should be a hotfix on main vs a new feature on develop branch. I lean towards the latter, as technically the bug is with the compiler ... I'll let you decide. Either way I'll propagate and get a new release out quickly.

Please be sure to add an entry in the ChangeLog.

cferenba commented 1 month ago

OK, changes are ready. This required a small change to gFTL-shared which is in Goddard-Fortran-Ecosystem/gFTL-shared#77. A PR for pFUnit will follow.

d7919 commented 1 month ago

Just to note that I see a related warning with gfortran 13.3.1

src/funit/core/FUnit_Core.F90:29:7:

   29 |    use gFTL_StringUnlimitedMap
      |       1
Warning: Although not referenced, ‘generic interface 'stringunlimitedmap'’ has ambiguous interfaces at (1)