Skip to content

Commit

Permalink
make compile with cmake.
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkOfTheMoon committed Mar 31, 2022
1 parent 2764ac3 commit e014a45
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@
*.exe
*.out
*.app

# CMake Build Directory
build
27 changes: 27 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
project(UCNS3D Fortran)

# FFLAGS depend on the compiler
get_filename_component (Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER} NAME)

if (Fortran_COMPILER_NAME MATCHES "gfortran*")
# gfortran
set(CMAKE_Fortran_FLAGS "-fdefault-real-8 -fdefault-double-8 -ffree-line-length-none -fbackslash -fopenmp -finit-local-zero -fimplicit-none -flto -fcray-pointer -Wno-lto-type-mismatch")
set(CMAKE_Fortran_FLAGS_RELEASE "-funroll-all-loops -fno-f2c -O3 -march=native")
set(CMAKE_Fortran_FLAGS_DEBUG "-fno-f2c -O0 -g")
elseif (Fortran_COMPILER_NAME MATCHES "ifort*")
# ifort (untested)
set (CMAKE_Fortran_FLAGS_RELEASE "-f77rtl -O3")
set (CMAKE_Fortran_FLAGS_DEBUG "-f77rtl -O0 -g")
else (Fortran_COMPILER_NAME MATCHES "gfortran.*")
message ("CMAKE_Fortran_COMPILER full path: " ${CMAKE_Fortran_COMPILER})
message ("Fortran compiler: " ${Fortran_COMPILER_NAME})
message ("No optimized Fortran compiler flags are known, we just try -O2...")
set (CMAKE_Fortran_FLAGS_RELEASE "-O2")
set (CMAKE_Fortran_FLAGS_DEBUG "-O0 -g")
endif (Fortran_COMPILER_NAME MATCHES "gfortran*")

#
find_package(MPI REQUIRED COMPONENTS Fortran)
set(CMAKE_Fortran_COMPILER ${MPI_Fortran_COMPILER})

add_subdirectory(CODE)
43 changes: 43 additions & 0 deletions CODE/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
set(SRCS
basis.f90
bc_p.f90
communications.f90
declarations.f90
der_r.f90
flow_operations.f90
flux_p.f90
flux_pv.f90
gradients.f90
grid_p.f90
grid_t.f90
implicit_fluxes.f90
implicit_time.f90
init_p.f90
io.f90
local_pt.f90
main.f90
matrix.f90
memory.f90
mood.f90
mpi_p.f90
parameters.f90
parts.f90
prestore.f90
profile.f90
reconstruct_p.f90
riemann.f90
source.f90
svd.f90
time_p.f90
translate.f90
)

find_library(BLIS_LIBRARY NAMES libblis.a)
find_library(ParMetis_LIBRARY NAMES libparmetis.a)
find_library(Metis_LIBRARY NAMES libmetis.so)

add_executable(ucns3d_p ${SRCS} )

target_link_libraries(ucns3d_p ${BLIS_LIBRARY} ${ParMetis_LIBRARY} ${Metis_LIBRARY}
${CMAKE_CURRENT_SOURCE_DIR}/libtecio.so
)

0 comments on commit e014a45

Please sign in to comment.