@@ -169,16 +169,23 @@ namespace ReaxFF {
169
169
static int Reallocate_HBonds_List (reax_system *system, reax_list *hbonds)
170
170
{
171
171
int i, total_hbonds;
172
+ LAMMPS_NS::bigint total_hbonds_big;
172
173
173
174
int mincap = system->mincap ;
174
175
double saferzone = system->saferzone ;
175
176
176
- total_hbonds = 0 ;
177
+ total_hbonds_big = 0 ;
177
178
for (i = 0 ; i < system->n ; ++i)
178
179
if ((system->my_atoms [i].Hindex ) >= 0 ) {
179
- total_hbonds += system->my_atoms [i].num_hbonds ;
180
+ total_hbonds_big += system->my_atoms [i].num_hbonds ;
180
181
}
181
- total_hbonds = (int )(MAX (total_hbonds*saferzone, mincap*system->minhbonds ));
182
+ total_hbonds_big = (LAMMPS_NS::bigint)(MAX (total_hbonds_big*saferzone, mincap*system->minhbonds ));
183
+
184
+ auto error = system->error_ptr ;
185
+ if (total_hbonds_big > MAXSMALLINT)
186
+ error->one (FLERR," Too many hydrogen bonds in pair reaxff" );
187
+
188
+ total_hbonds = total_hbonds_big;
182
189
183
190
Delete_List (hbonds);
184
191
Make_List (system->Hcap , total_hbonds, TYP_HBOND, hbonds);
@@ -190,17 +197,24 @@ namespace ReaxFF {
190
197
reax_list *bonds, int *total_bonds, int *est_3body)
191
198
{
192
199
int i;
200
+ LAMMPS_NS::bigint total_bonds_big;
193
201
194
202
int mincap = system->mincap ;
195
203
double safezone = system->safezone ;
196
204
197
- *total_bonds = 0 ;
205
+ total_bonds_big = 0 ;
198
206
*est_3body = 0 ;
199
207
for (i = 0 ; i < system->N ; ++i) {
200
208
*est_3body += SQR (system->my_atoms [i].num_bonds );
201
- *total_bonds += system->my_atoms [i].num_bonds ;
209
+ total_bonds_big += system->my_atoms [i].num_bonds ;
202
210
}
203
- *total_bonds = (int )(MAX (*total_bonds * safezone, mincap*MIN_BONDS));
211
+ total_bonds_big = (LAMMPS_NS::bigint)(MAX (total_bonds_big * safezone, mincap*MIN_BONDS));
212
+
213
+ auto error = system->error_ptr ;
214
+ if (total_bonds_big > MAXSMALLINT)
215
+ error->one (FLERR," Too many bonds in pair reaxff" );
216
+
217
+ *total_bonds = total_bonds_big;
204
218
205
219
if (system->omp_active )
206
220
for (i = 0 ; i < bonds->num_intrs ; ++i)
0 commit comments