fixed DAMASK_env.sh to work with linux and Mac, started to reorganize installation to be consistent for all solvers

This commit is contained in:
Martin Diehl 2014-01-11 12:46:30 +00:00
parent 2ba3c11879
commit e025ac5952
6 changed files with 336 additions and 6 deletions

View File

@ -1,9 +1,32 @@
# sets up an environment for DAMASK on bash # sets up an environment for DAMASK on bash
# usage: source DAMASK_env.sh # usage: source DAMASK_env.sh
STAT=$(stat "`dirname $BASH_SOURCE`") FFTWROOT=/usr/local
LOCATION=${STAT##* } LAPACKROOT=/usr
ACMLROOT=
IMKLROOT=
if [ "$OSTYPE" == "linux-gnu" ]
then LOCATION=$(readlink -f "`dirname $BASH_SOURCE`")
else
STAT=$(stat "`dirname $BASH_SOURCE`")
LOCATION=${STAT##* }
fi
export DAMASK_ROOT=${LOCATION} export DAMASK_ROOT=${LOCATION}
export DAMASK_NUM_THREADS=2 export DAMASK_NUM_THREADS=2
export FFTWROOT=${FFTWROOT}
LD_NEW=$FFTWROOT/lib
if [ "x$LAPACKROOT" != "x" ]
then export LAPACKROOT=$LAPACKROOT
LD_NEW=$LD_NEW:$LAPACKROOT/lib:$LAPACKROOT/lib64
fi
if [ "x$ACMLROOT" != "x" ]
then export ACMLROOT=$ACMLROOT
LD_NEW=$LD_NEW:$ACMLROOT/ifort64_mp/lib:$ACMLROOT/ifort64/lib:$ACMLROOT/gfortran64_mp/lib:$ACMLROOT/gfortran64/lib
fi
if [ "x$IMKLROOT" != "x" ]
then export IMKLROOT=${IMKLROOT}
fi
# disable output in case of scp # disable output in case of scp
if [ ! -z "$PS1" ]; then if [ ! -z "$PS1" ]; then
echo echo
@ -14,12 +37,13 @@ if [ ! -z "$PS1" ]; then
echo Preparing environment ... echo Preparing environment ...
echo "DAMASK_ROOT=$DAMASK_ROOT" echo "DAMASK_ROOT=$DAMASK_ROOT"
echo "DAMASK_NUM_THREADS=$DAMASK_NUM_THREADS" echo "DAMASK_NUM_THREADS=$DAMASK_NUM_THREADS"
echo "prepending to LD_LIBRARY_PATH: $LD_NEW"
fi fi
ulimit -s unlimited ulimit -s unlimited
ulimit -c 0 ulimit -c 0
ulimit -v unlimited ulimit -v unlimited
ulimit -m unlimited ulimit -m unlimited
export DAMASK_BIN=${DAMASK_ROOT}/bin export DAMASK_BIN=$DAMASK_ROOT/bin
export PATH=${PATH}:${DAMASK_BIN} export PATH=$PATH:$DAMASK_BIN
export PYTHONPATH=${PYTHONPATH}:${DAMASK_ROOT}/lib export PYTHONPATH=$PYTHONPATH:$DAMASK_ROOT/lib
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH} export LD_LIBRARY_PATH=$LD_NEW:$LD_LIBRARY_PATH

31
Makefile Normal file
View File

@ -0,0 +1,31 @@
SHELL = /bin/sh
########################################################################################
# Makefile for the installation of DAMASK
########################################################################################
.PHONY : spectral
spectral:
@$(MAKE) clean -C code >/dev/null
$(MAKE) -C code
.PHONY : marc
marc:
@./installation/mods_Marc/apply_DAMASK_modifcation.py
.PHONY : processing
processing:
@$(MAKE) tidy -C code >/dev/null
@./installation/compile_CoreModule.py
.PHONY : tidy
tidy:
@$(MAKE) tidy -C code >/dev/null
.PHONY : clean
clean:
@$(MAKE) clean -C code >/dev/null
.PHONY : install
install:
@./installation/symlink_Code.py
@./installation/symlink_Processing.py

18
configure vendored Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env python
import os,re,subprocess,sys
import damask
damaskEnv = damask.Environment() # script location relative to root
baseDir = damaskEnv.relPath('code/')
# basic idea: try to get the specific locations from:
# 1) command line option
# 2) envinronment variable
# 3) for F90: autodetect
# then call the respective scripts with their options
# changing dirs and compiler in makefile
compiler ={True:'ifort',False:'gfortran'}[\
subprocess.call(['which', 'ifort'],\
stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0]

View File

@ -0,0 +1,126 @@
#!/usr/bin/env python
# Makes postprocessing routines acessible from everywhere.
import os,sys,glob,string,subprocess
from damask import Environment
from optparse import OptionParser, Option
# -----------------------------
class extendableOption(Option):
# -----------------------------
# used for definition of new option parser action 'extend', which enables to take multiple option arguments
# taken from online tutorial http://docs.python.org/library/optparse.html
ACTIONS = Option.ACTIONS + ("extend",)
STORE_ACTIONS = Option.STORE_ACTIONS + ("extend",)
TYPED_ACTIONS = Option.TYPED_ACTIONS + ("extend",)
ALWAYS_TYPED_ACTIONS = Option.ALWAYS_TYPED_ACTIONS + ("extend",)
def take_action(self, action, dest, opt, value, values, parser):
if action == "extend":
lvalue = value.split(",")
values.ensure_value(dest, []).extend(lvalue)
else:
Option.take_action(self, action, dest, opt, value, values, parser)
########################################################
# MAIN
########################################################
parser = OptionParser(option_class=extendableOption, usage='%prog options', description = """
Sets up the pre and post processing tools of DAMASK
""" + string.replace('$Id$','\n','\\n')
)
compilers = ['ifort','gfortran']
parser.add_option('F90', dest='compiler', type='string', \
help='name of F90 [%default]')
parser.add_option('LAPACKROOT', dest='lapackroot', type='string', \
help='name of F90 [%default]')
parser.add_option('ACMLROOT', dest='acmlroot', type='string', \
help='name of F90 [%default]')
parser.add_option('IMKLROOT', dest='imklroot', type='string', \
help='name of F90 [%default]')
parser.add_option('FFTWROOT', dest='fftwroot', type='string', \
help='name of F90 [%default]')
(options,filenames) = parser.parse_args()
if options.compiler not in compilers:
parser.error('compiler switch "F90" has to be one out of: %s'%(', '.join(compilers)))
f2py_compiler = {
'gfortran': 'gnu95 --f90flags="-fPIC -fno-range-check -xf95-cpp-input -std=f2008 -fall-intrinsics -DSpectral -fdefault-real-8 -fdefault-double-8 -DFLOAT=8 -DINT=4 -I${DAMASK_ROOT}/lib"',
'ifort': 'intelem --f90flags="-fPIC -fpp -stand f08 -diag-disable 5268 -assume byterecl -DSpectral -real-size 64 -integer-size 32 -DFLOAT=8 -DINT=4 -I${DAMASK_ROOT}/lib"',
}[options.compiler]
damaskEnv = Environment()
baseDir = damaskEnv.relPath('installation/')
codeDir = damaskEnv.relPath('code/')
if options.imklroot= '' and options.compiler != 'gfortran':
lib_lapack = '-L%s/lib/intel64 -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -liomp5 -lpthread -lm'%(options.imklroot)
elif options.acmlroot= '':
lib_lapack = '-L%s/%s64/lib -lacml'%(options.acmlroot,compiler)
elif options.lapackroot != '':
lib_lapack = '-L%s -llapack'%(options.lapack) # see http://cens.ioc.ee/pipermail/f2py-users/2003-December/000621.html
execute = { \
'coreModule' : [
'make tidy',
# The following command is used to compile the fortran files and make the functions defined
# in damask.core.pyf available for python in the module core.so
# It uses the fortran wrapper f2py that is included in the numpy package to construct the
# module core.so out of the fortran code in the f90 files
# For the generation of the pyf file use the following lines:
###########################################################################
#'f2py -h damask.core.pyf' +\
#' --overwrite-signature --no-lower prec.f90 DAMASK_spectral_interface.f90 math.f90 mesh.f90',
###########################################################################
'rm `readlink -f %s`' %(os.path.join(damaskEnv.relPath('lib/damask'),'core.so')),
'f2py damask.core.pyf' +\
' --build-dir ./' +\
' -c --no-lower --fcompiler=%s'%(f2py_compiler) +\
' %s'%'prec.f90'+\
' %s'%'DAMASK_spectral_interface.f90'+\
' %s'%'IO.f90'+\
' %s'%'libs.f90'+\
' %s'%'numerics.f90'+\
' %s'%'debug.f90'+\
' %s'%'math.f90'+\
' %s'%'FEsolving.f90'+\
' %s'%'mesh.f90'+\
' %s'%'core_quit.f90'+\
' -L%s/lib -lfftw3'%(options.fftwroot)+\
' %s'%lib_lapack,
'mv %s `readlink -f %s`' %(os.path.join(codeDir,'core.so'),os.path.join(damaskEnv.relPath('lib/damask'),'core.so')),
]
}
os.chdir(codeDir) # needed for compilation with gfortran and f2py
for tasks in execute:
for cmd in execute[tasks]:
try:
print 'executing...:',cmd
os.system(cmd)
except:
print 'failed..!'
pass
modules = glob.glob('*.mod')
for module in modules:
print 'removing', module
os.remove(module)
#check if compilation of core module was successful
try:
with open(damaskEnv.relPath('lib/damask/core.so')) as f: pass
except IOError as e:
print '*********\n* core.so not found, compilation of core modules was not successful\n*********'
sys.exit()
f.close

34
installation/symlink_Code.py Executable file
View File

@ -0,0 +1,34 @@
#!/usr/bin/env python
import os
import damask
bin_link = { \
'.' : [
'DAMASK_spectral.exe',
],
}
MarcReleases =[2011,2012,2013,2013.1]
damaskEnv = damask.Environment('../../') # script location relative to root
baseDir = damaskEnv.relPath('code/')
for dir in bin_link:
for file in bin_link[dir]:
src = os.path.abspath(os.path.join(baseDir,dir,file))
if os.path.exists(src):
sym_link = os.path.abspath(os.path.join(damaskEnv.binDir(),\
{True: dir,
False:os.path.splitext(file)[0]}[file == '']))
if os.path.lexists(sym_link): os.remove(sym_link)
os.symlink(src,sym_link)
print sym_link,'-->',src
for version in MarcReleases:
src = os.path.abspath(os.path.join(baseDir,'DAMASK_marc.f90'))
if os.path.exists(src):
sym_link = os.path.abspath(os.path.join(baseDir,'DAMASK_marc'+str(version)+'.f90'))
if os.path.lexists(sym_link): os.remove(sym_link)
os.symlink(src,sym_link)
print sym_link,'-->',src

View File

@ -0,0 +1,97 @@
#!/usr/bin/env python
# Makes postprocessing routines acessible from everywhere.
import os
from damask import Environment
damaskEnv = Environment()
baseDir = damaskEnv.relPath('processing/')
codeDir = damaskEnv.relPath('code/')
#define ToDo list
bin_link = { \
'pre' : [
'marc_addUserOutput.py',
'mentat_pbcOnBoxMesh.py',
'mentat_spectralBox.py',
'OIMang_hex2cub.py',
'patchFromReconstructedBoundaries.py',
'randomSeeding.py',
'seed_check.py',
'geom_fromAng.py',
'geom_fromVPSC.py',
'geom_fromEuclideanDistance.py',
'geom_fromMinimalSurface.py',
'geom_fromVoronoiTessellation.py',
'geom_fromOsteonGeometry.py',
'geom_canvas.py',
'geom_check.py',
'geom_rescale.py',
'geom_pack.py',
'geom_unpack.py',
'geom_translate.py',
'geom_vicinityOffset.py',
'geom_grainGrowth.py',
'geom_poke.py',
],
'post' : [
'3Dvisualize.py',
'permuteData.py',
'addCalculation.py',
'addCauchy.py',
'addCompatibilityMismatch.py',
'addCurl.py',
'addDeformedConfiguration.py',
'addDeterminant.py',
'addDeviator.py',
'addDivergence.py',
'addEhkl.py',
'addEuclideanDistance.py',
'addGrainID.py',
'addMises.py',
'addNorm.py',
'addOrientations.py',
'addIPFcolor.py',
'addPK2.py',
'addSchmidfactors.py',
'addSpectralDecomposition.py',
'addStrainTensors.py',
'averageDown.py',
'binXY.py',
'blowUp.py',
'stddevDown.py',
'deleteColumn.py',
'deleteInfo.py',
'filterTable.py',
'sortTable.py',
'marc_deformedGeometry.py',
'marc_extractData.py',
'mentat_colorMap.py',
'nodesFromCentroids.py',
'perceptualUniformColorMap.py',
'postResults.py',
'showTable.py',
'tagLabel.py',
'vtk2ang.py',
'vtk_addData.py',
'vtk_pointcloud.py',
'vtk_addPointcloudData.py',
'vtk_voxelcloud.py',
'vtk_addVoxelcloudData.py',
],
}
for dir in bin_link:
for file in bin_link[dir]:
src = os.path.abspath(os.path.join(baseDir,dir,file))
if (file == ''):
sym_link = os.path.abspath(os.path.join(damaskEnv.binDir(),dir))
else:
sym_link = os.path.abspath(os.path.join(damaskEnv.binDir(),os.path.splitext(file)[0]))
print sym_link,'-->',src
if os.path.lexists(sym_link):
os.remove(sym_link)
os.symlink(src,sym_link)