Introduction
The debuging of a program allow us to find the errors written in the source code. The tool that we are going to illustrate is the GNU gdb
debuger.
Example
A user is trying to to Bader analysis of a Wavefunction with the aimpac tool extreme using a wavefunction obtained with Gaussian 09. When running the extreme program he obtains the following error:
extreme wave
forrtl: severe (64): input conversion error, unit 10, file
so extreme is not working. In order to figure out what is going on we will debug de conde. To do so we must compile it with the –g
option, as follows:
gfortran -g EXT94b.f -o extreme
Then we start debuging.
gdb ./extreme
Once it is running, we have to pass the argument (the wavefunction stored in the wave file) to the program using:
set arg wave
and then run the programa:
run
Here is the whole sequence of the execution.
[cn0 7] ~ > gdb ./extreme
GNU gdb Fedora (6.8-27.el5)
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type “show copying”
and “show warranty” for details.
This GDB was configured as “x86_64-redhat-linux-gnu”…
(no debugging symbols found
(gdb) set arg wave
(gdb) runStarting program: /home/pobmelat/extreme wave
At line 3689 of file EXT94b.f
Fortran runtime error: Bad value during floating point read
Program exited with code 02.
(gdb)
In the 3689 line of the EXT94b.f I read
C READ IN
C
READ (IWFN,109) TOTE,GAMMA
The READ statement is using 109 format, which is defined in line 3703:
109 FORMAT(17X,F20.12,18X,F13.8)
And, the TOTAL SCF ENERGY AND -V/T is writen as follows in the gaussian 09 generated WFN:
” TOTAL ENERGY = -1263.592058754168 THE VIRIAL(-V/T)= 2.00956965"
The format of writing this line has changed in gaussian 09 to:
109 FORMAT(15X,F20.12,18X,F13.8)
I modified it, compiled it and extreme is working again.
Woman Fall
HPC @UPV/EHU » Debuging example I