syntax polishing
This commit is contained in:
parent
a248a24250
commit
491fa52263
323
CMakeLists.txt
323
CMakeLists.txt
|
@ -7,19 +7,20 @@ cmake_minimum_required (VERSION 2.8.8 FATAL_ERROR)
|
||||||
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 ("${PETSC_DIR}" STREQUAL "")
|
endif
|
||||||
|
|
||||||
|
set (petsc_conf_variables "${PETSC_DIR}/lib/petsc/conf/variables")
|
||||||
|
set (petsc_conf_rules "${PETSC_DIR}/lib/petsc/conf/rules" )
|
||||||
|
|
||||||
# Use existing variables from PETSc
|
# Use existing variables from PETSc
|
||||||
# https://github.com/jedbrown/cmake-modules/blob/master/FindPETSc.cmake
|
# https://github.com/jedbrown/cmake-modules/blob/master/FindPETSc.cmake
|
||||||
exec_program(mktemp ARGS -d OUTPUT_VARIABLE PETSC_TEMP)
|
|
||||||
|
|
||||||
set(petsc_conf_variables "${PETSC_DIR}/lib/petsc/conf/variables")
|
|
||||||
set(petsc_conf_rules "${PETSC_DIR}/lib/petsc/conf/rules" )
|
|
||||||
# Generate a temporary makefile to probe the PETSc configuration
|
# Generate a temporary makefile to probe the PETSc configuration
|
||||||
# This file will be deleted once the settings from PETSc are parsed
|
# This file will be deleted
|
||||||
# into CMake
|
# once the settings from PETSc are parsed into CMake
|
||||||
set (petsc_config_makefile "${PETSC_TEMP}/Makefile.petsc")
|
|
||||||
|
|
||||||
|
exec_program (mktemp ARGS -d OUTPUT_VARIABLE TEMPDIR)
|
||||||
|
set (petsc_config_makefile "${TEMPDIR}/Makefile.petsc")
|
||||||
file (WRITE
|
file (WRITE
|
||||||
"${petsc_config_makefile}"
|
"${petsc_config_makefile}"
|
||||||
"## This file was auto generated by CMake
|
"## This file was auto generated by CMake
|
||||||
|
@ -48,149 +49,149 @@ linker:
|
||||||
# to acquire corresponding PETSc Variables.
|
# to acquire corresponding PETSc Variables.
|
||||||
find_program (MAKE_EXECUTABLE NAMES make gmake)
|
find_program (MAKE_EXECUTABLE NAMES make gmake)
|
||||||
# Find the PETSc includes directory settings
|
# Find the PETSc includes directory settings
|
||||||
execute_process(COMMAND ${MAKE_EXECUTABLE} --no-print-directory -f ${petsc_config_makefile} "includes"
|
execute_process (COMMAND ${MAKE_EXECUTABLE} --no-print-directory -f ${petsc_config_makefile} "includes"
|
||||||
RESULT_VARIABLE PETSC_INCLUDES_RETURN
|
RESULT_VARIABLE PETSC_INCLUDES_RETURN
|
||||||
OUTPUT_VARIABLE petsc_includes
|
OUTPUT_VARIABLE petsc_includes
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
# Find the PETSc external linking directory settings
|
# Find the PETSc external linking directory settings
|
||||||
# //required for final linking, must be appended after the executable
|
# //required for final linking, must be appended after the executable
|
||||||
execute_process(COMMAND ${MAKE_EXECUTABLE} --no-print-directory -f ${petsc_config_makefile} "extlibs"
|
execute_process (COMMAND ${MAKE_EXECUTABLE} --no-print-directory -f ${petsc_config_makefile} "extlibs"
|
||||||
RESULT_VARIABLE PETSC_EXTERNAL_LIB_RETURN
|
RESULT_VARIABLE PETSC_EXTERNAL_LIB_RETURN
|
||||||
OUTPUT_VARIABLE petsc_external_lib
|
OUTPUT_VARIABLE petsc_external_lib
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
# PETSc specified fortran compiler
|
# PETSc specified fortran compiler
|
||||||
execute_process(COMMAND ${MAKE_EXECUTABLE} --no-print-directory -f ${petsc_config_makefile} "compilerf"
|
execute_process (COMMAND ${MAKE_EXECUTABLE} --no-print-directory -f ${petsc_config_makefile} "compilerf"
|
||||||
RESULT_VARIABLE PETSC_MPIFC_RETURN
|
RESULT_VARIABLE PETSC_MPIFC_RETURN
|
||||||
OUTPUT_VARIABLE PETSC_MPIFC
|
OUTPUT_VARIABLE PETSC_MPIFC
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
# PETSc specified C compiler
|
# PETSc specified C compiler
|
||||||
execute_process(COMMAND ${MAKE_EXECUTABLE} --no-print-directory -f ${petsc_config_makefile} "compilerc"
|
execute_process (COMMAND ${MAKE_EXECUTABLE} --no-print-directory -f ${petsc_config_makefile} "compilerc"
|
||||||
RESULT_VARIABLE PETSC_MPICC_RETURN
|
RESULT_VARIABLE PETSC_MPICC_RETURN
|
||||||
OUTPUT_VARIABLE PETSC_MPICC
|
OUTPUT_VARIABLE PETSC_MPICC
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
# PETSc specified linker (MPIF90 + PETSc linking flags)
|
# PETSc specified linker (MPIF90 + PETSc linking flags)
|
||||||
execute_process(COMMAND ${MAKE_EXECUTABLE} --no-print-directory -f ${petsc_config_makefile} "linker"
|
execute_process (COMMAND ${MAKE_EXECUTABLE} --no-print-directory -f ${petsc_config_makefile} "linker"
|
||||||
RESULT_VARIABLE PETSC_LINKER_RETURN
|
RESULT_VARIABLE PETSC_LINKER_RETURN
|
||||||
OUTPUT_VARIABLE PETSC_LINKER
|
OUTPUT_VARIABLE PETSC_LINKER
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
# Remove temporary makefile, no need to keep it anymore.
|
# Remove temporary makefile, no need to keep it anymore.
|
||||||
file (REMOVE_RECURSE ${PETSC_TEMP})
|
file (REMOVE_RECURSE ${TEMPDIR})
|
||||||
|
|
||||||
# Remove duplicate compiler and linker flags
|
# Remove duplicate compiler and linker flags
|
||||||
string( REGEX MATCHALL "-I([^\" ]+)" TMP_LIST "${petsc_includes}")
|
string (REGEX MATCHALL "-I([^\" ]+)" TMP_LIST "${petsc_includes}")
|
||||||
list(REMOVE_DUPLICATES TMP_LIST)
|
list (REMOVE_DUPLICATES TMP_LIST)
|
||||||
foreach (dir ${TMP_LIST})
|
foreach (dir ${TMP_LIST})
|
||||||
set(PETSC_INCLUDES "${PETSC_INCLUDES} ${dir}")
|
set (PETSC_INCLUDES "${PETSC_INCLUDES} ${dir}")
|
||||||
endforeach(dir)
|
endforeach (dir)
|
||||||
string( REGEX MATCHALL "-[lLW]([^\" ]+)" TMP_LIST "${petsc_external_lib}")
|
string (REGEX MATCHALL "-[lLW]([^\" ]+)" TMP_LIST "${petsc_external_lib}")
|
||||||
list(REMOVE_DUPLICATES TMP_LIST)
|
list (REMOVE_DUPLICATES TMP_LIST)
|
||||||
foreach (exlib ${TMP_LIST})
|
foreach (exlib ${TMP_LIST})
|
||||||
set(PETSC_EXTERNAL_LIB "${PETSC_EXTERNAL_LIB} ${exlib}")
|
set (PETSC_EXTERNAL_LIB "${PETSC_EXTERNAL_LIB} ${exlib}")
|
||||||
endforeach(exlib)
|
endforeach (exlib)
|
||||||
|
|
||||||
message("Found PETSC_DIR:\n${PETSC_DIR}\n" )
|
message ("Found PETSC_DIR:\n${PETSC_DIR}\n" )
|
||||||
message("Found PETSC_INCLUDES:\n${PETSC_INCLUDES}\n" )
|
message ("Found PETSC_INCLUDES:\n${PETSC_INCLUDES}\n" )
|
||||||
message("Found PETSC_EXTERNAL_LIB:\n${PETSC_EXTERNAL_LIB}\n")
|
message ("Found PETSC_EXTERNAL_LIB:\n${PETSC_EXTERNAL_LIB}\n")
|
||||||
message("Found PETSC_LINKER:\n${PETSC_LINKER}\n" )
|
message ("Found PETSC_LINKER:\n${PETSC_LINKER}\n" )
|
||||||
message("Found MPI Fortran Compiler:\n${PETSC_MPIFC}\n" )
|
message ("Found MPI Fortran Compiler:\n${PETSC_MPIFC}\n" )
|
||||||
message("Found MPI C Compiler:\n${PETSC_MPICC}\n" )
|
message ("Found MPI C Compiler:\n${PETSC_MPICC}\n" )
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------------
|
||||||
# Now start to care about DAMASK
|
# Now start to care about DAMASK
|
||||||
|
|
||||||
# DAMASK Solver selection
|
# 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("Configuring 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("Configuring FEM Solver\n")
|
message ("Building FEM Solver\n")
|
||||||
endif()
|
endif
|
||||||
|
|
||||||
# set compiler and linker commands (need to be done after defining the project)
|
# set compiler and linker commands (need to be done after defining the project)
|
||||||
# https://cmake.org/Wiki/CMake_FAQ#How_do_I_use_a_different_compiler.3F
|
# https://cmake.org/Wiki/CMake_FAQ#How_do_I_use_a_different_compiler.3F
|
||||||
set(CMAKE_Fortran_COMPILER "${PETSC_MPIFC}")
|
set (CMAKE_Fortran_COMPILER "${PETSC_MPIFC}")
|
||||||
set(CMAKE_C_COMPILER "${PETSC_MPICC}")
|
set (CMAKE_C_COMPILER "${PETSC_MPICC}")
|
||||||
set(CMAKE_LINKER "${PETSC_LINKER}")
|
set (CMAKE_LINKER "${PETSC_LINKER}")
|
||||||
|
|
||||||
# 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 (PARALLEL "OFF")
|
set (PARALLEL "OFF")
|
||||||
set (OPTI "OFF")
|
set (OPTI "OFF")
|
||||||
set (BUILDCMD_POST "${BUILDCMD_POST} -fsyntax-only")
|
set (BUILDCMD_POST "${BUILDCMD_POST} -fsyntax-only")
|
||||||
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("${CMAKE_BUILD_TYPE}" STREQUAL "DEBUG")
|
endif
|
||||||
|
|
||||||
# overwrite optimization if given
|
# $OPTIMIZATION takes precedence over $BUILD_TYPE defaults
|
||||||
if("${OPTIMIZATION}" STREQUAL "")
|
if ("${OPTIMIZATION}" STREQUAL "")
|
||||||
set(OPTIMIZATION "${OPTI}")
|
set (OPTIMIZATION "${OPTI}")
|
||||||
else("${OPTIMIZATION}" STREQUAL "")
|
else
|
||||||
set(OPTIMIZATION "${OPTIMIZATION}")
|
set (OPTIMIZATION "${OPTIMIZATION}")
|
||||||
endif("${OPTIMIZATION}" STREQUAL "")
|
endif
|
||||||
|
|
||||||
# overwrite optimization if given
|
# $OPENMP takes precedence over $BUILD_TYPE defaults
|
||||||
if("${OPENMP}" STREQUAL "")
|
if ("${OPENMP}" STREQUAL "")
|
||||||
set(OPENMP "${PARALLEL}")
|
set (OPENMP "${PARALLEL}")
|
||||||
else("${OPENMP}" STREQUAL "")
|
else
|
||||||
set(OPENMP "${OPENMP}")
|
set(OPENMP "${OPENMP}")
|
||||||
endif("${OPENMP}" STREQUAL "")
|
endif
|
||||||
|
|
||||||
# Parse DAMASK_BIN from CONFIG file
|
# Parse DAMASK_BIN from CONFIG file
|
||||||
file(READ "CONFIG" CONFIGFILE)
|
file (READ "CONFIG" CONFIGFILE)
|
||||||
STRING(REGEX REPLACE ";" "\\\\;" CONFIGFILE "${CONFIGFILE}")
|
string (REGEX REPLACE ";" "\\\\;" CONFIGFILE "${CONFIGFILE}")
|
||||||
STRING(REGEX REPLACE "\n" ";" CONFIGFILE "${CONFIGFILE}")
|
string (REGEX REPLACE "\n" ";" CONFIGFILE "${CONFIGFILE}")
|
||||||
FOREACH(item ${CONFIGFILE})
|
foreach (item ${CONFIGFILE})
|
||||||
STRING(REGEX MATCH ".+DAMASK_BIN.+" item ${item})
|
string (REGEX MATCH ".+DAMASK_BIN.+" item ${item})
|
||||||
IF(item)
|
if (item)
|
||||||
string(REGEX REPLACE "set" "" item "${item}")
|
string (REGEX REPLACE "set" "" item "${item}")
|
||||||
string(REGEX REPLACE "=" " " item "${item}")
|
string (REGEX REPLACE "=" " " item "${item}")
|
||||||
string(REGEX REPLACE "\\\${DAMASK_ROOT}" "${PROJECT_SOURCE_DIR}" item "${item}")
|
string (REGEX REPLACE "\\\${DAMASK_ROOT}" "${PROJECT_SOURCE_DIR}" item "${item}")
|
||||||
string(REPLACE "DAMASK_BIN" ";" STRING_LIST ${item})
|
string (REPLACE "DAMASK_BIN" ";" STRING_LIST ${item})
|
||||||
list(GET STRING_LIST 1 item)
|
list (GET STRING_LIST 1 item)
|
||||||
string(STRIP "${item}" CMAKE_INSTALL_PREFIX)
|
string (STRIP "${item}" CMAKE_INSTALL_PREFIX)
|
||||||
ENDIF(item)
|
endif
|
||||||
ENDFOREACH(item ${CONFIGFILE})
|
endforeach(item ${CONFIGFILE})
|
||||||
|
|
||||||
# Parse DAMASK version from VERSION file
|
# Parse DAMASK version from VERSION file
|
||||||
find_program (CAT_EXECUTABLE NAMES cat)
|
find_program (CAT_EXECUTABLE NAMES cat)
|
||||||
execute_process(COMMAND ${CAT_EXECUTABLE} ${PROJECT_SOURCE_DIR}/VERSION
|
execute_process (COMMAND ${CAT_EXECUTABLE} ${PROJECT_SOURCE_DIR}/VERSION
|
||||||
RESULT_VARIABLE DAMASK_VERSION_RETURN
|
RESULT_VARIABLE DAMASK_VERSION_RETURN
|
||||||
OUTPUT_VARIABLE DAMASK_V
|
OUTPUT_VARIABLE DAMASK_V
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
add_definitions(-DDAMASKVERSION="${DAMASK_V}")
|
add_definitions (-DDAMASKVERSION="${DAMASK_V}")
|
||||||
|
|
||||||
# definition of other macros
|
# definition of other macros
|
||||||
add_definitions(-DPETSc)
|
add_definitions (-DPETSc)
|
||||||
add_definitions(-DFLOAT=8)
|
add_definitions (-DFLOAT=8)
|
||||||
add_definitions(-DINT=4)
|
add_definitions (-DINT=4)
|
||||||
|
|
||||||
set (DAMASK_INCLUDE_FLAGS "${DAMASK_INCLUDE_FLAGS} ${PETSC_INCLUDES}" )
|
set (DAMASK_INCLUDE_FLAGS "${DAMASK_INCLUDE_FLAGS} ${PETSC_INCLUDES}")
|
||||||
set (DAMASK_INCLUDE_FLAGS "${DAMASK_INCLUDE_FLAGS} -I${PROJECT_SOURCE_DIR}/lib")
|
set (DAMASK_INCLUDE_FLAGS "${DAMASK_INCLUDE_FLAGS} -I${PROJECT_SOURCE_DIR}/lib")
|
||||||
|
|
||||||
###################################################################################################
|
###################################################################################################
|
||||||
# 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(OPENMP)
|
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
|
||||||
|
|
||||||
set (STANDARD_CHECK "-stand f08 -standard-semantics")
|
set (STANDARD_CHECK "-stand f08 -standard-semantics")
|
||||||
set (LINKER_FLAGS "${LINKER_FLAGS} -shared-intel")
|
set (LINKER_FLAGS "${LINKER_FLAGS} -shared-intel")
|
||||||
|
@ -200,34 +201,38 @@ if(${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
|
||||||
# Fine tuning compilation options
|
# Fine tuning compilation options
|
||||||
set (COMPILE_FLAGS "${COMPILE_FLAGS} -fpp")
|
set (COMPILE_FLAGS "${COMPILE_FLAGS} -fpp")
|
||||||
# preprocessor
|
# preprocessor
|
||||||
|
|
||||||
set (COMPILE_FLAGS "${COMPILE_FLAGS} -ftz")
|
set (COMPILE_FLAGS "${COMPILE_FLAGS} -ftz")
|
||||||
# flush unterflow to zero, automatically set if O<0,1,2,3> >0
|
# flush underflow to zero, automatically set if -O[1,2,3]
|
||||||
|
|
||||||
set (COMPILE_FLAGS "${COMPILE_FLAGS} -assume")
|
set (COMPILE_FLAGS "${COMPILE_FLAGS} -assume")
|
||||||
# assume
|
# assume ...
|
||||||
set (COMPILE_FLAGS "${COMPILE_FLAGS}byterecl")
|
set (COMPILE_FLAGS "${COMPILE_FLAGS} byterecl")
|
||||||
# record length is given in bytes (also set by -standard-semantics)
|
# ... record length is given in bytes (also set by -standard-semantics)
|
||||||
set (COMPILE_FLAGS "${COMPILE_FLAGS},fpe_summary")
|
set (COMPILE_FLAGS "${COMPILE_FLAGS},fpe_summary")
|
||||||
# print list of floating point exceptions occured during execution
|
# ... print list of floating point exceptions occured during execution
|
||||||
|
|
||||||
set (COMPILE_FLAGS "${COMPILE_FLAGS} -diag-disable")
|
set (COMPILE_FLAGS "${COMPILE_FLAGS} -diag-disable")
|
||||||
# disables warnings, where
|
# disables warnings ...
|
||||||
set (COMPILE_FLAGS "${COMPILE_FLAGS}5268")
|
set (COMPILE_FLAGS "${COMPILE_FLAGS} 5268")
|
||||||
# the text exceeds right hand column allowed on the line (we have only comments there)
|
# ... the text exceeds right hand column allowed on the line (we have only comments there)
|
||||||
|
|
||||||
set (COMPILE_FLAGS "${COMPILE_FLAGS} -warn")
|
set (COMPILE_FLAGS "${COMPILE_FLAGS} -warn")
|
||||||
# enables warnings, where
|
# enables warnings ...
|
||||||
set (COMPILE_FLAGS "${COMPILE_FLAGS}declarations")
|
set (COMPILE_FLAGS "${COMPILE_FLAGS} declarations")
|
||||||
# any undeclared names (alternative name: -implicitnone)
|
# ... any undeclared names (alternative name: -implicitnone)
|
||||||
set (COMPILE_FLAGS "${COMPILE_FLAGS},general")
|
set (COMPILE_FLAGS "${COMPILE_FLAGS},general")
|
||||||
# warning messages and informational messages are issued by the compiler
|
# ... warning messages and informational messages are issued by the compiler
|
||||||
set (COMPILE_FLAGS "${COMPILE_FLAGS},usage")
|
set (COMPILE_FLAGS "${COMPILE_FLAGS},usage")
|
||||||
# questionable programming practices
|
# ... questionable programming practices
|
||||||
set (COMPILE_FLAGS "${COMPILE_FLAGS},interfaces")
|
set (COMPILE_FLAGS "${COMPILE_FLAGS},interfaces")
|
||||||
# checks the interfaces of all SUBROUTINEs called and FUNCTIONs invoked in your compilation against an external set of interface blocks
|
# ... checks the interfaces of all SUBROUTINEs called and FUNCTIONs invoked in your compilation against an external set of interface blocks
|
||||||
set (COMPILE_FLAGS "${COMPILE_FLAGS},ignore_loc")
|
set (COMPILE_FLAGS "${COMPILE_FLAGS},ignore_loc")
|
||||||
# %LOC is stripped from an actual argument
|
# ... %LOC is stripped from an actual argument
|
||||||
set (COMPILE_FLAGS "${COMPILE_FLAGS},alignments")
|
set (COMPILE_FLAGS "${COMPILE_FLAGS},alignments")
|
||||||
# data that is not naturally aligned
|
# ... data that is not naturally aligned
|
||||||
set (COMPILE_FLAGS "${COMPILE_FLAGS},unused")
|
set (COMPILE_FLAGS "${COMPILE_FLAGS},unused")
|
||||||
# declared variables that are never used
|
# ... declared variables that are never used
|
||||||
|
|
||||||
# Additional options
|
# Additional options
|
||||||
# -warn: enables warnings, where
|
# -warn: enables warnings, where
|
||||||
|
@ -241,37 +246,44 @@ if(${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
|
||||||
# Runtime debugging
|
# Runtime debugging
|
||||||
set (DEBUG_FLAGS "${DEBUG_FLAGS} -g")
|
set (DEBUG_FLAGS "${DEBUG_FLAGS} -g")
|
||||||
# Generate symbolic debugging information in the object file
|
# Generate symbolic debugging information in the object file
|
||||||
|
|
||||||
set (DEBUG_FLAGS "${DEBUG_FLAGS} -traceback")
|
set (DEBUG_FLAGS "${DEBUG_FLAGS} -traceback")
|
||||||
# Generate extra information in the object file to provide source file traceback information when a severe error occurs at run time.
|
# Generate extra information in the object file to provide source file traceback information when a severe error occurs at run time
|
||||||
|
|
||||||
set (DEBUG_FLAGS "${DEBUG_FLAGS} -gen-interfaces")
|
set (DEBUG_FLAGS "${DEBUG_FLAGS} -gen-interfaces")
|
||||||
# Generate an interface block for each routine. http://software.intel.com/en-us/blogs/2012/01/05/doctor-fortran-gets-explicit-again/
|
# Generate an interface block for each routine. http://software.intel.com/en-us/blogs/2012/01/05/doctor-fortran-gets-explicit-again/
|
||||||
|
|
||||||
set (DEBUG_FLAGS "${DEBUG_FLAGS} -fp-stack-check")
|
set (DEBUG_FLAGS "${DEBUG_FLAGS} -fp-stack-check")
|
||||||
# Generate extra code after every function call to ensure that the floating-point (FP) stack is in the expected state.
|
# Generate extra code after every function call to ensure that the floating-point (FP) stack is in the expected state
|
||||||
|
|
||||||
set (DEBUG_FLAGS "${DEBUG_FLAGS} -fp-model strict")
|
set (DEBUG_FLAGS "${DEBUG_FLAGS} -fp-model strict")
|
||||||
# Trap uninitalized variables
|
# Trap uninitalized variables
|
||||||
|
|
||||||
set (DEBUG_FLAGS "${DEBUG_FLAGS} -check" )
|
set (DEBUG_FLAGS "${DEBUG_FLAGS} -check" )
|
||||||
# Checks at runtime, where
|
# Checks at runtime ...
|
||||||
set (DEBUG_FLAGS "${DEBUG_FLAGS}bounds")
|
set (DEBUG_FLAGS "${DEBUG_FLAGS} bounds")
|
||||||
# if an array index is too small (<1) or too large!
|
# ... if an array index is too small (<1) or too large!
|
||||||
set (DEBUG_FLAGS "${DEBUG_FLAGS},format")
|
set (DEBUG_FLAGS "${DEBUG_FLAGS},format")
|
||||||
# for the data type of an item being formatted for output.
|
# ... for the data type of an item being formatted for output.
|
||||||
set (DEBUG_FLAGS "${DEBUG_FLAGS},output_conversion")
|
set (DEBUG_FLAGS "${DEBUG_FLAGS},output_conversion")
|
||||||
# for the fit of data items within a designated format descriptor field.
|
# ... for the fit of data items within a designated format descriptor field.
|
||||||
set (DEBUG_FLAGS "${DEBUG_FLAGS},pointers")
|
set (DEBUG_FLAGS "${DEBUG_FLAGS},pointers")
|
||||||
# for certain disassociated or uninitialized pointers or unallocated allocatable objects.
|
# ... for certain disassociated or uninitialized pointers or unallocated allocatable objects.
|
||||||
set (DEBUG_FLAGS "${DEBUG_FLAGS},uninit")
|
set (DEBUG_FLAGS "${DEBUG_FLAGS},uninit")
|
||||||
# for uninitialized variables.
|
# ... for uninitialized variables.
|
||||||
set (DEBUG_FLAGS "${DEBUG_FLAGS} -ftrapuv")
|
set (DEBUG_FLAGS "${DEBUG_FLAGS} -ftrapuv")
|
||||||
# initializes stack local variables to an unusual value to aid error detection
|
# ... initializes stack local variables to an unusual value to aid error detection
|
||||||
set (DEBUG_FLAGS "${DEBUG_FLAGS} -fpe-all0")
|
set (DEBUG_FLAGS "${DEBUG_FLAGS} -fpe-all0")
|
||||||
# capture all floating-point exceptions, sets -ftz automatically
|
# ... capture all floating-point exceptions, sets -ftz automatically
|
||||||
|
|
||||||
set (DEBUG_FLAGS "${DEBUG_FLAGS} -warn")
|
set (DEBUG_FLAGS "${DEBUG_FLAGS} -warn")
|
||||||
# enables warnings, where
|
# enables warnings ...
|
||||||
set (DEBUG_FLAGS "${DEBUG_FLAGS}errors")
|
set (DEBUG_FLAGS "${DEBUG_FLAGS} errors")
|
||||||
# warnings are changed to errors
|
# ... warnings are changed to errors
|
||||||
set (DEBUG_FLAGS "${DEBUG_FLAGS},stderrors")
|
set (DEBUG_FLAGS "${DEBUG_FLAGS},stderrors")
|
||||||
# warnings about Fortran standard violations are changed to errors
|
# ... warnings about Fortran standard violations are changed to errors
|
||||||
set (DEBUG_FLAGS "${DEBUG_FLAGS} -debug-parameters all" )
|
|
||||||
|
set (DEBUG_FLAGS "${DEBUG_FLAGS} -debug-parameters all")
|
||||||
# generate debug information for parameters
|
# generate debug information for parameters
|
||||||
|
|
||||||
# Additional options
|
# Additional options
|
||||||
|
@ -283,9 +295,9 @@ if(${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
|
||||||
#------------------------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------------------------
|
||||||
# precision settings
|
# precision settings
|
||||||
set (PRECISION_FLAGS "${PRECISION_FLAGS} -real-size 64")
|
set (PRECISION_FLAGS "${PRECISION_FLAGS} -real-size 64")
|
||||||
# set precision to one of those 32/64/128 (= 4/8/16 bytes) for standard real (=8 for pReal)
|
# set precision for standard real to 32 | 64 | 128 (= 4 | 8 | 16 bytes, type pReal is always 8 bytes)
|
||||||
set (PRECISION_FLAGS "${PRECISION_FLAGS} -integer-size 32")
|
set (PRECISION_FLAGS "${PRECISION_FLAGS} -integer-size 32")
|
||||||
# set precision to one of those 16/32/64 (= 2/4/8 bytes) for standard integer (=4 for pInt)
|
# set precision for standard int to 16 | 32 | 64 (= 2 | 4 | 8 bytes, type pInt is always 4 bytes)
|
||||||
|
|
||||||
|
|
||||||
###################################################################################################
|
###################################################################################################
|
||||||
|
@ -295,7 +307,7 @@ 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" )
|
||||||
|
@ -303,7 +315,7 @@ elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
|
||||||
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
|
||||||
|
|
||||||
set (STANDARD_CHECK "-std=f2008ts -pedantic-errors" )
|
set (STANDARD_CHECK "-std=f2008ts -pedantic-errors" )
|
||||||
set (LINKER_FLAGS "${LINKER_FLAGS} -Wl")
|
set (LINKER_FLAGS "${LINKER_FLAGS} -Wl")
|
||||||
|
@ -316,12 +328,16 @@ elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
|
||||||
# Fine tuning compilation options
|
# Fine tuning compilation options
|
||||||
set (COMPILE_FLAGS "${COMPILE_FLAGS} -xf95-cpp-input")
|
set (COMPILE_FLAGS "${COMPILE_FLAGS} -xf95-cpp-input")
|
||||||
# preprocessor
|
# preprocessor
|
||||||
|
|
||||||
set (COMPILE_FLAGS "${COMPILE_FLAGS} -ffree-line-length-132")
|
set (COMPILE_FLAGS "${COMPILE_FLAGS} -ffree-line-length-132")
|
||||||
# restrict line length to the standard 132 characters (lattice.f90 require more characters)
|
# restrict line length to the standard 132 characters (lattice.f90 require more characters)
|
||||||
|
|
||||||
set (COMPILE_FLAGS "${COMPILE_FLAGS} -fimplicit-none")
|
set (COMPILE_FLAGS "${COMPILE_FLAGS} -fimplicit-none")
|
||||||
# assume "implicit none" even if not present in source
|
# assume "implicit none" even if not present in source
|
||||||
|
|
||||||
set (COMPILE_FLAGS "${COMPILE_FLAGS} -fmodule-private")
|
set (COMPILE_FLAGS "${COMPILE_FLAGS} -fmodule-private")
|
||||||
# assume "private" even if not present in source
|
# assume "private" even if not present in source
|
||||||
|
|
||||||
set (COMPILE_FLAGS "${COMPILE_FLAGS} -Wall")
|
set (COMPILE_FLAGS "${COMPILE_FLAGS} -Wall")
|
||||||
# sets the following Fortran options:
|
# sets the following Fortran options:
|
||||||
# -Waliasing: warn about possible aliasing of dummy arguments. Specifically, it warns if the same actual argument is associated with a dummy argument with "INTENT(IN)" and a dummy argument with "INTENT(OUT)" in a call with an explicit interface.
|
# -Waliasing: warn about possible aliasing of dummy arguments. Specifically, it warns if the same actual argument is associated with a dummy argument with "INTENT(IN)" and a dummy argument with "INTENT(OUT)" in a call with an explicit interface.
|
||||||
|
@ -362,6 +378,7 @@ elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
|
||||||
# -Wunused-value
|
# -Wunused-value
|
||||||
# -Wunused-variable
|
# -Wunused-variable
|
||||||
# -Wvolatile-register-var
|
# -Wvolatile-register-var
|
||||||
|
|
||||||
set (COMPILE_FLAGS "${COMPILE_FLAGS} -Wextra")
|
set (COMPILE_FLAGS "${COMPILE_FLAGS} -Wextra")
|
||||||
# sets the following Fortran options:
|
# sets the following Fortran options:
|
||||||
# -Wunuses-parameter:
|
# -Wunuses-parameter:
|
||||||
|
@ -377,10 +394,13 @@ elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
|
||||||
# -Wuninitialized
|
# -Wuninitialized
|
||||||
# -Wunused-but-set-parameter (only with -Wunused or -Wall)
|
# -Wunused-but-set-parameter (only with -Wunused or -Wall)
|
||||||
# -Wno-globals
|
# -Wno-globals
|
||||||
|
|
||||||
set (COMPILE_FLAGS "${COMPILE_FLAGS} -Wcharacter-truncation")
|
set (COMPILE_FLAGS "${COMPILE_FLAGS} -Wcharacter-truncation")
|
||||||
# warn if character expressions (strings) are truncated
|
# warn if character expressions (strings) are truncated
|
||||||
|
|
||||||
set (COMPILE_FLAGS "${COMPILE_FLAGS} -Wunderflow")
|
set (COMPILE_FLAGS "${COMPILE_FLAGS} -Wunderflow")
|
||||||
# produce a warning when numerical constant expressions are encountered, which yield an UNDERFLOW during compilation
|
# produce a warning when numerical constant expressions are encountered, which yield an UNDERFLOW during compilation
|
||||||
|
|
||||||
set (COMPILE_FLAGS "${COMPILE_FLAGS} -Wsuggest-attribute=pure")
|
set (COMPILE_FLAGS "${COMPILE_FLAGS} -Wsuggest-attribute=pure")
|
||||||
set (COMPILE_FLAGS "${COMPILE_FLAGS} -Wsuggest-attribute=noreturn")
|
set (COMPILE_FLAGS "${COMPILE_FLAGS} -Wsuggest-attribute=noreturn")
|
||||||
set (COMPILE_FLAGS "${COMPILE_FLAGS} -Wconversion-extra")
|
set (COMPILE_FLAGS "${COMPILE_FLAGS} -Wconversion-extra")
|
||||||
|
@ -398,8 +418,10 @@ elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
|
||||||
# Runtime debugging
|
# Runtime debugging
|
||||||
set (DEBUG_FLAGS "${DEBUG_FLAGS} -ffpe-trap=invalid,zero,overflow")
|
set (DEBUG_FLAGS "${DEBUG_FLAGS} -ffpe-trap=invalid,zero,overflow")
|
||||||
# stop execution if floating point exception is detected (NaN is silent)
|
# stop execution if floating point exception is detected (NaN is silent)
|
||||||
|
|
||||||
set (DEBUG_FLAGS "${DEBUG_FLAGS} -g")
|
set (DEBUG_FLAGS "${DEBUG_FLAGS} -g")
|
||||||
# Generate symbolic debugging information in the object file
|
# Generate symbolic debugging information in the object file
|
||||||
|
|
||||||
set (DEBUG_FLAGS "${DEBUG_FLAGS} -fbacktrace")
|
set (DEBUG_FLAGS "${DEBUG_FLAGS} -fbacktrace")
|
||||||
set (DEBUG_FLAGS "${DEBUG_FLAGS} -fdump-core")
|
set (DEBUG_FLAGS "${DEBUG_FLAGS} -fdump-core")
|
||||||
set (DEBUG_FLAGS "${DEBUG_FLAGS} -fcheck=all")
|
set (DEBUG_FLAGS "${DEBUG_FLAGS} -fcheck=all")
|
||||||
|
@ -411,43 +433,44 @@ elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
|
||||||
# precision settings
|
# precision settings
|
||||||
set (PRECISION_FLAGS "${PRECISION_FLAGS} -fdefault-real-8")
|
set (PRECISION_FLAGS "${PRECISION_FLAGS} -fdefault-real-8")
|
||||||
# set precision to 8 bytes for standard real (=8 for pReal). Will set size of double to 16 bytes as long as -fdefault-double-8 is not set
|
# set precision to 8 bytes for standard real (=8 for pReal). Will set size of double to 16 bytes as long as -fdefault-double-8 is not set
|
||||||
|
|
||||||
set (PRECISION_FLAGS "${PRECISION_FLAGS} -fdefault-double-8")
|
set (PRECISION_FLAGS "${PRECISION_FLAGS} -fdefault-double-8")
|
||||||
# set precision to 8 bytes for double real, would be 16 bytes if -fdefault-real-8 is used
|
# set precision to 8 bytes for double real, would be 16 bytes if -fdefault-real-8 is used
|
||||||
|
|
||||||
# Additional options
|
# Additional options
|
||||||
# -fdefault-integer-8: Use it to set precision to 8 bytes for integer, don't use it for the standard case of pInt=4 (there is no -fdefault-integer-4)
|
# -fdefault-integer-8: Use it to set precision to 8 bytes for integer, don't use it for the standard case of pInt=4 (there is no -fdefault-integer-4)
|
||||||
endif()
|
endif
|
||||||
|
|
||||||
set (CMAKE_Fortran_FLAGS "${BUILDCMD_PRE} ${OPENMP_FLAGS} ${STANDARD_CHECK} ${OPTIMIZATION_FLAGS} ${COMPILE_FLAGS} ${PRECISION_FLAGS}")
|
set (CMAKE_Fortran_FLAGS "${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 "")
|
if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
|
||||||
set (CMAKE_BUILD_TYPE "RELEASE")
|
set (CMAKE_BUILD_TYPE "RELEASE")
|
||||||
elseif("${CMAKE_BUILD_TYPE}" STREQUAL "DEBUG")
|
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "DEBUG")
|
||||||
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${DEBUG_FLAGS}")
|
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${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
|
||||||
|
|
||||||
set (CMAKE_Fortran_LINK_EXECUTABLE "${CMAKE_Fortran_LINK_EXECUTABLE} <OBJECTS> -o <TARGET> <LINK_LIBRARIES> ${PETSC_EXTERNAL_LIB} ${BUILDCMD_POST}")
|
set (CMAKE_Fortran_LINK_EXECUTABLE "${CMAKE_Fortran_LINK_EXECUTABLE} <OBJECTS> -o <TARGET> <LINK_LIBRARIES> ${PETSC_EXTERNAL_LIB} ${BUILDCMD_POST}")
|
||||||
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${DAMASK_INCLUDE_FLAGS} ${BUILDCMD_POST}")
|
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${DAMASK_INCLUDE_FLAGS} ${BUILDCMD_POST}")
|
||||||
|
|
||||||
message("Compiler Flags (Fortran):\n${CMAKE_Fortran_FLAGS}\n")
|
message ("Fortran Compiler Flags:\n${CMAKE_Fortran_FLAGS}\n")
|
||||||
message("Linker Flags (Fortran):\n${CMAKE_Fortran_LINK_EXECUTABLE}\n")
|
message ("Fortran Linker Flags:\n${CMAKE_Fortran_LINK_EXECUTABLE}\n")
|
||||||
|
|
||||||
# location of code
|
# location of code
|
||||||
add_subdirectory(src)
|
add_subdirectory (src)
|
||||||
|
|
||||||
# INSTALL BUILT BINARIES
|
# INSTALL BUILT BINARIES
|
||||||
if ("${BUILD_TYPE}" STREQUAL SYNTAXONLY)
|
if ("${BUILD_TYPE}" STREQUAL SYNTAXONLY)
|
||||||
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("${PROJECT_NAME}" STREQUAL DAMASK_spectral)
|
endif
|
||||||
else("${BUILD_TYPE}" STREQUAL SYNTAXONLY)
|
else
|
||||||
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})
|
||||||
endif()
|
endif
|
||||||
|
|
Loading…
Reference in New Issue