Skip to content

Commit

Permalink
Merge pull request OpenFAST#20 from deslaughter/f/br_fsi_2
Browse files Browse the repository at this point in the history
Updated to work with Flang on Crusher
  • Loading branch information
gantech authored Apr 17, 2023
2 parents 6faec10 + 7e6ab74 commit 12902e7
Show file tree
Hide file tree
Showing 27 changed files with 648 additions and 1,981 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ if (MKL_FOUND)
set(BLAS_LIBRARIES ${MKL_LIBRARIES})
set(LAPACK_LIBRARIES ${MKL_LIBRARIES})
set(CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES "ifport;ifcore;imf;svml;m;ipgo;intlc;c;irc_s;dl;c")
elseif(${CMAKE_Fortran_COMPILER_ID} MATCHES "^Flang")
set(BLAS_LIBRARIES "")
set(LAPACK_LIBRARIES "")
else()
find_package(BLAS REQUIRED)
find_package(LAPACK REQUIRED)
Expand Down Expand Up @@ -173,7 +176,7 @@ if(BUILD_TESTING)
add_subdirectory(reg_tests)

# unit tests
add_subdirectory(unit_tests)
# add_subdirectory(unit_tests)
endif()

option(BUILD_DOCUMENTATION "Build documentation." OFF)
Expand Down
41 changes: 32 additions & 9 deletions cmake/OpenfastFortranOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ macro(set_fast_fortran)
# Abort if we do not have gfortran or Intel Fortran Compiler.
if (NOT (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU" OR
${CMAKE_Fortran_COMPILER_ID} MATCHES "^Intel" OR
${CMAKE_Fortran_COMPILER_ID} STREQUAL "Cray"))
message(FATAL_ERROR "OpenFAST requires GFortran, Intel Fortran, or Cray Compiler. Compiler detected by CMake: ${FCNAME}.")
${CMAKE_Fortran_COMPILER_ID} STREQUAL "Cray" OR
${CMAKE_Fortran_COMPILER_ID} STREQUAL "Flang"))
message(FATAL_ERROR "OpenFAST requires GFortran, Intel, Cray, or Flang Compiler. Compiler detected by CMake: ${FCNAME}.")
endif()

# Verify proper compiler versions are available
Expand Down Expand Up @@ -73,6 +74,8 @@ macro(set_fast_fortran)
set_fast_intel_fortran()
elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "Cray")
set_fast_cray_fortran()
elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "Flang")
set_fast_flang()
endif()
endmacro(set_fast_fortran)

Expand All @@ -83,8 +86,7 @@ macro(check_f2008_features)
include(CheckFortranSourceCompiles)
check_fortran_source_compiles(
"program test
use iso_fortran_env, only: compiler_version, real32, real64, real128
integer, parameter :: quki = real128
use iso_fortran_env, only: compiler_version, real32, real64
integer, parameter :: dbki = real64
integer, parameter :: reki = real32
Expand Down Expand Up @@ -118,7 +120,7 @@ macro(set_fast_gfortran)
# Deal with Double/Single precision
if (DOUBLE_PRECISION)
add_definitions(-DOPENFAST_DOUBLE_PRECISION)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fdefault-real-8")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fdefault-real-8 -fdefault-double-8")
endif (DOUBLE_PRECISION)

# debug flags
Expand Down Expand Up @@ -162,9 +164,9 @@ macro(set_fast_intel_fortran_posix)
if (DOUBLE_PRECISION)
add_definitions(-DOPENFAST_DOUBLE_PRECISION)
if("${CMAKE_Fortran_COMPILER_VERSION}" VERSION_GREATER "19")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -r8 -double-size 128")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -r8 -double-size 64")
else()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -r8 -double_size 128")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -r8 -double_size 64")
endif()
endif (DOUBLE_PRECISION)

Expand Down Expand Up @@ -212,9 +214,9 @@ macro(set_fast_intel_fortran_windows)
if (DOUBLE_PRECISION)
add_definitions(-DOPENFAST_DOUBLE_PRECISION)
if("${CMAKE_Fortran_COMPILER_VERSION}" VERSION_GREATER "19")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} /real-size:64 /double-size:128")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} /real-size:64 /double-size:64")
else()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} /real_size:64 /double_size:128")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} /real_size:64 /double_size:64")
endif()
endif (DOUBLE_PRECISION)

Expand Down Expand Up @@ -256,3 +258,24 @@ macro(set_fast_cray_fortran)

check_f2008_features()
endmacro()

#
# set_fast_flang - Customizations for GNU Fortran compiler
#
macro(set_fast_flang)

set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fno-backslash -cpp")

# Deal with Double/Single precision
if (DOUBLE_PRECISION)
add_definitions(-DOPENFAST_DOUBLE_PRECISION)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fdefault-real-8")
endif (DOUBLE_PRECISION)

# OPENMP
if (OPENMP)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fopenmp")
endif()

check_f2008_features()
endmacro(set_fast_flang)
12 changes: 3 additions & 9 deletions glue-codes/openfast-cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ find_package(HDF5 REQUIRED)
find_package(NetCDF REQUIRED COMPONENTS C)
find_package(yaml-cpp REQUIRED)

