From ee99216edc472a70c4673408b34ef552e16cd22f Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 28 Jan 2014 07:34:13 +0000 Subject: [PATCH] polishing compile_CoreModule, bug fix for Makefile --- code/Makefile | 14 +++++++------- installation/compile_CoreModule.py | 29 +++++++++++++++++------------ processing/post/3Dvisualize.py | 2 ++ processing/post/addCauchyX.py | 10 +++++----- 4 files changed, 31 insertions(+), 24 deletions(-) diff --git a/code/Makefile b/code/Makefile index 2efc0f967..1be14c568 100644 --- a/code/Makefile +++ b/code/Makefile @@ -46,7 +46,7 @@ COMPILERNAME ?= $(F90) INCLUDE_DIRS :=-I../lib LIBRARIES :=-lfftw3 LIB_DIRS :=-L$(FFTW_ROOT)/lib -RUN_PATH :=-Wl,-rpath,$(FFTW_ROOT)/lib +RUN_PATH :=-Wl,-rpath=$(FFTW_ROOT)/lib ifeq "$(FASTBUILD)" "YES" OPENMP := OFF @@ -95,18 +95,18 @@ endif ifneq "x$(IMKL_ROOT)" "x" LIB_DIRS :=-L$(IMKL_ROOT)/lib/intel64 -RUN_PATH +=$(RUNPATH) -Wl,-rpath,$(IMKL_ROOT)/lib/intel64 +RUN_PATH +=$(RUNPATH) -Wl,-rpath=$(IMKL_ROOT)/lib/intel64 INCLUDE_DIRS +=-I$(IMKL_ROOT)/include -LIBRARIES +=-lmkl_intel_lp64 -lmkl_core -lmkl$(ACML_ARCH) -lm -lpthread -liomp5 +LIBRARIES +=-lmkl_intel_lp64 -lmkl_core -lmkl$(IMKL_ARCH) -lm -lpthread -liomp5 else ifneq "x$(ACML_ROOT)" "x" LIB_DIRS +=-L$(ACML_ROOT)/$(F90)64$(ACML_ARCH)/lib -RUN_PATH +=$(RUNPATH) -Wl,-rpath,$(ACML_ROOT)/$(F90)64$(ACML_ARCH)/lib +RUN_PATH +=$(RUNPATH) -Wl,-rpath=$(ACML_ROOT)/$(F90)64$(ACML_ARCH)/lib LIBRARIES +=-lacml$(ACML_ARCH) else ifneq "x$(LAPACK_ROOT)" "x" LIB_DIRS +=-L$(LAPACK_ROOT)/lib64 -L$(LAPACK_ROOT)/lib -RUN_PATH +=$(RUN_PATH) -Wl,-rpath,$(LAPACK_ROOT)/lib64 -Wl,-rpath,$(LAPACK_ROOT)/lib +RUN_PATH +=$(RUN_PATH) -Wl,-rpath=$(LAPACK_ROOT)/lib64 -Wl,-rpath=$(LAPACK_ROOT)/lib LIBRARIES +=-llapack endif endif @@ -116,7 +116,7 @@ endif ifeq "$(HDF5)" "ON" LIBRARIES +=-lhdf5hl_fortran -lhdf5_hl -lhdf5_fortran -lhdf5 LIB_DIRS +=-L$(HDF5_ROOT)/lib -RUN_PATH +=$(RUNPATH) -Wl,-rpath,$(HDF5_ROOT)/lib +RUN_PATH +=$(RUNPATH) -Wl,-rpath=$(HDF5_ROOT)/lib INCLUDE_DIRS +=-I$(HDF5_ROOT)/include -DHDF endif @@ -142,7 +142,7 @@ OPTIMIZATION_OFF_ifort :=-O0 -no-ip OPTIMIZATION_OFF_gfortran :=-O0 OPTIMIZATION_DEFENSIVE_ifort :=-O2 OPTIMIZATION_DEFENSIVE_gfortran :=-O2 -OPTIMIZATION_AGGRESSIVE_ifort :=-O3 $(PORTABLE_SWITCH) -no-prec-div -fp-model fast=2 -ipo #-static causes trouble at the moment +OPTIMIZATION_AGGRESSIVE_ifort :=-O3 $(PORTABLE_SWITCH) -no-prec-div -fp-model fast=2 -ipo OPTIMIZATION_AGGRESSIVE_gfortran :=-O3 $(PORTABLE_SWITCH) -ffast-math -funroll-loops -ftree-vectorize diff --git a/installation/compile_CoreModule.py b/installation/compile_CoreModule.py index d09c7b28b..cc19b521d 100755 --- a/installation/compile_CoreModule.py +++ b/installation/compile_CoreModule.py @@ -1,18 +1,20 @@ #!/usr/bin/env python - -# compiles fortran code for Python +# -*- coding: UTF-8 no BOM -*- import os,sys,glob,string,subprocess,shlex from damask import Environment +# compiles fortran code for Python +scriptID = '$Id$' + damaskEnv = Environment() baseDir = damaskEnv.relPath('installation/') codeDir = damaskEnv.relPath('code/') -options={} keywords=['IMKL_ROOT','ACML_ROOT','LAPACK_ROOT','FFTW_ROOT','F90'] +options={} -# getting options from damask.conf or, if not present, from envinronment +#--- getting options from damask.conf or, if not present, from envinronment ----------------------- for option in keywords: try: value = damaskEnv.options[option] @@ -21,12 +23,13 @@ for option in keywords: if value is None: value = '' # env not set options[option]=value -# overwrite default options with keyword=value pair from argument list to mimic make behavior +#--- overwrite default options with keyword=value pair from argument list to mimic make behavior -- for i, arg in enumerate(sys.argv): for option in keywords: if arg.startswith(option): options[option] = sys.argv[i][len(option)+1:] +#--- check for valid compiler and set options ----------------------------------------------------- compilers = ['ifort','gfortran'] if options['F90'] not in compilers: sys.exit('compiler "F90" (in installation/options or as Shell variable) has to be one out of: %s'%(', '.join(compilers))) @@ -38,11 +41,11 @@ compiler = { ' -real-size 64 -integer-size 32"', }[options['F90']] -# option not depending on compiler +#--- option not depending on compiler ------------------------------------------------------------- compileOptions =' -DSpectral -DFLOAT=8 -DINT=4 -I%s/lib'%damaskEnv.rootDir() -# this saves the path of libraries during runtime -LDFLAGS ='-shared -Wl,-rpath=/lib -Wl,-rpath=/usr/lib -Wl,-rpath=%s/lib'%(options['FFTW_ROOT']) +#--- this saves the path of libraries to core.so, hence it is known during runtime ---------------- +LDFLAGS ='-shared -Wl,-rpath=%s/lib'%(options['FFTW_ROOT']) # see http://cens.ioc.ee/pipermail/f2py-users/2003-December/000621.html if options['IMKL_ROOT'] != '' and options['F90'] != 'gfortran': @@ -55,15 +58,16 @@ elif options['LAPACK_ROOT'] != '': lib_lapack = '-L%s/lib -L%s/lib64 -llapack'%(options['LAPACK_ROOT'],options['LAPACK_ROOT']) LDFLAGS +=' -Wl,-rpath=%s/lib -Wl,-rpath=%s/lib64'%(options['LAPACK_ROOT'],options['LAPACK_ROOT']) +#-------------------------------------------------------------------------------------------------- # f2py does not (yet) support setting of special flags for the linker, hence they must be set via -# environment variable +# environment variable ---------------------------------------------------------------------------- my_env = os.environ my_env["LDFLAGS"] = LDFLAGS -os.chdir(codeDir) # needed for compilation with gfortran and f2py +#--- delete old file ------------------------------------------------------------------------------ try: os.remove(os.path.join(damaskEnv.relPath('lib/damask'),'core.so')) -except OSError, e: ## if failed, report it back to the user ## +except OSError, e: print ("Error when deleting: %s - %s." % (e.filename,e.strerror)) @@ -76,6 +80,7 @@ except OSError, e: #'f2py -h damask.core.pyf' +\ #' --overwrite-signature --no-lower prec.f90 DAMASK_spectral_interface.f90 math.f90 mesh.f90,...' ########################################################################### +os.chdir(codeDir) cmd = 'f2py damask.core.pyf' +\ ' -c --no-lower %s'%(compiler) +\ compileOptions+\ @@ -111,7 +116,7 @@ for module in modules: print 'removing', module os.remove(module) -#check if compilation of core module was successful +#--- check if compilation of core module was successful ------------------------------------------- try: with open(damaskEnv.relPath('lib/damask/core.so')) as f: pass except IOError as e: diff --git a/processing/post/3Dvisualize.py b/processing/post/3Dvisualize.py index bd24d454c..947e95ae9 100755 --- a/processing/post/3Dvisualize.py +++ b/processing/post/3Dvisualize.py @@ -544,6 +544,8 @@ for filename in args: 'quadruple': 4,\ } + structure = vtk.vtkIntArray() + structure.SetName('Microstructures') for datatype in fields.keys(): print '\n%s:'%datatype, fields[datatype]['_order_'] = [] diff --git a/processing/post/addCauchyX.py b/processing/post/addCauchyX.py index 795f3feaf..06e16bc1c 100755 --- a/processing/post/addCauchyX.py +++ b/processing/post/addCauchyX.py @@ -68,15 +68,15 @@ for myFile in files: # ------------------------------------------ loop over increments ------------------------------------- for inc in myFile['file']['increments'].keys(): print("Current Increment: "+inc) - for instance in myFile['file']['increments/'+inc].keys(): - dsets = myFile['file']['increments/'+inc].keys() + for instance in myFile['file']['increments/'+inc+'/'+options.output].keys(): + dsets = myFile['file']['increments/'+inc+'/'+options.output+'/'+instance].keys() if (options.defgrad in dsets and options.stress in dsets): - defgrad = myFile['file']['increments/'+inc+'/'+options.defgrad] - stress = myFile['file']['increments/'+inc+'/'+options.stress] + defgrad = myFile['file']['increments/'+inc+'/'+options.output+'/'+instance+'/'+options.defgrad] + stress = myFile['file']['increments/'+inc+'/'+options.output+'/'+instance+'/'+options.stress] cauchy=np.zeros(np.shape(stress),'f') for p in range(stress.shape[0]): cauchy[p,...] = 1.0/np.linalg.det(defgrad[p,...])*np.dot(stress[p,...],defgrad[p,...].T) # [Cauchy] = (1/det(F)) * [P].[F_transpose] - cauchyFile = myFile['file']['increments/'+inc].create_dataset('cauchy', data=cauchy) + cauchyFile = myFile['file']['increments/'+inc+'/'+options.output+'/'+instance].create_dataset('cauchy', data=cauchy) cauchyFile.attrs['units'] = 'Pa'