CFD Online Logo CFD Online URL
Home > Forums > Software User Forums > ANSYS > CFX

Run a user fortran routine in parallel

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

Like Tree2Likes
  • 1 Post By Smilodon
  • 1 Post By Opaque

LinkBack Thread Tools Search this Thread Display Modes
Old   January 25, 2016, 10:47
Default Run a user fortran routine in parallel
New Member
Jure Ravnik
Join Date: Aug 2015
Posts: 1
Rep Power: 0
Smilodon is on a distinguished road
Hello everybody,

we have written a rather large user fortran model, which runs perfectly when running CFX on a single processor.

In order to be able to use our user fortran model in parallel, we would like to know, how to get the processor number in user fortran.

Namely, we would like to have only one processor writing the results and others skipping this step.

In short, we would like to do

myproc = the number of parallel thread
nproc = number of all threads
IF (myproc.EQ.1) THEN
CALL DoSomething

The question is how to get myproc and nproc?

Thank you for your answers!
doublestrong likes this.
Smilodon is offline   Reply With Quote

Old   January 25, 2016, 11:41
Senior Member
Join Date: Jun 2009
Posts: 1,472
Rep Power: 27
Opaque will become famous soon enough
Worth reading the documentation. For example,


The GET_PARALLEL_INFO routine provides access to information about the parallel run mode and partitioning details from within any user CEL function or from within junction box routines. It can be called in the following ways to look up the variables RUNMOD, PARMOD, OWNPAR and NPARD:

RUNMOD describes the run mode as either serial or parallel. It is an integer variable where 0 corresponds to serial and 1 to parallel.

PARMOD describes the parallel mode and can be master or slave. It is an integer variable where 1 corresponds to the master process and 2 to a slave process.

OWNPAR is an integer variable that gives the partition number on the current process.

NPARD is an integer variable that gives the total number of partitions.

The variables RUN_MODE, PAR_MODE, OWN_PAR and NUM_PAR are used to store the values locally and should be declared as integer variables in your subroutine. They can be named differently to the names used here, but to avoid conflicts they should not be named RUNMOD, PARMOD, OWNPAR or NPARD. CNAME is a dummy character variable and should be declared as such.
doublestrong likes this.
Opaque is offline   Reply With Quote

Old   March 28, 2017, 05:35
New Member
Join Date: Mar 2016
Posts: 24
Rep Power: 7
doublestrong is on a distinguished road
Thanks for the hints. I got the same problem and fixed it. The solver crashed if my subroutine wrote a result file in the parallel mode.

Now a result file is written only if the master processor calls my user routine. Here is the code block concerning output:
open(12,FILE='PressureRecordFile',POSITION = 'APPEND')
write(12,*) CTSTEP

Hope it helps people who also work with user routine.
doublestrong is offline   Reply With Quote


cfx, parallel computation, user fortran

Thread Tools Search this Thread
Search this Thread:

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Salome] Salome import "Cannot find file "points" in directory..." mismichael OpenFOAM Meshing & Mesh Conversion 5 June 22, 2019 03:56
parallel run is slower than serial run (pimpleFoam) !!! mechy OpenFOAM 18 August 17, 2016 18:19
simpleFoam in parallel issue plucas OpenFOAM Running, Solving & CFD 3 July 17, 2013 12:30
User fortran routines, DEBUG AND OUTPUT Bloshchitsyn Vladimir CFX 5 October 29, 2007 02:31
user subroutine error CFDUSER CFX 2 December 9, 2006 07:31

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