Welcome, Guest
Username: Password: Remember me

TOPIC: User variable computation and parallelism

User variable computation and parallelism 10 years 8 months ago #12339

  • special_20
  • special_20's Avatar
Hello all,

I created a subroutine to compute a variable over a set of points of my mesh with a DO loop such as :

(1) my_var = 0
DO i = 1, N
my_var = my_var+F(i)
ENDDO

where F(i) is a personal variable.

But those points may be in two different sub-domain when running Telemac in parallel mode. As F(i)=0 if i is not the correct sub-domain, loop (1) decomposes in two loop over the two related sub-domains :

(2) DO i = 1, N1
my_var = my_var+F(i)
ENDDO

(3) DO i = N1+1:N
my_var = my_var+F(i)
ENDDO

So my question are :
(a) The value of my_var at the end of the computation is the result of any of (2) or (3), or is it the sum of (2) and (3) ?
(b) Is it possible to "tell Telemac" to decompose the domain in such a way that my point sets are kept in the same sub-domain ?
The administrator has disabled public write access.

User variable computation and parallelism 10 years 8 months ago #12340

  • jmhervouet
  • jmhervouet's Avatar
Hello,

Suppose that the scalar implementation is :

my_var=0.D0
DO I=1,NPOIN
my_var=my_var+F(I)
ENDDO

NPOIN is here the number of points in the mesh.

The parallel implementation would be:

DOUBLE PRECISION P_DSUM
EXTERNAL P_DSUM

IF(NCSIZE.GT.1) THEN
my_var=0.D0
! here NPOIN is the number of points in the subdomain (and it is also the dimension of F, you must not dimension F in a subdomain with the original number of points)
DO I=1,NPOIN
my_var=my_var+F(I)*MESH%FAC%R(I)
ENDDO
my_var=P_DSUM(my_var)
ELSE
my_var=0.D0
DO I=1,N
my_var=my_var+F(I)
ENDDO
ENDIF

array MESH%FAC%R(I) accounts for the points that belong to several subdomains, P_DSUM sums over all subdomains.

For more information, see the "guide for programming in the Telemac system" (click on "manuals" on bottom of home page).

With best regards,

Jean-Michel Hervouet
The administrator has disabled public write access.

User variable computation and parallelism 10 years 8 months ago #12343

  • special_20
  • special_20's Avatar
Thank you JMH for this detailed answer.

To be exact F(i) depends not only on i but i and i+1. This may lead to tricky developments if i and i+1 refer to two nodes which are not in the same sub-domain.

As my subroutine is called only at the last time iteration and as this is a small computation I should do it only at the end of the run after Telemac has gathered all the informations from the processors.

So my two new questions are :

(1) Is it possible to do so ?
(2) If yes, then in where should I call my subroutine ?
The administrator has disabled public write access.

User variable computation and parallelism 10 years 8 months ago #12348

  • riadh
  • riadh's Avatar
Hello

If your subroutine is called once at the last time step of your simulation, don't implement it in parallel mode, i.e.:
1- run all your simulation until the last-but-one iteration in a parallel mode
2- change the obtained result file and put it as a previous computation file
3- run the last time step (including your new subroutine) in a sequential mode.

with my best regards

Riadh ATA
The administrator has disabled public write access.
Moderators: pham

The open TELEMAC-MASCARET template for Joomla!2.5, the HTML 4 version.