Refactoring dump_atom.cpp

This commit is contained in:
Richard Berger 2020-08-13 11:35:05 -04:00
parent 836ba01d51
commit 6d80435b51
No known key found for this signature in database
GPG Key ID: A9E83994E0BA0CAB
2 changed files with 32 additions and 29 deletions

View File

@ -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);

View File

@ -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();