Exemplo n.º 1
0
QIO_Writer *open_test_output(char *filename, int volfmt, 
			     int serpar, int ildgstyle, char *myname){
  QIO_String *xml_file_out;
  char xml_write_file[] = "Dummy user file XML";
  QIO_Writer *outfile;
  QIO_Oflag oflag;

  oflag.serpar = serpar;
  oflag.ildgstyle = ildgstyle;
  oflag.ildgLFN = QIO_string_create();
  QIO_string_set(oflag.ildgLFN,"TestLFN");
  oflag.mode = QIO_TRUNC;

  QIO_verbose(QIO_VERB_DEBUG);

  /* Create the file XML */
  xml_file_out = QIO_string_create();
  QIO_string_set(xml_file_out,xml_write_file);

  /* Open the file for writing */
  outfile = QIO_open_write(xml_file_out, filename, volfmt,  
			   &layout, NULL, &oflag);
  if(outfile == NULL){
    printf("%s(%d): QIO_open_write returned NULL\n",myname,this_node);
    fflush(stdout);
    return NULL;
  }
  QIO_string_destroy(xml_file_out);
  return outfile;
}
Exemplo n.º 2
0
/* Save random number state. (SITERAND case only) */
void save_random_state_scidac_from_site(char *filename, 
        char *fileinfo, char *recinfo, int volfmt, field_offset src)
{
  QIO_Layout layout;
  QIO_Filesystem fs;
  QIO_Writer *outfile;
  QIO_String *filexml;
  QIO_String *recxml;
  int status;

#ifndef SITERAND
  node0_printf("save_random_state_scidac_from_site: requires SITERAND. Save skipped\n");
  if(1)return;
#endif  

  QIO_verbose(QIO_VERB_OFF);

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

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

  /* Open file for writing */
  filexml = QIO_string_create();
  QIO_string_set(filexml, fileinfo);
  outfile = open_scidac_output(filename, volfmt, QIO_SERIAL,
			       QIO_ILDGNO, NULL, &layout, &fs, filexml);
  if(outfile == NULL)terminate(1);
  QIO_string_destroy(filexml);

  /* Write the lattice field */
  recxml = QIO_string_create();
  QIO_string_set(recxml, recinfo);
  status = write_S_from_site(outfile, recxml, src);
  QIO_string_destroy(recxml);
  if(status)terminate(1);
  
  /* Write information */
  if(volfmt == QIO_SINGLEFILE){
    node0_printf("Saved random state serially to binary file %s\n",
		 filename);
  }
  else if(volfmt == QIO_MULTIFILE){
    node0_printf("Saved random state multifile to binary file %s\n",
	   filename);
  }
  else if(volfmt == QIO_PARTFILE){
    node0_printf("Saved random state in partition format to binary file %s\n",
	   filename);
  }

  node0_printf("Checksums %x %x\n",
	       QIO_get_writer_last_checksuma(outfile),
	       QIO_get_writer_last_checksumb(outfile));

  close_scidac_output(outfile);
}
Exemplo n.º 3
0
void save_color_matrix_scidac_from_field(char *filename,
  char *fileinfo, char *recinfo, int volfmt, su3_matrix *src, int count, int prec)
{
  QIO_Layout layout;
  QIO_Writer *outfile;
  QIO_Filesystem fs;
  QIO_String *filexml;
  QIO_String *recxml;
  int status;

  QIO_verbose(QIO_VERB_OFF);

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

  /* Build the structure defining the I/O nodes */
  build_qio_filesystem(&fs);

  /* Open file for writing */
  filexml = QIO_string_create();
  QIO_string_set(filexml, fileinfo);
  outfile = open_scidac_output(filename, volfmt, QIO_SERIAL,
                               QIO_ILDGNO, NULL, &layout, &fs, filexml);
  if(outfile == NULL)terminate(1);
  QIO_string_destroy(filexml);

  /* Write the lattice field */
  recxml = QIO_string_create();
  QIO_string_set(recxml, recinfo);
  if(prec == 1)
    status = write_F3_M_from_field(outfile, recxml, src, count);
  else
    status = write_D3_M_from_field(outfile, recxml, src, count);
  if(status)terminate(1);
  QIO_string_destroy(recxml);

  /* Write information */
  if(volfmt == QIO_SINGLEFILE){
    node0_printf("Saved KS matrix serially to binary file %s\n",
                 filename);
  }
  else if(volfmt == QIO_MULTIFILE){
    node0_printf("Saved KS matrix as multifile to binary file %s\n",
           filename);
  }
  else if(volfmt == QIO_PARTFILE){
    node0_printf("Saved KS matrix in partition format to binary file %s\n",
           filename);
  }

  node0_printf("Checksums %x %x\n",
               QIO_get_writer_last_checksuma(outfile),
               QIO_get_writer_last_checksumb(outfile));

  close_scidac_output(outfile);
}
Exemplo n.º 4
0
void restore_real_scidac_to_field(char *filename, Real *dest, int count){
  QIO_Layout layout;
  QIO_Filesystem fs;
  QIO_Reader *infile;
  QIO_String *recxml;
  int status;

  QIO_verbose(QIO_VERB_OFF);

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

  /* Set the file system parameters */
  build_qio_filesystem(&fs);

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

  /* Read the lattice field */
  recxml = QIO_string_create();
  status = read_F_R_to_field(infile, recxml, dest, count);
  if(status)terminate(1);

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

  close_scidac_input(infile);
}
Exemplo n.º 5
0
/* Read random number state in SciDAC format (SITERAND case only) */
void restore_random_state_scidac_to_site(char *filename, field_offset dest){
  QIO_Layout layout;
  QIO_Filesystem fs;
  QIO_Reader *infile;
  QIO_String *recxml;
  int status;

#ifndef SITERAND
  node0_printf("restore_random_state_scidac_to_site: requires SITERAND. Save skipped\n");
  if(1)return;
#endif  

  QIO_verbose(QIO_VERB_OFF);

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

  /* Set the file system parameters */
  build_qio_filesystem(&fs);

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

  /* Read the lattice field */
  recxml = QIO_string_create();
  status = read_S_to_site(infile, recxml, dest);
  if(status)terminate(1);

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

  close_scidac_input(infile);
}
Exemplo n.º 6
0
char *create_QCDML(){
  QIO_USQCDLatticeInfo *record_info;
  char *milc_info;
  char plaqstring[32];
  char linktrstring[32];
  
  /* Build the components of the USQCD info string */
  print_prec(plaqstring, 32, (g_ssplaq+g_stplaq)/6., 1);
  print_prec(linktrstring, 32, linktrsum.real/3., 1);
  milc_info = create_MILC_info();  /* The MILC info data as a string */

  /* Stuff the data structure */
  record_info = QIO_create_usqcd_lattice_info(plaqstring, linktrstring, 
					      milc_info);

  destroy_MILC_info(milc_info);

  /* Convert the data structure to a QIO character string */
  xml_record = QIO_string_create();
  QIO_encode_usqcd_lattice_info(xml_record, record_info);
  QIO_destroy_usqcd_lattice_info(record_info);

  /* Return a pointer to the actual character string */
  return QIO_string_ptr(xml_record);
}
Exemplo n.º 7
0
int save_complex_scidac(QIO_Writer *outfile, char *filename, char *recinfo,
			int volfmt, complex *src, int count)
{
  QIO_String *recxml;
  int status;

  recxml = QIO_string_create();
  QIO_string_set(recxml, recinfo);
  status = write_F_C_from_field(outfile, recxml, src, count);
  QIO_string_destroy(recxml);
  if(status)return status;
  
  /* Write information */
  if(volfmt == QIO_SINGLEFILE){
    node0_printf("Saved complex field serially to binary file %s\n",
		 filename);
  }
  else if(volfmt == QIO_MULTIFILE){
    node0_printf("Saved complex field as multifile to binary file %s\n",
	   filename);
  }
  else if(volfmt == QIO_PARTFILE){
    node0_printf("Saved complex field in partition format to binary file %s\n",
	   filename);
  }

  node0_printf("Checksums %x %x\n",
	       QIO_get_writer_last_checksuma(outfile),
	       QIO_get_writer_last_checksumb(outfile));

  return status;
}
Exemplo n.º 8
0
int write_su3_field(QIO_Writer *outfile, int count, 
		     suN_matrix *field_out[], char *myname){
  QIO_String *xml_record_out;
  char xml_write_field[] = "Dummy user record XML for su3 field";
  int status;
  QIO_RecordInfo *rec_info;

  /* Create the record info for the field */
  rec_info = QIO_create_record_info(QIO_FIELD, NULL, NULL, 0,
				    "QDP_F3_ColorMatrix", "F", 3,
				    0, sizeof(suN_matrix), count);
  /* Create the record XML for the field */
  xml_record_out = QIO_string_create();
  QIO_string_set(xml_record_out,xml_write_field);

  /* Write the record for the field */
  status = QIO_write(outfile, rec_info, xml_record_out, vget_M, 
		     count*sizeof(suN_matrix), sizeof(float), field_out);
  printf("%s(%d): QIO_write returns status %d\n",myname,this_node,status);
  if(status != QIO_SUCCESS)return 1;

  QIO_destroy_record_info(rec_info);
  QIO_string_destroy(xml_record_out);

  return 0;
}
Exemplo n.º 9
0
QIO_Reader *open_test_input(char *filename, int volfmt, int serpar,
			    char *myname){
  QIO_String *xml_file_in;
  QIO_Reader *infile;
  QIO_Iflag iflag;

  iflag.serpar = serpar;
  iflag.volfmt = volfmt;

  /* Create the file XML */
  xml_file_in = QIO_string_create();

  /* Open the file for reading */
  infile = QIO_open_read(xml_file_in, filename, &layout, NULL, &iflag);
  if(infile == NULL){
    printf("%s(%d): QIO_open_read returns NULL.\n",myname,this_node);
    return NULL;
  }

  printf("%s(%d): QIO_open_read done.\n",myname,this_node);
  printf("%s(%d): User file info is \"%s\"\n",myname,this_node,
	 QIO_string_ptr(xml_file_in));

  QIO_string_destroy(xml_file_in);
  return infile;
}
Exemplo n.º 10
0
int read_ksproprecord_usqcd(QIO_Reader *infile, int *color, su3_vector *dest)
{
  QIO_USQCDKSPropRecordInfo proprecord_info;
  QIO_String *recxml;
  int status, typesize;
  QIO_RecordInfo recinfo;

  recxml = QIO_string_create();

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

  if(typesize == 6*4)
    /* Read as a single precision record */
    status = read_F3_V_to_field(infile, recxml, dest, 1);
  else
    /* Read as a double precision record */
    status = read_D3_V_to_field(infile, recxml, dest, 1);

  if(status != QIO_SUCCESS)return status;

  status = QIO_decode_usqcd_ksproprecord_info(&proprecord_info, recxml);
  if(status != QIO_SUCCESS)terminate(1);
  QIO_string_destroy(recxml);

  *color = QIO_get_usqcd_ksproprecord_color(&proprecord_info);
  return QIO_SUCCESS;
}
Exemplo n.º 11
0
QIO_Reader *open_usqcd_ksprop_read(char *filename, int serpar, char **fileinfo){

  QIO_Layout layout;
  QIO_Filesystem fs;
  QIO_Reader *infile;
  QIO_String *xml_file;
  char *s;
  int len;

  xml_file = QIO_string_create();
  build_qio_layout(&layout);
  build_qio_filesystem(&fs);

  infile = open_scidac_input_xml(filename, &layout, &fs, serpar, xml_file);

  if(infile == NULL)terminate(1);

  /* Make a copy of the file metadata */
  s = QIO_string_ptr(xml_file);
  len = strlen(s);
  *fileinfo = (char *)malloc((len+1)*sizeof(char));
  if(*fileinfo == NULL){
    printf("open_usqcd_ksprop_read: No room for fileinfo\n");
    terminate(1);
  }
  strncpy(*fileinfo, s, len);
  (*fileinfo)[len] = '\0';
  QIO_string_destroy(xml_file);

  return infile;
}
Exemplo n.º 12
0
int write_real_field_subset(QIO_Writer *outfile, int count, 
			    float *field_out[], int lower[],
			    int upper[], int dim, char *myname){
  QIO_String *xml_record_out;
  char xml_write_field[] = "Dummy user record XML for subset of real field";
  int status;
  QIO_RecordInfo *rec_info;

  /* Create the record info for the field */
  rec_info = QIO_create_record_info(QIO_HYPER, lower, upper, dim, 
				    "QDP_F_Real", "F", 0,
				    0, sizeof(float), count);
  /* Create the record XML for the field */
  xml_record_out = QIO_string_create();
  QIO_string_set(xml_record_out,xml_write_field);

  /* Write the record for the field */
  status = QIO_write(outfile, rec_info, xml_record_out, vget_R, 
		     count*sizeof(float), sizeof(float), field_out);
  printf("%s(%d): QIO_write returns status %d\n",myname,this_node,status);
  if(status != QIO_SUCCESS)return 1;

  QIO_destroy_record_info(rec_info);
  QIO_string_destroy(xml_record_out);

  return 0;
}
Exemplo n.º 13
0
int read_kspropsource_C_usqcd(QIO_Reader *infile, char *srcinfo, int n,
			      complex *dest)
{
  QIO_USQCDKSPropSourceInfo propsource_info;
  QIO_String *recxml;
  char *info;
  int status, typesize;
  QIO_RecordInfo recinfo;

  recxml = QIO_string_create();

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

  if(typesize == 8)
    status = read_F_C_to_field(infile, recxml, dest, 1);
  else
    status = read_D_C_to_field(infile, recxml, dest, 1);

  if(status != QIO_SUCCESS)return status;

  status = QIO_decode_usqcd_kspropsource_info(&propsource_info, recxml);
  if(status != QIO_SUCCESS)terminate(1);
  QIO_string_destroy(recxml);

  info = QIO_get_usqcd_kspropsource_info(&propsource_info);

  strncpy(srcinfo, info, n);
  return QIO_SUCCESS;
}
Exemplo n.º 14
0
QIO_Writer *open_usqcd_ksprop_write(char *filename, int volfmt, 
				    int serpar, int ildgstyle, 
				    char *stringLFN, int milc_type,
				    char *fileinfo){
  
  QIO_Layout layout;
  QIO_Filesystem fs;
  QIO_Writer *outfile;
  QIO_USQCDKSPropFileInfo *propfile_info;
  QIO_String *filexml;
  int usqcd_type = ks_prop_milc_to_usqcd(milc_type);
  
  build_qio_layout(&layout);
  build_qio_filesystem(&fs);

  propfile_info = QIO_create_usqcd_kspropfile_info(usqcd_type, fileinfo);
  filexml = QIO_string_create();
  QIO_encode_usqcd_kspropfile_info(filexml, propfile_info);
  QIO_destroy_usqcd_kspropfile_info(propfile_info);

  outfile = open_scidac_output(filename, volfmt, serpar, ildgstyle, 
			       stringLFN, &layout, &fs, filexml);
  QIO_string_destroy(filexml);
  return outfile;
}
Exemplo n.º 15
0
QIO_Writer *open_scidac_output(char *filename, int volfmt, 
			       int serpar, int ildgstyle, 
			       char *stringLFN, QIO_Layout *layout,
			       QIO_Filesystem *fs,
			       QIO_String *xml_write_file){
  QIO_Writer *outfile;
  QIO_Oflag oflag;

  /* Create the output flag structure */
  oflag.serpar = serpar;
  oflag.ildgstyle = ildgstyle;
  if(stringLFN != NULL){
    oflag.ildgLFN = QIO_string_create();
    QIO_string_set(oflag.ildgLFN, stringLFN);
  }
  else
    oflag.ildgLFN = NULL;
  oflag.mode = QIO_TRUNC;

  /* Open the file for writing */
#ifdef QIO_TRELEASE
  QIO_set_trelease(0,QIO_TRELEASE);
#endif
  outfile = QIO_open_write(xml_write_file, filename, volfmt, layout, 
			   fs, &oflag);
  if(outfile == NULL){
    printf("open_scidac_output(%d): QIO_open_write returned NULL\n",this_node);
    return NULL;
  }
  return outfile;
}
Exemplo n.º 16
0
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;
}
Exemplo n.º 17
0
QIO_Reader *r_open_complex_scidac_file(char *filename, int serpar)
{
  QIO_Reader *infile;
  QIO_String *xml_file;

  /* Open file for reading */
  xml_file = QIO_string_create();
  infile = r_open_complex_scidac_file_xml(filename, serpar, xml_file);
  QIO_string_destroy(xml_file);
  return infile;
}
Exemplo n.º 18
0
int read_complex_scidac(QIO_Reader *infile, complex *dest, int count){
  QIO_String *recxml;
  int status;

  /* Read the lattice field: "count" complex numbers per site */
  recxml = QIO_string_create();

  status = read_complex_scidac_xml(infile, dest, count, recxml);

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

  return status;
}
Exemplo n.º 19
0
REQUIRES QIO
#else
#include <qio.h>
#endif
#include "../include/io_scidac.h"
#include "../include/io_scidac_ks.h"
#include <string.h>

