コード例 #1
0
ファイル: io_scidac.c プロジェクト: zzmjohn/milc_qcd
static gauge_file *restore_scidac(char *filename, int serpar){
  QIO_Layout layout;
  QIO_Filesystem fs;
  QIO_Reader *infile;
  QIO_RecordInfo recinfo;
  QIO_String *recxml;
  int status;
  int typesize;
  field_offset dest = F_OFFSET(link[0]);
  gauge_file *gf;

  QIO_verbose(QIO_VERB_OFF);

  /* Build the layout structure */
  build_qio_layout(&layout);

  /* Define the I/O nodes */
  build_qio_filesystem(&fs);

  /* Make a dummy gauge file structure for MILC use */
  gf = setup_input_gauge_file(filename);

  /* Set the filename in the gauge_file structure */
  gf->filename = filename;

  /* Open file for reading */
  infile = open_scidac_input(filename, &layout, &fs, serpar);
  if(infile == NULL)terminate(1);

  /* Check the record type (double or single precision) */
  recxml = QIO_string_create();
  status = QIO_read_record_info(infile, &recinfo, recxml);
  if(status)terminate(1);
  typesize = QIO_get_typesize(&recinfo);

  /* Read the lattice field as single or double precision according to
     the type size (bytes in a single SU(3) matrix) */
  if(typesize == 72)
    status = read_F3_M_to_site(infile, recxml, dest, LATDIM);
  else if (typesize == 144)
    status = read_D3_M_to_site(infile, recxml, dest, LATDIM);
  else
    {
      node0_printf("restore_scidac: Bad typesize %d\n",typesize);
      terminate(1);
    }
  if(status)terminate(1);

  /* Discard for now */
  QIO_string_destroy(recxml);

  /* Close the file */
  QIO_close_read(infile);

  return gf;
}
コード例 #2
0
ファイル: io_lat_utils.c プロジェクト: daschaich/fourfermion
// -----------------------------------------------------------------
// Return file descriptor for opened file
gauge_file* r_serial_i(char *filename) {
  gauge_header *gh;
  gauge_file *gf;
  FILE *fp;
  int byterevflag;
  char editfilename[513];

  /* All nodes set up a gauge file and gauge header structure for reading */
  gf = setup_input_gauge_file(filename);
  gh = gf->header;

  /* Node 0 alone opens the file and reads the header */
  g_sync();
  if (this_node == 0) {
    fp = fopen(filename, "rb");
    if (fp == NULL) {
      /* If this is a partition format SciDAC file the node0 name
         has an extension ".vol0000".  So try again. */
      printf("r_serial_i: Node %d can't open file %s, error %d\n",
          this_node,filename,errno);fflush(stdout);
      strncpy(editfilename,filename,504);
      editfilename[504] = '\0';  /* Just in case of truncation */
      strcat(editfilename,".vol0000");
      printf("r_serial_i: Trying SciDAC partition volume %s\n",editfilename);
      fp = fopen(editfilename, "rb");
      if (fp == NULL) {
        printf("r_serial_i: Node %d can't open file %s, error %d\n",
               this_node,editfilename,errno);fflush(stdout);terminate(1);
      }
      printf("r_serial_i: Open succeeded\n");
    }

    gf->fp = fp;

    byterevflag = read_gauge_hdr(gf);
  }

  else gf->fp = NULL;  /* The other nodes don't know about this file */

  // Broadcast the byterevflag and header structure from node0 to all nodes
  broadcast_bytes((char *)&byterevflag, sizeof(byterevflag));
  gf->byterevflag = byterevflag;
  broadcast_bytes((char *)gh,sizeof(gauge_header));

  // No further processing here if this is a SciDAC file
  if (gh->magic_number == LIME_MAGIC_NO)
    return gf;

  // Read site list and broadcast to all nodes
  read_site_list(gf);

  return gf;
}
コード例 #3
0
ファイル: io_scidac.c プロジェクト: zzmjohn/milc_qcd
static gauge_file *file_scan_scidac(char *filename, int serpar){
  QIO_Layout layout;
  QIO_Filesystem fs;
  QIO_Reader *infile;
  QIO_RecordInfo recinfo;
  QIO_String *recxml;
  int status;
  int typesize;
  su3_matrix *dest = NULL;
  gauge_file *gf;
  int ndim;
  int dims[4];

  /* Read header to get lattice dimensions and close the file */
  read_lat_dim_scidac(filename, &ndim, dims);
  nx = dims[0]; ny = dims[1]; nz = dims[2]; nt = dims[3];
  volume = nx*ny*nz*nt;

  /* Finish setting up, now we know the dimensions */

  broadcast_bytes((char *)&nx,sizeof(int));
  broadcast_bytes((char *)&ny,sizeof(int));
  broadcast_bytes((char *)&nz,sizeof(int));
  broadcast_bytes((char *)&nt,sizeof(int));
  
  setup_layout();

  /* Build the layout structure */
  build_qio_layout(&layout);

  /* Define the I/O nodes */
  build_qio_filesystem(&fs);

  /* Make a dummy gauge file structure for MILC use */
  gf = setup_input_gauge_file(filename);

  /* Set the filename in the gauge_file structure */
  gf->filename = filename;

  /* Reopen file for reading */
  QIO_verbose(QIO_VERB_OFF);

  infile = open_scidac_input(filename, &layout, &fs, serpar);
  if(infile == NULL)terminate(1);

  /* Check the record type (double or single precision) */
  recxml = QIO_string_create();
  status = QIO_read_record_info(infile, &recinfo, recxml);
  if(status)terminate(1);
  typesize = QIO_get_typesize(&recinfo);

  /* Read the lattice field as single or double precision according to
     the type size (bytes in a single SU(3) matrix) */
  if(typesize == 72)
    status = read_F3_M_to_null(infile, recxml, dest, LATDIM);
  else if (typesize == 144)
    status = read_D3_M_to_null(infile, recxml, dest, LATDIM);
  else
    {
      node0_printf("file_scan_scidac: Bad typesize %d\n",typesize);
      terminate(1);
    }
  if(status){
    node0_printf("ERROR scanning file\n");
  } else {
    node0_printf("SUCCESS scanning file\n");
  }

  /* Discard for now */
  QIO_string_destroy(recxml);

  /* Close the file */
  QIO_close_read(infile);

  return gf;
}