[gmx-users] gromacs/mopac compilation: linking libmopac
Javier Cerezo
jcb1 at um.es
Thu Nov 17 11:15:49 CET 2011
Hi all
I post here the present status of my query in case my findings may be
helpful for someone else. In the case B (using gfortran to compile
libmopac) I have some success building g the gromacs binary for mdrun in
my x86_64 system.
**A
Regarding the compilation with ifort, making test with simple C code I
relized that (at least in my case), it is needed to add some extra intel
libreries during compilation. Concretely I added the mkl libraries
(maybe libm was enough, but just in case) and the additional libraries
libifcore, libifcore_pic, libimf, libifport and libintlc (actually the
two that seem strongly required were libifcore and libintlc). The case
is that libintlc is only available in shared version, so I fist
recompiled my libmopac library with -fPIC flag:
ifort -O2 -fPIC -c *f; ar rcv libmopac.a *.o; ranlib libifmopac.a
In my test C simple program, it was possible to link against the static
libifmopac.a while using other shared libraries (omitting the flag
-static), so I used --enable-shared. The configure script was
subsequently called as follows (with double precision as well):
./configure --prefix
/home/cerezo/Programas/gromacs-4.5.5_with_ifort_mopac/
--program-suffix=_d_ifmopac LDFLAGS="-L/home/cerezo/lib
-L/home/cerezo/lib/fftw/lib -L/usr/share/intel/mkl/lib/intel64
-L/usr/share/intel/lib/intel64" CPPFLAGS="-DUSE_MOPAC
-I/home/cerezo/lib/fftw/include" --with-qmmm-mopac
LIBS="-lmkl_intel_ilp64 -lmkl_core -lmkl_sequential -lifcore
-lifcore_pic -limf -lirc -lifport -lintlc -lifmopac" --disable-threads
--disable-float
LD_LIBRARY_PATH=/usr/share/intel/mkl/lib/intel64:/usr/share/intel/lib/intel64::LD_LIBRARY_PATH
Then
make mdrun -j 4
gave the following error:
cc -O3 -fomit-frame-pointer -finline-functions -Wall -Wno-unused -msse2
-funroll-all-loops -std=gnu99 -fexcess-precision=fast -o .libs/mdrun
gctio.o ionize.o do_gct.o repl_ex.o xutils.o runner.o md.o mdrun.o
genalg.o md_openmm.o -L/home/cerezo/lib -L/home/cerezo/lib/fftw/lib
-L/usr/share/intel/mkl/lib/intel64 -L/usr/share/intel/lib/intel64
./.libs/libgmxpreprocess_d.so
/home/cerezo/Programas/src/GROMACS_vX/gromacs-4.5.5/src/mdlib/.libs/libmd_d.so
../mdlib/.libs/libmd_d.so /home/cerezo/lib/fftw/lib/libfftw3.so
/home/cerezo/Programas/src/GROMACS_vX/gromacs-4.5.5/src/gmxlib/.libs/libgmx_d.so
../gmxlib/.libs/libgmx_d.so -lnsl -lm -lmkl_intel_ilp64 -lmkl_core
-lmkl_sequential -lifcore -lifcore_pic -limf -lirc -lifport -lintlc
-lifmopac -Wl,--rpath
-Wl,/home/cerezo/Programas/gromacs-4.5.5_with_ifort_mopac/lib
-Wl,--rpath -Wl,/home/cerezo/lib/fftw/lib
/home/cerezo/Programas/src/GROMACS_vX/gromacs-4.5.5/src/mdlib/.libs/libmd_d.so:
undefined reference to `__svml_asin2'
/home/cerezo/Programas/src/GROMACS_vX/gromacs-4.5.5/src/mdlib/.libs/libmd_d.so:
undefined reference to `__svml_exp2_mask'
collect2: ld returned 1 exit status
make[1]: *** [mdrun] Error 1
make[1]: se sale del directorio
«/home/cerezo/Programas/src/GROMACS_vX/gromacs-4.5.5/src/kernel»
**B
I succeeded to build gromacs/mopac with gfortran compiled libmopac.
Fisrt I compiled libmopac with:
gfortran -std=legacy -c *.f; ar rcv libmopac.a *.o; ranlib libmopac.a
(I made the necessary changes to remove the warnings and errors, such as
changing the calls to SECOND(1) by SECOND() in polar.f and writmo.f)
In this case, gfortran procedures are simply linked with a single
library: libgfortran, with static version. Thus, I deactivated shared
option in the configure script. Then, the configure script for gromacs
looked like:
./configure --prefix
/home/cerezo/Programas/gromacs-4.5.5_with_gfor_mopac/
--program-suffix=_d_mopac LDFLAGS="-L/home/cerezo/lib
-L/home/cerezo/lib/fftw/lib" CPPFLAGS="-DUSE_MOPAC
-I/home/cerezo/lib/fftw/include" --with-qmmm-mopac LIBS="-lmopac
-lgfortran" --disable-threads --disable-float -disable-shared
make mdrun -j 4
make install-mdrun
All worked correctly. However, I got a segmentation fault when running a
qm/mm calculation, the problem originated at libmopac subroutines.
Actually, the problem is in the subroutine FOCK2 (in fock2.f), at least
in my system compiling with gfortran: GNU Fortran (Ubuntu/Linaro
4.5.2-8ubuntu4) 4.5.2. The work around comes as follows:
In fock2.f:
Line 35: IF(ICALCN.NE.NUMCAL) THEN
[This if loop assures that variable initialization is only made the
fisrt time the main program calls the subroutine. However, in my
gfortran compiled binary, the variables were not saved from calls. So I
capped this loop (is should end at line 89), so that now it looks like:]
Line 35: IF(ICALCN.NE.NUMCAL) THEN
Line 36: ICALCN=NUMCAL
Line 37(new): ENDIF [this was moved from line 89]
And now I could run gromacs/mopac without errors. I guess with another
compiler, this problem will not arise, but at least here is a solution
for (standard?) gfortran in a x86_64 system
Javier
El 10/11/11 14:35, Javier Cerezo escribió:
> Hi all
>
> I am trying to compile gromacs with mopac but I'm experience some
> problems using libmopac.a. I have a x86_64 processor and I'm trying
> with gromacs-4.5.5. I've followed the instructions at the website
> (i.e. to compile libmopac.a, I've used the alternte dcart.f and
> gmxmop.f) but I didn't succeed. I've also seen that this topic have
> some times appeared in the mailing list but the trick proposed didn't
> work for me.
>
> Here you have the steps with different scenarios I've gone through:
>
> **A: Compilation of libmopac.a with fortran compiler then gromacs
> installation**
>
> [ in mopac fortran folder]
> javier at mopac/fortran/folder> $FC -O2 -c *.f (where FC=gfortran
> or ifort)
> javier at mopac/fortran/folder> ar rcv libmopac.a *.o;ranlib libmopac.a
> javier at mopac/fortran/folder> cp libmopac.a ~/lib/
>
> [in gromacs folder]
> javier at gromacs/folder> ./configure --prefix
> /home/cerezo/Programas/gromacs-4.5.5_with_mopac/ --with-qmmm-mopac
> --without-qmmm-gaussian --disable-threads --disable-shared
> LDFLAGS="-L/home/cerezo/lib" CPPFLAGS="-DUSE_MOPAC" LIBS="-lmopac"
> javier at gromacs/folder> make -j 4
>
> Then I get lots of "undefined reference" errors:
> cc -O3 -fomit-frame-pointer -finline-functions -Wall -Wno-unused
> -msse2 -funroll-all-loops -std=gnu99 -fexcess-precision=fast -o
> tpbconv tpbconv.o -L/home/cerezo/lib ./.libs/libgmxpreprocess.a
> /home/cerezo/Programas/src/GROMACS_vX/gromacs-4.5.5/src/mdlib/.libs/libmd.a
> ../mdlib/.libs/libmd.a -lfftw3f
> /home/cerezo/Programas/src/GROMACS_vX/gromacs-4.5.5/src/gmxlib/.libs/libgmx.a
> ../gmxlib/.libs/libgmx.a -ldl -lnsl -lm -lmopac
> /bin/bash ../../libtool --tag=CC --mode=link cc -O3
> -fomit-frame-pointer -finline-functions -Wall -Wno-unused -msse2
> -funroll-all-loops -std=gnu99 -fexcess-precision=fast
> -L/home/cerezo/lib -o g_protonate g_protonate.o libgmxpreprocess.la
> ../mdlib/libmd.la ../gmxlib/libgmx.la -lnsl -lm -lmopac
> /bin/bash ../../libtool --tag=CC --mode=link cc -O3
> -fomit-frame-pointer -finline-functions -Wall -Wno-unused -msse2
> -funroll-all-loops -std=gnu99 -fexcess-precision=fast
> -L/home/cerezo/lib -o g_luck g_luck.o libgmxpreprocess.la
> ../mdlib/libmd.la ../gmxlib/libgmx.la -lnsl -lm -lmopac
> /home/cerezo/lib/libmopac.a(gmxmop.o): In function `donhco_':
> gmxmop.f:(.text+0x23e): undefined reference to `for_f90_index'
> gmxmop.f:(.text+0x26c): undefined reference to `for_f90_index'
> gmxmop.f:(.text+0x298): undefined reference to `for_f90_index'
> ...
> /home/cerezo/lib/libmopac.a(gmxmop.o): In function `deriv_':
> gmxmop.f:(.text+0x792): undefined reference to `for_f90_index'
> gmxmop.f:(.text+0x7c0): undefined reference to `for_f90_index'
> gmxmop.f:(.text+0x7e1): undefined reference to `for_f90_index'
> /home/javier/lib/libmopac.a(timer.o)(.text+0x11d): In function `timer_':
> : undefined reference to `for_write_seq_fmt'
> ... (an so on for each mopac object)
>
> Where I think these refer to internal intel fortran functions
> (compilation with ifort, analogous errors come with gfortran internal
> functions). So probably I'm missing something to include this function
> at gromacs compilation time
>
> ---
>
> **B: Compilation of libmopac.a with f2c+gcc then gromacs installation**
> javier at mopac/fortran/folder> f2c *.f
> javier at mopac/fortran/folder> gcc -O2 -c *.c
> javier at mopac/fortran/folder> ar rcv libmopac.a *.o;ranlib libmopac.a
> javier at mopac/fortran/folder> cp libmopac.a ~/lib
>
> [in gromacs folder]
> javier at gromacs/folder> ./configure --prefix
> /home/cerezo/Programas/gromacs-4.5.5_with_mopac/ --with-qmmm-mopac
> --without-qmmm-gaussian --disable-threads --disable-shared
> LDFLAGS="-L/home/cerezo/lib" CPPFLAGS="-DUSE_MOPAC" LIBS="-lmopac"
> javier at gromacs/folder> make -j 4
>
> This time I also get "undefined reference errors", but related to f2c
> funtions:
> +timout.c0x105:)(:. textundefined+ 0x3c8reference) :to undefined`
> do_fioreference'
> totimer.c :`(do_fio.'text
>
> In this case, do I need to include the f2c.h file somewhere in the
> gromacs qmmm interface code?
>
> Could someone point me out where I'm mistaking and what should I do to
> complete the installation?
>
> Thanks
>
> Javier
>
>
--
Javier CEREZO BASTIDA
PhD Student
Physical Chemistry
Universidad de Murcia
Murcia (Spain)
Tlf.(+34)868887434
More information about the gromacs.org_gmx-users
mailing list