#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];
    subnet [mynet:I==0]row0, [mynet:I==1]row1;

    uname(&un);
    strcpy(me, un.nodename);
    [row0]neighbour[] = [row1]me[];
    [row1]neighbour[] = [row0]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);
  }
}