include_directories(${HDF5_INCLUDE_DIRS})
include_directories(${YAML_INCLUDES})
include_directories(${NETCDF_INCLUDE_DIRS})
include_directories(${ZLIB_INCLUDES})
Expand All @@ -38,8 +39,7 @@ include_directories(${CMAKE_BINARY_DIR}/modules/extloads/)
include_directories(${CMAKE_BINARY_DIR}/modules/supercontroller/)
include_directories(${MPI_INCLUDE_PATH})

add_library(openfastcpplib
src/OpenFAST.cpp src/SC.cpp)
add_library(openfastcpplib src/OpenFAST.cpp src/SC.cpp)
set_property(TARGET openfastcpplib PROPERTY POSITION_INDEPENDENT_CODE ON)
target_link_libraries(openfastcpplib
openfastlib
Expand All @@ -51,13 +51,7 @@ target_link_libraries(openfastcpplib
${CMAKE_DL_LIBS})

add_executable(openfastcpp src/FAST_Prog.cpp)
target_link_libraries(openfastcpp openfastcpplib openfastlib
${MPI_LIBRARIES}
${YAML_CPP_LIBRARIES}
${NETCDF_LIBRARIES}
${ZLIB_LIBRARIES}
${LIBXML2_LIBRARIES}
${CMAKE_DL_LIBS})
target_link_libraries(openfastcpp openfastcpplib openfastlib ${YAML_CPP_LIBRARIES})

if(MPI_COMPILE_FLAGS)
set_target_properties(openfastcpp PROPERTIES
Expand Down
4 changes: 2 additions & 2 deletions modules/aerodyn14/src/AeroSubs.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1264,13 +1264,13 @@ SUBROUTINE READFL(InitInp, P, x, xd, z, m, y, ErrStat, ErrMess )

IF ( p%PMOMENT ) THEN

READ( NUNIT,*,END=150 ) m%AirFoil%AL(NFOILID,I), &
READ( NUNIT,*,END=150, ERR=150 ) m%AirFoil%AL(NFOILID,I), &
(m%AirFoil%CL(NFOILID,I,IPHI), m%AirFoil%CD(NFOILID,I,IPHI), &
m%AirFoil%CM(NFOILID,I,IPHI), IPHI = 1, p%AirFoil%NTables(NFOILID))

ELSE

READ( NUNIT,*,END=150 ) m%AirFoil%AL(NFOILID,I), &
READ( NUNIT,*,END=150, ERR=150 ) m%AirFoil%AL(NFOILID,I), &
(m%AirFoil%CL(NFOILID,I,IPHI), m%AirFoil%CD(NFOILID,I,IPHI), &
IPHI = 1, p%AirFoil%NTables(NFOILID))

Expand Down
3 changes: 2 additions & 1 deletion modules/beamdyn/src/BeamDyn_IO.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@ SUBROUTINE BD_ReadBladeFile(BldFile,BladeInputFileData,UnEc,ErrStat,ErrMsg)
return
end if
BladeInputFileData%stiff0(:,:,i) = temp66

CALL ReadCom(UnIn,BldFile,'blank',ErrStat2,ErrMsg2,UnEc)
DO j=1,6
CALL ReadAry(UnIn,BldFile,temp66(j,:),6,'mass_matrix','Blade C/S mass matrix',ErrStat2,ErrMsg2,UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
Expand All @@ -1137,6 +1137,7 @@ SUBROUTINE BD_ReadBladeFile(BldFile,BladeInputFileData,UnEc,ErrStat,ErrMsg)
return
end if
BladeInputFileData%mass0(:,:,i) = temp66
CALL ReadCom(UnIn,BldFile,'blank',ErrStat2,ErrMsg2,UnEc)

ENDDO

Expand Down
6 changes: 5 additions & 1 deletion modules/nwtc-library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,14 @@ elseif (${CMAKE_Fortran_COMPILER_ID} MATCHES "^Intel")
elseif (WIN32)
set(NWTC_SYS_FILE src/SysIVF.f90)
endif (APPLE OR UNIX)
elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Cray")
elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Cray")
if(APPLE OR UNIX)
set(NWTC_SYS_FILE src/SysCrayLinux.f90)
endif()
elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Flang")
if(APPLE OR UNIX)
set(NWTC_SYS_FILE src/SysFlangLinux.f90)
endif()
endif ()

if (NWTC_SYS_FILE)
Expand Down
2 changes: 1 addition & 1 deletion modules/nwtc-library/src/NWTC_Base.f90
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ MODULE NWTC_Base

INTEGER(C_INTPTR_T) :: FileAddr !< The address of file FileName. (RETURN value from LoadLibrary ) [Windows]
TYPE(C_PTR) :: FileAddrX = C_NULL_PTR !< The address of file FileName. (RETURN value from dlopen ) [Linux]
TYPE(C_FUNPTR) :: ProcAddr(NWTC_MAX_DLL_PROC) = C_NULL_FUNPTR !< The address of procedure ProcName. (RETURN value from GetProcAddress or dlsym) [initialized to Null for pack/unpack]
TYPE(C_FUNPTR) :: ProcAddr(NWTC_MAX_DLL_PROC) !< The address of procedure ProcName. (RETURN value from GetProcAddress or dlsym) [initialized to Null for pack/unpack]

CHARACTER(1024) :: FileName !< The name of the DLL file including the full path to the current working directory.
CHARACTER(1024) :: ProcName(NWTC_MAX_DLL_PROC) = "" !< The name of the procedure in the DLL that will be called.
Expand Down
Loading

0 comments on commit 12902e7

Please sign in to comment.