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

Run a user fortran routine in parallel

Register Blogs Community New Posts Updated Threads Search

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 25, 2016, 09:47
Default Run a user fortran routine in parallel
  #1
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
END IF

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, 10:41
Default
  #2
Senior Member
 
Join Date: Jun 2009
Posts: 1,804
Rep Power: 32
Opaque will become famous soon enough
Worth reading the documentation. For example,

Quote:
18.5.2.9. GET_PARALLEL_INFO

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:

CALL GET_PARALLEL_INFO ('RUNMOD',RUN_MODE,CNAME,CRESLT)
CALL GET_PARALLEL_INFO ('PARMOD',PAR_MODE,CNAME,CRESLT)
CALL GET_PARALLEL_INFO ('OWNPAR',OWN_PAR,CNAME,CRESLT)
CALL GET_PARALLEL_INFO ('NPARD',NUM_PAR,CNAME,CRESLT)
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, 04:35
Default
  #3
New Member
 
Tony
Join Date: Mar 2016
Posts: 24
Rep Power: 10
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:
CALL GET_PARALLEL_INFO ('PARMOD',PAR_MODE,CNAME,CRESLT)
if (PAR_MODE .EQ. 1) THEN
open(12,FILE='PressureRecordFile',POSITION = 'APPEND')
write(12,*) CTSTEP
close(12)
ENDIF

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

Reply

Tags
cfx, parallel computation, user fortran


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 02:56
parallel run is slower than serial run (pimpleFoam) !!! mechy OpenFOAM 18 August 17, 2016 17:19
simpleFoam in parallel issue plucas OpenFOAM Running, Solving & CFD 3 July 17, 2013 11:30
User fortran routines, DEBUG AND OUTPUT Bloshchitsyn Vladimir CFX 5 October 29, 2007 01:31
user subroutine error CFDUSER CFX 2 December 9, 2006 06:31


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