CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Installation (
-   -   unable to source openFOAM under $HOME directory (

lilinghan8 November 6, 2012 14:03

unable to source openFOAM under $HOME directory
Dear all,

I would like to modify the solver in openfoam210 but it seems that I cannot make any changes to the files under /opt/
So I moved it to my home directory and add the following line into my $HOME/.bashrc file
source $HOME/openfoam210/etc/bashrc.

Then I run “source $HOME/.bashrc” in the terminal window and these were the information I got:
bash: /opt/openfoam210/bin/foamEtcFile: No such file or directory
bash: /opt/openfoam210/bin/foamCleanPath: No such file or directory
bash: /opt/openfoam210/bin/foamCleanPath: No such file or directory
bash: /opt/openfoam210/bin/foamCleanPath: No such file or directory
bash: /opt/openfoam210/etc/config/ No such file or directory
bash: /opt/openfoam210/etc/config/ No such file or directory
bash: /opt/openfoam210/bin/foamEtcFile: No such file or directory
bash: /opt/openfoam210/bin/foamEtcFile: No such file or directory
bash: /opt/openfoam210/bin/foamCleanPath: No such file or directory
bash: /opt/openfoam210/bin/foamCleanPath: No such file or directory
bash: /opt/openfoam210/bin/foamCleanPath: No such file or directory

can anyone please tell to me is there any thing I miss?


treima November 7, 2012 03:18


did you move your hole OpenFOAM folder? In this case you have to compile again...

You can modify solvers in your home folder. You just have to copy the solver into your user directory of OpenFoam, normally

In this case you can modify solvers without a sudo or moving the OpenFOAM installation. It´s like the run directory ;).


lilinghan8 November 7, 2012 18:51

Hi treima,

Thanks for your reply, I moved the whole OpenFOAM folder, How to compile it again?
I type wmake all or ./Allwmake under the new directory in terminal window but it doesnt work. It says that wmake commmand is not found


blacksquirrel November 8, 2012 03:52

Hello lilinghan,

look into your bashrc.
(gedit $HOME/.bashrc)

there should be written something like:
source /opt/openfoam211/etc/bashrc

change this to your new location of the OpenFOAM folder, e.g.
source $HOME/OpenFOAM/OpenFOAM-2.1.1/etc/bashrc

source the bashrc again (. $HOME/bashrc) and try ./Allwmake in the OpenFOAM folder

lilinghan8 November 8, 2012 05:44

Hi Squirrel,

Thanks for ur reply, I have done the step that changing the location in bashrc, and when and run "source $HOME/OpenFOAM/OpenFOAM-2.1.1/etc/bashrc" I got the error messages as I mentioned in my post above.


blacksquirrel November 8, 2012 06:38

Ok, sorry I didn't check the bash file of the OpenFOAM installation.
In /OpenFOAM/OpenFOAM-2.1.0/etc/bashrc file there is written

(line 43)

# Location of the OpenFOAM installation
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# foamInstall=~$WM_PROJECT
# foamInstall=/opt/$WM_PROJECT
# foamInstall=/usr/local/$WM_PROJECT

Which means, it still searches your OpenFOAM in the /opt/ directory
So you have two possibilities, I would suggest the first one, because it is less likely to accidentally overwrite a working solver:
1.) you move your whole OpenFOAM directory back to the /opt/ directory and test whether it works again.
Then you create a directory in your home $HOME/OpenFOAM/user-2.1.0
Then you COPY the solver you want to modify from the opt/openfoam into your user directory, but keep a similar directory tree
e.g. simpleFoam would be
copy from /opt/openfoam210/applications/solvers/incompressible/simpleFoam
to $HOME/OpenFOAM/user-2.1.0/applications/solvers/incompressible/simpleFoam

In the copied solver directory edit the Make/files


EXE = $(FOAM_USER_APPBIN)/mysimpleFoam
compile the solver with wmake,
modify to whatever you want and compile again.
You can use the modified solver with the new name mysimpleFoam (you can name it whatever you like in Make/files, but I would suggest not using the original name).

2. you change in

to the correct foamInstall directory.
foamInstall = $HOME/$WM_PROJECT


lilinghan8 November 8, 2012 08:38

Hi again,

I need to modify the solver and I download a other people's work which is also needed to change the libraries in the original file so I prefer the 2rd method.

I changed the foamInstall directory to

BUt I still got the error message, do i need also change the code:

#- note the location for later use (eg, in job scripts)
: ${FOAM_INST_DIR:=$foamInstall}; export FOAM_INST_DIR

Any idea?


blacksquirrel November 8, 2012 08:57

Ok, this is curious. What do you get, if you type




I don't think you need to change the code for FOAM_INST_DIR, because

#- note the location for later use (eg, in job scripts)
: ${FOAM_INST_DIR:=$foamInstall}; export FOAM_INST_DIR

sets the $FOAM_INST_DIR to the location of foamInstall.

And you can also compile new libraries with my first method. I'm doing the same, modifying solvers and libraries. It isn't more complicated.

lilinghan8 November 8, 2012 09:09


one is
and the second is

blacksquirrel November 8, 2012 09:19

Ok, so there is still the wrong directory.
Let's try the simplest thing: close the terminal and open another one. Try again.
Still the same?

I tried it with my installation and it doesn't change the directory despite sourcing the bash file, but it worked after closing and reopening the terminal.
I'm kinda out of ideas right now, sorry...

lilinghan8 November 8, 2012 09:56

I close and open a new terminal window, and now it works!

Thanks very much for your replies!


palmerlee January 9, 2014 09:12

Hi, blacksquirrel!

Here is my situation:

hpc@node23:/opt/openfoam201$ echo $WM_PROJECT_DIR
hpc@node23:/opt/openfoam201$ echo $FOAM_INST_DIR
Could you please tell me if there is something wrong and how to fix it?


blacksquirrel January 10, 2014 06:16

Hi Peter,

Please specify your problem. What exactly do you want to do, and what is not working?

Your output means, that the installation directory of OpenFOAM is /home/hpc/OpenFOAM.

If you want to modify a solver and/or library and have the problem, that you don't have the permission to do it in the /opt directory, I strongly recommend possibility 1 of my post from November 8, 2012 11:38.


palmerlee January 10, 2014 06:28

Hi, squirrel!

Thank you for your reply. I try to install OpenFOAM following this instruction:

I think I have already solved the problem by adding

export FOAM_INST_DIR=/opt
into /opt/openfoam201/etc/bashrc file. Thank anyway!


neiht November 16, 2016 23:09

All you need is just
0. make sure in etc/bashrc file : foamInstall=$HOME/$WM_PROJECT (no # before)
1. go straight to the .../etc/ directory
2. open the terminal in directory above then type: source bashrc
3. echo $WM_PROJECT_DIR to check
4. Install OpenFoam in the main OpenFOAM directory by ./Allwamke
5. F*** someone to enjoy

All times are GMT -4. The time now is 19:09.