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

This commit is contained in:
sjplimp 2013-04-12 22:24:18 +00:00
parent a741fcf859
commit d8509b5842
2 changed files with 54 additions and 48 deletions

View File

@ -143,37 +143,29 @@ void DumpCFG::write_header(bigint n)
} else if (unwrapflag == 1) scale = UNWRAPEXPAND;
else scale = 1.0;
if (me == 0 || multiproc) {
char str[64];
sprintf(str,"Number of particles = %s\n",BIGINT_FORMAT);
fprintf(fp,str,n);
fprintf(fp,"A = %g Angstrom (basic length-scale)\n",scale);
fprintf(fp,"H0(1,1) = %g A\n",domain->xprd);
fprintf(fp,"H0(1,2) = 0 A \n");
fprintf(fp,"H0(1,3) = 0 A \n");
fprintf(fp,"H0(2,1) = %g A \n",domain->xy);
fprintf(fp,"H0(2,2) = %g A\n",domain->yprd);
fprintf(fp,"H0(2,3) = 0 A \n");
fprintf(fp,"H0(3,1) = %g A \n",domain->xz);
fprintf(fp,"H0(3,2) = %g A \n",domain->yz);
fprintf(fp,"H0(3,3) = %g A\n",domain->zprd);
fprintf(fp,".NO_VELOCITY.\n");
fprintf(fp,"entry_count = %d\n",nfield-2);
for (int i = 0; i < nfield-5; i++)
fprintf(fp,"auxiliary[%d] = %s\n",i,auxname[i]);
}
char str[64];
sprintf(str,"Number of particles = %s\n",BIGINT_FORMAT);
fprintf(fp,str,n);
fprintf(fp,"A = %g Angstrom (basic length-scale)\n",scale);
fprintf(fp,"H0(1,1) = %g A\n",domain->xprd);
fprintf(fp,"H0(1,2) = 0 A \n");
fprintf(fp,"H0(1,3) = 0 A \n");
fprintf(fp,"H0(2,1) = %g A \n",domain->xy);
fprintf(fp,"H0(2,2) = %g A\n",domain->yprd);
fprintf(fp,"H0(2,3) = 0 A \n");
fprintf(fp,"H0(3,1) = %g A \n",domain->xz);
fprintf(fp,"H0(3,2) = %g A \n",domain->yz);
fprintf(fp,"H0(3,3) = %g A\n",domain->zprd);
fprintf(fp,".NO_VELOCITY.\n");
fprintf(fp,"entry_count = %d\n",nfield-2);
for (int i = 0; i < nfield-5; i++)
fprintf(fp,"auxiliary[%d] = %s\n",i,auxname[i]);
// calculate total # of data lines to be written on a writing proc
// allocate memory needed for data rearrangement
if (multiproc) nchosen = nme;
else MPI_Reduce(&nme,&nchosen,1,MPI_INT,MPI_SUM,0,world);
// allocate memory needed for data rearrangement on writing proc(s)
if (multiproc || me == 0) {
if (rbuf) memory->destroy(rbuf);
memory->create(rbuf,nchosen,size_one,"dump:rbuf");
}
nchosen = static_cast<int> (n);
if (rbuf) memory->destroy(rbuf);
memory->create(rbuf,nchosen,size_one,"dump:rbuf");
}
/* ----------------------------------------------------------------------

View File

@ -117,6 +117,18 @@ void WriteData::write(char *file)
if (natoms != atom->natoms && output->thermo->lostflag == ERROR)
error->all(FLERR,"Atom count is inconsistent, cannot write data file");
// sum up bond,angle counts
// may be different than atom->nbonds,nangles if broken/turned-off
if (atom->nbonds || atom->nbondtypes) {
nbonds_local = atom->avec->pack_bond(NULL);
MPI_Allreduce(&nbonds_local,&nbonds,1,MPI_LMP_BIGINT,MPI_SUM,world);
}
if (atom->nangles || atom->nangletypes) {
nangles_local = atom->avec->pack_angle(NULL);
MPI_Allreduce(&nangles_local,&nangles,1,MPI_LMP_BIGINT,MPI_SUM,world);
}
// open data file
if (me == 0) {
@ -166,14 +178,10 @@ void WriteData::header()
fprintf(fp,"%d atom types\n",atom->ntypes);
if (atom->nbonds || atom->nbondtypes) {
nbonds_local = atom->avec->pack_bond(NULL);
MPI_Allreduce(&nbonds_local,&nbonds,1,MPI_LMP_BIGINT,MPI_SUM,world);
fprintf(fp,BIGINT_FORMAT " bonds\n",nbonds);
fprintf(fp,"%d bond types\n",atom->nbondtypes);
}
if (atom->nangles || atom->nangletypes) {
nangles_local = atom->avec->pack_angle(NULL);
MPI_Allreduce(&nangles_local,&nangles,1,MPI_LMP_BIGINT,MPI_SUM,world);
fprintf(fp,BIGINT_FORMAT " angles\n",nangles);
fprintf(fp,"%d angle types\n",atom->nangletypes);
}
@ -278,8 +286,9 @@ void WriteData::atoms()
MPI_Send(&tmp,0,MPI_INT,iproc,0,world);
MPI_Wait(&request,&status);
MPI_Get_count(&status,MPI_DOUBLE,&recvrow);
recvrow /= ncol;
} else recvrow = sendrow;
atom->avec->write_data(fp,recvrow,buf);
}
@ -330,6 +339,7 @@ void WriteData::velocities()
MPI_Send(&tmp,0,MPI_INT,iproc,0,world);
MPI_Wait(&request,&status);
MPI_Get_count(&status,MPI_DOUBLE,&recvrow);
recvrow /= ncol;
} else recvrow = sendrow;
atom->avec->write_vel(fp,recvrow,buf);
@ -362,7 +372,7 @@ void WriteData::bonds()
// pack my bond data into buf
atom->avec->pack_bond(buf);
int foo = atom->avec->pack_bond(buf);
// write one chunk of atoms per proc to file
// proc 0 pings each proc, receives its chunk, writes to file
@ -377,19 +387,20 @@ void WriteData::bonds()
fprintf(fp,"\nBonds\n\n");
for (int iproc = 0; iproc < nprocs; iproc++) {
if (iproc) {
MPI_Irecv(&buf[0][0],maxrow*ncol,MPI_DOUBLE,iproc,0,world,&request);
MPI_Irecv(&buf[0][0],maxrow*ncol,MPI_INT,iproc,0,world,&request);
MPI_Send(&tmp,0,MPI_INT,iproc,0,world);
MPI_Wait(&request,&status);
MPI_Get_count(&status,MPI_DOUBLE,&recvrow);
MPI_Get_count(&status,MPI_INT,&recvrow);
recvrow /= ncol;
} else recvrow = sendrow;
atom->avec->write_bond(fp,recvrow,buf,index);
index += recvrow;
}
} else {
MPI_Recv(&tmp,0,MPI_INT,0,0,world,&status);
MPI_Rsend(&buf[0][0],sendrow*ncol,MPI_DOUBLE,0,0,world);
MPI_Rsend(&buf[0][0],sendrow*ncol,MPI_INT,0,0,world);
}
memory->destroy(buf);
@ -429,10 +440,11 @@ void WriteData::angles()
fprintf(fp,"\nAngles\n\n");
for (int iproc = 0; iproc < nprocs; iproc++) {
if (iproc) {
MPI_Irecv(&buf[0][0],maxrow*ncol,MPI_DOUBLE,iproc,0,world,&request);
MPI_Irecv(&buf[0][0],maxrow*ncol,MPI_INT,iproc,0,world,&request);
MPI_Send(&tmp,0,MPI_INT,iproc,0,world);
MPI_Wait(&request,&status);
MPI_Get_count(&status,MPI_DOUBLE,&recvrow);
MPI_Get_count(&status,MPI_INT,&recvrow);
recvrow /= ncol;
} else recvrow = sendrow;
atom->avec->write_angle(fp,recvrow,buf,index);
@ -441,7 +453,7 @@ void WriteData::angles()
} else {
MPI_Recv(&tmp,0,MPI_INT,0,0,world,&status);
MPI_Rsend(&buf[0][0],sendrow*ncol,MPI_DOUBLE,0,0,world);
MPI_Rsend(&buf[0][0],sendrow*ncol,MPI_INT,0,0,world);
}
memory->destroy(buf);
@ -499,10 +511,11 @@ void WriteData::dihedrals()
fprintf(fp,"\nDihedrals\n\n");
for (int iproc = 0; iproc < nprocs; iproc++) {
if (iproc) {
MPI_Irecv(&buf[0][0],maxrow*ncol,MPI_DOUBLE,iproc,0,world,&request);
MPI_Irecv(&buf[0][0],maxrow*ncol,MPI_INT,iproc,0,world,&request);
MPI_Send(&tmp,0,MPI_INT,iproc,0,world);
MPI_Wait(&request,&status);
MPI_Get_count(&status,MPI_DOUBLE,&recvrow);
MPI_Get_count(&status,MPI_INT,&recvrow);
recvrow /= ncol;
} else recvrow = sendrow;
atom->avec->write_dihedral(fp,recvrow,buf,index);
@ -511,7 +524,7 @@ void WriteData::dihedrals()
} else {
MPI_Recv(&tmp,0,MPI_INT,0,0,world,&status);
MPI_Rsend(&buf[0][0],sendrow*ncol,MPI_DOUBLE,0,0,world);
MPI_Rsend(&buf[0][0],sendrow*ncol,MPI_INT,0,0,world);
}
memory->destroy(buf);
@ -569,10 +582,11 @@ void WriteData::impropers()
fprintf(fp,"\nImpropers\n\n");
for (int iproc = 0; iproc < nprocs; iproc++) {
if (iproc) {
MPI_Irecv(&buf[0][0],maxrow*ncol,MPI_DOUBLE,iproc,0,world,&request);
MPI_Irecv(&buf[0][0],maxrow*ncol,MPI_INT,iproc,0,world,&request);
MPI_Send(&tmp,0,MPI_INT,iproc,0,world);
MPI_Wait(&request,&status);
MPI_Get_count(&status,MPI_DOUBLE,&recvrow);
MPI_Get_count(&status,MPI_INT,&recvrow);
recvrow /= ncol;
} else recvrow = sendrow;
atom->avec->write_improper(fp,recvrow,buf,index);
@ -581,7 +595,7 @@ void WriteData::impropers()
} else {
MPI_Recv(&tmp,0,MPI_INT,0,0,world,&status);
MPI_Rsend(&buf[0][0],sendrow*ncol,MPI_DOUBLE,0,0,world);
MPI_Rsend(&buf[0][0],sendrow*ncol,MPI_INT,0,0,world);
}
memory->destroy(buf);