--- trunk/dp/dp.c 2003/08/05 21:44:35 667 +++ trunk/dp/dp.c 2003/08/13 16:43:53 692 @@ -1,7 +1,17 @@ #include +#include +#include +#include #include #include #include +#include "mkl_vsl.h" + +#define SEED 1 +#define BRNG VSL_BRNG_MCG31 +#define METHOD 0 +#define N 1 + #define max_sites 15000 #define MYSEED 8973247 @@ -14,41 +24,56 @@ int main(argc, argv) int attemp, nacc; -int main(argc, argv) -int argc; -char *argv[]; +int main(int argc, char *argv[]) { void getmag(); double eneri(double xi, double yi, double zi, double phii, double thetai, int i, int jb); double toterg(); void adjust(); - void mcmove(); + void mcmove(VSLStreamStatePtr stream); void store(FILE *outFile); double twopi, nnd, myran, kb; double ent; int icycl, ncycl, imove, nmoves, nsamp; int nx, ny, which, i, j; + int readfile, mySeed; FILE *inFile; char *endptr, s[100000]; double ux, uy, uz; - + + struct timeval now_time_val; + struct timezone time_zone; + struct tm *now_tm; + time_t now; + + VSLStreamStatePtr stream; + FILE *outFile; outFile=fopen("dp_file1","a"); - srand48(MYSEED); - // These two parameters set the size of the system: + //srand48(MYSEED); + // + gettimeofday(&now_time_val, &time_zone); /* get the time now */ + now = now_time_val.tv_sec; /* convert to epoch time */ + + mySeed = (int) now; + + vslNewStream(&stream, BRNG, mySeed); + + // These two parameters set the size of the system: + nnd = 7.0; ny = 100; - + // we want the domains to be roughly square: - + nx = (int) ((double)ny / sqrt(3.0)); - - + + // periodic box boundaries: domsizex = sqrt(3.0) * nx * nnd; @@ -64,92 +89,105 @@ char *argv[]; beta = 1.0 / (kb * 300.0); z0 = 0.0; deltaz = 0.1; - deltaphi = 0.1; - kz = kb; - ktheta = kb; + deltaphi = 0.1; + kz = kb; + ktheta = kb; theta0 = M_PI / 2.0; which = 0; xlat = 0; - if( strcmp(argv[1], "-resume") == 0) { + if (argc > 1) { + if( strcmp(argv[1], "-resume") == 0) + readfile = 1; + else + readfile = 0; + } else + readfile = 0; + + if (readfile == 1) { + inFile = fopen("./l_con","r"); if (inFile == NULL){ - printf("Error opening file\n"); - exit(-1); + printf("Error opening file\n"); + exit(-1); } - + while(!feof(inFile)) - { - fgets(s, 500, inFile); - nsites = atoi(s); + { + fgets(s, 500, inFile); + nsites = atoi(s); + fscanf(inFile,"%s",s); + xlat= atoi(s); + fscanf(inFile,"%s",s); + ylat= atoi(s); + for(i=1; i<=nsites; i++) + { fscanf(inFile,"%s",s); - xlat= atoi(s); fscanf(inFile,"%s",s); - ylat= atoi(s); - for(i=1; i<=nsites; i++) - { - fscanf(inFile,"%s",s); - fscanf(inFile,"%s",s); - x[i] = strtod(s, &endptr); - fscanf(inFile,"%s",s); - y[i] = strtod(s, &endptr); - fscanf(inFile,"%s",s); - z[i] = strtod(s, &endptr); - fscanf(inFile,"%s",s); - phi[i] = strtod(s, &endptr); - fscanf(inFile,"%s",s); - ux = strtod(s, &endptr); - fscanf(inFile,"%s",s); - uy = strtod(s, &endptr); - fscanf(inFile,"%s",s); - uz = strtod(s, &endptr); - theta[i] = acos(uz); - mu[i] = strength; - } - } + x[i] = strtod(s, &endptr); + fscanf(inFile,"%s",s); + y[i] = strtod(s, &endptr); + fscanf(inFile,"%s",s); + z[i] = strtod(s, &endptr); + fscanf(inFile,"%s",s); + phi[i] = strtod(s, &endptr); + fscanf(inFile,"%s",s); + ux = strtod(s, &endptr); + fscanf(inFile,"%s",s); + uy = strtod(s, &endptr); + fscanf(inFile,"%s",s); + uz = strtod(s, &endptr); + theta[i] = acos(uz); + mu[i] = strength; + } + } fclose(inFile); printf("%f\t%f\t%f\t%f\t%f\n", x[nsites], y[nsites], z[nsites], phi[nsites], theta[nsites]); - } + } else { - else{ - for(i=0; i < nx; i++) { - - xlat = xlat + 2; - ylat = 0; - - for(j=0; j