git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@2930 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp 2009-06-30 19:31:16 +00:00
parent 4d4f48bb74
commit 3092a34191
5 changed files with 29 additions and 11 deletions

View File

@ -106,8 +106,13 @@ Dump::~Dump()
// XTC style sets fp to NULL since it closes file in its destructor // XTC style sets fp to NULL since it closes file in its destructor
if (multifile == 0 && fp != NULL) { if (multifile == 0 && fp != NULL) {
if (multiproc) fclose(fp); if (compressed) {
else if (me == 0) fclose(fp); if (multiproc) pclose(fp);
else if (me == 0) pclose(fp);
} else {
if (multiproc) fclose(fp);
else if (me == 0) fclose(fp);
}
} }
} }
@ -205,8 +210,13 @@ void Dump::write()
// if file per timestep, close file // if file per timestep, close file
if (multifile) { if (multifile) {
if (multiproc) fclose(fp); if (compressed) {
else if (me == 0) fclose(fp); if (multiproc) pclose(fp);
else if (me == 0) pclose(fp);
} else {
if (multiproc) fclose(fp);
else if (me == 0) fclose(fp);
}
} }
} }

View File

@ -500,7 +500,11 @@ void FixTMD::readfile(char *file)
// clean up // clean up
delete [] buffer; delete [] buffer;
if (me == 0) fclose(fp);
if (me == 0) {
if (compressed) pclose(fp);
else fclose(fp);
}
// check that all atoms in group were listed in target file // check that all atoms in group were listed in target file
// set xf = 0.0 for atoms not in group // set xf = 0.0 for atoms not in group
@ -525,7 +529,7 @@ void FixTMD::readfile(char *file)
void FixTMD::open(char *file) void FixTMD::open(char *file)
{ {
int compressed = 0; compressed = 0;
char *suffix = file + strlen(file) - 3; char *suffix = file + strlen(file) - 3;
if (suffix > file && strcmp(suffix,".gz") == 0) compressed = 1; if (suffix > file && strcmp(suffix,".gz") == 0) compressed = 1;
if (!compressed) fp = fopen(file,"r"); if (!compressed) fp = fopen(file,"r");

View File

@ -37,7 +37,7 @@ class FixTMD : public Fix {
private: private:
int me; int me;
int nfileevery,previous_stat; int nfileevery,previous_stat,compressed;
FILE *fp; FILE *fp;
double rho_start,rho_stop,rho_old,masstotal; double rho_start,rho_stop,rho_old,masstotal;
double dtv,dtf; double dtv,dtf;

View File

@ -86,7 +86,8 @@ void ReadData::command(int narg, char **arg)
header(0); header(0);
scan(atom->bond_per_atom,atom->angle_per_atom, scan(atom->bond_per_atom,atom->angle_per_atom,
atom->dihedral_per_atom,atom->improper_per_atom); atom->dihedral_per_atom,atom->improper_per_atom);
fclose(fp); if (compressed) pclose(fp);
else fclose(fp);
atom->bond_per_atom += atom->extra_bond_per_atom; atom->bond_per_atom += atom->extra_bond_per_atom;
} }
@ -256,7 +257,10 @@ void ReadData::command(int narg, char **arg)
// close file // close file
if (me == 0) fclose(fp); if (me == 0) {
if (compressed) pclose(fp);
else fclose(fp);
}
// error if natoms > 0 yet no atoms were read // error if natoms > 0 yet no atoms were read
@ -1219,7 +1223,7 @@ int ReadData::reallocate(int **pcount, int cmax, int amax)
void ReadData::open(char *file) void ReadData::open(char *file)
{ {
int compressed = 0; compressed = 0;
char *suffix = file + strlen(file) - 3; char *suffix = file + strlen(file) - 3;
if (suffix > file && strcmp(suffix,".gz") == 0) compressed = 1; if (suffix > file && strcmp(suffix,".gz") == 0) compressed = 1;
if (!compressed) fp = fopen(file,"r"); if (!compressed) fp = fopen(file,"r");

View File

@ -29,7 +29,7 @@ class ReadData : protected Pointers {
int me; int me;
char *line,*keyword,*buffer; char *line,*keyword,*buffer;
FILE *fp; FILE *fp;
int narg,maxarg; int narg,maxarg,compressed;
char **arg; char **arg;
void open(char *); void open(char *);