Navigation: Previous   Up   Next

3.8 Example of dbx90

This is an example of the use of dbx90 in debugging some Fortran code which contains both COMMON blocks and modules.

The file to be debugged is called ‘fh4.f90’ and contains:

    MODULE fh4
      REAL r
    END MODULE fh4

    PROGRAM fh4_prog
      USE fh4
      COMMON/fh4com/i
      i = 2
      CALL sub
      PRINT *,i,r
    END PROGRAM fh4_prog

    SUBROUTINE sub
      USE fh4
      COMMON/fh4com/i
      r = 0.5*i
      i = i*3
    END SUBROUTINE sub

It is first compiled with the -g90 option and then run under dbx90:

    % nagfor -g90 -o fh4 fh4.f90
    % dbx90 fh4
    NAG dbx90 Version 5.2(22)
    Copyright 1995-2008 The Numerical Algorithms Group Ltd., Oxford, U.K.
    GNU gdb Red Hat Linux (6.5-15.fc6rh)
    Copyright (C) 2006 Free Software Foundation, Inc.
    GDB is free software, covered by the GNU General Public License, and you are
    welcome to change it and/or distribute copies of it under certain conditions.
    Type "show copying" to see the conditions.
    There is absolutely no warranty for GDB.  Type "show warranty" for details.
    This GDB was configured as "i386-redhat-linux-gnu"...Using host libthread_db lib
    rary "/lib/libthread_db.so.1".

    (dbx90)

Setting a breakpoint in routine SUB and running the program.

    (dbx90) stop in sub
    [1] stop in SUB in file "fh4.f90"
    (dbx90) run
    stopped in SUB at line 16 in file "fh4.f90"
       16     r = 0.5*i
    (dbx90)

Printing the value of a variable, which may be local, in a COMMON block, or in a USEd module.

    (dbx90) print i
    I = 2
    (dbx90) next
    17        i = i*3
    (dbx90) print r
    R = 1
    (dbx90) next
    18      END SUBROUTINE sub
    (dbx90) print i
    I = 6

Variables can also be assigned values.

    (dbx90) assign i = 7
    I  = 7
    (dbx90) cont
     7   1.0000000

    Program exited normally.
    (dbx90) quit
    %