CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Environment variable ($MPI_PROCS) in decomposeParDict (https://www.cfd-online.com/Forums/openfoam-solving/115823-environment-variable-mpi_procs-decomposepardict.html)

Pj. April 7, 2013 22:30

Environment variable ($MPI_PROCS) in decomposeParDict
 
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

haakon April 8, 2013 02:34

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:
    Code:

    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".

Pj. April 8, 2013 02:38

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 ;)


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