Take the 2-minute tour ×

I am debugging prog.f90, which has a module mod.f90. How do I print the argument variable values?

The module has a subroutine that gets called within a loop. It takes in the arguments, stores one in a local variable, calculates the new value of the argument, stores that in another local variable, then uses the local variables to test a certain condition. The new value of the argument gets passed back to main.

I am trying to print the values of all the variables while within the subroutine. I can print the local variables, but printing the argument variables gives me a reference address.

(gdb)print temp_curr
$1 = 4
(gdb)print arg1
$2 = (REF TO -> ( real8 )) @0x7fffffffe0a0: -nan(0x8000000000000)

I tried...

(gdb)print $arg1
$3 = VOID

The subroutine looks something like this...

SUBROUTINE sub(arg1, arg2)
REAL, INTENT(inout):: arg1, arg2
REAL               :: temp_prev, temp_curr

temp_prev = arg1

arg1 = (a bunch of calculations)/arg2

temp_curr = arg1

IF (temp_curr < temp_prev) THEN

share|improve this question
It looks like you should be able to dereference that variables using C syntax: numericalnoob.blogspot.be/2012/08/… –  dbrank0 Jan 24 '13 at 22:59
I tried this without success: (gdb) print *((real *) ecc) Cannot access memory at address 0x3fe999999999999a –  jgoldst1 Jan 25 '13 at 1:10
add comment

1 Answer

The $arg1 variable in gdb is used only in gdb scrips (see GDB documentation). If you refer to the variable of the program being debugged use only arg1.

Try print MODULENAME::VARNAME if you want to print a variable (VARNAME) from another module (MODULENAME)

share|improve this answer
add comment

Your Answer


