A simple Fortran project

In order to get started we shall create a new project containing a very simple Fortran program. Select New and then Project from the main File menu.

Select FTN95 Projects from the Project Types. We shall call the project Project1. Choose a Location (that is a folder) for the project. Click on the OK button to create the project.

A new project is created which initially contains one file called FreeFormat1.f95. If you wish you can change the name of the file in the Solution Explorer window but we shall use the default name. To add other files to the project, in the Solution Explorer window, use the right mouse button to click on the Project1 item and then select Add New Item from the resulting popup menu.

Note the Build menu item in this popup menu that we shall use in a moment. Note also the item in the tree called References. This is used to provide references to additional libraries and DLLs when they are needed in the linking process. Further information can be found in the Visual Studio help contents and index. Select the type of the source file in the resulting dialog box and click on Open to create the file and to add it to the project.

Open FreeFormat1.f95, delete the default text and type in a simple program.

Now click on Build in the Solution Explorer popup menu (see above). The program is automatically compiled and linked and any error messages are reported in the Output window. After a successful build you can run the program by selecting Start without debugging from the main Debug menu (Ctrl+F5).

Tracking compilation error messages

If your program contains compilation errors, these appear as a Task list in the Output dialog. Double click on the build icon or the red exclamation icon in order to go to the error in the client area.

Changing between modes

When a project is created it is automatically set to be a .NET application in Debug mode. In order to change the mode, select an item from the Solutions Configurations drop-down list on the main toolbar.

Or select Configuration Manager from this list.

Choose a mode using the box at the top entitled Active Solution Configuration. Click on the arrow icon and select a mode from the drop down list. Release mode can be selected when a solution is ready for use/shipping. The debug and Checkmate modes plant debugging code that allows you to step into the code using the integrated debugger. The Checkmate mode is recommended for development.

The default configuration at project level reflects the Active Solution Configuration and should be left unchanged.

Note that you can also change from .NET to Win32. Most of the features of Visual Studio can be used to create Win32 as well as .NET applications and DLLs. You can even use ClearWin+ together with the Visual Studio image and dialog editors if you wish. The main difference is that, when the mode is set to Win32, a choice of debuggers is available. Win32 applications can be debugged using an integrated Visual Studio debugger or SDBG.

Using the debugger

The simplest way to get started using the FTN95 for .NET debugger is to set the cursor on a line in the program, click on the right mouse button and select Run to Cursor from the popup menu.

If you wait a few moments without touching anything you will get the following display.

Now press F10 to step over a line at a time viewing the changes to local variables as you proceed.

In addition to the display in the Locals window, you can also view the value of a variable by allowing the mouse cursor to hover over a point where the variable is used in the program. This causes a tooltip popup window to appear. This contains the value of the variable.

Another method is to click on the Watch 1 window and then click on the first cell in the Name column. Now type in the name of a variable you want to watch. The Quick Watch window is also useful. Select Quick Watch from the popup menu or from the main Debug menu. A Watch window is particularly useful when tracking non-local variables.

The call stack can be viewed from the Output dialog.

Once you are familiar with these basic methods, you can begin to experiment by setting break points and stepping into and out of procedures.

Changing the compiler options

So far we have used the default compiler command line options based on Checkmate. Options for a project can be changed from the Project Properties dialog. Click with the right mouse button on the Project1 item in the Solution Explorer window.

This displays the Project Properties dialog that contains a section like that shown below. Change the entries in this dialog in order to configure the project as a whole.

The Output File Type is one of EXE, DLL and MDL.

When using Visual Studio 2005, Visual Studio 2008 or Visual Studio 2010, an option is present to select the .NET Framework version to target. 4.0 and 2.0 are available.

The linker options can also be changed from this dialog box. To do this select Linker Options from the tree on the left hand side (see Using the linker in Visual Studio).

When your project contains a number of files, you can set different command line options for a particular file by using the File Properties window as follows.

Click with the left mouse button on the file freeformat1.f95 in the Solution Explorer window (or use the right mouse button and select Properties from the popup menu). Now look at the Properties dialog that normally appears below the Solution Explorer dialog. If the Properties Window is not visible, select Properties Window from the main View menu.

On the CustomCompilerOptions line, click on Off and the resulting arrow icon in order to view the options to Append to or Override the global project options. Now type in the options in the box labeled CustomSwitches. For example, if the project is set to debug rather than Checkmate mode then a particular file might be set to Checkmate using this option.


For further information see Changing compiler options from Visual Studio.



Copyright © 1999-2024 Silverfrost Limited