As the title suggests, for those who are suffering from this error.
I had a lot of trouble when I was told when I used f2py
(now integrated with numpy) to call fortran as a python module.
The environment is Mac OS 10.15 Catalina.
If you have a version lower than that, there is a lot of information available, so I will omit it (you can download the command line tool from the official page and unpack it).
Since it is just a memorandum, I conclude from the beginning. Execute the following command in the terminal.
$ sudo ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/* /usr/local/include/
You can now put a symbolic link to the Xcode header in / usr / local / include /
.
After that, for example
$ python3 -m numpy.f2py -c hello.f90 -m hello
If you do, you will have a file named hello.cpython-38-darwin.so
etc.
$ python3 f2.py
Hello from Fortran!
a= 4
If so, it will work.
f2.py
import hello
hello.foo(4)
hello.f90
subroutine foo(a)
integer :: a
write(*,*) "Hello from Fortran!" !Output characters here
write(*,*) "a=",a !Output an integer here
end subroutine foo
Recommended Posts