Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimal cmake build (GCC + generic FFT) #20

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
cmake_minimum_required(VERSION 3.12)
cmake_policy(SET CMP0074 NEW)

project(xcompact3d LANGUAGES Fortran)

find_package(MPI REQUIRED)
if (MPI_Fortran_COMPILER)
message(STATUS "MPI_Fortran_COMPILER found: ${MPI_Fortran_COMPILER}")
else (MPI_Fortran_COMPILER)
message(SEND_ERROR "This application cannot compile without MPI")
endif(MPI_Fortran_COMPILER)

# Create a static library for the fft
add_subdirectory(decomp2d)

# Create the Xcompact3d executable
add_subdirectory(src)

include(GNUInstallDirs)
set(CMAKE_INSTALL_PREFIX ${PROJECT_BINARY_DIR})
install(TARGETS xcompact3d
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
14 changes: 14 additions & 0 deletions decomp2d/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
file(GLOB files_decomp decomp_2d.f90 glassman.f90)
file(GLOB files_fft fft_generic.f90)
set(SRCFILES ${files_decomp} ${files_fft})

add_library(decomp2d STATIC ${SRCFILES})
target_link_libraries(decomp2d PRIVATE MPI::MPI_Fortran)

include(cmake/gfortran_flags.cmake)

if(${CMAKE_Fortran_COMPILER_VERSION} VERSION_GREATER_EQUAL 10.3)
list(APPEND gfortran_flags -fallow-argument-mismatch)
# See https://github.com/xcompact3d/x3div/pull/20#discussion_r814948614
endif()
target_compile_options(decomp2d PRIVATE ${gfortran_flags})
10 changes: 10 additions & 0 deletions decomp2d/cmake/gfortran_flags.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
set(gfortran_flags
-cpp
-funroll-loops
-floop-optimize
-g
-Warray-bounds
-fcray-pointer
-fbacktrace
-ffree-line-length-none
)
26 changes: 26 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
set(SRCFILES
xcompact3d.f90
case.f90
derive.f90
module_param.f90
mom.f90
navier.f90
parameters.f90
poisson.f90
schemes.f90
transeq.f90
variables.f90
)

add_executable(xcompact3d ${SRCFILES})

target_include_directories(xcompact3d PRIVATE ${PROJECT_BINARY_DIR}/decomp2d)
target_link_libraries(xcompact3d PRIVATE decomp2d)
target_link_libraries(xcompact3d PRIVATE MPI::MPI_Fortran)

include(cmake/gfortran_flags.cmake)
if(${CMAKE_Fortran_COMPILER_VERSION} VERSION_GREATER_EQUAL 10.3)
list(APPEND gfortran_flags -fallow-argument-mismatch)
# See https://github.com/xcompact3d/x3div/pull/20#discussion_r814948614
endif()
target_compile_options(xcompact3d PRIVATE ${gfortran_flags})
10 changes: 10 additions & 0 deletions src/cmake/gfortran_flags.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
set(gfortran_flags
-cpp
-funroll-loops
-floop-optimize
-g
-Warray-bounds
-fcray-pointer
-fbacktrace
-ffree-line-length-none
)