Preparing Your Program for Debugging

This section describes preparing your program for debugging.

Preparing for Debugging using the Command Line

To prepare your program for debugging when using the command line (ifort command):

  1. Correct any compilation and linker errors.

  2. In a command window, (such as the Fortran command window available from the Intel Fortran program folder), compile and link the program with full debug information and no optimization:
    ifort -g file.f90
    (Linux and Mac OS)
    ifort
    /debug:full file.f90 (Windows)

On Linux  and Mac OS systems, specify the -g compiler option to create unoptimized code and provides the symbol table and traceback information needed for symbolic debugging. (The -notraceback option cancels the traceback information.)

On Windows systems, specify the /debug:full compiler option to produce full debugging information. It produces symbol table information needed for full symbolic debugging of unoptimized code and global symbol information needed for linking.

Preparing for Debugging using Microsoft Visual Studio*

The following applies to Windows* systems only.

To prepare your program for debugging when using the integrated development environment (IDE):

  1. Start the IDE (select the appropriate version of Microsoft Visual Studio in the program folder).

  2. Open the appropriate solution (using the Solution menu, either Open Solution or Recent Projects).

  3. Open the Solution Explorer View.

  4. To view the source file to be debugged, double-click on the file name. The screen resembles the following:

  5. In the Build menu, select Configuration Manager and select the Debug configuration.

  6. To check your project settings for compiling and linking, select the project name in the Solution Explorer. Now, in the Project menu, select Properties, then click the Fortran folder in the left pane. Similarly, to check the debug options set for your project (such as command arguments or working directory), click the Debugging folder in the Property Pages dialog box. 

  7. To build your application, select Build>Build Solution.

  8. Eliminate any compiler diagnostic messages using the text editor to resolve problems detected in the source code and recompile if needed.

  9. Set breakpoints in the source file and debug the program, as described in Debugging the Squares Example Program.