diff --git a/code/setup/setup_code.py b/code/setup/setup_code.py index 54c6dc5e1..01c34aad7 100755 --- a/code/setup/setup_code.py +++ b/code/setup/setup_code.py @@ -29,7 +29,8 @@ for arch in architectures: childFile.write(line.replace(me['versions'][0],version)) childFile.close() -os.system('make --directory %s'%wd) +if raw_input("Do you want to compile the spectral code now? (y/n)") is 'y': + os.system('make --directory %s'%wd) if '--clean' in [s.lower() for s in sys.argv]: os.system('make --directory %s clean'%wd) diff --git a/damask_env.sh b/damask_env.sh new file mode 100644 index 000000000..5ae171d5d --- /dev/null +++ b/damask_env.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# Sets environment variable DAMASK_ROOT to allow python to locate various scripts. +# run with --bashrc to set DAMASK_ROOT permanently. +# should maybe got to /etc/profile.d/ for permanent "installation" +#http://stackoverflow.com/questions/630372/determine-the-path-of-the-executing-bash-script +MY_PATH="`dirname \"$0\"`" # relative +MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized +if [ -z "$MY_PATH" ] ; then + # error; for some reason, the path is not accessible + # to the script (e.g. permissions re-evaled after suid) + echo "set_damask_root.sh failed" + exit 1 # fail +fi +#echo "$MY_PATH" +DAMASK_ROOT=$MY_PATH +export DAMASK_ROOT +echo "DAMASK_ROOT: $DAMASK_ROOT" + +PYTHONPATH=$DAMASK_ROOT:$PYTHONPATH +export PYTHONPATH +#echo "PYTHONPATH: $PYTHONPATH" + +if [ "$1" = "--bashrc" ] ; then + echo -e "\nDAMASK_ROOT=$DAMASK_ROOT; export DAMASK_ROOT" >> $HOME/.bashrc + echo -e "\nPYTHONPATH=$DAMASK_ROOT:$PYTHONPATH; export PYTHONPATH" >> $HOME/.bashrc + else + echo "Run with option --bashrc to set DAMASK_ROOT and adjust PYTHONPATH permanently through .bashrc" +fi +echo "Now starting a new child bash that inherits the appropriate DAMASK_ROOT and PYTHONPATH variables. Have even more fun ..." +echo "To run the automated tests call ./testing/run_tests.py" +bash diff --git a/processing/msc_tools.py b/processing/msc_tools.py index ed749c441..35da5b30d 100644 --- a/processing/msc_tools.py +++ b/processing/msc_tools.py @@ -1,10 +1,9 @@ class MSC_TOOLS(): - import string - + import os,string def submit_job(self, run_marc_path='/msc/marc2010/tools/', - subroutine_dir='../../../code/', + subroutine_dir=None, subroutine_name='DAMASK_marc2010', compile='yes', compiled_dir='../../../code/', @@ -13,8 +12,12 @@ class MSC_TOOLS(): #IOdir='', host=[] ): + import os import subprocess, shlex - import shutil + import shutil + + if subroutine_dir is None: + subroutine_dir=os.getenv('DAMASK_ROOT')+'/code/' # Define all options [see Marc Installation and Operation Guide, pp 23] run_marc=run_marc_path+'run_marc' jid=' -jid '+modelname+'_'+jobname diff --git a/set_python_env.py b/set_python_env.py index fab4bbb4f..0ecace95f 100644 --- a/set_python_env.py +++ b/set_python_env.py @@ -1,21 +1,21 @@ #!/usr/bin/env python -import os,site,sys - -# More elegant was to determine DAMASK install dir? -#p=os.path.abspath(__file__) -#l=p.split('/') -#p=p[:-len(l[-1])] -#print p -#site.addsitedir(p) # adds the paths in the *.pth file to the python search path - -basepath=os.path.expanduser('~')+'/DAMASK/' - - -sys.path.insert(0,basepath+'processing') -sys.path.insert(0,basepath+'processing/post') -sys.path.insert(0,basepath+'processing/pre') -sys.path.insert(0,basepath+'processing/setup') -#print sys.path +import os,sys +#import site +# maybe there is an alternative by using site.addsitedir() and *.pth file(s)? +damask_root=os.getenv('DAMASK_ROOT') +if damask_root is None: + print('Environment variable DAMASK_ROOT not set.\nPlease run DAMASK/damask_env.sh first.') + sys.exit() +print('Setting PYTHONPATH for DAMASK') +path_list=['processing' + ,'processing/setup' + ,'processing/pre' + ,'processing/post' + ] +for p in path_list: + if p not in sys.path: + sys.path.insert(0, damask_root+'/'+p) +print sys.path