Skip to content
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ _*
m3dc1_meshgen.log
plot_geo
unstructured/templates/*/*/*.txt

# Ignore cmake build files
CMakeCache.txt
CMakeFiles
96 changes: 96 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
cmake_minimum_required(VERSION 3.8)
project(m3dc1 LANGUAGES Fortran C CXX)

macro(checkSetParam varName isRequired)
if("${${varName}}" STREQUAL "") # if varName is empty
set(${varName} $ENV{${varName}})
if(("${${varName}}" STREQUAL "") AND ${isRequired}) # if ENV{varName} is empty also
message(FATAL_ERROR
"${varName} is not defined or in the environment, please specify ${varName}")
endif()
endif()
endmacro(checkSetParam varName)

cmake_host_system_information(RESULT HOST QUERY HOSTNAME)
message(STATUS "Configuring to build on: ${HOST}")

# rhel/centos place x86-64 libs in lib64 instead of lib
# this *shouldn't* effect searching the lib directory
# first on other distros where the default install location
# is lib instead of lib64 (like debian derivatives)
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE)

# prefer static libraries unless we explicitly specify no to
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a" ".so")
if(BUILD_SHARED_LIBS)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".a")
endif()

# set the build type logically
# default is Debug if .git directory exists
# otherwise default is Release
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(BuildType)

# add C++ compiler flags
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Cray")
# todo : set cray-specific cxx flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "XL")
# todo : check for regular xl vs bg/q xl compiler
# currently assuming bg/q
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -qflag=w -glanglvl=extended0x")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
# todo : set intel-specific cxx flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# todo : version checks to see which c++ standards are available
# and warn/error if the version is incompatible
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -Wextra")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# todo : version checks to see which c++ standards are available
# and warn/error if the version is incompatible
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z -Wall -Wextra")
endif()

# add C compiler flags
if("${CMAKE_C_COMPILER_ID}" STREQUAL "Cray")
# todo : set cray-specific c flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "XL")
# todo : set xl-specific c flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel")
# todo : set intel-specific c flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
# todo : version checks to see which c standards are available
# and warn/error if the version is incompatible
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# todo : version checks to see which c++ standards are available
# and warn/error if the version is incompatible
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
endif()

# add Fortran compiler flags
if("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "Cray")
# todo : set cray-specific fortran flags
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}")
elseif("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "XL")
# todo : set xl-specific fortran flags
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}")
elseif("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "Intel")
# todo : set intel-specific fortran flags
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g noarg_temp_created")
elseif("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fdefault-real-8 -Wall -cpp")
elseif("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fdefault-real-8 -Wall -cpp")
endif()

message(STATUS "Configuring m3dc1_scorec")
add_subdirectory(m3dc1_scorec)
message(STATUS "Configuring unstructured")
add_subdirectory(unstructured)

21 changes: 21 additions & 0 deletions build/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

CC=$(which mpicc)
CXX=$(which mpicxx)
FORT=$(which mpif90)

cmake \
-DCMAKE_C_COMPILER=$CC \
-DCMAKE_CXX_COMPILER=$CXX \
-DCMAKE_Fortran_COMPILER=$FORT \
-DCMAKE_INSTALL_PREFIX=$DEVROOT/install/m3dc1 \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
-DUSE3D=1 \
-DUSESCOREC=1 \
-DM3DC1_ARCH=scorec \
-DSCOREC_LIB_DIR=$DEVROOT/install/core/lib \
-DSCOREC_INCLUDE_DIR=$DEVROOT/install/core/include \
-DPETSC_DIR=$PETSC_DIR \
-DPETSC_ARCH=$PETSC_ARCH \
-DENABLE_TESTING=1 \
..
14 changes: 14 additions & 0 deletions cmake/BuildType.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Set a default build type if none was specified
set(default_build_type "Release")
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
set(default_build_type "Debug")
endif()

if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
endif()
8 changes: 8 additions & 0 deletions cmake/FindFFTW.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
find_library(FFTW_LIB fftw3)
find_library(FFTW_THREADS_LIB fftw3_threads)

set(FFTW_LIBRARIES ${FFTW_LIB} ${FFTW_THREADS_LIB})
#message(STATUS "FFTW Libraries : ${FFTW_LIBRARIES}")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FFTW DEFAULT_MSG FFTW_LIBRARIES)
mark_as_advanced(FFTW_LIBRARIES)
8 changes: 8 additions & 0 deletions cmake/FindGSL.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
find_library(GSL_LIB gsl)
find_library(GSL_CBLAS_LIB gslcblas)

set(GSL_LIBRARIES ${GSL_LIB} ${GSL_CBLAS_LIB})
#message(STATUS "GSL Libraries : ${GSL_LIBRARIES}")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GSL DEFAULT_MSG GSL_LIBRARIES)
mark_as_advanced(GSL_LIBRARIES)
17 changes: 17 additions & 0 deletions cmake/FindPARMETIS.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
if(NOT PARMETIS_FOUND)
find_library(PARMETIS_LIBRARY parmetis)
find_library(METIS_LIBRARY metis)
if(PARMETIS_FIND_REQUIRED)
if(NOT PARMETIS_LIBRARY)
message(FATAL_ERROR "Required library Parmetis not found!")
elseif(NOT METIS_LIBRARY)
message(FATAL_ERROR "Required library Metis not found!")
endif()
endif()
set(PARMETIS_LIBRARIES ${PARMETIS_LIBRARY} ${METIS_LIBRARY})
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PARMETIS DEFAULT_MSG PARMETIS_LIBRARIES)
mark_as_advanced(PARMETIS_LIBRARIES)

