second round of making per-atom allocations consistent.
now all sections that dimension per-atom local arrays to atom->nmax will also *test* for atom->nmax and thus we avoid potential segfaults in all cases where atom->nlocal or atom->nlocal+atom->nghost are 0. it doesn't make sense to test for these if the arrays are dimensioned to atom->nmax afterwards anyway.
This commit is contained in:
@ -309,7 +309,7 @@ void ComputeTempCS::vcm_pairs()
|
||||
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
if (nlocal > maxatom) {
|
||||
if (atom->nmax > maxatom) {
|
||||
memory->destroy(vint);
|
||||
maxatom = atom->nmax;
|
||||
memory->create(vint,maxatom,3,"temp/cs:vint");
|
||||
|
||||
@ -584,7 +584,7 @@ void FixAtomSwap::update_semi_grand_atoms_list()
|
||||
int nlocal = atom->nlocal;
|
||||
double **x = atom->x;
|
||||
|
||||
if (nlocal > atom_swap_nmax) {
|
||||
if (atom->nmax > atom_swap_nmax) {
|
||||
memory->sfree(local_swap_atom_list);
|
||||
atom_swap_nmax = atom->nmax;
|
||||
local_swap_atom_list = (int *) memory->smalloc(atom_swap_nmax*sizeof(int),
|
||||
@ -639,7 +639,7 @@ void FixAtomSwap::update_swap_atoms_list()
|
||||
int *type = atom->type;
|
||||
double **x = atom->x;
|
||||
|
||||
if (nlocal > atom_swap_nmax) {
|
||||
if (atom->nmax > atom_swap_nmax) {
|
||||
memory->sfree(local_swap_iatom_list);
|
||||
memory->sfree(local_swap_jatom_list);
|
||||
atom_swap_nmax = atom->nmax;
|
||||
|
||||
@ -2190,7 +2190,7 @@ void FixGCMC::update_gas_atoms_list()
|
||||
tagint *molecule = atom->molecule;
|
||||
double **x = atom->x;
|
||||
|
||||
if (nlocal > gcmc_nmax) {
|
||||
if (atom->nmax > gcmc_nmax) {
|
||||
memory->sfree(local_gas_list);
|
||||
gcmc_nmax = atom->nmax;
|
||||
local_gas_list = (int *) memory->smalloc(gcmc_nmax*sizeof(int),
|
||||
|
||||
@ -254,7 +254,7 @@ void FixEfield::post_force(int vflag)
|
||||
|
||||
// reallocate efield array if necessary
|
||||
|
||||
if (varflag == ATOM && nlocal > maxatom) {
|
||||
if (varflag == ATOM && atom->nmax > maxatom) {
|
||||
maxatom = atom->nmax;
|
||||
memory->destroy(efield);
|
||||
memory->create(efield,maxatom,4,"efield:efield");
|
||||
|
||||
@ -444,7 +444,7 @@ void VerletSplit::rk_setup()
|
||||
// grow f_kspace array on master procs if necessary
|
||||
|
||||
if (master) {
|
||||
if (atom->nlocal > maxatom) {
|
||||
if (atom->nmax > maxatom) {
|
||||
memory->destroy(f_kspace);
|
||||
maxatom = atom->nmax;
|
||||
memory->create(f_kspace,maxatom,3,"verlet/split:f_kspace");
|
||||
|
||||
@ -179,7 +179,7 @@ void ComputeSNADAtom::compute_peratom()
|
||||
|
||||
// grow snad array if necessary
|
||||
|
||||
if (ntotal > nmax) {
|
||||
if (atom->nmax > nmax) {
|
||||
memory->destroy(snad);
|
||||
nmax = atom->nmax;
|
||||
memory->create(snad,nmax,size_peratom_cols,
|
||||
|
||||
@ -182,7 +182,7 @@ void ComputeSNAVAtom::compute_peratom()
|
||||
|
||||
// grow snav array if necessary
|
||||
|
||||
if (ntotal > nmax) {
|
||||
if (atom->nmax > nmax) {
|
||||
memory->destroy(snav);
|
||||
nmax = atom->nmax;
|
||||
memory->create(snav,nmax,size_peratom_cols,
|
||||
|
||||
@ -264,7 +264,7 @@ void ComputeTempDeformEff::remove_bias_all()
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
if (nlocal > maxbias) {
|
||||
if (atom->nmax > maxbias) {
|
||||
memory->destroy(vbiasall);
|
||||
maxbias = atom->nmax;
|
||||
memory->create(vbiasall,maxbias,3,"temp/deform/eff:vbiasall");
|
||||
|
||||
@ -237,7 +237,7 @@ void ComputeTempRegionEff::remove_bias_all()
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
if (nlocal > maxbias) {
|
||||
if (atom->nmax > maxbias) {
|
||||
memory->destroy(vbiasall);
|
||||
maxbias = atom->nmax;
|
||||
memory->create(vbiasall,maxbias,3,"temp/region:vbiasall");
|
||||
|
||||
@ -104,7 +104,7 @@ void FixLangevinEff::post_force_no_tally()
|
||||
error->one(FLERR,"Fix langevin/eff variable returned negative temperature");
|
||||
tsqrt = sqrt(t_target);
|
||||
} else {
|
||||
if (nlocal > maxatom2) {
|
||||
if (atom->nmax > maxatom2) {
|
||||
maxatom2 = atom->nmax;
|
||||
memory->destroy(tforce);
|
||||
memory->create(tforce,maxatom2,"langevin/eff:tforce");
|
||||
@ -241,7 +241,7 @@ void FixLangevinEff::post_force_tally()
|
||||
|
||||
// reallocate flangevin and erforcelangevin if necessary
|
||||
|
||||
if (atom->nlocal > maxatom1) {
|
||||
if (atom->nmax > maxatom1) {
|
||||
memory->destroy(flangevin);
|
||||
memory->destroy(erforcelangevin);
|
||||
maxatom1 = atom->nmax;
|
||||
@ -279,7 +279,7 @@ void FixLangevinEff::post_force_tally()
|
||||
error->one(FLERR,"Fix langevin/eff variable returned negative temperature");
|
||||
tsqrt = sqrt(t_target);
|
||||
} else {
|
||||
if (nlocal > maxatom2) {
|
||||
if (atom->nmax > maxatom2) {
|
||||
maxatom2 = atom->nmax;
|
||||
memory->destroy(tforce);
|
||||
memory->create(tforce,maxatom2,"langevin/eff:tforce");
|
||||
|
||||
@ -112,7 +112,7 @@ double ComputeTempRotate::compute_scalar()
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
if (nlocal > maxbias) {
|
||||
if (atom->nmax > maxbias) {
|
||||
memory->destroy(vbiasall);
|
||||
maxbias = atom->nmax;
|
||||
memory->create(vbiasall,maxbias,3,"temp/rotate:vbiasall");
|
||||
@ -175,7 +175,7 @@ void ComputeTempRotate::compute_vector()
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
if (nlocal > maxbias) {
|
||||
if (atom->nmax > maxbias) {
|
||||
memory->destroy(vbiasall);
|
||||
maxbias = atom->nmax;
|
||||
memory->create(vbiasall,maxbias,3,"temp/rotate:vbiasall");
|
||||
|
||||
@ -605,7 +605,7 @@ void FixAveSpatialSphere::end_of_step()
|
||||
int *mask= atom->mask;
|
||||
int nlocal= atom->nlocal;
|
||||
|
||||
if (nlocal > maxatom) {
|
||||
if (atom->nmax > maxatom) {
|
||||
maxatom= atom->nmax;
|
||||
memory->destroy(bin);
|
||||
memory->create(bin,maxatom,"ave/spatial/sphere:bin");
|
||||
@ -684,7 +684,7 @@ void FixAveSpatialSphere::end_of_step()
|
||||
else values_one[bin[i]][m] += array[i][jm1];
|
||||
}
|
||||
} else if(which[m] == VARIABLE) {
|
||||
if (nlocal > maxvar) {
|
||||
if (atom->nmax > maxvar) {
|
||||
maxvar = atom->nmax;
|
||||
memory->destroy(varatom);
|
||||
memory->create(varatom,maxvar,"ave/spatial:varatom");
|
||||
|
||||
@ -257,7 +257,7 @@ void FixSMDSetVel::post_force(int vflag) {
|
||||
|
||||
// reallocate sforce array if necessary
|
||||
|
||||
if (varflag == ATOM && nlocal > maxatom) {
|
||||
if (varflag == ATOM && atom->nmax > maxatom) {
|
||||
maxatom = atom->nmax;
|
||||
memory->destroy(sforce);
|
||||
memory->create(sforce, maxatom, 3, "setvelocity:sforce");
|
||||
|
||||
@ -266,7 +266,7 @@ int DumpCustomVTK::count()
|
||||
// grow choose and variable vbuf arrays if needed
|
||||
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal > maxlocal) {
|
||||
if (atom->nmax > maxlocal) {
|
||||
maxlocal = atom->nmax;
|
||||
|
||||
memory->destroy(choose);
|
||||
|
||||
@ -319,7 +319,7 @@ void ComputeVoronoi::buildCells()
|
||||
if (!input->variable->atomstyle(radvar))
|
||||
error->all(FLERR,"Variable for voronoi radius is not atom style");
|
||||
// prepare destination buffer for variable evaluation
|
||||
if (nlocal > rmax) {
|
||||
if (atom->nmax > rmax) {
|
||||
memory->destroy(rfield);
|
||||
rmax = atom->nmax;
|
||||
memory->create(rfield,rmax,"voronoi/atom:rfield");
|
||||
@ -378,7 +378,7 @@ void ComputeVoronoi::checkOccupation()
|
||||
**x = atom->x;
|
||||
|
||||
// prepare destination buffer for variable evaluation
|
||||
if (nall > lmax) {
|
||||
if (atom->nmax > lmax) {
|
||||
memory->destroy(lnext);
|
||||
lmax = atom->nmax;
|
||||
memory->create(lnext,lmax,"voronoi/atom:lnext");
|
||||
|
||||
@ -988,7 +988,7 @@ void ComputeChunkAtom::assign_chunk_ids()
|
||||
}
|
||||
|
||||
} else if (which == VARIABLE) {
|
||||
if (nlocal > maxvar) {
|
||||
if (atom->nmax > maxvar) {
|
||||
maxvar = atom->nmax;
|
||||
memory->destroy(varatom);
|
||||
memory->create(varatom,maxvar,"chunk/atom:varatom");
|
||||
|
||||
@ -104,7 +104,7 @@ void ComputeClusterAtom::compute_peratom()
|
||||
|
||||
// grow clusterID array if necessary
|
||||
|
||||
if (atom->nlocal+atom->nghost > nmax) {
|
||||
if (atom->nmax > nmax) {
|
||||
memory->destroy(clusterID);
|
||||
nmax = atom->nmax;
|
||||
memory->create(clusterID,nmax,"cluster/atom:clusterID");
|
||||
|
||||
@ -574,7 +574,7 @@ double ComputeReduce::compute_one(int m, int flag)
|
||||
// evaluate atom-style variable
|
||||
|
||||
} else if (which[m] == VARIABLE) {
|
||||
if (nlocal > maxatom) {
|
||||
if (atom->nmax > maxatom) {
|
||||
maxatom = atom->nmax;
|
||||
memory->destroy(varatom);
|
||||
memory->create(varatom,maxatom,"reduce:varatom");
|
||||
|
||||
@ -200,7 +200,7 @@ double ComputeReduceRegion::compute_one(int m, int flag)
|
||||
// evaluate atom-style variable
|
||||
|
||||
} else if (which[m] == VARIABLE) {
|
||||
if (nlocal > maxatom) {
|
||||
if (atom->nmax > maxatom) {
|
||||
maxatom = atom->nmax;
|
||||
memory->destroy(varatom);
|
||||
memory->create(varatom,maxatom,"reduce/region:varatom");
|
||||
|
||||
@ -251,7 +251,7 @@ void ComputeTempDeform::remove_bias_all()
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
if (nlocal > maxbias) {
|
||||
if (atom->nmax > maxbias) {
|
||||
memory->destroy(vbiasall);
|
||||
maxbias = atom->nmax;
|
||||
memory->create(vbiasall,maxbias,3,"temp/deform:vbiasall");
|
||||
|
||||
@ -215,7 +215,7 @@ void ComputeTempPartial::remove_bias_all()
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
if (nlocal > maxbias) {
|
||||
if (atom->nmax > maxbias) {
|
||||
memory->destroy(vbiasall);
|
||||
maxbias = atom->nmax;
|
||||
memory->create(vbiasall,maxbias,3,"temp/partial:vbiasall");
|
||||
|
||||
@ -516,7 +516,7 @@ void ComputeTempProfile::bin_assign()
|
||||
{
|
||||
// reallocate bin array if necessary
|
||||
|
||||
if (atom->nlocal > maxatom) {
|
||||
if (atom->nmax > maxatom) {
|
||||
maxatom = atom->nmax;
|
||||
memory->destroy(bin);
|
||||
memory->create(bin,maxatom,"temp/profile:bin");
|
||||
|
||||
@ -257,7 +257,7 @@ void ComputeTempRamp::remove_bias_all()
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
if (nlocal > maxbias) {
|
||||
if (atom->nmax > maxbias) {
|
||||
memory->destroy(vbiasall);
|
||||
maxbias = atom->nmax;
|
||||
memory->create(vbiasall,maxbias,3,"temp/ramp:vbiasall");
|
||||
|
||||
@ -226,7 +226,7 @@ void ComputeTempRegion::remove_bias_all()
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
if (nlocal > maxbias) {
|
||||
if (atom->nmax > maxbias) {
|
||||
memory->destroy(vbiasall);
|
||||
maxbias = atom->nmax;
|
||||
memory->create(vbiasall,maxbias,3,"temp/region:vbiasall");
|
||||
|
||||
@ -386,7 +386,7 @@ int DumpCustom::count()
|
||||
// grow choose and variable vbuf arrays if needed
|
||||
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal > maxlocal) {
|
||||
if (atom->nmax > maxlocal) {
|
||||
maxlocal = atom->nmax;
|
||||
|
||||
memory->destroy(choose);
|
||||
|
||||
@ -901,7 +901,7 @@ void DumpImage::create_image()
|
||||
// communicate choose flag for ghost atoms to know if they are selected
|
||||
// if bcolor/bdiam = ATOM, setup bufcopy to comm atom color/diam attributes
|
||||
|
||||
if (nall > maxbufcopy) {
|
||||
if (atom->nmax > maxbufcopy) {
|
||||
maxbufcopy = atom->nmax;
|
||||
memory->destroy(chooseghost);
|
||||
memory->create(chooseghost,maxbufcopy,"dump:chooseghost");
|
||||
|
||||
@ -251,7 +251,7 @@ void FixAddForce::post_force(int vflag)
|
||||
|
||||
// reallocate sforce array if necessary
|
||||
|
||||
if ((varflag == ATOM || estyle == ATOM) && nlocal > maxatom) {
|
||||
if ((varflag == ATOM || estyle == ATOM) && atom->nmax > maxatom) {
|
||||
maxatom = atom->nmax;
|
||||
memory->destroy(sforce);
|
||||
memory->create(sforce,maxatom,4,"addforce:sforce");
|
||||
|
||||
@ -721,7 +721,7 @@ void FixAveChunk::end_of_step()
|
||||
// evaluate atom-style variable
|
||||
|
||||
} else if (which[m] == VARIABLE) {
|
||||
if (nlocal > maxvar) {
|
||||
if (atom->nmax > maxvar) {
|
||||
maxvar = atom->nmax;
|
||||
memory->destroy(varatom);
|
||||
memory->create(varatom,maxvar,"ave/chunk:varatom");
|
||||
|
||||
@ -754,7 +754,7 @@ void FixAveHisto::end_of_step()
|
||||
bin_vector(nvec,varvec,1);
|
||||
|
||||
} else if (which[i] == VARIABLE && kind == PERATOM) {
|
||||
if (atom->nlocal > maxatom) {
|
||||
if (atom->nmax > maxatom) {
|
||||
memory->destroy(vector);
|
||||
maxatom = atom->nmax;
|
||||
memory->create(vector,maxatom,"ave/histo:vector");
|
||||
|
||||
@ -256,7 +256,7 @@ void FixAveHistoWeight::end_of_step()
|
||||
weight = input->variable->compute_equal(m);
|
||||
|
||||
} else if (which[i] == VARIABLE && kind == PERATOM) {
|
||||
if (atom->nlocal > maxatom) {
|
||||
if (atom->nmax > maxatom) {
|
||||
memory->destroy(vector);
|
||||
maxatom = atom->nmax;
|
||||
memory->create(vector,maxatom,"ave/histo/weight:vector");
|
||||
@ -385,7 +385,7 @@ void FixAveHistoWeight::end_of_step()
|
||||
bin_one_weights(input->variable->compute_equal(m),weight);
|
||||
|
||||
} else if (which[i] == VARIABLE && kind == PERATOM) {
|
||||
if (atom->nlocal > maxatom) {
|
||||
if (atom->nmax > maxatom) {
|
||||
memory->destroy(vector);
|
||||
maxatom = atom->nmax;
|
||||
memory->create(vector,maxatom,"ave/histo/weight:vector");
|
||||
|
||||
@ -585,7 +585,7 @@ void FixAveSpatial::end_of_step()
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
if (nlocal > maxatom) {
|
||||
if (atom->nmax > maxatom) {
|
||||
maxatom = atom->nmax;
|
||||
memory->destroy(bin);
|
||||
memory->create(bin,maxatom,"ave/spatial:bin");
|
||||
@ -716,7 +716,7 @@ void FixAveSpatial::end_of_step()
|
||||
// evaluate atom-style variable
|
||||
|
||||
} else if (which[m] == VARIABLE) {
|
||||
if (nlocal > maxvar) {
|
||||
if (atom->nmax > maxvar) {
|
||||
maxvar = atom->nmax;
|
||||
memory->destroy(varatom);
|
||||
memory->create(varatom,maxvar,"ave/spatial:varatom");
|
||||
|
||||
@ -153,7 +153,7 @@ void FixHeat::end_of_step()
|
||||
|
||||
// reallocate per-atom arrays if necessary
|
||||
|
||||
if (hstyle == ATOM && atom->nlocal > maxatom) {
|
||||
if (hstyle == ATOM && atom->nmax > maxatom) {
|
||||
maxatom = atom->nmax;
|
||||
memory->destroy(vheat);
|
||||
memory->destroy(vscale);
|
||||
|
||||
@ -511,7 +511,7 @@ void FixLangevin::post_force_untemplated
|
||||
// reallocate flangevin if necessary
|
||||
|
||||
if (Tp_TALLY) {
|
||||
if (atom->nlocal > maxatom1) {
|
||||
if (atom->nmax > maxatom1) {
|
||||
memory->destroy(flangevin);
|
||||
maxatom1 = atom->nmax;
|
||||
memory->create(flangevin,maxatom1,3,"langevin:flangevin");
|
||||
@ -641,7 +641,7 @@ void FixLangevin::compute_target()
|
||||
error->one(FLERR,"Fix langevin variable returned negative temperature");
|
||||
tsqrt = sqrt(t_target);
|
||||
} else {
|
||||
if (nlocal > maxatom2) {
|
||||
if (atom->nmax > maxatom2) {
|
||||
maxatom2 = atom->nmax;
|
||||
memory->destroy(tforce);
|
||||
memory->create(tforce,maxatom2,"langevin:tforce");
|
||||
|
||||
@ -726,7 +726,7 @@ void FixMove::initial_integrate(int vflag)
|
||||
|
||||
// reallocate displace and velocity arrays as necessary
|
||||
|
||||
if ((displaceflag || velocityflag) && nlocal > maxatom) {
|
||||
if ((displaceflag || velocityflag) && atom->nmax > maxatom) {
|
||||
maxatom = atom->nmax;
|
||||
if (displaceflag) {
|
||||
memory->destroy(displace);
|
||||
|
||||
@ -231,7 +231,7 @@ void FixSetForce::post_force(int vflag)
|
||||
|
||||
// reallocate sforce array if necessary
|
||||
|
||||
if (varflag == ATOM && nlocal > maxatom) {
|
||||
if (varflag == ATOM && atom->nmax > maxatom) {
|
||||
maxatom = atom->nmax;
|
||||
memory->destroy(sforce);
|
||||
memory->create(sforce,maxatom,3,"setforce:sforce");
|
||||
|
||||
@ -1539,7 +1539,7 @@ void Neighbor::build(int topoflag)
|
||||
double **x = atom->x;
|
||||
int nlocal = atom->nlocal;
|
||||
if (includegroup) nlocal = atom->nfirst;
|
||||
if (nlocal > maxhold) {
|
||||
if (atom->nmax > maxhold) {
|
||||
maxhold = atom->nmax;
|
||||
memory->destroy(xhold);
|
||||
memory->create(xhold,maxhold,3,"neigh:xhold");
|
||||
@ -1574,10 +1574,10 @@ void Neighbor::build(int topoflag)
|
||||
// else only invoke grow() if nlocal exceeds previous list size
|
||||
// only for lists with growflag set and which are perpetual (glist)
|
||||
|
||||
if (anyghostlist && atom->nlocal+atom->nghost > maxatom) {
|
||||
if (anyghostlist && atom->nmax > maxatom) {
|
||||
maxatom = atom->nmax;
|
||||
for (i = 0; i < nglist; i++) lists[glist[i]]->grow(maxatom);
|
||||
} else if (atom->nlocal > maxatom) {
|
||||
} else if (atom->nmax > maxatom) {
|
||||
maxatom = atom->nmax;
|
||||
for (i = 0; i < nglist; i++) lists[glist[i]]->grow(maxatom);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user