Skip to content

Commit

Permalink
Merge pull request #5003 from mathomp4/bugfix/nag-pic
Browse files Browse the repository at this point in the history
Fixes for NAG Compiler
  • Loading branch information
martin-frbg authored Dec 4, 2024
2 parents 9c5d201 + c4e8bac commit 4ba471d
Show file tree
Hide file tree
Showing 24 changed files with 140 additions and 104 deletions.
25 changes: 25 additions & 0 deletions cmake/fc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,31 @@ if (${F_COMPILER} STREQUAL "CRAY")
endif ()
endif ()

if (${F_COMPILER} STREQUAL "NAGFOR")
set(CCOMMON_OPT "${CCOMMON_OPT} -DF_INTERFACE_NAG")
if (INTERFACE64)
set(FCOMMON_OPT "${FCOMMON_OPT} -i8")
endif ()
# Options from Makefile.system
# -dcfuns: Enable non-standard double precision complex intrinsic functions
# -ieee=full: enables all IEEE arithmetic facilities including non-stop arithmetic.
# -w=obs: Suppress warning messages about obsolescent features
# -thread_safe: Compile code for safe execution in a multi-threaded environment.
# -recursive: Specifies that procedures are RECURSIVE by default.
set(FCOMMON_OPT "${FCOMMON_OPT} -dcfuns -recursive -ieee=full -w=obs -thread_safe")
# Options from Reference-LAPACK
# Suppress compiler banner and summary
set(FCOMMON_OPT "${FCOMMON_OPT} -quiet")
# Disable other common warnings
# -w=x77: Suppress warning messages about Fortran 77 features
# -w=ques: Suppress warning messages about questionable usage
# -w=unused: Suppress warning messages about unused variables
set(FCOMMON_OPT "${FCOMMON_OPT} -w=x77 -w=ques -w=unused")
if (USE_OPENMP)
set(FCOMMON_OPT "${FCOMMON_OPT} -openmp")
endif ()
endif ()

# from the root Makefile - this is for lapack-netlib to compile the correct secnd file.
if (${F_COMPILER} STREQUAL "GFORTRAN")
set(TIMER "INT_ETIME")
Expand Down
7 changes: 6 additions & 1 deletion cmake/lapack.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,12 @@ foreach (LA_FILE ${LA_GEN_SRC})
endforeach ()

if (NOT C_LAPACK)
set_source_files_properties(${LA_SOURCES} PROPERTIES COMPILE_FLAGS "${LAPACK_FFLAGS}")
# The below line is duplicating Fortran flags but NAG has a few flags
# that cannot be specified twice. It's possible this is not needed for
# any compiler, but for safety, we only turn off for NAG
if (NOT ${F_COMPILER} STREQUAL "NAGFOR")
set_source_files_properties(${LA_SOURCES} PROPERTIES COMPILE_FLAGS "${LAPACK_FFLAGS}")
endif ()
if (${F_COMPILER} STREQUAL "GFORTRAN")
set_source_files_properties(${LA_SOURCES} PROPERTIES COMPILE_FLAGS "${LAPACK_FFLAGS} -fno-tree-vectorize")
endif()
Expand Down
22 changes: 12 additions & 10 deletions cmake/system.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,8 @@ if (NEED_PIC)
if (NOT NOFORTRAN)
if (${F_COMPILER} STREQUAL "SUN")
set(FCOMMON_OPT "${FCOMMON_OPT} -pic")
elseif (${F_COMPILER} STREQUAL "NAGFOR")
set(FCOMMON_OPT "${FCOMMON_OPT} -PIC")
else ()
set(FCOMMON_OPT "${FCOMMON_OPT} -fPIC")
endif ()
Expand Down Expand Up @@ -640,17 +642,17 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
endif ()

