[Nek5000-users] Sharing parameters between processors

nek5000-users at lists.mcs.anl.gov nek5000-users at lists.mcs.anl.gov
Tue Dec 1 08:49:15 CST 2015


Oscar,

In general, you need to use MPI routines to do that sort of thing. There 
are a bunch of NEK subroutines which are "wrappers" for the underlying 
MPI routines, and properly set them up, pass the variables, etc...

They are pretty easy to use, but you do have to read up a little about 
how the MPI routines work to understand the context.

I have some .usr code where I am counting grid points during a specific 
number of time steps, holding them in an array at each rank, then adding 
them up at a certain time step.  I am using the "gop()" subroutine to do 
this; it implements MPI_ALLREDUCE.  There are other routines which find 
the min, max, etc...  Look at comm_mpi.f for some ideas; sounds like you 
need some simple broadcast function, something using MPI_bcast...

See Ya,
Murph

-- 
Murphy Leo O'Dea
PhD Candidate
Oakland University
mlodea at oakland.edu



---------------------------------------------------------------------------------------------------------------------------------------
On 12/1/2015 6:49 AM, nek5000-users-request at lists.mcs.anl.gov wrote:

Indeed, common blocks only work with the local memory. The easiest way 
is, if it is only a few parameters, that you put them into the rea file 
in the unused section (say about index 120 or so). Then the values are 
immediately available on each processor.

Otherwise you have to do explicit communication. The starting point 
would be the broadcast operation, bcast(buf,len), which shares len reals 
stored on process 0 with all other processes. bcast is a wrapper to the 
standard MPI function
  call mpi_bcast (buf,len,mpi_byte,0,nekcomm,ierr)

Hope this helps,
Philipp

On 2015-11-30 23:31, nek5000-users at lists.mcs.anl.gov wrote:
Hi Nekers,

In my current simulation, I am defining an array containing parameters
that are shared between several processors. I have tried to do this in
the usercheck subroutine, with a COMMON statement. However, the COMMON
statement enables saving the parameters between two successive calls of
the usercheck by the same processor, but does not enable to share a
variable between two processor. In other words, if I modify the variable
a on the processor 1, the variable a on the processor 2 will not be
modified, which is not what I want. Any idea on how to do that?

Thanks for your help,

Oscar Valdorez



More information about the Nek5000-users mailing list