I would like to use Paraview Catalyst in my Fortran project. Could you give me an example or would you please help me prepare an example?
While in theory it should be possible, we haven’t tired this yet with Catalyst 2.0 and hence there’s some figuring out to do here. If someone wants to investigate this, that’d be great.
Could you please help me how to get started?
I’ve recently been working on coupling a Fortran code to Catalyst2, and I have the basics working. To that end I have written a small C interface, that calls functions in the Fortran code to get pointers to the data. Maybe this is helpful?
For example in the C-code:
double* pVertices(nullptr);
int nVertices(-1);
get_vertex_array(&pVertices, &nVertices);
mesh["coordsets/coords/values/x"].set_external(
pVertices, nVertices, 0, sizeof(double));
mesh["coordsets/coords/values/y"].set_external(
pVertices, nVertices, nVertices * sizeof(double), sizeof(double));
mesh["coordsets/coords/values/z"].set_external(
pVertices, nVertices, 2 * nVertices * sizeof(double), sizeof(double));
and in the Fortran code (the coord_v_3
array is the Fortran array that contains the vertices with dimension (nVertices,3)
!>
!! @brief
!! Gets a C-pointer to the vertices array
!<
!=====================================================================
SUBROUTINE get_vertex_array(arr, nverts) BIND(C)
!=====================================================================
USE, intrinsic :: iso_c_binding, ONLY: C_LOC, C_PTR
TYPE(C_PTR), INTENT(OUT) :: arr
INTEGER , INTENT(OUT) :: nverts
arr = C_LOC(coord_v_3)
nverts = nVertices
END SUBROUTINE get_vertex_array
Thanks Menno
I’m a beginner in the Catalyst world, especially Catalyst2.
I’m currently trying to compile the C example (CFullExample) of Catalyst2. Then I can use your idea with the C interface.
I have a basic question. First of all, regardless of Fortran, how can I use Make to compile this C example at https://gitlab.kitware.com/paraview/paraview/-/tree/master/Examples/Catalyst2/CFullExample
I’m using Paraview v5.10, should I compile it first to use Catalyst2 or can I use the binaries? If I remember correctly, when using Catalyst you should compile Paraview first?
Ali
Building and using Catalyst2 is documented here
https://catalyst-in-situ.readthedocs.io/en/latest/?badge=latest
Catalyst 2 has proper Fortran bindings now. An example using ParaViewCatalyst can be found here.