Ejemplo n.º 1
0
int read_qdppp_lattice_fermion_double(int latdims[], double  *LatticeFermion, char *fin)
{

    long int buff_size=latdims[0]*latdims[1]*latdims[2]*latdims[3]*4*3*2*8; /*size in bytes of a single precision lattice fermion*/
    int num_elem=buff_size/8;
    int check_reading;

    check_reading=read_qdppp_scidac_binary_data((void *)LatticeFermion, buff_size,fin);

    if(check_reading == EXIT_FAILURE)
    {
        fprintf(stderr,"Error reading SCIDAC binary data\n");
        exit(EXIT_FAILURE);
    }

    /*test the machine endianness*/
    int check_end=endianness();

    if(check_end == UNKNOWN_ENDIAN)
    {
       fprintf(stderr,"Error: machine endianess is unknown.\n");
       exit(EXIT_FAILURE);
    }

    if(check_end == BIG_ENDIAN)
      return;   /*no swapping is needed*/

    if(check_end == LITTLE_ENDIAN)
      bswap_double(num_elem,LatticeFermion);

    return;   
}
Ejemplo n.º 2
0
extern void import_cnfg_ildg(char *in)
{
   int my_rank,np[4],n,ie,tag,status,prec=0;
   int i,l,ix,iy,iz,it,ixx;
   n_uint64_t read_bytes,nbytes=0;
   double plaq1,eps;
   MPI_Status stat;
   LimeReader *reader=NULL;
   FILE *fin;
   char lime_type_target[100]="ildg-binary-data";
   char *lime_type;
   MPI_Comm_rank(MPI_COMM_WORLD,&my_rank);

   /* allocate IO-buffers */
   if (ubuf==NULL)
      alloc_ubuf_ildg(my_rank);

   error(pud[VOLUME/2][0]==NULL,1,"import_cnfg [archive_ildg.c]",
         "Double-precision gauge field is not allocated");
   ie=check_machine();   

   if (my_rank==0)
   {
     fin=fopen(in,"rb");
     error_root(fin==NULL,1,"import_cnfg  [archive_ildg.c]",
               	"Unable to open input file");
     reader=limeCreateReader(fin);
     error( reader == (LimeReader *)NULL ,1,"import_cnfg [archive_ildg.c]",
    		"Unable to open LimeReader");
     nbytes = (n_uint64_t)0;

     /* set the file-pointer to the beginning of the "ildg-binary-data" tag
      * in the LIME file */
     while( (status = limeReaderNextRecord(reader)) != LIME_EOF ){
       nbytes    = limeReaderBytes(reader);
       lime_type = limeReaderType(reader);
       error((status!=LIME_SUCCESS),1,"import_cnfg [archive_ildg.c]",
       	     "limeReaderNextRecord returned status %d and LIME_SUCCESS %d\n",
       status,LIME_SUCCESS);
       if (strcmp(lime_type,lime_type_target) != 0) continue;
        break;
     }
     /* Decide whether the gauge file is stored in single or
      * double precision format */
     if ((int)nbytes==8*VOLUME*NPROC*3*3*4*2){
       prec=8; 
       message("ILDG-file contains double precision gauge field\n");
     }
     else if ((int)nbytes==4*VOLUME*NPROC*3*3*4*2){
       prec=4; 
       message("ILDG-file contains single precision gauge field\n");
     }
     else
     error(1!=0,1,"import_cnfg [archive_ildg]",
		"Lattice geometry doesn't match size of gauge field %d %d\n");
   }
   /* Now read the gauge file in steps of 4 SU(3) matrices */
   for (it=0;it<N0;it++){
    for (iz=0;iz<N3;iz++){
     for (iy=0;iy<N2;iy++){
      for (ix=0;ix<N1;ix++){
	if(my_rank==0){
         if(prec==8){
          read_bytes = (n_uint64_t)(4*18*sizeof(double));
          status = limeReaderReadData((double *)vbuf,&read_bytes, reader);
	  bswap_double(4*18,(double *)(vbuf));/* ILDG always big endian */
         }
	 else if(prec==4){
          read_bytes = (n_uint64_t)(4*18*sizeof(float));
          status = limeReaderReadData((void *)vbuf_s,&read_bytes, reader);
	  bswap_float(4*18,(float *)(vbuf_s)); /* ILDG always big endian */
         for (i=0;i<4;i++)
	  su3_copy_singletodouble((vbuf_s+i),(vbuf+i));
         }
	}
        np[0]=it;
        np[1]=ix;
        np[2]=iy;
        np[3]=iz;
        n=ipr_global(np);
        MPI_Barrier(MPI_COMM_WORLD);
            if (n>0)
            {
               tag=mpi_tag();

               if (my_rank==0)
                  MPI_Send((double*)(vbuf),4*18,MPI_DOUBLE,n,tag,
                           MPI_COMM_WORLD);

               if (my_rank==n)
                  MPI_Recv((double*)(ubuf),4*18,MPI_DOUBLE,0,tag,
                           MPI_COMM_WORLD,&stat);
            }
            else if (my_rank==0)
               for (l=0;l<(4);l++)
                  ubuf[l]=vbuf[l];

            ixx = ((iy%L2)*L3 + (ix%L1)*L3*L2 + (it%L0)*L1*L2*L3);
            if (my_rank==n)
               set_links_ildg(ixx,iz);
      }
     }
    }
   }

   plaq1=plaq_sum_dble()/(double)(6*NPROC*VOLUME);
   message("Plaquette   %f\n",plaq1);
   message("Plaquette/3 %f\n",plaq1/3);
   message("Please check consistency of average plaquette by hand\n");
   eps=sqrt((double)(6*NPROC*VOLUME))*DBL_EPSILON;
}