#include #include #include /* function prototypes */ void IsingStep(int N, int **State, double JoverT, int *pM); void PrintStep(int N, int **State); int main(int argc, char **argv) { int i,j; /* loop variables */ int N; /* system size */ int Nrounds; /* number of iterations */ int M; /* magnetization */ int **State; /* state of all the spins */ double JoverT; /* J/T */ FILE *gfp; /* file pointer to gnuplot */ /* interpret command line arguments */ if (argc!=4) { fprintf(stderr,"ising usage: ising \n"); return(1); } N=atoi(argv[1]); Nrounds=atoi(argv[2]); JoverT=atof(argv[3]); /* get memory for state array */ State=(int **)malloc((N+2)*sizeof(int *)); if (State) { State[0]=(int *)malloc((N+2)*(N+2)*sizeof(int)); if (!State[0]) { free((void *)State); State=NULL; } } if (!State) { fprintf(stderr,"Not enough memory !\n"); return(2); } for(i=1;i0) fprintf(fp,"%d %d\n",i,j); fclose(fp); } fp=fopen("isingdown.dat","w"); if (fp) { for(i=1;i<=N;i++) for(j=1;j<=N;j++) if (State[i][j]<0) fprintf(fp,"%d %d\n",i,j); fclose(fp); } for(j=0;j<100;j++) for(i=0;i<100000;i++); }