static void write_state(void) { FILE *fp; int k,ns,*state; float base,r[N]; ns=rlxs_size(); state=malloc(ns*sizeof(int)); base=(float)(ldexp(1.0,24)); rlxs_init(1,1234567); for (k=0; k<10; k++) ranlxs(r,N); rlxs_get(state); ranlxs(r,N); fp=fopen(".tmp","w"); for (k=0; k<ns; k++) fprintf(fp,"%d\n",state[k]); for (k=0; k<N; k++) fprintf(fp,"%12.1f\n",base*r[k]); fclose(fp); }
//////////////////////////////////////////////////////////////////////////////// /////////////////////// private methods //////////////////////////////////////// void LapH::distillery::set_random_vector() { double sqrt2 = 0.5*sqrt(2.0); double re, im; rlxs_init(2, param.seed^param.config); int rnd_length = 2*param.Lt*param.nb_ev*4; float* rnd = new float[rnd_length]; ranlxs(rnd, rnd_length); int myid = 0; MPI_Comm_rank(MPI_COMM_WORLD, &myid); // generating a Z_2 source for(size_t t = 0; t < param.Lt; ++t ){ random_vector[t].setRandom(4 * param.nb_ev); for(size_t i = 0; i < 4 * param.nb_ev; ++i){ if (rnd[8 * param.nb_ev * t + 2*i] < 0.5) re = -sqrt2; else re = sqrt2; if (rnd[8 * param.nb_ev * t + 2*i + 1] < 0.5) im = -sqrt2; else im = sqrt2; random_vector[t](i) = {re, im}; } } // writing random vector to disc if(myid == 0) write_random_vector_to_disk(); }
static void read_state(void) { FILE *fp; int k,ns,*state; float base,r[N],r_old[N]; ns=rlxs_size(); state=malloc(ns*sizeof(int)); base=(float)(ldexp(1.0,24)); fp=fopen(".tmp","r"); for (k=0; k<ns; k++) fscanf(fp,"%d",&state[k]); for (k=0; k<N; k++) fscanf(fp,"%f",&r_old[k]); fclose(fp); remove(".tmp"); rlxs_reset(state); ranlxs(r,N); for (k=0; k<N; k++) { if (r_old[k]!=(base*r[k])) { printf("\n"); printf("Error: state of ranlxs has not been properly reset\n"); printf("\n"); exit(1); } } }
// ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- void LapH::RandomVector::set(const int seed) { // initialisation of the rando vector to create Z2 random vector size_t length = vec.size(); rlxs_init(0, seed); std::vector<float> rnd(2*length); ranlxs(&(rnd[0]), 2*length); // generating a Z_2 source for(size_t i = 0; i < length; ++i){ const double sqrt2 = 0.5*sqrt(2.0); double re, im; if (rnd[2*i] < 0.5) re = -sqrt2; else re = sqrt2; if (rnd[2*i + 1] < 0.5) im = -sqrt2; else im = sqrt2; vec[i] = cmplx(re, im); } }
int main(void) { int k,test1,test2; int *state1,*state2; float sbase; float xs[NXS],ys[NXS],xsn[96]; double base; double xd[NXD],yd[NXD],xdn[48]; sbase=(float)(ldexp(1.0,24)); base=ldexp(1.0,48); state1=malloc(rlxs_size()*sizeof(int)); state2=malloc(rlxd_size()*sizeof(int)); rlxs_init(0,32767); rlxd_init(1,32767); /******************************************************************************* * * Check that the correct sequences of random numbers are obtained * *******************************************************************************/ for (k=0;k<20;k++) { ranlxs(xs,NXS); ranlxd(xd,NXD); } xsn[0]=13257445.0f; xsn[1]=15738482.0f; xsn[2]=5448599.0f; xsn[3]=9610459.0f; xsn[4]=1046025.0f; xsn[5]=2811360.0f; xsn[6]=14923726.0f; xsn[7]=2287739.0f; xsn[8]=16133204.0f; xsn[9]=16328320.0f; xsn[10]=12980218.0f; xsn[11]=9256959.0f; xsn[12]=5633754.0f; xsn[13]=7422961.0f; xsn[14]=6032411.0f; xsn[15]=14970828.0f; xsn[16]=10717272.0f; xsn[17]=2520878.0f; xsn[18]=8906135.0f; xsn[19]=8507426.0f; xsn[20]=11925022.0f; xsn[21]=12042827.0f; xsn[22]=12263021.0f; xsn[23]=4828801.0f; xsn[24]=5300508.0f; xsn[25]=13346776.0f; xsn[26]=10869790.0f; xsn[27]=8520207.0f; xsn[28]=11213953.0f; xsn[29]=14439320.0f; xsn[30]=5716476.0f; xsn[31]=13600448.0f; xsn[32]=12545579.0f; xsn[33]=3466523.0f; xsn[34]=113906.0f; xsn[35]=10407879.0f; xsn[36]=12058596.0f; xsn[37]=4390921.0f; xsn[38]=1634350.0f; xsn[39]=9823280.0f; xsn[40]=12569690.0f; xsn[41]=8267856.0f; xsn[42]=5869501.0f; xsn[43]=7210219.0f; xsn[44]=1362361.0f; xsn[45]=2956909.0f; xsn[46]=504465.0f; xsn[47]=6664636.0f; xsn[48]=6048963.0f; xsn[49]=1098525.0f; xsn[50]=1261330.0f; xsn[51]=2401071.0f; xsn[52]=8087317.0f; xsn[53]=1293933.0f; xsn[54]=555494.0f; xsn[55]=14872475.0f; xsn[56]=11261534.0f; xsn[57]=166813.0f; xsn[58]=13424516.0f; xsn[59]=15280818.0f; xsn[60]=4644497.0f; xsn[61]=6333595.0f; xsn[62]=10012569.0f; xsn[63]=6878028.0f; xsn[64]=9176136.0f; xsn[65]=8379433.0f; xsn[66]=11073957.0f; xsn[67]=2465529.0f; xsn[68]=13633550.0f; xsn[69]=12721649.0f; xsn[70]=569725.0f; xsn[71]=6375015.0f; xsn[72]=2164250.0f; xsn[73]=6725885.0f; xsn[74]=7223108.0f; xsn[75]=4890858.0f; xsn[76]=11298261.0f; xsn[77]=12086020.0f; xsn[78]=4447706.0f; xsn[79]=1164782.0f; xsn[80]=1904399.0f; xsn[81]=16669839.0f; xsn[82]=2586766.0f; xsn[83]=3605708.0f; xsn[84]=15761082.0f; xsn[85]=14937769.0f; xsn[86]=13965017.0f; xsn[87]=2175021.0f; xsn[88]=16668997.0f; xsn[89]=13996602.0f; xsn[90]=6313099.0f; xsn[91]=15646036.0f; xsn[92]=9746447.0f; xsn[93]=9596781.0f; xsn[94]=9244169.0f; xsn[95]=4731726.0f; xdn[0]=135665102723086.0; xdn[1]=259840970195871.0; xdn[2]=110726726657103.0; xdn[3]=53972500363809.0; xdn[4]=199301297412157.0; xdn[5]=63744794353870.0; xdn[6]=178745978725904.0; xdn[7]=243549380863176.0; xdn[8]=244796821836177.0; xdn[9]=223788809121855.0; xdn[10]=113720856430443.0; xdn[11]=124607822268499.0; xdn[12]=25705458431399.0; xdn[13]=155476863764950.0; xdn[14]=195602097736933.0; xdn[15]=183038707238950.0; xdn[16]=62268883953527.0; xdn[17]=157047615112119.0; xdn[18]=58134973897037.0; xdn[19]=26908869337679.0; xdn[20]=259927185454290.0; xdn[21]=130534606773507.0; xdn[22]=205295065526788.0; xdn[23]=40201323262686.0; xdn[24]=193822255723177.0; xdn[25]=239720285097881.0; xdn[26]=54433631586673.0; xdn[27]=31313178820772.0; xdn[28]=152904879618865.0; xdn[29]=256187025780734.0; xdn[30]=110292144635528.0; xdn[31]=26555117184469.0; xdn[32]=228913371644996.0; xdn[33]=126837665590799.0; xdn[34]=141069100232139.0; xdn[35]=96171028602910.0; xdn[36]=259271018918511.0; xdn[37]=65257892816619.0; xdn[38]=14254344610711.0; xdn[39]=137794868158301.0; xdn[40]=269703238916504.0; xdn[41]=35782602710520.0; xdn[42]=51447305327263.0; xdn[43]=247852246697199.0; xdn[44]=65072958134912.0; xdn[45]=273325640150591.0; xdn[46]=2768714666444.0; xdn[47]=173907458721736.0; test1=0; test2=0; for (k=0;k<96;k++) { if (xsn[k]!=(xs[k+60]*sbase)) test1=1; } for (k=0;k<48;k++) { if (xdn[k]!=(xd[k+39]*base)) test2=1; } if (test1==1) { printf("\n"); printf("Test failed: ranlxs gives incorrect results\n"); printf("=> do not use ranlxs on this machine\n"); printf("\n"); } if (test2==1) { printf("\n"); printf("Test failed: ranlxd gives incorrect results\n"); printf("=> do not use ranlxd on this machine\n"); printf("\n"); } /******************************************************************************* * * Check of the I/O routines * *******************************************************************************/ rlxs_get(state1); rlxd_get(state2); for (k=0;k<10;k++) { ranlxs(xs,NXS); ranlxd(xd,NXD); } rlxs_reset(state1); rlxd_reset(state2); for (k=0;k<10;k++) { ranlxs(ys,NXS); ranlxd(yd,NXD); } for (k=0;k<NXS;k++) { if (xs[k]!=ys[k]) test1=2; } for (k=0;k<NXD;k++) { if (xd[k]!=yd[k]) test2=2; } if (test1==2) { printf("\n"); printf("Test failed: I/O routines for ranlxs do not work properly\n"); printf("=> do not use ranlxs on this machine\n"); printf("\n"); } if (test2==2) { printf("\n"); printf("Test failed: I/O routines for ranlxd do not work properly\n"); printf("=> do not use ranlxd on this machine\n"); printf("\n"); } /******************************************************************************* * * Success messages * *******************************************************************************/ if ((test1==0)&&(test2==0)) { printf("\n"); printf("All tests passed\n"); printf("=> ranlxs and ranlxd work correctly on this machine\n"); printf("\n"); } else if (test1==0) { printf("\n"); printf("All tests on ranlxs passed\n"); printf("=> ranlxs works correctly on this machine\n"); printf("\n"); } else if (test2==0) { printf("\n"); printf("All tests on ranlxd passed\n"); printf("=> ranlxd works correctly on this machine\n"); printf("\n"); } exit(0); }
void online_measurement(const int traj, const int id, const int ieo) { int i, j, t, tt, t0; double *Cpp = NULL, *Cpa = NULL, *Cp4 = NULL; double res = 0., respa = 0., resp4 = 0.; double atime, etime; float tmp; operator * optr; #ifdef MPI double mpi_res = 0., mpi_respa = 0., mpi_resp4 = 0.; // send buffer for MPI_Gather double *sCpp = NULL, *sCpa = NULL, *sCp4 = NULL; #endif FILE *ofs; char *filename; char buf[100]; spinor phi; filename=buf; sprintf(filename,"%s%.6d", "onlinemeas." ,traj); init_operators(); if(no_operators < 1 && g_proc_id == 0) { if(g_proc_id == 0) { fprintf(stderr, "Warning! no operators defined in input file, cannot perform online correlator mesurements!\n"); } return; } if(no_operators > 1 && g_proc_id == 0) { fprintf(stderr, "Warning! number of operators defined larger than 1, using only the first!\n"); } optr = &operator_list[0]; // we don't want to do inversion twice for this purpose here optr->DownProp = 0; if(optr->type != TMWILSON && optr->type != WILSON && optr->type != CLOVER) { if(g_proc_id == 0) { fprintf(stderr, "Warning! correlator online measurement currently only implemented for TMWILSON, WILSON and CLOVER\n"); fprintf(stderr, "Cannot perform online measurement!\n"); } return; } /* generate random timeslice */ if(ranlxs_init == 0) { rlxs_init(1, 123456); } ranlxs(&tmp, 1); t0 = (int)(measurement_list[id].max_source_slice*tmp); #ifdef MPI MPI_Bcast(&t0, 1, MPI_INT, 0, MPI_COMM_WORLD); #endif if(g_debug_level > 1 && g_proc_id == 0) { printf("# timeslice set to %d (T=%d) for online measurement\n", t0, g_nproc_t*T); printf("# online measurements parameters: kappa = %g, mu = %g\n", g_kappa, g_mu/2./g_kappa); } atime = gettime(); #ifdef MPI sCpp = (double*) calloc(T, sizeof(double)); sCpa = (double*) calloc(T, sizeof(double)); sCp4 = (double*) calloc(T, sizeof(double)); if(g_mpi_time_rank == 0) { Cpp = (double*) calloc(g_nproc_t*T, sizeof(double)); Cpa = (double*) calloc(g_nproc_t*T, sizeof(double)); Cp4 = (double*) calloc(g_nproc_t*T, sizeof(double)); } #else Cpp = (double*) calloc(T, sizeof(double)); Cpa = (double*) calloc(T, sizeof(double)); Cp4 = (double*) calloc(T, sizeof(double)); #endif source_generation_pion_only(g_spinor_field[0], g_spinor_field[1], t0, 0, traj); optr->sr0 = g_spinor_field[0]; optr->sr1 = g_spinor_field[1]; optr->prop0 = g_spinor_field[2]; optr->prop1 = g_spinor_field[3]; // op_id = 0, index_start = 0, write_prop = 0 optr->inverter(0, 0, 0); /* now we bring it to normal format */ /* here we use implicitly DUM_MATRIX and DUM_MATRIX+1 */ convert_eo_to_lexic(g_spinor_field[DUM_MATRIX], g_spinor_field[2], g_spinor_field[3]); /* now we sum only over local space for every t */ for(t = 0; t < T; t++) { j = g_ipt[t][0][0][0]; res = 0.; respa = 0.; resp4 = 0.; for(i = j; i < j+LX*LY*LZ; i++) { res += _spinor_prod_re(g_spinor_field[DUM_MATRIX][j], g_spinor_field[DUM_MATRIX][j]); _gamma0(phi, g_spinor_field[DUM_MATRIX][j]); respa += _spinor_prod_re(g_spinor_field[DUM_MATRIX][j], phi); _gamma5(phi, phi); resp4 += _spinor_prod_im(g_spinor_field[DUM_MATRIX][j], phi); } #if defined MPI MPI_Reduce(&res, &mpi_res, 1, MPI_DOUBLE, MPI_SUM, 0, g_mpi_time_slices); res = mpi_res; MPI_Reduce(&respa, &mpi_respa, 1, MPI_DOUBLE, MPI_SUM, 0, g_mpi_time_slices); respa = mpi_respa; MPI_Reduce(&resp4, &mpi_resp4, 1, MPI_DOUBLE, MPI_SUM, 0, g_mpi_time_slices); resp4 = mpi_resp4; sCpp[t] = +res/(g_nproc_x*LX)/(g_nproc_y*LY)/(g_nproc_z*LZ)*2.; sCpa[t] = -respa/(g_nproc_x*LX)/(g_nproc_y*LY)/(g_nproc_z*LZ)*2.; sCp4[t] = +resp4/(g_nproc_x*LX)/(g_nproc_y*LY)/(g_nproc_z*LZ)*2.; #else Cpp[t] = +res/(g_nproc_x*LX)/(g_nproc_y*LY)/(g_nproc_z*LZ)*2.; Cpa[t] = -respa/(g_nproc_x*LX)/(g_nproc_y*LY)/(g_nproc_z*LZ)*2.; Cp4[t] = +resp4/(g_nproc_x*LX)/(g_nproc_y*LY)/(g_nproc_z*LZ)*2.; #endif } #ifdef MPI /* some gymnastics needed in case of parallelisation */ if(g_mpi_time_rank == 0) { MPI_Gather(sCpp, T, MPI_DOUBLE, Cpp, T, MPI_DOUBLE, 0, g_mpi_SV_slices); MPI_Gather(sCpa, T, MPI_DOUBLE, Cpa, T, MPI_DOUBLE, 0, g_mpi_SV_slices); MPI_Gather(sCp4, T, MPI_DOUBLE, Cp4, T, MPI_DOUBLE, 0, g_mpi_SV_slices); } #endif /* and write everything into a file */ if(g_mpi_time_rank == 0 && g_proc_coords[0] == 0) { ofs = fopen(filename, "w"); fprintf( ofs, "1 1 0 %e %e\n", Cpp[t0], 0.); for(t = 1; t < g_nproc_t*T/2; t++) { tt = (t0+t)%(g_nproc_t*T); fprintf( ofs, "1 1 %d %e ", t, Cpp[tt]); tt = (t0+g_nproc_t*T-t)%(g_nproc_t*T); fprintf( ofs, "%e\n", Cpp[tt]); } tt = (t0+g_nproc_t*T/2)%(g_nproc_t*T); fprintf( ofs, "1 1 %d %e %e\n", t, Cpp[tt], 0.); fprintf( ofs, "2 1 0 %e %e\n", Cpa[t0], 0.); for(t = 1; t < g_nproc_t*T/2; t++) { tt = (t0+t)%(g_nproc_t*T); fprintf( ofs, "2 1 %d %e ", t, Cpa[tt]); tt = (t0+g_nproc_t*T-t)%(g_nproc_t*T); fprintf( ofs, "%e\n", Cpa[tt]); } tt = (t0+g_nproc_t*T/2)%(g_nproc_t*T); fprintf( ofs, "2 1 %d %e %e\n", t, Cpa[tt], 0.); fprintf( ofs, "6 1 0 %e %e\n", Cp4[t0], 0.); for(t = 1; t < g_nproc_t*T/2; t++) { tt = (t0+t)%(g_nproc_t*T); fprintf( ofs, "6 1 %d %e ", t, Cp4[tt]); tt = (t0+g_nproc_t*T-t)%(g_nproc_t*T); fprintf( ofs, "%e\n", Cp4[tt]); } tt = (t0+g_nproc_t*T/2)%(g_nproc_t*T); fprintf( ofs, "6 1 %d %e %e\n", t, Cp4[tt], 0.); fclose(ofs); } #ifdef MPI if(g_mpi_time_rank == 0) { free(Cpp); free(Cpa); free(Cp4); } free(sCpp); free(sCpa); free(sCp4); #else free(Cpp); free(Cpa); free(Cp4); #endif etime = gettime(); if(g_proc_id == 0 && g_debug_level > 0) { printf("ONLINE: measurement done int t/s = %1.4e\n", etime - atime); } return; }
void pion_norm(const int traj, const int id) { int i, j, z, zz, z0; double *Cpp; double res = 0.; double pionnorm; double atime, etime; float tmp; #ifdef MPI double mpi_res = 0.; #endif FILE *ofs, *ofs2; char *filename, *filename2, *sourcefilename; char buf[100]; char buf2[100]; char buf3[100]; filename=buf; filename2=buf2; sourcefilename=buf3; sprintf(filename,"pionnormcorrelator_finiteT.%.6d",traj); sprintf(filename2,"%s", "pion_norm.data"); /* generate random source point */ if(ranlxs_init == 0) { rlxs_init(1, 123456); } ranlxs(&tmp, 1); z0 = (int)(measurement_list[id].max_source_slice*tmp); #ifdef MPI MPI_Bcast(&z0, 1, MPI_INT, 0, MPI_COMM_WORLD); #endif #ifdef MPI atime = MPI_Wtime(); #else atime = (double)clock()/(double)(CLOCKS_PER_SEC); #endif Cpp = (double*) calloc(g_nproc_z*LZ, sizeof(double)); printf("Doing finite Temperature online measurement\n"); /* stochastic source in z-slice */ source_generation_pion_zdir(g_spinor_field[0], g_spinor_field[1], z0, 0, traj); /* invert on the stochastic source */ invert_eo(g_spinor_field[2], g_spinor_field[3], g_spinor_field[0], g_spinor_field[1], 1.e-14, measurement_list[id].max_iter, CG, 1, 0, 1, 0, NULL, -1); /* now we bring it to normal format */ /* here we use implicitly DUM_MATRIX and DUM_MATRIX+1 */ convert_eo_to_lexic(g_spinor_field[DUM_MATRIX], g_spinor_field[2], g_spinor_field[3]); /* now we sums only over local space for every z */ for(z = 0; z < LZ; z++) { res = 0.; /* sum here over all points in one z-slice we have to look up g_ipt*/ j = g_ipt[0][0][0][z]; for(i = 0; i < T*LX*LY ; i++) { res += _spinor_prod_re(g_spinor_field[DUM_MATRIX][j], g_spinor_field[DUM_MATRIX][j]); j += LZ; /* jump LZ sites in array, z ist fastest index */ } #if defined MPI MPI_Reduce(&res, &mpi_res, 1, MPI_DOUBLE, MPI_SUM, 0, g_mpi_z_slices); res = mpi_res; #endif Cpp[z+g_proc_coords[3]*LZ] = +res/(g_nproc_x*LX)/(g_nproc_y*LY)/(g_nproc_t*T)*2.; } #ifdef MPI /* some gymnastics needed in case of parallelisation */ if(g_mpi_z_rank == 0) { MPI_Gather(&Cpp[g_proc_coords[3]*LZ], LZ, MPI_DOUBLE, Cpp, LZ, MPI_DOUBLE, 0, g_mpi_ST_slices); } #endif /* and write everything into a file */ if(g_mpi_z_rank == 0 && g_proc_coords[3] == 0) { ofs = fopen(filename, "w"); fprintf( ofs, "1 1 0 %e %e\n", Cpp[z0], 0.); for(z = 1; z < g_nproc_z*LZ/2; z++) { zz = (z0+z)%(g_nproc_z*LZ); fprintf( ofs, "1 1 %d %e ", z, Cpp[zz]); zz = (z0+g_nproc_z*LZ-z)%(g_nproc_z*LZ); fprintf( ofs, "%e\n", Cpp[zz]); } zz = (z0+g_nproc_z*LZ/2)%(g_nproc_z*LZ); fprintf( ofs, "1 1 %d %e %e\n", z, Cpp[zz], 0.); fclose(ofs); /* sum over all Cpp to get pionnorm*/ ofs2 = fopen(filename2, "a"); pionnorm = 0.; for(z=0; z<g_nproc_z*LZ; z++){ pionnorm += Cpp[z]; } /* normalize */ pionnorm = pionnorm/(g_nproc_z*LZ); fprintf(ofs2,"%d\t %.16e\n",traj,pionnorm); fclose(ofs2); } free(Cpp); #ifdef MPI etime = MPI_Wtime(); #else etime = (double)clock()/(double)(CLOCKS_PER_SEC); #endif if(g_proc_id == 0 && g_debug_level > 0) { printf("PIONNORM : measurement done int t/s = %1.4e\n", etime - atime); } return; }
void online_measurement(const int traj, const int id) { int i, j, t, tt, t0; double *Cpp, *Cpa, *Cp4; double res = 0., respa = 0., resp4 = 0.; double atime, etime; float tmp; #ifdef MPI double mpi_res = 0., mpi_respa = 0., mpi_resp4 = 0.; #endif FILE *ofs; char *filename; char buf[100]; spinor phi; filename=buf; sprintf(filename,"%s%.6d", "onlinemeas." ,traj); /* generate random timeslice */ if(ranlxs_init == 0) { rlxs_init(1, 123456); } ranlxs(&tmp, 1); t0 = (int)(measurement_list[id].max_source_slice*tmp); #ifdef MPI MPI_Bcast(&t0, 1, MPI_INT, 0, MPI_COMM_WORLD); #endif if(g_debug_level > 1 && g_proc_id == 0) { printf("# timeslice set to %d (T=%d) for online measurement\n", t0, g_nproc_t*T); printf("# online measurements parameters: kappa = %g, mu = %g\n", g_kappa, g_mu/2./g_kappa); } #ifdef MPI atime = MPI_Wtime(); #else atime = (double)clock()/(double)(CLOCKS_PER_SEC); #endif Cpp = (double*) calloc(g_nproc_t*T, sizeof(double)); Cpa = (double*) calloc(g_nproc_t*T, sizeof(double)); Cp4 = (double*) calloc(g_nproc_t*T, sizeof(double)); source_generation_pion_only(g_spinor_field[0], g_spinor_field[1], t0, 0, traj); invert_eo(g_spinor_field[2], g_spinor_field[3], g_spinor_field[0], g_spinor_field[1], 1.e-14, measurement_list[id].max_iter, CG, 1, 0, 1, 0, NULL, -1); /* now we bring it to normal format */ /* here we use implicitly DUM_MATRIX and DUM_MATRIX+1 */ convert_eo_to_lexic(g_spinor_field[DUM_MATRIX], g_spinor_field[2], g_spinor_field[3]); /* now we sum only over local space for every t */ for(t = 0; t < T; t++) { j = g_ipt[t][0][0][0]; res = 0.; respa = 0.; resp4 = 0.; for(i = j; i < j+LX*LY*LZ; i++) { res += _spinor_prod_re(g_spinor_field[DUM_MATRIX][j], g_spinor_field[DUM_MATRIX][j]); _gamma0(phi, g_spinor_field[DUM_MATRIX][j]); respa += _spinor_prod_re(g_spinor_field[DUM_MATRIX][j], phi); _gamma5(phi, phi); resp4 += _spinor_prod_im(g_spinor_field[DUM_MATRIX][j], phi); } #if defined MPI MPI_Reduce(&res, &mpi_res, 1, MPI_DOUBLE, MPI_SUM, 0, g_mpi_time_slices); res = mpi_res; MPI_Reduce(&respa, &mpi_respa, 1, MPI_DOUBLE, MPI_SUM, 0, g_mpi_time_slices); respa = mpi_respa; MPI_Reduce(&resp4, &mpi_resp4, 1, MPI_DOUBLE, MPI_SUM, 0, g_mpi_time_slices); resp4 = mpi_resp4; #endif Cpp[t+g_proc_coords[0]*T] = +res/(g_nproc_x*LX)/(g_nproc_y*LY)/(g_nproc_z*LZ)*2.; Cpa[t+g_proc_coords[0]*T] = -respa/(g_nproc_x*LX)/(g_nproc_y*LY)/(g_nproc_z*LZ)*2.; Cp4[t+g_proc_coords[0]*T] = +resp4/(g_nproc_x*LX)/(g_nproc_y*LY)/(g_nproc_z*LZ)*2.; } #ifdef MPI /* some gymnastics needed in case of parallelisation */ if(g_mpi_time_rank == 0) { MPI_Gather(&Cpp[g_proc_coords[0]*T], T, MPI_DOUBLE, Cpp, T, MPI_DOUBLE, 0, g_mpi_SV_slices); MPI_Gather(&Cpa[g_proc_coords[0]*T], T, MPI_DOUBLE, Cpa, T, MPI_DOUBLE, 0, g_mpi_SV_slices); MPI_Gather(&Cp4[g_proc_coords[0]*T], T, MPI_DOUBLE, Cp4, T, MPI_DOUBLE, 0, g_mpi_SV_slices); } #endif /* and write everything into a file */ if(g_mpi_time_rank == 0 && g_proc_coords[0] == 0) { ofs = fopen(filename, "w"); fprintf( ofs, "1 1 0 %e %e\n", Cpp[t0], 0.); for(t = 1; t < g_nproc_t*T/2; t++) { tt = (t0+t)%(g_nproc_t*T); fprintf( ofs, "1 1 %d %e ", t, Cpp[tt]); tt = (t0+g_nproc_t*T-t)%(g_nproc_t*T); fprintf( ofs, "%e\n", Cpp[tt]); } tt = (t0+g_nproc_t*T/2)%(g_nproc_t*T); fprintf( ofs, "1 1 %d %e %e\n", t, Cpp[tt], 0.); fprintf( ofs, "2 1 0 %e %e\n", Cpa[t0], 0.); for(t = 1; t < g_nproc_t*T/2; t++) { tt = (t0+t)%(g_nproc_t*T); fprintf( ofs, "2 1 %d %e ", t, Cpa[tt]); tt = (t0+g_nproc_t*T-t)%(g_nproc_t*T); fprintf( ofs, "%e\n", Cpa[tt]); } tt = (t0+g_nproc_t*T/2)%(g_nproc_t*T); fprintf( ofs, "2 1 %d %e %e\n", t, Cpa[tt], 0.); fprintf( ofs, "6 1 0 %e %e\n", Cp4[t0], 0.); for(t = 1; t < g_nproc_t*T/2; t++) { tt = (t0+t)%(g_nproc_t*T); fprintf( ofs, "6 1 %d %e ", t, Cp4[tt]); tt = (t0+g_nproc_t*T-t)%(g_nproc_t*T); fprintf( ofs, "%e\n", Cp4[tt]); } tt = (t0+g_nproc_t*T/2)%(g_nproc_t*T); fprintf( ofs, "6 1 %d %e %e\n", t, Cp4[tt], 0.); fclose(ofs); } free(Cpp); free(Cpa); free(Cp4); #ifdef MPI etime = MPI_Wtime(); #else etime = (double)clock()/(double)(CLOCKS_PER_SEC); #endif if(g_proc_id == 0 && g_debug_level > 0) { printf("ONLINE: measurement done int t/s = %1.4e\n", etime - atime); } return; }