#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <termios.h>
#include <unistd.h>

#define     PI          3.14159265358979323846
#define     pi          3.14159265358979323846
#define     NLo         6.022045e23
#define     kB          1.380662e-23
#define     Rgas        8.3143
#define     amu         1.6605655e-27
#define     epsilon_0   8.8542e-12
#define     el_Charge   1.6021e-19

#define     max(a,b)   ((a>b) ? a : b)
#define     min(a,b)   ((a<b) ? a : b)
#define     SMALL      (1.0e-30)
#define     BIG        (1.0e+30)

#define     maxnsites   5000

extern char inputfilename[];

extern int EN,MD,MC,GCMD,GCMC;
extern int SHIFT;
extern int RELAX;
extern int ASSVEL;
extern int nsites;
extern int NHT;
extern int LRC;
extern int VELDIS;
extern int KINSTA;
extern int totnsteps;
extern int neqsteps;
extern int currentstep;
extern int Ndegfree;
extern int printvl;
extern int DEBUG;
extern int ndispacpt;
extern int ndeleacpt;
extern int ncreaacpt;
extern int ndisptried;
extern int ndeletried;
extern int ncreatried;
extern int nmodnMD;
extern int nWid;
extern int vdist[100];
extern int set;
extern int seed;

extern double xo[maxnsites],yo[maxnsites],zo[maxnsites];
extern double  x[maxnsites], y[maxnsites], z[maxnsites];
extern double fx[maxnsites],fy[maxnsites],fz[maxnsites];
extern double Lx,Ly,Lz;
extern double Tsoll,Tist;
extern double Tsum, Psum;
extern double rho;
extern double rhosum;
extern double NHtau;
extern double NHzeta;
extern double NHzetaold;
extern double NHcom;
extern double deltat;
extern double cutoff;
extern double Evdw, Vvdw, Ekin;
extern double dEdisp,dEmodn;
extern double dVdisp,dVmodn;
extern double Evdwsum;
extern double Ekinsum;
extern double Vvdwsum;
extern double muex;
extern double m;
extern double sigma;
extern double epsilon;
extern double BA;
extern double V;
extern double maxdisp;
extern double Elrc, Vlrc;
extern double EshiftpIA,VshiftpIA;
extern double beta;
extern double gset;

extern FILE* output;

extern int read_parameters(char*);
extern int read_coords(char*);
extern int checkcoords(void);
extern int checkvel(void);
extern int setup(char*);
extern int forces(void);
extern int sum(void);
extern int move(void);
extern int modn(void);
extern int displace(void);
extern void averages(void);
extern int write_coords(char*);
extern void write_time(clock_t,clock_t);
extern void merr(char*);
extern char* getfirst(char*,char*);
extern void relax(double*,double*);
extern double gauss_rand(void);
extern int write_veldis(char*);
extern int modnMD(void);

extern struct termios saved_attributes;
extern void reset_input_mode(void);
extern void set_input_mode(void);
extern int ask_stop(void);
extern void presskey(void);
extern char mic_getchar(char*); 
extern void mabort(char*);
extern double **dmat(int,int);
extern double *dvec(int);
extern float **fmat(int,int); 
extern float *fvec(int);
extern int **imat(int,int);
extern char **cmat(int,int);
extern int *ivec(int);
extern char *cvec(int);
extern double **d0mat(int,int);
extern double *d0vec(int);
extern float **f0mat(int,int);
extern float *f0vec(int);
extern int **i0mat(int,int);
extern int *i0vec(int);
extern char **c0mat(int,int); 
extern char *c0vec(int);
extern void waitsec(int);
