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; }
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); }
/* 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); }
int read_lat_dim_scidac(char *filename, int *ndim, int dims[]) { QIO_Layout layout; QIO_Filesystem fs; int i; int *latsize; QIO_Reader *infile; QIO_verbose(QIO_VERB_REG); /* Build the layout structure */ nx = 0; ny = 0; nz = 0; nt = 0; build_qio_layout(&layout); /* Forces discovery */ layout.latdim = 0; /* Set the file system parameters */ build_qio_filesystem(&fs); /* Get lattice dimensions from file */ infile = open_scidac_input(filename, &layout, &fs, QIO_SERIAL); if(!infile)return 1; *ndim = QIO_get_reader_latdim(infile); latsize = QIO_get_reader_latsize(infile); for(i = 0; i < *ndim; i++) dims[i] = latsize[i]; QIO_close_read(infile); return 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); }
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); }
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; }
void restore_complex_scidac_to_field(char *filename, int serpar, complex *dest, int count){ QIO_Reader *infile; int status; QIO_verbose(QIO_VERB_OFF); infile = r_open_complex_scidac_file(filename, serpar); if(infile == NULL)terminate(1); /* Read the lattice field: "count" complex numbers per site */ status = read_complex_scidac(infile, dest, count); if(status)terminate(1); r_close_complex_scidac_file(infile); }
void restore_ks_vector_scidac_to_field(char *filename, int serpar, su3_vector *dest, int count){ QIO_Reader *infile; int status; QIO_verbose(QIO_VERB_OFF); infile = r_open_scidac_file(filename, serpar); if(infile == NULL)terminate(1); /* Read the lattice field: "count" color vectors per site */ status = read_ks_vector_scidac(infile, dest, count); if(status != QIO_SUCCESS)terminate(1); r_close_scidac_file(infile); }
void save_complex_scidac_from_field(char *filename, char *fileinfo, char *recinfo, int volfmt, int serpar, complex *src, int count){ QIO_Writer *outfile; int status; QIO_verbose(QIO_VERB_OFF); outfile = w_open_complex_scidac_file(filename, fileinfo, volfmt, serpar); if(outfile == NULL)terminate(1); /* Write the lattice field: "count" complex numbers per site */ status = save_complex_scidac(outfile, filename, recinfo, volfmt, src, count); if(status)terminate(1); w_close_complex_scidac_file(outfile); }
/* 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); }
void save_ks_vector_scidac_from_field(char *filename, char *fileinfo, char *recinfo, int volfmt, int serpar, su3_vector *src, int count, int prec) { QIO_Writer *outfile; int status; QIO_verbose(QIO_VERB_OFF); outfile = w_open_scidac_file(filename, fileinfo, volfmt, serpar); if(outfile == NULL)terminate(1); status = save_ks_vector_scidac(outfile, filename, recinfo, volfmt, src, count, prec); if(status)terminate(1); w_close_scidac_file(outfile); }
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; }
/* The QIO file is closed after writing the lattice */ gauge_file *save_scidac(char *filename, int volfmt, int serpar, int ildgstyle, char *stringLFN){ QIO_Layout layout; QIO_Filesystem fs; QIO_Writer *outfile; int status; field_offset src = F_OFFSET(link[0]); gauge_file *gf; char *info; QIO_String *filexml; QIO_String *recxml; char default_file_xml[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><title>MILC ILDG archival gauge configuration</title>"; QIO_verbose(QIO_VERB_OFF); /* Build the layout structure */ build_qio_layout(&layout); /* Define the I/O system */ build_qio_filesystem(&fs); /* Make a dummy gauge file structure for MILC use */ gf = setup_output_gauge_file(); /* Set the filename in the gauge_file structure */ gf->filename = filename; /* Open file for writing */ filexml = QIO_string_create(); QIO_string_set(filexml, default_file_xml); outfile = open_scidac_output(filename, volfmt, serpar, ildgstyle, stringLFN, &layout, &fs, filexml); if(outfile == NULL)terminate(1); QIO_string_destroy(filexml); /* Create the QCDML string for this configuration */ info = create_QCDML(); recxml = QIO_string_create(); QIO_string_set(recxml, info); /* Write the lattice field */ status = write_F3_M_from_site(outfile, recxml, src, LATDIM); if(status)terminate(1); /* Discard for now */ QIO_string_destroy(recxml); /* Write information */ if(volfmt == QIO_SINGLEFILE){ node0_printf("Saved gauge configuration serially to binary file %s\n", filename); } else if(volfmt == QIO_MULTIFILE){ node0_printf("Saved gauge configuration as multifile to binary file %s\n", filename); } else if(volfmt == QIO_PARTFILE){ node0_printf("Saved gauge configuration in partition format to binary file %s\n", filename); } node0_printf("Time stamp %s\n",gf->header->time_stamp); node0_printf("Checksums %x %x\n", QIO_get_writer_last_checksuma(outfile), QIO_get_writer_last_checksumb(outfile)); /* Close the file */ QIO_close_write(outfile); free_QCDML(info); return gf; }