Commit 183980e8 authored by Richard Berger's avatar Richard Berger
Browse files

Replace VLAs with std::vectors

parent f2c11727
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -30,9 +30,11 @@
#include "domain.h"
#include "memory.h"
#include "error.h"
#include <vector>

#include "math_const.h"

using namespace std;
using namespace LAMMPS_NS;
using namespace MathConst;

@@ -2261,7 +2263,7 @@ void MSM::restriction(int n)
  double ***qgrid2 = qgrid[n+1];

  int k = 0;
  int index[p+2];
  vector<int> index(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]);
@@ -2348,7 +2350,7 @@ void MSM::prolongation(int n)
  double ***v5grid2 = v5grid[n+1];

  int k = 0;
  int index[p+2];
  vector<int> index(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]);
+1 −1
Original line number Diff line number Diff line
@@ -310,7 +310,7 @@ 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];
+8 −7
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@
#include "output.h"
#include "neighbor.h"
#include <iostream>
#include <vector>

using namespace std;
using namespace LAMMPS_NS;
@@ -1300,7 +1301,7 @@ void FixGCMC::attempt_molecule_insertion()
  MathExtra::quat_to_mat(quat,rotmat);

  double insertion_energy = 0.0;
  bool procflag[natoms_per_molecule];
  vector<bool> procflag(natoms_per_molecule);

  for (int i = 0; i < natoms_per_molecule; i++) {
    MathExtra::matvec(rotmat,onemols[imol]->x[i],atom_coord[i]);
@@ -1803,7 +1804,7 @@ void FixGCMC::attempt_molecule_rotation_full()

  double **x = atom->x;
  imageint *image = atom->image;
  imageint image_orig[natoms_per_molecule];
  vector<imageint> image_orig(natoms_per_molecule);
  int n = 0;
  for (int i = 0; i < atom->nlocal; i++) {
    if (mask[i] & molecule_group_bit) {
@@ -1866,8 +1867,8 @@ void FixGCMC::attempt_molecule_deletion_full()
  double energy_before = energy_stored;

  int m = 0;
  double q_tmp[natoms_per_molecule];
  int tmpmask[atom->nlocal];
  vector<double> q_tmp(natoms_per_molecule);
  vector<int> tmpmask(atom->nlocal);
  for (int i = 0; i < atom->nlocal; i++) {
    if (atom->molecule[i] == deletion_molecule) {
      tmpmask[i] = atom->mask[i];
@@ -2358,9 +2359,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];
      vector<double> comx(maxmol_all);
      vector<double> comy(maxmol_all);
      vector<double> comz(maxmol_all);
      for (int imolecule = 0; imolecule < maxmol_all; imolecule++) {
        for (int i = 0; i < nlocal; i++) {
          if (molecule[i] == imolecule) {
+4 −2
Original line number Diff line number Diff line
@@ -38,7 +38,9 @@
#include "error.h"
#include "force.h"
#include "math_const.h"
#include <vector>

using namespace std;
using namespace LAMMPS_NS;
using namespace MathConst;

@@ -588,7 +590,7 @@ void NEB::print_status()
    MPI_Allgather(&fnorminf,1,MPI_DOUBLE,&fmaxatomInRepl[0],1,MPI_DOUBLE,roots);
  }

  double one[numall];
  vector<double> one(numall);
  one[0] = fneb->veng;
  one[1] = fneb->plen;
  one[2] = fneb->nlen;
@@ -602,7 +604,7 @@ void NEB::print_status()

  if (output->thermo->normflag) one[0] /= atom->natoms;
  if (me == 0)
    MPI_Allgather(one,numall,MPI_DOUBLE,&all[0][0],numall,MPI_DOUBLE,roots);
    MPI_Allgather(&one[0],numall,MPI_DOUBLE,&all[0][0],numall,MPI_DOUBLE,roots);
  MPI_Bcast(&all[0][0],numall*nreplica,MPI_DOUBLE,0,world);

  rdist[0] = 0.0;
+5 −2
Original line number Diff line number Diff line
@@ -39,6 +39,9 @@
#include "version.h"
#endif

#include <vector>

using namespace std;
using namespace LAMMPS_NS;
using namespace MathConst;

@@ -1065,11 +1068,11 @@ 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];
  vector<png_bytep> row_pointers(height);
  for (int i=0; i < height; ++i)
    row_pointers[i] = (png_bytep) &writeBuffer[(height-i-1)*3*width];

  png_write_image(png_ptr, row_pointers);
  png_write_image(png_ptr, &row_pointers[0]);
  png_write_end(png_ptr, info_ptr);

  png_destroy_write_struct(&png_ptr, &info_ptr);
Loading