diff --git a/src/GPU/gpu_extra.h b/src/GPU/gpu_extra.h index ddb0b5ceaa..56a4f15f1b 100644 --- a/src/GPU/gpu_extra.h +++ b/src/GPU/gpu_extra.h @@ -61,13 +61,13 @@ namespace GPU_EXTRA { else error->all(FLERR,"Unknown error in GPU library"); } - }; + } inline void gpu_ready(LAMMPS_NS::Modify *modify, LAMMPS_NS::Error *error) { int ifix = modify->find_fix("package_gpu"); if (ifix < 0) error->all(FLERR,"The package gpu command is required for gpu styles"); - }; + } } #endif diff --git a/src/KIM/pair_kim.cpp b/src/KIM/pair_kim.cpp index 46e843158a..fe638214ba 100644 --- a/src/KIM/pair_kim.cpp +++ b/src/KIM/pair_kim.cpp @@ -1264,15 +1264,15 @@ void *PairKIM::extract(const char *str, int &dim) int ier; int dummyint; int isIndexed = 0; - int maxLine = 1024; + const int MAXLINE = 1024; int rank; int validParam = 0; int numParams; - int *speciesIndex = new int[maxLine]; - char *paramStr = new char[maxLine]; + int *speciesIndex = new int[MAXLINE]; + char *paramStr = new char[MAXLINE]; char *paramName; char *indexStr; - char message[maxLine]; + char message[MAXLINE]; int offset; double* paramPtr; @@ -1354,7 +1354,7 @@ void *PairKIM::extract(const char *str, int &dim) } kim_error(__LINE__,"get_rank",kimerror); - int *shape = new int[maxLine]; + int *shape = new int[MAXLINE]; dummyint = (*pkim).get_shape(paramName, shape, &kimerror); if (kimerror == KIM_STATUS_FAIL) { diff --git a/src/KSPACE/msm.cpp b/src/KSPACE/msm.cpp index cc1ea027ee..9f3221449b 100644 --- a/src/KSPACE/msm.cpp +++ b/src/KSPACE/msm.cpp @@ -2261,7 +2261,7 @@ void MSM::restriction(int n) double ***qgrid2 = qgrid[n+1]; int k = 0; - int index[p+2]; + int *index = new int[p+2]; for (int nu=-p; nu<=p; nu++) { if (nu%2 == 0 && nu != 0) continue; phi1d[0][k] = compute_phi(nu*delxinv[n+1]/delxinv[n]); @@ -2317,7 +2317,7 @@ void MSM::restriction(int n) } qgrid2[kp][jp][ip] += q2sum; } - + delete[] index; } /* ---------------------------------------------------------------------- @@ -2348,7 +2348,7 @@ void MSM::prolongation(int n) double ***v5grid2 = v5grid[n+1]; int k = 0; - int index[p+2]; + int *index = new int[p+2]; for (int nu=-p; nu<=p; nu++) { if (nu%2 == 0 && nu != 0) continue; phi1d[0][k] = compute_phi(nu*delxinv[n+1]/delxinv[n]); @@ -2420,7 +2420,7 @@ void MSM::prolongation(int n) } } - + delete[] index; } /* ---------------------------------------------------------------------- diff --git a/src/MANYBODY/pair_comb3.cpp b/src/MANYBODY/pair_comb3.cpp index e38a05c6ed..b4f9c02206 100644 --- a/src/MANYBODY/pair_comb3.cpp +++ b/src/MANYBODY/pair_comb3.cpp @@ -310,10 +310,10 @@ double PairComb3::init_one(int i, int j) void PairComb3::read_lib() { - unsigned int maxlib = 1024; + const unsigned int MAXLIB = 1024; int i,j,k,l,nwords,m; int ii,jj,kk,ll,mm,iii; - char s[maxlib]; + char s[MAXLIB]; char **words = new char*[80]; // open libraray file on proc 0 @@ -327,8 +327,8 @@ void PairComb3::read_lib() } // read and store at the same time - fgets(s,maxlib,fp); - fgets(s,maxlib,fp); + fgets(s,MAXLIB,fp); + fgets(s,MAXLIB,fp); nwords = 0; words[nwords++] = strtok(s," \t\n\r\f"); while ((words[nwords++] = strtok(NULL," \t\n\r\f")))continue; @@ -339,7 +339,7 @@ void PairComb3::read_lib() ccutoff[4] = atof(words[4]); ccutoff[5] = atof(words[5]); - fgets(s,maxlib,fp); + fgets(s,MAXLIB,fp); nwords = 0; words[nwords++] = strtok(s," \t\n\r\f"); while ((words[nwords++] = strtok(NULL," \t\n\r\f")))continue; @@ -351,7 +351,7 @@ void PairComb3::read_lib() ch_a[5] = atof(words[5]); ch_a[6] = atof(words[6]); - fgets(s,maxlib,fp); + fgets(s,MAXLIB,fp); nwords = 0; words[nwords++] = strtok(s," \t\n\r\f"); while ((words[nwords++] = strtok(NULL," \t\n\r\f")))continue; @@ -359,7 +359,7 @@ void PairComb3::read_lib() nsplrad = atoi(words[1]); nspltor = atoi(words[2]); - fgets(s,maxlib,fp); + fgets(s,MAXLIB,fp); nwords = 0; words[nwords++] = strtok(s," \t\n\r\f"); while ((words[nwords++] = strtok(NULL," \t\n\r\f")))continue; @@ -367,7 +367,7 @@ void PairComb3::read_lib() maxy = atoi(words[1]); maxz = atoi(words[2]); - fgets(s,maxlib,fp); + fgets(s,MAXLIB,fp); nwords = 0; words[nwords++] = strtok(s," \t\n\r\f"); while ((words[nwords++] = strtok(NULL," \t\n\r\f")))continue; @@ -376,7 +376,7 @@ void PairComb3::read_lib() maxconj = atoi(words[2]); for (l=0; lx[i],molcoords[i]); @@ -1472,6 +1472,7 @@ void FixGCMC::attempt_molecule_insertion() update_gas_atoms_list(); ninsertion_successes += 1.0; } + delete[] procflag; } /* ---------------------------------------------------------------------- @@ -1934,7 +1935,7 @@ void FixGCMC::attempt_molecule_deletion_full() grow_molecule_arrays(nmolq); int m = 0; - int tmpmask[atom->nlocal]; + int *tmpmask = new int[atom->nlocal]; for (int i = 0; i < atom->nlocal; i++) { if (atom->molecule[i] == deletion_molecule) { tmpmask[i] = atom->mask[i]; @@ -1982,6 +1983,7 @@ void FixGCMC::attempt_molecule_deletion_full() if (force->kspace) force->kspace->qsum_qsq(); } update_gas_atoms_list(); + delete[] tmpmask; } /* ---------------------------------------------------------------------- @@ -2426,9 +2428,9 @@ void FixGCMC::update_gas_atoms_list() for (int i = 0; i < nlocal; i++) maxmol = MAX(maxmol,molecule[i]); tagint maxmol_all; MPI_Allreduce(&maxmol,&maxmol_all,1,MPI_LMP_TAGINT,MPI_MAX,world); - double comx[maxmol_all]; - double comy[maxmol_all]; - double comz[maxmol_all]; + double *comx = new double[maxmol_all]; + double *comy = new double[maxmol_all]; + double *comz = new double[maxmol_all]; for (int imolecule = 0; imolecule < maxmol_all; imolecule++) { for (int i = 0; i < nlocal; i++) { if (molecule[i] == imolecule) { @@ -2458,7 +2460,9 @@ void FixGCMC::update_gas_atoms_list() } } } - + delete[] comx; + delete[] comy; + delete[] comz; } else { for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { diff --git a/src/PYTHON/fix_python_move.cpp b/src/PYTHON/fix_python_move.cpp index 7331a75db6..b330ab7945 100644 --- a/src/PYTHON/fix_python_move.cpp +++ b/src/PYTHON/fix_python_move.cpp @@ -47,7 +47,7 @@ FixPythonMove::FixPythonMove(LAMMPS *lmp, int narg, char **arg) : PyGILState_STATE gstate = PyGILState_Ensure(); // add current directory to PYTHONPATH - PyObject * py_path = PySys_GetObject("path"); + PyObject * py_path = PySys_GetObject((char *)"path"); PyList_Append(py_path, PY_STRING_FROM_STRING(".")); @@ -136,7 +136,7 @@ void FixPythonMove::init() { PyGILState_STATE gstate = PyGILState_Ensure(); PyObject *py_move_obj = (PyObject *) py_move; - PyObject *py_init = PyObject_GetAttrString(py_move_obj,"init"); + PyObject *py_init = PyObject_GetAttrString(py_move_obj,(char *)"init"); if (!py_init) { PyErr_Print(); PyErr_Clear(); diff --git a/src/REPLICA/neb.cpp b/src/REPLICA/neb.cpp index 35225b3c1e..c9aedf7401 100644 --- a/src/REPLICA/neb.cpp +++ b/src/REPLICA/neb.cpp @@ -303,7 +303,7 @@ void NEB::run() update->minimize->setup(); if (me_universe == 0) { - if (uscreen) + if (uscreen) { if (verbose) { fprintf(uscreen,"Step MaxReplicaForce MaxAtomForce " "GradV0 GradV1 GradVc EBF EBR RDT " @@ -317,7 +317,8 @@ void NEB::run() "EBF EBR RDT " "RD1 PE1 RD2 PE2 ... RDN PEN\n"); } - if (ulogfile) + } + if (ulogfile) { if (verbose) { fprintf(ulogfile,"Step MaxReplicaForce MaxAtomForce " "GradV0 GradV1 GradVc EBF EBR RDT " @@ -331,6 +332,7 @@ void NEB::run() "EBF EBR RDT " "RD1 PE1 RD2 PE2 ... RDN PEN\n"); } + } } print_status(); @@ -588,7 +590,7 @@ void NEB::print_status() MPI_Allgather(&fnorminf,1,MPI_DOUBLE,&fmaxatomInRepl[0],1,MPI_DOUBLE,roots); } - double one[numall]; + double one[7]; one[0] = fneb->veng; one[1] = fneb->plen; one[2] = fneb->nlen; diff --git a/src/RIGID/fix_rigid.cpp b/src/RIGID/fix_rigid.cpp index 554412330c..3d9e24ced9 100644 --- a/src/RIGID/fix_rigid.cpp +++ b/src/RIGID/fix_rigid.cpp @@ -2342,7 +2342,7 @@ void FixRigid::write_restart_file(char *file) sprintf(outfile,"%s.rigid",file); FILE *fp = fopen(outfile,"w"); if (fp == NULL) { - char str[128]; + char str[192]; sprintf(str,"Cannot open fix rigid restart file %s",outfile); error->one(FLERR,str); } diff --git a/src/USER-DPD/fix_rx.cpp b/src/USER-DPD/fix_rx.cpp index b8b002a7fa..c370f8abe6 100644 --- a/src/USER-DPD/fix_rx.cpp +++ b/src/USER-DPD/fix_rx.cpp @@ -260,6 +260,7 @@ void FixRX::post_constructor() error->all(FLERR,"fix rx cannot be combined with fix property/atom"); char **tmpspecies = new char*[maxspecies]; + int tmpmaxstrlen = 0; for(int jj=0; jj < maxspecies; jj++) tmpspecies[jj] = NULL; @@ -320,6 +321,7 @@ void FixRX::post_constructor() error->all(FLERR,"Exceeded the maximum number of species permitted in fix rx."); tmpspecies[nUniqueSpecies] = new char[strlen(word)+1]; strcpy(tmpspecies[nUniqueSpecies],word); + tmpmaxstrlen = MAX(tmpmaxstrlen,strlen(word)); nUniqueSpecies++; } word = strtok(NULL, " \t\n\r\f"); @@ -354,9 +356,9 @@ void FixRX::post_constructor() newarg2[0] = id_fix_species_old; newarg2[1] = group->names[igroup]; newarg2[2] = (char *) "property/atom"; + char *str1 = new char[tmpmaxstrlen+3]; + char *str2 = new char[tmpmaxstrlen+6]; for(int ii=0; ii::setup(int) { if (!rmass) { if (!mcoeff) mcoeff = new double[ntypes+1]; - double mcoeff_loc[ntypes+1]; + double *mcoeff_loc = new double[ntypes+1]; for (int itype=0; itype<=ntypes; itype++) mcoeff_loc[itype] = 2.; // an impossible value: mcoeff is at most 1. for (int i=0; i::setup(int) { // mcoeff is 2 for non polarizable // 0 < mcoeff < 1 for drude // mcoeff < 0 for core + delete[] mcoeff_loc; } } @@ -313,6 +314,6 @@ void FixDrudeTransform::unpack_forward_comm(int n, int first, double *b } /* ---------------------------------------------------------------------- */ -template class FixDrudeTransform; -template class FixDrudeTransform; +template class LAMMPS_NS::FixDrudeTransform; +template class LAMMPS_NS::FixDrudeTransform; diff --git a/src/USER-LB/fix_lb_momentum.cpp b/src/USER-LB/fix_lb_momentum.cpp index 6cf2d3bfd0..490b95ef71 100644 --- a/src/USER-LB/fix_lb_momentum.cpp +++ b/src/USER-LB/fix_lb_momentum.cpp @@ -102,8 +102,8 @@ void FixLbMomentum::end_of_step() double masslb,masslbloc; double momentumlbloc[3],momentumlb[3]; double vcmtotal[3]; - int numvel = fix_lb_fluid->numvel; - double etacov[numvel]; + const int numvel = fix_lb_fluid->numvel; + double etacov[19]; // = double etacov[numvel]; i.e. 15 or 19 double rho; if (linear) { diff --git a/src/USER-MEAMC/meam.h b/src/USER-MEAMC/meam.h index 8a439a2118..42fd722e01 100644 --- a/src/USER-MEAMC/meam.h +++ b/src/USER-MEAMC/meam.h @@ -255,5 +255,5 @@ static inline double fdiv_zero(const double n, const double d) { return n / d; } -}; +} #endif diff --git a/src/USER-MESO/pair_edpd.cpp b/src/USER-MESO/pair_edpd.cpp index f1d9c215b4..351637a842 100644 --- a/src/USER-MESO/pair_edpd.cpp +++ b/src/USER-MESO/pair_edpd.cpp @@ -59,7 +59,6 @@ static const char cite_pair_edpd[] = " volume = {51},\n" " pages = {11038--11040}\n" "}\n\n"; -; /* ---------------------------------------------------------------------- */ diff --git a/src/USER-MESO/pair_tdpd.cpp b/src/USER-MESO/pair_tdpd.cpp index 0d0d2a3a0a..b8bbf6d622 100644 --- a/src/USER-MESO/pair_tdpd.cpp +++ b/src/USER-MESO/pair_tdpd.cpp @@ -280,7 +280,9 @@ void PairTDPD::coeff(int narg, char **arg) double power_one = force->numeric(FLERR,arg[4]); double cut_one = force->numeric(FLERR,arg[5]); double cutcc_one = force->numeric(FLERR,arg[6]); - double kappa_one[cc_species],epsilon_one[cc_species],powercc_one[cc_species]; + double *kappa_one = new double[cc_species]; + double *epsilon_one = new double[cc_species]; + double *powercc_one = new double[cc_species]; for(int k=0; knumeric(FLERR,arg[7+3*k]); epsilon_one[k] = force->numeric(FLERR,arg[8+3*k]); @@ -304,6 +306,9 @@ void PairTDPD::coeff(int narg, char **arg) setflag[i][j] = 1; count++; } + delete[] kappa_one; + delete[] epsilon_one; + delete[] powercc_one; if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); } diff --git a/src/USER-MISC/compute_basal_atom.cpp b/src/USER-MISC/compute_basal_atom.cpp index 1da43a6baf..4d8627a11f 100644 --- a/src/USER-MISC/compute_basal_atom.cpp +++ b/src/USER-MISC/compute_basal_atom.cpp @@ -204,8 +204,11 @@ void ComputeBasalAtom::compute_peratom() double bond_angle; double norm_j, norm_k; chi[0] = chi[1] = chi[2] = chi[3] = chi[4] = chi[5] = chi[6] = chi[7] = 0; - double x_ij, y_ij, z_ij, x_ik, y_ik, z_ik,x3[n0],y3[n0],z3[n0], - xmean5, ymean5, zmean5, xmean6, ymean6, zmean6, xmean7, ymean7, zmean7; + double x_ij, y_ij, z_ij, x_ik, y_ik, z_ik, xmean5, ymean5, zmean5, + xmean6, ymean6, zmean6, xmean7, ymean7, zmean7; + double *x3 = new double[n0]; + double *y3 = new double[n0]; + double *z3 = new double[n0]; for (j = 0; j < n0; j++) { x_ij = x[i][0]-x[nearest_n0[j]][0]; y_ij = x[i][1]-x[nearest_n0[j]][1]; @@ -411,9 +414,12 @@ void ComputeBasalAtom::compute_peratom() } } } - } - //if there are less than two ~180 degree bond angles, the algorithm returns null - else BPV[i][0] = BPV[i][1] = BPV[i][2] = 0.0; + //if there are less than two ~180 degree bond angles, the algorithm returns null + } else BPV[i][0] = BPV[i][1] = BPV[i][2] = 0.0; + + delete[] x3; + delete[] y3; + delete[] z3; //normalize BPV: double Mag = sqrt(BPV[i][0]*BPV[i][0] + diff --git a/src/USER-MISC/fix_filter_corotate.cpp b/src/USER-MISC/fix_filter_corotate.cpp index a5f0e57041..91c7033513 100644 --- a/src/USER-MISC/fix_filter_corotate.cpp +++ b/src/USER-MISC/fix_filter_corotate.cpp @@ -1527,7 +1527,10 @@ void FixFilterCorotate::general_cluster(int index, int index_in_list) //derivative: //dn1dx: - double sum1[3][3*N]; + + double **sum1; + memory->create(sum1,3,3*N,"filter_corotate:sum1"); + for (int i=0; i<3; i++) for (int j=0; j<3*N; j++) sum1[i][j] = 0; @@ -1564,10 +1567,12 @@ void FixFilterCorotate::general_cluster(int index, int index_in_list) dn1dx[i][j] = norm1*sum; } } + memory->destroy(sum1); //dn2dx: norm2 * I3mn2n2T * (I3mn1n1T*sum2 - rkn1pn1rk*dn1dx) - double sum2[3][3*N]; + double **sum2; + memory->create(sum2,3,3*N,"filter_corotate:sum2"); for (int i=0; i<3; i++) for (int j=0; j<3*N; j++) sum2[i][j] = 0; @@ -1618,7 +1623,8 @@ void FixFilterCorotate::general_cluster(int index, int index_in_list) //dn2dx: norm2 * I3mn2n2T * (I3mn1n1T*sum2 - rkn1pn1rk*dn1dx) //sum3 = (I3mn1n1T*sum2 - rkn1pn1rk*dn1dx) - double sum3[3][3*N]; + double **sum3; + memory->create(sum3,3,3*N,"filter_corotate:sum3"); for (int i=0; i<3; i++) for (int j=0; j<3*N; j++) { double sum = 0; @@ -1627,6 +1633,7 @@ void FixFilterCorotate::general_cluster(int index, int index_in_list) sum3[i][j] = sum; } + memory->destroy(sum2); //dn2dx = norm2 * I3mn2n2T * sum3 for (int i=0; i<3; i++) for (int j=0; j<3*N; j++) { @@ -1636,6 +1643,7 @@ void FixFilterCorotate::general_cluster(int index, int index_in_list) dn2dx[i][j] = norm2*sum; } + memory->destroy(sum3); //dn3dx = norm3 * I3mn3n3T * cross double I3mn3n3T[3][3]; //(I_3 - n3n3T) for (int i=0; i<3; i++) { @@ -1644,7 +1652,8 @@ void FixFilterCorotate::general_cluster(int index, int index_in_list) I3mn3n3T[i][i] += 1.0; } - double cross[3][3*N]; + double **cross; + memory->create(cross,3,3*N,"filter_corotate:cross"); for (int j=0; j<3*N; j++) { cross[0][j] = dn1dx[1][j]*n2[2] -dn1dx[2][j]*n2[1] + @@ -1663,6 +1672,7 @@ void FixFilterCorotate::general_cluster(int index, int index_in_list) dn3dx[i][j] = norm3*sum; } + memory->destroy(cross); for (int l=0; l0.?sqrt(D[i]):0.); - } + D[i]=(D[i]>0.0) ? sqrt(D[i]):0.0; + } - for(i=0; i=0; p--) - { - MyMult(n, n, n, SM, EM, TMP); for (int i=0; i=0; p--) { + MyMult(n, n, n, SM, EM, TMP); for (int i=0; if; - double lbuf[bsize]; + double *lbuf = new double[bsize]; // reassembles the force vector from the local arrays int nlocal = atom->nlocal; @@ -440,6 +440,7 @@ void FixIPI::final_integrate() lbuf[3*(atom->tag[i]-1)+2]=f[i][2]*forceconv; } MPI_Allreduce(lbuf,buffer,bsize,MPI_DOUBLE,MPI_SUM,world); + delete[] lbuf; for (int i = 0; i < 9; ++i) vir[i]=0.0; diff --git a/src/USER-MISC/pair_lj_sf_dipole_sf.cpp b/src/USER-MISC/pair_lj_sf_dipole_sf.cpp index cc92bfc30f..523b2ca71a 100644 --- a/src/USER-MISC/pair_lj_sf_dipole_sf.cpp +++ b/src/USER-MISC/pair_lj_sf_dipole_sf.cpp @@ -539,7 +539,7 @@ double PairLJSFDipoleSF::single(int i, int j, int itype, int jtype, double rsq, double &fforce) { double r2inv,r6inv; - double pdotp,pidotr,pjdotr,pre1,delx,dely,delz; + double pdotp,pidotr,pjdotr,delx,dely,delz; double rinv, r3inv,r5inv, rcutlj2inv, rcutcoul2inv,rcutlj6inv; double qtmp,xtmp,ytmp,ztmp,bfac,pqfac,qpfac, ecoul, evdwl; diff --git a/src/USER-PHONON/fix_phonon.cpp b/src/USER-PHONON/fix_phonon.cpp index cf56117892..3a37c67a38 100644 --- a/src/USER-PHONON/fix_phonon.cpp +++ b/src/USER-PHONON/fix_phonon.cpp @@ -668,7 +668,8 @@ void FixPhonon::postprocess( ) } // to get Phi = KT.G^-1; normalization of FFTW data is done here - double boltz = force->boltz, kbtsqrt[sysdim], TempAve = 0.; + double boltz = force->boltz, TempAve = 0.; + double *kbtsqrt = new double[sysdim]; double TempFac = inv_neval * inv_nTemp; double NormFac = TempFac * double(ntotal); @@ -692,7 +693,7 @@ void FixPhonon::postprocess( ) MPI_Gatherv(Phi_q[0],mynq*fft_dim2*2,MPI_DOUBLE,Phi_all[0],recvcnts,displs,MPI_DOUBLE,0,world); // to collect all basis info and averaged it on root - double basis_root[fft_dim]; + double *basis_root = new double[fft_dim]; if (fft_dim > sysdim) MPI_Reduce(&basis[1][0], &basis_root[sysdim], fft_dim-sysdim, MPI_DOUBLE, MPI_SUM, 0, world); if (me == 0){ // output dynamic matrix by root @@ -772,7 +773,8 @@ void FixPhonon::postprocess( ) } fflush(flog); } - + delete[] kbtsqrt; + delete[] basis_root; } // end of postprocess /* ---------------------------------------------------------------------- diff --git a/src/USER-SMD/fix_smd_integrate_ulsph.h b/src/USER-SMD/fix_smd_integrate_ulsph.h index ea4f46ce53..9d954bf529 100644 --- a/src/USER-SMD/fix_smd_integrate_ulsph.h +++ b/src/USER-SMD/fix_smd_integrate_ulsph.h @@ -48,7 +48,7 @@ class FixSMDIntegrateUlsph : public Fix { private: class NeighList *list; protected: - double dtv,dtf, vlimit, vlimitsq;; + double dtv,dtf, vlimit, vlimitsq; int mass_require; bool xsphFlag; bool adjust_radius_flag; diff --git a/src/USER-UEF/fix_nh_uef.h b/src/USER-UEF/fix_nh_uef.h index 43f5bb46a9..0629db5aa1 100644 --- a/src/USER-UEF/fix_nh_uef.h +++ b/src/USER-UEF/fix_nh_uef.h @@ -23,7 +23,7 @@ namespace LAMMPS_NS { // forward declaration namespace UEF_utils { class UEFBox; - }; + } class FixNHUef : public FixNH { public: diff --git a/src/image.cpp b/src/image.cpp index 599ac4a091..301a2af88f 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -1065,7 +1065,7 @@ void Image::write_PNG(FILE *fp) png_set_text(png_ptr,info_ptr,text_ptr,1); png_write_info(png_ptr,info_ptr); - png_bytep row_pointers[height]; + png_bytep *row_pointers = new png_bytep[height]; for (int i=0; i < height; ++i) row_pointers[i] = (png_bytep) &writeBuffer[(height-i-1)*3*width]; @@ -1073,6 +1073,7 @@ void Image::write_PNG(FILE *fp) png_write_end(png_ptr, info_ptr); png_destroy_write_struct(&png_ptr, &info_ptr); + delete[] row_pointers; #endif } diff --git a/src/library.cpp b/src/library.cpp index 865bf2a0a5..0162c560ce 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -933,7 +933,7 @@ void lammps_gather_atoms_concat(void *ptr, char *name, BEGIN_CAPTURE { - int i,j,offset; + int i,offset; // error if tags are not defined // NOTE: test that name = image or ids is not a 64-bit int in code? @@ -975,7 +975,6 @@ void lammps_gather_atoms_concat(void *ptr, char *name, lmp->memory->create(copy,count*natoms,"lib/gather:copy"); for (i = 0; i < count*natoms; i++) copy[i] = 0; - tagint *tag = lmp->atom->tag; int nlocal = lmp->atom->nlocal; if (count == 1) { @@ -1117,7 +1116,6 @@ void lammps_gather_atoms_subset(void *ptr, char *name, lmp->memory->create(copy,count*ndata,"lib/gather:copy"); for (i = 0; i < count*ndata; i++) copy[i] = 0; - tagint *tag = lmp->atom->tag; int nlocal = lmp->atom->nlocal; if (count == 1) { @@ -1163,7 +1161,6 @@ void lammps_gather_atoms_subset(void *ptr, char *name, lmp->memory->create(copy,count*ndata,"lib/gather:copy"); for (i = 0; i < count*ndata; i++) copy[i] = 0.0; - tagint *tag = lmp->atom->tag; int nlocal = lmp->atom->nlocal; if (count == 1) { diff --git a/src/molecule.cpp b/src/molecule.cpp index b03142e984..56e56dab2c 100644 --- a/src/molecule.cpp +++ b/src/molecule.cpp @@ -1111,7 +1111,7 @@ void Molecule::special_generate() { int newton_bond = force->newton_bond; tagint atom1,atom2; - int count[natoms]; + int *count = new int[natoms]; // temporary array for special atoms @@ -1197,6 +1197,7 @@ void Molecule::special_generate() } } } + delete[] count; maxspecial = 0; for (int i = 0; i < natoms; i++)