from file add.f95:
gfortran -shared -fPIC add.f95 -o add.so
The simple python code with which you can call it is:
subroutine add(a,b,c) implicit none integer a,b,c c = a + b end
Note the extra underscore. I didn't play around with arrays. It should work as well but is maybe more a dirty hack than a good solution. ctypes is however python standard if you don't have access to f2py.
#!/usr/bin/env python from ctypes import c_int, byref, cdll a = c_int(3) b = c_int(4) c = c_int() addlib = cdll.LoadLibrary('./add.so') addlib.add_(byref(a),byref(b),byref(c)) print c