if (CMAKE_Fortran_COMPILER)
if ("${F_COMPILER}" STREQUAL "NAG" OR "${F_COMPILER}" STREQUAL "CRAY" OR CMAKE_Fortran_COMPILER_ID MATCHES "LLVMFlang.*")
set(FILTER_FLAGS "-msse3;-mssse3;-msse4.1;-mavx;-mavx2,-mskylake-avx512")
if (CMAKE_Fortran_COMPILER_ID MATCHES "LLVMFlang.*")
message(STATUS "removing fortran flags")
set(FILTER_FLAGS "${FILTER_FLAGS};-m32;-m64")
if ("${F_COMPILER}" STREQUAL "NAGFOR" OR "${F_COMPILER}" STREQUAL "CRAY" OR CMAKE_Fortran_COMPILER_ID MATCHES "LLVMFlang.*")
set(FILTER_FLAGS "-msse3;-mssse3;-msse4.1;-mavx;-mavx2,-mskylake-avx512")
if (CMAKE_Fortran_COMPILER_ID MATCHES "LLVMFlang.*")
message(STATUS "removing fortran flags")
set(FILTER_FLAGS "${FILTER_FLAGS};-m32;-m64")
endif ()
foreach (FILTER_FLAG ${FILTER_FLAGS})
string(REPLACE ${FILTER_FLAG} "" LAPACK_FFLAGS ${LAPACK_FFLAGS})
string(REPLACE ${FILTER_FLAG} "" LAPACK_FPFLAGS ${LAPACK_FPFLAGS})
endforeach ()
endif ()
foreach (FILTER_FLAG ${FILTER_FLAGS})
string(REPLACE ${FILTER_FLAG} "" LAPACK_FFLAGS ${LAPACK_FFLAGS})
string(REPLACE ${FILTER_FLAG} "" LAPACK_FPFLAGS ${LAPACK_FPFLAGS})
endforeach ()
endif ()
endif ()

