"I don't know whether anyone has run into exactly this problem. What
happens if
you write a small program that does not use deal.II at all, but uses the
uses
the cmake scripts of one of the deal.II tutorial programs? That is, you take
one of the deal.II tutorials, and replace the entire code of that program by
just a minimal thing that calls Matlab but does not call anything in deal.II
nor uses any of the deal.II #include files?"
Good point to narrow down the problem.
I modified step-1 so that the main function only calls matlab via
callFevalsqrt().
This works fine, even if I use the mpi compiler mentioned in my original
post.
However, if I just add a second line in the main function,
dealii::Triangulation<2> triangulation,
I run again into the segfault.
Including deal.II headers seems to be not the problem, using dealii
members/functions seems to a problem.
Clearly, the compiler shipped with openmpi seems not to be the real problem,
although I do not see the above issue with the default compiler on my
system.
Attached is the minimal program that I created along with the
CMakeLists.txt.
In case you have matlab installed and can reproduce my problem, you only
have to replace
<matlabroot> in line 8
by what matlabroot() returns.
Any idea why adding any dealii members/functions causes a segfault in
startMatlab() ?
May I have to pass some compiler flags to cmake, given that it works with
the default compiler?
Thanks,
Math
Wolfgang Bangerth schrieb am Mittwoch, 21. Juni 2023 um 23:53:06 UTC+2:
On 6/21/23 11:42, Mathieu wrote:
>
> I compiled dealii with MPI and the cxx compiler found by cmake is from
> openmpi-4.1.3.
> I narrowed my program down and installed dealii without any dependencies
> to use the default cxx compiler on my system (gcc 11.3.0).
> Long story short, calling callFevalsqrt() runs without any errors.
> From this, I include that dealii compiled with MPI and the MATLAB engine
can
> not be combined (because matlab does not support compilers from MPI ?)
>
> Has someone experience with that and can provide a workaround?
Mathieu:
I don't know whether anyone has run into exactly this problem. What happens
if
you write a small program that does not use deal.II at all, but uses the
uses
the cmake scripts of one of the deal.II tutorial programs? That is, you
take
one of the deal.II tutorials, and replace the entire code of that program
by
just a minimal thing that calls Matlab but does not call anything in
deal.II
nor uses any of the deal.II #include files?
Best
W.
--
------------------------------------------------------------------------
Wolfgang Bangerth email: [email protected]
www: http://www.math.colostate.edu/~bangerth/
--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see
https://groups.google.com/d/forum/dealii?hl=en
---
You received this message because you are subscribed to the Google Groups
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/dealii/91d4149a-00e2-4afc-8dd6-6dea29f15176n%40googlegroups.com.
##
# CMake script for the step-1 tutorial program:
##
SET(TARGET "step-1")
#MATLAB
SET(Matlab_ROOT_DIR <matlabroot>)
#MATLAB
SET(LD_LIBRARY_PATH
${Matlab_ROOT_DIR}/extern/bin/glnxa64:${Matlab_ROOT_DIR}/sys/os/glnxa64)
#MATLAB
include_directories(${Matlab_ROOT_DIR}/extern/include/)
# MATLAB
link_directories(${Matlab_ROOT_DIR}/extern/bin/glnxa64)
SET(TARGET_SRC
${TARGET}.cc
)
CMAKE_MINIMUM_REQUIRED(VERSION 3.3.0)
FIND_PACKAGE(deal.II 9.3.2
HINTS ${deal.II_DIR} ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}
)
IF(NOT ${deal.II_FOUND})
MESSAGE(FATAL_ERROR "\n"
"*** Could not locate a (sufficiently recent) version of deal.II. ***\n\n"
"You may want to either pass a flag -DDEAL_II_DIR=/path/to/deal.II to
cmake\n"
"or set an environment variable \"DEAL_II_DIR\" that contains this path."
)
ENDIF()
DEAL_II_INITIALIZE_CACHED_VARIABLES()
PROJECT(${TARGET})
DEAL_II_INVOKE_AUTOPILOT()
# MATLAB: Linker to libMatlabEngine in link_directories
target_link_libraries(${TARGET} MatlabEngine)
# MATLAB: Linker to libMatlabDataArray in link_directories
target_link_libraries(${TARGET} MatlabDataArray)
#include <deal.II/grid/grid_generator.h>
#include "MatlabEngine.hpp"
#include "MatlabDataArray.hpp"
#include <iostream>
void callFevalsqrt() {
// Call MATLAB sqrt function on array
using namespace matlab::engine;
// Start MATLAB engine synchronously
std::unique_ptr<MATLABEngine> matlabPtr = startMATLAB();
// Create MATLAB data array factory
matlab::data::ArrayFactory factory;
// Define a four-element array
matlab::data::Array const argArray =
factory.createArray({ 1,4 }, { -2.0, 2.0, 6.0, 8.0 });
// Call MATLAB function
matlab::data::Array results = matlabPtr->feval(u"sqrt", argArray);
// Display results
for (int i = 0; i < results.getNumberOfElements(); i++) {
double a = argArray[i];
std::complex<double> v = results[i];
double realPart = v.real();
double imgPart = v.imag();
std::cout << "Square root of " << a << " is " <<
realPart << " + " << imgPart << std::endl;
}
}
int main()
{
callFevalsqrt();
//dealii::Triangulation<2> triangulation;
}