got petsc related flags for CMake

This commit is contained in:
zhangc43 2016-03-01 13:23:47 -05:00
parent 22689c1053
commit 48da078bfe
2 changed files with 40 additions and 81 deletions

View File

@ -39,60 +39,67 @@ file (WRITE "${petsc_config_makefile}"
"## This file was autogenerated by FindPETSc.cmake
# PETSC_DIR = ${PETSC_DIR}
# PETSC_ARCH = ${PETSC_ARCH}
SHELL = /bin/sh
include ${petsc_conf_rules}
include ${petsc_conf_variables}
show:
\t-@echo -n \${\${VARIABLE}}
INCLUDE_DIRS := \${PETSC_FC_INCLUDES} -DPETSc
LIBRARIES := \${PETSC_WITH_EXTERNAL_LIB}
COMPILERNAME ?= \${FC}
LINKERNAME ?= \${FLINKER}
includes:
\t@echo \${INCLUDE_DIRS}
extlibs:
\t@echo \${LIBRARIES}
compiler:
\t@echo \${COMPILERNAME}
linker:
\t@echo \${LINKERNAME}
")
macro (PETSC_GET_VARIABLE name var)
set (${var} "NOTFOUND" CACHE INTERNAL "Cleared" FORCE)
execute_process (COMMAND ${MAKE_EXECUTABLE} --no-print-directory -f ${petsc_config_makefile}
show VARIABLE=${name}
OUTPUT_VARIABLE ${var}
RESULT_VARIABLE petsc_return)
endmacro (PETSC_GET_VARIABLE)
petsc_get_variable (PETSC_LIB_DIR "PETSC_LIB_DIR" )
petsc_get_variable (PETSC_EXTERNAL_LIB_BASIC "PETSC_LIBS_EXTERNAL")
petsc_get_variable (PETSC_CCPPFLAGS "PETSC_CPP_LINE" )
petsc_get_variable (PETSC_INCLUDE "PETSC_INCLUDE" )
petsc_get_variable (PCC "PETSC_CC" )
petsc_get_variable (PCC_FLAGS "PETSC_CC_FLAGS" )
petsc_get_variable (MPIEXEC "PETSC_MPIEXEC" )
# We are done with the temporary Makefile, calling PETSC_GET_VARIABLE after this point is invalid!
# file (REMOVE ${petsc_config_makefile})
find_program (MAKE_EXECUTABLE NAMES make gmake)
execute_process(COMMAND ${MAKE_EXECUTABLE} -f ${petsc_config_makefile} "includes"
RESULT_VARIABLE PETSC_INCLUDES_RETURN
OUTPUT_VARIABLE PETSC_INCLUDES)
execute_process(COMMAND ${MAKE_EXECUTABLE} -f ${petsc_config_makefile} "extlibs"
RESULT_VARIABLE PETSC_EXTERNAL_LIB_RETURN
OUTPUT_VARIABLE PETSC_EXTERNAL_LIB)
execute_process(COMMAND ${MAKE_EXECUTABLE} -f ${petsc_config_makefile} "linker"
RESULT_VARIABLE PETSC_LINK_LIB_RETURN
OUTPUT_VARIABLE PETSC_LINK_LIB)
execute_process(COMMAND ${MAKE_EXECUTABLE} -f ${petsc_config_makefile} "compiler"
RESULT_VARIABLE MPIEXEC_RETURN
OUTPUT_VARIABLE MPIEXEC)
file (REMOVE ${petsc_config_makefile})
message("${PETSC_DIR}")
message("${PETSC_LIB_DIR}")
message("${PETSC_INCLUDE}")
message("\nFound PETSC_DIR:\n${PETSC_DIR}")
message("Set PETSC_INCLUDES to:\n${PETSC_INCLUDES}")
message("Set PETSC_EXTERNAL_LIB to:\n${PETSC_EXTERNAL_LIB}")
message("Set PETSC_LINK_LIB to:\n${PETSC_LINK_LIB}")
message("Use PETSC wrapped compiler @: ${MPIEXEC}")
# OUTPUT TYPE
set (SPECTRAL OFF)
set (FEM OFF)
set (MARC OFF)
set (ABAQUS OFF)
if (DAMASK_DRIVER STREQUAL "SPECTRAL")
set (SPECTRAL ON )
elseif (DAMASK_DRIVER STREQUAL "FEM")
set (FEM ON )
elseif (DAMASK_DRIVER STREQUAL "MARC")
set (MARC ON )
elseif (DAMASK_DRIVER STREQUAL "ABAQUS")
set (ABAQUS ON )
else (DAMASK_DRIVER STREQUAL "SPECTRAL")
message (FATAL_ERROR "Unknown output, check build script!")
endif (DAMASK_DRIVER STREQUAL "SPECTRAL")
# set system include directories
include_directories(${CMAKE_SOURCE_DIR}/code
${PETSC_DIR}/include
include_directories(${PETSC_INCLUDES}
lib
${HDF5_DIR}/include
)
link_directories(${HDF5_DIR}/lib
${PETSC_DIR}/lib
${PETSC_EXTERNAL_LIB_BASIC})
${PETSC_LINK_LIB}
${PETSC_EXTERNAL_LIB}
)
##
# set compile and debug flags
@ -356,7 +363,7 @@ get_filename_component (Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER} NAME)
if (Fortran_COMPILER_NAME MATCHES "ifort.*")
# need the PETSC wrapped version of ifort
set (CMAKE_Fortran_COMPILER "${PETSC_DIR}/bin/mpif90")
set (CMAKE_Fortran_COMPILER "${MPIEXEC}")
# for RELEASE
set (CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} ${OPENMP_FLAG_ifort}" )
set (CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} ${STANDARD_CHECK_ifort}" )
@ -375,7 +382,7 @@ if (Fortran_COMPILER_NAME MATCHES "ifort.*")
set (CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${DEBUG_OPTIONS_ifort}")
#
elseif (Fortran_COMPILER_NAME MATCHES "gfortran.*")
set (CMAKE_Fortran_COMPILER "${PETSC_DIR}/bin/mpif90")
set (CMAKE_Fortran_COMPILER "${MPIEXEC}")
# for RELEASE
set (CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} ${OPENMP_FLAG_gfortran}" )
set (CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} ${STANDARD_CHECK_gfortran}" )
@ -414,12 +421,6 @@ if (FEM)
set (CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -DFEM")
endif (FEM)
# set PETSC flags
set (CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} -DPETSc")
set (CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} -DPETSc")
set (CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -DPETSc")
set (CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -DPETSc")
# set default project compiler flags
# NOTE: some file might need different flags for compiling, DAMASK_$FLAGS
# are essentially the swap for this purpose

View File

@ -1,42 +0,0 @@
SHELL = /bin/sh
########################################################################################
# Makefile for the installation of DAMASK
########################################################################################
.PHONY: all
all: spectral marc processing
.PHONY: spectral
spectral:
$(MAKE) DAMASK_spectral.exe -C code
.PHONY: FEM
FEM:
$(MAKE) DAMASK_FEM.exe -C code
.PHONY: marc
marc:
@./installation/mods_MarcMentat/apply_DAMASK_modifications.sh ${MAKEFLAGS}
.PHONY: processing
processing:
@if hash cython 2>/dev/null; then \
cd ./lib/damask; \
CC=gcc python setup_corientation.py build_ext --inplace; \
rm -rv build; \
rm *.c; \
fi
@./installation/compile_CoreModule.py ${MAKEFLAGS}
.PHONY: tidy
tidy:
@$(MAKE) tidy -C code >/dev/null
.PHONY: clean
clean:
@$(MAKE) cleanDAMASK -C code >/dev/null
.PHONY: install
install:
@./installation/symlink_Code.py ${MAKEFLAGS}
@./installation/symlink_Processing.py ${MAKEFLAGS}