add support for optionally including unit information in standard dump files
This commit is contained in:
@ -108,27 +108,26 @@ void DumpAtomGZ::openfile()
|
|||||||
void DumpAtomGZ::write_header(bigint ndump)
|
void DumpAtomGZ::write_header(bigint ndump)
|
||||||
{
|
{
|
||||||
if ((multiproc) || (!multiproc && me == 0)) {
|
if ((multiproc) || (!multiproc && me == 0)) {
|
||||||
|
if (unit_flag && !unit_count) {
|
||||||
|
++unit_count;
|
||||||
|
gzprintf(gzFp,"ITEM: UNITS\n%s\n",update->unit_style);
|
||||||
|
}
|
||||||
|
gzprintf(gzFp,"ITEM: TIMESTEP\n");
|
||||||
|
gzprintf(gzFp,BIGINT_FORMAT "\n",update->ntimestep);
|
||||||
|
gzprintf(gzFp,"ITEM: NUMBER OF ATOMS\n");
|
||||||
|
gzprintf(gzFp,BIGINT_FORMAT "\n",ndump);
|
||||||
if (domain->triclinic == 0) {
|
if (domain->triclinic == 0) {
|
||||||
gzprintf(gzFp,"ITEM: TIMESTEP\n");
|
|
||||||
gzprintf(gzFp,BIGINT_FORMAT "\n",update->ntimestep);
|
|
||||||
gzprintf(gzFp,"ITEM: NUMBER OF ATOMS\n");
|
|
||||||
gzprintf(gzFp,BIGINT_FORMAT "\n",ndump);
|
|
||||||
gzprintf(gzFp,"ITEM: BOX BOUNDS %s\n",boundstr);
|
gzprintf(gzFp,"ITEM: BOX BOUNDS %s\n",boundstr);
|
||||||
gzprintf(gzFp,"%g %g\n",boxxlo,boxxhi);
|
gzprintf(gzFp,"%g %g\n",boxxlo,boxxhi);
|
||||||
gzprintf(gzFp,"%g %g\n",boxylo,boxyhi);
|
gzprintf(gzFp,"%g %g\n",boxylo,boxyhi);
|
||||||
gzprintf(gzFp,"%g %g\n",boxzlo,boxzhi);
|
gzprintf(gzFp,"%g %g\n",boxzlo,boxzhi);
|
||||||
gzprintf(gzFp,"ITEM: ATOMS %s\n",columns);
|
|
||||||
} else {
|
} else {
|
||||||
gzprintf(gzFp,"ITEM: TIMESTEP\n");
|
|
||||||
gzprintf(gzFp,BIGINT_FORMAT "\n",update->ntimestep);
|
|
||||||
gzprintf(gzFp,"ITEM: NUMBER OF ATOMS\n");
|
|
||||||
gzprintf(gzFp,BIGINT_FORMAT "\n",ndump);
|
|
||||||
gzprintf(gzFp,"ITEM: BOX BOUNDS xy xz yz %s\n",boundstr);
|
gzprintf(gzFp,"ITEM: BOX BOUNDS xy xz yz %s\n",boundstr);
|
||||||
gzprintf(gzFp,"%g %g %g\n",boxxlo,boxxhi,boxxy);
|
gzprintf(gzFp,"%g %g %g\n",boxxlo,boxxhi,boxxy);
|
||||||
gzprintf(gzFp,"%g %g %g\n",boxylo,boxyhi,boxxz);
|
gzprintf(gzFp,"%g %g %g\n",boxylo,boxyhi,boxxz);
|
||||||
gzprintf(gzFp,"%g %g %g\n",boxzlo,boxzhi,boxyz);
|
gzprintf(gzFp,"%g %g %g\n",boxzlo,boxzhi,boxyz);
|
||||||
gzprintf(gzFp,"ITEM: ATOMS %s\n",columns);
|
|
||||||
}
|
}
|
||||||
|
gzprintf(gzFp,"ITEM: ATOMS %s\n",columns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -108,27 +108,26 @@ void DumpCustomGZ::openfile()
|
|||||||
void DumpCustomGZ::write_header(bigint ndump)
|
void DumpCustomGZ::write_header(bigint ndump)
|
||||||
{
|
{
|
||||||
if ((multiproc) || (!multiproc && me == 0)) {
|
if ((multiproc) || (!multiproc && me == 0)) {
|
||||||
|
if (unit_flag && !unit_count) {
|
||||||
|
++unit_count;
|
||||||
|
gzprintf(gzFp,"ITEM: UNITS\n%s\n",update->unit_style);
|
||||||
|
}
|
||||||
|
gzprintf(gzFp,"ITEM: TIMESTEP\n");
|
||||||
|
gzprintf(gzFp,BIGINT_FORMAT "\n",update->ntimestep);
|
||||||
|
gzprintf(gzFp,"ITEM: NUMBER OF ATOMS\n");
|
||||||
|
gzprintf(gzFp,BIGINT_FORMAT "\n",ndump);
|
||||||
if (domain->triclinic == 0) {
|
if (domain->triclinic == 0) {
|
||||||
gzprintf(gzFp,"ITEM: TIMESTEP\n");
|
|
||||||
gzprintf(gzFp,BIGINT_FORMAT "\n",update->ntimestep);
|
|
||||||
gzprintf(gzFp,"ITEM: NUMBER OF ATOMS\n");
|
|
||||||
gzprintf(gzFp,BIGINT_FORMAT "\n",ndump);
|
|
||||||
gzprintf(gzFp,"ITEM: BOX BOUNDS %s\n",boundstr);
|
gzprintf(gzFp,"ITEM: BOX BOUNDS %s\n",boundstr);
|
||||||
gzprintf(gzFp,"%-1.16g %-1.16g\n",boxxlo,boxxhi);
|
gzprintf(gzFp,"%-1.16g %-1.16g\n",boxxlo,boxxhi);
|
||||||
gzprintf(gzFp,"%-1.16g %-1.16g\n",boxylo,boxyhi);
|
gzprintf(gzFp,"%-1.16g %-1.16g\n",boxylo,boxyhi);
|
||||||
gzprintf(gzFp,"%-1.16g %-1.16g\n",boxzlo,boxzhi);
|
gzprintf(gzFp,"%-1.16g %-1.16g\n",boxzlo,boxzhi);
|
||||||
gzprintf(gzFp,"ITEM: ATOMS %s\n",columns);
|
|
||||||
} else {
|
} else {
|
||||||
gzprintf(gzFp,"ITEM: TIMESTEP\n");
|
|
||||||
gzprintf(gzFp,BIGINT_FORMAT "\n",update->ntimestep);
|
|
||||||
gzprintf(gzFp,"ITEM: NUMBER OF ATOMS\n");
|
|
||||||
gzprintf(gzFp,BIGINT_FORMAT "\n",ndump);
|
|
||||||
gzprintf(gzFp,"ITEM: BOX BOUNDS xy xz yz %s\n",boundstr);
|
gzprintf(gzFp,"ITEM: BOX BOUNDS xy xz yz %s\n",boundstr);
|
||||||
gzprintf(gzFp,"%-1.16g %-1.16g %-1.16g\n",boxxlo,boxxhi,boxxy);
|
gzprintf(gzFp,"%-1.16g %-1.16g %-1.16g\n",boxxlo,boxxhi,boxxy);
|
||||||
gzprintf(gzFp,"%-1.16g %-1.16g %-1.16g\n",boxylo,boxyhi,boxxz);
|
gzprintf(gzFp,"%-1.16g %-1.16g %-1.16g\n",boxylo,boxyhi,boxxz);
|
||||||
gzprintf(gzFp,"%-1.16g %-1.16g %-1.16g\n",boxzlo,boxzhi,boxyz);
|
gzprintf(gzFp,"%-1.16g %-1.16g %-1.16g\n",boxzlo,boxzhi,boxyz);
|
||||||
gzprintf(gzFp,"ITEM: ATOMS %s\n",columns);
|
|
||||||
}
|
}
|
||||||
|
gzprintf(gzFp,"ITEM: ATOMS %s\n",columns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
11
src/dump.cpp
11
src/dump.cpp
@ -87,6 +87,8 @@ Dump::Dump(LAMMPS *lmp, int /*narg*/, char **arg) : Pointers(lmp)
|
|||||||
buffer_flag = 0;
|
buffer_flag = 0;
|
||||||
padflag = 0;
|
padflag = 0;
|
||||||
pbcflag = 0;
|
pbcflag = 0;
|
||||||
|
unit_flag = 0;
|
||||||
|
unit_count = 0;
|
||||||
delay_flag = 0;
|
delay_flag = 0;
|
||||||
|
|
||||||
maxfiles = -1;
|
maxfiles = -1;
|
||||||
@ -545,6 +547,8 @@ void Dump::openfile()
|
|||||||
if (singlefile_opened) return;
|
if (singlefile_opened) return;
|
||||||
if (multifile == 0) singlefile_opened = 1;
|
if (multifile == 0) singlefile_opened = 1;
|
||||||
|
|
||||||
|
unit_count = 0;
|
||||||
|
|
||||||
// if one file per timestep, replace '*' with current timestep
|
// if one file per timestep, replace '*' with current timestep
|
||||||
|
|
||||||
char *filecurrent = filename;
|
char *filecurrent = filename;
|
||||||
@ -1119,6 +1123,13 @@ void Dump::modify_params(int narg, char **arg)
|
|||||||
}
|
}
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
|
|
||||||
|
} else if (strcmp(arg[iarg],"units") == 0) {
|
||||||
|
if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command");
|
||||||
|
if (strcmp(arg[iarg+1],"yes") == 0) unit_flag = 1;
|
||||||
|
else if (strcmp(arg[iarg+1],"no") == 0) unit_flag = 0;
|
||||||
|
else error->all(FLERR,"Illegal dump_modify command");
|
||||||
|
iarg += 2;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
int n = modify_param(narg-iarg,&arg[iarg]);
|
int n = modify_param(narg-iarg,&arg[iarg]);
|
||||||
if (n == 0) error->all(FLERR,"Illegal dump_modify command");
|
if (n == 0) error->all(FLERR,"Illegal dump_modify command");
|
||||||
|
|||||||
@ -75,6 +75,8 @@ class Dump : protected Pointers {
|
|||||||
int sortcol; // 0 to sort on ID, 1-N on columns
|
int sortcol; // 0 to sort on ID, 1-N on columns
|
||||||
int sortcolm1; // sortcol - 1
|
int sortcolm1; // sortcol - 1
|
||||||
int sortorder; // ASCEND or DESCEND
|
int sortorder; // ASCEND or DESCEND
|
||||||
|
int unit_flag; // 1 if dump should contain unit information
|
||||||
|
int unit_count; // # of times the unit information was written
|
||||||
int delay_flag; // 1 if delay output until delaystep
|
int delay_flag; // 1 if delay output until delaystep
|
||||||
bigint delaystep;
|
bigint delaystep;
|
||||||
|
|
||||||
|
|||||||
@ -209,7 +209,10 @@ void DumpAtom::header_binary_triclinic(bigint ndump)
|
|||||||
|
|
||||||
void DumpAtom::header_item(bigint ndump)
|
void DumpAtom::header_item(bigint ndump)
|
||||||
{
|
{
|
||||||
fprintf(fp,"ITEM: UNITS\n%s\n",update->unit_style);
|
if (unit_flag && !unit_count) {
|
||||||
|
++unit_count;
|
||||||
|
fprintf(fp,"ITEM: UNITS\n%s\n",update->unit_style);
|
||||||
|
}
|
||||||
fprintf(fp,"ITEM: TIMESTEP\n");
|
fprintf(fp,"ITEM: TIMESTEP\n");
|
||||||
fprintf(fp,BIGINT_FORMAT "\n",update->ntimestep);
|
fprintf(fp,BIGINT_FORMAT "\n",update->ntimestep);
|
||||||
fprintf(fp,"ITEM: NUMBER OF ATOMS\n");
|
fprintf(fp,"ITEM: NUMBER OF ATOMS\n");
|
||||||
@ -225,7 +228,10 @@ void DumpAtom::header_item(bigint ndump)
|
|||||||
|
|
||||||
void DumpAtom::header_item_triclinic(bigint ndump)
|
void DumpAtom::header_item_triclinic(bigint ndump)
|
||||||
{
|
{
|
||||||
fprintf(fp,"ITEM: UNITS\n%s\n",update->unit_style);
|
if (unit_flag && !unit_count) {
|
||||||
|
++unit_count;
|
||||||
|
fprintf(fp,"ITEM: UNITS\n%s\n",update->unit_style);
|
||||||
|
}
|
||||||
fprintf(fp,"ITEM: TIMESTEP\n");
|
fprintf(fp,"ITEM: TIMESTEP\n");
|
||||||
fprintf(fp,BIGINT_FORMAT "\n",update->ntimestep);
|
fprintf(fp,BIGINT_FORMAT "\n",update->ntimestep);
|
||||||
fprintf(fp,"ITEM: NUMBER OF ATOMS\n");
|
fprintf(fp,"ITEM: NUMBER OF ATOMS\n");
|
||||||
|
|||||||
@ -420,7 +420,10 @@ void DumpCustom::header_binary_triclinic(bigint ndump)
|
|||||||
|
|
||||||
void DumpCustom::header_item(bigint ndump)
|
void DumpCustom::header_item(bigint ndump)
|
||||||
{
|
{
|
||||||
fprintf(fp,"ITEM: UNITS\n%s\n",update->unit_style);
|
if (unit_flag && !unit_count) {
|
||||||
|
++unit_count;
|
||||||
|
fprintf(fp,"ITEM: UNITS\n%s\n",update->unit_style);
|
||||||
|
}
|
||||||
fprintf(fp,"ITEM: TIMESTEP\n");
|
fprintf(fp,"ITEM: TIMESTEP\n");
|
||||||
fprintf(fp,BIGINT_FORMAT "\n",update->ntimestep);
|
fprintf(fp,BIGINT_FORMAT "\n",update->ntimestep);
|
||||||
fprintf(fp,"ITEM: NUMBER OF ATOMS\n");
|
fprintf(fp,"ITEM: NUMBER OF ATOMS\n");
|
||||||
@ -436,6 +439,10 @@ void DumpCustom::header_item(bigint ndump)
|
|||||||
|
|
||||||
void DumpCustom::header_item_triclinic(bigint ndump)
|
void DumpCustom::header_item_triclinic(bigint ndump)
|
||||||
{
|
{
|
||||||
|
if (unit_flag && !unit_count) {
|
||||||
|
++unit_count;
|
||||||
|
fprintf(fp,"ITEM: UNITS\n%s\n",update->unit_style);
|
||||||
|
}
|
||||||
fprintf(fp,"ITEM: TIMESTEP\n");
|
fprintf(fp,"ITEM: TIMESTEP\n");
|
||||||
fprintf(fp,BIGINT_FORMAT "\n",update->ntimestep);
|
fprintf(fp,BIGINT_FORMAT "\n",update->ntimestep);
|
||||||
fprintf(fp,"ITEM: NUMBER OF ATOMS\n");
|
fprintf(fp,"ITEM: NUMBER OF ATOMS\n");
|
||||||
|
|||||||
@ -256,7 +256,10 @@ int DumpLocal::modify_param(int narg, char **arg)
|
|||||||
void DumpLocal::write_header(bigint ndump)
|
void DumpLocal::write_header(bigint ndump)
|
||||||
{
|
{
|
||||||
if (me == 0) {
|
if (me == 0) {
|
||||||
fprintf(fp,"ITEM: UNITS\n%s\n",update->unit_style);
|
if (unit_flag && !unit_count) {
|
||||||
|
++unit_count;
|
||||||
|
fprintf(fp,"ITEM: UNITS\n%s\n",update->unit_style);
|
||||||
|
}
|
||||||
fprintf(fp,"ITEM: TIMESTEP\n");
|
fprintf(fp,"ITEM: TIMESTEP\n");
|
||||||
fprintf(fp,BIGINT_FORMAT "\n",update->ntimestep);
|
fprintf(fp,BIGINT_FORMAT "\n",update->ntimestep);
|
||||||
fprintf(fp,"ITEM: NUMBER OF %s\n",label);
|
fprintf(fp,"ITEM: NUMBER OF %s\n",label);
|
||||||
|
|||||||
Reference in New Issue
Block a user