#include <stdlib.h>
#include <stdio.h>
#include <converse.h>
#include <sm.h>

CmiStartFn mymain()
{

  SMInit(0);
  return 0;
}

main(int argc,char *argv[])
{
  ConverseInit(argc,argv,(CmiStartFn)0,1,1);
  SMInit(0);
  CmiPrintf("PE %d of %d starting\n",CmiMyPe(),CmiNumPes());
  int i;
  char buf[64];
  for(i=0;i<100;i++) {
    sprintf(buf, "Iteration %d", i);
    if(CmiMyPe()==0) {
      send(1, 2*i, 64, buf);
      recv(1, 2*i+1, 64, buf);
    } else {
      recv(0, 2*i, 64, buf);
      send(0, 2*i+1, 64, buf);
      CmiPrintf("Data = \"%s\"\n", buf);
    }
  }
  CmiPrintf("Done\n");
  ConverseExit();
}
