easybuilders / easybuild-easyblocks

Collection of easyblocks that implement support for building and installing software with EasyBuild.
https://easybuild.io
GNU General Public License v2.0
104 stars 284 forks source link

GROMACS: Get libraries used by a dependency in easyblock #2587

Open jmbuhr opened 3 years ago

jmbuhr commented 3 years ago

I am attempting to configure the easyblock for gromacs (https://github.com/easybuilders/easybuild-easyblocks/blob/11870c2e93df143587b842cb93524f848418086c/easybuild/easyblocks/g/gromacs.py) with support for the QM/MM integration that is currently in the works on this branch: https://gitlab.com/gromacs/gromacs/-/tree/2021.2-qmmm

The installation instructions mention that it needs to be configured to know about the libraries used by the QM/MM engine (cp2k): https://gitlab.com/gromacs/gromacs/-/blob/2021.2-qmmm/INSTALL-dev#L44

Other libraries used by CP2K. Typically that should be combination of LDFLAGS and LIBS from the ARCH file used for libcp2k compilation.
An exmaple for CP2K compiled with: OpenMPI, OpenBLAS, Netlib-SCALAPACK, fftw3, libxsmm, libint and libxc:
-DCP2K_LIBS="-Wl,--enable-new-dtags -pthread -L/usr/lib64 -L/appl/spack/v014/install-tree/gcc-9.3.0/openmpi-4.0.3-ddb3ro/lib -L'/appl/spack/v014/install-tree/gcc-9.3.0/openblas-0.3.10-72fp3r/lib' -L'/appl/spack/v014/install-tree/gcc-9.3.0/fftw-3.3.8-aqjlqz/lib' -L'/appl/spack/gromacs_cp2k/cp2k/tools/toolchain/install/libint-v2.6.0-cp2k-lmax-5/lib' -L'/appl/spack/gromacs_cp2k/cp2k/tools/toolchain/install/libxc-4.3.4/lib' -L'/appl/spack/gromacs_cp2k/cp2k/tools/toolchain/install/libxsmm-1.16.1/lib' -L'/appl/spack/v014/install-tree/gcc-9.3.0/netlib-scalapack-2.1.0-his6fu/lib' -lscalapack -lxsmmf -lxsmm -ldl -lpthread -lxcf03 -lxc -lint2 -lfftw3_mpi -lfftw3 -lfftw3_omp -lmpi -lopenblas -lstdc++"

I have successfully added the cp2k library directory if cp2k is a dependency in the configure step, but how do I correctly use the libraries as specified by the cp2k module that is the dependency? After all, I should probably not hardcode these.

        cp2k = get_software_root('CP2K')
        if cp2k:
            self.cfg.update('configopts', '-DGMX_CP2K=ON')
            self.cfg.update('configopts', '-DCP2K_DIR=%s/lib' % cp2k)
            self.cfg.update('configopts', '-DCP2K_LIBS=<.......?>')
jmbuhr commented 3 years ago

I got it to compile (well it is still compiling, so we will see) with

        # add suport for QMMM engines the starting from <https://gitlab.com/gromacs/gromacs/-/tree/2021.2-qmmm>
        cp2k = get_software_root('CP2K')
        if cp2k:
            self.cfg.update('configopts', '-DGMX_CP2K=ON')
            self.cfg.update('configopts', '-DCP2K_DIR=%s/lib' % cp2k)

            libs_config = '-DCP2K_LIBS=Wl,--enable-new-dtags'
            libs_config += ' -lscalapack -lxsmmf -lxsmm -ldl -lpthread -lxcf03 -lxc -lint2 -lfftw3_mpi -lfftw3 -lfftw3_omp -lmpi -lopenblas -lstdc++ -pthread'
            libs_config += ' -L/usr/lib64'

            cp2k_libs = ['OpenMPI', 'OpenBLAS', 'FFTW', 'Libint', 'libxc', 'libxsmm', 'ScaLAPACK']
            lib_paths = {key: get_software_root(key) for key in cp2k_libs}
            for lib in cp2k_libs:
                libs_config += ' -L%s/lib' % lib_paths[lib]

            self.cfg.update('configopts', libs_config)

but I still hardcoded the cp2k dependencies, so I would very happy about a more easybuild-ideomatic approach :)

akesandgren commented 3 years ago

The best approach is likely to make sure that cp2klib is dynamic, then you won't need more than a -lcp2k there...