vapaa icon indicating copy to clipboard operation
vapaa copied to clipboard

CMake + NAG Fortran build issue

Open ivan-pi opened this issue 8 months ago • 6 comments

Trying to build with nagfor and OpenMPI, I encounter the issue:

~/vapaa-jh/build> cmake .. -DCMAKE_Fortran_COMPILER=/lrz/sys/compilers/nag/7.2/bin/nagfor -DMPI_VENDOR=OPEN_MPI
-- The Fortran compiler identification is NAG 7.2.7203
-- The C compiler identification is GNU 13.2.0
-- Detecting NAG Fortran directory
-- Detecting NAG Fortran directory - /dss/lrzsys/sys/compilers/nag/7.2/lib
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: /lrz/sys/compilers/nag/7.2/bin/nagfor - skipped
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /dss/lrzsys/sys/spack/release/24.4.0/opt/x86_64/gcc/13.2.0-gcc-j6fttbw/bin/gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Found MPI_C: /dss/lrzsys/sys/spack/release/24.4.0/opt/icelake/openmpi/5.0.5-gcc-f2f442m/lib/libmpi.so (found version "3.1") 
-- Could NOT find MPI_Fortran (missing: MPI_Fortran_WORKS) 
CMake Error at /dss/lrzsys/sys/spack/release/23.1.0/opt/x86_64/cmake/3.26.3-gcc-gesqvgr/share/cmake-3.26/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find MPI (missing: MPI_Fortran_FOUND) (found version "3.1")
Call Stack (most recent call first):
  /dss/lrzsys/sys/spack/release/23.1.0/opt/x86_64/cmake/3.26.3-gcc-gesqvgr/share/cmake-3.26/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  /dss/lrzsys/sys/spack/release/23.1.0/opt/x86_64/cmake/3.26.3-gcc-gesqvgr/share/cmake-3.26/Modules/FindMPI.cmake:1837 (find_package_handle_standard_args)
  CMakeLists.txt:27 (find_package)


-- Configuring incomplete, errors occurred!

I'm guessing this is a problem in the FindMPI CMake package? The purpose of vapaa is that you don't need to have MPI_Fortran...

(cc @JorgeG94)

ivan-pi avatar Mar 25 '25 11:03 ivan-pi

oh whoops! I didn't catch that because my local MPIs were built with the fortran compiler I was using! My bad, let me fix this

JorgeG94 avatar Mar 25 '25 11:03 JorgeG94

can you try this fix

JorgeG94 avatar Mar 25 '25 11:03 JorgeG94

I opened a PR for this, feel free to look at it. It should work now I believe, sorry about this!

JorgeG94 avatar Mar 25 '25 11:03 JorgeG94

That configures correctly, but nagfor doesn't recognize the same flags. We would need to add use generator expressions in the target_compile_options command.

[ 55%] Building Fortran object tests/CMakeFiles/test_attr.dir/test_attr.F90.o
make[2]: *** [tests/CMakeFiles/mpich_uallreducef08.dir/build.make:75: tests/CMakeFiles/mpich_uallreducef08.dir/mpich_uallreducef08.F90.o] Error 2
make[1]: *** [CMakeFiles/Makefile2:192: tests/CMakeFiles/mpich_uallreducef08.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
NAG Fortran Compiler Release 7.2(Shin-Urayasu) Build 7203
Option error: Unrecognised option -Wall

If I comment the target_compile_options the library builds (btw there is a name typo -> libvapaa.a), but the -rpath options of the tests also isn't allowed for some reason:

[ 54%] Linking Fortran static library lib/libvapa.a
[ 54%] Built target vapa
[ 54%] Building Fortran object tests/CMakeFiles/mpich_uallreducef08.dir/mpich_uallreducef08.F90.o
NAG Fortran Compiler Release 7.2(Shin-Urayasu) Build 7203
[NAG Fortran Compiler normal termination]
[ 55%] Linking Fortran executable mpich_uallreducef08
NAG Fortran Compiler Release 7.2(Shin-Urayasu) Build 7203
gcc: error: unrecognized command line option ‘-rpath’
gcc: error: unrecognized command line option ‘-rpath’
gcc: error: unrecognized command line option ‘-rpath’

As a side-note, nagfor transpiles Fortran to C, and then it invokes the system C compiler (i.e. gcc).

ivan-pi avatar Mar 25 '25 11:03 ivan-pi

you can do without rpath if you set LD_LIBRARY_PATH correctly. i just prefer the former.

jeffhammond avatar Apr 01 '25 08:04 jeffhammond

@ivan-pi can you look at #55 where I set flags per compiler and don't pass the warn flags to NAG

JorgeG94 avatar Jul 10 '25 23:07 JorgeG94