From 37442ca5cf1034cf90da9bdbdf84415e11e78946 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 15 May 2020 08:05:32 -0400 Subject: [PATCH] fix bug in USER-OMP with "pair_modify compute no" and "kspace_modify compute no" --- src/USER-OMP/fix_omp.cpp | 12 +++++++++--- src/USER-OMP/fix_omp.h | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/USER-OMP/fix_omp.cpp b/src/USER-OMP/fix_omp.cpp index d7216a4571..51e65d24ed 100644 --- a/src/USER-OMP/fix_omp.cpp +++ b/src/USER-OMP/fix_omp.cpp @@ -63,7 +63,8 @@ static int get_tid() FixOMP::FixOMP(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), thr(NULL), last_omp_style(NULL), last_pair_hybrid(NULL), - _nthr(-1), _neighbor(true), _mixed(false), _reduced(true) + _nthr(-1), _neighbor(true), _mixed(false), _reduced(true), + _pair_compute_flag(false), _kspace_compute_flag(false) { if (narg < 4) error->all(FLERR,"Illegal package omp command"); @@ -207,6 +208,11 @@ void FixOMP::init() && (strstr(update->integrate_style,"respa/omp") == NULL)) error->all(FLERR,"Need to use respa/omp for r-RESPA with /omp styles"); + if (force->pair && force->pair->compute_flag) _pair_compute_flag = true; + else _pair_compute_flag = false; + if (force->kspace && force->kspace->compute_flag) _kspace_compute_flag = true; + else _kspace_compute_flag = false; + int check_hybrid, kspace_split; last_pair_hybrid = NULL; last_omp_style = NULL; @@ -254,7 +260,7 @@ void FixOMP::init() } \ } - if (kspace_split <= 0) { + if (_pair_compute_flag && (kspace_split <= 0)) { CheckStyleForOMP(pair); CheckHybridForOMP(pair,Pair); if (check_hybrid) { @@ -275,7 +281,7 @@ void FixOMP::init() CheckHybridForOMP(improper,Improper); } - if (kspace_split >= 0) { + if (_kspace_compute_flag && (kspace_split >= 0)) { CheckStyleForOMP(kspace); } diff --git a/src/USER-OMP/fix_omp.h b/src/USER-OMP/fix_omp.h index 55e042dd52..3020a927fd 100644 --- a/src/USER-OMP/fix_omp.h +++ b/src/USER-OMP/fix_omp.h @@ -70,6 +70,8 @@ class FixOMP : public Fix { bool _neighbor; // en/disable threads for neighbor list construction bool _mixed; // whether to prefer mixed precision compute kernels bool _reduced; // whether forces have been reduced for this step + bool _pair_compute_flag; // whether pair_compute is called + bool _kspace_compute_flag; // whether kspace_compute is called void set_neighbor_omp(); };