Skip to content

Commit

Permalink
FORTLINK: Guess if Unknown (AMReX-Codes#1126)
Browse files Browse the repository at this point in the history
* FORTLINK: Guess of Unknown

Guess the FORTLINK API convention is `UNDERSCORE` for unknown values,
unless it's the classic (non-clang) IBM Fortran compiler, where it's
`LOWERCASE`.

* add edge case where FORTLINK couldn't be determined by CMake

Co-authored-by: Johannes Blaschke <jpblaschke@lbl.gov>
  • Loading branch information
2 people authored and dwillcox committed Oct 3, 2020
1 parent f8113e6 commit 12fe62a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Tools/CMake/AMReX_Defines.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,22 @@ function ( set_amrex_defines )

set( FORTLINK "" )

if ( FortranCInterface_GLOBAL_SUFFIX STREQUAL "" )
if ( (FortranCInterface_GLOBAL_SUFFIX STREQUAL "" ) AND NOT
(FortranCInterface_GLOBAL_CASE STREQUAL "") )
set(FORTLINK "${FortranCInterface_GLOBAL_CASE}CASE" )
message(STATUS "Fortran name mangling scheme: ${FORTLINK} (no append underscore)")
elseif ( (FortranCInterface_GLOBAL_SUFFIX STREQUAL "_") AND
( FortranCInterface_GLOBAL_CASE STREQUAL "LOWER" ) )
set(FORTLINK "UNDERSCORE")
message(STATUS "Fortran name mangling scheme: ${FORTLINK} (lower case, append underscore)")
else ()
message(AUTHOR_WARNING "Fortran to C mangling not compatible with AMReX code")
# now we have to guess
if (CMAKE_Fortran_COMPILER_ID MATCHES XL) # old IBM prior to XLClang
set(FORTLINK "LOWERCASE")
else ()
set(FORTLINK "UNDERSCORE")
endif()
message(WARNING "Fortran to C mangling not compatible with AMReX code, assuming '${FORTLINK}'")
endif ()

add_amrex_define( BL_FORT_USE_${FORTLINK} ) # Only legacy form
Expand Down

0 comments on commit 12fe62a

Please sign in to comment.