cleaning
This commit is contained in:
parent
3b843b1dd9
commit
5ef9c65cbe
160
CMakeLists.txt
160
CMakeLists.txt
|
@ -11,17 +11,18 @@ if ("${PETSC_DIR}" STREQUAL "")
|
|||
endif ("${PETSC_DIR}" STREQUAL "")
|
||||
|
||||
# BRUTAL FORCE TO FIND THE VARIABLES DEFINED IN PETSC
|
||||
# ref:
|
||||
# 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 makerfile to probe the PETSc configuration
|
||||
# Generate a temporary makefile to probe the PETSc configuration
|
||||
# This file will be deleted once the setting from PETSc is parsed
|
||||
# into CMake
|
||||
set (petsc_config_makefile "${PETSC_TEMP}/Makefile.petsc")
|
||||
file (WRITE "${petsc_config_makefile}"
|
||||
|
||||
file (WRITE
|
||||
"${petsc_config_makefile}"
|
||||
"## This file was auto generated by CMake
|
||||
# PETSC_DIR = ${PETSC_DIR}
|
||||
SHELL = /bin/sh
|
||||
|
@ -40,7 +41,8 @@ compilerf:
|
|||
compilerc:
|
||||
\t@echo \${COMPILERC}
|
||||
linker:
|
||||
\t@echo \${LINKERNAME}")
|
||||
\t@echo \${LINKERNAME}
|
||||
")
|
||||
|
||||
# CMake will execute each target in the ${petsc_config_makefile}
|
||||
# to acquire corresponding PETSc Variables.
|
||||
|
@ -58,12 +60,7 @@ execute_process(COMMAND ${MAKE_EXECUTABLE} --no-print-directory -f ${petsc_confi
|
|||
RESULT_VARIABLE PETSC_EXTERNAL_LIB_RETURN
|
||||
OUTPUT_VARIABLE petsc_external_lib
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
# The MPI compiler specified in PETSc
|
||||
# //its version information is used to identify whether it is INTEL FORTRAN
|
||||
# //or GNU FORTRAN,
|
||||
# //e.g. for PETSc configured with INTEL FORTRAN compiler
|
||||
# // >>${MPIFC} -v
|
||||
# // ifort version 14.0.3 --> This line is captured and parsed by CMake
|
||||
# PETSc specified compiler
|
||||
execute_process(COMMAND ${MAKE_EXECUTABLE} --no-print-directory -f ${petsc_config_makefile} "compilerf"
|
||||
RESULT_VARIABLE MPIFC_RETURN
|
||||
OUTPUT_VARIABLE MPIFC
|
||||
|
@ -74,7 +71,7 @@ execute_process(COMMAND ${MAKE_EXECUTABLE} --no-print-directory -f ${petsc_confi
|
|||
OUTPUT_VARIABLE PETSC_LINKER
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
# Remove temporary makefile, no need to keep it anymore.
|
||||
file (REMOVE ${petsc_config_makefile})
|
||||
file (REMOVE_RECURSE ${PETSC_TEMP})
|
||||
|
||||
# REMOVE DUPLICATE FLAGS FOR COMPILER AND LINKING
|
||||
string( REGEX MATCHALL "-I([^\" ]+)" TMP_LIST "${petsc_includes}")
|
||||
|
@ -116,7 +113,7 @@ 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(OPTIMIZATION "DAMASK optimization level [OFF,DEFENSIVE,AGGRESSIVE]" "AGGRESSIVE" )
|
||||
option(OPTIMIZATION "DAMASK optimization level [OFF,DEFENSIVE,AGGRESSIVE]" "DEFENSIVE" )
|
||||
option(SPECTRAL "Build spectral sovler for DAMASAK" OFF )
|
||||
option(FEM "Build FEM solver for DAMASK" OFF )
|
||||
|
||||
|
@ -143,35 +140,39 @@ if ("${DAMASK_DRIVER}" STREQUAL "SPECTRAL")
|
|||
set (SPECTRAL ON )
|
||||
add_definitions(-DSpectral)
|
||||
set (FEM OFF)
|
||||
message("***Confiugring Spectral Solver\n")
|
||||
message("***Configuring Spectral Solver\n")
|
||||
elseif ("${DAMASK_DRIVER}" STREQUAL "FEM")
|
||||
set (FEM ON )
|
||||
add_definitions(-DFEM)
|
||||
set (SPECTRAL OFF)
|
||||
message("***Confiugring FEM Solver\n")
|
||||
message("***Configuring FEM Solver\n")
|
||||
endif("${DAMASK_DRIVER}" STREQUAL "SPECTRAL")
|
||||
|
||||
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")
|
||||
set (OPTIMIZATION_ifort "-O0 -no-ip")
|
||||
set (OPTIMIZATION_gfortran "-O0" )
|
||||
elseif ("${OPTIMIZATION}" STREQUAL "DEFENSIVE")
|
||||
set (OPTIMIZATION_ifort "-O2")
|
||||
set (OPTIMIZATION_gfortran "-O2")
|
||||
elseif ("${OPTIMIZATION}" STREQUAL "AGGRESSIVE") #ToDo: this is not fully correct here, check old makefile
|
||||
set (OPTIMIZATION_ifort "-ipo -O3 -no-prec-div -fp-model fast=2 -xHost" ) #-fast = -ipo, -O3, -no-prec-div, -static, -fp-model fast=2, and -xHost"
|
||||
set (OPTIMIZATION_gfortran "-O3 -ffast-math -funroll-loops -ftree-vectorize")
|
||||
else("${OPTIMIZATION}" STREQUAL "OFF")
|
||||
set (OPTIMIZATION_ifort "-O2")
|
||||
set (OPTIMIZATION_gfortran "-O2")
|
||||
endif("${OPTIMIZATION}" STREQUAL "OFF")
|
||||
|
||||
|
||||
###################################################################################################
|
||||
# Intel Compiler
|
||||
###################################################################################################
|
||||
if(${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
|
||||
|
||||
if (OPENMP)
|
||||
set (OPENMP_FLAG "-openmp -openmp-report0 -parallel")
|
||||
endif(OPENMP)
|
||||
|
||||
if ("${OPTIMIZATION}" STREQUAL "OFF")
|
||||
set (OPTIMIZATION_FLAG "-O0 -no-ip")
|
||||
elseif("${OPTIMIZATION}" STREQUAL "DEFENSIVE")
|
||||
set (OPTIMIZATION_FLAG "-O2")
|
||||
elseif ("${OPTIMIZATION}" STREQUAL "AGGRESSIVE")
|
||||
set (OPTIMIZATION_FLAG "-ipo -O3 -no-prec-div -fp-model fast=2 -xHost" ) #-fast = -ipo, -O3, -no-prec-div, -static, -fp-model fast=2, and -xHost"
|
||||
endif()
|
||||
|
||||
set (STANDARD_CHECK "-stand f08 -standard-semantics")
|
||||
set (LINKER_FLAG " -shared-intel")
|
||||
|
||||
#------------------------------------------------------------------------------------------------
|
||||
# COMPILE SWITCHES
|
||||
# -shared-intel: Link against shared Intel libraries instead of static ones
|
||||
# -fpp: preprocessor
|
||||
# -ftz: flush unterflow to zero, automatically set if O<0,1,2,3> >0
|
||||
# -assume byterecl record length is given in bytes (also set by -standard-semantics)
|
||||
|
@ -189,32 +190,12 @@ endif("${OPTIMIZATION}" STREQUAL "OFF")
|
|||
# unused: declared variables that are never used
|
||||
# stderrors: warnings about Fortran standard violations are changed to errors (STANDARD_CHECK)
|
||||
#
|
||||
###################################################################################################
|
||||
# MORE OPTIONS FOR DEBUGGING DURING COMPILATION
|
||||
# -warn: enables warnings, where
|
||||
# truncated_source: Determines whether warnings occur when source exceeds the maximum column width in fixed-format files. (too many warnings because we have comments beyond character 132)
|
||||
# uncalled: Determines whether warnings occur when a statement function is never called
|
||||
# all:
|
||||
# -name as_is: case sensitive Fortran!
|
||||
###################################################################################################
|
||||
if(${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
|
||||
|
||||
if (OPENMP)
|
||||
set (OPENMP_FLAG "-openmp -openmp-report0 -parallel")
|
||||
endif(OPENMP)
|
||||
|
||||
if ("${OPTIMIZATION}" STREQUAL "OFF")
|
||||
set (OPTIMIZATION_FLAG "-O0 -no-ip")
|
||||
elseif ("${OPTIMIZATION}" STREQUAL "AGGRESSIVE") #ToDo: this is not fully correct here, check old makefile
|
||||
set (OPTIMIZATION_FLAG "-ipo -O3 -no-prec-div -fp-model fast=2 -xHost" ) #-fast = -ipo, -O3, -no-prec-div, -static, -fp-model fast=2, and -xHost"
|
||||
elseif ("${OPTIMIZATION}" STREQUAL "ULTRA")
|
||||
set (OPTIMIZATION_FLAG "-ipo -O3 -no-prec-div -fp-model fast=2 -xHost" ) #-fast = -ipo, -O3, -no-prec-div, -static, -fp-model fast=2, and -xHost"
|
||||
else() # this is the default
|
||||
set (OPTIMIZATION_FLAG "-O2")
|
||||
endif()
|
||||
|
||||
set (STANDARD_CHECK "-stand f08 -standard-semantics")
|
||||
|
||||
set (COMPILE_FLAGS "${COMPILE_FLAGS} -fpp" )
|
||||
set (COMPILE_FLAGS "${COMPILE_FLAGS} -ftz" )
|
||||
set (COMPILE_FLAGS "${COMPILE_FLAGS} -assume byterecl,fpe_summary")
|
||||
|
@ -226,7 +207,8 @@ if(${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
|
|||
set (COMPILE_FLAGS "${COMPILE_FLAGS} -warn ignore_loc" )
|
||||
set (COMPILE_FLAGS "${COMPILE_FLAGS} -warn alignments" )
|
||||
set (COMPILE_FLAGS "${COMPILE_FLAGS} -warn unused" )
|
||||
###################################################################################################
|
||||
|
||||
#------------------------------------------------------------------------------------------------
|
||||
# COMPILE SWITCHES FOR RUNTIME DEBUGGING
|
||||
# -g: Generate symbolic debugging information in the object file
|
||||
# -traceback: Generate extra information in the object file to provide source file traceback information when a severe error occurs at run time.
|
||||
|
@ -244,13 +226,12 @@ if(${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
|
|||
# errors: warnings are changed to errors
|
||||
# stderrors: warnings about Fortran standard violations are changed to errors
|
||||
# information on http://software.intel.com/en-us/articles/determining-root-cause-of-sigsegv-or-sigbus-errors/
|
||||
###################################################################################################
|
||||
#
|
||||
# MORE OPTIONS FOR RUNTIME DEBUGGING
|
||||
# -heap-arrays: should not be done for OpenMP, but set "ulimit -s unlimited" on shell. Probably it helps also to unlimit other limits
|
||||
# -check: checks at runtime, where
|
||||
# arg_temp_created: will cause a lot of warnings because we create a bunch of temporary arrays (performance?)
|
||||
# stack:
|
||||
###################################################################################################
|
||||
set (DEBUG_FLAGS "${DEBUG_FLAGS} -g" )
|
||||
set (DEBUG_FLAGS "${DEBUG_FLAGS} -traceback" )
|
||||
set (DEBUG_FLAGS "${DEBUG_FLAGS} -gen-interfaces" )
|
||||
|
@ -263,14 +244,34 @@ if(${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
|
|||
set (DEBUG_FLAGS "${DEBUG_FLAGS} -warn stderrors" )
|
||||
set (DEBUG_FLAGS "${DEBUG_FLAGS} -debug-parameters all" )
|
||||
|
||||
set (LINKER_FLAG " -shared-intel")
|
||||
|
||||
###################################################################################################
|
||||
#------------------------------------------------------------------------------------------------
|
||||
# PRECISION SETTINGS
|
||||
#-real-size 32: set precision to one of those 32/64/128 (= 4/8/16 bytes) for standard real (=8 for pReal)
|
||||
#-integer-size 16: set precision to one of those 16/32/64 (= 2/4/8 bytes) for standard integer (=4 for pInt)
|
||||
###################################################################################################
|
||||
set (PRECISION "-real-size 64 -integer-size 32")
|
||||
|
||||
|
||||
###################################################################################################
|
||||
# GNU Compiler
|
||||
###################################################################################################
|
||||
elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
|
||||
|
||||
if (OPENMP)
|
||||
set (OPENMP_FLAG "-fopenmp")
|
||||
endif()
|
||||
|
||||
if ("${OPTIMIZATION}" STREQUAL "OFF")
|
||||
set (OPTIMIZATION_FLAG "-O0" )
|
||||
elseif ("${OPTIMIZATION}" STREQUAL "DEFENSIVE")
|
||||
set (OPTIMIZATION_FLAG "-O2")
|
||||
elseif ("${OPTIMIZATION}" STREQUAL "AGGRESSIVE")
|
||||
set (OPTIMIZATION_FLAG "-O3 -ffast-math -funroll-loops -ftree-vectorize")
|
||||
endif()
|
||||
|
||||
set (STANDARD_CHECK "-std=f2008ts -pedantic-errors" )
|
||||
set (LINKER_FLAG " -Wl,-undefined,dynamic_lookup")
|
||||
|
||||
#------------------------------------------------------------------------------------------------
|
||||
# COMPILE SWITCHES
|
||||
# -shared
|
||||
# -Wl,-undefined,dynamic_lookup:ensure to link against dynamic libraries
|
||||
|
@ -339,31 +340,12 @@ if(${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
|
|||
# -Wunused-but-set-parameter (only with -Wunused or -Wall)
|
||||
# -Wno-globals
|
||||
# -ffpe-summary=all only for newer gfortran
|
||||
###################################################################################################
|
||||
#
|
||||
# MORE OPTIONS FOR DEBUGGING DURING COMPILATION
|
||||
# -Warray-temporarieswarnings: because we have many temporary arrays (performance issue?):
|
||||
# -Wimplicit-interface: no interfaces for lapack routines
|
||||
# -Wunsafe-loop-optimizations: warn if the loop cannot be optimized due to nontrivial assumptions.
|
||||
# -Wstrict-overflow:
|
||||
###################################################################################################
|
||||
elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
|
||||
|
||||
if (OPENMP)
|
||||
set (OPENMP_FLAG "-fopenmp")
|
||||
endif()
|
||||
|
||||
if ("${OPTIMIZATION}" STREQUAL "OFF")
|
||||
set (OPTIMIZATION_FLAG "-O0" )
|
||||
elseif ("${OPTIMIZATION}" STREQUAL "AGGRESSIVE") #ToDo: this is not fully correct here, check old makefile
|
||||
set (OPTIMIZATION_FLAG "-O3 -ffast-math -funroll-loops -ftree-vectorize")
|
||||
elseif ("${OPTIMIZATION}" STREQUAL "ULTRA")
|
||||
set (OPTIMIZATION_FLAG "-O3 -ffast-math -funroll-loops -ftree-vectorize")
|
||||
else() # this is the default
|
||||
set (OPTIMIZATION_FLAG "-O2")
|
||||
endif()
|
||||
|
||||
set (STANDARD_CHECK "-std=f2008ts -pedantic-errors" )
|
||||
|
||||
set (COMPILE_FLAGS "${COMPILE_FLAGS} -xf95-cpp-input" )
|
||||
set (COMPILE_FLAGS "${COMPILE_FLAGS} -ffree-line-length-132" )
|
||||
set (COMPILE_FLAGS "${COMPILE_FLAGS} -fimplicit-none" )
|
||||
|
@ -379,9 +361,7 @@ elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
|
|||
set (COMPILE_FLAGS "${COMPILE_FLAGS} -Wno-unused-parameter" )
|
||||
set (COMPILE_FLAGS "${COMPILE_FLAGS} -fno-range-check" )
|
||||
|
||||
set (LINKER_FLAG " -Wl,-undefined,dynamic_lookup")
|
||||
|
||||
###################################################################################################
|
||||
#------------------------------------------------------------------------------------------------
|
||||
# COMPILE SWITCHES FOR RUNTIME DEBUGGING
|
||||
# -ffpe-trap=invalid,\ stop execution if floating point exception is detected (NaN is silent)
|
||||
# zero,\
|
||||
|
@ -393,24 +373,24 @@ elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
|
|||
# mem
|
||||
# pointer
|
||||
# recursion
|
||||
###################################################################################################
|
||||
#
|
||||
# MORE OPTIONS FOR RUNTIME DEBUGGING
|
||||
# -ffpe-trap=precision,\
|
||||
# denormal, \
|
||||
# -ffpe-trap=precision,
|
||||
# denormal,
|
||||
# underflow
|
||||
###################################################################################################
|
||||
set (DEBUG_FLAGS "${DEBUG_FLAGS} -g" )
|
||||
set (DEBUG_FLAGS "${DEBUG_FLAGS} -fbacktrace" )
|
||||
set (DEBUG_FLAGS "${DEBUG_FLAGS} -fdump-core" )
|
||||
set (DEBUG_FLAGS "${DEBUG_FLAGS} -fcheck=all" )
|
||||
set (DEBUG_FLAGS "${DEBUG_FLAGS} -ffpe-trap=invalid,zero,overflow")
|
||||
|
||||
###################################################################################################
|
||||
#------------------------------------------------------------------------------------------------
|
||||
# PRECISION SETTINGS
|
||||
#-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
|
||||
#-fdefault-double-8: set precision to 8 bytes for double real, would be 16 bytes because -fdefault-real-8 is used
|
||||
#-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)
|
||||
###################################################################################################
|
||||
set (PRECISION "-fdefault-real-8 -fdefault-double-8")
|
||||
|
||||
endif()
|
||||
|
||||
set (CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} ${OPENMP_FLAG}" )
|
||||
|
@ -493,11 +473,3 @@ elseif (FEM)
|
|||
DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||
endif(SPECTRAL)
|
||||
|
||||
##
|
||||
# ADD TESTING CASES
|
||||
# add_test (SmokeTestRun
|
||||
# DAMASK_spectral.exe -g test/test1.geom -l test/test.load)
|
||||
|
||||
# Enable Dashboard scripting
|
||||
# include (CTest)
|
||||
# set (CTEST_PROJECT_NAME "DAMASK")
|
||||
|
|
Loading…
Reference in New Issue