CFD Online Logo CFD Online URL
Home > Forums > OpenFOAM Running, Solving & CFD

Environment variable ($MPI_PROCS) in decomposeParDict

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By haakon

LinkBack Thread Tools Display Modes
Old   April 7, 2013, 22:30
Default Environment variable ($MPI_PROCS) in decomposeParDict
Join Date: Mar 2013
Posts: 68
Rep Power: 4
Pj. is on a distinguished road
Hi everyone,

this is my second post, so please excuse me if the question is pretty stupid.

I'm trying to run a OpenFOAM case on a super-computer with PBS queue manager. In the launch script I create the environment variable MPI_PROCS that contains the number of CPU that i'm using.

Is it possible to use this variable as number of subdomain in the decomposeParDict? (I'm using the scotch/ptscotch method, so I don't have to bother about the number of subdomain in other options)

I've tried to set just $MPI_PROCS in the place of the number of subdomain, but it gives me the error "Bad token in decomposeParDict ....etc etc".

PS: I'm not even very sure of what i'm saying, but could it be that i need to "export" the variable from the launch script to the variables of the run? (excuse me if my language is not technically correct, but I'm not a computer technician, I don't even now very well what environment variables are...)

thank you
Pj. is offline   Reply With Quote

Old   April 8, 2013, 02:34
Senior Member
Håkon Strandenes
Join Date: Dec 2011
Location: Norway
Posts: 111
Rep Power: 10
haakon will become famous soon enough
Ok; this might not be what you want, but this is my solution to this problem:

  1. In decomposeParDict, replace numberOfSubdomains 144; (or whatever number you want to use) with #include "numProcs"
  2. In the job script (the one you submit to PBS) you write the following line:
    echo "numberOfSubdomains $MPI_PROCS;" > system/numProcs
    before you decompose the domain.
  3. When the job is started, the file system/numProcs will be written, and read together with decomposeParDict.
This trick also work brilliantly for other parts of OpenFOAM as well, for example mesh convergence studies, time step convergence or other, generic parameter studies.

However, if someone has a method of getting environment variables directly in a dictionary, that would be great, as this method is a bit "dirty".
sylvester likes this.
haakon is offline   Reply With Quote

Old   April 8, 2013, 02:38
Join Date: Mar 2013
Posts: 68
Rep Power: 4
Pj. is on a distinguished road
Thank you very much haakon.

I see what you mean when you say that it's a bit "dirty", but it does exactly what I need.

It saves me from change that damn number every time i need to change number of CPU.

Thank you very much for the tip
Pj. is offline   Reply With Quote


decomposepar, environment variable, mpi, pbs

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
SWAK4FOAM_SRC environment variable fcuevas OpenFOAM Running, Solving & CFD 2 June 18, 2012 09:58
emag beta feature: charge density charlotte CFX 4 March 22, 2011 10:14
error in COMSOL:'ERROR:6164 Duplicate Variable' bhushas Main CFD Forum 1 May 30, 2008 04:35
How to set environment variables kanishka OpenFOAM Installation 1 September 4, 2005 10:15
Replace periodic by inlet-outlet pair lego CFX 3 November 5, 2002 21:09

All times are GMT -4. The time now is 16:46.