diff --git a/src/dump_atom.cpp b/src/dump_atom.cpp index 7e89e5a075..6e70fdcd79 100644 --- a/src/dump_atom.cpp +++ b/src/dump_atom.cpp @@ -182,6 +182,7 @@ void DumpAtom::format_endian_binary() int endian = ENDIAN; fwrite(&endian, sizeof(int), 1, fp); } + /* ---------------------------------------------------------------------- */ void DumpAtom::format_revision_binary() @@ -192,6 +193,30 @@ void DumpAtom::format_revision_binary() /* ---------------------------------------------------------------------- */ +void DumpAtom::header_unit_style_binary() +{ + int len = 0; + if (unit_flag && !unit_count) { + ++unit_count; + len = strlen(update->unit_style); + fwrite(&len, sizeof(int), 1, fp); + fwrite(update->unit_style, sizeof(char), len, fp); + } else { + fwrite(&len, sizeof(int), 1, fp); + } +} + +/* ---------------------------------------------------------------------- */ + +void DumpAtom::header_columns_binary() +{ + int len = strlen(columns); + fwrite(&len, sizeof(int), 1, fp); + fwrite(columns, sizeof(char), len, fp); +} + +/* ---------------------------------------------------------------------- */ + void DumpAtom::header_format_binary() { format_magic_string_binary(); @@ -217,21 +242,8 @@ void DumpAtom::header_binary(bigint ndump) fwrite(&boxzhi,sizeof(double),1,fp); fwrite(&size_one,sizeof(int),1,fp); - int len = 0; - - if (unit_flag && !unit_count) { - ++unit_count; - len = strlen(update->unit_style); - fwrite(&len, sizeof(int), 1, fp); - fwrite(update->unit_style, sizeof(char), len, fp); - } else { - fwrite(&len, sizeof(int), 1, fp); - } - - len = strlen(columns); - fwrite(&len, sizeof(int), 1, fp); - fwrite(columns, sizeof(char), len, fp); - + header_unit_style_binary(); + header_columns_binary(); if (multiproc) fwrite(&nclusterprocs,sizeof(int),1,fp); else fwrite(&nprocs,sizeof(int),1,fp); @@ -242,6 +254,7 @@ void DumpAtom::header_binary(bigint ndump) void DumpAtom::header_binary_triclinic(bigint ndump) { header_format_binary(); + fwrite(&update->ntimestep,sizeof(bigint),1,fp); fwrite(&ndump,sizeof(bigint),1,fp); fwrite(&domain->triclinic,sizeof(int),1,fp); @@ -257,20 +270,8 @@ void DumpAtom::header_binary_triclinic(bigint ndump) fwrite(&boxyz,sizeof(double),1,fp); fwrite(&size_one,sizeof(int),1,fp); - int len = 0; - - if (unit_flag && !unit_count) { - ++unit_count; - len = strlen(update->unit_style); - fwrite(&len, sizeof(int), 1, fp); - fwrite(update->unit_style, sizeof(char), len, fp); - } else { - fwrite(&len, sizeof(int), 1, fp); - } - - len = strlen(columns); - fwrite(&len, sizeof(int), 1, fp); - fwrite(columns, sizeof(char), len, fp); + header_unit_style_binary(); + header_columns_binary(); if (multiproc) fwrite(&nclusterprocs,sizeof(int),1,fp); else fwrite(&nprocs,sizeof(int),1,fp); diff --git a/src/dump_atom.h b/src/dump_atom.h index 4431a67bc0..433c52427a 100644 --- a/src/dump_atom.h +++ b/src/dump_atom.h @@ -46,6 +46,8 @@ class DumpAtom : public Dump { void write_data(int, double *); void header_format_binary(); + void header_unit_style_binary(); + void header_columns_binary(); void format_magic_string_binary(); void format_endian_binary(); void format_revision_binary();