This commit is contained in:
Martin Diehl 2016-05-18 08:54:16 +02:00
parent 3b843b1dd9
commit 5ef9c65cbe
1 changed files with 66 additions and 94 deletions

View File

@ -11,17 +11,18 @@ if ("${PETSC_DIR}" STREQUAL "")
endif ("${PETSC_DIR}" STREQUAL "") endif ("${PETSC_DIR}" STREQUAL "")
# BRUTAL FORCE TO FIND THE VARIABLES DEFINED IN PETSC # BRUTAL FORCE TO FIND THE VARIABLES DEFINED IN PETSC
# ref:
# 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) exec_program(mktemp ARGS -d OUTPUT_VARIABLE PETSC_TEMP)
set(petsc_conf_variables "${PETSC_DIR}/lib/petsc/conf/variables") set(petsc_conf_variables "${PETSC_DIR}/lib/petsc/conf/variables")
set(petsc_conf_rules "${PETSC_DIR}/lib/petsc/conf/rules" ) 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 # This file will be deleted once the setting from PETSc is parsed
# into CMake # into CMake
set (petsc_config_makefile "${PETSC_TEMP}/Makefile.petsc") 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 "## This file was auto generated by CMake
# PETSC_DIR = ${PETSC_DIR} # PETSC_DIR = ${PETSC_DIR}
SHELL = /bin/sh SHELL = /bin/sh
@ -40,7 +41,8 @@ compilerf:
compilerc: compilerc:
\t@echo \${COMPILERC} \t@echo \${COMPILERC}
linker: linker:
\t@echo \${LINKERNAME}") \t@echo \${LINKERNAME}
")
# CMake will execute each target in the ${petsc_config_makefile} # CMake will execute each target in the ${petsc_config_makefile}
# to acquire corresponding PETSc Variables. # 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 RESULT_VARIABLE PETSC_EXTERNAL_LIB_RETURN
OUTPUT_VARIABLE petsc_external_lib OUTPUT_VARIABLE petsc_external_lib
OUTPUT_STRIP_TRAILING_WHITESPACE) OUTPUT_STRIP_TRAILING_WHITESPACE)
# The MPI compiler specified in PETSc # PETSc specified compiler
# //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
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 MPIFC_RETURN RESULT_VARIABLE MPIFC_RETURN
OUTPUT_VARIABLE MPIFC OUTPUT_VARIABLE MPIFC
@ -74,7 +71,7 @@ execute_process(COMMAND ${MAKE_EXECUTABLE} --no-print-directory -f ${petsc_confi
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 ${petsc_config_makefile}) file (REMOVE_RECURSE ${PETSC_TEMP})
# REMOVE DUPLICATE FLAGS FOR COMPILER AND LINKING # REMOVE DUPLICATE FLAGS FOR COMPILER AND LINKING
string( REGEX MATCHALL "-I([^\" ]+)" TMP_LIST "${petsc_includes}") 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 # Built-in options for DAMASK build system
# -> can be overwritten from commandline/install_script # -> can be overwritten from commandline/install_script
option(OPENMP "Use OpenMP libaries for DAMASK" ON ) 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(SPECTRAL "Build spectral sovler for DAMASAK" OFF )
option(FEM "Build FEM solver for DAMASK" OFF ) option(FEM "Build FEM solver for DAMASK" OFF )
@ -143,35 +140,39 @@ if ("${DAMASK_DRIVER}" STREQUAL "SPECTRAL")
set (SPECTRAL ON ) set (SPECTRAL ON )
add_definitions(-DSpectral) add_definitions(-DSpectral)
set (FEM OFF) set (FEM OFF)
message("***Confiugring Spectral Solver\n") message("***Configuring Spectral Solver\n")
elseif ("${DAMASK_DRIVER}" STREQUAL "FEM") elseif ("${DAMASK_DRIVER}" STREQUAL "FEM")
set (FEM ON ) set (FEM ON )
add_definitions(-DFEM) add_definitions(-DFEM)
set (SPECTRAL OFF) set (SPECTRAL OFF)
message("***Confiugring FEM Solver\n") message("***Configuring FEM Solver\n")
endif("${DAMASK_DRIVER}" STREQUAL "SPECTRAL") endif("${DAMASK_DRIVER}" STREQUAL "SPECTRAL")
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")
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 # COMPILE SWITCHES
# -shared-intel: Link against shared Intel libraries instead of static ones
# -fpp: preprocessor # -fpp: preprocessor
# -ftz: flush unterflow to zero, automatically set if O<0,1,2,3> >0 # -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) # -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 # unused: declared variables that are never used
# stderrors: warnings about Fortran standard violations are changed to errors (STANDARD_CHECK) # stderrors: warnings about Fortran standard violations are changed to errors (STANDARD_CHECK)
# #
###################################################################################################
# MORE OPTIONS FOR DEBUGGING DURING COMPILATION # MORE OPTIONS FOR DEBUGGING DURING COMPILATION
# -warn: enables warnings, where # -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) # 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 # uncalled: Determines whether warnings occur when a statement function is never called
# all: # all:
# -name as_is: case sensitive Fortran! # -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} -fpp" )
set (COMPILE_FLAGS "${COMPILE_FLAGS} -ftz" ) set (COMPILE_FLAGS "${COMPILE_FLAGS} -ftz" )
set (COMPILE_FLAGS "${COMPILE_FLAGS} -assume byterecl,fpe_summary") 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 ignore_loc" )
set (COMPILE_FLAGS "${COMPILE_FLAGS} -warn alignments" ) set (COMPILE_FLAGS "${COMPILE_FLAGS} -warn alignments" )
set (COMPILE_FLAGS "${COMPILE_FLAGS} -warn unused" ) set (COMPILE_FLAGS "${COMPILE_FLAGS} -warn unused" )
###################################################################################################
#------------------------------------------------------------------------------------------------
# COMPILE SWITCHES FOR RUNTIME DEBUGGING # COMPILE SWITCHES FOR RUNTIME DEBUGGING
# -g: Generate symbolic debugging information in the object file # -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. # -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 # errors: warnings are changed to errors
# stderrors: warnings about Fortran standard violations 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/ # information on http://software.intel.com/en-us/articles/determining-root-cause-of-sigsegv-or-sigbus-errors/
################################################################################################### #
# MORE OPTIONS FOR RUNTIME DEBUGGING # 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 # -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 # -check: checks at runtime, where
# arg_temp_created: will cause a lot of warnings because we create a bunch of temporary arrays (performance?) # arg_temp_created: will cause a lot of warnings because we create a bunch of temporary arrays (performance?)
# stack: # stack:
###################################################################################################
set (DEBUG_FLAGS "${DEBUG_FLAGS} -g" ) set (DEBUG_FLAGS "${DEBUG_FLAGS} -g" )
set (DEBUG_FLAGS "${DEBUG_FLAGS} -traceback" ) set (DEBUG_FLAGS "${DEBUG_FLAGS} -traceback" )
set (DEBUG_FLAGS "${DEBUG_FLAGS} -gen-interfaces" ) 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} -warn stderrors" )
set (DEBUG_FLAGS "${DEBUG_FLAGS} -debug-parameters all" ) 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) #-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) #-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") 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 # COMPILE SWITCHES
# -shared # -shared
# -Wl,-undefined,dynamic_lookup:ensure to link against dynamic libraries # -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) # -Wunused-but-set-parameter (only with -Wunused or -Wall)
# -Wno-globals # -Wno-globals
# -ffpe-summary=all only for newer gfortran # -ffpe-summary=all only for newer gfortran
################################################################################################### #
# MORE OPTIONS FOR DEBUGGING DURING COMPILATION # MORE OPTIONS FOR DEBUGGING DURING COMPILATION
# -Warray-temporarieswarnings: because we have many temporary arrays (performance issue?): # -Warray-temporarieswarnings: because we have many temporary arrays (performance issue?):
# -Wimplicit-interface: no interfaces for lapack routines # -Wimplicit-interface: no interfaces for lapack routines
# -Wunsafe-loop-optimizations: warn if the loop cannot be optimized due to nontrivial assumptions. # -Wunsafe-loop-optimizations: warn if the loop cannot be optimized due to nontrivial assumptions.
# -Wstrict-overflow: # -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} -xf95-cpp-input" )
set (COMPILE_FLAGS "${COMPILE_FLAGS} -ffree-line-length-132" ) set (COMPILE_FLAGS "${COMPILE_FLAGS} -ffree-line-length-132" )
set (COMPILE_FLAGS "${COMPILE_FLAGS} -fimplicit-none" ) 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} -Wno-unused-parameter" )
set (COMPILE_FLAGS "${COMPILE_FLAGS} -fno-range-check" ) set (COMPILE_FLAGS "${COMPILE_FLAGS} -fno-range-check" )
set (LINKER_FLAG " -Wl,-undefined,dynamic_lookup") #------------------------------------------------------------------------------------------------
###################################################################################################
# COMPILE SWITCHES FOR RUNTIME DEBUGGING # COMPILE SWITCHES FOR RUNTIME DEBUGGING
# -ffpe-trap=invalid,\ stop execution if floating point exception is detected (NaN is silent) # -ffpe-trap=invalid,\ stop execution if floating point exception is detected (NaN is silent)
# zero,\ # zero,\
@ -393,24 +373,24 @@ elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
# mem # mem
# pointer # pointer
# recursion # recursion
################################################################################################### #
# MORE OPTIONS FOR RUNTIME DEBUGGING # MORE OPTIONS FOR RUNTIME DEBUGGING
# -ffpe-trap=precision,\ # -ffpe-trap=precision,
# denormal, \ # denormal,
# underflow # underflow
###################################################################################################
set (DEBUG_FLAGS "${DEBUG_FLAGS} -g" ) set (DEBUG_FLAGS "${DEBUG_FLAGS} -g" )
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" )
set (DEBUG_FLAGS "${DEBUG_FLAGS} -ffpe-trap=invalid,zero,overflow") 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-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-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) #-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") set (PRECISION "-fdefault-real-8 -fdefault-double-8")
endif() endif()
set (CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} ${OPENMP_FLAG}" ) set (CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} ${OPENMP_FLAG}" )
@ -493,11 +473,3 @@ elseif (FEM)
DESTINATION ${CMAKE_INSTALL_PREFIX}) DESTINATION ${CMAKE_INSTALL_PREFIX})
endif(SPECTRAL) 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")