From 3080bb53411335a2008bedba4c01903f0cd413d6 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 28 Jul 2016 08:03:42 -0400 Subject: [PATCH] provide better informative messages when OMP_NUM_THREADS is not set or code was compiled without OpenMP support --- src/USER-OMP/fix_omp.cpp | 5 +++++ src/comm.cpp | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/USER-OMP/fix_omp.cpp b/src/USER-OMP/fix_omp.cpp index e3adb6c268..20e60bab26 100644 --- a/src/USER-OMP/fix_omp.cpp +++ b/src/USER-OMP/fix_omp.cpp @@ -105,6 +105,7 @@ FixOMP::FixOMP(LAMMPS *lmp, int narg, char **arg) // print summary of settings if (comm->me == 0) { +#if defined(_OPENMP) const char * const nmode = _neighbor ? "multi-threaded" : "serial"; if (screen) { @@ -118,6 +119,10 @@ FixOMP::FixOMP(LAMMPS *lmp, int narg, char **arg) fprintf(logfile,"set %d OpenMP thread(s) per MPI task\n", nthreads); fprintf(logfile,"using %s neighbor list subroutines\n", nmode); } +#else + error->warning(FLERR,"OpenMP support not enabled during compilation; " + "using 1 thread only."); +#endif } // allocate list for per thread accumulator manager class instances diff --git a/src/comm.cpp b/src/comm.cpp index f29d1bf7df..070fd8575a 100644 --- a/src/comm.cpp +++ b/src/comm.cpp @@ -87,7 +87,8 @@ Comm::Comm(LAMMPS *lmp) : Pointers(lmp) } else if (getenv("OMP_NUM_THREADS") == NULL) { nthreads = 1; if (me == 0) - error->warning(FLERR,"OMP_NUM_THREADS environment is not set."); + error->warning(FLERR,"OMP_NUM_THREADS environment is not set. " + "Defaulting to 1 thread."); } else { nthreads = omp_get_max_threads(); }