We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3f204ab commit ad4981cCopy full SHA for ad4981c
demos/interface/fortran/README.md
@@ -0,0 +1,8 @@
1
+# Building the extension
2
+
3
+Fortran source can be built into a C-extension as
4
+```
5
+f2py -c add.f90 -m add
6
7
+(For Python 3 use f2py3)
8
demos/interface/fortran/add.f90
@@ -0,0 +1,12 @@
+subroutine add(a, b, n)
+ implicit none
+ ! f2py understands only limited number of kind parameters
+ real(kind=8), intent(inout) :: a(n)
+ real(kind=8), intent(inout) :: b(n)
+ integer :: n
9
10
+ a = a + b
11
12
+end subroutine
demos/interface/fortran/example.py
+import add
+import numpy as np
+a = np.random.random(10)
+b = np.ones_like(a)
+print(a)
+add.add(a, b)
0 commit comments