#include <stdlib.h>
#include "pgm.h"

main::main(CkArgMsg *m)
{
  if(m->argc !=2) {
    CkAbort("Usage: pgm <niter>\n");
  }
  Iter *msg = new Iter;
  total = niter = atoi(m->argv[1]);
  startTime = CkWallTimer();
  pm = new CProxy_main(thishandle);
  pm->iteration(msg);
  delete m;
}

void
main::iteration(Iter *msg)
{
  niter--;
  if(niter) {
    pm->iteration(msg);
    return;
  }
  endTime = CkWallTimer();
  CkPrintf("Total time for %d messages of %d size is %le seconds\n",
	  total, MSIZE, endTime-startTime);
  CkExit();
}

#include "pgm.def.h"
