diff -r 6c1cb606132d c/amspub.c --- a/c/amspub.c Tue Aug 07 14:46:49 2012 +0800 +++ b/c/amspub.c Wed Aug 08 11:27:37 2012 +0800 @@ -51,7 +51,7 @@ HOST_NODE *host_node; char host[MAXHOSTLEN+1], hosterr[255], *p; - int err, AMS_port, my_port = -1, tmp_port = -1, size = 0, t_flag; + int err, AMS_port, my_port = -1, tmp_port = -1, size = 0, rank, t_flag; static int firstcall = 1; #ifdef AMS_LDAP @@ -84,18 +84,19 @@ switch(ctype) { case MPI_TYPE: mpi_comm = (MPI_Comm) va_arg(args, MPI_Comm); - MPI_Comm_size(mpi_comm, &size); - mysetport = *(int *) va_arg(args, int *); - if (size > 1) { - err = AMSP_Construct_Host_list_AMS_MPI(&host_list, mpi_comm); - CheckErr(err); - port_list = NULL; - break; - } - ctype = NODE_TYPE; - host_list = NULL; + MPI_Comm_size(mpi_comm, &size); + MPI_Comm_rank(mpi_comm, &rank); + /*mysetport = *(int *) va_arg(args, int *);*/ + if (size > 1) { + err = AMSP_Construct_Host_list_AMS_MPI(&host_list, mpi_comm); + CheckErr(err); + port_list = NULL; + break; + } + ctype = NODE_TYPE; + host_list = NULL; port_list = NULL; - break; + break; case NODE_TYPE: host_list = (char **) va_arg(args, char **); port_list = (int *) va_arg(args, int *); @@ -126,9 +127,11 @@ else AMS_port = DEFAULT_PORT; /* Default port */ + /* if (mysetport != -1) { AMS_port = mysetport; } + */ if (firstcall == 1 || PUBLISHER.alive == 0) { /* Start the publisher **NOT THE COMMUNICATOR** */ /* Should be called once */ @@ -151,7 +154,17 @@ pub_arg->alive = 1; if(ctype == MPI_TYPE) + { + if(rank == 0) + { + pub_arg->care_about_port = 1; + } + else + { pub_arg->care_about_port = 0; + pub_arg->port = -1; + } + } else pub_arg->care_about_port = 1;