Edit 3/6: Sorry, this was a false alarm. It seems to be working now. I believe the -g
flag on gfortran and --debug-capi
are sufficient after all to generate line numbers for GDB (gnu debugger). I will make a short answer summarizing how to do this in case it is helpful for others (was a bit of a learning experience for me). But please feel free to post additional answers that improve on this. In particular I would be interested in being able to get line numbers without using GDB, if that's possible.
This must be a common problem but I can't find any answers. The error is in in the Fortran library (what I call f2.f90
below), but it's a runtime error that isn't triggered until I am using the code via Python.
To make it a little more explicit:
I compile several files with
gfortran
:gfortran -c f1.f90 f2.f90
I generate a module with
f2py
:f2py -c f1.o f2.o -m main main.f90
In python:
import main
In python, call subroutine main, inside of main:
main.main()
I can get this to work successfully but when I play around with f2.f90
I will often have some error, and when that happens it's in step 4 and will crash python and only give me the option to close it. Unfortunately I get no information about what line in f2.f90
caused the problem or any other info.
So, pretty simple question, is there a way I can cause step 4 to give me some basic info about the run time crash? Mainly the line number of the problem.
I've tried adding -g -fbacktrace
to gfortran call and --debug-capi
to f2py
and then using gdb python
with backtrace. This looks somewhat promising as it at least tells me that the offending file is f2.f90
, but not the line number. If I try "backtrace full" it will tell me No symbol table info available
which is probably where the line number info is held?