1% command to call
    2% mpirun -np 2 swipl bcast.pl
    3
    4:- use_module(library(lam_mpi)).    5
    6
    7main :-
    8       mpi_init,
    9       writeln(ok1),
   10       mpi_comm_size(N),
   11       writeln(ok2:N),
   12       mpi_comm_rank(Rank),
   13       do_comm(Rank),
   14       mpi_finalize.
   15
   16do_comm(Rank) :-
   17	   between(1,10,I),
   18	   NI is I*10,
   19	   gen_list(NI,List),
   20	   mpi_ibcast2(Rank, List),
   21	   mpi_barrier,
   22	   format('Rank=~d Msg=~w~n',[Rank,List]),
   23	   fail.
   24do_comm(_).
   25
   26gen_list(0,[]) :- !.
   27gen_list(I,[I|List]) :-
   28          I1 is I-1,
   29          gen_list(I1,List).
   30
   31:-main,halt.