Reputation: 49
module constants
implicit none
DOUBLE PRECISION,parameter,public::MJ=9.552538964304e-4
DOUBLE PRECISION,parameter,public::pi=3.1415926536
DOUBLE PRECISION,parameter,public::MS=0.44
DOUBLE PRECISION,parameter,public::RS=0.002045615583096031
end module constants
module photdynh
use constants
INTEGER,parameter,public::NBOD=2,NDGL=6*NBOD, &
n=7+8*(nbod-1),nmax=77970,nparam=3*nbod
INTEGER,public::NOBS,ntransit(nbod),phottype
DOUBLE PRECISION,public::mc(nbod),mp(nbod),xstart, &
ystart(ndgl),per(nbod)
DOUBLE PRECISION,public::a(NBOD),e(NBOD),inc(NBOD)
DOUBLE PRECISION,public::g(NBOD),node(NBOD),l(NBOD),p(NBOD), &
ex(NBOD),ey(NBOD)
double precision,public::lb(n),ub(n),flux_obs(nmax), &
jd(nmax),normerr(nmax),tmids(nbod),u1,u2,rearth
logical::ipar(n),iorbel
end module photdynh
The code above defines fortran modules that are used by another module photdyn_model with use statements like use photdynh. After wrapping the modules with f2py, f2py -c -m photdyn_model.f90 -m photdyn_model and importing into python, I get an error message
File "photdynmodel.py", line 4, in import photdyn_model ImportError: /mnt/d/TESS/TOI2095/photdyn_model.cpython-38-x86_64-linux-gnu.so: undefined symbol: __photdynh_MOD_ms
Why is f2py having trouble with this publicly defined constant ? Is there something wrong with this code/approach ?
Upvotes: 2
Views: 124
Reputation: 37208
You don't say which Fortran compiler you're using, but at least with GFortran a named constant (a variable declared with the parameter
attribute) doesn't necessarily result in a corresponding symbol in the object file. It's been a very long time since I've used f2py, but if f2py expects that each Fortran variable has a corresponding symbol in the object file (as suggested by the error message you're getting), then that sounds like a bug in f2py.
Upvotes: 1