# include <sys/types.h>
# include <string.h>

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdbool.h>

#include <qmp.h>
#include "init_qmp.h"

extern "C" void INIT_QMP(int& aa)
{
  int *argc;
  char ***argv;
  argc = &aa;
  bool setGeomP = false;
  if (QMP_is_initialized() == QMP_FALSE)
    {
      QMP_thread_level_t prv;
      if (QMP_init_msg_passing(argc, argv, QMP_THREAD_SINGLE, &prv) != QMP_SUCCESS)
	{
          printf( "%s\n", "QMP_init_msg_passing failed");
        }
    }
}

extern "C" void INIT_QMP_NODE(int& nx, int& ny, int& nz, int& nt)
{
    int logical_geom[4];
    logical_geom[0]=nx;
    logical_geom[1]=ny;
    logical_geom[2]=nz;
    logical_geom[3]=nt;
//	printf( "nx = %d\n", *nx);
//	printf( "ny = %d\n", *ny);
//	printf( "nz = %d\n", *nz);
//	printf( "nt = %d\n", *nt);
    //logical_geom[0]=2;
    //logical_geom[1]=4;
    //logical_geom[2]=4;
    //logical_geom[3]=2;

    if (QMP_declare_logical_topology(logical_geom, 4) != QMP_SUCCESS)
    {
	printf( "%s\n", "QMP_declare_logical_topology failed");
    }
}

extern "C" void ABORT_QMP()
{
int stat;
QMP_abort(stat);
}
