Skip to content

Commit

Permalink
Move to cmake installation
Browse files Browse the repository at this point in the history
  • Loading branch information
J Todd committed Aug 23, 2018
1 parent ba45bb0 commit 1754b30
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 24 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
@@ -0,0 +1,6 @@
cmake_minimum_required (VERSION 2.8)
project (HiDEM Fortran C)

add_subdirectory (libs/metis-5.1.0)
add_subdirectory (src)

1 change: 0 additions & 1 deletion compile.sh

This file was deleted.

19 changes: 6 additions & 13 deletions scripts/compilation/compile_cray.sh 100755 → 100644
@@ -1,14 +1,7 @@
#!/bin/bash
module swap PrgEnv-gnu PrgEnv-cray
module load metis
cd ./src/
ftn -o ../HiDEM -O3 -lmetis typedefs.f90 utils.f90 io.f90 octree.F90 glas.f90 dist.f90 effload.f90 amat.f tmat.f ttmat.f kmat.f ranmar.f wave2.f90
#ftn -o ../HiDEM -g -R bcp -lmetis typedefs.f90 utils.f90 io.f90 octree.F90 glas.f90 dist.f90 effload.f90 amat.f tmat.f ttmat.f kmat.f ranmar.f wave2.f90
cd ..
rm INOUT.mod
rm TYPEDEFS.mod
rm LATTICE.mod
rm UTILS.mod
rm OCTREE.mod
rm EFFL.mod
module swap PrgEnv-cray PrgEnv-gnu
mkdir -p build #make dir if first build
cd build

cmake ../ -DCMAKE_INSTALL_PREFIX="." -DCMAKE_TOOLCHAIN_FILE=./scripts/toolchains/HiDEM-cray.cmake
make
make install
17 changes: 7 additions & 10 deletions scripts/compilation/compile_ubuntu.sh 100755 → 100644
@@ -1,10 +1,7 @@
#!/bin/bash
cd ./src/
mpif90 -g -fcheck=bounds typedefs.f90 utils.f90 io.f90 octree.F90 glas.f90 dist.f90 effload.f90 amat.f tmat.f ttmat.f kmat.f ranmar.f wave2.f90 -I/usr/include/mpi/ -I/usr/include/ -L/usr/lib/x86_64-linux-gnu/ -lmetis -o ../HiDEM
rm inout.mod
rm typedefs.mod
rm lattice.mod
rm utils.mod
rm octree.mod
rm effl.mod
cd ..
module swap PrgEnv-gnu PrgEnv-cray
mkdir -p build #make dir if first build
cd build

cmake ../ -DCMAKE_INSTALL_PREFIX="." -DCMAKE_TOOLCHAIN_FILE=./scripts/toolchains/HiDEM-ubuntu.cmake
make
make install
21 changes: 21 additions & 0 deletions scripts/toolchains/HiDEM-cray.cmake
@@ -0,0 +1,21 @@
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_PROCESSOR x86_64)
SET(CMAKE_SYSTEM_VERSION 1)

# Specify the cross compilers (serial)
SET(CMAKE_C_COMPILER cc)
SET(CMAKE_Fortran_COMPILER ftn)
SET(CMAKE_CXX_COMPILER CC)

# Specify the cross compilers (parallel)
SET(MPI_C_COMPILER cc)
SET(MPI_CXX_COMPILER CC)
SET(MPI_Fortran_COMPILER ftn)

# Compilation flags (i.e. with optimization)
SET(CMAKE_C_FLAGS "-O3 -fPIC" CACHE STRING "")
SET(CMAKE_CXX_FLAGS "-O3 -fPIC" CACHE STRING "")
SET(CMAKE_Fortran_FLAGS "-O3 -fPIC" CACHE STRING "")

SET ( MPIEXEC "aprun" CACHE STRING "")
SET ( MPIEXEC_NUMPROC_FLAG "-n" CACHE STRING "")
18 changes: 18 additions & 0 deletions scripts/toolchains/HiDEM-ubuntu.cmake
@@ -0,0 +1,18 @@
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_PROCESSOR x86_64)
SET(CMAKE_SYSTEM_VERSION 1)

# Specify the cross compilers (serial)
SET(CMAKE_C_COMPILER gcc)
SET(CMAKE_Fortran_COMPILER gfortran)
SET(CMAKE_CXX_COMPILER g++)

# Specify the cross compilers (parallel) - don't think these are used
SET(MPI_C_COMPILER mpicc)
SET(MPI_CXX_COMPILER mpic++)
SET(MPI_Fortran_COMPILER mpif90)

# Compilation flags (i.e. with optimization)
SET(CMAKE_C_FLAGS "-O3 -fPIC" CACHE STRING "")
SET(CMAKE_CXX_FLAGS "-O3 -fPIC" CACHE STRING "")
SET(CMAKE_Fortran_FLAGS "-O3 -fPIC" CACHE STRING "")
26 changes: 26 additions & 0 deletions src/CMakeLists.txt
@@ -0,0 +1,26 @@
#Define the source code which makes up HiDEM
add_executable (HiDEM typedefs.f90 utils.f90 io.f90 octree.F90 glas.f90 effload.f90 amat.f tmat.f ttmat.f kmat.f ranmar.f wave2.f90)

#Locate MPI and add relevant flags, links
find_package(MPI REQUIRED)

if(MPI_Fortran_COMPILE_FLAGS)
set_target_properties(HiDEM PROPERTIES
COMPILE_FLAGS "${MPI_Fortran_COMPILE_FLAGS}")
endif()

if(MPI_Fortran_LINK_FLAGS)
set_target_properties(HiDEM PROPERTIES
LINK_FLAGS "${MPI_Fortran_LINK_FLAGS}")
endif()

if(MPI_Fortran_INCLUDE_PATH)
include_directories(${MPI_Fortran_INCLUDE_PATH})
endif()

target_link_libraries(HiDEM ${MPI_Fortran_LIBRARIES})

#Link to previously compiled metis library
target_link_libraries(HiDEM metis)

INSTALL(TARGETS HiDEM RUNTIME DESTINATION ".")

0 comments on commit 1754b30

Please sign in to comment.