PhreeqcUsers Discussion Forum

PHREEQC installation => Installing => Topic started by: hjung on June 05, 2018, 06:57:29 PM

Title: PhreeqcRM MPI compilation
Post by: hjung on June 05, 2018, 06:57:29 PM
Hi all,

I'm trying to use phreeqcrm with a mpi compiler on a cluster with the following conditions but having the problem that is terminated by the error

error: undefined reference to 'PhreeqcRM::PhreeqcRM(int, int, PHRQ_io*)'
collect2: error: ld returned 1 exit status

which is invoked by calling the constructor PhreeqcRM.

Can anyone give me some suggestions to solve this problem?
I posted a similar issue about compiling phreeqcm on a mac (http://phreeqcusers.org/index.php/topic,1011.0.html) and it was solved by installing llvm.

I'm using the following conditions in a cluster.

Description:   CentOS Linux release 7.1.1503 (Core)
OpenMPI/3.0.0-GCC-7.2.0-2.29
LLVM/6.0.0-GCCcore-7.2.0

PhreeqcRM is compiled with the followings.

configure (--prefix=$HOME/local)
*************************************
Summary:
C++ Compiler                 = mpicxx
CPPFLAGS                     =
CXXFLAGS                     = -g -O2
Fortran Compiler             =
Fortran Libs                 =
LDFLAGS                      =
Enable OpenMP                = no
Enable MPI                   = yes
*************************************

make check
PASS: test
============================================================================
Testsuite summary for PhreeqcRM 3.4.0-12927
============================================================================
# TOTAL: 1
# PASS:  1
# SKIP:  0
# XFAIL: 0
# FAIL:  0
# XPASS: 0
# ERROR: 0
============================================================================

but the problem occurs when the installed library is called from a transport code.

Any help will be greatly appreciated.

Best,
hjung
Title: Re: PhreeqcRM MPI compilation
Post by: dlparkhurst on June 05, 2018, 07:28:59 PM
Looks like you may need to add the library (-l) and the library path (-L) to the Makefile? you are using to compile your transport code. I don't think the library has been found.

The library passed its check of the library compilation.
Title: Re: PhreeqcRM MPI compilation
Post by: hjung on June 05, 2018, 08:22:28 PM
Dear Dr. Parkhurst,

Thanks so much for your help so many times.

I have added the library path but it is still not linking the library for some reason.
The problem in linking also happened on my local machine (mac) but installing llvm somehow solved the issue. But using llvm no longer solve the problem for mpi.

this is the command that is invoking the erro

mpicxx -o biomorph3D biomorph3D.o /home/hj28939/palabos-v2.0r0/lib/libplb_mpi.a -L/home/hj28939/local/lib -lphreeqcrm

I'm attaching the makefile I'm using. I'm trying to couple lattice boltzmann transport code (palabos) to phreeqcrm.

##########################################################################
palabosRoot  = /home/hj28939/palabos-v2.0r0
projectFiles = biomorph3D.cpp

optimize     = true
debug        = false
profile      = false
MPIparallel  = true
SMPparallel  = false
usePOSIX     = true

# Path to external source files
srcPaths =
# Path to external libraries
libraryPaths = /home/hj28939/local/lib/
# Path to inlude directories
includePaths = /home/hj28939/local/include/
# Dynamic and static libraries
libraries    = phreeqcrm

serialCXX    = g++
parallelCXX  = mpicxx
compileFlags = -Wall -Wnon-virtual-dtor -Wno-deprecated-declarations
linkFlags    =
# Compiler flags to use when optimization mode is on
optimFlags   = -O3
# Compiler flags to use when debug mode is on
debugFlags   = -g
# Compiler flags to use when profile mode is on
profileFlags = -pg

##########################################################################

SCons     = $(palabosRoot)/scons/scons.py -j 6 -f $(palabosRoot)/SConstruct

SConsArgs = palabosRoot=$(palabosRoot) \
            projectFiles="$(projectFiles)" \
            optimize=$(optimize) \
            debug=$(debug) \
            profile=$(profile) \
            MPIparallel=$(MPIparallel) \
            SMPparallel=$(SMPparallel) \
            usePOSIX=$(usePOSIX) \
            serialCXX=$(serialCXX) \
            parallelCXX=$(parallelCXX) \
            compileFlags="$(compileFlags)" \
            linkFlags="$(linkFlags)" \
            optimFlags="$(optimFlags)" \
            debugFlags="$(debugFlags)" \
            profileFlags="$(profileFlags)" \
            srcPaths="$(srcPaths)" \
            libraryPaths="$(libraryPaths)" \
            includePaths="$(includePaths)" \
            libraries="$(libraries)"

compile:
   python $(SCons) $(SConsArgs)

clean:
   python $(SCons) -c $(SConsArgs)
   /bin/rm -vf `find $(palabosRoot) -name '*~'`
Title: Re: PhreeqcRM MPI compilation
Post by: dlparkhurst on June 06, 2018, 12:30:57 AM
Have you read the README file distributed with PhreeqcRM? Look at sections D.7 and F.

Perhaps you are missing the include files (-I and -i) in you Makefile.
Title: Re: PhreeqcRM MPI compilation
Post by: dksliusiyan on August 28, 2018, 05:06:27 PM
Hi all,

I'm trying to use phreeqcrm with a mpi compiler on a cluster with the following conditions but having the problem that is terminated by the error

error: undefined reference to 'PhreeqcRM::PhreeqcRM(int, int, PHRQ_io*)'
collect2: error: ld returned 1 exit status

which is invoked by calling the constructor PhreeqcRM.

Can anyone give me some suggestions to solve this problem?
I posted a similar issue about compiling phreeqcm on a mac (http://phreeqcusers.org/index.php/topic,1011.0.html) and it was solved by installing llvm.

I'm using the following conditions in a cluster.

Description:   CentOS Linux release 7.1.1503 (Core)
OpenMPI/3.0.0-GCC-7.2.0-2.29
LLVM/6.0.0-GCCcore-7.2.0

PhreeqcRM is compiled with the followings.

configure (--prefix=$HOME/local)
*************************************
Summary:
C++ Compiler                 = mpicxx
CPPFLAGS                     =
CXXFLAGS                     = -g -O2
Fortran Compiler             =
Fortran Libs                 =
LDFLAGS                      =
Enable OpenMP                = no
Enable MPI                   = yes
*************************************

make check
PASS: test
============================================================================
Testsuite summary for PhreeqcRM 3.4.0-12927
============================================================================
# TOTAL: 1
# PASS:  1
# SKIP:  0
# XFAIL: 0
# FAIL:  0
# XPASS: 0
# ERROR: 0
============================================================================

but the problem occurs when the installed library is called from a transport code.

Any help will be greatly appreciated.

Best,
hjung

Hi hjung,

Have you solved the compilation issue? I have the issue exact same with you, everything was OK when I compiled them in OpenMP version, but when I switch to MPI, it was not working. Do you or anybody has any ideas about this? Thanks!

Siyan

BTW: I'm using Ubuntu 16.04 LTS with g++/mpic++ 6.4.0
Title: Re: PhreeqcRM MPI compilation
Post by: dlparkhurst on August 28, 2018, 06:22:20 PM
The directions for compiling, installing, and linking the PhreeqcRM library are given in doc/README.TXT of the distribution (attached here for convenience).

Remember you must set an option to test the Fortran interface (although it does not affect the library). If, as Hjung, the tests passed, the the library has been compiled properly. You still may need to install the library in a place of your choosing, which also installs the include files necessary for compiling your transport code.

Finally, you need to follow the directions to compile your transport code and link it to the PhreeqcRM library. Again, directions are in the attached file. If you are getting a message for an undefined reference (that looks like a PhreeqcRM method), then you have not successfully linked the library.
Title: Re: PhreeqcRM MPI compilation
Post by: dksliusiyan on September 20, 2018, 05:56:08 PM
Dear Dr. Parkhurst,

Thanks for your reply!

I again tried compiled the PhreeqcRM in OpenMP mode and successfully executed the built-in test example, also I tried to compile the coupled code(couple to flow solver) by linking 'libphreeqcrm.a, libphreeqcrm.so, phreeqcrm.la' and including the compiled header files, the coupled code was running well but only in OpenMP mode.

So I followed the same procedures to compile PhreeqcRM in MPI mode and try to do the same tests, libraries compilation was OK and also passed the 'make test' step:

*************************************
Summary:
C++ Compiler                 = mpic++
CPPFLAGS                     =
CXXFLAGS                     = -g -O3
Fortran Compiler             =
Fortran Libs                 =
LDFLAGS                      =
Enable OpenMP                = no
Enable MPI                   = yes
*************************************

PASS: test
============================================================================
Testsuite summary for PhreeqcRM 3.4.0-12927
============================================================================
# TOTAL: 1
# PASS:  1
# SKIP:  0
# XFAIL: 0
# FAIL:  0
# XPASS: 0
# ERROR: 0
============================================================================

when I was trying to compile the built-in test case (/phreeqcrm-3.4.0-12927/Tests), it failed:

phreeqcrm-3.4.0-12927/Tests$ cmake CMakeLists.txt
-- The CXX compiler identification is GNU 7.3.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning (dev) in CMakeLists.txt:
  No cmake_minimum_required command is present.  A line of code such as

    cmake_minimum_required(VERSION 3.11)

  should be added at the top of the file.  The version specified may be lower
  if you wish to support older CMake versions for this project.  For more
  information run "cmake --help-policy CMP0000".
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring done
-- Generating done
-- Build files have been written to: /media/siyan/data_disk/cloud/PhreeqcRM_related/MPI_test/phreeqcrm-3.4.0-12927/Tests

***************************** PhreeqcRM ***********************************************

siyan@siyan-workstation:/media/siyan/data_disk/cloud/PhreeqcRM_related/MPI_test/phreeqcrm-3.4.0-12927/Tests$ make
Scanning dependencies of target TestRM
[ 25%] Building CXX object CMakeFiles/TestRM.dir/advection_cpp.o
[ 50%] Building CXX object CMakeFiles/TestRM.dir/main.o
[ 75%] Building CXX object CMakeFiles/TestRM.dir/species_cpp.o
[100%] Linking CXX executable TestRM
CMakeFiles/TestRM.dir/advection_cpp.o: In function `advection_cpp()':
advection_cpp.cpp:(.text+0xba): undefined reference to `PhreeqcRM::PhreeqcRM(int, int, PHRQ_io*)'
CMakeFiles/TestRM.dir/advection_cpp.o: In function `units_tester()':
advection_cpp.cpp:(.text+0x2de6): undefined reference to `PhreeqcRM::PhreeqcRM(int, int, PHRQ_io*)'
CMakeFiles/TestRM.dir/main.o: In function `main':
main.cpp:(.text+0x28): undefined reference to `advection_c'
main.cpp:(.text+0x32): undefined reference to `species_c'
CMakeFiles/TestRM.dir/species_cpp.o: In function `species_cpp()':
species_cpp.cpp:(.text+0x4f): undefined reference to `PhreeqcRM::PhreeqcRM(int, int, PHRQ_io*)'
collect2: error: ld returned 1 exit status
CMakeFiles/TestRM.dir/build.make:113: recipe for target 'TestRM' failed
make[2]: *** [TestRM] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/TestRM.dir/all' failed
make[1]: *** [CMakeFiles/TestRM.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

I tried my coupled code, it failed again(I do have the -L /usr/local/lib -lphreeqcrm added as compilation flag):

siyan@siyan-workstation:/media/siyan/data_disk/cloud/palabos_tests/palabos-v2.0r0/scons_palabos_phreeqcrm_compiling_test$ make
python2 ../../../../../scons/scons.py -j 10 -f ../../../../../SConstruct palabosRoot=../../../../.. projectFiles="good_diff_demo_poiseuille_porous.cpp" optimize=true debug=false profile=false MPIparallel=true SMPparallel=false usePOSIX=true serialCXX=g++ parallelCXX=mpicxx compileFlags="-Wall -Wnon-virtual-dtor -Wno-deprecated-declarations" linkFlags="" optimFlags="-O3" debugFlags="-g" profileFlags="-pg" srcPaths="" libraryPaths="/usr/local/lib " includePaths="/media/siyan/data_disk/cloud/palabos_tests/palabos-v2.0r0/scons_palabos_phreeqcrm_compiling_test/test_includes" libraries="-lphreeqcrm" 
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
mpicxx -o good_diff_demo_poiseuille_porous good_diff_demo_poiseuille_porous.o /media/siyan/data_disk/cloud/palabos_tests/palabos-v2.0r0/lib/libplb_mpi.a -L/usr/local/lib -lphreeqcrm
good_diff_demo_poiseuille_porous.o: In function `phreeqcrm_advection_cpp_test()':
good_diff_demo_poiseuille_porous.cpp:(.text+0xbac): undefined reference to `PhreeqcRM::PhreeqcRM(int, int, PHRQ_io*)'
collect2: error: ld returned 1 exit status
scons: *** [good_diff_demo_poiseuille_porous] Error 1
scons: building terminated because of errors.
Makefile:92: recipe for target 'compile' failed
make: *** [compile] Error 2

Seems like the MPI version of libraries are not linked, or there were some other issues. I don't know what happened, do you have any ideas? Thank you!

Siyan








Title: Re: PhreeqcRM MPI compilation
Post by: dlparkhurst on September 20, 2018, 07:26:42 PM
You are pretty much on your own for figuring out how to compile and link your code. Every system is different, and I now longer have easy access to a Linux computer.

The test case appeared to work, which means the library is compiled and working, but your compilation gets the message

undefined reference to `PhreeqcRM::PhreeqcRM(int, int, PHRQ_io*)'

Clearly, you are not linking the library correctly.

In addition, for the example advection, I think you are not including all of the necessary source files: advection_c.c and species_c.c.