From 4e97b575087377e8b74e4b0ac8f3a36fc9477d95 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 10 Aug 2017 05:46:42 -0400 Subject: [PATCH 1/8] remove -DLAMMPS_MEMALIGN from "make mpi" and "make serial" for increased portability --- src/MAKE/Makefile.mpi | 2 +- src/MAKE/Makefile.serial | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MAKE/Makefile.mpi b/src/MAKE/Makefile.mpi index aebb465454..0155e8b3cb 100644 --- a/src/MAKE/Makefile.mpi +++ b/src/MAKE/Makefile.mpi @@ -28,7 +28,7 @@ SHLIBFLAGS = -shared # LAMMPS ifdef settings # see possible settings in Section 2.2 (step 4) of manual -LMP_INC = -DLAMMPS_GZIP -DLAMMPS_MEMALIGN=64 +LMP_INC = -DLAMMPS_GZIP # MPI library # see discussion in Section 2.2 (step 5) of manual diff --git a/src/MAKE/Makefile.serial b/src/MAKE/Makefile.serial index 5954d97761..957bff85ff 100644 --- a/src/MAKE/Makefile.serial +++ b/src/MAKE/Makefile.serial @@ -28,7 +28,7 @@ SHLIBFLAGS = -shared # LAMMPS ifdef settings # see possible settings in Section 2.2 (step 4) of manual -LMP_INC = -DLAMMPS_GZIP -DLAMMPS_MEMALIGN=64 +LMP_INC = -DLAMMPS_GZIP # MPI library # see discussion in Section 2.2 (step 5) of manual From ce62c41252f61751a65a56b8ded8f0a93fd3441d Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 10 Aug 2017 06:47:26 -0400 Subject: [PATCH 2/8] when recomputing special bonds, make certain we do not shrink atom->maxspecial and add force->special_extra only once --- src/special.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/special.cpp b/src/special.cpp index 4697fc40a6..381a763dd2 100644 --- a/src/special.cpp +++ b/src/special.cpp @@ -561,7 +561,13 @@ void Special::combine() for (j = 0; j < nspecial[i][2]; j++) atom->map_one(onefour[i][j],-1); } - // compute global maxspecial, must be at least 1 + // if atom->maxspecial has been updated before, make certain + // we do not reset it to a smaller value. Since atom->maxspecial + // is initialized to 1, this ensures that it is larger than zero. + + maxspecial = MAX(atom->maxspecial,maxspecial); + + // compute global maxspecial // add in extra factor from special_bonds command // allocate correct special array with same nmax, new maxspecial // previously allocated one must be destroyed @@ -569,7 +575,10 @@ void Special::combine() MPI_Allreduce(&maxspecial,&atom->maxspecial,1,MPI_INT,MPI_MAX,world); atom->maxspecial += force->special_extra; - atom->maxspecial = MAX(atom->maxspecial,1); + + // add force->special_extra only once + + force->special_extra = 0; if (me == 0) { if (screen) From 0dc3cbaa8accbb64c0a8ca74a9b34048f0dd8f82 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 10 Aug 2017 06:51:57 -0400 Subject: [PATCH 3/8] Revert "remove -DLAMMPS_MEMALIGN from "make mpi" and "make serial" for increased portability" This reverts commit 4e97b575087377e8b74e4b0ac8f3a36fc9477d95. --- src/MAKE/Makefile.mpi | 2 +- src/MAKE/Makefile.serial | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MAKE/Makefile.mpi b/src/MAKE/Makefile.mpi index 0155e8b3cb..aebb465454 100644 --- a/src/MAKE/Makefile.mpi +++ b/src/MAKE/Makefile.mpi @@ -28,7 +28,7 @@ SHLIBFLAGS = -shared # LAMMPS ifdef settings # see possible settings in Section 2.2 (step 4) of manual -LMP_INC = -DLAMMPS_GZIP +LMP_INC = -DLAMMPS_GZIP -DLAMMPS_MEMALIGN=64 # MPI library # see discussion in Section 2.2 (step 5) of manual diff --git a/src/MAKE/Makefile.serial b/src/MAKE/Makefile.serial index 957bff85ff..5954d97761 100644 --- a/src/MAKE/Makefile.serial +++ b/src/MAKE/Makefile.serial @@ -28,7 +28,7 @@ SHLIBFLAGS = -shared # LAMMPS ifdef settings # see possible settings in Section 2.2 (step 4) of manual -LMP_INC = -DLAMMPS_GZIP +LMP_INC = -DLAMMPS_GZIP -DLAMMPS_MEMALIGN=64 # MPI library # see discussion in Section 2.2 (step 5) of manual From 5b557442093c811f32e347a6cde9361a809a3b23 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 10 Aug 2017 07:21:39 -0400 Subject: [PATCH 4/8] fix a header line formatting issue --- doc/src/Section_start.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/src/Section_start.txt b/doc/src/Section_start.txt index 53a36b8c22..714ef0a898 100644 --- a/doc/src/Section_start.txt +++ b/doc/src/Section_start.txt @@ -587,8 +587,7 @@ Typing "make clean-all" or "make clean-machine" will delete *.o object files created when LAMMPS is built, for either all builds or for a particular machine. -Changing the LAMMPS size limits via -DLAMMPS_SMALLBIG or --DLAMMPS_BIGBIG or -DLAMMPS_SMALLSMALL :h6 +Changing the LAMMPS size limits via -DLAMMPS_SMALLBIG or -DLAMMPS_BIGBIG or -DLAMMPS_SMALLSMALL :h6 As explained above, any of these 3 settings can be specified on the LMP_INC line in your low-level src/MAKE/Makefile.foo. From f9a515efd37dc3515b6cddc4a00c645bce40f8a5 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 10 Aug 2017 07:24:24 -0400 Subject: [PATCH 5/8] add some remarks about makefile settings on windows --- doc/src/Section_start.txt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/doc/src/Section_start.txt b/doc/src/Section_start.txt index 714ef0a898..6eef155be2 100644 --- a/doc/src/Section_start.txt +++ b/doc/src/Section_start.txt @@ -658,7 +658,16 @@ utilities. For Cygwin and the MinGW cross-compilers, suitable makefiles are provided in src/MAKE/MACHINES. When using other compilers, like Visual C++ or Intel compilers for Windows, you may have to implement -your own build system. Since none of the current LAMMPS core developers +your own build system. Due to differences between the Windows OS +and Windows system libraries to Unix-like environments like Linux +or MacOS, when compiling for Windows a few adjustments may be needed: + +Do not set the -DLAMMPS_MEMALIGN define (see LMP_INC makefile variable) +Add -lwsock32 -lpsapi to the linker flags (see LIB makefile variable) +Try adding -static-libgcc or -static or both to the linker flags when your +LAMMPS executable complains about missing .dll files :ul + +Since none of the current LAMMPS core developers has significant experience building executables on Windows, we are happy to distribute contributed instructions and modifications, but we cannot provide support for those. From 2bc6ad80d404583d70a47a879e2dd72afa1f35a9 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 10 Aug 2017 07:45:21 -0400 Subject: [PATCH 6/8] avoid writable string and deprecated implicit conversion warning --- lib/poems/poemsobject.cpp | 4 ++-- lib/poems/poemsobject.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/poems/poemsobject.cpp b/lib/poems/poemsobject.cpp index 4a5f903fca..7c3f1ca872 100644 --- a/lib/poems/poemsobject.cpp +++ b/lib/poems/poemsobject.cpp @@ -21,7 +21,7 @@ POEMSObject::POEMSObject(){ name = 0; - ChangeName("unnamed"); + ChangeName((const char*)"unnamed"); ID = -1; } @@ -29,7 +29,7 @@ POEMSObject::~POEMSObject(){ delete [] name; } -void POEMSObject::ChangeName(char* newname){ +void POEMSObject::ChangeName(const char* newname){ delete [] name; name = new char[strlen(newname)+1]; strcpy(name,newname); diff --git a/lib/poems/poemsobject.h b/lib/poems/poemsobject.h index d898ab3c66..63b2915638 100644 --- a/lib/poems/poemsobject.h +++ b/lib/poems/poemsobject.h @@ -26,7 +26,7 @@ class POEMSObject { public: POEMSObject(); virtual ~POEMSObject(); - void ChangeName(char* newname); + void ChangeName(const char* newname); char* GetName(); int GetID(); void SetID(int id); From 2f3747eb6e6cc4978587ed36e017791d48bea35b Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 10 Aug 2017 08:34:46 -0400 Subject: [PATCH 7/8] we need to override compiler flags in lib/voronoi/Install.py The default compiler flags in voro++'s config.mk file do not include -fPIC, which makes it incompatible with building the shared object for the python wrapper. --- lib/voronoi/Install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/voronoi/Install.py b/lib/voronoi/Install.py index 5a246bbeb1..a4d07ac745 100644 --- a/lib/voronoi/Install.py +++ b/lib/voronoi/Install.py @@ -116,7 +116,7 @@ if buildflag: if buildflag: print("Building Voro++ ...") - cmd = 'cd "%s"; make' % homedir + cmd = 'cd "%s"; make CXX=g++ CFLAGS="-fPIC -O3"' % homedir txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) print(txt.decode('UTF-8')) From 146aa4cdbdd3e83a859c1f1f02959904913695bc Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 10 Aug 2017 09:05:23 -0400 Subject: [PATCH 8/8] fall back to wget when curl is not available --- lib/kim/Install.py | 23 ++++++++++++++++++++++- lib/mscg/Install.py | 23 ++++++++++++++++++++++- lib/smd/Install.py | 23 ++++++++++++++++++++++- lib/voronoi/Install.py | 23 ++++++++++++++++++++++- 4 files changed, 88 insertions(+), 4 deletions(-) diff --git a/lib/kim/Install.py b/lib/kim/Install.py index 06479d2d4d..21ea859852 100644 --- a/lib/kim/Install.py +++ b/lib/kim/Install.py @@ -60,8 +60,29 @@ def error(str=None): def fullpath(path): return os.path.abspath(os.path.expanduser(path)) +def which(program): + def is_exe(fpath): + return os.path.isfile(fpath) and os.access(fpath, os.X_OK) + + fpath, fname = os.path.split(program) + if fpath: + if is_exe(program): + return program + else: + for path in os.environ["PATH"].split(os.pathsep): + path = path.strip('"') + exe_file = os.path.join(path, program) + if is_exe(exe_file): + return exe_file + + return None + def geturl(url,fname): - cmd = 'curl -L -o "%s" %s' % (fname,url) + if which('curl') != None: + cmd = 'curl -L -o "%s" %s' % (fname,url) + elif which('wget') != None: + cmd = 'wget -O "%s" %s' % (fname,url) + else: error("cannot find 'wget' or 'curl' to download source code") txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) return txt diff --git a/lib/mscg/Install.py b/lib/mscg/Install.py index e4e5ec5613..154f5aa522 100644 --- a/lib/mscg/Install.py +++ b/lib/mscg/Install.py @@ -47,8 +47,29 @@ def error(str=None): def fullpath(path): return os.path.abspath(os.path.expanduser(path)) +def which(program): + def is_exe(fpath): + return os.path.isfile(fpath) and os.access(fpath, os.X_OK) + + fpath, fname = os.path.split(program) + if fpath: + if is_exe(program): + return program + else: + for path in os.environ["PATH"].split(os.pathsep): + path = path.strip('"') + exe_file = os.path.join(path, program) + if is_exe(exe_file): + return exe_file + + return None + def geturl(url,fname): - cmd = 'curl -L -o "%s" %s' % (fname,url) + if which('curl') != None: + cmd = 'curl -L -o "%s" %s' % (fname,url) + elif which('wget') != None: + cmd = 'wget -O "%s" %s' % (fname,url) + else: error("cannot find 'wget' or 'curl' to download source code") txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) return txt diff --git a/lib/smd/Install.py b/lib/smd/Install.py index 1c270bea5e..00891339d0 100644 --- a/lib/smd/Install.py +++ b/lib/smd/Install.py @@ -47,8 +47,29 @@ def error(str=None): def fullpath(path): return os.path.abspath(os.path.expanduser(path)) +def which(program): + def is_exe(fpath): + return os.path.isfile(fpath) and os.access(fpath, os.X_OK) + + fpath, fname = os.path.split(program) + if fpath: + if is_exe(program): + return program + else: + for path in os.environ["PATH"].split(os.pathsep): + path = path.strip('"') + exe_file = os.path.join(path, program) + if is_exe(exe_file): + return exe_file + + return None + def geturl(url,fname): - cmd = 'curl -L -o "%s" %s' % (fname,url) + if which('curl') != None: + cmd = 'curl -L -o "%s" %s' % (fname,url) + elif which('wget') != None: + cmd = 'wget -O "%s" %s' % (fname,url) + else: error("cannot find 'wget' or 'curl' to download source code") txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) return txt diff --git a/lib/voronoi/Install.py b/lib/voronoi/Install.py index a4d07ac745..4998358d27 100644 --- a/lib/voronoi/Install.py +++ b/lib/voronoi/Install.py @@ -46,8 +46,29 @@ def error(str=None): def fullpath(path): return os.path.abspath(os.path.expanduser(path)) +def which(program): + def is_exe(fpath): + return os.path.isfile(fpath) and os.access(fpath, os.X_OK) + + fpath, fname = os.path.split(program) + if fpath: + if is_exe(program): + return program + else: + for path in os.environ["PATH"].split(os.pathsep): + path = path.strip('"') + exe_file = os.path.join(path, program) + if is_exe(exe_file): + return exe_file + + return None + def geturl(url,fname): - cmd = 'curl -L -o "%s" %s' % (fname,url) + if which('curl') != None: + cmd = 'curl -L -o "%s" %s' % (fname,url) + elif which('wget') != None: + cmd = 'wget -O "%s" %s' % (fname,url) + else: error("cannot find 'wget' or 'curl' to download source code") txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) return txt