Problem: Fortran source files not compiled when building in Visual Studio

This article provides a solution for the problem of, when in Microsoft Visual Studio, a Fortran source file cannot be compiled (no Compile option when right clicked) or when building a Fortran project, Fortran source files are skipped over. If errors are reported when compiling Fortran sources, this article does not apply.

First, verify that your Fortran source files have a file type that is recognized by Intel Visual Fortran.  These are:

  • For free-form source: .f90
  • For fixed-form source: .f, .for, .fpp

Other file types are not supported by default but can be optionally enabled.  See Adding Fortran File Types in Visual Studio below for more information.

The cause of the problem of Fortran source files being ignored is usually a blank list of file types in the Visual Studio options dialog for Fortran source files. Sometimes this happens immediately after a new install of the compiler.  It has also been seen when the install was done under one username but compilations are done under another.

The solution varies slightly by Visual Studio version.

Microsoft Visual Studio 2017, 2015, 2013, 2012 and 2010

Open Microsoft Visual Studio. Select Tools > Options > Intel Compilers and Tools > Visual Fortran > General. (In older versions the levels after Options may be "Intel Composer XE > Visual Fortran > General" or "Intel Visual Fortran > General") You should see a property page that looks similar to this:

For each of the Headers and Sources under Fixed Format Extensions and Free Format Extensions, click on the property to highlight it and then click on the "..." button to the right, indicated by the red arrow in the image above. You should then see a dialog that looks similar to this:

If the "Reset to default" button is enabled (not grayed out), click it.  Then click Ok. Repeat this for each of the "Extensions" fields. Then click Ok on the Options dialog. Close and restart Visual Studio.  This should correct the problem.

Microsoft Visual Studio 2008, 2005 or 2003

Open Visual Studio and select Tools > Options > Intel Composer XE > Visual Fortran > General. (If using Intel Visual Fortran Composer XE 2011 or an earlier version of Intel Visual Fortran Compiler Professional Edition, select Tools > Options > Intel Visual Fortran > General.) You should see a property page that looks similar to this:

Click on each of the two Reset buttons as indicated by the red arrows in the image above, then click OK. Exit and restart Visual Studio. This should correct the problem.

Adding Fortran File Types in Visual Studio

Using non-standard file types for Fortran source files is not recommended, as it impairs portability. In particular, the file type .f90 does not mean "Fortran 90" but rather it identifies a source file that should be treated as free-form source. Using file types to indicate other attributes, such as which revision of the Fortran standard the source is written to, should be avoided. However, if you wish to add file types, you can do so in Visual Studio.

Follow the instructions above pertaining to the Visual Studio and Intel compiler version you are using. However, instead of clicking the Reset button, add your desired file type to the lists for source files, under the appropriate choice of Fixed Form or Free Form. If typing in the text field, values are separated by semicolons. If you click on the "..." button to add values, add the new file type, with the leading dot, on a new line.  Then click OK to save the changes, exit and restart Visual Studio.

These settings affect how the Visual Studio editor "colors" Fortran source files and how files of the given file types are compiled. For "Header" file types, it controls editor behavior only.

Questions or Problems?

If you need additional assistance, please visit Intel Online Service Center or Intel Fortran User Forum for help.

For more complete information about compiler optimizations, see our Optimization Notice.