/********************************************************************/
/* Generic color vector file (not USQCD)                            */
/* Write color vectors in SciDAC format, taking data from the site
   structure */

int save_ks_vector_scidac(QIO_Writer *outfile, char *filename, char *recinfo,
			  int volfmt, su3_vector *src, int count, int prec)
{
  QIO_String *recxml;
  int status;

  recxml = QIO_string_create();
  QIO_string_set(recxml, recinfo);
  if(prec == 1)
    status = write_F3_V_from_field(outfile, recxml, src, count);
  else
    status = write_D3_V_from_field(outfile, recxml, src, count); 

  QIO_string_destroy(recxml);
  if(status != QIO_SUCCESS)return status;
  
  /* Write information */
  if(volfmt == QIO_SINGLEFILE){
    node0_printf("Saved KS vector serially to binary file %s\n",
		 filename);
  }
  else if(volfmt == QIO_MULTIFILE){
    node0_printf("Saved KS vector as multifile to binary file %s\n",
	   filename);
  }
  else if(volfmt == QIO_PARTFILE){
    node0_printf("Saved KS vector in partition format to binary file %s\n",
	   filename);
  }

  node0_printf("Checksums %x %x\n",
	       QIO_get_writer_last_checksuma(outfile),
	       QIO_get_writer_last_checksumb(outfile));

  return status;
}
Exemplo n.º 20
0
int write_kspropsource_V_usqcd(QIO_Writer *outfile, char *srcinfo, 
			       su3_vector *src, int t0){
  QIO_USQCDKSPropSourceInfo *propsource_info;
  QIO_String *recxml;
  int status;

  propsource_info = QIO_create_usqcd_kspropsource_info(srcinfo);
  recxml = QIO_string_create();
  QIO_encode_usqcd_kspropsource_info(recxml, propsource_info);
  QIO_destroy_usqcd_kspropsource_info(propsource_info);

  status = write_kspropsource_V_usqcd_xml(outfile, recxml, src, t0);
  QIO_string_destroy(recxml);
  return status;
}
Exemplo n.º 21
0
QIO_ChecksumInfo *QIO_read_checksum(QIO_Reader *in)
{
  char myname[] = "QIO_read_checksum";
  QIO_String *xml_checksum;
  QIO_ChecksumInfo *checksum_info_expect = NULL;
  int this_node = in->layout->this_node;
  int status;
  LIME_type lime_type=NULL;
  
  if(in->read_state != QIO_RECORD_CHECKSUM_NEXT){
    printf("%s(%d): Bad read state %d\n",myname,this_node,in->read_state);
    return NULL;
  }
  
  /* Master node reads the checksum record */
  status = QIO_SUCCESS;  /* Changed if checksum does not match */
  if(this_node == in->layout->master_io_node){
    checksum_info_expect = QIO_create_checksum_info(0,0);
    /* No checksum record for non-native files */
    if(in->format == QIO_SCIDAC_NATIVE){
      xml_checksum = QIO_string_create();
      QIO_string_realloc(xml_checksum,QIO_STRINGALLOC);
      if((status=QIO_read_string(in, xml_checksum, &lime_type))
	 !=QIO_SUCCESS){
	printf("%s(%d): Error reading checksum\n",myname,this_node);
	return NULL;
      }
      if(QIO_verbosity() >= QIO_VERB_DEBUG){
	printf("%s(%d): checksum = %s\n",myname,this_node,
	       QIO_string_ptr(xml_checksum));
      }
      /* Extract checksum */
      if((status=QIO_decode_checksum_info(checksum_info_expect, xml_checksum))
	 !=0){
	printf("%s(%d): bad checksum record\n",myname,this_node);
	return NULL;
      }
      QIO_string_destroy(xml_checksum);
    }
  }
  
  in->read_state = QIO_RECORD_INFO_PRIVATE_NEXT;
  
  return checksum_info_expect;
}
Exemplo n.º 22
0
/*Write current record for the accumulated average over random sources */
static int
write_vector_current_record(QIO_Writer *outfile, int jrand, int nwrite, Real mass, Real *j_mu){
  int status = QIO_SUCCESS;
  QIO_String *recxml = QIO_string_create();
  char recinfo[NRECINFO];

  snprintf(recinfo, NRECINFO, "source index %d mass %g", jrand/nwrite, mass);
  QIO_string_set(recxml, recinfo);
  if(PRECISION == 1)
    status = write_F_R_from_field(outfile, recxml, j_mu, NMU);
  else
    status = write_D_R_from_field(outfile, recxml, j_mu, NMU);
  QIO_string_destroy(recxml);

  node0_printf("Wrote current density for source %d and mass %g\n", jrand, mass);
  
  return status;
}
Exemplo n.º 23
0
int read_su3_field(QIO_Reader *infile, int count, 
		    suN_matrix *field_in[], char *myname)
{
  QIO_String *xml_record_in;
  QIO_RecordInfo rec_info;
  int status;
  
  /* Create the record XML */
  xml_record_in = QIO_string_create();

  /* Read the field record */
  status = QIO_read(infile, &rec_info, xml_record_in, 
		    vput_M, sizeof(suN_matrix)*count, sizeof(float), field_in);
  printf("%s(%d): QIO_read_record_data returns status %d\n",
	 myname,this_node,status);
  if(status != QIO_SUCCESS)return 1;
  return 0;
}
Exemplo n.º 24
0
/* Read color matrices in SciDAC format to a field */
void restore_color_matrix_scidac_to_field(char *filename, 
		  su3_matrix *dest, int count, int prec){
  QIO_Layout layout;
  QIO_Filesystem fs;
  QIO_Reader *infile;
  QIO_String *recxml;
  int status, typesize;
  QIO_RecordInfo recinfo;
  char myname[] = "restore_color_matrix_scidac_to_field";

  QIO_verbose(QIO_VERB_OFF);

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

  /* Set the file system parameters */
  build_qio_filesystem(&fs);

  /* Open file for reading */
  infile = open_scidac_input(filename, &layout, &fs, QIO_SERIAL);
  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 != QIO_SUCCESS)terminate(1);
  typesize = QIO_get_typesize(&recinfo);

  /* Read the lattice field */
  if(typesize == 18*4)
    status = read_F3_M_to_field(infile, recxml, dest, count);
  else if(typesize == 18*8)
    status = read_D3_M_to_field(infile, recxml, dest, count);
  else {
    node0_printf("%s: Incorrect data type size %d prec %d\n", myname, typesize, prec);
    terminate(1);
  }
  if(status)terminate(1);

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

  close_scidac_input(infile);
}
Exemplo n.º 25
0
int peek_record_info(QIO_Reader *infile, char *myname){
  QIO_String *xml_record_in;
  QIO_RecordInfo rec_info;
  int status;

  printf("%s(%d) peeking\n",myname,this_node);
  /* Create the record XML */
  xml_record_in = QIO_string_create();
  /* Create placeholder for record_info */

  status = QIO_read_record_info(infile, &rec_info, xml_record_in);
  if(status != QIO_SUCCESS)return 1;
  
  printf("%s(%d): User record info is \"%s\"\n",myname,this_node,
	 QIO_string_ptr(xml_record_in));

  QIO_string_destroy(xml_record_in);
  return 0;
}
Exemplo n.º 26
0
/* Open file for writing */
static QIO_Writer *
open_vector_current_file(char *filename){
  char default_file_xml[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><title>MILC ILDG disconnected vector current</title>";
  int volfmt = QIO_SINGLEFILE;
  int serpar = QIO_SERIAL;
  QIO_String *filexml = QIO_string_create();
  QIO_string_set(filexml, default_file_xml);
  QIO_Layout layout;
  QIO_Filesystem fs;
  /* Build the layout structure */
  build_qio_layout(&layout);

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

  QIO_Writer *outfile = open_scidac_output(filename, volfmt, serpar, QIO_ILDGNO, NULL,
					   &layout, &fs, filexml);
  QIO_string_destroy(filexml);
  return outfile;
}
Exemplo n.º 27
0
int write_ksprop_usqcd_c(QIO_Writer *outfile, su3_vector *src, 
			 int color, char *recinfo)
{
  QIO_USQCDKSPropRecordInfo *proprecord_info;
  QIO_String *recxml;
  int status;

  proprecord_info = QIO_create_usqcd_ksproprecord_c_info(color, recinfo);
  recxml = QIO_string_create();
  QIO_encode_usqcd_ksproprecord_info(recxml, proprecord_info);
  QIO_destroy_usqcd_ksproprecord_info(proprecord_info);

  if(PRECISION == 1)
    status = write_F3_V_from_field(outfile, recxml, src, 1);
  else
    status = write_D3_V_from_field(outfile, recxml, src, 1);

  QIO_string_destroy(recxml);
  return status;
}
Exemplo n.º 28
0
QIO_Reader *open_scidac_input(char *filename, QIO_Layout *layout, 
			      QIO_Filesystem *fs, int serpar){
  QIO_String *xml_file_in;
  QIO_Reader *infile;

  /* Allocate for the file XML string */
  xml_file_in = QIO_string_create();

  infile = open_scidac_input_xml(filename, layout, fs, serpar, xml_file_in);

  if(infile == NULL)return NULL;

  if(this_node==0){
    printf("Restoring binary SciDAC file %s\n",filename);
    printf("File info \n\"%s\"\n",QIO_string_ptr(xml_file_in));
  }

  QIO_string_destroy(xml_file_in);
  return infile;
}
Exemplo n.º 29
0
int io_detect_ks_usqcd(char *filename){

  QIO_Layout layout;
  QIO_Filesystem fs;
  QIO_Reader *infile;
  QIO_String *xml_file_in;
  QIO_USQCDKSPropFileInfo prop_info;
  int status, usqcd_type, milc_type;

  /* Allocate for the file XML string */
  xml_file_in = QIO_string_create();

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

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

  /* Open file for reading */
  layout.latdim = 0; /* Force discovery of dimensions */
  infile = open_scidac_input_xml(filename, &layout, &fs, QIO_SERIAL, 
				 xml_file_in);
  if(infile == NULL)terminate(1);

  /* Decode the file XML */

  status = QIO_decode_usqcd_kspropfile_info(&prop_info, xml_file_in);
  QIO_string_destroy(xml_file_in);
  if(status)return -1;

  milc_type = -1;
  if(QIO_defined_usqcd_kspropfile_type(&prop_info))
    {
      /* Translate the file type */
      usqcd_type = QIO_get_usqcd_kspropfile_type(&prop_info);
      milc_type = ks_prop_usqcd_to_milc(usqcd_type);
    }

  close_scidac_input(infile);
  return milc_type;
}
Exemplo n.º 30
0
int read_real_global(QIO_Reader *infile, int count, 
		    float array_in[], char *myname)
{
  QIO_String *xml_record_in;
  QIO_RecordInfo rec_info;
  int status;

  /* Create the record XML */
  xml_record_in = QIO_string_create();

  /* Read the global array record */
  status = QIO_read(infile, &rec_info, xml_record_in, 
		    vput_r, sizeof(float)*count, sizeof(float), array_in);
  printf("%s(%d): QIO_read returns status %d\n",
	 myname,this_node,status);
  if(status != QIO_SUCCESS)return 1;
  printf("%s(%d): User record info is \"%s\"\n",myname,this_node,
	 QIO_string_ptr(xml_record_in));

  QIO_string_destroy(xml_record_in);
  return 0;
}