Copies u11 and u12 into arrays without halos which then get written to output.
342 {
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358 const char *funcname = "par_swrite";
359 #if (nproc>1)
360 MPI_Status status;
361
362 MPI_Datatype MPI_SEED_TYPE = (
sizeof(
seed)==
sizeof(int)) ? MPI_INT:MPI_LONG;
363 #endif
366#ifdef _DEBUG
367 char dump_prefix[
FILELEN]=
"u11.";
368 char dump_buff[32];
369 sprintf(dump_buff,
"r%01d_c%06d",
rank,itraj);
370 strcat(dump_prefix,dump_buff);
371 FILE *gauge_dump=fopen(dump_prefix,"wb");
372
373
375 fclose(gauge_dump);
376#endif
377#ifdef __RANLUX__
378 seed=gsl_rng_get(ranlux_instd);
379#endif
381
382#ifdef __RANLUX__
383 unsigned long *seed_array=(
unsigned long*)calloc(
nproc,
sizeof(
seed));
384#elif defined __INTEL_MKL__ && !defined USE_RAN2
385 int *seed_array=(
int *)calloc(
nproc,
sizeof(
seed));
386#else
387 long *seed_array=(
long*)calloc(
nproc,
sizeof(
seed));
388#endif
390#if(nproc>1)
391 for(
int iproc = 1; iproc<
nproc; iproc++)
392 if(MPI_Recv(&seed_array[iproc], 1, MPI_SEED_TYPE,iproc, 1, comm, &status)){
393 fprintf(stderr, "Error %i in %s: Failed to receive seed from process %i.\nExiting...\n\n",
394 CANTRECV, funcname, iproc);
395 MPI_Abort(comm,CANTRECV);
396 }
397#endif
400
401 for(
int iproc=0;iproc<
nproc;iproc++)
402 for(
int idim=0;idim<
ndim;idim++){
403#if(nproc>1)
404 if(iproc){
405 if(MPI_Recv(u1buff,
kvol, MPI_C_DOUBLE_COMPLEX, iproc, 2*idim, comm, &status)){
406 fprintf(stderr, "Error %i in %s: Falied to receive u11 from process %i.\nExiting...\n\n",
407 CANTRECV, funcname, iproc);
408 MPI_Abort(comm,CANTRECV);
409 }
410 if(MPI_Recv(u2buff,
kvol, MPI_C_DOUBLE_COMPLEX, iproc, 2*idim+1, comm, &status)){
411 fprintf(stderr, "Error %i in %s: Falied to receive u12 from process %i.\nExiting...\n\n",
412 CANTRECV, funcname, iproc);
413 MPI_Abort(comm,CANTRECV);
414 }
415 }
416 else{
417#endif
418
419
420#if defined USE_BLAS
421 cblas_zcopy(
kvol,u11+idim,
ndim,u1buff,1);
422 cblas_zcopy(
kvol,u12+idim,
ndim,u2buff,1);
423#else
424#pragma omp parallel for simd aligned(u11,u12,u1buff,u2buff:AVX)
425 for(
int i=0;i<
kvol;i++){
426 u1buff[i]=u11[i*
ndim+idim];
427 u2buff[i]=u12[i*
ndim+idim];
428 }
429#endif
430#ifdef _DEBUG
432 strcat(part_dump,dump_prefix);
433 sprintf(dump_buff,"_d%d",idim);
434 strcat(part_dump,dump_buff);
435 FILE *pdump=fopen(part_dump,"wb");
437 fclose(pdump);
438#endif
439#if(nproc>1)
440 }
441#endif
442 int i=0;
443 for(
int it=
pstart[3][iproc]; it<
pstop[3][iproc]; it++)
444 for(
int iz=
pstart[2][iproc]; iz<
pstop[2][iproc]; iz++)
445 for(
int iy=
pstart[1][iproc]; iy<
pstop[1][iproc]; iy++)
446 for(
int ix=
pstart[0][iproc]; ix<
pstop[0][iproc]; ix++){
447
449 u11Write[idim*
gvol+j] = u1buff[i];
450 u12Write[idim*
gvol+j] = u2buff[i];
451
452 i++;
453 }
455 fprintf(stderr, "Error %i in %s: Number of elements %i is not equal to\
456 kvol %i.\nExiting...\n\n", NUMELEM, funcname, i,
kvol);
457#if(nproc>1)
458 MPI_Abort(comm,NUMELEM);
459#else
460 exit(NUMELEM);
461#endif
462 }
463 }
464 free(u1buff); free(u2buff);
465
466 char gauge_title[
FILELEN]=
"config.";
467 int buffer; char buff2[7];
468
469 buffer = (int)round(100*beta);
470 sprintf(buff2,"b%03d",buffer);
471 strcat(gauge_title,buff2);
472
473 buffer = (int)round(10000*akappa);
474 sprintf(buff2,"k%04d",buffer);
475 strcat(gauge_title,buff2);
476
477 buffer = (int)round(1000*fmu);
478 sprintf(buff2,"mu%04d",buffer);
479 strcat(gauge_title,buff2);
480
481 buffer = (int)round(1000*creal(ajq));
482 sprintf(buff2,"j%03d",buffer);
483 strcat(gauge_title,buff2);
484
485 sprintf(buff2,
"s%02d",
nx);
486 strcat(gauge_title,buff2);
487
488 sprintf(buff2,
"t%02d",
nt);
489 strcat(gauge_title,buff2);
490
492 strcpy(gauge_file,gauge_title);
493 char c[8];
494 sprintf(c,".%06d", itraj);
495 strcat(gauge_file, c);
496 printf("Gauge file name is %s\n", gauge_file);
497 printf(
"Writing the gauge file on processor %i.\n",
rank);
498 FILE *con;
499 char *fileop = "wb";
500 if(!(con=fopen(gauge_file, fileop))){
501 fprintf(stderr, "Error %i in %s: Failed to open %s for %s.\
502 \nExiting...\n\n", OPENERROR, funcname, gauge_file, fileop);
503#if(nproc>1)
504 MPI_Abort(comm,OPENERROR);
505#else
506 exit(OPENERROR);
507#endif
508 }
509
510
511#if(nproc==1)
513#endif
514 fwrite(&
size,
sizeof(
int),1,con);
517
518
519 fwrite(seed_array,
nproc*
sizeof(
seed), 1, con);
520 fclose(con);
521 free(u11Write); free(u12Write);
522 free(seed_array);
523 }
524#if(nproc>1)
525 else{
527 fprintf(stderr, "Error %i in %s: Falied to send u11 from process %i.\nExiting...\n\n",
528 CANTSEND, funcname,
rank);
529 MPI_Abort(comm,CANTSEND);
530 }
531 for(
int idim = 0; idim<
ndim; idim++){
532#if defined USE_BLAS
533 cblas_zcopy(
kvol,u11+idim,
ndim,u1buff,1);
534 cblas_zcopy(
kvol,u12+idim,
ndim,u2buff,1);
535#else
536#pragma omp parallel for simd aligned(u11,u12,u1buff,u2buff:AVX)
537 for(
int i=0;i<
kvol;i++){
538 u1buff[i]=u11[i*
ndim+idim];
539 u2buff[i]=u12[i*
ndim+idim];
540 }
541#endif
542#ifdef _DEBUG
544 strcat(part_dump,dump_prefix);
545 sprintf(dump_buff,"_d%d",idim);
546 strcat(part_dump,dump_buff);
547 FILE *pdump=fopen(part_dump,"wb");
549 fclose(pdump);
550#endif
551 int i=0;
552 if(MPI_Send(u1buff,
kvol, MPI_C_DOUBLE_COMPLEX,
masterproc, 2*idim, comm)){
553 fprintf(stderr, "Error %i in %s: Falied to send u11 from process %i.\nExiting...\n\n",
554 CANTSEND, funcname,
rank);
555 MPI_Abort(comm,CANTSEND);
556 }
557 if(MPI_Send(u2buff,
kvol, MPI_C_DOUBLE_COMPLEX,
masterproc, 2*idim+1, comm)){
558 fprintf(stderr, "Error %i in %s: Falied to send u12 from process %i.\nExiting...\n\n",
559 CANTSEND, funcname,
rank);
560 MPI_Abort(comm,CANTSEND);
561 }
562 }
563 free(u1buff); free(u2buff);
564 }
565#endif
566 return 0;
567}