From 72b295d7f48538f310b658b63497904a0659a082 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 10 Jun 2019 18:21:17 -0400 Subject: [PATCH 1/4] add support for internal style variables to info command --- src/info.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/info.cpp b/src/info.cpp index ac2ee4a96d..25b9879408 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -67,7 +67,7 @@ namespace LAMMPS_NS { // same as in variable.cpp enum {INDEX,LOOP,WORLD,UNIVERSE,ULOOP,STRING,GETENV, - SCALARFILE,ATOMFILE,FORMAT,EQUAL,ATOM,PYTHON}; + SCALARFILE,ATOMFILE,FORMAT,EQUAL,ATOM,VECTOR,PYTHON,INTERNAL}; enum {COMPUTES=1<<0, DUMPS=1<<1, @@ -106,7 +106,7 @@ static const int STYLES = ATOM_STYLES | INTEGRATE_STYLES | MINIMIZE_STYLES static const char *varstyles[] = { "index", "loop", "world", "universe", "uloop", "string", "getenv", - "file", "atomfile", "format", "equal", "atom", "python", "(unknown)"}; + "file", "atomfile", "format", "equal", "atom", "vector", "python", "internal", "(unknown)"}; static const char *mapstyles[] = { "none", "array", "hash" }; @@ -599,6 +599,10 @@ void Info::command(int narg, char **arg) int ndata = 1; fprintf(out,"Variable[%3d]: %-10s, style = %-10s, def =", i,names[i],varstyles[style[i]]); + if (style[i] == INTERNAL) { + fprintf(out,"%g\n",input->variable->dvalue[i]); + continue; + } if ((style[i] != LOOP) && (style[i] != ULOOP)) ndata = input->variable->num[i]; for (int j=0; j < ndata; ++j) From 3e2f3a80583494420eda14e4ce178f5b71695e60 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 10 Jun 2019 18:22:04 -0400 Subject: [PATCH 2/4] avoid a case of mixing malloc()/free() with new/delete --- src/variable.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/variable.cpp b/src/variable.cpp index 376cc8045a..7cbdc57d3a 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -288,11 +288,11 @@ void Variable::set(int narg, char **arg) int maxcopy = strlen(arg[2]) + 1; int maxwork = maxcopy; - char *scopy = new char[maxcopy]; - char *work = new char[maxwork]; + char *scopy = (char *) memory->smalloc(maxcopy,"var:string/copy"); + char *work = (char *) memory->smalloc(maxwork,"var:string/work"); strcpy(scopy,arg[2]); input->substitute(scopy,work,maxcopy,maxwork,1); - delete [] work; + memory->sfree(work); int ivar = find(arg[0]); if (ivar >= 0) { @@ -310,7 +310,7 @@ void Variable::set(int narg, char **arg) data[nvar] = new char*[num[nvar]]; copy(1,&scopy,data[nvar]); } - delete [] scopy; + memory->sfree(scopy); // GETENV // remove pre-existing var if also style GETENV (allows it to be reset) From 7f4c611e2148387acedb58b2f7767cf54c936b14 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 11 Jun 2019 06:51:03 -0400 Subject: [PATCH 3/4] must use C++ compiler to check for include files --- cmake/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 911b6f0f15..8ab9540482 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -1135,7 +1135,7 @@ endif() if(PKG_USER-INTEL) include(CheckIncludeFile) - check_include_file(immintrin.h FOUND_IMMINTRIN) + check_include_file_cxx(immintrin.h FOUND_IMMINTRIN) if(NOT FOUND_IMMINTRIN) message(FATAL_ERROR "immintrin.h header not found, Intel package won't work without it") endif() From dbafb92dd5202571be499acbe306f50cb18ff8e2 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 11 Jun 2019 14:02:41 -0400 Subject: [PATCH 4/4] cmake minor cleanup and removal of redundant code and empty lines --- cmake/CMakeLists.txt | 7 +------ cmake/Modules/Packages/USER-INTEL.cmake | 1 - 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 40d3de0e7b..8f7ac9a6e7 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -33,7 +33,6 @@ include(LAMMPSUtils) get_lammps_version(${LAMMPS_SOURCE_DIR}/version.h LAMMPS_VERSION) - include(PreventInSourceBuilds) if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CXX_FLAGS) @@ -51,6 +50,7 @@ check_for_autogen_files(${LAMMPS_SOURCE_DIR}) # these need ot be done early (before further tests). ##################################################################### include(CheckCCompilerFlag) +include(CheckIncludeFileCXX) if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -restrict") @@ -186,10 +186,6 @@ if(LAMMPS_EXCEPTIONS) set(LAMMPS_API_DEFINES "${LAMMPS_API_DEFINES} -DLAMMPS_EXCEPTIONS") endif() -option(CMAKE_VERBOSE_MAKEFILE "Verbose makefile" OFF) - - - # "hard" dependencies between packages resulting # in an error instead of skipping over files pkg_depends(MPIIO MPI) @@ -198,7 +194,6 @@ pkg_depends(USER-LB MPI) pkg_depends(USER-PHONON KSPACE) pkg_depends(USER-SCAFACOS MPI) -include(CheckIncludeFileCXX) find_package(OpenMP QUIET) # TODO: this is a temporary workaround until a better solution is found. AK 2019-05-30 diff --git a/cmake/Modules/Packages/USER-INTEL.cmake b/cmake/Modules/Packages/USER-INTEL.cmake index f61b8f1630..3c0cc7ba24 100644 --- a/cmake/Modules/Packages/USER-INTEL.cmake +++ b/cmake/Modules/Packages/USER-INTEL.cmake @@ -1,5 +1,4 @@ if(PKG_USER-INTEL) - include(CheckIncludeFile) check_include_file_cxx(immintrin.h FOUND_IMMINTRIN) if(NOT FOUND_IMMINTRIN) message(FATAL_ERROR "immintrin.h header not found, Intel package won't work without it")