1:- use_module(library(lam_mpi)).    2:- use_module(library(system)).    3main:-
    4  write(main),nl,
    5  mpi_init,
    6  write(after_init),nl,
    7  mpi_comm_size(S),
    8  mpi_comm_rank(R),
    9  write([R,S]),nl,
   10  (R == 0->
   11    sleep(2),
   12    write(wait_end),nl,
   13    mpi_send(ciao,1,201),
   14    write(after_send),nl
   15  ;
   16    mpi_irecv(0,_Tag,H),
   17    write(irecv),nl,
   18    test(H)
   19  ),
   20  mpi_finalize.
   21
   22test(H):-
   23  (mpi_test_recv(H,S,Data)->
   24    write(c(S,Data)),nl
   25  ;
   26    write(no),nl,
   27    test(H)
   28  ).
   29
   30:-main,halt.