1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- #################################################
- # This scripts sets an environment to work with #
- # Python 2.7, Clang, OpenMPI and PETSc #
- # #
- # To use, run #
- # source <this_script> #
- #################################################
- # Compiler Variables
- # Set MPI with Clang
- export OMPI_CC=clang
- export OMPI_CXX=clang++
- # Use MPI
- export CC=mpicc
- export CXX=mpicxx
- export FC=mpif90
- export F77=mpif77
- export F90=mpif90
- # PETSc
- export PETSC_DIR=/opt/petsc/linux-c-opt
- # JOB Count (the number of cores available on this machine)
- export MOOSE_JOBS=4
- # Set the default language to English (useful when
- # communicating with moose-users and moose-devs)
- export LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8
- # Load the virtual environment (for installation, see
- # https://wiki.archlinux.org/index.php/Python/Virtual_environment)
- # * Get Python version (select only the second column, space
- # as separator)
- pyver=$(python --version |
- awk -F" " '{print $NF}')
- if [[ ! "$pyver" == 2.* ]]; then
- # MOOSE needs python2.7
- # Check if python2.7 is available
- # * Preset a value
- py2=python2.7;
- # * Erase preset, if there is no executable
- which "$py2" &>/dev/null || py2="";
- # * Check if the dummy variable was set (if there
- # * is python2.7)
- if [[ -z "$py2" ]]; then
- # Print warning and exit if there is no python2.7
- printf "MOOSE needs python2.7, ";
- printf "and it seems that it is not ";
- printf "available.\n";
- # * If python2.7 exists, check for virtualenv
- # * (send any error output to a hole)
- elif [[ $(which virtualenv 2>/dev/null) ]]; then
- # ** If python3 is default, there is virtualenv
- # ** and python2.7 is available, use or create virtual
- # ** environment for python2.7
- printf "MOOSE needs python2.7, checking for ";
- printf "virtualenv.\n";
- # TODO
- printf "(This code is dumb, ";
- if [ -f venv/bin/activate ] && \
- [ -f venv/bin/"$py2" ]; then
- printf "found venv/bin/$py2, ";
- printf "using venv/bin/activate).\n";
- else
- printf "it may be that you already ";
- printf "have a virtual environment, sorry).\n";
- virtualenv -p "$py2" venv || exit
- printf "Making the virtualenv relocatale (relative ";
- printf ".pth files)\n";
- virtualenv --relocatable -p "$py2" venv || exit;
- # Could not create virtual environment
- fi;
- printf "Activating the virtual environment\n"
- source venv/bin/activate || exit;
- # Exits here if virtual environment didn't run
- else
- printf "MOOSE needs python2.7, ";
- printf "and it seems that virtualenv is not ";
- printf "available.\n";
- fi;
- fi
- printf "Virtual environment ready\n";
|