Viewing Fortran Data Types in the Debugger

The following general suggestions apply to different types of Fortran data:

For information on using Data Tips, the Local Variables window, or a Watch window, see Debugging the Squares Example Program.

For information on using the Array Viewer in the debugger, see Using the Array Viewer in the Debugger.

The following sections apply to using the Watch window:

To display the Watch window:

  1. In the View menu, point at (or click) Debug Windows
  2. In the submenu, click Watch

Specifying Array Sections

You can specify array sections in a watch window. For example, consider an array declared as:

  integer foo(10)

You can specify the following statement in a watch window to see the 2nd, 5th, and 8th elements:

  foo(2:10:3)

When working with character arrays, this syntax may be combined with a substring specification. Consider the following array declaration:

  character*8 chr_arr(10)

You can specify the following statement in a watch window to display the substring made up of character 3 through 8 of array elements 2 through 5:

  chr_arr(2:5)(3:8)

This support is available for arrays of any type, including array pointers, assumed-shape, allocatable, and assumed-size arrays.

Any valid integer expression can be used when specifying lower bound, upper bound, or stride. If the lower bound is omitted, the array lower bound is used. If the upper bound is omitted, the array upper bound is used. For example, consider the following declaration:

  integer foo(10)

To display:

Specifying Module Variables

To view a module variable in the Watch window, specify the module name, followed by "::", followed by the variable name.

For example, to watch variable "bar" of module "foo", specify the following expression:


  foo::bar

Specifying Format Specifiers

You can use format specifiers in Watch windows to display variables in different data formats.

For example, given a REAL variable 'foo' in a program, it is now possible to see 'foo' in different floating point notation (by typing "foo,f" "foo,g" or "foo,e" in a Watch window) or as an integer (""foo,i" or "foo,d"), a hexadecimal value ("foo,x"), an an octal value ("foo,o"), and so on.

You can change the display format of variables in the Watch window using the formatting symbols in the following table:

Symbol Format Value Displays
d,i signed decimal integer 0xF000F065 -268373915
o unsigned octal integer 0xF065 0170145
x,X Hexadecimal integer 61541 (decimal) #0000F065
f signed floating-point 3./2. 1.5000000
e signed scientific notation 3./2. 0.1500000E+01
g signed floating-point or signed scientific notation, whichever is shorter 3./2. 1.500000
c Single character 0x0065 'e'
s String 0x0012fde8 "Hello world"

To use a formatting symbol, type the variable name, followed by a comma and the appropriate symbol. For example, if var has a value of 0x0065, and you want to see the value in character form, type var,c in the Name column on the tab of the Watch window. When you press ENTER, the character-format value appears:

  var,c = 'e'

You can use the formatting symbols shown in the following table to format the contents of memory locations:

Symbol Format Displays
ma 64 ASCII characters 0x0012ffac .4...0...".0W&.......1W&.0.:W..1...."..1.JO&.1.2.."..1...0y....1
m 16 bytes in hexadecimal, followed by 16 ASCII characters 0x0012ffac B3 34 CB 00 84 30 94 80 FF 22 8A 30 57 26 00 00 .4...0...".0W&..
mb 16 bytes in hexadecimal, followed by 16 ASCII characters 0x0012ffac B3 34 CB 00 84 30 94 80 FF 22 8A 30 57 26 00 00 .4...0...".0W&..
mw 8 words 0x0012ffac 34B3 00CB 3084 8094 22FF 308A 2657 0000
md 4 doublewords 0x0012ffac 00CB34B3 80943084 308A22FF 00002657

With the memory location formatting symbols, you can type any value or expression that evaluates to a location.

A formatting character can follow an expression also:

  rep+1,x
  alps[0],mb
  xloc,g
  count,d

Note: You can apply formatting symbols to structures, arrays, pointers, and objects as unexpanded variables only. If you expand the variable, the specified formatting affects all members. You cannot apply formatting symbols to individual members.