CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM

how to add OpenFoam in module environment

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By wikstrom

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 12, 2011, 23:45
Question how to add OpenFoam in module environment
  #1
New Member
 
Sangmin Park
Join Date: Apr 2011
Posts: 3
Rep Power: 15
smpark is on a distinguished road
Hello,

I installed OpenFOAM 1.7.1 in /opt directory on linux cluster
and for users, I want to add OpenFOAM in module environment but I don't know how to do it.

Module environment has already installed on our system.
and I tried to add OpenFOAM by inseting /etc/modulefiles/OpenFOAM/OpenFOAM-1.7.1 file.
But, It did not work at all.

Here is file I put into.

#%Module1.0

################################################## ###################
##
## Modulefile for OpenFOAM 1.7.1
##
################################################## ###################

proc ModulesHelp { } {

puts stderr "OpenFOAM-1.7.1"

}

module-whatis "sets the environment for OpenFOAM 1.7.1"

# for Tcl script use only
set topdir /opt/OpenFOAM/OpenFOAM-1.7.1
set version 1.7.1

setenv OpenFOAM_HOME $topdir
prepend-path PATH $topdir/bin
prepend-path LD_LIBRARY_PATH $topdir/lib

and I think I have to put some line about exporting path like
source /opt/OpenFOAM/OpenFOAM/etc/bashrc

does anyone have idea?

thanks in advance.

Sangmin
smpark is offline   Reply With Quote

Old   April 26, 2011, 14:02
Default
  #2
Member
 
Niklas Wikstrom
Join Date: Mar 2009
Posts: 86
Rep Power: 17
wikstrom is on a distinguished road
Hello,
I have the same problem. Have tried with

Code:
system("source ..../bashrc")
or
Code:
system "source ..../bashrc"
etc.
Both gives me a Tcl error.

/Niklas

Last edited by wikstrom; April 27, 2011 at 02:12.
wikstrom is offline   Reply With Quote

Old   April 27, 2011, 06:14
Default
  #3
Senior Member
 
Eugene de Villiers
Join Date: Mar 2009
Posts: 725
Rep Power: 21
eugene is on a distinguished road
You only need a very small number of environmental variables to run OPENFOAM (to compile it you need a whole lot more).

With modules it is easier to simply set the exact environmental variables needed to run and do the compiling in a non-modules environment.

I can't recall all the variables needed, but there is no more than 10. The ones I remember:
- PATH and LD_LIBRARY_PATH
- MPI_BUFFER_SIZE
- WM_PROJECT_INST_DIR
- WM_PROJECT_DIR
- FOAM_SIGFPE & FOAM_SETNAN (optional)

Some might be superfluous and there might be one or two missing, but as far as I recall, that's the gist of it.
eugene is offline   Reply With Quote

Old   April 27, 2011, 16:46
Default
  #4
Member
 
Niklas Wikstrom
Join Date: Mar 2009
Posts: 86
Rep Power: 17
wikstrom is on a distinguished road
Thank's a lot Eugene,

I will sort it out that way. You just saved me from wasting time on tedious scripting...

-Niklas
wikstrom is offline   Reply With Quote

Old   May 12, 2011, 15:00
Default
  #5
Member
 
Niklas Wikstrom
Join Date: Mar 2009
Posts: 86
Rep Power: 17
wikstrom is on a distinguished road
Might as well post the simplest 'obvious' solution. To prepare the contents of a module file, I just run printenv before and after sourcing OpenFOAM, piping output to two different files. A diff on these combined with sed gives a 90% working OpenFOAM-module file. Then clean up the remaining 10% by hand.

Without fancyness:
Code:
printenv > /tmp/env_0
export FOAM_INST_DIR=/opt/OpenFOAM
. /opt/OpenFOAM/OpenFOAM-1.7.x/etc/bashrc
printenv > /tmp/env_1

diff /tmp/env_?|sed -ne 's/> \(.*\)=\(.*\)/setenv \1\t"\2"/gp' >> moduleFile
Crude, but quick and functional. 15 minutes more 'sed'ing and editing and the moduleFile can be 'parameterised', and reusable.

/N
markusrehm and Nomis like this.
wikstrom is offline   Reply With Quote

Reply

Tags
module load, openfoam


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
CFX11 + Fortran compiler ? Mohan CFX 20 March 30, 2011 19:56
Cross-compiling OpenFOAM 1.7.0 on Linux for Windows 32 and 64bits with Mingw-w64 wyldckat OpenFOAM Announcements from Other Sources 3 September 8, 2010 07:25
Cross-compiling OpenFOAM 1.6 on Linux for Windows 32 and 64bits with Mingw-w64 wyldckat OpenFOAM Announcements from Other Sources 7 January 19, 2010 16:39
Can someone PLEASE document the development version installation bernd OpenFOAM Installation 76 November 14, 2008 22:51
Getting OpenFOAM to coexist with an existing JAVA VM nik777 OpenFOAM Installation 5 February 22, 2007 08:21


All times are GMT -4. The time now is 13:52.