void lime_read_info(FILE **fin, lime_fileinfo *lime, char* binary_data) { LimeReader *limereader; char *lime_type,*lime_data; ASSERT((limereader = limeCreateReader(*fin))); lime->spin=4; lime->colour=3; while(limeReaderNextRecord(limereader) != LIME_EOF) { lime_type = limeReaderType(limereader); if(strcmp(lime_type, binary_data)==0) { break; } if(strcmp(lime_type,"ildg-format")==0) { lime->data_size = limeReaderBytes(limereader); lime_data = (char * )malloc(lime->data_size); limeReaderReadData((void *)lime_data,&(lime->data_size), limereader); sscanf(lime_getParam("<precision>",lime_data, lime->data_size, '<'),"%i",&(lime->precision)); sscanf(lime_getParam("<lx>",lime_data, lime->data_size, '<'),"%i",&(lime->l[X])); sscanf(lime_getParam("<ly>",lime_data, lime->data_size, '<'),"%i",&(lime->l[Y])); sscanf(lime_getParam("<lz>",lime_data, lime->data_size, '<'),"%i",&(lime->l[Z])); sscanf(lime_getParam("<lt>",lime_data, lime->data_size, '<'),"%i",&(lime->l[T])); free(lime_data); } if(strcmp(lime_type,"etmc-source-format")==0 || strcmp(lime_type,"etmc-propagator-format")==0) { lime->data_size = limeReaderBytes(limereader); lime_data = (char * )malloc(lime->data_size); limeReaderReadData((void *)lime_data,&(lime->data_size), limereader); sscanf(lime_getParam("<precision>",lime_data, lime->data_size, '<'),"%i",&(lime->precision)); sscanf(lime_getParam("<flavours>",lime_data, lime->data_size, '<'),"%i",&(lime->flavours)); sscanf(lime_getParam("<lx>",lime_data, lime->data_size, '<'),"%i",&(lime->l[X])); sscanf(lime_getParam("<ly>",lime_data, lime->data_size, '<'),"%i",&(lime->l[Y])); sscanf(lime_getParam("<lz>",lime_data, lime->data_size, '<'),"%i",&(lime->l[Z])); sscanf(lime_getParam("<lt>",lime_data, lime->data_size, '<'),"%i",&(lime->l[T])); sscanf(lime_getParam("<spin>",lime_data, lime->data_size, '<'),"%i",&(lime->spin)); sscanf(lime_getParam("<colour>",lime_data, lime->data_size, '<'),"%i",&(lime->colour)); free(lime_data); } if(strcmp(lime_type,"xlf-info")==0) { lime->data_size = limeReaderBytes(limereader); lime_data = (char * )malloc(lime->data_size); limeReaderReadData((void *)lime_data,&(lime->data_size), limereader); sscanf(lime_getParam("plaquette =",lime_data, lime->data_size, '\n'),"%lf",&(lime->plaquette)); free(lime_data); } } lime->data_size = limeReaderBytes(limereader); lime->offset = ftell(*fin); limeDestroyReader(limereader); }
int ILDGReader::header(){ _Message(DEBUG_VERB_LEVEL, "ILDG Header...\n"); n_uint64_t nbytes; LimeR = limeCreateReader(inputFile); do {limeReaderNextRecord(LimeR);} while (strncmp(limeReaderType(LimeR), "ildg-binary-data",16)); nbytes = limeReaderBytes(LimeR);//size of this record (configuration) _Message(DEBUG_VERB_LEVEL, "ILDG Header: reading "<<nbytes<< " bytes record...\n"); }
void meson_ASCII_IO(char *filename, int rec_seek, int msg_seek) { int i,j,k=0,l=0; char buf[MAXBUF]; LimeReader *r; int status; twopt_mom *corr; n_uint64_t nbytes, bytes_left, bytes_to_copy, read_bytes; int rec, msg; char *lime_type; size_t bytes_pad; int MB_flag, ME_flag; FILE *fin=NULL; corr=malloc(NMOM_MAX*sizeof(twopt_mom)); fin=fopen(filename,"r"); error_root(fin == (FILE *)NULL,0,"meson_ASCII_IO [IOarchive.c]", "IOarchive: Unable to open file %s for reading\n", filename); /* Open LIME reader */ r = limeCreateReader(fin); error_root(r == (LimeReader *)NULL,0,"meson_ASCII_IO [IOarchive.c]", "Unable to open LimeReader\n"); /* Loop over records */ rec = 0; msg = 0; while( (status = limeReaderNextRecord(r)) != LIME_EOF ){ error_root(status != LIME_SUCCESS,0,"meson_ASCII_IO [IOarchive.c]", "IOarchive: limeReaderNextRecord returned status = %d\n",status); nbytes = limeReaderBytes(r); lime_type = limeReaderType(r); bytes_pad = limeReaderPadBytes(r); MB_flag = limeReaderMBFlag(r); ME_flag = limeReaderMEFlag(r); /* Update message and record numbers */ if(MB_flag == 1){ msg++; rec = 0; } rec++; /* Skip to next record until target record is reached */ if (msg != msg_seek || rec != rec_seek) continue; /* Buffered copy */ bytes_left = nbytes; while(bytes_left > (n_uint64_t)0){ bytes_to_copy = mino((n_uint64_t)(NMOM_MAX*sizeof(twopt_mom)),bytes_left); read_bytes = bytes_to_copy; error_root((int)read_bytes>MAXBUF,0,"meson_ASCII_IO [IOarchive.c]", "read_bytes exceeds MAXBUF"); status = limeReaderReadData((void *)buf, &read_bytes, r); error_root(status<0 && status !=LIME_EOR,1,"meson_ASCII_IO [IOarchive.c]", "LIME read error occurred: status= %d", status); error_root(read_bytes != bytes_to_copy,1,"meson_ASCII_IO [IOarchive.c]", "Read error %lld bytes wanted,%lld read\n", (unsigned long long)nbytes, (unsigned long long)read_bytes); /* Print to stdout */ corr=(twopt_mom*)buf; l=0; for(i=0;i<NMOM_MAX;i++){ for(j=0;j<TT;j++) { printf("%d %s %d %d %d %d %d %d %.16e %.16e\n", k,lime_type, (*(corr+l)).musrc, (*(corr+l)).musnk, (*(corr+l)).p[0], (*(corr+l)).p[1], (*(corr+l)).p[2], j, (*(corr+l)).corr[j].re, (*(corr+l)).corr[j].im); } l++; k++; } bytes_left -= bytes_to_copy; } /* Quit at this record */ break; } limeDestroyReader(r); fclose(fin); }
extern void import_cnfg_ildg(char *in) { int my_rank,np[4],n,ie,tag,status,prec=0; int i,l,ix,iy,iz,it,ixx; n_uint64_t read_bytes,nbytes=0; double plaq1,eps; MPI_Status stat; LimeReader *reader=NULL; FILE *fin; char lime_type_target[100]="ildg-binary-data"; char *lime_type; MPI_Comm_rank(MPI_COMM_WORLD,&my_rank); /* allocate IO-buffers */ if (ubuf==NULL) alloc_ubuf_ildg(my_rank); error(pud[VOLUME/2][0]==NULL,1,"import_cnfg [archive_ildg.c]", "Double-precision gauge field is not allocated"); ie=check_machine(); if (my_rank==0) { fin=fopen(in,"rb"); error_root(fin==NULL,1,"import_cnfg [archive_ildg.c]", "Unable to open input file"); reader=limeCreateReader(fin); error( reader == (LimeReader *)NULL ,1,"import_cnfg [archive_ildg.c]", "Unable to open LimeReader"); nbytes = (n_uint64_t)0; /* set the file-pointer to the beginning of the "ildg-binary-data" tag * in the LIME file */ while( (status = limeReaderNextRecord(reader)) != LIME_EOF ){ nbytes = limeReaderBytes(reader); lime_type = limeReaderType(reader); error((status!=LIME_SUCCESS),1,"import_cnfg [archive_ildg.c]", "limeReaderNextRecord returned status %d and LIME_SUCCESS %d\n", status,LIME_SUCCESS); if (strcmp(lime_type,lime_type_target) != 0) continue; break; } /* Decide whether the gauge file is stored in single or * double precision format */ if ((int)nbytes==8*VOLUME*NPROC*3*3*4*2){ prec=8; message("ILDG-file contains double precision gauge field\n"); } else if ((int)nbytes==4*VOLUME*NPROC*3*3*4*2){ prec=4; message("ILDG-file contains single precision gauge field\n"); } else error(1!=0,1,"import_cnfg [archive_ildg]", "Lattice geometry doesn't match size of gauge field %d %d\n"); } /* Now read the gauge file in steps of 4 SU(3) matrices */ for (it=0;it<N0;it++){ for (iz=0;iz<N3;iz++){ for (iy=0;iy<N2;iy++){ for (ix=0;ix<N1;ix++){ if(my_rank==0){ if(prec==8){ read_bytes = (n_uint64_t)(4*18*sizeof(double)); status = limeReaderReadData((double *)vbuf,&read_bytes, reader); bswap_double(4*18,(double *)(vbuf));/* ILDG always big endian */ } else if(prec==4){ read_bytes = (n_uint64_t)(4*18*sizeof(float)); status = limeReaderReadData((void *)vbuf_s,&read_bytes, reader); bswap_float(4*18,(float *)(vbuf_s)); /* ILDG always big endian */ for (i=0;i<4;i++) su3_copy_singletodouble((vbuf_s+i),(vbuf+i)); } } np[0]=it; np[1]=ix; np[2]=iy; np[3]=iz; n=ipr_global(np); MPI_Barrier(MPI_COMM_WORLD); if (n>0) { tag=mpi_tag(); if (my_rank==0) MPI_Send((double*)(vbuf),4*18,MPI_DOUBLE,n,tag, MPI_COMM_WORLD); if (my_rank==n) MPI_Recv((double*)(ubuf),4*18,MPI_DOUBLE,0,tag, MPI_COMM_WORLD,&stat); } else if (my_rank==0) for (l=0;l<(4);l++) ubuf[l]=vbuf[l]; ixx = ((iy%L2)*L3 + (ix%L1)*L3*L2 + (it%L0)*L1*L2*L3); if (my_rank==n) set_links_ildg(ixx,iz); } } } } plaq1=plaq_sum_dble()/(double)(6*NPROC*VOLUME); message("Plaquette %f\n",plaq1); message("Plaquette/3 %f\n",plaq1/3); message("Please check consistency of average plaquette by hand\n"); eps=sqrt((double)(6*NPROC*VOLUME))*DBL_EPSILON; }
int read_lime_gauge_field_doubleprec(double * config, char * filename, const int T, const int LX, const int LY, const int LZ) { FILE * ifs; int t, x, y, z, status, p=0; n_uint64_t bytes; char * header_type; LimeReader * limereader; double tmp[72]; int words_bigendian; words_bigendian = big_endian(); ifs = fopen(filename, "r"); if(ifs == (FILE *)NULL) { fprintf(stderr, "Could not open file %s\n Aborting...\n", filename); exit(500); } limereader = limeCreateReader( ifs ); if( limereader == (LimeReader *)NULL ) { fprintf(stderr, "Unable to open LimeReader\n"); exit(500); } while( (status = limeReaderNextRecord(limereader)) != LIME_EOF ) { if(status != LIME_SUCCESS ) { fprintf(stderr, "limeReaderNextRecord returned error with status = %d!\n", status); status = LIME_EOF; break; } header_type = limeReaderType(limereader); if(!strcmp("ildg-binary-data",header_type)) break; } if(status == LIME_EOF) { fprintf(stderr, "no ildg-binary-data record found in file %s\n",filename); limeDestroyReader(limereader); fclose(ifs); exit(-2); } bytes = limeReaderBytes(limereader); if((int)bytes != LX*LY*LZ*T*72*sizeof(double)) { fprintf(stderr, "Probably wrong lattice size or precision (bytes=%d) in file %s\n", (int)bytes, filename); fprintf(stderr, "Aborting...!\n"); fflush( stdout ); exit(501); } bytes = (n_uint64_t)72*sizeof(double); for(t = 0; t < T; t++) { for(z = 0; z < LZ; z++) { for(y = 0; y < LY; y++) { for(x = 0; x < LX; x++) { p = (((t*LZ+z)*LY+y)*LX+x)*72; if(!words_bigendian) { status = limeReaderReadData(tmp, &bytes, limereader); byte_swap_assign(&config[p], tmp, 72); } else { status = limeReaderReadData(&config[p], &bytes, limereader); } if(status < 0 && status != LIME_EOR) { fprintf(stderr, "LIME read error occured with status = %d while reading file %s!\n Aborting...\n", status, filename); exit(500); } } } } } limeDestroyReader(limereader); fclose(ifs); return(0); }
int read_qdppp_scidac_binary_data(char *buff_out, long int buff_size, char *fin) { char buf[MAXBUF]; /* auxilary buffer for using a buffer copy. Bytes first copied to buf then from buf to buff_out*/ LimeReader *reader; int status; n_uint64_t nbytes, bytes_left, bytes_to_copy, read_bytes; int rec_seek,msg_seek; int rec, msg; char *lime_type; size_t bytes_pad; int MB_flag, ME_flag; int i; /* Open file */ FILE *fp = fopen(fin, "r"); if(fp == NULL) { fprintf(stderr,"Unable to open file %s for reading\n", fin); return EXIT_FAILURE; } /* Open LIME reader */ reader = limeCreateReader(fp); if( reader == (LimeReader *)NULL ) { fprintf(stderr, "Unable to open LimeReader\n"); return EXIT_FAILURE; } /* Loop over records */ msg=0; rec=0; while( (status = limeReaderNextRecord(reader)) != LIME_EOF ){ if( status != LIME_SUCCESS ) { fprintf(stderr, "limeReaderNextRecord returned status = %d\n", status); return EXIT_FAILURE; } nbytes = limeReaderBytes(reader); lime_type = limeReaderType(reader); bytes_pad = limeReaderPadBytes(reader); MB_flag = limeReaderMBFlag(reader); ME_flag = limeReaderMEFlag(reader); /* Update message and record numbers */ if(MB_flag == 1){ msg++; rec = 0; } rec++; #if 1 printf("\n\n"); printf("Type: %s\n", lime_type); printf("Data Length: %ld\n", nbytes); printf("Padding Length: %zd\n", bytes_pad); printf("MB flag: %d\n", MB_flag); printf("ME flag: %d\n", ME_flag); #endif /* Skip to next record until target record is reached */ /*if (msg != msg_seek || rec != rec_seek) continue;*/ if (strcmp(lime_type,"scidac-binary-data") != 0) continue; /*check that the data record has the expected number of byutes*/ if(nbytes != buff_size) { fprintf(stderr,"Error, expecting %ld bytes but data has %ld bytes\n",buff_size,nbytes); return EXIT_FAILURE; } /* Buffered copy */ bytes_left = nbytes; int bcopied=0; while(bytes_left > (n_uint64_t)0){ bytes_to_copy = mino((n_uint64_t)MAXBUF,bytes_left); read_bytes = bytes_to_copy; status = limeReaderReadData((void *)buf, &read_bytes, reader); if( status < 0 && status != LIME_EOR ) { fprintf(stderr, "LIME read error occurred: status= %d\n", status); exit(EXIT_FAILURE); } if (read_bytes != bytes_to_copy) { fprintf(stderr, "Read error %lld bytes wanted,%lld read\n", (unsigned long long)nbytes, (unsigned long long)read_bytes); return EXIT_FAILURE; } /* copy to the output buffer */ for(i=0; i<read_bytes; i++) buff_out[bcopied+i]=buf[i]; bcopied += read_bytes; bytes_left -= bytes_to_copy; } /* Quit at this record */ break; } limeDestroyReader(reader); DCAP(fclose)(fp); return EXIT_SUCCESS; }
int read_lime_contraction_3d(double * const s, char * filename, const int N, const int position) { #ifdef MPI fprintf(stderr, "[read_lime_contraction_3d] No mpi version.\n"); return(1); #else FILE *ifs=(FILE*)NULL; int status=0, getpos=-1; n_uint64_t bytes; char * header_type; LimeReader * limereader; int prec = 32; DML_Checksum checksum; if((ifs = fopen(filename, "r")) == (FILE*)NULL) { if(g_proc_id == 0) { fprintf(stderr, "Error opening file %s\n", filename); } return(106); } limereader = limeCreateReader( ifs ); if( limereader == (LimeReader *)NULL ) { if(g_proc_id == 0) { fprintf(stderr, "Unable to open LimeReader\n"); } return(-1); } while( (status = limeReaderNextRecord(limereader)) != LIME_EOF ) { if(status != LIME_SUCCESS ) { fprintf(stderr, "limeReaderNextRecord returned error with status = %d!\n", status); status = LIME_EOF; break; } header_type = limeReaderType(limereader); if(strcmp("scidac-binary-data",header_type) == 0) getpos++; if(getpos == position) break; } if(status == LIME_EOF) { if(g_proc_id == 0) { fprintf(stderr, "no scidac-binary-data record found in file %s\n",filename); } limeDestroyReader(limereader); fclose(ifs); if(g_proc_id == 0) { fprintf(stderr, "try to read in non-lime format\n"); } return(read_contraction(s, NULL, filename, N)); } bytes = limeReaderBytes(limereader); if((int)bytes == (LX*g_nproc_x)*(LY*g_nproc_y)*LZ*2*N*sizeof(double)) prec = 64; else if((int)bytes == (LX*g_nproc_x)*(LY*g_nproc_y)*LZ*2*N*sizeof(float)) prec = 32; else { if(g_proc_id == 0) { fprintf(stderr, "wrong length in contraction: bytes = %lu, not %d. Aborting read!\n", bytes, (LX*g_nproc_x)*(LY*g_nproc_y)*LZ*2*N*(int)sizeof(float)); } return(-1); } if(g_proc_id == 0) { printf("# %d Bit precision read\n", prec); } status = read_binary_contraction_data_3d(s, limereader, prec, N, &checksum); if(g_proc_id == 0) { printf("# checksum for contractions in file %s position %d is %#x %#x\n", filename, position, checksum.suma, checksum.sumb); } if(status < 0) { fprintf(stderr, "LIME read error occured with status = %d while reading file %s!\n Aborting...\n", status, filename); exit(500); } limeDestroyReader(limereader); fclose(ifs); return(0); #endif }
// Read in the gaugefield, deprecated tmLqcd routine void GaugeField::read_lime_gauge_field_doubleprec_timeslices(double *gaugefield, const char *filename, const ssize_t slice_i, const ssize_t slice_f) { try { // const int slice_i = 0; // const int slice_f = Lt+1; FILE *ifs; ssize_t t, x, y, z; int status; n_uint64_t bytes; char *header_type; LimeReader *limereader; double tmp[72], tmp2[72]; int words_bigendian; printf("reading gauge fields from files:\n"); // if(verbose){ // printf("reading gauge fields from files:\n"); // } // else{ // printf("\treading gauge fields:\n"); // } words_bigendian = big_endian(); ifs = fopen(filename, "r"); if (ifs == (FILE *)NULL) { fprintf(stderr, "Could not open file %s\n Aborting...\n", filename); exit(500); } limereader = limeCreateReader(ifs); if (limereader == (LimeReader *)NULL) { throw std::runtime_error("Unable to open LimeReader!"); } while ((status = limeReaderNextRecord(limereader)) != LIME_EOF) { if (status != LIME_SUCCESS) { fprintf( stderr, "limeReaderNextRecord returned error with status = %d!\n", status); status = LIME_EOF; break; } header_type = limeReaderType(limereader); if (strcmp("ildg-binary-data", header_type) == 0) break; } if (status == LIME_EOF) { fprintf(stderr, "no ildg-binary-data record found in file %s\n", filename); limeDestroyReader(limereader); fclose(ifs); exit(-2); } bytes = limeReaderBytes(limereader); if (bytes != (n_uint64_t)Lx * Ly * Lz * Lt * 72 * (n_uint64_t)sizeof(double)) { if (bytes != (n_uint64_t)Lx * Ly * Lz * Lt * 72 * (n_uint64_t)sizeof(double) / 2) { fprintf(stderr, "Probably wrong lattice size or precision (bytes=%lu) in file %s " "expected %lu\n", (n_uint64_t)bytes, filename, (n_uint64_t)Lx * Ly * Lz * Lt * 72 * (n_uint64_t)sizeof(double)); fprintf(stderr, "Aborting...!\n"); fflush(stdout); exit(501); } else { fclose(ifs); throw std::runtime_error("Single precision read!"); } } bytes = (n_uint64_t)72 * sizeof(double); for (t = 0; t < Lt; t++) { for (z = 0; z < Lz; z++) { for (y = 0; y < Ly; y++) { for (x = 0; x < Lx; x++) { // check for endianess and reading in data // the pointer limereader is internally increased by bytes // in the limeReaderReadData function if (!words_bigendian) { status = limeReaderReadData(tmp, &bytes, limereader); byte_swap_assign(tmp2, tmp, 72); } else status = limeReaderReadData(tmp2, &bytes, limereader); // check if reading was successfull if (status < 0 && status != LIME_EOR) { fprintf(stderr, "LIME read error occured with status = %d while reading file %s!\n " "Aborting...\n", status, filename); exit(500); } // we just want to read in data in the specific range of timeslices // must be here because the limereader pointer must be increased // correctly // could be done with much more performance but might be tricky to // do correctly if (t < slice_i || t > slice_f) continue; // copy of link variables from tmp2 into config // ILDG has mu-order: x,y,z,t so it is changed here to: t,x,y,z ! const ssize_t p = (ssize_t)(((t - slice_i) * Lx * Lz * Lz + x * Ly * Lz + y * Lz + z) * 72); // position in config ssize_t k = 0; for (ssize_t mu = 1; mu <= 4; mu++) { // mu=4 is for the shift of U_t ssize_t index; if (mu != 4) index = p + mu * 18; // for U_x, U_y and U_z else index = p; // U_t is copied into the beginning of // the (config+p) array for (ssize_t i = 0; i < 3; i++) { for (ssize_t j = 0; j < 3; j++) { gaugefield[index + 6 * i + 2 * j] = tmp2[2 * k]; gaugefield[index + 6 * i + 2 * j + 1] = tmp2[2 * k + 1]; k++; } } } // loop over mu ends here } // loop over position space ends here } } } if (status < 0 && status != LIME_EOR) { fprintf(stderr, "LIME read error occured with status = %d while reading file %s!\n " "Aborting...\n", status, filename); exit(500); } limeDestroyReader(limereader); fclose(ifs); return; } catch (std::exception &e) { std::cout << e.what() << "in: ReadWrite::read_lime_gauge_field_doubleprec_timeslices\n"; throw e; } }
int main(int argc, char *argv[]) { char* data_buf; LimeReader *reader; FILE *fp; int status; n_uint64_t nbytes, read_bytes; int msg,rec,first; char *lime_type; size_t bytes_pad; int MB_flag, ME_flag; if( argc != 2 ) { fprintf(stderr, "Usage: %s <lime_file>\n", argv[0]); return EXIT_FAILURE; } fp = DCAPL(fopen)(argv[1], "r"); if(fp == (FILE *)NULL) { fprintf(stderr,"Unable to open file %s for reading\n", argv[1]); return EXIT_FAILURE; } reader = limeCreateReader(fp); if( reader == (LimeReader *)NULL ) { fprintf(stderr, "Unable to open LimeReader\n"); return EXIT_FAILURE; } msg = 0; first = 1; rec = 0; while( (status = limeReaderNextRecord(reader)) != LIME_EOF ){ if( status != LIME_SUCCESS ) { fprintf(stderr, "limeReaderNextRecord returned status = %d\n", status); return EXIT_FAILURE; } nbytes = limeReaderBytes(reader); lime_type = limeReaderType(reader); bytes_pad = limeReaderPadBytes(reader); MB_flag = limeReaderMBFlag(reader); ME_flag = limeReaderMEFlag(reader); if (MB_flag == 1 || first) { first = 0; rec = 0; msg++; } rec++; printf("\n\n"); printf("Message: %d\n", msg); printf("Record: %d\n", rec); printf("Type: %s\n", lime_type); printf("Data Length: %llu\n", (unsigned long long)nbytes); printf("Padding Length: %lu\n", (unsigned long)bytes_pad); printf("MB flag: %d\n", MB_flag); printf("ME flag: %d\n", ME_flag); /* TO DO: Buffer the input */ if(nbytes < MAX_BYTES){ data_buf = (char *)malloc((size_t)nbytes+1); if( data_buf == (char *)NULL) { fprintf(stderr, "Couldn't malloc data buf\n"); return EXIT_FAILURE; } read_bytes = nbytes; status = limeReaderReadData((void *)data_buf, &read_bytes, reader); if( status < 0 ) { if( status != LIME_EOR ) { fprintf(stderr, "LIME read error occurred: status= %d %llu bytes wanted, %llu read\n", status, (unsigned long long)nbytes, (unsigned long long)read_bytes); return EXIT_FAILURE; } } data_buf[nbytes]='\0'; if(!all_ascii(data_buf, nbytes)) printf("Data: [Binary data]\n"); else printf("Data: \"%s\" \n", data_buf); free(data_buf); } else{ printf("Data: [Long record skipped]\n"); } } limeDestroyReader(reader); DCAP(fclose)(fp); return EXIT_SUCCESS; }