// write global checksum, and runinfo in new file void write_1st_msg(const char* filename, GlobalDat& dat, size_t chksum){ // open file FILE* fp; fp = fopen(filename, "w"); LimeWriter* w; w = limeCreateWriter(fp); // first record is global checksum int MB_flag = 1; int ME_flag = 0; LimeRecordHeader* chk; n_uint64_t chk_bytes = sizeof(chksum); chk = limeCreateHeader(MB_flag, ME_flag, "Global Checksum", chk_bytes); limeWriteRecordHeader(chk, w); limeDestroyHeader(chk); limeWriteRecordData(&chksum, &chk_bytes, w); // second record is data on calculation MB_flag = 0; ME_flag = 1; LimeRecordHeader* run_id; n_uint64_t run_id_bytes = sizeof(dat); run_id = limeCreateHeader(MB_flag, ME_flag, "Runinfo", run_id_bytes); limeWriteRecordHeader(run_id,w); limeDestroyHeader(run_id); limeWriteRecordData(&dat, &run_id_bytes, w); limeDestroyWriter(w); fclose(fp); }
/*********************************************************** * write_lime_contraction ***********************************************************/ int write_lime_contraction_3d(double * const s, char * filename, const int prec, const int N, char * type, const int gid, const int sid) { #ifdef MPI fprintf(stderr, "[write_lime_contraction_3d] No mpi version.\n"); return(1); #else FILE * ofs = NULL; LimeWriter * limewriter = NULL; LimeRecordHeader * limeheader = NULL; int status = 0; int ME_flag=0, MB_flag=0; n_uint64_t bytes; DML_Checksum checksum; write_contraction_format(filename, prec, N, type, gid, sid); if(g_cart_id==0) { ofs = fopen(filename, "a"); if(ofs == (FILE*)NULL) { fprintf(stderr, "Could not open file %s for writing!\n Aborting...\n", filename); exit(500); } limewriter = limeCreateWriter( ofs ); if(limewriter == (LimeWriter*)NULL) { fprintf(stderr, "LIME error in file %s for writing!\n Aborting...\n", filename); exit(500); } bytes = LX*g_nproc_x*LY*g_nproc_y*LZ*(n_uint64_t)2*N*sizeof(double)*prec/64; MB_flag=0; ME_flag=1; limeheader = limeCreateHeader(MB_flag, ME_flag, "scidac-binary-data", bytes); status = limeWriteRecordHeader( limeheader, limewriter); if(status < 0 ) { fprintf(stderr, "LIME write header (scidac-binary-data) error %d\n", status); exit(500); } limeDestroyHeader( limeheader ); } status = write_binary_contraction_data_3d(s, limewriter, prec, N, &checksum); if(g_cart_id==0) { printf("# Final check sum is (%#lx %#lx)\n", checksum.suma, checksum.sumb); if(ferror(ofs)) { fprintf(stderr, "Warning! Error while writing to file %s \n", filename); } limeDestroyWriter( limewriter ); fflush(ofs); fclose(ofs); } write_checksum(filename, &checksum); return(0); #endif }
void lime_write_info(FILE **fout, char* binary_data, n_uint64_t data_size_per_site, n_uint64_t *offset) { LimeWriter *limewriter; LimeRecordHeader *limeheader = NULL; n_uint64_t message_length; char tmp_string[STRINGLENGTH]; ASSERT((limewriter = limeCreateWriter(*fout))!=(LimeWriter*)NULL); sprintf(tmp_string, "Vector_by_DDalphaAMG"); message_length=(n_uint64_t) strlen(tmp_string); limeheader = limeCreateHeader(1, 1, "vector-type", message_length); ASSERT(limeheader != (LimeRecordHeader*)NULL); ASSERT(limeWriteRecordHeader(limeheader, limewriter)>=0); ASSERT(limeWriteRecordData(tmp_string, &message_length, limewriter)>=0); limeDestroyHeader(limeheader); sprintf(tmp_string, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<etmcFormat>\n\t<field>diracFermion</field>\n\t<precision>64</precision>\n\t<flavours>1</flavours>\n\t<lx>%d</lx>\n\t<ly>%d</ly>\n\t<lz>%d</lz>\n\t<lt>%d</lt>\n\t<spin>4</spin>\n\t<colour>3</colour>\n</etmcFormat>", g.global_lattice[0][X], g.global_lattice[0][Y], g.global_lattice[0][Z], g.global_lattice[0][T]); message_length=(n_uint64_t) strlen(tmp_string); limeheader = limeCreateHeader(1, 1, "etmc-propagator-format", message_length); ASSERT(limeheader != (LimeRecordHeader*)NULL); ASSERT(limeWriteRecordHeader(limeheader, limewriter)>=0); ASSERT(limeWriteRecordData(tmp_string, &message_length, limewriter)>=0); limeDestroyHeader(limeheader); message_length=(n_uint64_t) strlen(tmp_string); limeheader = limeCreateHeader(1, 1, "DDalphaAMG-header", message_length); ASSERT(limeheader != (LimeRecordHeader*)NULL); ASSERT(limeWriteRecordHeader(limeheader, limewriter)>=0); ASSERT(limeWriteRecordData(tmp_string, &message_length, limewriter)>=0); limeDestroyHeader(limeheader); int vol=1, mu; for ( mu=0; mu<4; mu++ ){ vol*=g.global_lattice[0][mu]; } message_length=data_size_per_site*vol; limeheader = limeCreateHeader(1, 1, "scidac-binary-data", message_length); ASSERT(limeWriteRecordHeader(limeheader, limewriter)>=0); limeDestroyHeader(limeheader); message_length=1; //make one fake record-write to set offset ASSERT(limeWriteRecordData(tmp_string, &message_length, limewriter)>=0); *offset = (n_uint64_t) ftell(*fout)-1; limeDestroyWriter(limewriter); }