Just like in your original code snippet, you can

If (master_comm .ne. Mpi_comm_null) then
   ...

Sent from my phone. No type good.

On Aug 2, 2017, at 7:17 AM, Diego Avesani 
<diego.aves...@gmail.com<mailto:diego.aves...@gmail.com>> wrote:

Dear all, Dear Jeff,

I am very sorry, but I do not know how to do this kind of comparison.

this is my peace of code:

CALL MPI_GROUP_INCL(GROUP_WORLD, nPSObranch, MRANKS, MASTER_GROUP,ierr)
 CALL MPI_COMM_CREATE_GROUP(MPI_COMM_WORLD,MASTER_GROUP,0,MASTER_COMM,iErr)
 !
 IF(MPI_COMM_NULL .NE. MASTER_COMM)THEN
    CALL MPI_COMM_RANK(MASTER_COMM, MPImaster%rank,MPIlocal%iErr)
    CALL MPI_COMM_SIZE(MASTER_COMM, MPImaster%nCPU,MPIlocal%iErr)
 ELSE
    MPImaster%rank = MPI_PROC_NULL
 ENDIF

and then

 IF(MPImaster%rank.GE.0)THEN
    CALL MPI_SCATTER(PP, 10, MPI_DOUBLE, PPL, 10,MPI_DOUBLE, 0, MASTER_COMM, 
iErr)
 ENDIF

What I should compare?

Thanks again

Diego


On 1 August 2017 at 16:18, Jeff Squyres (jsquyres) 
<jsquy...@cisco.com<mailto:jsquy...@cisco.com>> wrote:
On Aug 1, 2017, at 5:56 AM, Diego Avesani 
<diego.aves...@gmail.com<mailto:diego.aves...@gmail.com>> wrote:
>
> If I do this:
>
> CALL MPI_SCATTER(PP, npart, MPI_DOUBLE, PPL, 10,MPI_DOUBLE, 0, MASTER_COMM, 
> iErr)
>
> I get an error. This because some CPU does not belong to MATER_COMM. The 
> alternative should be:
>
> IF(rank.LT.0)THEN
>     CALL MPI_SCATTER(PP, npart, MPI_DOUBLE, PPL, 10,MPI_DOUBLE, 0, 
> MASTER_COMM, iErr)
> ENDIF

MPI_PROC_NULL is a sentinel value; I don't think you can make any assumptions 
about its value (i.e., that it's negative).  In practice, it probably always 
is, but if you want to check the rank, you should compare it to MPI_PROC_NULL.

That being said, comparing MASTER_COMM to MPI_COMM_NULL is no more expensive 
than comparing an integer. So that might be a bit more expressive to read / 
easier to maintain over time, and it won't cost you any performance.

--
Jeff Squyres
jsquy...@cisco.com<mailto:jsquy...@cisco.com>

_______________________________________________
users mailing list
users@lists.open-mpi.org<mailto:users@lists.open-mpi.org>
https://lists.open-mpi.org/mailman/listinfo/users

_______________________________________________
users mailing list
users@lists.open-mpi.org<mailto:users@lists.open-mpi.org>
https://lists.open-mpi.org/mailman/listinfo/users
_______________________________________________
users mailing list
users@lists.open-mpi.org
https://lists.open-mpi.org/mailman/listinfo/users

Reply via email to