# Catalyst 2: Add Fortran examples

**URL:** https://discourse.paraview.org/t/catalyst-2-add-fortran-examples/7541
**Category:** In Situ Support
**Tags:** catalyst
**Created:** [July 3, 2021, 2:47pm UTC](https://discourse.paraview.org/t/catalyst-2-add-fortran-examples/7541 "2021-07-03T14:47:16Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![gha3mi](https://discourse.paraview.org/user_avatar/discourse.paraview.org/gha3mi/32/9267_2.png) [@gha3mi](https://discourse.paraview.org/u/gha3mi)
#### Post date: [July 3, 2021, 2:47pm UTC](https://discourse.paraview.org/t/catalyst-2-add-fortran-examples/7541/1 "2021-07-03T14:47:16Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![utkarsh.ayachit](https://discourse.paraview.org/user_avatar/discourse.paraview.org/utkarsh.ayachit/32/39_2.png) [@utkarsh.ayachit](https://discourse.paraview.org/u/utkarsh.ayachit)
#### Post date: [July 7, 2021, 11:45am UTC](https://discourse.paraview.org/t/catalyst-2-add-fortran-examples/7541/2 "2021-07-07T11:45:51Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![gha3mi](https://discourse.paraview.org/user_avatar/discourse.paraview.org/gha3mi/32/9267_2.png) [@gha3mi](https://discourse.paraview.org/u/gha3mi)
#### Post date: [February 12, 2022, 11:25am UTC](https://discourse.paraview.org/t/catalyst-2-add-fortran-examples/7541/3 "2022-02-12T11:25:41Z")

</div>

Could you please help me how to get started?

---

<div class="post-metadata">

### Author: ![menno](https://discourse.paraview.org/user_avatar/discourse.paraview.org/menno/32/1127_2.png) [@menno](https://discourse.paraview.org/u/menno)
#### Post date: [February 15, 2022, 8:06am UTC](https://discourse.paraview.org/t/catalyst-2-add-fortran-examples/7541/4 "2022-02-15T08:06:02Z")

</div>

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:

```auto
  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)

```cs
!>
!! @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

```

---

<div class="post-metadata">

### Author: ![gha3mi](https://discourse.paraview.org/user_avatar/discourse.paraview.org/gha3mi/32/9267_2.png) [@gha3mi](https://discourse.paraview.org/u/gha3mi)
#### Post date: [February 15, 2022, 4:55pm UTC](https://discourse.paraview.org/t/catalyst-2-add-fortran-examples/7541/5 "2022-02-15T16:55:00Z")

</div>

Thanks Menno

I’m a beginner in the Catalyst world, especially Catalyst2.

I’m currently trying to compile the C example ([CFullExample](https://gitlab.kitware.com/paraview/paraview/-/tree/master/Examples/Catalyst2/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](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

---

<div class="post-metadata">

### Author: ![menno](https://discourse.paraview.org/user_avatar/discourse.paraview.org/menno/32/1127_2.png) [@menno](https://discourse.paraview.org/u/menno)
#### Post date: [February 16, 2022, 8:37am UTC](https://discourse.paraview.org/t/catalyst-2-add-fortran-examples/7541/6 "2022-02-16T08:37:06Z")

</div>

Building and using Catalyst2 is documented here

[https://catalyst-in-situ.readthedocs.io/en/latest/?badge=latest](https://catalyst-in-situ.readthedocs.io/en/latest/?badge=latest)

---

<div class="post-metadata">

### Author: ![Christos\_Tsolakis](https://discourse.paraview.org/user_avatar/discourse.paraview.org/christos_tsolakis/32/4450_2.png) [@Christos\_Tsolakis](https://discourse.paraview.org/u/Christos_Tsolakis)
#### Post date: [August 17, 2023, 2:55pm UTC](https://discourse.paraview.org/t/catalyst-2-add-fortran-examples/7541/7 "2023-08-17T14:55:41Z")

</div>

Catalyst 2 has proper Fortran bindings now. An example using ParaViewCatalyst can be found [here](https://gitlab.kitware.com/paraview/paraview/-/tree/master/Examples/Catalyst2/Fortran90FullExample).
