I figured a solution it gives the desired results but I think it's not the best one,
first of all I sent data from process_A (belonging to communicator_A) to a process_B (belonging to communicator_B) using point to point communication (MPI_Send()
and MPI_Recv()
) because they all belong to the MPI_COMM_WORLD
communicator :
/*to get rank of my process in MPI_COMM_WORLD*/
MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
/*point to point communication*/
if (world_rank == process_A_rank_in_comm_world_communicator)
MPI_Send( &data ,size_of_data, MPI_INT, process_B_rank, tag ,MPI_COMM_WORLD);
if (world_rank == process_B_rank_in_comm_world_communicator)
MPI_Recv( &data ,size_of_data, MPI_INT, process_A_rank, tag ,MPI_COMM_WORLD, &lStatus);
then I made the process_B to broadcast the received data to all processes in its communicator which is the communicator_B.
/*broadCasting*/
MPI_Bcast(&data, size_of_data, MPI_INT, process_B_rank_in_communicator_B, communicator_B) ;