2012-03-02 01:04:42 +05:30
SHELL = /bin/sh
########################################################################################
# Makefile to compile the Material subroutine for BVP solution using spectral method
########################################################################################
# Be sure to remove all files compiled with different options by using "make clean"
#
2012-07-03 18:06:54 +05:30
# Uses OpenMP to parallelize the material subroutines
# (set number of threads with "export DAMASK_NUM_THREADS=n" to n)
2012-03-02 01:04:42 +05:30
#
# Install fftw3 (v3.3 is tested):
2012-07-03 18:06:54 +05:30
# + execute
2012-03-02 01:04:42 +05:30
# ./configure --enable-threads --enable-sse2 --enable-shared [-enable-float]
# make
# make install
# + specify in the "pathinfo:FFTW" where FFTW was installed.
2012-07-03 18:06:54 +05:30
# We essentially look for two library files "lib/libfftw3_threads" and "lib/libfftw3",
# so you can copy those, for instance,
2012-03-02 01:04:42 +05:30
# into DAMASK_ROOT/lib/fftw/lib/ and specify "./fftw/" as pathinfo:FFTW
# Use --enable-float in above configure for single precision...
# Uses linux threads to parallelize fftw3
#
2012-07-03 18:06:54 +05:30
# Instead of the AMD Core Math Library a standard "lib(64)/liblapack.a/dylib/etc." can be used.
# leave pathinfo:ACML and pathinfo:IKML blank, but specify as pathinfo:LAPACK where the library folder is located
2012-03-02 01:04:42 +05:30
########################################################################################
# OPTIONS = standard (alternative): meaning
#-------------------------------------------------------------
# F90 = ifort (gfortran): compiler, choose Intel or GNU
# COMPILERNAME = overwrite name of Compiler, e.g. using mpich-g90 instead of ifort
# PORTABLE = TRUE (FALSE): decision, if executable is optimized for the machine on which it was built.
# OPTIMIZATION = DEFENSIVE (OFF,AGGRESSIVE,ULTRA): Optimization mode: O2, O0, O3 + further options for most files, O3 + further options for all files
# OPENMP = TRUE (FALSE): OpenMP multiprocessor support
# FFTWROOT = pathinfo:FFTW (will be adjusted by setup_code.py - required in pathinfo)
2012-07-03 18:06:54 +05:30
# IMKLROOT = pathinfo:IMKL (will be adjusted by setup_code.py if present in pathinfo)
2012-03-02 01:04:42 +05:30
# ACMLROOT = pathinfo:ACML (will be adjusted by setup_code.py if present in pathinfo)
# LAPACKROOT = pathinfo:LAPACK (will be adjusted by setup_code.py if present in pathinfo)
# PREFIX = arbitrary prefix
# SUFFIX = arbitrary suffix
# STANDARD_CHECK = checking for Fortran 2008, compiler dependend
########################################################################################
2012-11-14 00:42:00 +05:30
#any values will be overwritten by setup_code.py
FFTWROOT ?= auto
IMKLROOT ?= auto
ACMLROOT ?= auto
LAPACKROOT ?= auto
2012-11-14 00:10:14 +05:30
F90 ?= ifort
2012-03-02 01:04:42 +05:30
COMPILERNAME ?= $( F90)
2012-06-18 20:57:01 +05:30
2012-06-12 15:14:05 +05:30
INCLUDE_DIRS += -I$( DAMASK_ROOT) /lib
2012-06-20 18:19:46 +05:30
2012-03-02 01:04:42 +05:30
i f e q "$(FASTBUILD)" "YES"
2012-07-03 18:06:54 +05:30
OPENMP := OFF
OPTIMIZATION := OFF
2012-06-15 21:40:21 +05:30
e l s e
2012-03-02 01:04:42 +05:30
OPENMP ?= ON
OPTIMIZATION ?= DEFENSIVE
2012-06-15 21:40:21 +05:30
e n d i f
2012-03-02 01:04:42 +05:30
i f e q "$(OPTIMIZATION)" "OFF"
OPTI := OFF
MAXOPTI := OFF
e n d i f
i f e q "$(OPTIMIZATION)" "DEFENSIVE"
OPTI := DEFENSIVE
MAXOPTI := DEFENSIVE
e n d i f
i f e q "$(OPTIMIZATION)" "AGGRESSIVE"
OPTI := AGGRESSIVE
MAXOPTI := DEFENSIVE
e n d i f
i f e q "$(OPTIMIZATION)" "ULTRA"
OPTI := AGGRESSIVE
MAXOPTI := AGGRESSIVE
e n d i f
i f n d e f O P T I
OPTI := DEFENSIVE
MAXOPTI := DEFENSIVE
e n d i f
i f e q "$(PORTABLE)" "FALSE"
PORTABLE_SWITCH = -msse3
e n d i f
# settings for multicore support
i f e q "$(OPENMP)" "ON"
OPENMP_FLAG_ifort = -openmp -openmp-report0 -parallel
OPENMP_FLAG_gfortran = -fopenmp
ACML_ARCH = _mp
LIBRARIES += -lfftw3_threads -lpthread
e n d i f
LIBRARIES += -lfftw3
2012-07-03 18:06:54 +05:30
LIB_DIRS += -L$( FFTWROOT) /lib
i f d e f I M K L R O O T
LIB_DIRS += -L$( IMKLROOT) /lib/intel64
2012-03-02 01:04:42 +05:30
LIBRARIES += -mkl
e l s e
i f d e f A C M L R O O T
2012-07-03 18:06:54 +05:30
LIB_DIRS += -L$( ACMLROOT) /$( F90) 64$( ACML_ARCH) /lib
2012-03-02 01:04:42 +05:30
LIBRARIES += -lacml$( ACML_ARCH)
e l s e
i f d e f L A P A C K R O O T
2012-07-03 18:06:54 +05:30
LIB_DIRS += -L$( LAPACKROOT) /lib64 -L$( LAPACKROOT) /lib
2012-07-03 19:29:38 +05:30
LIBRARIES += -llapack
e n d i f
e n d i f
2012-03-02 01:04:42 +05:30
e n d i f
2012-11-08 23:56:10 +05:30
i f e q "$(SOLVER)" "NEW"
i f d e f P E T S C _ D I R
i n c l u d e $ { P E T S C _ D I R } / c o n f / v a r i a b l e s
INCLUDE_DIRS += ${ PETSC_FC_INCLUDES } -DPETSc
LIBRARIES += ${ PETSC_WITH_EXTERNAL_LIB }
e n d i f
e n d i f
2012-03-02 01:04:42 +05:30
i f d e f S T A N D A R D _ C H E C K
2012-06-15 21:40:21 +05:30
STANDARD_CHECK_ifort = $( STANDARD_CHECK)
STANDARD_CHECK_gfortran = $( STANDARD_CHECK)
2012-03-02 01:04:42 +05:30
e n d i f
i f n e q "$(FASTBUILD)" "YES"
2012-06-15 21:40:21 +05:30
STANDARD_CHECK_ifort ?= -stand f08 -standard-semantics -warn stderrors
STANDARD_CHECK_gfortran ?= -std= f2008 -fall-intrinsics
2012-10-19 14:14:21 +05:30
#-std=2008ts for newer gfortran
2012-03-02 01:04:42 +05:30
e n d i f
2012-05-04 13:49:12 +05:30
#-fall-intrinsics: all intrinsic procedures (including the GNU-specific extensions) are accepted. This can be useful with -std=f95 to force standard-compliance
# but get access to the full range of intrinsics available with gfortran. As a consequence, -Wintrinsics-std will be ignored and no user-defined
# procedure with the same name as any intrinsic will be called except when it is explicitly declared external
#-Wintrinsics-std: warnings because of "flush" is not longer in the standard, but still an intrinsic fuction of the compilers
2012-03-02 01:04:42 +05:30
OPTIMIZATION_OFF_ifort := -O0 -no-ip
OPTIMIZATION_OFF_gfortran := -O0
OPTIMIZATION_DEFENSIVE_ifort := -O2
OPTIMIZATION_DEFENSIVE_gfortran := -O2
2012-06-13 22:49:16 +05:30
OPTIMIZATION_AGGRESSIVE_ifort := -O3 $( PORTABLE_SWITCH) -no-prec-div -fp-model fast = 2 -ipo #-static causes trouble at the moment
2012-03-02 01:04:42 +05:30
OPTIMIZATION_AGGRESSIVE_gfortran := -O3 $( PORTABLE_SWITCH) -ffast-math -funroll-loops -ftree-vectorize
2012-03-20 17:56:21 +05:30
2012-03-02 01:04:42 +05:30
COMPILE_OPTIONS_ifort := -fpp\
2012-10-19 14:14:21 +05:30
-ftz\
2012-03-20 17:56:21 +05:30
-assume byterecl
i f n e q "$(FASTBUILD)" "YES"
COMPILE_OPTIONS_ifort := $( COMPILE_OPTIONS_ifort) \
2012-03-02 01:04:42 +05:30
-implicitnone\
-diag-enable sc3\
-diag-disable 5268\
-warn declarations\
-warn general\
-warn usage\
-warn interfaces\
-warn ignore_loc\
-warn alignments\
-warn unused\
2012-03-06 20:22:48 +05:30
-warn errors
2012-03-02 01:04:42 +05:30
e n d i f
#-fpp: preprocessor
2012-10-19 14:14:21 +05:30
#-ftz: flush unterflow to zero, automatically set if O<0,1,2,3> >0
2012-03-02 01:04:42 +05:30
#-fimplicit-none: assume "implicit-none" even if not present in source
#-diag-disable: disables warnings, where
# warning ID 5268: the text exceeds right hand column allowed on the line (we have only comments there)
#-warn: enables warnings, where
# declarations: any undeclared names
# general: warning messages and informational messages are issued by the compiler
# usage: questionable programming practices
# interfaces: checks the interfaces of all SUBROUTINEs called and FUNCTIONs invoked in your compilation against an external set of interface blocks
# ignore_loc: %LOC is stripped from an actual argument
# alignments: data that is not naturally aligned
# unused: declared variables that are never used
# errors: warnings are changed to errors
2012-03-06 20:22:48 +05:30
# stderrors: warnings about Fortran standard violations are changed to errors (STANDARD_CHECK)
2012-03-02 01:04:42 +05:30
#
###################################################################################################
#MORE OPTIONS FOR DEBUGGING DURING COMPILING
#-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:
#
#OPTIONS FOR DEGUBBING DURING RUNTIME
# information on http://software.intel.com/en-us/articles/determining-root-cause-of-sigsegv-or-sigbus-errors/
#-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.
#-gen-interfaces: Generate an interface block for each routine. http://software.intel.com/en-us/blogs/2012/01/05/doctor-fortran-gets-explicit-again/
#-fp-stack-check: Generate extra code after every function call to ensure that the floating-point (FP) stack is in the expected state.
#-check: checks at runtime, where
# bounds: check if an array index is too small (<1) or too large!
# arg_temp_created: will cause a lot of warnings because we create a bunch of temporary arrays
# format: Checking for the data type of an item being formatted for output.
# output_conversion: Checking for the fit of data items within a designated format descriptor field.
# pointers: Checking for certain disassociated or uninitialized pointers or unallocated allocatable objects.
# uninit: Checking for uninitialized variables.
#-heap-arrays: should not be done for OpenMP, but set "ulimit -s unlimited" on shell. Probably it helps also to unlimit other limits
2012-10-19 14:14:21 +05:30
#-fpe-all0 capture all floating-point exceptions, sets -ftz automatically
2012-03-02 01:04:42 +05:30
###################################################################################################
2012-05-11 18:16:17 +05:30
COMPILE_OPTIONS_gfortran := -xf95-cpp-input
2012-03-20 17:56:21 +05:30
i f n e q "$(FASTBUILD)" "YES"
COMPILE_OPTIONS_gfortran := $( COMPILE_OPTIONS_gfortran) \
2012-03-02 01:04:42 +05:30
-ffree-line-length-132\
-fimplicit-none\
-pedantic\
-Warray-bounds\
-Wampersand\
-Wno-tabs\
-Wcharacter-truncation\
-Wintrinsic-shadow\
-Waliasing\
-Wconversion\
-Wsurprising\
-Wunderflow\
-Wswitch\
-Wstrict-overflow\
-Wattributes\
-Wunsafe-loop-optimizations\
-Wunused\
-Wall\
2012-05-04 13:49:12 +05:30
-Wextra
2012-03-02 01:04:42 +05:30
e n d i f
#-xf95-cpp-input: preprocessor
#-ffree-line-length-132: restrict line length to the standard 132 characters
#-fno-range-check: disables checking if result can be represented by variable. Needs to be set to enable DAMASK_NaN
#-fimplicit-none: assume "implicit-none" even if not present in source
#-pedantic: more strict on standard, enables some of the warnings below
#-Warray-bounds: checks if array reference is out of bounds at compile time. use -fcheck-bounds to also check during runtime
#-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
#-Wno-tabs: do not allow tabs in source
#-Wcharacter-truncation: warn if character expressions (strings) are truncated
#-Wintrinsic-shadow: warn if a user-defined procedure or module procedure has the same name as an intrinsic
#-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.
#-Wconversion: warn about implicit conversions between different type
#-Wsurprising: warn when "suspicious" code constructs are encountered. While technically legal these usually indicate that an error has been made.
#-Wunderflow: produce a warning when numerical constant expressions are encountered, which yield an UNDERFLOW during compilation
#-Wswitch: warn whenever a "switch" statement has an index of enumerated type and lacks a "case" for one or more of the named codes of that enumeration. (The presence of a "default" label prevents this warning.) "case" labels outside the enumeration range also provokewarnings when this option is used (even if there is a "default" label)
#-Wstrict-overflow:
#-Wattributes: warn about inappropriate attribute usage
#-Wunsafe-loop-optimizations: warn if the loop cannot be optimized due to nontrivial assumptions.
#-Wunused:
# -value:
# -parameter: find usused variables with "parameter" attribute
2012-05-03 22:42:36 +05:30
#-Wextra:
2012-03-02 01:04:42 +05:30
###################################################################################################
#OPTIONS FOR GFORTRAN 4.6
#-Wsuggest-attribute=const:
#-Wsuggest-attribute=noreturn:
#-Wsuggest-attribute=pure:
#-Wreal-q-constant: Warn about real-literal-constants with 'q' exponent-letter
2012-03-06 20:22:48 +05:30
#
2012-03-02 01:04:42 +05:30
#MORE OPTIONS FOR DEBUGGING DURING COMPILING
#-Wline-truncation: too many warnings because we have comments beyond character 132
2012-03-06 20:22:48 +05:30
#-Warray-temporarieswarnings: because we have many temporary arrays (performance issue?):
#-Wimplicit-interface:
#-pedantic-errors:
#-fmodule-private:
2012-03-02 01:04:42 +05:30
#
#OPTIONS FOR DEGUBBING DURING RUNTIME
#-fcheck-bounds: check if an array index is too small (<1) or too large!
2012-10-19 14:14:21 +05:30
#-ffpe-trap=invalid,\ stop execution if floating point exception is detected (NaN is silent)
# zero,\
# overflow,\
# underflow,\
# precision,\
# denormal
2012-08-28 21:38:17 +05:30
##################################################################################################
PRECISION_ifort := -real-size 64 -integer-size 32 -DFLOAT= 8 -DINT= 4
2012-11-08 23:56:10 +05:30
#-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)
2012-08-29 10:49:35 +05:30
PRECISION_gfortran := -fdefault-real-8 -fdefault-double-8 -DFLOAT= 8 -DINT= 4
2012-11-08 23:56:10 +05:30
#-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)
2012-03-02 01:04:42 +05:30
2012-08-28 21:38:17 +05:30
###################################################################################################
COMPILE = $( OPENMP_FLAG_$( F90) ) $( COMPILE_OPTIONS_$( F90) ) $( STANDARD_CHECK_$( F90) ) $( OPTIMIZATION_$( OPTI) _$( F90) ) $( INCLUDE_DIRS) $( PRECISION_$( F90) ) -DSpectral
COMPILE_MAXOPTI = $( OPENMP_FLAG_$( F90) ) $( COMPILE_OPTIONS_$( F90) ) $( STANDARD_CHECK_$( F90) ) $( OPTIMIZATION_$( MAXOPTI) _$( F90) ) $( INCLUDE_DIRS) $( PRECISION_$( F90) ) -DSpectral
2012-03-02 01:04:42 +05:30
###################################################################################################
COMPILED_FILES = prec.o DAMASK_spectral_interface.o IO.o numerics.o debug.o math.o \
FEsolving.o mesh.o material.o lattice.o \
constitutive_dislotwin.o constitutive_j2.o constitutive_phenopowerlaw.o \
2012-08-06 18:13:05 +05:30
constitutive_titanmod.o constitutive_nonlocal.o constitutive_none.o constitutive.o crystallite.o \
homogenization_RGC.o homogenization_isostrain.o homogenization.o CPFEM.o
2012-03-21 23:31:25 +05:30
2012-08-29 00:49:47 +05:30
2012-08-06 18:13:05 +05:30
i f e q "$(SOLVER)" "NEW"
2012-08-29 00:49:47 +05:30
i f d e f P E T S C _ D I R
2012-10-19 14:14:21 +05:30
PETSC_FILES = DAMASK_spectral_solverAL.o DAMASK_spectral_solverBasicPETSc.o
2012-08-29 00:49:47 +05:30
e n d i f
2012-10-19 14:14:21 +05:30
COMPILED_FILES += DAMASK_spectral_utilities.o DAMASK_spectral_solverBasic.o $( PETSC_FILES)
2012-08-06 18:13:05 +05:30
2012-10-19 14:14:21 +05:30
DAMASK_spectral.exe : DAMASK_spectral_driver .o
2012-03-06 20:22:48 +05:30
$( PREFIX) $( COMPILERNAME) $( OPENMP_FLAG_$( F90) ) $( OPTIMIZATION_$( MAXOPTI) _$( F90) ) $( STANDARD_CHECK_$( F90) ) \
2012-10-19 14:14:21 +05:30
-o DAMASK_spectral.exe DAMASK_spectral_driver.o \
2012-03-02 01:04:42 +05:30
$( COMPILED_FILES) $( LIB_DIRS) $( LIBRARIES) $( SUFFIX)
2012-10-19 14:14:21 +05:30
DAMASK_spectral_driver.o : DAMASK_spectral_driver .f 90 DAMASK_spectral_solverBasic .o $( PETSC_FILES )
$( PREFIX) $( COMPILERNAME) $( COMPILE_MAXOPTI) -c DAMASK_spectral_driver.f90 $( SUFFIX)
2012-08-06 18:13:05 +05:30
2012-10-19 14:14:21 +05:30
DAMASK_spectral_solverAL.o : DAMASK_spectral_solverAL .f 90\
DAMASK_spectral_utilities.o
2012-08-06 18:13:05 +05:30
2012-10-19 14:14:21 +05:30
DAMASK_spectral_solverBasic.o : DAMASK_spectral_solverBasic .f 90\
DAMASK_spectral_utilities.o
2012-08-14 22:28:23 +05:30
2012-10-19 14:14:21 +05:30
DAMASK_spectral_solverBasicPETSc.o : DAMASK_spectral_solverBasicPETSc .f 90\
DAMASK_spectral_utilities.o
2012-08-06 18:13:05 +05:30
2012-10-19 14:14:21 +05:30
DAMASK_spectral_utilities.o : DAMASK_spectral_utilities .f 90\
2012-08-06 18:13:05 +05:30
CPFEM.o
2012-03-21 23:31:25 +05:30
e l s e
2012-08-06 18:13:05 +05:30
DAMASK_spectral.exe : DAMASK_spectral .o
2012-03-21 23:31:25 +05:30
$( PREFIX) $( COMPILERNAME) $( OPENMP_FLAG_$( F90) ) $( OPTIMIZATION_$( MAXOPTI) _$( F90) ) $( STANDARD_CHECK_$( F90) ) \
2012-08-06 18:13:05 +05:30
-o DAMASK_spectral.exe DAMASK_spectral.o \
2012-03-21 23:31:25 +05:30
$( COMPILED_FILES) $( LIB_DIRS) $( LIBRARIES) $( SUFFIX)
2012-03-02 01:04:42 +05:30
2012-08-06 18:13:05 +05:30
DAMASK_spectral.o : DAMASK_spectral .f 90 CPFEM .o
$( PREFIX) $( COMPILERNAME) $( COMPILE_MAXOPTI) -c DAMASK_spectral.f90 $( SUFFIX)
e n d i f
2012-03-02 01:04:42 +05:30
CPFEM.o : CPFEM .f 90\
homogenization.o
homogenization.o : homogenization .f 90\
homogenization_RGC.o \
homogenization_isostrain.o
homogenization_RGC.o : homogenization_RGC .f 90 \
crystallite.o
homogenization_isostrain.o : homogenization_isostrain .f 90 \
crystallite.o
crystallite.o : crystallite .f 90 \
constitutive.o
constitutive.o : constitutive .f 90 \
constitutive_nonlocal.o \
constitutive_titanmod.o \
constitutive_dislotwin.o \
constitutive_phenopowerlaw.o \
2012-07-03 19:29:38 +05:30
constitutive_j2.o \
constitutive_none.o
2012-03-02 01:04:42 +05:30
constitutive_nonlocal.o : constitutive_nonlocal .f 90 \
lattice.o
constitutive_titanmod.o : constitutive_titanmod .f 90 \
lattice.o
constitutive_dislotwin.o : constitutive_dislotwin .f 90 \
lattice.o
constitutive_phenopowerlaw.o : constitutive_phenopowerlaw .f 90 \
lattice.o
constitutive_j2.o : constitutive_j 2.f 90 \
lattice.o
2012-07-03 19:29:38 +05:30
constitutive_none.o : constitutive_none .f 90 \
lattice.o
2012-03-02 01:04:42 +05:30
lattice.o : lattice .f 90 \
material.o
material.o : material .f 90 \
mesh.o
mesh.o : mesh .f 90 \
FEsolving.o \
math.o
FEsolving.o : FEsolving .f 90 \
debug.o
math.o : math .f 90 \
debug.o
debug.o : debug .f 90 \
numerics.o
numerics.o : numerics .f 90 \
IO.o
IO.o : IO .f 90 \
DAMASK_spectral_interface.o
DAMASK_spectral_interface.o : DAMASK_spectral_interface .f 90 \
prec.o
2012-11-28 19:24:02 +05:30
i f e q "$(F90)" "gfortran" # fno-range-check because NaN is defined in prec
2012-05-11 18:16:17 +05:30
prec.o : prec .f 90
$( PREFIX) $( COMPILERNAME) $( COMPILE) -c -fno-range-check prec.f90 $( SUFFIX)
e l s e
2012-03-02 01:04:42 +05:30
prec.o : prec .f 90
2012-05-11 18:16:17 +05:30
$( PREFIX) $( COMPILERNAME) $( COMPILE) -c prec.f90 $( SUFFIX)
e n d i f
2012-03-02 01:04:42 +05:30
%.o : %.f 90
2012-03-20 23:31:31 +05:30
$( PREFIX) $( COMPILERNAME) $( COMPILE) -c $< $( SUFFIX)
2012-03-02 01:04:42 +05:30
tidy :
2012-05-23 23:38:34 +05:30
@rm -rf *.o
@rm -rf *.mod
2012-03-02 01:04:42 +05:30
clean :
2012-05-23 23:38:34 +05:30
@rm -rf *.o
@rm -rf *.mod
@rm -rf *.exe