From 42e8a7613e144e86b8ce0eac302b5fc87323779e Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 5 Apr 2019 06:29:38 -0400 Subject: [PATCH] stop with error or print a warning when the system or atom ids get to large for reax/c pair styles --- src/USER-OMP/pair_reaxc_omp.cpp | 9 +++++++++ src/USER-REAXC/pair_reaxc.cpp | 11 +++++++++-- src/USER-REAXC/reaxc_io_tools.cpp | 6 ++---- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/USER-OMP/pair_reaxc_omp.cpp b/src/USER-OMP/pair_reaxc_omp.cpp index 92ba31048d..81e890538a 100644 --- a/src/USER-OMP/pair_reaxc_omp.cpp +++ b/src/USER-OMP/pair_reaxc_omp.cpp @@ -343,6 +343,15 @@ void PairReaxCOMP::init_style( ) if (force->newton_pair == 0) error->all(FLERR,"Pair style reax/c/omp requires newton pair on"); + if ((atom->map_max_tag > 99999999) && (comm->me == 0)) + error->warning(FLERR,"Some Atom-IDs are too large. Pair style reax/c/omp " + "native output files may get misformatted or corrupted"); + + // because system->bigN is an int, we cannot have more atoms than MAXSMALLINT + + if (atom->natoms > MAXSMALLINT) + error->all(FLERR,"Too many atoms for pair style reax/c/omp"); + // need a half neighbor list w/ Newton off and ghost neighbors // built whenever re-neighboring occurs diff --git a/src/USER-REAXC/pair_reaxc.cpp b/src/USER-REAXC/pair_reaxc.cpp index 6bb2b9a197..3164280872 100644 --- a/src/USER-REAXC/pair_reaxc.cpp +++ b/src/USER-REAXC/pair_reaxc.cpp @@ -90,8 +90,7 @@ PairReaxC::PairReaxC(LAMMPS *lmp) : Pair(lmp) mpi_data = (mpi_datatypes *) memory->smalloc(sizeof(mpi_datatypes),"reax:mpi"); - MPI_Comm_rank(world,&system->my_rank); - control->me = system->my_rank; + control->me = system->my_rank = comm->me; system->my_coords[0] = 0; system->my_coords[1] = 0; @@ -383,6 +382,14 @@ void PairReaxC::init_style( ) error->all(FLERR,"Pair style reax/c requires atom IDs"); if (force->newton_pair == 0) error->all(FLERR,"Pair style reax/c requires newton pair on"); + if ((atom->map_max_tag > 99999999) && (comm->me == 0)) + error->warning(FLERR,"Some Atom-IDs are too large. Pair style reax/c " + "native output files may get misformatted or corrupted"); + + // because system->bigN is an int, we cannot have more atoms than MAXSMALLINT + + if (atom->natoms > MAXSMALLINT) + error->all(FLERR,"Too many atoms for pair style reax/c"); // need a half neighbor list w/ Newton off and ghost neighbors // built whenever re-neighboring occurs diff --git a/src/USER-REAXC/reaxc_io_tools.cpp b/src/USER-REAXC/reaxc_io_tools.cpp index f71fcbec8e..a4f0db7c7d 100644 --- a/src/USER-REAXC/reaxc_io_tools.cpp +++ b/src/USER-REAXC/reaxc_io_tools.cpp @@ -55,8 +55,7 @@ int Init_Output_Files( reax_system *system, control_params *control, sprintf( temp, "%s.pot", control->sim_name ); if ((out_control->pot = fopen( temp, "w" )) != NULL) { fflush( out_control->pot ); - } - else { + } else { strcpy( msg, "init_out_controls: .pot file could not be opened\n" ); return FAILURE; } @@ -74,8 +73,7 @@ int Init_Output_Files( reax_system *system, control_params *control, "step", "Pint/norm[x]", "Pint/norm[y]", "Pint/norm[z]", "Pext/Ptot[x]", "Pext/Ptot[y]", "Pext/Ptot[z]", "Pkin/V" ); fflush( out_control->prs ); - } - else { + } else { strcpy(msg,"init_out_controls: .prs file couldn't be opened\n"); return FAILURE; }