Welcome, Guest
Username: Password: Remember me

TOPIC: How to debug Telemac2D

How to debug Telemac2D 5 years 10 months ago #32614

  • nguyenblue
  • nguyenblue's Avatar
Dear all,
I'm a newbie in programming Telemac, I have installed Telemac and run several examples in its document.
But I still can not debug Telemac code (fortran) using GDB. I checked some topics in this forum and searched over the Internet as well but Telemac seems to lack tutorial for debugging its code.

So just a dumb question but can you give me document(s) which guides developers to debug Telemac source code?

Thank you anyway.
The administrator has disabled public write access.

How to debug Telemac2D 5 years 10 months ago #32620

  • nguyenblue
  • nguyenblue's Avatar
Dear all,
I'm a newbie in developing Telemac. I installed this software in my Ubuntu and run several examples in its documents.

But I still do not know how to debug the source code of Telemac. Although I searched in Internet and this forum but I didn't see any documents/tutorials about using GDB to debug Fortran code of Telemac.

Do you know documents/guidance to debug Telemac source code by change?

Thank you anyway.
The administrator has disabled public write access.

How to debug Telemac2D 5 years 10 months ago #32625

  • yugi
  • yugi's Avatar
  • OFFLINE
  • openTELEMAC Guru
  • Posts: 851
  • Thank you received: 244
Hi,

You can have a look at the debug configuration (C9.gfortran.debug) in systel.edf.cfg for the options to add.

As for gdb the "only" tricky part is that you need to run gdb on the executable that is in the temporary folder.
There are 10 types of people in the world: those who understand binary, and those who don't.
The administrator has disabled public write access.
The following user(s) said Thank You: nguyenblue

How to debug Telemac2D 5 years 10 months ago #32628

  • nguyenblue
  • nguyenblue's Avatar
Thank you yugi,
I have looked at "v8p0r0/configs/systel.edf.cfg", and then the tag [C9.gfortran.debug], it writes:
brief: Debug mode Gfortran compiler 4.9.2 with open_mpi for a debian 8
options: api

So what shoud I do? IMHO, all I should do is to keep these lines in the file "systel.edf.cfg" instead of deleting them?
[C9.gfortran.debug]
brief: Debug mode Gfortran compiler 4.9.2 with open_mpi for a debian 8
options: api

Thank you again,
PS: according to this link, I removed [C9.gfortran.debug] option from my "systel.edf.cfg".
The administrator has disabled public write access.

How to debug Telemac2D 5 years 10 months ago #32632

  • nguyenblue
  • nguyenblue's Avatar
ah, it seems to add these following statements into my systel.edf.cfg
#
[C9.gfortran.debug]
brief: Debug mode Gfortran compiler 4.9.2 with open_mpi for a debian 8
options: api
#
f2py_name: f2py3
pyd_fcompiler: gfortran
sfx_lib:    .so
#
obj_flags: -c -O0 -fPIC [fflags_gfo] [fflags_debug_gfo] [flags_mpi] [flags_mumps] [flags_med] [flags_aed] -DHAVE_VTK
lib_flags: -fPIC -shared [fflags_gfo] [fflags_debug_gfo]
#
exe_flags: -fPIC [fflags_gfo]
libs_all: [libs_so]
#
cflags: -fPIC
#
cmd_lib: [fc] [lib_flags] -o <libname> <objs>
#
The administrator has disabled public write access.

How to debug Telemac2D 5 years 10 months ago #32634

  • yugi
  • yugi's Avatar
  • OFFLINE
  • openTELEMAC Guru
  • Posts: 851
  • Thank you received: 244
What you should look at is the key fflags_gfo_debug
This contains the additionals options passed to the compiler to be in "debug" mode.

You should be able to just add them to your actual configuration at the same place i added them to mine.
There are 10 types of people in the world: those who understand binary, and those who don't.
The administrator has disabled public write access.
The following user(s) said Thank You: nguyenblue

How to debug Telemac2D 5 years 10 months ago #32635

  • nguyenblue
  • nguyenblue's Avatar
Thank you, I follow your guidance and then I get debugging for my fortran code.

In previous post, you wrote: "
you need to run gdb on the executable that is in the temporary folder.
"

Where is the temporary folder? I run the example
telemac2d.py t2d_gouttedo.cas
in folder
examples/telemac2d/gouttedo
. As the program is executing, I cancel it and notice this path:
examples/telemac2d/gouttedo/t2d_gouttedo.cas_2019-01-22-03h46min55s/

This directory contains an executable file named "out_user_fortran". Is it the temporary folder?

Thank you in advance.
The administrator has disabled public write access.

How to debug Telemac2D 5 years 10 months ago #32636

  • c.coulet
  • c.coulet's Avatar
  • OFFLINE
  • Moderator
  • Posts: 3722
  • Thank you received: 1031
Hi
Yes this is the temporary folder.
To simplify the name you could use the option -w or --wdir to fix the name of the temporary directory (look in the help menu)
Once inside the temporay, you should run gdb out_user_fortran.exe and you could debug the code

Regards
Christophe
The administrator has disabled public write access.
The following user(s) said Thank You: nguyenblue

How to debug Telemac2D 5 years 10 months ago #32642

  • nguyenblue
  • nguyenblue's Avatar
Thank you for all,
From now on, I can debug the Fortran source code of Telemac.

With example gouttedo, I run "gdb out_user_fortran" and then I notice something really strange.

I know that the subroutine lecdon_telemac2d is involved but I can not set breakpoint at it by typing:
break lecdon_telemac2d
.

I find out that I can type:
(gdb) break LECDON_TELEMAC2D_
, the same with
(gdb) break TELEMAC2D_
. It works. But I can not set breakpoint at a line of lecdon_telemac2d.F or telemac2D.F.

I wonder what is happening here. I suppose after compiling, Telemac source code will be changed - at least names of subroutines, names of variables, lines of code - by gfortran.

Is it correct?

Or does anyone happen to have the same problem as debugging Telemac fortran code in Ubuntu by change?

Thank you very much
The administrator has disabled public write access.

How to debug Telemac2D 5 years 10 months ago #32650

  • yugi
  • yugi's Avatar
  • OFFLINE
  • openTELEMAC Guru
  • Posts: 851
  • Thank you received: 244
This is normal gdb was meant for C code.
So it is using the C name of the functions hence the additional _ in fortran
Those names are compiler dependant and can be change via compiler options.
As for the line of the file that should work.
Try using the full name path (break /home/..../sources/telemac2d/lecdon_telemac.F:31)
There are 10 types of people in the world: those who understand binary, and those who don't.
The administrator has disabled public write access.

The open TELEMAC-MASCARET template for Joomla!2.5, the HTML 4 version.