Debugger for Fortran in Linux

I have been trying to search for a good debugger for Fortran code in Linux. But it is very hard to find. I know that GDB is supposed to be able to do it. But when I debug Fortran 95 code compiled using GFortran, I simply don’t know how to display the dynamic size array. I tried to google, and found that other people also find the same issue with GDB and fortran:

this is what I get when I tried to print an array which was allocatable, and allocated afterward:

(gdb) p myarray
{ 0x80614c8, -1, 537, ({ 1, 1, 6})}

and when I get the type:

(gdb) pt myarray
type = Type array_descriptor1
PTR TO -> ( void ) :: data
int4 :: offset
int4 :: dtype
Type descriptor_dimension
int4 :: stride
int4 :: lbound
int4 :: ubound
End Type descriptor_dimension (0:0) :: dim
End Type array_descriptor1

so for me, the best solution currently is to use Intel compiler and debugger in Linux. The debugger is called “idb”. You can download freely from intel website.

So what I did was that I recompiled my code using “ifort” which is the intel fortran compiler, and use the “idb” to debug. To run it type:

$ /opt/intel/Compiler/11.1/038/bin/ia32/idb

the location will depend on where you install the compiler and the debugger.

To start debug, click “File->Load executable”, and choose the executable which has been compiled using Ifort. To view the source as well, click “View->Source Files”.

You can set a break point, etc, in the code, and to view an array simply type:

(idb) p myarray

or you can also access the element

(idb) p myarray(3)

Below is the snapshot of the debugger. I used Kubuntu 8.04.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: