J'ai ce module Fortran:Interfacing Python avec module Fortran par ctypes
MODULE utils
IMPLICIT NONE
PUBLIC
INTEGER :: num_atom ! number of atoms in one configuration
CONTAINS
SUBROUTINE readin
IMPLICIT NONE
INTEGER :: iargc, ndim, i
END SUBROUTINE readin
SUBROUTINE convert
IMPLICIT NONE
REAL :: x,y,z
END SUBROUTINE convert
Je compilez par:
gfortran -shared -fPIC -cpp -O2 thiscode.f90 -o somelib.so
Ainsi, tout en essayant d'appeler la fonction "readin" de ce qui suit code python:
import os
_path = os.path.dirname(os.path.realpath(__file__)) + "/" + "somelib.so"
from ctypes import cdll, byref, c_int, c_double, c_char
lib_polint = cdll.LoadLibrary(_path)
def A():
a = lib_polint.readin_
A()
Je ne peux pas identifier le nom de la fonction dans « somelib.so » et l'erreur suivant apparaît:
"undefined symbol: readin_".
Si je retire le module et que je garde juste le sous-programme "readin", cela fonctionne. Comment gérer cela?