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; }
/* 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); }
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; }
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; }
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; }
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; }
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; }
/*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; }
/* 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; }
QIO_Writer *w_open_complex_scidac_file(char *filename, char *fileinfo, int volfmt, int serpar) { QIO_Layout layout; QIO_Filesystem fs; QIO_Writer *outfile; QIO_String *filexml; /* Build the layout structure */ build_qio_layout(&layout); /* Define 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, serpar, QIO_ILDGNO, NULL, &layout, &fs, filexml); QIO_string_destroy(filexml); return outfile; }
int write_real_global(QIO_Writer *outfile, int count, float array_out[], char *myname){ QIO_String *xml_record_out; char xml_write_global[] = "Dummy user record XML for global"; int status; QIO_RecordInfo *rec_info; /* Create the record info for the global array */ xml_record_out = QIO_string_create(); QIO_string_set(xml_record_out,xml_write_global); rec_info = QIO_create_record_info(QIO_GLOBAL, NULL, NULL, 0, "QLA_F_Real", "F", 0, 0, sizeof(float), count); /* Write the array to a file */ status = QIO_write(outfile, rec_info, xml_record_out, vget_r, count*sizeof(float), sizeof(float), array_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; }
/* 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; }