adding functionality from previous build system

This commit is contained in:
Martin Diehl 2017-02-03 23:23:55 +01:00
parent 3914dfbec4
commit 3e7ab76582
4 changed files with 257 additions and 237 deletions

View File

@ -1,23 +1,22 @@
######################################################################################## ########################################################################################
# CMAKE for build the Material subroutine for BVP solution # Compiler options for building DAMASK
########################################################################################
cmake_minimum_required (VERSION 2.8.8 FATAL_ERROR) 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 in system!") message (FATAL_ERROR "PETSC_DIR is not defined")
endif ("${PETSC_DIR}" STREQUAL "") endif ("${PETSC_DIR}" STREQUAL "")
# BRUTAL FORCE TO FIND THE VARIABLES DEFINED IN 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) 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 makefile 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 settings from PETSc are parsed
# into CMake # into CMake
set (petsc_config_makefile "${PETSC_TEMP}/Makefile.petsc") set (petsc_config_makefile "${PETSC_TEMP}/Makefile.petsc")
@ -47,8 +46,6 @@ linker:
# 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.
# The include path and linking libraries in PETSc usually contains
# duplicated entries, which is cleaned up later using CMake list.
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"
@ -79,7 +76,7 @@ execute_process(COMMAND ${MAKE_EXECUTABLE} --no-print-directory -f ${petsc_confi
# 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 ${PETSC_TEMP})
# REMOVE DUPLICATE FLAGS FOR COMPILER AND LINKING # 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})
@ -91,12 +88,12 @@ 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
@ -105,11 +102,11 @@ message("***Found MPI C COMPILER:\n${PETSC_MPICC}\n" )
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("Configuring 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("Configuring 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)
@ -123,15 +120,32 @@ set(CMAKE_LINKER "${PETSC_LINKER}")
option(OPENMP "Use OpenMP libaries for DAMASK" ON ) option(OPENMP "Use OpenMP libaries for DAMASK" ON )
option(OPTIMIZATION "DAMASK optimization level [OFF,DEFENSIVE,AGGRESSIVE]" "DEFENSIVE" ) option(OPTIMIZATION "DAMASK optimization level [OFF,DEFENSIVE,AGGRESSIVE]" "DEFENSIVE" )
# Setting installation prefix if("${CMAKE_BUILD_TYPE}" STREQUAL "DEBUG")
if (DEFINED DAMASK_INSTALL) set (OPENMP "OFF")
set (CMAKE_INSTALL_PREFIX "${DAMASK_INSTALL}") set (OPTIMIZATION "OFF")
else(DEFINED DAMASK_INSTALL) endif("${CMAKE_BUILD_TYPE}" STREQUAL "DEBUG")
set (CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/bin")
endif(DEFINED DAMASK_INSTALL)
message("\n***The binary will be installed at\n${CMAKE_INSTALL_PREFIX}\n")
# Find DAMASK version (DAMASK_V) in DAMASK_ROOT # Parse DAMASK_BIN from CONFIG file
file(READ "CONFIG" CONFIGFILE)
STRING(REGEX REPLACE ";" "\\\\;" CONFIGFILE "${CONFIGFILE}")
STRING(REGEX REPLACE "\n" ";" CONFIGFILE "${CONFIGFILE}")
FOREACH(item ${CONFIGFILE})
STRING(REGEX MATCH ".+DAMASK_BIN.+" item ${item})
IF(item)
message("${item}")
string(REGEX REPLACE "set" "" item "${item}")
message("${item}")
string(REGEX REPLACE "=" " " item "${item}")
message("${item}")
string(REGEX REPLACE "\\\${DAMASK_ROOT}" "${CMAKE_CURRENT_SOURCE_DIR}" item "${item}")
message("${item}")
string(REPLACE "DAMASK_BIN" ";" STRING_LIST ${item})
list(GET STRING_LIST 1 item)
string(STRIP "${item}" CMAKE_INSTALL_PREFIX)
ENDIF(item)
ENDFOREACH(item ${CONFIGFILE})
# 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
@ -153,7 +167,7 @@ set (DAMASK_INCLUDE_FLAGS "${DAMASK_INCLUDE_FLAGS} -I${PROJECT_SOURCE_DIR}/lib")
if(${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel") if(${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
if (OPENMP) if (OPENMP)
set (OPENMP_FLAGS "-openmp -openmp-report0 -parallel") set (OPENMP_FLAGS "-qopenmp -parallel")
endif(OPENMP) endif(OPENMP)
if ("${OPTIMIZATION}" STREQUAL "OFF") if ("${OPTIMIZATION}" STREQUAL "OFF")
@ -161,69 +175,104 @@ if(${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
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" ) #-fast = -ipo, -O3, -no-prec-div, -static, -fp-model fast=2, and -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"
endif() endif()
set (STANDARD_CHECK "-stand f08 -standard-semantics") set (STANDARD_CHECK "-stand f08 -standard-semantics")
set (LINKER_FLAGS "-shared-intel") set (LINKER_FLAGS "${LINKER_FLAGS} -shared-intel")
# Link against shared Intel libraries instead of static ones
#------------------------------------------------------------------------------------------------ #------------------------------------------------------------------------------------------------
# COMPILE SWITCHES # Fine tuning compilation options
# -fimplicit-none: assume "implicit-none" even if not present in source set (COMPILE_FLAGS "${COMPILE_FLAGS} -fpp")
# stderrors: warnings about Fortran standard violations are changed to errors (STANDARD_CHECK) # preprocessor
set (COMPILE_FLAGS "${COMPILE_FLAGS} -ftz")
# flush unterflow to zero, automatically set if O<0,1,2,3> >0
set (COMPILE_FLAGS "${COMPILE_FLAGS} -assume")
# assume
set (COMPILE_FLAGS "${COMPILE_FLAGS}byterecl")
# record length is given in bytes (also set by -standard-semantics)
set (COMPILE_FLAGS "${COMPILE_FLAGS},fpe_summary")
# print list of floating point exceptions occured during execution
set (COMPILE_FLAGS "${COMPILE_FLAGS} -diag-disable")
# disables warnings, where
set (COMPILE_FLAGS "${COMPILE_FLAGS}5268")
# the text exceeds right hand column allowed on the line (we have only comments there)
set (COMPILE_FLAGS "${COMPILE_FLAGS} -warn")
# enables warnings, where
set (COMPILE_FLAGS "${COMPILE_FLAGS}declarations")
# any undeclared names (alternative name: -implicitnone)
set (COMPILE_FLAGS "${COMPILE_FLAGS},general")
# warning messages and informational messages are issued by the compiler
set (COMPILE_FLAGS "${COMPILE_FLAGS},usage")
# questionable programming practices
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
set (COMPILE_FLAGS "${COMPILE_FLAGS},ignore_loc")
# %LOC is stripped from an actual argument
set (COMPILE_FLAGS "${COMPILE_FLAGS},alignments")
# data that is not naturally aligned
set (COMPILE_FLAGS "${COMPILE_FLAGS},unused")
# declared variables that are never used
set (COMPILE_FLAGS "${COMPILE_FLAGS} -fpp") # preprocessor # Additional options
set (COMPILE_FLAGS "${COMPILE_FLAGS} -ftz") # flush unterflow to zero, automatically set if O<0,1,2,3> >0 # -warn: enables warnings, where
set (COMPILE_FLAGS "${COMPILE_FLAGS} -assume") # assume # truncated_source: Determines whether warnings occur when source exceeds the maximum column width in fixed-format files.
set (COMPILE_FLAGS "${COMPILE_FLAGS} byterecl,") # record length is given in bytes (also set by -standard-semantics) # (too many warnings because we have comments beyond character 132)
set (COMPILE_FLAGS "${COMPILE_FLAGS} ,fpe_summary") # print list of floating point exceptions occured during execution # uncalled: Determines whether warnings occur when a statement function is never called
set (COMPILE_FLAGS "${COMPILE_FLAGS} -diag-disable") # disables warnings, where # all:
set (COMPILE_FLAGS "${COMPILE_FLAGS} 5268") # the text exceeds right hand column allowed on the line (we have only comments there) # -name as_is: case sensitive Fortran!
set (COMPILE_FLAGS "${COMPILE_FLAGS} -warn") # enables warnings, where
set (COMPILE_FLAGS "${COMPILE_FLAGS} declarations") # any undeclared names (alternative name: -implicitnone)
set (COMPILE_FLAGS "${COMPILE_FLAGS} ,general") # warning messages and informational messages are issued by the compiler
set (COMPILE_FLAGS "${COMPILE_FLAGS} ,usage") # questionable programming practices
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
set (COMPILE_FLAGS "${COMPILE_FLAGS} ,ignore_loc") # %LOC is stripped from an actual argument
set (COMPILE_FLAGS "${COMPILE_FLAGS} ,alignments") # data that is not naturally aligned
set (COMPILE_FLAGS "${COMPILE_FLAGS} ,unused") # declared variables that are never used
# 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!
#------------------------------------------------------------------------------------------------ #------------------------------------------------------------------------------------------------
# COMPILE SWITCHES FOR RUNTIME DEBUGGING # Runtime debugging
set (DEBUG_FLAGS "${DEBUG_FLAGS} -g" )# Generate symbolic debugging information in the object file set (DEBUG_FLAGS "${DEBUG_FLAGS} -g")
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 symbolic debugging information in the object file
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/ set (DEBUG_FLAGS "${DEBUG_FLAGS} -traceback")
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 information in the object file to provide source file traceback information when a severe error occurs at run time.
set (DEBUG_FLAGS "${DEBUG_FLAGS} -fp-model strict" )# Trap uninitalized variables set (DEBUG_FLAGS "${DEBUG_FLAGS} -gen-interfaces")
set (DEBUG_FLAGS "${DEBUG_FLAGS} -check bounds,format,output_conversion,pointers,uninit" )# Checks at runtime, where # Generate an interface block for each routine. http://software.intel.com/en-us/blogs/2012/01/05/doctor-fortran-gets-explicit-again/
# bounds: if an array index is too small (<1) or too large! set (DEBUG_FLAGS "${DEBUG_FLAGS} -fp-stack-check")
# format: for the data type of an item being formatted for output. # Generate extra code after every function call to ensure that the floating-point (FP) stack is in the expected state.
# output_conversion: for the fit of data items within a designated format descriptor field. set (DEBUG_FLAGS "${DEBUG_FLAGS} -fp-model strict")
# pointers: for certain disassociated or uninitialized pointers or unallocated allocatable objects. # Trap uninitalized variables
# uninit: for uninitialized variables. set (DEBUG_FLAGS "${DEBUG_FLAGS} -check" )
set (DEBUG_FLAGS "${DEBUG_FLAGS} -ftrapuv" ) # Checks at runtime, where
set (DEBUG_FLAGS "${DEBUG_FLAGS} -fpe-all0" )# Capture all floating-point exceptions, sets -ftz automatically set (DEBUG_FLAGS "${DEBUG_FLAGS}bounds")
set (DEBUG_FLAGS "${DEBUG_FLAGS} -warn errors,stderrors" )# Configures warnings, where # if an array index is too small (<1) or too large!
# errors: warnings are changed to errors set (DEBUG_FLAGS "${DEBUG_FLAGS},format")
# stderrors: warnings about Fortran standard violations are changed to errors # for the data type of an item being formatted for output.
set (DEBUG_FLAGS "${DEBUG_FLAGS},output_conversion")
# for the fit of data items within a designated format descriptor field.
set (DEBUG_FLAGS "${DEBUG_FLAGS},pointers")
# for certain disassociated or uninitialized pointers or unallocated allocatable objects.
set (DEBUG_FLAGS "${DEBUG_FLAGS},uninit")
# for uninitialized variables.
set (DEBUG_FLAGS "${DEBUG_FLAGS} -ftrapuv")
# initializes stack local variables to an unusual value to aid error detection
set (DEBUG_FLAGS "${DEBUG_FLAGS} -fpe-all0")
# capture all floating-point exceptions, sets -ftz automatically
set (DEBUG_FLAGS "${DEBUG_FLAGS} -warn")
# enables warnings, where
set (DEBUG_FLAGS "${DEBUG_FLAGS}errors")
# warnings are changed to errors
set (DEBUG_FLAGS "${DEBUG_FLAGS},stderrors")
# 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" )
# MORE OPTIONS FOR RUNTIME DEBUGGING # generate debug information for parameters
# -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 # Additional options
# arg_temp_created: will cause a lot of warnings because we create a bunch of temporary arrays (performance?) # -heap-arrays: Should not be done for OpenMP, but set "ulimit -s unlimited" on shell. Probably it helps also to unlimit other limits
# stack: # -check: Checks at runtime, where
# arg_temp_created: will cause a lot of warnings because we create a bunch of temporary arrays (performance?)
# stack:
#------------------------------------------------------------------------------------------------ #------------------------------------------------------------------------------------------------
# PRECISION SETTINGS # precision settings
#-real-size 32: set precision to one of those 32/64/128 (= 4/8/16 bytes) for standard real (=8 for pReal) set (PRECISION_FLAGS "${PRECISION_FLAGS} -real-size 64")
#-integer-size 16: set precision to one of those 16/32/64 (= 2/4/8 bytes) for standard integer (=4 for pInt) # set precision to one of those 32/64/128 (= 4/8/16 bytes) for standard real (=8 for pReal)
set (PRECISION_FLAGS "-real-size 64 -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)
################################################################################################### ###################################################################################################
@ -244,15 +293,24 @@ elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
endif() endif()
set (STANDARD_CHECK "-std=f2008ts -pedantic-errors" ) set (STANDARD_CHECK "-std=f2008ts -pedantic-errors" )
set (LINKER_FLAGS "-Wl,-undefined,dynamic_lookup" )# ensure to link against dynamic libraries set (LINKER_FLAGS "${LINKER_FLAGS} -Wl")
# options parsed directly to the linker
set (LINKER_FLAGS "${LINKER_FLAGS},-undefined")
set (LINKER_FLAGS "${LINKER_FLAGS},-dynamic_lookup" )
# ensure to link against dynamic libraries
#------------------------------------------------------------------------------------------------ #------------------------------------------------------------------------------------------------
# COMPILE SWITCHES # Fine tuning compilation options
set (COMPILE_FLAGS "${COMPILE_FLAGS} -xf95-cpp-input" )# preprocessor set (COMPILE_FLAGS "${COMPILE_FLAGS} -xf95-cpp-input")
set (COMPILE_FLAGS "${COMPILE_FLAGS} -ffree-line-length-132" )# restrict line length to the standard 132 characters (lattice.f90 require larger) # preprocessor
set (COMPILE_FLAGS "${COMPILE_FLAGS} -fimplicit-none" )# assume "implicit none" even if not present in source set (COMPILE_FLAGS "${COMPILE_FLAGS} -ffree-line-length-132")
set (COMPILE_FLAGS "${COMPILE_FLAGS} -fmodule-private" )# assume "private" even if not present in source # restrict line length to the standard 132 characters (lattice.f90 require more characters)
set (COMPILE_FLAGS "${COMPILE_FLAGS} -Wall" )# sets the following Fortran options: set (COMPILE_FLAGS "${COMPILE_FLAGS} -fimplicit-none")
# assume "implicit none" even if not present in source
set (COMPILE_FLAGS "${COMPILE_FLAGS} -fmodule-private")
# assume "private" even if not present in source
set (COMPILE_FLAGS "${COMPILE_FLAGS} -Wall")
# 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.
# -Wampersand: checks if a character expression is continued proberly by an ampersand at the end of the line and at the beginning of the new line # -Wampersand: checks if a character expression is continued proberly by an ampersand at the end of the line and at the beginning of the new line
# -Warray-bounds: checks if array reference is out of bounds at compile time. use -fcheck-bounds to also check during runtime # -Warray-bounds: checks if array reference is out of bounds at compile time. use -fcheck-bounds to also check during runtime
@ -266,7 +324,7 @@ elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
# -Wtarget-lifetime: # -Wtarget-lifetime:
# -Wreal-q-constant: warn about real-literal-constants with 'q' exponent-letter # -Wreal-q-constant: warn about real-literal-constants with 'q' exponent-letter
# -Wunused: a number of unused-xxx warnings # -Wunused: a number of unused-xxx warnings
# these are general (non -Fortran options) implied by -Wall # and sets the general (non-Fortran options) options:
# -Waddress # -Waddress
# -Warray-bounds (only with -O2) # -Warray-bounds (only with -O2)
# -Wc++11-compat # -Wc++11-compat
@ -291,83 +349,79 @@ 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")
# -Wextra: sets the following Fortran options: # sets the following Fortran options:
# -Wunuses-parameter: # -Wunuses-parameter:
# -Wcompare-reals: # -Wcompare-reals:
# these are general (non -Fortran options) implied by -Wextra # and sets the general (non-Fortran options) options:
# -Wclobbered # -Wclobbered
# -Wempty-body # -Wempty-body
# -Wignored-qualifiers # -Wignored-qualifiers
# -Wmissing-field-initializers # -Wmissing-field-initializers
# -Woverride-init # -Woverride-init
# -Wsign-compare # -Wsign-compare
# -Wtype-limits # -Wtype-limits
# -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" )# warn if character expressions (strings) are truncated set (COMPILE_FLAGS "${COMPILE_FLAGS} -Wcharacter-truncation")
set (COMPILE_FLAGS "${COMPILE_FLAGS} -Wunderflow" )# produce a warning when numerical constant expressions are encountered, which yield an UNDERFLOW during compilation # warn if character expressions (strings) are truncated
set (COMPILE_FLAGS "${COMPILE_FLAGS} -Wsuggest-attribute=pure" ) set (COMPILE_FLAGS "${COMPILE_FLAGS} -Wunderflow")
# 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=noreturn") set (COMPILE_FLAGS "${COMPILE_FLAGS} -Wsuggest-attribute=noreturn")
set (COMPILE_FLAGS "${COMPILE_FLAGS} -Wconversion-extra" ) set (COMPILE_FLAGS "${COMPILE_FLAGS} -Wconversion-extra")
set (COMPILE_FLAGS "${COMPILE_FLAGS} -Wimplicit-procedure" ) set (COMPILE_FLAGS "${COMPILE_FLAGS} -Wimplicit-procedure")
set (COMPILE_FLAGS "${COMPILE_FLAGS} -Wno-unused-parameter" ) set (COMPILE_FLAGS "${COMPILE_FLAGS} -Wno-unused-parameter")
# MORE OPTIONS FOR DEBUGGING DURING COMPILATION set (COMPILE_FLAGS "${COMPILE_FLAGS} -ffpe-summary=all")
# -Warray-temporarieswarnings: because we have many temporary arrays (performance issue?): # print summary of floating point exeptions (invalid,zero,overflow,underflow,inexact,denormal)
# -Wimplicit-interface: no interfaces for lapack/MPI routines
# -Wunsafe-loop-optimizations: warn if the loop cannot be optimized due to nontrivial assumptions.
# -ffpe-summary: print summary of floating point exeptions (invalid, zero, overflow, underflow, inexact and denormal)
# -ffpe-summary=all: only for newer gfortran
# Additional options
# -Warray-temporarieswarnings: because we have many temporary arrays (performance issue?):
# -Wimplicit-interface: no interfaces for lapack/MPI routines
# -Wunsafe-loop-optimizations: warn if the loop cannot be optimized due to nontrivial assumptions.
#------------------------------------------------------------------------------------------------ #------------------------------------------------------------------------------------------------
# COMPILE SWITCHES FOR RUNTIME DEBUGGING # Runtime debugging
# -ffpe-trap=invalid,\ stop execution if floating point exception is detected (NaN is silent) set (DEBUG_FLAGS "${DEBUG_FLAGS} -ffpe-trap=invalid,zero,overflow")
# zero,\ # stop execution if floating point exception is detected (NaN is silent)
# overflow set (DEBUG_FLAGS "${DEBUG_FLAGS} -g")
# # Generate symbolic debugging information in the object file
# MORE OPTIONS FOR RUNTIME DEBUGGING
# -ffpe-trap=precision,
# denormal,
# underflow
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" )
# -fcheck=all: sets the following Fortran options: # checks for (array-temps,bounds,do,mem,pointer,recursion)
# array-temps
# bounds
# do
# mem
# pointer
# recursion
set (DEBUG_FLAGS "${DEBUG_FLAGS} -ffpe-trap=invalid,zero,overflow")
# Additional options
# -ffpe-trap=precision,denormal,underflow
#------------------------------------------------------------------------------------------------ #------------------------------------------------------------------------------------------------
# PRECISION SETTINGS # 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 set (PRECISION_FLAGS "${PRECISION_FLAGS} -fdefault-real-8")
#-fdefault-double-8: set precision to 8 bytes for double real, would be 16 bytes because -fdefault-real-8 is used # 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-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_FLAGS "${PRECISION_FLAGS} -fdefault-double-8")
set (PRECISION_FLAGS "-fdefault-real-8 -fdefault-double-8") # set precision to 8 bytes for double real, would be 16 bytes if -fdefault-real-8 is used
# 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)
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 (NOT "${CMAKE_BUILD_TYPE}" STREQUAL "RELEASE") if("${CMAKE_BUILD_TYPE}" STREQUAL "")
set (CMAKE_BUILD_TYPE "RELEASE")
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("***COMPILE FLAGS:\n${CMAKE_Fortran_FLAGS}\n") message("Compiler Flags (Fortran):\n${CMAKE_Fortran_FLAGS}\n")
message("***LINKER:\n${CMAKE_Fortran_LINK_EXECUTABLE}\n") message("Linker Flags (Fortran):\n${CMAKE_Fortran_LINK_EXECUTABLE}\n")
# MOVE to SOURCE DIRECTORY for BUILDING # location of code
add_subdirectory(src) add_subdirectory(src)
# INSTALL BUILT BINARIES # INSTALL BUILT BINARIES

View File

@ -3,43 +3,38 @@ SHELL = /bin/sh
# Makefile for the installation of DAMASK # Makefile for the installation of DAMASK
######################################################################################## ########################################################################################
.PHONY: all .PHONY: all
all: spectral FEM marc all: spectral FEM marc processing
spectral: build/spectral spectral: build/spectral
@(cd build/spectral; make --no-print-directory -ws all install VERBOSE=1;) @(cd build/spectral;make --no-print-directory -ws all install VERBOSE=1;)
build/spectral: build
@mkdir build/spectral
@(cd build/spectral; cmake -Wno-dev -DCMAKE_BUILD_TYPE=RELEASE -DDAMASK_SOLVER=SPECTRAL ../..;)
FEM: build/FEM FEM: build/FEM
@(cd build/FEM; make --no-print-directory -ws all install;) @(cd build/FEM; make --no-print-directory -ws all install;)
OPTIONS="-Wno-dev -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DBUILDCMD_POST=${BUILDCMD_POST} -DBUILDCMD_PRE={BUILDCMD_PRE} -DOPTIMIZATION=${OPTIMIZATION} -DOPENMP=${OPENMP}"
build/spectral: build
@mkdir -p build/spectral
@(cd build/spectral; cmake -DDAMASK_SOLVER=SPECTRAL ${OPTIONS} ../..;)
build/FEM: build build/FEM: build
@mkdir build @mkdir -p build/FEM
@(cd build/FEM; cmake -Wno-dev -DCMAKE_BUILD_TYPE=RELEASE -DDAMASK_SOLVER=FEM ../..;) @(cd build/FEM; cmake -DDAMASK_SOLVER=FEM ${OPTIONS} ../..;)
build: bin
@mkdir build
bin:
@mkdir bin
build:
@mkdir -p build
.PHONY: marc .PHONY: marc
marc: marc:
@./installation/symLink_Code.sh
@./installation/mods_MarcMentat/apply_DAMASK_modifications.sh ${MAKEFLAGS} @./installation/mods_MarcMentat/apply_DAMASK_modifications.sh ${MAKEFLAGS}
.PHONY: tidy
tidy:
@$(MAKE) tidy -C code >/dev/null
.PHONY: clean .PHONY: clean
clean: clean:
@$(MAKE) cleanDAMASK -C code >/dev/null @rm -rf build
.PHONY: install .PHONY: processing
install: install:
@./installation/symlink_Code.py ${MAKEFLAGS}
@./installation/symlink_Processing.py ${MAKEFLAGS} @./installation/symlink_Processing.py ${MAKEFLAGS}

View File

@ -4,13 +4,6 @@
import os,sys import os,sys
import damask import damask
bin_link = { \
'.' : [
'DAMASK_spectral.exe',
'DAMASK_FEM.exe'
],
}
MarcReleases =[ \ MarcReleases =[ \
'2014', '2014',
'2014.2', '2014.2',
@ -25,29 +18,6 @@ binDir = damaskEnv.options['DAMASK_BIN']
if not os.path.isdir(binDir): if not os.path.isdir(binDir):
os.mkdir(binDir) os.mkdir(binDir)
sys.stdout.write('\nsymbolic linking...\n')
for subDir in bin_link:
theDir = os.path.abspath(os.path.join(baseDir,subDir))
sys.stdout.write('\n'+binDir+' ->\n'+theDir+damask.util.deemph(' ...')+'\n')
for theFile in bin_link[subDir]:
theName,theExt = os.path.splitext(theFile)
src = os.path.abspath(os.path.join(theDir,theFile))
if os.path.exists(src):
sym_link = os.path.abspath(os.path.join(binDir,subDir if theFile == '' else theName))
if os.path.lexists(sym_link):
os.remove(sym_link)
output = theName+damask.util.deemph(theExt)
else:
output = damask.util.emph(theName)+damask.util.deemph(theExt)
sys.stdout.write(damask.util.deemph('... ')+output+'\n')
os.symlink(src,sym_link)
sys.stdout.write('\nMSC.Marc versioning...\n\n') sys.stdout.write('\nMSC.Marc versioning...\n\n')
theMaster = 'DAMASK_marc.f90' theMaster = 'DAMASK_marc.f90'

View File

@ -1,5 +1,8 @@
# SOME FILES REQUIRE SPECIAL FLAGS # special flags for some files
if (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU") if (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
SET_SOURCE_FILES_PROPERTIES( "prec.f90" PROPERTIES
COMPILE_FLAGS "-fno-range-check -fall-intrinsics -fno-fast-math")
# fno-range-check: Disable range checking on results of simplification of constant expressions during compilation # fno-range-check: Disable range checking on results of simplification of constant expressions during compilation
# --> allows the definition of DAMASK_NaN # --> allows the definition of DAMASK_NaN
#-fall-intrinsics: all intrinsic procedures (including the GNU-specific extensions) are accepted. -Wintrinsics-std will be ignored #-fall-intrinsics: all intrinsic procedures (including the GNU-specific extensions) are accepted. -Wintrinsics-std will be ignored
@ -7,13 +10,14 @@ if (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
# --> allows the use of 'isnan' # --> allows the use of 'isnan'
#-fno-fast-math: #-fno-fast-math:
# --> otherwise, when setting -ffast-math, isnan always evaluates to false (I would call it a bug) # --> otherwise, when setting -ffast-math, isnan always evaluates to false (I would call it a bug)
SET_SOURCE_FILES_PROPERTIES( "prec.f90" PROPERTIES
COMPILE_FLAGS "-fno-range-check -fall-intrinsics -fno-fast-math")
# long lines for interaction matrix
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
endif() endif()
set( CMAKE_VERBOSE_MAKEFILE on ) set( CMAKE_VERBOSE_MAKEFILE on )
# The dependency detection in CMake is not functioning for Fortran, # The dependency detection in CMake is not functioning for Fortran,
# hence we declare the dependencies from top to bottom in the following # hence we declare the dependencies from top to bottom in the following
add_library(C_ROUTINES OBJECT "C_routines.c") add_library(C_ROUTINES OBJECT "C_routines.c")
@ -30,7 +34,7 @@ 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 "DAMASK_FEM_interface.f90") add_library(DAMASK_INTERFACE OBJECT "FEM_interface.f90")
endif() endif()
add_dependencies(DAMASK_INTERFACE PREC) add_dependencies(DAMASK_INTERFACE PREC)
list(APPEND OBJECTFILES $<TARGET_OBJECTS:DAMASK_INTERFACE>) list(APPEND OBJECTFILES $<TARGET_OBJECTS:DAMASK_INTERFACE>)
@ -51,11 +55,8 @@ add_library(FEsolving OBJECT "FEsolving.f90")
add_dependencies(FEsolving DEBUG) add_dependencies(FEsolving DEBUG)
list(APPEND OBJECTFILES $<TARGET_OBJECTS:FEsolving>) list(APPEND OBJECTFILES $<TARGET_OBJECTS:FEsolving>)
add_library(EXTERNAL_LIBS OBJECT "libs.f90")
list(APPEND OBJECTFILES $<TARGET_OBJECTS:EXTERNAL_LIBS>)
add_library(DAMASK_MATH OBJECT "math.f90") add_library(DAMASK_MATH OBJECT "math.f90")
add_dependencies(DAMASK_MATH FEsolving EXTERNAL_LIBS) 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