Refactoring dump_atom.cpp
This commit is contained in:
@ -182,6 +182,7 @@ void DumpAtom::format_endian_binary()
|
|||||||
int endian = ENDIAN;
|
int endian = ENDIAN;
|
||||||
fwrite(&endian, sizeof(int), 1, fp);
|
fwrite(&endian, sizeof(int), 1, fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
void DumpAtom::format_revision_binary()
|
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()
|
void DumpAtom::header_format_binary()
|
||||||
{
|
{
|
||||||
format_magic_string_binary();
|
format_magic_string_binary();
|
||||||
@ -217,21 +242,8 @@ void DumpAtom::header_binary(bigint ndump)
|
|||||||
fwrite(&boxzhi,sizeof(double),1,fp);
|
fwrite(&boxzhi,sizeof(double),1,fp);
|
||||||
fwrite(&size_one,sizeof(int),1,fp);
|
fwrite(&size_one,sizeof(int),1,fp);
|
||||||
|
|
||||||
int len = 0;
|
header_unit_style_binary();
|
||||||
|
header_columns_binary();
|
||||||
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);
|
|
||||||
|
|
||||||
|
|
||||||
if (multiproc) fwrite(&nclusterprocs,sizeof(int),1,fp);
|
if (multiproc) fwrite(&nclusterprocs,sizeof(int),1,fp);
|
||||||
else fwrite(&nprocs,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)
|
void DumpAtom::header_binary_triclinic(bigint ndump)
|
||||||
{
|
{
|
||||||
header_format_binary();
|
header_format_binary();
|
||||||
|
|
||||||
fwrite(&update->ntimestep,sizeof(bigint),1,fp);
|
fwrite(&update->ntimestep,sizeof(bigint),1,fp);
|
||||||
fwrite(&ndump,sizeof(bigint),1,fp);
|
fwrite(&ndump,sizeof(bigint),1,fp);
|
||||||
fwrite(&domain->triclinic,sizeof(int),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(&boxyz,sizeof(double),1,fp);
|
||||||
fwrite(&size_one,sizeof(int),1,fp);
|
fwrite(&size_one,sizeof(int),1,fp);
|
||||||
|
|
||||||
int len = 0;
|
header_unit_style_binary();
|
||||||
|
header_columns_binary();
|
||||||
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);
|
|
||||||
|
|
||||||
if (multiproc) fwrite(&nclusterprocs,sizeof(int),1,fp);
|
if (multiproc) fwrite(&nclusterprocs,sizeof(int),1,fp);
|
||||||
else fwrite(&nprocs,sizeof(int),1,fp);
|
else fwrite(&nprocs,sizeof(int),1,fp);
|
||||||
|
|||||||
@ -46,6 +46,8 @@ class DumpAtom : public Dump {
|
|||||||
void write_data(int, double *);
|
void write_data(int, double *);
|
||||||
|
|
||||||
void header_format_binary();
|
void header_format_binary();
|
||||||
|
void header_unit_style_binary();
|
||||||
|
void header_columns_binary();
|
||||||
void format_magic_string_binary();
|
void format_magic_string_binary();
|
||||||
void format_endian_binary();
|
void format_endian_binary();
|
||||||
void format_revision_binary();
|
void format_revision_binary();
|
||||||
|
|||||||
Reference in New Issue
Block a user