SSAGESproject / SSAGES

Software Suite for Advanced General Ensemble Simulations
GNU General Public License v3.0
81 stars 28 forks source link

SSAGES with lammps_22Aug2018 | Opt package issues && #39

Closed kaustubhjsawant closed 2 years ago

kaustubhjsawant commented 2 years ago

Hello,

I am tryting to compile ssages with lammps_22Aug2018. However, I am not able to install with the opt package with intel compilers. The opt package has some issues with intel compilers and requires -restrict tag ( https://github.com/lammps/lammps/issues/610 ). I am not well versed with cmake but can someone help to figure out that the right makefile is being used to build lammps ? Just to clarify, I can build lammps standalone but ssages cant.

Error Message:

[ 93%] Performing build step for 'lammps'
Gathering installed package information (may take a little while)
Compiling LAMMPS for machine mpi
../pair_morse_opt.cpp(71): error: expected a ";"
    double** _noalias x = atom->x;
                      ^
../pair_morse_opt.cpp(72): error: "restrict" has already been declared in the current scope
    double** _noalias f = atom->f;

Thank you, Kaustubh

mquevill commented 2 years ago

Yes, it needs the -restrict flag for proper compilation.

You can add the flag manually if you will be using Intel compilers.

diff --git a/hooks/lammps/CMakeLists.txt b/hooks/lammps/CMakeLists.txt
index dcc9998..c080a4f 100644
--- a/hooks/lammps/CMakeLists.txt
+++ b/hooks/lammps/CMakeLists.txt
@@ -187,6 +187,7 @@ ExternalProject_Add(
     CCFLAGS+=-I${PROJECT_SOURCE_DIR}/include
     CCFLAGS+=-std=c++11
     CCFLAGS+=-O3
+    CCFLAGS+=-restrict
     LIB+=$<TARGET_FILE:libssages>
     INSTALL_COMMAND ""
     BUILD_IN_SOURCE true

A more robust change would be something like this, that checks for Intel compilers and adds the flags if necessary.

@@ -176,6 +176,10 @@ foreach (PACKAGE ${LAMMPS_PACKAGES})
     add_custom_target (no-${PACKAGE} $(MAKE) -C ${LAMMPS_SRC} no-${PACKAGE})
 endforeach (PACKAGE ${LAMMPS_PACKAGES})

+if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
+    set(INTEL_FLAGS "CCFLAGS+=-restrict")
+endif ()
+
 # Add lammps as external project
 ExternalProject_Add(
     lammps
@@ -187,6 +191,7 @@ ExternalProject_Add(
     CCFLAGS+=-I${PROJECT_SOURCE_DIR}/include
     CCFLAGS+=-std=c++11
     CCFLAGS+=-O3
+    ${INTEL_FLAGS}
     LIB+=$<TARGET_FILE:libssages>
     INSTALL_COMMAND ""
     BUILD_IN_SOURCE true
kaustubhjsawant commented 2 years ago

Thank you. The fix worked !

Kaustubh