Newsgroups: comp.parallel.mpi
From: jcksndk1@nano.ma (Mr D K Jackson)
Subject: Re: MPI_IO and MPI_HOST
Organization: IC
Date: 24 Mar 1998 16:26:58 +0000
Message-ID: <nqwafag8371.fsf@nano.ma>

In article <dwp3egg7w3u.fsf@breeze.cs.wisc.edu> Steve Huss-Lederman <lederman@breeze.cs.wisc.edu> writes:
   My first guess (without seeing the whole code) is that you did not
   treat them as attributes.  You have to use MPI_ATTR_GET (or preferably

Many thanks. The light dawned very quickly on reading your reply.
However, I was initially caught out by the use of pointers to the attribute
value in MPI_Attr_get. I've stuck the working code below in case any other
novices suffering similar trauma are following this thread.

cheers,
david

/***** MPI attributes MPI_HOST and MPI_IO test *****/ 
#include <stdio.h>
#include <unistd.h>
#include <mpi.h> 
#include <stdlib.h>

main(int argc, char **argv) {
  int myid, np, ierr, idummi, iflag;
  int *mpihost, *mpiio;
  char host[40],pname[MPI_MAX_PROCESSOR_NAME+1];

  /* Initialise MPI */ 
  MPI_Init (&argc, &argv); 

  /* Main part of program .... */ 
  MPI_Comm_size(MPI_COMM_WORLD, &np);
  MPI_Comm_rank(MPI_COMM_WORLD, &myid);
  strcpy(host, "this should change");
  gethostname(host,40);
  MPI_Get_processor_name(pname,&idummi);
  MPI_Attr_get(MPI_COMM_WORLD, MPI_IO,(void**)&mpiio, &iflag);
  ierr = MPI_Attr_get(MPI_COMM_WORLD, MPI_HOST, (void**)&mpihost, &iflag);

  fprintf(stdout,"This is node %d of %d  on %s, unix says %s\n ",myid,np,pname,host);
  fprintf(stdout," MPI_HOST  %d   MPI_PROC_NULL %d  MPI_ANY_SOURCE %d  MPI_IO %d\n",*mpihost,MPI_PROC_NULL,MPI_ANY_SOURCE,*mpiio);

  /* Terminate MPI */ 
  MPI_Finalize (); 
  exit(0);
}