53 changes: 53 additions & 0 deletions cmake/FindPETSc.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
find_package(PkgConfig REQUIRED QUIET)

checkSetParam(PETSC_DIR REQUIRED)
checkSetParam(PETSC_ARCH REQUIRED)
list(APPEND CMAKE_PREFIX_PATH "${PETSC_DIR}/${PETSC_ARCH}")
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH true)

if(PETSC_FIND_REQUIRED)
set(_PETSC_OPTS "REQUIRED")
endif()
if(PETSC_FIND_QUIETLY)
set(_PETSC_OPTS "QUIET")
endif()
if(PETSC_FIND_REQUIRED AND PETSC_FIND_QUIETLY)
set(_PETSC_OPTS "REQUIRED QUIET")
endif()

pkg_check_modules(PETSC ${_PETSC_OPTS} PETSc)

#TODO : set the below XXX_LIBRARIES and XXX_INCLUDE_DIRS for petsc external libs
if(PETSC_FOUND)
# todo : finding the external packages as PETSc dependencies currently relies on this *.cmake file
# it would be preferable for this functionality to be included in the relavent FindXXX.cmake files
# for each package
include(${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/PETScBuildInternal.cmake)
set(PETSC_INCLUDE_DIRS "${PETSC_STATIC_INCLUDE_DIRS}")
set(PETSC_LIBRARIES "${PETSC_STATIC_LDFLAGS};${PETSC_STATIC_LIBRARIES}")
if(PETSC_ZOLTAN_LIB)
message(STATUS "Found Zoltan library as PETSc dependency.")
set(ZOLTAN_FOUND true)
set(ZOLTAN_LIBRARIES ${PETSC_ZOLTAN_LIB} ${PETSC_PTSCOTCH_LIB} ${PETSC_PTSCOTCH_LIB} ${PETSC_SCOTCH_LIB} ${PETSC_SCOTCHERR_LIB})
set(ZOLTAN_INCLUDE_DIRS )
endif()
if(PETSC_PARMETIS_LIB)
message(STATUS "Found Metis/Parmetis library as PETSc dependency.")
set(PARMETIS_FOUND true)
set(METIS_FOUND true)
set(PARMETIS_LIBRARIES ${PETSC_PARMETIS_LIB} ${PETSC_METIS_LIB})
set(METIS_LIBRARIES ${PETSC_METIS_LIB})
set(PARMETIS_INCLUDE_DIRS )
set(METIS_INCLUDE_DIRS )
endif()
if(PETSC_HDF5_LIB)
message(STATUS "Found HDF5 library as PETSc dependency.")
set(HDF5_FOUND true)
set(HDF5_LIBRARIES ${PETSC_NDF5HL_FORTRAN_LIB} ${PETSC_HDF5_FORTRAN_LIB} ${PETSC_HDF5_HL_LIB} ${PETSC_HDF5_LIB})
set(HDF5_INCLUDE_DIRS )
endif()
endif(PETSC_FOUND)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PETSC DEFAULT_MSG PETSC_LIBRARIES PETSC_INCLUDE_DIRS)
mark_as_advanced(PETSC_LIBRARIES PETSC_INCLUDE_DIRS)
111 changes: 111 additions & 0 deletions cmake/FindScorec.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# - Try to find SCOREC PUMI libraries
# Once done this will define
# SCOREC_FOUND - System has SCOREC
# SCOREC_INCLUDE_DIRS - The SCOREC include directories
# SCOREC_LIBRARIES - The libraries needed to use SCOREC
# SCOREC_DEFINITIONS - Compiler switches required for using SCOREC
#
# This implementation assumes a SCOREC install has the following structure
# VERSION/
# include/*.h
# lib/*.a

