use options for future cross-platform support

This commit is contained in:
zhangc43 2016-03-14 15:57:19 -04:00
parent cfddba930b
commit 7aadfd56ca
4 changed files with 89 additions and 16 deletions

View File

@ -25,7 +25,6 @@ set (petsc_config_makefile "${PETSC_TEMP}/Makefile.petsc")
file (WRITE "${petsc_config_makefile}"
"## This file was auto generated by CMake
# PETSC_DIR = ${PETSC_DIR}
# PETSC_ARCH = ${PETSC_ARCH}
SHELL = /bin/sh
include ${petsc_conf_rules}
include ${petsc_conf_variables}
@ -99,11 +98,21 @@ endforeach(exlib)
set(CMAKE_Fortran_COMPILER "${MPIEXEC}")
project (DAMASK Fortran)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
find_package(FFTW REQUIRED)
find_package(PythonInterp REQUIRED)
find_program(F2PY_EXECUTABLE NAMES "f2py${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}"
"f2py-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}"
"f2py${PYTHON_VERSION_MAJOR}"
"f2py")
message("***Found PETSC_DIR:\n${PETSC_DIR}\n" )
message("***Found PETSC_INCLUDES:\n${PETSC_INCLUDES}\n" )
message("***Found PETSC_EXTERNAL_LIB:\n${PETSC_EXTERNAL_LIB}\n")
message("***Found PETSC_LINKER:\n${PETSC_LINKER}\n" )
message("***Found FORTRAN MPI COMPILER:\n${MPIEXEC}\n" )
message("***Found FFTW_LIB:\n${FFTW_LIBRARIES}")
# # https://cmake.org/Wiki/CMake_FAQ#How_do_I_use_a_different_compiler.3F
@ -114,6 +123,14 @@ message("***Found FORTRAN MPI COMPILER:\n${MPIEXEC}\n" )
set (DAMASK_VERSION_MAJOR 1)
set (DAMASK_VERSION_MINOR ${DAMASK_V})
# Built-in options for DAMASK build system
# -> can be overwritten from commandline/install_script
option(OPENMP "Use OpenMP libaries for DAMASK" ON )
option(DAMASK_PROCESSING "Build pre/post processing modules for DAMASK" OFF )
option(OPTIMIZATION "DAMASK optimization level [OFF,DEFENSIVE,AGGRESSIVE,ULTRA]" NONE)
option(SPECTRAL "Build spectral sovler for DAMASAK" OFF )
option(FEM "Builb FEM solver for DAMASK" OFF )
# COMPILE VARIABLES
add_definitions(-DDAMASKVERSION="${DAMASK_V}")
add_definitions(-DPETSc)
@ -142,7 +159,7 @@ endif()
set (DAMASK_INCLUDE_FLAGS "${DAMASK_INCLUDE_FLAGS} ${PETSC_INCLUDES}" )
set (DAMASK_INCLUDE_FLAGS "${DAMASK_INCLUDE_FLAGS} -I${PROJECT_SOURCE_DIR}/lib")
if ("${OPTIMIZATION}" STREQUAL "OFF")
if ("${OPTIMIZATION}" STREQUAL "NONE")
set (OPTIMIZATION_ifort "-O0 -no-ip")
set (OPTIMIZATION_gfortran "-O0" )
elseif ("${OPTIMIZATION}" STREQUAL "DEFENSIVE")
@ -445,6 +462,11 @@ elseif (FEM)
DESTINATION ${CMAKE_INSTALL_PREFIX})
endif(SPECTRAL)
if (DAMASK_PROCESSING)
INSTALL(PROGRAMS ${PROJECT_BINARY_DIR}/src/core.so
DESTINATION ${PROJECT_SOURCE_DIR}/lib/damask)
endif(DAMASK_PROCESSING)
##
# ADD TESTING CASES
# add_test (SmokeTestRun

View File

@ -30,6 +30,7 @@ cd FEM
# OPTIMIZATION | [OFF,DEFENSIVE,AGGRESSIVE,ULTRA]
# DAMASK_DRIVER | [SPECTRAL, FEM]
# DAMASK_INSTALL | Directory to install binary output
# INSTALL_PROCESSING | Build supporting pre/post processing scripts
cmake -D PETSC_DIR=${PETSC_DIR} \
-D DAMASK_V=${DAMASKVERSION} \
-D CMAKE_BUILD_TYPE=RELEASE \
@ -37,6 +38,7 @@ cmake -D PETSC_DIR=${PETSC_DIR} \
-D OPTIMIZATION=DEFENSIVE \
-D DAMASK_DRIVER=FEM \
-D DAMASK_INSTALL=${HOME}/bin \
-D INSTALL_PROCESSING=YES \
../..
echo

View File

@ -44,6 +44,7 @@ cmake -D PETSC_DIR=${PETSC_DIR} \
-D DAMASK_V=${DAMASKVERSION} \
-D CMAKE_BUILD_TYPE=RELEASE \
-D OPENMP=ON \
-D DAMASK_PROCESSING=ON \
-D OPTIMIZATION=DEFENSIVE \
-D DAMASK_DRIVER=SPECTRAL \
-D DAMASK_INSTALL=${HOME}/bin \

View File

@ -196,3 +196,51 @@ if (SPECTRAL)
add_executable(DAMASKSpectral.exe "DAMASK_spectral.f90")
target_link_libraries(DAMASKSpectral.exe DAMASK_EXE)
endif(SPECTRAL)
if (DAMASK_PROCESSING)
# set compiler flags based on type of compiler used
if (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
set(CORECOMPILER "${CORECOMPILER} --fcompiler=intelem")
set(CORECOMPILER "${CORECOMPILER} --f90flags=\"-fPIC -fpp -stand f08 -diag-disable 5268 -assume byterecl -real-size 64 -integer-size 32 -shared-intel\"")
elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
set(CORECOMPILER "${CORECOMPILER} --fcompiler=gnu95")
set(CORECOMPILER "${CORECOMPILER} --f90flags=\"-fPIC -fno-range-check -xf95-cpp-input -std=f2008 -fall-intrinsics -fdefault-real-8 -fdefault-double-8\"")
endif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
# set CORE compiler options
set(CORE_COMPILE_OPTIONS "${COMPILEROPTIONS} -DSpectral -DFLOAT=8 -DINT=4")
set(CORE_COMPILE_OPTIONS "${COMPILEROPTIONS} -I${PROJECT_SOURCE_DIR}/lib")
set(CORE_COMPILE_OPTIONS "${COMPILEROPTIONS} -DDAMASKVERSION=\\\"${DAMASK_V}\\\"")
# set CORE link flags
if (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
set(CORE_LDFLAGS "${CORE_LDFLAGS} -openmp -Wl")
elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
set(CORE_LDFLAGS "${CORE_LDFLAGS} -shared -Wl,-undefined,dynamic_lookup")
endif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
# source file for building core
set(COREFILES "${COREFILES} prec.f90" )
set(COREFILES "${COREFILES} spectral_interface.f90")
set(COREFILES "${COREFILES} IO.f90" )
set(COREFILES "${COREFILES} libs.f90" )
set(COREFILES "${COREFILES} numerics.f90" )
set(COREFILES "${COREFILES} debug.f90" )
set(COREFILES "${COREFILES} math.f90" )
set(COREFILES "${COREFILES} FEsolving.f90" )
set(COREFILES "${COREFILES} mesh.f90" )
set(COREFILES "${COREFILES} core_quit.f90" )
execute_process(COMMAND F2PY_EXECUTABLE damask.core.pyf )
endif(DAMASK_PROCESSING)