[Dune] strange MPI with CMAKE

Aleksejs Fomins aleksejs.fomins at lspr.ch
Wed Jan 21 17:31:34 CET 2015


Dear Dune,

I have 1 test program, which compiles and runs. It uses MPI and ParMetis
I have now written a 2nd test program. It uses MPI but does not use
ParMetis. I compile the 2nd test and I get the error

error: ‘MPI_Comm’ was not declared in this scope
   MPI_Comm comm = Dune::MPIHelper::getCommunicator();

although statements like that work no problem in the 1st test. From my
point of view, the ONLY difference between the tests in terms of CMAKE
is that one of them uses ParMetis and the other does not.


Now here is the trick. I decided to make the tests completely symmetric by

if(HAVE_MPI)
    add_dune_parmetis_flags(test1)
    add_dune_parmetis_flags(test2)   # I inserted this line
endif(HAVE_MPI)

Now both tests compile.


I mean, this solution works, but I am sure I am doing something wrong.

Opts file and cmake file attached

Cheers,
Aleksejs
-------------- next part --------------
# Define variable with path to the grids to be used in the code
add_definitions("-DDUNE_CURVILINEARGRID_EXAMPLE_GRIDS_PATH=\"${PROJECT_SOURCE_DIR}/doc/grids/\"")

# Define tests to be run
set(TESTS
  test-diagnostics
  test-allcommunicate
)

add_executable(test-diagnostics test-diagnostics.cc)
add_executable(test-allcommunicate test-allcommunicate.cc)
target_link_libraries(test-diagnostics dunecommon dunegeometry dunegrid) # dunecurvilineargeometry
target_link_libraries(test-allcommunicate dunecommon dunegeometry dunegrid) # dunecurvilineargeometry


# We do not want want to build the tests during make all,
# but just build them on demand
add_directory_test_target(_test_target)
add_dependencies(${_test_target} ${TESTS})

foreach(_test ${TESTS})
  add_test(${_test} ${_test})
endforeach(_test ${TESTS})


# Add parmetis
if(HAVE_MPI)
    add_dune_parmetis_flags(test-diagnostics)
endif(HAVE_MPI)

# Add boost
if(Boost_FOUND)
   target_link_libraries(test-diagnostics ${Boost_LIBRARIES})
endif()


-------------- next part --------------
#################################################################################################################
## objective - opts file for building curvilineargrid, based on Dune, with cmake
##
## history - 2014 apr 16, created
##
## usage - time ./dune-common/bin/dunecontrol --use-cmake --opts=af.debian7.lsprag.cmakebuild.minimalistic.opts all
##
##################################################################################################################


USE_CMAKE=yes

CONFIGURE_FLAGS="--enable-parallel --enable-experimental-grid-extensions CC=mpicc CXX=mpicxx" 

CMAKE_PREFIX_PATH="\
/opt/extlib/boost/1.55.0/gcc/4.9.0;\
/opt/extlib/parmetis/4.0.3/openmpi/1.8.1/gcc/4.9.0;\
/opt/extlib/metis/5.1.0/gcc/4.9.0;\
"

GXX_WARNING_OPTS="-Wall -pedantic" 
GXX_OPTS="-O0 -g2" 

CMAKE_FLAGS="\
CXXFLAGS=\"$GXX_WARNING_OPTS $GXX_OPTS\" \
-DPARMETIS_ROOT="/opt/extlib/parmetis/4.0.3/openmpi/1.8.1/gcc/4.9.0" \
-DCMAKE_LIBRARY_PATH:RELEASE=\"/opt/extlib/boost/1.55.0/gcc/4.9.0/lib\" \
-DCMAKE_LIBRARY_PATH:DEBUG=\"/opt/extlib/boost/1.55.0/gcc/4.9.0/lib\" \
-DCMAKE_STANDARD_LIBRARIES:RELEASE=\"-lboost_system\" \
-DCMAKE_STANDARD_LIBRARIES:DEBUG=\"-lboost_system\" \
-DCMAKE_PREFIX_PATH=\"$CMAKE_PREFIX_PATH\" \
-DDUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS:BOOL=TRUE \
" 



# -DCXXFLAGS=\"-O2 -Wall\" \


More information about the Dune mailing list