Author Topic: Debugging gfortran allocatable arrays  (Read 1721 times)

Offline DoctorRad

  • Single posting newcomer
  • *
  • Posts: 6
Debugging gfortran allocatable arrays
« on: October 15, 2016, 01:18:19 pm »
Hi all,

New here, but a pretty experienced developer getting into modern Fortran after a couple of decades Hiatus.

Code::Blocks (16.01) has been great so far, but when I am debugging my Fortran code, I am having issues with the debugger. If I add a watch onto an allocatable array, then right click -> Properties and select 'Watch as Array', with any Start and Count values other than zero, I get an error of the form "A syntax error in expression, near `[0]@1'."

I can happily use expressions of the form

Code: [Select]
print *((real_8 *)price)@10
in the debugger command line, but I would like to be able to examine array and how they change line-by-line in the watch window. Is there some way I can set up either gdb or Code::Blocks to allow this?

According to this page, one possible solution would be to use gdb 7.11 rather than version 7.6.1 which is bundled with Code::Blocks 16.01. I have tried installing gdb and gdbserver executables from a pre-compiled mingw distribution which included gdb 7.11, but this did not work.

I'm not afraid to perform surgery on my installation if that's what's necessary, but any pointers would be gratefully appreciated.

Many thanks,

Dr. Matt...

Offline jcrespo

  • Single posting newcomer
  • *
  • Posts: 1
Re: Debugging gfortran allocatable arrays
« Reply #1 on: May 23, 2018, 11:51:50 am »
I think the issue is related with nightly builds, I do not know exactly where the source code is, but the point is the way the "variable watcher" access the array in the memory. In C is row-wise whilst in fortran is column-wise. An example is shown in wikipedia:

The point would be to access to the source code of the array inspector of codeblocks (i.e. variable watcher), and include an "if" statement for gfortran case of accessing arrays column-wise instead of row-wise

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2580
Re: Debugging gfortran allocatable arrays
« Reply #2 on: May 24, 2018, 12:19:00 am »
If someone could give a debugger log output of a array from c vs fortran we could thing to work on it..