if ("${F_COMPILER}" STREQUAL "GFORTRAN")
Expand Down
6 changes: 3 additions & 3 deletions ctest/c_cblat1.f
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ PROGRAM CCBLAT1
IF (PASS) THEN
WRITE (NOUT,99998)
ELSE
CALL ABORT
ERROR STOP
END IF
20 CONTINUE
*
Expand Down Expand Up @@ -231,7 +231,7 @@ SUBROUTINE CHECK1(SFAC)
CALL ITEST1(ICAMAXTEST(N,CX,INCX),ITRUE3(NP1))
ELSE
WRITE (NOUT,*) ' Shouldn''t be here in CHECK1'
CALL ABORT
ERROR STOP
END IF
*
40 CONTINUE
Expand Down Expand Up @@ -515,7 +515,7 @@ SUBROUTINE CHECK2(SFAC)
CALL CTEST(LENY,CY,CT10Y(1,KN,KI),CSIZE3,1.0E0)
ELSE
WRITE (NOUT,*) ' Shouldn''t be here in CHECK2'
CALL ABORT
ERROR STOP
END IF
*
40 CONTINUE
Expand Down
10 changes: 5 additions & 5 deletions ctest/c_cblat2.f
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ PROGRAM CBLAT2
* 'CBLAT2.SNAP' NAME OF SNAPSHOT OUTPUT FILE
* -1 UNIT NUMBER OF SNAPSHOT FILE (NOT USED IF .LT. 0)
* F LOGICAL FLAG, T TO REWIND SNAPSHOT FILE AFTER EACH RECORD.
* F LOGICAL FLAG, T TO CALL ABORT ON FAILURES.
* F LOGICAL FLAG, T TO ERROR STOP ON FAILURES.
* T LOGICAL FLAG, T TO TEST ERROR EXITS.
* 2 0 TO TEST COLUMN-MAJOR, 1 TO TEST ROW-MAJOR, 2 TO TEST BOTH
* 16.0 THRESHOLD VALUE OF TEST RATIO
Expand Down Expand Up @@ -243,7 +243,7 @@ PROGRAM CBLAT2
$ GO TO 70
60 CONTINUE
WRITE( NOUT, FMT = 9986 )SNAMET
CALL ABORT
ERROR STOP
70 LTEST( I ) = LTESTT
GO TO 50
*
Expand Down Expand Up @@ -283,15 +283,15 @@ PROGRAM CBLAT2
SAME = LCE( YY, YT, N )
IF( .NOT.SAME.OR.ERR.NE.RZERO )THEN
WRITE( NOUT, FMT = 9985 )TRANS, SAME, ERR
CALL ABORT
ERROR STOP
END IF
TRANS = 'T'
CALL CMVCH( TRANS, N, N, ONE, A, NMAX, X, -1, ZERO, Y, -1, YT, G,
$ YY, EPS, ERR, FATAL, NOUT, .TRUE. )
SAME = LCE( YY, YT, N )
IF( .NOT.SAME.OR.ERR.NE.RZERO )THEN
WRITE( NOUT, FMT = 9985 )TRANS, SAME, ERR
CALL ABORT
ERROR STOP
END IF
*
* Test each subroutine in turn.
Expand Down Expand Up @@ -419,7 +419,7 @@ PROGRAM CBLAT2
$ CLOSE ( NTRA )
CLOSE ( NOUT )
IF( FATAL ) THEN
CALL ABORT
ERROR STOP
END IF
*
10002 FORMAT( ' COLUMN-MAJOR AND ROW-MAJOR DATA LAYOUTS ARE TESTED' )
Expand Down
14 changes: 7 additions & 7 deletions ctest/c_cblat3.f
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ PROGRAM CBLAT3
* 'CBLAT3.SNAP' NAME OF SNAPSHOT OUTPUT FILE
* -1 UNIT NUMBER OF SNAPSHOT FILE (NOT USED IF .LT. 0)
* F LOGICAL FLAG, T TO REWIND SNAPSHOT FILE AFTER EACH RECORD.
* F LOGICAL FLAG, T TO CALL ABORT ON FAILURES.
* F LOGICAL FLAG, T TO ERROR STOP ON FAILURES.
* T LOGICAL FLAG, T TO TEST ERROR EXITS.
* 2 0 TO TEST COLUMN-MAJOR, 1 TO TEST ROW-MAJOR, 2 TO TEST BOTH
* 16.0 THRESHOLD VALUE OF TEST RATIO
Expand Down Expand Up @@ -194,7 +194,7 @@ PROGRAM CBLAT3
$ GO TO 50
40 CONTINUE
WRITE( NOUT, FMT = 9990 )SNAMET
CALL ABORT
ERROR STOP
50 LTEST( I ) = LTESTT
GO TO 30
*
Expand Down Expand Up @@ -237,7 +237,7 @@ PROGRAM CBLAT3
SAME = LCE( CC, CT, N )
IF( .NOT.SAME.OR.ERR.NE.RZERO )THEN
WRITE( NOUT, FMT = 9989 )TRANSA, TRANSB, SAME, ERR
CALL ABORT
ERROR STOP
END IF
TRANSB = 'C'
CALL CMMCH( TRANSA, TRANSB, N, 1, N, ONE, AB, NMAX,
Expand All @@ -246,7 +246,7 @@ PROGRAM CBLAT3
SAME = LCE( CC, CT, N )
IF( .NOT.SAME.OR.ERR.NE.RZERO )THEN
WRITE( NOUT, FMT = 9989 )TRANSA, TRANSB, SAME, ERR
CALL ABORT
ERROR STOP
END IF
DO 120 J = 1, N
AB( J, NMAX + 1 ) = N - J + 1
Expand All @@ -264,7 +264,7 @@ PROGRAM CBLAT3
SAME = LCE( CC, CT, N )
IF( .NOT.SAME.OR.ERR.NE.RZERO )THEN
WRITE( NOUT, FMT = 9989 )TRANSA, TRANSB, SAME, ERR
CALL ABORT
ERROR STOP
END IF
TRANSB = 'C'
CALL CMMCH( TRANSA, TRANSB, N, 1, N, ONE, AB, NMAX,
Expand All @@ -273,7 +273,7 @@ PROGRAM CBLAT3
SAME = LCE( CC, CT, N )
IF( .NOT.SAME.OR.ERR.NE.RZERO )THEN
WRITE( NOUT, FMT = 9989 )TRANSA, TRANSB, SAME, ERR
CALL ABORT
ERROR STOP
END IF
*
* Test each subroutine in turn.
Expand Down Expand Up @@ -386,7 +386,7 @@ PROGRAM CBLAT3
$ CLOSE ( NTRA )
CLOSE ( NOUT )
IF( FATAL ) THEN
CALL ABORT
ERROR STOP
END IF
*
10002 FORMAT( ' COLUMN-MAJOR AND ROW-MAJOR DATA LAYOUTS ARE TESTED' )
Expand Down
14 changes: 7 additions & 7 deletions ctest/c_cblat3_3m.f
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ PROGRAM CBLAT3
* 'CBLAT3.SNAP' NAME OF SNAPSHOT OUTPUT FILE
* -1 UNIT NUMBER OF SNAPSHOT FILE (NOT USED IF .LT. 0)
* F LOGICAL FLAG, T TO REWIND SNAPSHOT FILE AFTER EACH RECORD.
* F LOGICAL FLAG, T TO CALL ABORT ON FAILURES.
* F LOGICAL FLAG, T TO ERROR STOP ON FAILURES.
* T LOGICAL FLAG, T TO TEST ERROR EXITS.
* 2 0 TO TEST COLUMN-MAJOR, 1 TO TEST ROW-MAJOR, 2 TO TEST BOTH
* 16.0 THRESHOLD VALUE OF TEST RATIO
Expand Down Expand Up @@ -194,7 +194,7 @@ PROGRAM CBLAT3
$ GO TO 50
40 CONTINUE
WRITE( NOUT, FMT = 9990 )SNAMET
CALL ABORT
ERROR STOP
50 LTEST( I ) = LTESTT
GO TO 30
*
Expand Down Expand Up @@ -237,7 +237,7 @@ PROGRAM CBLAT3
SAME = LCE( CC, CT, N )
IF( .NOT.SAME.OR.ERR.NE.RZERO )THEN
WRITE( NOUT, FMT = 9989 )TRANSA, TRANSB, SAME, ERR
CALL ABORT
ERROR STOP
END IF
TRANSB = 'C'
CALL CMMCH( TRANSA, TRANSB, N, 1, N, ONE, AB, NMAX,
Expand All @@ -246,7 +246,7 @@ PROGRAM CBLAT3
SAME = LCE( CC, CT, N )
IF( .NOT.SAME.OR.ERR.NE.RZERO )THEN
WRITE( NOUT, FMT = 9989 )TRANSA, TRANSB, SAME, ERR
CALL ABORT
ERROR STOP
END IF
DO 120 J = 1, N
AB( J, NMAX + 1 ) = N - J + 1
Expand All @@ -264,7 +264,7 @@ PROGRAM CBLAT3
SAME = LCE( CC, CT, N )
IF( .NOT.SAME.OR.ERR.NE.RZERO )THEN
WRITE( NOUT, FMT = 9989 )TRANSA, TRANSB, SAME, ERR
CALL ABORT
ERROR STOP
END IF
TRANSB = 'C'
CALL CMMCH( TRANSA, TRANSB, N, 1, N, ONE, AB, NMAX,
Expand All @@ -273,7 +273,7 @@ PROGRAM CBLAT3
SAME = LCE( CC, CT, N )
IF( .NOT.SAME.OR.ERR.NE.RZERO )THEN
WRITE( NOUT, FMT = 9989 )TRANSA, TRANSB, SAME, ERR
CALL ABORT
ERROR STOP
END IF
*
* Test each subroutine in turn.
Expand Down Expand Up @@ -386,7 +386,7 @@ PROGRAM CBLAT3
$ CLOSE ( NTRA )
CLOSE ( NOUT )
IF( FATAL ) THEN
CALL ABORT
ERROR STOP
END IF
*
10002 FORMAT( ' COLUMN-MAJOR AND ROW-MAJOR DATA LAYOUTS ARE TESTED' )
Expand Down
10 changes: 5 additions & 5 deletions ctest/c_dblat1.f
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ PROGRAM DCBLAT1
IF (PASS) THEN
WRITE (NOUT,99998)
ELSE
CALL ABORT
ERROR STOP
END IF
20 CONTINUE
*
Expand Down Expand Up @@ -139,7 +139,7 @@ SUBROUTINE CHECK0(SFAC)
CALL STEST1(SS,DS1(K),DS1(K),SFAC)
ELSE
WRITE (NOUT,*) ' Shouldn''t be here in CHECK0'
CALL ABORT
ERROR STOP
END IF
20 CONTINUE
40 RETURN
Expand Down Expand Up @@ -232,7 +232,7 @@ SUBROUTINE CHECK1(SFAC)
CALL ITEST1(IDAMAXTEST(N,SX,INCX),ITRUE2(NP1))
ELSE
WRITE (NOUT,*) ' Shouldn''t be here in CHECK1'
CALL ABORT
ERROR STOP
END IF
60 CONTINUE
80 CONTINUE
Expand Down Expand Up @@ -387,7 +387,7 @@ SUBROUTINE CHECK2(SFAC)
CALL STEST(LENY,SY,STY,SSIZE2(1,1),1.0D0)
ELSE
WRITE (NOUT,*) ' Shouldn''t be here in CHECK2'
CALL ABORT
ERROR STOP
END IF
100 CONTINUE
120 CONTINUE
Expand Down Expand Up @@ -475,7 +475,7 @@ SUBROUTINE CHECK3(SFAC)
70 CONTINUE
ELSE
WRITE (NOUT,*) ' Shouldn''t be here in CHECK3'
CALL ABORT
ERROR STOP
END IF
40 CONTINUE
60 CONTINUE
Expand Down
10 changes: 5 additions & 5 deletions ctest/c_dblat2.f
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ PROGRAM DBLAT2
* 'DBLAT2.SNAP' NAME OF SNAPSHOT OUTPUT FILE
* -1 UNIT NUMBER OF SNAPSHOT FILE (NOT USED IF .LT. 0)
* F LOGICAL FLAG, T TO REWIND SNAPSHOT FILE AFTER EACH RECORD.
* F LOGICAL FLAG, T TO CALL ABORT ON FAILURES.
* F LOGICAL FLAG, T TO ERROR STOP ON FAILURES.
* T LOGICAL FLAG, T TO TEST ERROR EXITS.
* 2 0 TO TEST COLUMN-MAJOR, 1 TO TEST ROW-MAJOR, 2 TO TEST BOTH
* 16.0 THRESHOLD VALUE OF TEST RATIO
Expand Down Expand Up @@ -239,7 +239,7 @@ PROGRAM DBLAT2
$ GO TO 70
60 CONTINUE
WRITE( NOUT, FMT = 9986 )SNAMET
CALL ABORT
ERROR STOP
70 LTEST( I ) = LTESTT
GO TO 50
*
Expand Down Expand Up @@ -279,15 +279,15 @@ PROGRAM DBLAT2
SAME = LDE( YY, YT, N )
IF( .NOT.SAME.OR.ERR.NE.ZERO )THEN
WRITE( NOUT, FMT = 9985 )TRANS, SAME, ERR
CALL ABORT
ERROR STOP
END IF
TRANS = 'T'
CALL DMVCH( TRANS, N, N, ONE, A, NMAX, X, -1, ZERO, Y, -1, YT, G,
$ YY, EPS, ERR, FATAL, NOUT, .TRUE. )
SAME = LDE( YY, YT, N )
IF( .NOT.SAME.OR.ERR.NE.ZERO )THEN
WRITE( NOUT, FMT = 9985 )TRANS, SAME, ERR
CALL ABORT
ERROR STOP
END IF
*
* Test each subroutine in turn.
Expand Down Expand Up @@ -415,7 +415,7 @@ PROGRAM DBLAT2
$ CLOSE ( NTRA )
CLOSE ( NOUT )
IF( FATAL ) THEN
CALL ABORT
ERROR STOP
END IF
*
10002 FORMAT( ' COLUMN-MAJOR AND ROW-MAJOR DATA LAYOUTS ARE TESTED' )
Expand Down
Loading

0 comments on commit 4ba471d

Please sign in to comment.