
/*******************************************************************************
*
* File global.h
*
* Copyright (C) 2005, 2007 Martin Luescher
*
* This software is distributed under the terms of the GNU General Public
* License (GPL)
*
* Global parameters and arrays
*
*******************************************************************************/

#ifndef GLOBAL_H
#define GLOBAL_H

#define NAME_SIZE 128

//#define COMPILETIME_SIZE

#ifdef COMPILETIME_SIZE

#define NPROC0 1
#define NPROC1 1
#define NPROC2 1
#define NPROC3 1
#define L0 8
#define L1 8
#define L2 8
#define L3 8



/****************************** do not change *********************************/

#if ((NPROC0<1)||(NPROC1<1)||(NPROC2<1)||(NPROC3<1)|| \
    ((NPROC0>1)&&((NPROC0%2)!=0))||((NPROC1>1)&&((NPROC1%2)!=0))|| \
    ((NPROC2>1)&&((NPROC2%2)!=0))||((NPROC3>1)&&((NPROC3%2)!=0)))
#error : The number of processes in each direction must be 1 or a multiple of 2
#endif

#if ((L0<4)||(L1<4)||(L2<4)||(L3<4)|| \
    ((L0%2)!=0)||((L1%2)!=0)||((L2%2)!=0)||((L3%2)!=0))
#error : The local lattice sizes must be even and not smaller than 4
#endif

#if (NAME_SIZE<128)
#error : NAME_SIZE must be greater or equal to 128
#endif

#define NPROC (NPROC0*NPROC1*NPROC2*NPROC3)
#define VOLUME (L0*L1*L2*L3)
#define FACE0 ((1-(NPROC0%2))*L1*L2*L3)
#define FACE1 ((1-(NPROC1%2))*L2*L3*L0)
#define FACE2 ((1-(NPROC2%2))*L3*L0*L1)
#define FACE3 ((1-(NPROC3%2))*L0*L1*L2)
#define BNDRY (2*(FACE0+FACE1+FACE2+FACE3))
#define NSPIN (VOLUME+(BNDRY/2))

#endif


#if ((defined P4)||(defined DH))
#define ALIGN 7
#elif (defined PM)
#define ALIGN 6
#else
#define ALIGN 5
#endif

#ifndef SU3_H
#include "su3.h"
#endif

#if defined MAIN_PROGRAM
  #define EXTERN
#else
  #define EXTERN extern
#endif

EXTERN int cpr[4];
EXTERN int npr[8];



EXTERN pauli *sw;
EXTERN pauli_dble *swd;

#ifdef COMPILETIME_SIZE

EXTERN int ipt[VOLUME];
EXTERN int iup[VOLUME][4];
EXTERN int idn[VOLUME][4];
EXTERN int map[BNDRY+NPROC%2];
EXTERN int no_s,no_sd;

EXTERN su3 *pu[VOLUME][4];
EXTERN su3_dble *pud[VOLUME][4];

EXTERN spinor *(*ps)[NSPIN];
EXTERN spinor_dble *(*psd)[NSPIN];

#else




EXTERN int NPROC0;
EXTERN int NPROC1;
EXTERN int NPROC2;
EXTERN int NPROC3;

EXTERN int L0;
EXTERN int L1;
EXTERN int L2;
EXTERN int L3;

EXTERN int NPROC;
EXTERN int VOLUME;



EXTERN int FACE0;
EXTERN int FACE1;
EXTERN int FACE2;
EXTERN int FACE3;
EXTERN int BNDRY; 
EXTERN int NSPIN;



EXTERN int *ipt;
EXTERN int **iup;
EXTERN int **idn;



EXTERN int *map;
EXTERN int no_s,no_sd;



EXTERN su3 ***pu;
EXTERN su3_dble ***pud;

EXTERN spinor ***ps;
EXTERN spinor_dble ***psd;

#endif

#undef EXTERN

#endif
