Introduced environment variable DAMASK_ROOT.
It is set in the DAMASK root folder by running damask_env.sh Much needed in the testing routines so far (try ./testing/run_tests.py) damask_env.sh could also trigger other scripts to get to a working setup after fresh checkout. For example it could run ./processing/setup/setup_processing.py ./code/setup/setup_code.py if it finds that we have a fresh checkout.
This commit is contained in:
parent
7fc8cd1949
commit
447e69019c
|
@ -29,7 +29,8 @@ for arch in architectures:
|
||||||
childFile.write(line.replace(me['versions'][0],version))
|
childFile.write(line.replace(me['versions'][0],version))
|
||||||
childFile.close()
|
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]:
|
if '--clean' in [s.lower() for s in sys.argv]:
|
||||||
os.system('make --directory %s clean'%wd)
|
os.system('make --directory %s clean'%wd)
|
||||||
|
|
|
@ -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
|
|
@ -1,10 +1,9 @@
|
||||||
class MSC_TOOLS():
|
class MSC_TOOLS():
|
||||||
import string
|
import os,string
|
||||||
|
|
||||||
|
|
||||||
def submit_job(self,
|
def submit_job(self,
|
||||||
run_marc_path='/msc/marc2010/tools/',
|
run_marc_path='/msc/marc2010/tools/',
|
||||||
subroutine_dir='../../../code/',
|
subroutine_dir=None,
|
||||||
subroutine_name='DAMASK_marc2010',
|
subroutine_name='DAMASK_marc2010',
|
||||||
compile='yes',
|
compile='yes',
|
||||||
compiled_dir='../../../code/',
|
compiled_dir='../../../code/',
|
||||||
|
@ -13,8 +12,12 @@ class MSC_TOOLS():
|
||||||
#IOdir='',
|
#IOdir='',
|
||||||
host=[]
|
host=[]
|
||||||
):
|
):
|
||||||
|
import os
|
||||||
import subprocess, shlex
|
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]
|
# Define all options [see Marc Installation and Operation Guide, pp 23]
|
||||||
run_marc=run_marc_path+'run_marc'
|
run_marc=run_marc_path+'run_marc'
|
||||||
jid=' -jid '+modelname+'_'+jobname
|
jid=' -jid '+modelname+'_'+jobname
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
import os,site,sys
|
import os,sys
|
||||||
|
#import site
|
||||||
# More elegant was to determine DAMASK install dir?
|
# maybe there is an alternative by using site.addsitedir() and *.pth file(s)?
|
||||||
#p=os.path.abspath(__file__)
|
damask_root=os.getenv('DAMASK_ROOT')
|
||||||
#l=p.split('/')
|
if damask_root is None:
|
||||||
#p=p[:-len(l[-1])]
|
print('Environment variable DAMASK_ROOT not set.\nPlease run DAMASK/damask_env.sh first.')
|
||||||
#print p
|
sys.exit()
|
||||||
#site.addsitedir(p) # adds the paths in the *.pth file to the python search path
|
print('Setting PYTHONPATH for DAMASK')
|
||||||
|
path_list=['processing'
|
||||||
basepath=os.path.expanduser('~')+'/DAMASK/'
|
,'processing/setup'
|
||||||
|
,'processing/pre'
|
||||||
|
,'processing/post'
|
||||||
sys.path.insert(0,basepath+'processing')
|
]
|
||||||
sys.path.insert(0,basepath+'processing/post')
|
for p in path_list:
|
||||||
sys.path.insert(0,basepath+'processing/pre')
|
if p not in sys.path:
|
||||||
sys.path.insert(0,basepath+'processing/setup')
|
sys.path.insert(0, damask_root+'/'+p)
|
||||||
#print sys.path
|
print sys.path
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue