Using Intel® Inspector XE on Fortran Applications – Threading Analysis

Intel® Inspector XE supports analysis of programs written in the C/C++, C#, and Fortran languages. This is the second article in a three part series covering how to use Intel Inspector XE on Fortran applications. This article will cover using Intel Inspector XE threading analysis on a sample Fortran application. Part 1 covered memory analysis and part 3 will cover how to use static security analysis on Fortran.

Once you have a debug configuration (optimization off and debug information included) successfully compiled the next step is to create an Intel Inspector XE project. If you are using Microsoft* Visual Studio, this step is omitted because Intel Inspector XE will use the current Visual Studio project. When creating a new project, modify the project properties in Intel Inspector XE to record the location of the application to launch, the application parameters, and working directory. For more information on these steps, see the previous article.

Running a threading analysis is a very thorough and detailed process, and due to this, it adds significant overhead to the run time of the application. To mitigate some of this overhead, try to decrease the workload of the application. Choose an input data set or input parameters that execute the most code paths, with as little repetition as possible.

To run a threading analysis on your application, create a “New Analysis”, select an Analysis Type and click “Start” as shown in the following figure. In this figure, the “Detect Deadlocks and Data Races” Analysis Type is selected. Intel Inspector XE also has the predefined Analysis Types “Detect Deadlocks” and “Locate Deadlocks and Data Races.” Each of these has trade-offs with respect to overhead, problems detected, and level of detail. For more information on controlling the analysis cost check out this article. The Details region of the Analysis Type window gives in-depth information about each analysis type. New analysis types can also be created and configured. All of the analysis type details are documented in the Intel Inspector XE help.


Intel Inspector XE will launch the application and monitor it to detect threading issues. Once the application completes, the detected issues are presented in the analysis summary.


In this example, Intel Inspector XE detected two “Data race” problems in the application. The Code Locations pane shows source code locations related to the selected problem. Double-clicking on any of these problems will open the Sources view with complete source code information and call stack data. The Sources view for the first data race is shown in the figure below.

From this view, double click on any source line to open the code editor and modify the source file. This particular problem is the result of memory reuse on the ‘queens’ array, i.e. multiple threads are using the same location to store data but no data is shared between threads. To fix this issue, a local copy of the array should be created for each thread.

The Sources view for the second data race problem is shown below.

In order to fix this issue, the variable ‘nrOfSolutions’ should be protected from multiple threads accessing it at the same time. This can be achieved with an atomic directive.
Once you have made corrections to fix the issues, rebuild your application and run the analysis again. If all of the issues are fixed, you should see a result similar to the figure below.

Using Intel Inspector XE on Fortran applications is straightforward and increases your confidence in the correctness and security of an application.

Para obter informações mais completas sobre otimizações do compilador, consulte nosso aviso de otimização.