diff --git a/src/KOKKOS/neigh_full_kokkos.h b/src/KOKKOS/neigh_full_kokkos.h index 388d77dae1..ae2d7efb64 100644 --- a/src/KOKKOS/neigh_full_kokkos.h +++ b/src/KOKKOS/neigh_full_kokkos.h @@ -15,7 +15,7 @@ #include "atom_masks.h" #include "domain_kokkos.h" -using namespace LAMMPS_NS; +namespace LAMMPS_NS { /* ---------------------------------------------------------------------- */ @@ -845,3 +845,5 @@ void NeighborKokkosExecute:: } neigh_list.d_ilist(i) = i; } + +} diff --git a/src/MAKE/Makefile.serial b/src/MAKE/Makefile.serial index 47e3472649..2833839eef 100755 --- a/src/MAKE/Makefile.serial +++ b/src/MAKE/Makefile.serial @@ -1,4 +1,4 @@ -# serial = g++ compiler, no MPI +# serial = g++ compiler, no MPI, internal FFT SHELL = /bin/sh diff --git a/src/STUBS/mpi.c b/src/STUBS/mpi.c index fc2d60429a..38174bb1de 100644 --- a/src/STUBS/mpi.c +++ b/src/STUBS/mpi.c @@ -77,17 +77,30 @@ int MPI_Finalized(int *flag) /* return "localhost" as name of the processor */ -void MPI_Get_processor_name(char *name, int *resultlen) +int MPI_Get_processor_name(char *name, int *resultlen) { const char host[] = "localhost"; int len; - if (!name || !resultlen) return; + if (!name || !resultlen) return MPI_ERR_ARG; len = strlen(host); memcpy(name,host,len+1); *resultlen = len; - return; + return MPI_SUCCESS; +} + +/* ---------------------------------------------------------------------- */ + +/* return MPI version level. v1.2 is not 100% correct, but close enough */ + +int MPI_Get_version(int *major, int *minor) +{ + if (!major || !minor) return MPI_ERR_ARG; + + *major = 1; + *minor = 2; + return MPI_SUCCESS; } /* ---------------------------------------------------------------------- */ diff --git a/src/STUBS/mpi.h b/src/STUBS/mpi.h index 07ea1027eb..1344de76df 100644 --- a/src/STUBS/mpi.h +++ b/src/STUBS/mpi.h @@ -79,7 +79,8 @@ typedef struct _MPI_Status MPI_Status; int MPI_Init(int *argc, char ***argv); int MPI_Initialized(int *flag); int MPI_Finalized(int *flag); -void MPI_Get_processor_name(char *name, int *resultlen); +int MPI_Get_processor_name(char *name, int *resultlen); +int MPI_Get_version(int *major, int *minor); int MPI_Comm_rank(MPI_Comm comm, int *me); int MPI_Comm_size(MPI_Comm comm, int *nprocs); diff --git a/src/USER-QTB/fix_qbmsst.cpp b/src/USER-QTB/fix_qbmsst.cpp index 6b4969d212..1e592d9c99 100644 --- a/src/USER-QTB/fix_qbmsst.cpp +++ b/src/USER-QTB/fix_qbmsst.cpp @@ -522,7 +522,6 @@ void FixQBMSST::initial_integrate(int vflag) int *type = atom->type; double **x = atom->x; double boltz = force->boltz; - double hplanck = force->hplanck; // check to see if old_velocity is correctly allocated check_alloc(nlocal); diff --git a/src/USER-QTB/fix_qtb.cpp b/src/USER-QTB/fix_qtb.cpp index 44abe7c7ff..0962bece18 100644 --- a/src/USER-QTB/fix_qtb.cpp +++ b/src/USER-QTB/fix_qtb.cpp @@ -245,7 +245,6 @@ void FixQTB::post_force(int vflag) double **v = atom->v; double **f = atom->f; - double *rmass = atom->rmass; int *type = atom->type; int *mask = atom->mask; bigint nlocal = atom->nlocal; diff --git a/src/comm.cpp b/src/comm.cpp index df8b73110e..2ebd124aa6 100644 --- a/src/comm.cpp +++ b/src/comm.cpp @@ -337,7 +337,7 @@ void Comm::set_processors(int narg, char **arg) strcmp(arg[iarg+1],"zxy") == 0 || strcmp(arg[iarg+1],"zyx") == 0) { mapflag = XYZ; - strcpy(xyz,arg[iarg+1]); + strncpy(xyz,arg[iarg+1],3); } else error->all(FLERR,"Illegal processors command"); iarg += 2; diff --git a/src/comm_tiled.cpp b/src/comm_tiled.cpp index 0d27a0fd32..8246aeb5a0 100644 --- a/src/comm_tiled.cpp +++ b/src/comm_tiled.cpp @@ -182,7 +182,7 @@ void CommTiled::setup() if (cut == 0.0) { cutzero = 1; cut = MIN(prd[0],prd[1]); - if (dimension == 3) cut = MIN(cut,prd[3]); + if (dimension == 3) cut = MIN(cut,prd[2]); cut *= EPSILON*EPSILON; } @@ -920,9 +920,9 @@ void CommTiled::borders() } } if (sendself[iswap]) { - n = avec->pack_border_vel(sendnum[iswap][nsend],sendlist[iswap][nsend], - buf_send,pbc_flag[iswap][nsend], - pbc[iswap][nsend]); + avec->pack_border_vel(sendnum[iswap][nsend],sendlist[iswap][nsend], + buf_send,pbc_flag[iswap][nsend], + pbc[iswap][nsend]); avec->unpack_border_vel(recvnum[iswap][nrecv],firstrecv[iswap][nrecv], buf_send); } @@ -949,9 +949,8 @@ void CommTiled::borders() } } if (sendself[iswap]) { - n = avec->pack_border(sendnum[iswap][nsend],sendlist[iswap][nsend], - buf_send,pbc_flag[iswap][nsend], - pbc[iswap][nsend]); + avec->pack_border(sendnum[iswap][nsend],sendlist[iswap][nsend], + buf_send,pbc_flag[iswap][nsend],pbc[iswap][nsend]); avec->unpack_border(recvnum[iswap][nsend],firstrecv[iswap][nsend], buf_send); } diff --git a/src/compute_angle_local.cpp b/src/compute_angle_local.cpp index 049887e0d5..e1dad85769 100644 --- a/src/compute_angle_local.cpp +++ b/src/compute_angle_local.cpp @@ -164,7 +164,7 @@ int ComputeAngleLocal::compute_angles(int flag) atom3 = atom->map(angle_atom3[atom2][i]); } else { if (tag[atom2] != onemols[imol]->angle_atom2[atom2][i]) continue; - tagprev = tag[atom1] - iatom - 1; + tagprev = tag[atom2] - iatom - 1; atype = atom->map(onemols[imol]->angle_type[atom2][i]); atom1 = atom->map(onemols[imol]->angle_atom1[atom2][i]+tagprev); atom3 = atom->map(onemols[imol]->angle_atom3[atom2][i]+tagprev); diff --git a/src/compute_chunk_atom.cpp b/src/compute_chunk_atom.cpp index 1dbd21726f..487bd43de2 100644 --- a/src/compute_chunk_atom.cpp +++ b/src/compute_chunk_atom.cpp @@ -1351,7 +1351,7 @@ void ComputeChunkAtom::atom2bin2d() continue; } if (!maxflag[jdim]) i2bin = MIN(i2bin,nlayer2m1); - else if (i2bin > nlayer1m1) { + else if (i2bin > nlayer2m1) { exclude[i] = 1; continue; } @@ -1456,7 +1456,7 @@ void ComputeChunkAtom::atom2bin3d() continue; } if (!maxflag[jdim]) i2bin = MIN(i2bin,nlayer2m1); - else if (i2bin > nlayer1m1) { + else if (i2bin > nlayer2m1) { exclude[i] = 1; continue; } diff --git a/src/compute_dihedral_local.cpp b/src/compute_dihedral_local.cpp index 5565a6b289..8316df01b0 100644 --- a/src/compute_dihedral_local.cpp +++ b/src/compute_dihedral_local.cpp @@ -158,7 +158,7 @@ int ComputeDihedralLocal::compute_dihedrals(int flag) atom4 = atom->map(dihedral_atom4[atom2][i]); } else { if (tag[atom2] != onemols[imol]->dihedral_atom2[atom2][i]) continue; - tagprev = tag[atom1] - iatom - 1; + tagprev = tag[atom2] - iatom - 1; atom1 = atom->map(onemols[imol]->dihedral_atom1[atom2][i]+tagprev); atom3 = atom->map(onemols[imol]->dihedral_atom3[atom2][i]+tagprev); atom4 = atom->map(onemols[imol]->dihedral_atom4[atom2][i]+tagprev); diff --git a/src/compute_improper_local.cpp b/src/compute_improper_local.cpp index 33dcff53bb..439a2bd3b2 100644 --- a/src/compute_improper_local.cpp +++ b/src/compute_improper_local.cpp @@ -159,7 +159,7 @@ int ComputeImproperLocal::compute_impropers(int flag) atom4 = atom->map(improper_atom4[atom2][i]); } else { if (tag[atom2] != onemols[imol]->improper_atom2[atom2][i]) continue; - tagprev = tag[atom1] - iatom - 1; + tagprev = tag[atom2] - iatom - 1; atom1 = atom->map(onemols[imol]->improper_atom1[atom2][i]+tagprev); atom3 = atom->map(onemols[imol]->improper_atom3[atom2][i]+tagprev); atom4 = atom->map(onemols[imol]->improper_atom4[atom2][i]+tagprev); diff --git a/src/compute_temp_chunk.cpp b/src/compute_temp_chunk.cpp index bc8df94b79..3c0cdff80d 100644 --- a/src/compute_temp_chunk.cpp +++ b/src/compute_temp_chunk.cpp @@ -850,8 +850,8 @@ void ComputeTempChunk::allocate() double ComputeTempChunk::memory_usage() { double bytes = (bigint) maxchunk * 2 * sizeof(double); - bytes = (bigint) maxchunk * 2 * sizeof(int); - bytes = (bigint) maxchunk * nvalues * sizeof(double); + bytes += (bigint) maxchunk * 2 * sizeof(int); + bytes += (bigint) maxchunk * nvalues * sizeof(double); if (comflag || nvalues) { bytes += (bigint) maxchunk * 2 * sizeof(double); bytes += (bigint) maxchunk * 2*3 * sizeof(double); diff --git a/src/domain.cpp b/src/domain.cpp index c84e619cbd..66d5f5936a 100644 --- a/src/domain.cpp +++ b/src/domain.cpp @@ -594,17 +594,15 @@ void Domain::pbc() int Domain::inside(double* x) { - double *lo,*hi,*period; + double *lo,*hi; double delta[3]; if (triclinic == 0) { lo = boxlo; hi = boxhi; - period = prd; } else { lo = boxlo_lamda; hi = boxhi_lamda; - period = prd_lamda; delta[0] = x[0] - boxlo[0]; delta[1] = x[1] - boxlo[1]; @@ -628,7 +626,7 @@ int Domain::inside(double* x) int Domain::inside_nonperiodic(double* x) { - double *lo,*hi,*period; + double *lo,*hi; double delta[3]; if (xperiodic && yperiodic && zperiodic) return 1; @@ -636,11 +634,9 @@ int Domain::inside_nonperiodic(double* x) if (triclinic == 0) { lo = boxlo; hi = boxhi; - period = prd; } else { lo = boxlo_lamda; hi = boxhi_lamda; - period = prd_lamda; delta[0] = x[0] - boxlo[0]; delta[1] = x[1] - boxlo[1]; diff --git a/src/dump.cpp b/src/dump.cpp index 6e5d787625..e1fc9f31ed 100644 --- a/src/dump.cpp +++ b/src/dump.cpp @@ -380,7 +380,7 @@ void Dump::write() write_data(nlines,buf); } - if (flush_flag) fflush(fp); + if (flush_flag && fp) fflush(fp); } else { MPI_Recv(&tmp,0,MPI_INT,fileproc,0,world,MPI_STATUS_IGNORE); @@ -401,7 +401,7 @@ void Dump::write() write_data(nchars,(double *) sbuf); } - if (flush_flag) fflush(fp); + if (flush_flag && fp) fflush(fp); } else { MPI_Recv(&tmp,0,MPI_INT,fileproc,0,world,MPI_STATUS_IGNORE); @@ -413,9 +413,9 @@ void Dump::write() if (multifile) { if (compressed) { - if (filewriter) pclose(fp); + if (filewriter && fp) pclose(fp); } else { - if (filewriter) fclose(fp); + if (filewriter && fp) fclose(fp); } } } diff --git a/src/dump_cfg.h b/src/dump_cfg.h index 490de32e2b..2ede0789be 100755 --- a/src/dump_cfg.h +++ b/src/dump_cfg.h @@ -36,9 +36,9 @@ class DumpCFG : public DumpCustom { int unwrapflag; // 1 if unwrapped coordinates are requested void init_style(); - void write_header(bigint); + virtual void write_header(bigint); int convert_string(int, double *); - void write_data(int, double *); + virtual void write_data(int, double *); typedef void (DumpCFG::*FnPtrWrite)(int, double *); FnPtrWrite write_choice; // ptr to write data functions diff --git a/src/fix_adapt.cpp b/src/fix_adapt.cpp index a8bb57cf98..56a3538f5b 100644 --- a/src/fix_adapt.cpp +++ b/src/fix_adapt.cpp @@ -296,11 +296,14 @@ void FixAdapt::init() Pair *pair = NULL; if (lmp->suffix_enable) { - char psuffix[128]; + int len = 2 + strlen(ad->pstyle) + strlen(lmp->suffix); + char *psuffix = new char[len]; + strcpy(psuffix,ad->pstyle); strcat(psuffix,"/"); strcat(psuffix,lmp->suffix); pair = force->pair_match(psuffix,1); + delete[] psuffix; } if (pair == NULL) pair = force->pair_match(ad->pstyle,1); if (pair == NULL) error->all(FLERR,"Fix adapt pair style does not exist"); diff --git a/src/fix_balance.cpp b/src/fix_balance.cpp index f4dc2e76cb..5eb4fde54b 100644 --- a/src/fix_balance.cpp +++ b/src/fix_balance.cpp @@ -62,6 +62,7 @@ FixBalance::FixBalance(LAMMPS *lmp, int narg, char **arg) : int iarg = 5; if (lbstyle == SHIFT) { if (iarg+4 > narg) error->all(FLERR,"Illegal fix balance command"); + if (strlen(arg[iarg+1]) > 3) error->all(FLERR,"Illegal fix balance command"); strcpy(bstr,arg[iarg+1]); nitermax = force->inumeric(FLERR,arg[iarg+2]); if (nitermax <= 0) error->all(FLERR,"Illegal fix balance command"); diff --git a/src/fix_balance.h b/src/fix_balance.h index a661825767..9ea1fe45ba 100644 --- a/src/fix_balance.h +++ b/src/fix_balance.h @@ -42,7 +42,7 @@ class FixBalance : public Fix { private: int nevery,lbstyle,nitermax,outflag; double thresh,stopthresh; - char bstr[3]; + char bstr[4]; FILE *fp; double imbnow; // current imbalance factor diff --git a/src/fix_move.cpp b/src/fix_move.cpp index e7ff801626..c2e7131395 100644 --- a/src/fix_move.cpp +++ b/src/fix_move.cpp @@ -195,13 +195,9 @@ FixMove::FixMove(LAMMPS *lmp, int narg, char **arg) : if ((mstyle == LINEAR || mstyle == WIGGLE || mstyle == ROTATE) && scaleflag) { - double xscale,yscale,zscale; - if (scaleflag) { - xscale = domain->lattice->xlattice; - yscale = domain->lattice->ylattice; - zscale = domain->lattice->zlattice; - } - else xscale = yscale = zscale = 1.0; + double xscale = domain->lattice->xlattice; + double yscale = domain->lattice->ylattice; + double zscale = domain->lattice->zlattice; if (mstyle == LINEAR) { if (vxflag) vx *= xscale; diff --git a/src/fix_temp_csvr.cpp b/src/fix_temp_csvr.cpp index 6c9a040010..deaa8f91ec 100644 --- a/src/fix_temp_csvr.cpp +++ b/src/fix_temp_csvr.cpp @@ -92,7 +92,6 @@ double FixTempCSVR::sumnoises(int nn) { const double rr = random->gaussian(); return 2.0 * gamdev((nn-1) / 2) + rr*rr; } - return 0.0; } /* ------------------------------------------------------------------- diff --git a/src/force.cpp b/src/force.cpp index 850714f828..f56d11e0e4 100644 --- a/src/force.cpp +++ b/src/force.cpp @@ -415,7 +415,7 @@ Dihedral *Force::new_dihedral(const char *style, int trysuffix, int &sflag) #undef DIHEDRAL_CLASS } - if (lmp->suffix) { + if (lmp->suffix2) { sflag = 2; char estyle[256]; sprintf(estyle,"%s/%s",style,lmp->suffix2); diff --git a/src/info.cpp b/src/info.cpp index 8665e5af17..f8085aca4c 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -65,6 +65,7 @@ enum {COMPUTES=1<<0, TIME=1<<6, VARIABLES=1<<7, SYSTEM=1<<8, + COMM=1<<9, ALL=~0}; } @@ -74,6 +75,9 @@ static const char *varstyles[] = { static const char *mapstyles[] = { "none", "array", "hash" }; +static const char *commstyles[] = { "brick", "tiled" }; +static const char *commlayout[] = { "uniform", "nonuniform", "irregular" }; + static const char bstyles[] = "pfsm"; using namespace LAMMPS_NS; @@ -104,13 +108,18 @@ void Info::command(int narg, char **arg) idx += 2; } else if ((idx+2 < narg) && (strncmp(arg[idx],"out",3) == 0) && (strncmp(arg[idx+1],"append",3) == 0)) { + if ((out != screen) && (out != logfile)) fclose(out); out = fopen(arg[idx+2],"a"); idx += 3; } else if ((idx+2 < narg) && (strncmp(arg[idx],"out",3) == 0) && (strncmp(arg[idx+1],"overwrite",3) == 0)) { + if ((out != screen) && (out != logfile)) fclose(out); out = fopen(arg[idx+2],"w"); idx += 3; - } else if (strncmp(arg[idx],"computes",3) == 0) { + } else if (strncmp(arg[idx],"communication",4) == 0) { + flags |= COMM; + ++idx; + } else if (strncmp(arg[idx],"computes",4) == 0) { flags |= COMPUTES; ++idx; } else if (strncmp(arg[idx],"dumps",3) == 0) { @@ -220,6 +229,20 @@ void Info::command(int narg, char **arg) #endif } + if (flags & COMM) { + int major,minor; + MPI_Get_version(&major,&minor); + + fprintf(out,"\nCommunication information:\n"); + fprintf(out,"MPI library level: MPI v%d.%d\n",major,minor); + fprintf(out,"Comm style = %s, Comm layout = %s\n", + commstyles[comm->style], commlayout[comm->layout]); + fprintf(out,"Nprocs = %d Nthreads = %d\n", + comm->nprocs, comm->nthreads); + fprintf(out,"Processor grid = %d x %d x %d\n",comm->procgrid[0], + comm->procgrid[1], comm->procgrid[2]); + } + if (flags & SYSTEM) { fprintf(out,"\nSystem information:\n"); fprintf(out,"Units = %s\n",update->unit_style); @@ -230,32 +253,32 @@ void Info::command(int narg, char **arg) msg = (atom->molecular == 2) ? "template" : "standard"; fprintf(out,"Molecule type = %s\n",msg); } - fprintf(out,"Atoms: " BIGINT_FORMAT ", types: %d, style: %s\n", + fprintf(out,"Atoms = " BIGINT_FORMAT ", types = %d, style = %s\n", atom->natoms, atom->ntypes, force->pair_style); if (atom->molecular > 0) { const char *msg; msg = force->bond_style ? force->bond_style : "none"; - fprintf(out,"Bonds: " BIGINT_FORMAT ", types: %d, style: %s\n", + fprintf(out,"Bonds = " BIGINT_FORMAT ", types = %d, style = %s\n", atom->nbonds, atom->nbondtypes, msg); msg = force->angle_style ? force->angle_style : "none"; - fprintf(out,"Angles: " BIGINT_FORMAT ", types: %d, style: %s\n", + fprintf(out,"Angles = " BIGINT_FORMAT ", types = %d, style = %s\n", atom->nangles, atom->nangletypes, msg); msg = force->dihedral_style ? force->dihedral_style : "none"; - fprintf(out,"Dihedrals: " BIGINT_FORMAT ", types: %d, style: %s\n", + fprintf(out,"Dihedrals = " BIGINT_FORMAT ", types = %d, style = %s\n", atom->ndihedrals, atom->ndihedraltypes, msg); msg = force->improper_style ? force->improper_style : "none"; - fprintf(out,"Impropers: " BIGINT_FORMAT ", types: %d, style: %s\n", + fprintf(out,"Impropers = " BIGINT_FORMAT ", types = %d, style = %s\n", atom->nimpropers, atom->nimpropertypes, msg); const double * const special_lj = force->special_lj; const double * const special_coul = force->special_coul; - fprintf(out,"Special bond factors lj: %-10g %-10g %-10g\n" - "Special bond factors coul: %-10g %-10g %-10g\n", + fprintf(out,"Special bond factors lj = %-10g %-10g %-10g\n" + "Special bond factors coul = %-10g %-10g %-10g\n", special_lj[1],special_lj[2],special_lj[3], special_coul[1],special_coul[2],special_coul[3]); } @@ -264,7 +287,8 @@ void Info::command(int narg, char **arg) force->kspace ? force->kspace_style : "none"); if (domain->box_exist) { - fprintf(out,"\n%s box: (%g x %g %g)\n", + fprintf(out,"\nDimensions = %d\n",domain->dimension); + fprintf(out,"%s box = %g x %g x %g\n", domain->triclinic ? "Triclinic" : "Orthogonal", domain->xprd, domain->yprd, domain->zprd); fprintf(out,"Boundaries = %c,%c %c,%c %c,%c\n", @@ -298,7 +322,7 @@ void Info::command(int narg, char **arg) Region **regs = domain->regions; fprintf(out,"\nRegion information:\n"); for (int i=0; i < nreg; ++i) { - fprintf(out,"Region[%3d]: %s, style: %s, side: %s\n", + fprintf(out,"Region[%3d]: %s, style = %s, side = %s\n", i, regs[i]->id, regs[i]->style, regs[i]->interior ? "in" : "out"); } @@ -310,7 +334,7 @@ void Info::command(int narg, char **arg) char **names = group->names; fprintf(out,"\nCompute information:\n"); for (int i=0; i < ncompute; ++i) { - fprintf(out,"Compute[%3d]: %s, style: %s, group: %s\n", + fprintf(out,"Compute[%3d]: %s, style = %s, group = %s\n", i, compute[i]->id, compute[i]->style, names[compute[i]->igroup]); } @@ -324,13 +348,13 @@ void Info::command(int narg, char **arg) char **names = group->names; fprintf(out,"\nDump information:\n"); for (int i=0; i < ndump; ++i) { - fprintf(out,"Dump[%3d]: %s, file: %s, style: %s, group: %s, ", + fprintf(out,"Dump[%3d]: %s, file = %s, style = %s, group = %s, ", i, dump[i]->id, dump[i]->filename, dump[i]->style, names[dump[i]->igroup]); if (nevery[i]) { - fprintf(out,"every: %d\n", nevery[i]); + fprintf(out,"every = %d\n", nevery[i]); } else { - fprintf(out,"every: %s\n", vnames[i]); + fprintf(out,"every = %s\n", vnames[i]); } } } @@ -341,7 +365,7 @@ void Info::command(int narg, char **arg) char **names = group->names; fprintf(out,"\nFix information:\n"); for (int i=0; i < nfix; ++i) { - fprintf(out,"Fix[%3d]: %s, style: %s, group: %s\n", + fprintf(out,"Fix[%3d]: %s, style = %s, group = %s\n", i, fix[i]->id, fix[i]->style, names[fix[i]->igroup]); } } diff --git a/src/main.cpp b/src/main.cpp index fd8a4ebe3f..e0096bfd28 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -14,7 +14,7 @@ #include "mpi.h" #include "lammps.h" #include "input.h" -#include "string.h" +#include "stdio.h" using namespace LAMMPS_NS; @@ -26,10 +26,18 @@ int main(int argc, char **argv) { MPI_Init(&argc,&argv); - LAMMPS *lammps = new LAMMPS(argc,argv,MPI_COMM_WORLD); + try { + LAMMPS *lammps = new LAMMPS(argc,argv,MPI_COMM_WORLD); - lammps->input->file(); - delete lammps; + lammps->input->file(); + delete lammps; + } + + catch(...) { + int me; + MPI_Comm_rank(MPI_COMM_WORLD,&me); + fprintf(stderr,"Unknown exception caught on rank %d\n",me); + } MPI_Barrier(MPI_COMM_WORLD); MPI_Finalize(); diff --git a/src/molecule.cpp b/src/molecule.cpp index 09a0529012..a5b34170ad 100644 --- a/src/molecule.cpp +++ b/src/molecule.cpp @@ -1051,6 +1051,7 @@ void Molecule::special_generate() for (int i = 0; i < natoms; i++) { nspecial[i][0] = num_bond[i]; for (int j = 0; j < num_bond[i]; j++) { + atom1 = i; atom2 = bond_atom[i][j]; if (count[atom1] >= maxspecial) error->one(FLERR,""); diff --git a/src/neighbor.cpp b/src/neighbor.cpp index 270ea48f44..34d8d692eb 100644 --- a/src/neighbor.cpp +++ b/src/neighbor.cpp @@ -796,6 +796,15 @@ void Neighbor::init() if (me == 0) { const double cutghost = MAX(cutneighmax,comm->cutghostuser); + double binsize, bbox[3]; + bbox[0] = bboxhi[0]-bboxlo[0]; + bbox[1] = bboxhi[1]-bboxlo[1]; + bbox[2] = bboxhi[2]-bboxlo[2]; + if (binsizeflag) binsize = binsize_user; + else if (style == BIN) binsize = 0.5*cutneighmax; + else binsize = 0.5*cutneighmin; + if (binsize == 0.0) binsize = bbox[0]; + if (logfile) { fprintf(logfile,"Neighbor list info ...\n"); fprintf(logfile," %d neighbor list requests\n",nrequest); @@ -803,6 +812,9 @@ void Neighbor::init() every,delay,dist_check ? "yes" : "no"); fprintf(logfile," master list distance cutoff = %g\n",cutneighmax); fprintf(logfile," ghost atom cutoff = %g\n",cutghost); + if (style != NSQ) + fprintf(logfile," binsize = %g -> bins = %g %g %g\n",binsize, + ceil(bbox[0]/binsize), ceil(bbox[1]/binsize), ceil(bbox[2]/binsize)); } if (screen) { fprintf(screen,"Neighbor list info ...\n"); @@ -811,6 +823,9 @@ void Neighbor::init() every,delay,dist_check ? "yes" : "no"); fprintf(screen," master list distance cutoff = %g\n",cutneighmax); fprintf(screen," ghost atom cutoff = %g\n",cutghost); + if (style != NSQ) + fprintf(screen," binsize = %g, bins = %g %g %g\n",binsize, + ceil(bbox[0]/binsize), ceil(bbox[1]/binsize), ceil(bbox[2]/binsize)); } } } diff --git a/src/pair.cpp b/src/pair.cpp index 31fa8edad4..a87b674608 100644 --- a/src/pair.cpp +++ b/src/pair.cpp @@ -711,7 +711,7 @@ void Pair::add_tally_callback(Compute *ptr) found = num_tally_compute; ++num_tally_compute; void *p = memory->srealloc((void *)list_tally_compute, - sizeof(Compute **) * num_tally_compute, + sizeof(Compute *) * num_tally_compute, "pair:list_tally_compute"); list_tally_compute = (Compute **) p; list_tally_compute[num_tally_compute-1] = ptr; diff --git a/src/pair_hybrid.cpp b/src/pair_hybrid.cpp index 81760bb4f7..490b3a5b1c 100644 --- a/src/pair_hybrid.cpp +++ b/src/pair_hybrid.cpp @@ -114,6 +114,7 @@ void PairHybrid::compute(int eflag, int vflag) // check if we are running with r-RESPA using the hybrid keyword Respa *respa = NULL; + respaflag = 0; if (strstr(update->integrate_style,"respa")) { respa = (Respa *) update->integrate; if (respa->nhybrid_styles > 0) respaflag = 1; @@ -565,8 +566,6 @@ double PairHybrid::init_one(int i, int j) // perform mixing only if I,I sub-style = J,J sub-style // also require I,I and J,J are both assigned to single sub-style - printf("IJ %d %d\n",i,j); - if (setflag[i][j] == 0) { if (nmap[i][i] != 1 || nmap[j][j] != 1 || map[i][i][0] != map[j][j][0]) error->one(FLERR,"All pair coeffs are not set"); diff --git a/src/pair_lj_cut_coul_dsf.cpp b/src/pair_lj_cut_coul_dsf.cpp index 3fed3738af..448bff34cd 100644 --- a/src/pair_lj_cut_coul_dsf.cpp +++ b/src/pair_lj_cut_coul_dsf.cpp @@ -145,7 +145,6 @@ void PairLJCutCoulDSF::compute(int eflag, int vflag) forcecoul = prefactor * (erfcc/r + 2.0*alpha/MY_PIS * erfcd + r*f_shift) * r; if (factor_coul < 1.0) forcecoul -= (1.0-factor_coul)*prefactor; - fpair = forcecoul * r2inv; } else forcecoul = 0.0; fpair = (forcecoul + factor_lj*forcelj) * r2inv; diff --git a/src/read_data.cpp b/src/read_data.cpp index 2c5aa6c060..82eaf56a75 100644 --- a/src/read_data.cpp +++ b/src/read_data.cpp @@ -886,7 +886,7 @@ void ReadData::header() } else if (strstr(line,"dihedrals")) { sscanf(line,BIGINT_FORMAT,&ndihedrals); if (addflag == NONE) atom->ndihedrals = ndihedrals; - else atom->ndihedrals += natoms; + else atom->ndihedrals += ndihedrals; } else if (strstr(line,"impropers")) { sscanf(line,BIGINT_FORMAT,&nimpropers); if (addflag == NONE) atom->nimpropers = nimpropers; @@ -1812,7 +1812,8 @@ void ReadData::parse_keyword(int first) void ReadData::skip_lines(bigint n) { if (me) return; - char *eof; + if (n <= 0) return; + char *eof = NULL; for (bigint i = 0; i < n; i++) eof = fgets(line,MAXLINE,fp); if (eof == NULL) error->one(FLERR,"Unexpected end of data file"); } diff --git a/src/reader_native.cpp b/src/reader_native.cpp index b09060c843..f4f802947d 100644 --- a/src/reader_native.cpp +++ b/src/reader_native.cpp @@ -318,13 +318,13 @@ int ReaderNative::find_label(const char *label, int n, char **labels) /* ---------------------------------------------------------------------- read N lines from dump file only last one is saved in line - return NULL if end-of-file error, else non-NULL only called by proc 0 ------------------------------------------------------------------------- */ void ReaderNative::read_lines(int n) { - char *eof; + char *eof = NULL; + if (n <= 0) return; for (int i = 0; i < n; i++) eof = fgets(line,MAXLINE,fp); - if (eof == NULL) error->all(FLERR,"Unexpected end of dump file"); + if (eof == NULL) error->one(FLERR,"Unexpected end of dump file"); } diff --git a/src/reader_xyz.cpp b/src/reader_xyz.cpp index a78f63792a..2c18e336cb 100644 --- a/src/reader_xyz.cpp +++ b/src/reader_xyz.cpp @@ -204,13 +204,13 @@ void ReaderXYZ::read_atoms(int n, int nfield, double **fields) /* ---------------------------------------------------------------------- read N lines from dump file only last one is saved in line - return NULL if end-of-file error, else non-NULL only called by proc 0 ------------------------------------------------------------------------- */ void ReaderXYZ::read_lines(int n) { - char *eof; + char *eof = NULL; + if (n <= 0) return; for (int i = 0; i < n; i++) eof = fgets(line,MAXLINE,fp); - if (eof == NULL) error->all(FLERR,"Unexpected end of dump file"); + if (eof == NULL) error->one(FLERR,"Unexpected end of dump file"); } diff --git a/src/region_cylinder.cpp b/src/region_cylinder.cpp index 52547cf46e..2e46f5523d 100644 --- a/src/region_cylinder.cpp +++ b/src/region_cylinder.cpp @@ -61,7 +61,7 @@ RegCylinder::RegCylinder(LAMMPS *lmp, int narg, char **arg) : shape_update(); } else { radius = force->numeric(FLERR,arg[5]); - if (axis == 'x') radius *= xscale; + if (axis == 'x') radius *= yscale; else radius *= xscale; rstyle = CONSTANT; } @@ -439,7 +439,7 @@ void RegCylinder::shape_update() radius = input->variable->compute_equal(rvar); if (radius < 0.0) error->one(FLERR,"Variable evaluation in region gave bad value"); - if (axis == 'x') radius *= xscale; + if (axis == 'x') radius *= yscale; else radius *= xscale; } diff --git a/src/variable.cpp b/src/variable.cpp index df14be27a8..0b11372c71 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -316,6 +316,7 @@ void Variable::set(int narg, char **arg) data[nvar] = new char*[num[nvar]]; copy(1,&arg[2],data[nvar]); data[nvar][1] = new char[VALUELENGTH]; + strcpy(data[nvar][1],"(undefined)"); // SCALARFILE for strings or numbers // which = 1st value @@ -370,6 +371,7 @@ void Variable::set(int narg, char **arg) data[nvar] = new char*[num[nvar]]; copy(2,&arg[2],data[nvar]); data[nvar][2] = new char[VALUELENGTH]; + strcpy(data[nvar][2],"(undefined)"); // EQUAL // replace pre-existing var if also style EQUAL (allows it to be reset) @@ -394,6 +396,7 @@ void Variable::set(int narg, char **arg) data[nvar] = new char*[num[nvar]]; copy(1,&arg[2],data[nvar]); data[nvar][1] = new char[VALUELENGTH]; + strcpy(data[nvar][1],"(undefined)"); } // ATOM @@ -445,6 +448,7 @@ void Variable::set(int narg, char **arg) data[nvar] = new char*[num[nvar]]; copy(1,&arg[2],data[nvar]); data[nvar][1] = new char[VALUELENGTH]; + strcpy(data[nvar][1],"(undefined)"); } } else error->all(FLERR,"Illegal variable command"); @@ -742,7 +746,7 @@ char *Variable::retrieve(char *name) error->all(FLERR,"Variable has circular dependency"); eval_in_progress[ivar] = 1; - char *str; + char *str = NULL; if (style[ivar] == INDEX || style[ivar] == WORLD || style[ivar] == UNIVERSE || style[ivar] == STRING || style[ivar] == SCALARFILE) { diff --git a/src/velocity.cpp b/src/velocity.cpp index 20d62b6b02..8b83b007b5 100644 --- a/src/velocity.cpp +++ b/src/velocity.cpp @@ -241,7 +241,7 @@ void Velocity::create(double t_desired, int seed) int m; double vx,vy,vz,factor; - RanPark *random; + RanPark *random = NULL; if (loop_flag == ALL) {