forked from lijiext/lammps
git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@3150 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
parent
3e6da4ede1
commit
799775274d
|
@ -34,10 +34,6 @@ DumpBond::DumpBond(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg)
|
|||
int n = strlen(str) + 1;
|
||||
format_default = new char[n];
|
||||
strcpy(format_default,str);
|
||||
|
||||
// one-time file open
|
||||
|
||||
if (multifile == 0) openfile();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
@ -53,6 +49,10 @@ void DumpBond::init()
|
|||
format = new char[n];
|
||||
strcpy(format,str);
|
||||
strcat(format,"\n");
|
||||
|
||||
// open single file, one time only
|
||||
|
||||
if (multifile == 0) openfile();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
|
35
src/dump.cpp
35
src/dump.cpp
|
@ -53,6 +53,7 @@ Dump::Dump(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
|
|||
format_user = NULL;
|
||||
|
||||
sort_flag = 0;
|
||||
append_flag = 0;
|
||||
|
||||
maxbuf = 0;
|
||||
buf = NULL;
|
||||
|
@ -65,6 +66,7 @@ Dump::Dump(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
|
|||
// else if ends in .gz = gzipped text file
|
||||
// else ASCII text file
|
||||
|
||||
singlefile_opened = 0;
|
||||
compressed = 0;
|
||||
binary = 0;
|
||||
multifile = 0;
|
||||
|
@ -233,7 +235,22 @@ void Dump::modify_params(int narg, char **arg)
|
|||
|
||||
int iarg = 0;
|
||||
while (iarg < narg) {
|
||||
if (strcmp(arg[iarg],"format") == 0) {
|
||||
if (strcmp(arg[iarg],"append") == 0) {
|
||||
if (iarg+2 > narg) error->all("Illegal dump_modify command");
|
||||
if (strcmp(arg[iarg+1],"yes") == 0) append_flag = 1;
|
||||
else if (strcmp(arg[iarg+1],"no") == 0) append_flag = 0;
|
||||
else error->all("Illegal dump_modify command");
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"every") == 0) {
|
||||
if (iarg+2 > narg) error->all("Illegal dump_modify command");
|
||||
int n = atoi(arg[iarg+1]);
|
||||
if (n <= 0) error->all("Illegal dump_modify command");
|
||||
int idump;
|
||||
for (idump = 0; idump < output->ndump; idump++)
|
||||
if (strcmp(id,output->dump[idump]->id) == 0) break;
|
||||
output->dump_every[idump] = n;
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"format") == 0) {
|
||||
if (iarg+2 > narg) error->all("Illegal dump_modify command");
|
||||
delete [] format_user;
|
||||
format_user = NULL;
|
||||
|
@ -249,15 +266,6 @@ void Dump::modify_params(int narg, char **arg)
|
|||
else if (strcmp(arg[iarg+1],"no") == 0) flush_flag = 0;
|
||||
else error->all("Illegal dump_modify command");
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"every") == 0) {
|
||||
if (iarg+2 > narg) error->all("Illegal dump_modify command");
|
||||
int n = atoi(arg[iarg+1]);
|
||||
if (n <= 0) error->all("Illegal dump_modify command");
|
||||
int idump;
|
||||
for (idump = 0; idump < output->ndump; idump++)
|
||||
if (strcmp(id,output->dump[idump]->id) == 0) break;
|
||||
output->dump_every[idump] = n;
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"sort") == 0) {
|
||||
if (iarg+2 > narg) error->all("Illegal dump_modify command");
|
||||
if (strcmp(arg[iarg+1],"yes") == 0) sort_flag = 1;
|
||||
|
@ -290,6 +298,11 @@ double Dump::memory_usage()
|
|||
|
||||
void Dump::openfile()
|
||||
{
|
||||
// single file, already opened, so just return
|
||||
|
||||
if (singlefile_opened) return;
|
||||
if (multifile == 0) singlefile_opened = 1;
|
||||
|
||||
// if one file per timestep, replace '*' with current timestep
|
||||
|
||||
char *filecurrent;
|
||||
|
@ -315,6 +328,8 @@ void Dump::openfile()
|
|||
#endif
|
||||
} else if (binary) {
|
||||
fp = fopen(filecurrent,"wb");
|
||||
} else if (append_flag) {
|
||||
fp = fopen(filecurrent,"a");
|
||||
} else {
|
||||
fp = fopen(filecurrent,"w");
|
||||
}
|
||||
|
|
|
@ -35,6 +35,8 @@ class Dump : protected Pointers {
|
|||
int header_flag; // 0 = item, 2 = xyz
|
||||
int flush_flag; // 0 if no flush, 1 if flush every dump
|
||||
int sort_flag; // 1 if write in sorted order, 0 if not
|
||||
int append_flag; // 1 if open file in append mode, 0 if not
|
||||
int singlefile_opened; // 1 = one big file, already opened, else 0
|
||||
|
||||
char *format_default; // default format string
|
||||
char *format_user; // format string set by user
|
||||
|
|
|
@ -30,10 +30,6 @@ DumpAtom::DumpAtom(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg)
|
|||
scale_flag = 1;
|
||||
image_flag = 0;
|
||||
format_default = NULL;
|
||||
|
||||
// one-time file open
|
||||
|
||||
if (multifile == 0) openfile();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
@ -99,6 +95,10 @@ void DumpAtom::init()
|
|||
if (binary) write_choice = &DumpAtom::write_binary;
|
||||
else if (image_flag == 0) write_choice = &DumpAtom::write_noimage;
|
||||
else if (image_flag == 1) write_choice = &DumpAtom::write_image;
|
||||
|
||||
// open single file, one time only
|
||||
|
||||
if (multifile == 0) openfile();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
|
|
@ -112,10 +112,6 @@ DumpCustom::DumpCustom(LAMMPS *lmp, int narg, char **arg) :
|
|||
strcat(columns,arg[iarg]);
|
||||
strcat(columns," ");
|
||||
}
|
||||
|
||||
// one-time file open
|
||||
|
||||
if (multifile == 0) openfile();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
@ -219,6 +215,10 @@ void DumpCustom::init()
|
|||
if (ivariable < 0) error->all("Could not find dump custom variable name");
|
||||
variable[i] = ivariable;
|
||||
}
|
||||
|
||||
// open single file, one time only
|
||||
|
||||
if (multifile == 0) openfile();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
|
|
@ -45,9 +45,6 @@ DumpXYZ::DumpXYZ(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg)
|
|||
coords = (float *) memory->smalloc(3*natoms*sizeof(float),"dump:coords");
|
||||
}
|
||||
|
||||
// one-time file open
|
||||
|
||||
if (multifile == 0) openfile();
|
||||
ntotal = 0;
|
||||
}
|
||||
|
||||
|
@ -74,6 +71,10 @@ void DumpXYZ::init()
|
|||
format = new char[n];
|
||||
strcpy(format,str);
|
||||
strcat(format,"\n");
|
||||
|
||||
// open single file, one time only
|
||||
|
||||
if (multifile == 0) openfile();
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue