From 13f1c7d2d72e69eea5a4359741fda4fa30e153e6 Mon Sep 17 00:00:00 2001 From: jrgissing Date: Wed, 13 Feb 2019 20:42:52 -0700 Subject: [PATCH] bond/react_VLA_compliance --- src/USER-MISC/fix_bond_react.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/USER-MISC/fix_bond_react.cpp b/src/USER-MISC/fix_bond_react.cpp index b9c357f363..42ebdd69f7 100644 --- a/src/USER-MISC/fix_bond_react.cpp +++ b/src/USER-MISC/fix_bond_react.cpp @@ -1174,13 +1174,16 @@ void FixBondReact::superimpose_algorithm() for (int i = 0; i < nreacts; i++) { if (reaction_count_total[i] > max_rxn[i]) { // let's randomly choose rxns to skip, unbiasedly from local and ghostly - int local_rxncounts[nprocs]; - int all_localskips[nprocs]; + int *local_rxncounts; + int *all_localskips; + memory->create(local_rxncounts,nprocs,"bond/react:local_rxncounts"); + memory->create(all_localskips,nprocs,"bond/react:all_localskips"); MPI_Gather(&local_rxn_count[i],1,MPI_INT,local_rxncounts,1,MPI_INT,0,world); if (me == 0) { int overstep = reaction_count_total[i] - max_rxn[i]; int delta_rxn = reaction_count[i] + ghostly_rxn_count[i]; - int rxn_by_proc[delta_rxn]; + int *rxn_by_proc; + memory->create(rxn_by_proc,delta_rxn,"bond/react:rxn_by_proc"); for (int j = 0; j < delta_rxn; j++) rxn_by_proc[j] = -1; // corresponds to ghostly int itemp = 0; @@ -1195,10 +1198,13 @@ void FixBondReact::superimpose_algorithm() if (rxn_by_proc[j] == -1) nghostlyskips[i]++; else all_localskips[rxn_by_proc[j]]++; } + memory->destroy(rxn_by_proc); } reaction_count_total[i] = max_rxn[i]; MPI_Scatter(&all_localskips[0],1,MPI_INT,&nlocalskips[i],1,MPI_INT,0,world); MPI_Bcast(&nghostlyskips[i],1,MPI_INT,0,world); + memory->destroy(local_rxncounts); + memory->destroy(all_localskips); } } @@ -2170,7 +2176,7 @@ void FixBondReact::update_everything() for (int pass = 0; pass < 2; pass++) { update_num_mega = 0; - int iskip[nreacts]; + int *iskip = new int[nreacts]; for (int i = 0; i < nreacts; i++) iskip[i] = 0; if (pass == 0) { for (int i = 0; i < local_num_mega; i++) { @@ -2191,6 +2197,7 @@ void FixBondReact::update_everything() update_num_mega++; } } + delete [] iskip; // mark to-delete atoms for (int i = 0; i < update_num_mega; i++) {