From cfe0d02a30f115a6d61aaf4f2575de34c20494bb Mon Sep 17 00:00:00 2001 From: sjplimp Date: Tue, 8 Apr 2008 13:58:15 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@1723 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/MOLECULE/dump_bond.cpp | 12 +++++++----- src/XTC/dump_xtc.cpp | 6 +++++- src/atom.cpp | 4 ++-- src/dump.cpp | 2 +- src/dump_atom.cpp | 2 +- src/dump_custom.cpp | 2 +- src/dump_dcd.cpp | 12 +++++++----- src/dump_xyz.cpp | 10 +++++++--- 8 files changed, 31 insertions(+), 19 deletions(-) diff --git a/src/MOLECULE/dump_bond.cpp b/src/MOLECULE/dump_bond.cpp index f0415ca80f..ef3e55bfac 100644 --- a/src/MOLECULE/dump_bond.cpp +++ b/src/MOLECULE/dump_bond.cpp @@ -59,11 +59,13 @@ void DumpBond::init() void DumpBond::write_header(int ndump) { - fprintf(fp,"ITEM: TIMESTEP\n"); - fprintf(fp,"%d\n",update->ntimestep); - fprintf(fp,"ITEM: NUMBER OF BONDS\n"); - fprintf(fp,"%d\n",ndump); - fprintf(fp,"ITEM: BONDS\n"); + if (me == 0) { + fprintf(fp,"ITEM: TIMESTEP\n"); + fprintf(fp,"%d\n",update->ntimestep); + fprintf(fp,"ITEM: NUMBER OF BONDS\n"); + fprintf(fp,"%d\n",ndump); + fprintf(fp,"ITEM: BONDS\n"); + } } /* ---------------------------------------------------------------------- */ diff --git a/src/XTC/dump_xtc.cpp b/src/XTC/dump_xtc.cpp index eac87fae85..54e987fd53 100644 --- a/src/XTC/dump_xtc.cpp +++ b/src/XTC/dump_xtc.cpp @@ -151,7 +151,7 @@ void DumpXTC::openfile() void DumpXTC::write_header(int n) { - // realloc coords if necessary + // all procs realloc types & coords if necessary if (n != natoms) { memory->sfree(coords); @@ -161,6 +161,10 @@ void DumpXTC::write_header(int n) coords = (float *) memory->smalloc(3*natoms*sizeof(float),"dump:coords"); } + // only proc 0 writes header + + if (me != 0) return; + int tmp = XTC_MAGIC; xdr_int(&xd,&tmp); xdr_int(&xd,&n); diff --git a/src/atom.cpp b/src/atom.cpp index 5475ec7cdc..7f8b7b274d 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -602,7 +602,7 @@ void Atom::tag_extend() /* ---------------------------------------------------------------------- check if atom tags are consecutive from 1 to Natoms - return 0 if any tag <= 0 or maxtag > Natoms + return 0 if any tag <= 0 or maxtag != Natoms return 1 if OK (doesn't actually check if all tag values are used) ------------------------------------------------------------------------- */ @@ -620,7 +620,7 @@ int Atom::tag_consecutive() } MPI_Allreduce(check,check_all,2,MPI_INT,MPI_MAX,world); - if (check_all[0] || check_all[1] > natoms) return 0; + if (check_all[0] || check_all[1] != static_cast (natoms)) return 0; return 1; } diff --git a/src/dump.cpp b/src/dump.cpp index 8ac2724ef5..1114624552 100644 --- a/src/dump.cpp +++ b/src/dump.cpp @@ -153,7 +153,7 @@ void Dump::write() // write timestep header if (multiproc) write_header(nme); - else if (me == 0) write_header(ntotal); + else write_header(ntotal); // grow communication buffer if necessary diff --git a/src/dump_atom.cpp b/src/dump_atom.cpp index 50aea9be29..a293bd0f59 100644 --- a/src/dump_atom.cpp +++ b/src/dump_atom.cpp @@ -110,7 +110,7 @@ int DumpAtom::modify_param(int narg, char **arg) void DumpAtom::write_header(int ndump) { - (this->*header_choice)(ndump); + if (me == 0) (this->*header_choice)(ndump); } /* ---------------------------------------------------------------------- */ diff --git a/src/dump_custom.cpp b/src/dump_custom.cpp index 8f6d46dc28..fb9d7c14a5 100644 --- a/src/dump_custom.cpp +++ b/src/dump_custom.cpp @@ -206,7 +206,7 @@ void DumpCustom::init() void DumpCustom::write_header(int ndump) { - (this->*header_choice)(ndump); + if (me == 0) (this->*header_choice)(ndump); } /* ---------------------------------------------------------------------- */ diff --git a/src/dump_dcd.cpp b/src/dump_dcd.cpp index 46570b415a..cdd2a82c31 100644 --- a/src/dump_dcd.cpp +++ b/src/dump_dcd.cpp @@ -179,11 +179,13 @@ void DumpDCD::write_header(int n) dim[4] = (h[0]*h[5]) / alen/blen; } - uint32_t out_integer = 48; - fwrite_int32(fp,out_integer); - fwrite(dim,out_integer,1,fp); - fwrite_int32(fp,out_integer); - if (flush_flag) fflush(fp); + if (me == 0) { + uint32_t out_integer = 48; + fwrite_int32(fp,out_integer); + fwrite(dim,out_integer,1,fp); + fwrite_int32(fp,out_integer); + if (flush_flag) fflush(fp); + } } /* ---------------------------------------------------------------------- */ diff --git a/src/dump_xyz.cpp b/src/dump_xyz.cpp index 13f6d7767e..0656843f5c 100644 --- a/src/dump_xyz.cpp +++ b/src/dump_xyz.cpp @@ -94,7 +94,7 @@ double DumpXYZ::memory_usage() void DumpXYZ::write_header(int n) { - // realloc types & coords if necessary + // all procs realloc types & coords if necessary if (igroup == 0 && n != natoms) { memory->sfree(types); @@ -106,8 +106,12 @@ void DumpXYZ::write_header(int n) coords = (float *) memory->smalloc(3*natoms*sizeof(float),"dump:coords"); } - fprintf(fp,"%d\n",n); - fprintf(fp,"Atoms\n"); + // only proc 0 writes header + + if (me == 0) { + fprintf(fp,"%d\n",n); + fprintf(fp,"Atoms\n"); + } } /* ---------------------------------------------------------------------- */