# The difficulties of using Fortran in SciPy

**URL:** <https://fortran-lang.discourse.group/t/the-difficulties-of-using-fortran-in-scipy/6753>\
**Category:** Uncategorized\
**Created:** [November 8, 2023, 8:47pm UTC](https://fortran-lang.discourse.group/t/the-difficulties-of-using-fortran-in-scipy/6753 "2023-11-08T20:47:39Z")\
**Posts on this page:** 1\
**Showing post:** 40

<div class="post-metadata">

**Author:** ![hkvzjal](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/hkvzjal/32/3055_2.png) [@hkvzjal](https://fortran-lang.discourse.group/u/hkvzjal)\
**Post date:** [November 9, 2023, 6:57pm UTC](https://fortran-lang.discourse.group/t/the-difficulties-of-using-fortran-in-scipy/6753/40 "2023-11-09T18:57:46Z")

</div>

> [@certik](#):
>
> This ties to our previous discussion of being able to operate on NumPy arrays directly in Fortran without any overhead, which has to be solved.

there is already a solution for that: [numpy.ctypeslib](https://numpy.org/doc/stable/reference/routines.ctypeslib.html) posted something on this regard in the previous thread:

> [@Optimization Without Using Derivatives: the PRIMA Package, its Fortran Implementation, and Its Inclusion in SciPy](https://fortran-lang.discourse.group/t/optimization-without-using-derivatives-the-prima-package-its-fortran-implementation-and-its-inclusion-in-scipy/5798/19):
>
> With pleasure! If you want to start getting your hands dirty you could start with a very simple example. I reworked a minimum working example previously discussed [here](https://fortran-lang.discourse.group/t/rfc-get-rid-of-linalg-interpolative-fortran-code/5677/13) Since I work on windows but also have linux through WSL I prepared it such that you can test the following combination A) windows with ifort B) Linux with gfortran. Also, let’s assume that for simplicity you have everything in the same folder: 
> 
> > **fortran2python.f90**
> >
> > module fortran2python use iso\_c\_binding implicit none contain…

I’ve used the ctypeslib for crunching big arrays and saw basically the same cpu time running the shared library called from python compared to a compiled executable.

---

_[View the full topic](https://fortran-lang.discourse.group/t/the-difficulties-of-using-fortran-in-scipy/6753)._
