using syntax with better error handling
This commit is contained in:
parent
0ee34d608c
commit
1c75a2e9cd
|
@ -5,7 +5,7 @@ cmake_minimum_required (VERSION 2.8.8 FATAL_ERROR)
|
||||||
#---------------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------------
|
||||||
# Find PETSc from system environment
|
# Find PETSc from system environment
|
||||||
set(PETSC_DIR $ENV{PETSC_DIR})
|
set(PETSC_DIR $ENV{PETSC_DIR})
|
||||||
if ("${PETSC_DIR}" STREQUAL "")
|
if (PETSC_DIR STREQUAL "")
|
||||||
message (FATAL_ERROR "PETSC_DIR is not defined")
|
message (FATAL_ERROR "PETSC_DIR is not defined")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
@ -105,11 +105,11 @@ set (CMAKE_C_COMPILER "${PETSC_MPICC}")
|
||||||
# Now start to care about DAMASK
|
# Now start to care about DAMASK
|
||||||
|
|
||||||
# DAMASK solver defines project to build
|
# DAMASK solver defines project to build
|
||||||
if ("${DAMASK_SOLVER}" STREQUAL "SPECTRAL")
|
if (DAMASK_SOLVER STREQUAL "SPECTRAL")
|
||||||
project (DAMASK_spectral Fortran C)
|
project (DAMASK_spectral Fortran C)
|
||||||
add_definitions (-DSpectral)
|
add_definitions (-DSpectral)
|
||||||
message ("Building Spectral Solver\n")
|
message ("Building Spectral Solver\n")
|
||||||
elseif ("${DAMASK_SOLVER}" STREQUAL "FEM")
|
elseif (DAMASK_SOLVER STREQUAL "FEM")
|
||||||
project (DAMASK_FEM Fortran C)
|
project (DAMASK_FEM Fortran C)
|
||||||
add_definitions (-DFEM)
|
add_definitions (-DFEM)
|
||||||
message ("Building FEM Solver\n")
|
message ("Building FEM Solver\n")
|
||||||
|
@ -120,39 +120,39 @@ endif ()
|
||||||
# set linker commands (needs to be done after defining the project)
|
# set linker commands (needs to be done after defining the project)
|
||||||
set (CMAKE_LINKER "${PETSC_LINKER}")
|
set (CMAKE_LINKER "${PETSC_LINKER}")
|
||||||
|
|
||||||
if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
|
if (CMAKE_BUILD_TYPE STREQUAL "")
|
||||||
set (CMAKE_BUILD_TYPE "RELEASE")
|
set (CMAKE_BUILD_TYPE "RELEASE")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# Predefined sets for OPTIMIZATION/OPENMP based on BUILD_TYPE
|
# Predefined sets for OPTIMIZATION/OPENMP based on BUILD_TYPE
|
||||||
if ("${CMAKE_BUILD_TYPE}" STREQUAL "DEBUG" OR "${CMAKE_BUILD_TYPE}" STREQUAL "SYNTAXONLY" )
|
if (CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "SYNTAXONLY")
|
||||||
set (DEBUG_FLAGS "${DEBUG_FLAGS} -DDEBUG")
|
set (DEBUG_FLAGS "${DEBUG_FLAGS} -DDEBUG")
|
||||||
set (PARALLEL "OFF")
|
set (PARALLEL "OFF")
|
||||||
set (OPTI "OFF")
|
set (OPTI "OFF")
|
||||||
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "RELEASE")
|
elseif (CMAKE_BUILD_TYPE STREQUAL "RELEASE")
|
||||||
set (PARALLEL "ON")
|
set (PARALLEL "ON")
|
||||||
set (OPTI "DEFENSIVE")
|
set (OPTI "DEFENSIVE")
|
||||||
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "PERFORMANCE")
|
elseif (CMAKE_BUILD_TYPE STREQUAL "PERFORMANCE")
|
||||||
set (PARALLEL "ON")
|
set (PARALLEL "ON")
|
||||||
set (OPTI "AGGRESSIVE")
|
set (OPTI "AGGRESSIVE")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# $OPTIMIZATION takes precedence over $BUILD_TYPE defaults
|
# $OPTIMIZATION takes precedence over $BUILD_TYPE defaults
|
||||||
if ("${OPTIMIZATION}" STREQUAL "")
|
if (OPTIMIZATION STREQUAL "")
|
||||||
set (OPTIMIZATION "${OPTI}")
|
set (OPTIMIZATION "${OPTI}")
|
||||||
else ()
|
else ()
|
||||||
set (OPTIMIZATION "${OPTIMIZATION}")
|
set (OPTIMIZATION "${OPTIMIZATION}")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# $OPENMP takes precedence over $BUILD_TYPE defaults
|
# $OPENMP takes precedence over $BUILD_TYPE defaults
|
||||||
if ("${OPENMP}" STREQUAL "")
|
if (OPENMP STREQUAL "")
|
||||||
set (OPENMP "${PARALLEL}")
|
set (OPENMP "${PARALLEL}")
|
||||||
else ()
|
else ()
|
||||||
set(OPENMP "${OPENMP}")
|
set(OPENMP "${OPENMP}")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# syntax check only (mainly for pre-receive hook, works only with gfortran)
|
# syntax check only (mainly for pre-receive hook, works only with gfortran)
|
||||||
if ("${CMAKE_BUILD_TYPE}" STREQUAL "SYNTAXONLY" )
|
if (CMAKE_BUILD_TYPE STREQUAL "SYNTAXONLY")
|
||||||
set (BUILDCMD_POST "${BUILDCMD_POST} -fsyntax-only")
|
set (BUILDCMD_POST "${BUILDCMD_POST} -fsyntax-only")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
@ -190,17 +190,17 @@ set (DAMASK_INCLUDE_FLAGS "${DAMASK_INCLUDE_FLAGS} ${PETSC_INCLUDES}")
|
||||||
###################################################################################################
|
###################################################################################################
|
||||||
# Intel Compiler
|
# Intel Compiler
|
||||||
###################################################################################################
|
###################################################################################################
|
||||||
if ("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "Intel")
|
if (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
|
||||||
|
|
||||||
if (OPENMP)
|
if (OPENMP)
|
||||||
set (OPENMP_FLAGS "-qopenmp -parallel")
|
set (OPENMP_FLAGS "-qopenmp -parallel")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if ("${OPTIMIZATION}" STREQUAL "OFF")
|
if (OPTIMIZATION STREQUAL "OFF")
|
||||||
set (OPTIMIZATION_FLAGS "-O0 -no-ip")
|
set (OPTIMIZATION_FLAGS "-O0 -no-ip")
|
||||||
elseif ("${OPTIMIZATION}" STREQUAL "DEFENSIVE")
|
elseif (OPTIMIZATION STREQUAL "DEFENSIVE")
|
||||||
set (OPTIMIZATION_FLAGS "-O2")
|
set (OPTIMIZATION_FLAGS "-O2")
|
||||||
elseif ("${OPTIMIZATION}" STREQUAL "AGGRESSIVE")
|
elseif (OPTIMIZATION STREQUAL "AGGRESSIVE")
|
||||||
set (OPTIMIZATION_FLAGS "-ipo -O3 -no-prec-div -fp-model fast=2 -xHost")
|
set (OPTIMIZATION_FLAGS "-ipo -O3 -no-prec-div -fp-model fast=2 -xHost")
|
||||||
# -fast = -ipo, -O3, -no-prec-div, -static, -fp-model fast=2, and -xHost"
|
# -fast = -ipo, -O3, -no-prec-div, -static, -fp-model fast=2, and -xHost"
|
||||||
endif ()
|
endif ()
|
||||||
|
@ -310,17 +310,17 @@ if ("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "Intel")
|
||||||
###################################################################################################
|
###################################################################################################
|
||||||
# GNU Compiler
|
# GNU Compiler
|
||||||
###################################################################################################
|
###################################################################################################
|
||||||
elseif("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "GNU")
|
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
|
||||||
|
|
||||||
if (OPENMP)
|
if (OPENMP)
|
||||||
set (OPENMP_FLAGS "-fopenmp")
|
set (OPENMP_FLAGS "-fopenmp")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if ("${OPTIMIZATION}" STREQUAL "OFF")
|
if (OPTIMIZATION STREQUAL "OFF")
|
||||||
set (OPTIMIZATION_FLAGS "-O0" )
|
set (OPTIMIZATION_FLAGS "-O0" )
|
||||||
elseif ("${OPTIMIZATION}" STREQUAL "DEFENSIVE")
|
elseif (OPTIMIZATION STREQUAL "DEFENSIVE")
|
||||||
set (OPTIMIZATION_FLAGS "-O2")
|
set (OPTIMIZATION_FLAGS "-O2")
|
||||||
elseif ("${OPTIMIZATION}" STREQUAL "AGGRESSIVE")
|
elseif (OPTIMIZATION STREQUAL "AGGRESSIVE")
|
||||||
set (OPTIMIZATION_FLAGS "-O3 -ffast-math -funroll-loops -ftree-vectorize")
|
set (OPTIMIZATION_FLAGS "-O3 -ffast-math -funroll-loops -ftree-vectorize")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
@ -450,7 +450,7 @@ endif ()
|
||||||
set (CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE} "${BUILDCMD_PRE} ${OPENMP_FLAGS} ${STANDARD_CHECK} ${OPTIMIZATION_FLAGS} ${COMPILE_FLAGS} ${PRECISION_FLAGS}")
|
set (CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE} "${BUILDCMD_PRE} ${OPENMP_FLAGS} ${STANDARD_CHECK} ${OPTIMIZATION_FLAGS} ${COMPILE_FLAGS} ${PRECISION_FLAGS}")
|
||||||
set (CMAKE_Fortran_LINK_EXECUTABLE "${BUILDCMD_PRE} ${CMAKE_LINKER} ${OPENMP_FLAGS} ${OPTIMIZATION_FLAGS} ${LINKER_FLAGS}")
|
set (CMAKE_Fortran_LINK_EXECUTABLE "${BUILDCMD_PRE} ${CMAKE_LINKER} ${OPENMP_FLAGS} ${OPTIMIZATION_FLAGS} ${LINKER_FLAGS}")
|
||||||
|
|
||||||
if ("${CMAKE_BUILD_TYPE}" STREQUAL "DEBUG")
|
if (CMAKE_BUILD_TYPE STREQUAL "DEBUG")
|
||||||
set (CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE} "${CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE}} ${DEBUG_FLAGS}")
|
set (CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE} "${CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE}} ${DEBUG_FLAGS}")
|
||||||
set (CMAKE_Fortran_LINK_EXECUTABLE "${CMAKE_Fortran_LINK_EXECUTABLE} ${DEBUG_FLAGS}")
|
set (CMAKE_Fortran_LINK_EXECUTABLE "${CMAKE_Fortran_LINK_EXECUTABLE} ${DEBUG_FLAGS}")
|
||||||
endif ()
|
endif ()
|
||||||
|
@ -466,15 +466,15 @@ message ("Fortran Linker Command:\n${CMAKE_Fortran_LINK_EXECUTABLE}\n")
|
||||||
add_subdirectory (src)
|
add_subdirectory (src)
|
||||||
|
|
||||||
# INSTALL BUILT BINARIES
|
# INSTALL BUILT BINARIES
|
||||||
if ("${CMAKE_BUILD_TYPE}" STREQUAL "SYNTAXONLY")
|
if (CMAKE_BUILD_TYPE STREQUAL "SYNTAXONLY")
|
||||||
exec_program (mktemp ARGS -d OUTPUT_VARIABLE BLACK_HOLE)
|
exec_program (mktemp ARGS -d OUTPUT_VARIABLE BLACK_HOLE)
|
||||||
install (PROGRAMS ${PROJECT_BINARY_DIR}/src/prec.mod
|
install (PROGRAMS ${PROJECT_BINARY_DIR}/src/prec.mod
|
||||||
DESTINATION ${BLACK_HOLE})
|
DESTINATION ${BLACK_HOLE})
|
||||||
else ()
|
else ()
|
||||||
if ("${PROJECT_NAME}" STREQUAL "DAMASK_spectral")
|
if (PROJECT_NAME STREQUAL "DAMASK_spectral")
|
||||||
install (PROGRAMS ${PROJECT_BINARY_DIR}/src/DAMASK_spectral
|
install (PROGRAMS ${PROJECT_BINARY_DIR}/src/DAMASK_spectral
|
||||||
DESTINATION ${CMAKE_INSTALL_PREFIX})
|
DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||||
elseif ("${PROJECT_NAME}" STREQUAL "DAMASK_FEM")
|
elseif (PROJECT_NAME STREQUAL "DAMASK_FEM")
|
||||||
install (PROGRAMS ${PROJECT_BINARY_DIR}/src/DAMASK_FEM
|
install (PROGRAMS ${PROJECT_BINARY_DIR}/src/DAMASK_FEM
|
||||||
DESTINATION ${CMAKE_INSTALL_PREFIX})
|
DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||||
endif ()
|
endif ()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# special flags for some files
|
# special flags for some files
|
||||||
if ("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "GNU")
|
if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
|
||||||
SET_SOURCE_FILES_PROPERTIES( "lattice.f90" PROPERTIES
|
SET_SOURCE_FILES_PROPERTIES( "lattice.f90" PROPERTIES
|
||||||
COMPILE_FLAGS "-ffree-line-length-240")
|
COMPILE_FLAGS "-ffree-line-length-240")
|
||||||
# long lines for interaction matrix
|
# long lines for interaction matrix
|
||||||
|
@ -18,9 +18,9 @@ add_library(PREC OBJECT "prec.f90")
|
||||||
add_dependencies(PREC SYSTEM_ROUTINES)
|
add_dependencies(PREC SYSTEM_ROUTINES)
|
||||||
list(APPEND OBJECTFILES $<TARGET_OBJECTS:PREC>)
|
list(APPEND OBJECTFILES $<TARGET_OBJECTS:PREC>)
|
||||||
|
|
||||||
if ("${PROJECT_NAME}" STREQUAL "DAMASK_spectral")
|
if (PROJECT_NAME STREQUAL "DAMASK_spectral")
|
||||||
add_library(DAMASK_INTERFACE OBJECT "spectral_interface.f90")
|
add_library(DAMASK_INTERFACE OBJECT "spectral_interface.f90")
|
||||||
elseif ("${PROJECT_NAME}" STREQUAL "DAMASK_FEM")
|
elseif (PROJECT_NAME STREQUAL "DAMASK_FEM")
|
||||||
add_library(DAMASK_INTERFACE OBJECT "FEM_interface.f90")
|
add_library(DAMASK_INTERFACE OBJECT "FEM_interface.f90")
|
||||||
else ()
|
else ()
|
||||||
message ( FATAL_ERROR "PROJECT_NAME is not defined!")
|
message ( FATAL_ERROR "PROJECT_NAME is not defined!")
|
||||||
|
@ -49,11 +49,11 @@ add_dependencies(DAMASK_MATH FEsolving)
|
||||||
list(APPEND OBJECTFILES $<TARGET_OBJECTS:DAMASK_MATH>)
|
list(APPEND OBJECTFILES $<TARGET_OBJECTS:DAMASK_MATH>)
|
||||||
|
|
||||||
# SPECTRAL solver and FEM solver use different mesh files
|
# SPECTRAL solver and FEM solver use different mesh files
|
||||||
if ("${PROJECT_NAME}" STREQUAL "DAMASK_spectral")
|
if (PROJECT_NAME STREQUAL "DAMASK_spectral")
|
||||||
add_library(MESH OBJECT "mesh.f90")
|
add_library(MESH OBJECT "mesh.f90")
|
||||||
add_dependencies(MESH DAMASK_MATH)
|
add_dependencies(MESH DAMASK_MATH)
|
||||||
list(APPEND OBJECTFILES $<TARGET_OBJECTS:MESH>)
|
list(APPEND OBJECTFILES $<TARGET_OBJECTS:MESH>)
|
||||||
elseif ("${PROJECT_NAME}" STREQUAL "DAMASK_FEM")
|
elseif (PROJECT_NAME STREQUAL "DAMASK_FEM")
|
||||||
add_library(FEZoo OBJECT "FEZoo.f90")
|
add_library(FEZoo OBJECT "FEZoo.f90")
|
||||||
add_dependencies(FEZoo DAMASK_MATH)
|
add_dependencies(FEZoo DAMASK_MATH)
|
||||||
list(APPEND OBJECTFILES $<TARGET_OBJECTS:FEZoo>)
|
list(APPEND OBJECTFILES $<TARGET_OBJECTS:FEZoo>)
|
||||||
|
@ -160,7 +160,7 @@ add_library(DAMASK_CPFE OBJECT "CPFEM2.f90")
|
||||||
add_dependencies(DAMASK_CPFE DAMASK_ENGINE)
|
add_dependencies(DAMASK_CPFE DAMASK_ENGINE)
|
||||||
list(APPEND OBJECTFILES $<TARGET_OBJECTS:DAMASK_CPFE>)
|
list(APPEND OBJECTFILES $<TARGET_OBJECTS:DAMASK_CPFE>)
|
||||||
|
|
||||||
if ("${PROJECT_NAME}" STREQUAL "DAMASK_spectral")
|
if (PROJECT_NAME STREQUAL "DAMASK_spectral")
|
||||||
add_library(SPECTRAL_UTILITIES OBJECT "spectral_utilities.f90")
|
add_library(SPECTRAL_UTILITIES OBJECT "spectral_utilities.f90")
|
||||||
add_dependencies(SPECTRAL_UTILITIES DAMASK_CPFE)
|
add_dependencies(SPECTRAL_UTILITIES DAMASK_CPFE)
|
||||||
list(APPEND OBJECTFILES $<TARGET_OBJECTS:SPECTRAL_UTILITIES>)
|
list(APPEND OBJECTFILES $<TARGET_OBJECTS:SPECTRAL_UTILITIES>)
|
||||||
|
@ -172,13 +172,13 @@ if ("${PROJECT_NAME}" STREQUAL "DAMASK_spectral")
|
||||||
"spectral_mech_Basic.f90")
|
"spectral_mech_Basic.f90")
|
||||||
add_dependencies(SPECTRAL_SOLVER SPECTRAL_UTILITIES)
|
add_dependencies(SPECTRAL_SOLVER SPECTRAL_UTILITIES)
|
||||||
list(APPEND OBJECTFILES $<TARGET_OBJECTS:SPECTRAL_SOLVER>)
|
list(APPEND OBJECTFILES $<TARGET_OBJECTS:SPECTRAL_SOLVER>)
|
||||||
if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "SYNTAXONLY")
|
if(NOT CMAKE_BUILD_TYPE STREQUAL "SYNTAXONLY")
|
||||||
add_executable(DAMASK_spectral "DAMASK_spectral.f90" ${OBJECTFILES})
|
add_executable(DAMASK_spectral "DAMASK_spectral.f90" ${OBJECTFILES})
|
||||||
else()
|
else()
|
||||||
add_library(DAMASK_spectral OBJECT "DAMASK_spectral.f90")
|
add_library(DAMASK_spectral OBJECT "DAMASK_spectral.f90")
|
||||||
endif()
|
endif()
|
||||||
add_dependencies(DAMASK_spectral SPECTRAL_SOLVER)
|
add_dependencies(DAMASK_spectral SPECTRAL_SOLVER)
|
||||||
elseif ("${PROJECT_NAME}" STREQUAL "DAMASK_FEM")
|
elseif (PROJECT_NAME STREQUAL "DAMASK_FEM")
|
||||||
add_library(FEM_UTILITIES OBJECT "FEM_utilities.f90")
|
add_library(FEM_UTILITIES OBJECT "FEM_utilities.f90")
|
||||||
add_dependencies(FEM_UTILITIES DAMASK_CPFE)
|
add_dependencies(FEM_UTILITIES DAMASK_CPFE)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue