Close

5th July 2024

OpenFOAM Repo: 3. Setting the Environment

Environment variable settings for OpenFOAM are contained in files in the OpenFOAM-dev/etc directory.  To compile OpenFOAM, the user must ‘source’ the environment, either the bashrc file if they are running the bash or ksh shell, or the cshrc file if they are running the tcsh or csh shell.  To check the shell, type “echo $SHELL”.

The user should configure their system with permanent settings to source the environment. If OpenFOAM is installed in the $HOME/OpenFOAM directory, the user should:

  • EITHER if running bash or ksh, add the following line to the end of the user’s $HOME/.bashrc file:
    source $HOME/OpenFOAM/OpenFOAM-dev/etc/bashrc

    then type “source $HOME/.bashrc” in the current terminal window.

  • OR if running tcsh or csh, add the following line to the end of your $HOME/.cshrc file:
    source $HOME/OpenFOAM/OpenFOAM-dev/etc/cshrc

    then type “source $HOME/.cshrc” in the current terminal window.

When OpenFOAM is installed in an alternative directory, e.g. /opt, the user should substitute $HOME/OpenFOAM with the relevant installation location in the lines above.

Test this works correctly by typing “echo $WM_PROJECT_DIR” in the terminal window, which should return the full path to your repository directory, e.g. ${HOME}/OpenFOAM/OpenFOAM-dev.

← Back: 2. Downloading the Source CodeUp ↑ | Next: 4. Installing Third Party Software