macro(scorecLibCheck libs isRequired)
foreach(lib ${libs})
unset(scoreclib CACHE)
find_library(scoreclib "${lib}" PATHS ${SCOREC_LIB_DIR})
if(scoreclib MATCHES "^scoreclib-NOTFOUND$")
if(${isRequired})
message(FATAL_ERROR "SCOREC library ${lib} not found in ${SCOREC_LIB_DIR}")
else()
message("SCOREC library ${lib} not found in ${SCOREC_LIB_DIR}")
endif()
else()
set("SCOREC_${lib}_FOUND" TRUE CACHE INTERNAL "SCOREC library present")
set(SCOREC_LIBS ${SCOREC_LIBS} ${scoreclib})
endif()
endforeach()
endmacro(scorecLibCheck)

find_package(ZOLTAN REQUIRED)
find_package(PARMETIS REQUIRED)

set(SCOREC_LIBS "")
if(ENABLE_SIMMETRIX)
set(SCOREC_LIB_NAMES
pumi
ma
mds
apf
apf_sim
apf_zoltan
parma
dsp
gmi
gmi_sim
mth
pcu
sam
spr
crv
lion
ph
size
)
else()
set(SCOREC_LIB_NAMES
pumi
ma
crv
ph
sam
spr
apf_zoltan
parma
mds
apf
lion
gmi
mth
pcu
)
endif()
scorecLibCheck("${SCOREC_LIB_NAMES}" TRUE)

find_path(SCOREC_INCLUDE_DIR
NAMES apf.h PCU.h ma.h
PATHS ${SCOREC_INCLUDE_DIR})
if(NOT EXISTS "${SCOREC_INCLUDE_DIR}")
message(FATAL_ERROR "SCOREC include dir not found")
endif()

string(REGEX REPLACE
"/include$" ""
SCOREC_INSTALL_DIR
"${SCOREC_INCLUDE_DIR}")

set(SCOREC_LIBRARIES ${SCOREC_LIBS} ${ZOLTAN_LIBRARIES} ${PARMETIS_LIBRARIES})
set(SCOREC_INCLUDE_DIRS ${SCOREC_INCLUDE_DIR})

include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments
find_package_handle_standard_args(SCOREC DEFAULT_MSG
SCOREC_LIBRARIES SCOREC_INCLUDE_DIR)

mark_as_advanced(SCOREC_INCLUDE_DIR SCOREC_LIBRARIES)

set(SCOREC_LINK_LIBS "")
foreach(lib ${SCOREC_LIB_NAMES})
set(SCOREC_LINK_LIBS "${SCOREC_LINK_LIBS} -l${lib}")
endforeach()

#pkgconfig
set(prefix "${SCOREC_INSTALL_DIR}")
set(includedir "${SCOREC_INCLUDE_DIR}")
configure_file(
"${CMAKE_SOURCE_DIR}/cmake/libScorec.pc.in"
"${CMAKE_BINARY_DIR}/libScorec.pc"
@ONLY)

INSTALL(FILES "${CMAKE_BINARY_DIR}/libScorec.pc" DESTINATION lib/pkgconfig)

11 changes: 11 additions & 0 deletions cmake/FindZOLTAN.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
if(NOT ZOLTAN_FOUND)
find_library(ZOLTAN_LIBRARY zoltan)
if(ZOLTAN_FIND_REQUIRED AND NOT ZOLTAN_LIBRARY)
message(FATAL_ERROR "Require library Zoltan not found!")
endif()
set(ZOLTAN_LIBRARIES ${ZOLTAN_LIBRARY})
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ZOLTAN DEFAULT_MSG ZOLTAN_LIBRARIES)
mark_as_advanced(ZOLTAN_LIBRARIES)
10 changes: 10 additions & 0 deletions cmake/libScorec.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
prefix=@prefix@
libdir=@prefix@/lib
includedir=@includedir@

Name: SCOREC libraries
URL: http://www.scorec.rpi.edu
Description: SCOREC PUMI and MeshAdapt
Version: 1.0
Libs: -L${libdir} @SCOREC_LINK_LIBS@ -lzoltan -lparmetis -lmetis -lstd++
Cflags: -I${includedir}
10 changes: 10 additions & 0 deletions cmake/libSimmetrix.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
prefix=@prefix@
libdir=@prefix@/lib
includedir=@includedir@

Name: SIMMETRIX libraries
URL: http://www.simmetrix.com
Description: SIMMETRIX
Version: 1.0
Libs: -L${libdir} @SIMMETRIX_LINK_LIBS@
Cflags: -I${includedir}
Loading