GALAHAD icon indicating copy to clipboard operation
GALAHAD copied to clipboard

Build error on Silicon with NAG Fortran

Open dpo opened this issue 2 years ago • 5 comments

[110/1503] Compiling Fortran object libgalahad_hsl_single.dylib.p/src_kinds_kinds.F90.o
FAILED: libgalahad_hsl_single.dylib.p/src_kinds_kinds.F90.o libgalahad_hsl_single.dylib.p/galahad_kinds.mod
nagfor -Ilibgalahad_hsl_single.dylib.p -I. -I.. -I../include -Ilibgalahad_lapack.dylib.p -Ilibgalahad_blas.dylib.p -quiet -O0 -g -PIC -DGALAHAD_SINGLE -DSPRAL_SINGLE -DSPRAL_NO_HWLOC -DSPRAL_HAVE_SCHED_GETCPU -mdir libgalahad_hsl_single.dylib.p -o libgalahad_hsl_single.dylib.p/src_kinds_kinds.F90.o -c ../src/kinds/kinds.F90
Error: ../src/kinds/kinds.F90, line 45: Invalid #line directive
Error: ../src/kinds/kinds.F90, line 46: Syntax error
       detected at <invalid token>@INTEGER
Error: ../src/kinds/kinds.F90, line 50: Invalid #line directive
Error: ../src/kinds/kinds.F90, line 51: Syntax error
       detected at <invalid token>@INTEGER
Error: ../src/kinds/kinds.F90, line 52: Duplicate type declaration for RP_
       detected at RP_@=
Error: ../src/kinds/kinds.F90, line 52: PARAMETER RP_ has already been defined
       detected at R8_@<end-of-statement>
Error: ../src/kinds/kinds.F90, line 53: Duplicate type declaration for CP_
       detected at CP_@=
Error: ../src/kinds/kinds.F90, line 53: PARAMETER CP_ has already been defined
       detected at C8_@<end-of-statement>
Error: ../src/kinds/kinds.F90, line 54: Duplicate type declaration for RPC_
       detected at RPC_@=
Error: ../src/kinds/kinds.F90, line 54: PARAMETER RPC_ has already been defined
       detected at C_DOUBLE@<end-of-statement>
Error: ../src/kinds/kinds.F90, line 55: Invalid #line directive
Error: ../src/kinds/kinds.F90, line 57: Invalid #line directive
Error: ../src/kinds/kinds.F90, line 57: Syntax error
Error: ../src/kinds/kinds.F90, line 60: Invalid #line directive
Error: ../src/kinds/kinds.F90, line 61: Syntax error
       detected at <invalid token>@INTEGER
Error: ../src/kinds/kinds.F90, line 62: Duplicate type declaration for IPC_
       detected at IPC_@=
Error: ../src/kinds/kinds.F90, line 62: PARAMETER IPC_ has already been defined
       detected at C_INT32_T@<end-of-statement>
Error: ../src/kinds/kinds.F90, line 63: Invalid #line directive
Error: ../src/kinds/kinds.F90, line 65: Syntax error
       detected at <invalid token>@END

dpo avatar Jan 23 '23 16:01 dpo

If the compiler doesn't understand standard #ifdef then it will never work. The linux version of nagfor does understand this, and https://www.nag.com/nagware/np/r70_doc/fpp.html suggests that this is generally supported. What does nagfor -c kinds.F90 report?

nimgould avatar Jan 23 '23 17:01 nimgould

nagfor -c kinds.F90 complains as above, but nagfor -fpp -c kinds.F90 works. It seems the preprocessor is not activated by defauilt.

dpo avatar Jan 23 '23 17:01 dpo

Excellent. Under linux, a .F90 suffix implies -fpp, a bit odd that this doesn't follow for Macs

nimgould avatar Jan 24 '23 07:01 nimgould

I'm reopening this because it requires a fix. What's happening is that fpp isn't triggered automatically by the F90 extension (capital F) on macOS. The reason is that most users don't install macOS as case sensitive (it isn't by default).

So we should really add the preprocessing flag to all compilers by default on macOS. Same thing on Windows.

dpo avatar Jan 24 '23 15:01 dpo

Nice! Mac trying to emulate the best features of Windows

AFAIK, for Mac it is

-cpp for gfortran and -fpp for nagfor and ifort, although for the latter it is on by default

I'll add these for the osx files on archdefs (for those of us who might still use the makefiles)

nimgould avatar Jan 24 '23 15:01 nimgould