Compiling Notes



Switch the compiler environment variables so that we can make a 32-bit library to be called from python using the ctypes module.

. /opt/intel/composerxe-2011/bin/ ia32


Here is an example of making a library out of a fortran90/95 module:

ifort -dynamiclib -o num_types.f90 combinatorics.f90

Now, call a routine from python


from ctypes import *
libtest = cdll.LoadLibrary("./")

# If you don't know what the method is called in the library, use "nm"
method = libtest.combinatorics_mp_binomial_
x = c_int(32)
y = c_int(15)
print "x = %d, y = %d" % (x.value, y.value)
# The byref() is necessary since
# FORTRAN does references,
bnml = method( byref(x), byref(y) )
print "x = %d, y = %d" % (x.value, y.value)
print bnml