Refactoring dump_atom.cpp
This commit is contained in:
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user