#include <string.h>
#include <mpc.h>
#include <sys/utsname.h>

nettype Mesh(int m, int n) {
  coord I=m, J=n;
  parent [0,0];
};

#define MAXLEN 256

int [*]main() {
  net Mesh(2,3) [host]mynet;
    
  [mynet]: {
    struct utsname un;
    char me[MAXLEN], neighbour[MAXLEN];

    uname(&un);
    strcpy(me, un.nodename);
    [mynet:I==0]neighbour[] = [mynet:I==1]me[];
    [mynet:I==1]neighbour[] = [mynet:I==0]me[];
    MPC_Printf("I'm on \"%s\" and have coordinates (%d, %d),\n"
              "My neighbour with coordinates (%d, %d) is on \"%s\".\n\n",
              me, I coordof mynet, J coordof mynet,
              (I coordof mynet + 1)%2, J coordof mynet, neighbour);
    }
}