Using Visual Fortran 6.6

Compaq has donated a license for Compaq Visual Fortran 6.6 to the physics department. For use in the physics department, the compiler has been installed on the PHYSICS server. It can be used in the Physics Library as well as Olin 221 and 224 labs. The Department of Information Technology has also installed it on the computers in the main Olin lab

 Overview of Building Projects

The Microsoft® Visual Studio development environment (also called Developer Studio) organizes development into projects. A project consists of the source files required for your application, along with the specifications for building the project. The build process involves defining your project, setting options for it, and building the program or library.

Each project can specify one or more configurations to build from its source files. A configuration specifies such things as the type of application to build, the platform on which it is to run, and the tool settings to use when building. Having multiple configurations lets you extend the scope of a project but still maintain a consistent source code base from which to work.

When you create a new project, the Microsoft visual development environment automatically creates Debug and Release configurations for you. The default configuration is the Debug configuration. To specify the current configuration, select Set Active Configuration from the Build menu.

Projects are contained in a workspace. When you create a new project, you indicate whether the project is created in a new workspace or an existing workspace. To open an existing project, you open its workspace. A workspace can contain multiple projects.

Once you open a workspace, the development environment displays a FileView pane, which displays the files contained in the project, and lets you examine visually the relationships among the files in your project. Modules, include files, or special libraries your program uses are automatically listed as dependencies. The output window displays information produced by the compiler, linker, Find in Files utility, and the profiler.

You can specify build options in the Project menu Settings dialog box, for one of the following:

For example, you can specify certain kinds of compiler optimizations for your project in general, but turn them off for certain configurations or certain files. You can also specify additional libraries to be used at link time (e.g. pgplot.lib) to add previously compiled subroutines to your program,

Once you have specified the files in your project, the configurations that your project is to build, and the tool settings for those configurations, you can build the project with the commands on the Build menu.

 Types of Projects

When you create the project, you must choose a project type. You need to create a project for each binary executable file to be created. For example, the main Fortran program and a Fortran dynamic-link library (DLL) would each reside in the same workspace as separate projects.

The project type specifies what to generate and determines some of the options that the visual development environment sets by default for the project. It determines, for instance, the options that the compiler uses to compile the source files, the static libraries that the linker uses to build the project, the default locations for output files, defined constants, and so on.

You can build six kinds of projects with Visual Fortran. You specify the project type when you create a new project. They are summarized in the following table:

Project type

Key features

Fortran Console Application (.EXE)

Single window main projects without graphics (resembles character-cell applications). Requires no special programming expertise.

Fortran Standard Graphics Application (.EXE)

Single window main projects with graphics. The programming complexity is simple to moderate, depending on the graphics and user interaction used. Samples of Standard Graphics Applications (QuickWin single window) resemble those for QuickWin Applications (see below).

Fortran QuickWin Application (.EXE)

Multiple window main projects with graphics. The programming complexity is simple to moderate, depending on the graphics and user interaction used.

Fortran Windows Application (.EXE)

Multiple window main projects with full graphical interface and Win32 API functions. Requires advanced programming expertise and knowledge of the Win32 routines API.

Fortran Static library (.LIB)

Library routines to link into .EXE files.

Fortran Dynamic-Link Library (.DLL)

Library routines to associate during execution.

The first four projects listed in the preceding table are main project types, requiring main programs. The last two are library projects, without main programs.

Making Your First Project (Hello World)

  1. Open your Z: folder on the Gustavus network. You should probably make a folder "Fortran" to store all of your programs (because there will be a lot of them by the end of the semester) First start the Visual Studio Program
  2. Select File->New then under the Projects Tab, select Fortran Console Application
  3. In the Location Blank, select Z:\Fortran\ (if this is where you made your Fortran folder).
  4. In the Project Name Blank, type in Hello. You will note that this will create a folder Z:\Fortran\Hello as the location for the project.
  5. Select OK. Also select "Create an Empty Project" and Finish. Select OK (when it says that it is creating a skeleton project).
  6. It will come up with an empty developers window (with no files).
  7. Select Project->Add to Project->New and then on the New Menu File tab, select F90 (Fortran Free Format Source File). For the file put in a name such as hello_world and select OK. This will create a source code file hello_world.f90 in the directory Z:\Fortran\hello.
  8. Now you can start typing your program into the white window for the source code.
  9. Once typed in, the screen might appear as follows (the ClassView tab only appears if Visual C++ is also installed):
  10. When done, save your file.
  11. To build the executable file, select Build->Rebuild All or select the icon
  12. To execute your program, select Build->Execute or select the icon

Preparing Your Program for Debugging

To prepare your program for debugging when using the Microsoft visual development environment:

  1. Open the appropriate Workspace (File menu, either Open Workspaces or Recent Workspaces).
  2. Click the FileView pane.
  3. To edit the source file to be debugged, double-click on the file name.
  4. Click the Project name.
  5. In the Build menu, click Set Active Configuration and select the debug configuration.
  6. To check your Project Settings, in the Project menu, click Settings, then click the Fortran tab.
  7. To compile your program:
  1. Eliminate any compiler diagnostic messages in the text editor and recompile if needed.
  2. To build your application, in the Build menu, click Build file.EXE.
  3. Set breakpoints in the source file and debug the program.

 Debugging Your Program

  1. Click the first executable line to set the cursor position.
  2. Click on the Set/Remove Breakpoint (open hand symbol) button in the Build toolbar: The red circle in the left margin of the text editor/debugger window shows where a breakpoint is set.
  3. The debugger is now active. The current position is marked by a yellow arrow at the first executable line (the initial breakpoint):
  4. The Debug menu appears on the visual development environment title bar in place of the Build menu. If not displayed previously, the Debug toolbar appears.
  5. If needed, you can set another breakpoint, position the cursor at the line where you want to add or remove a breakpoint and do either of the following:
  1. Step through the lines of source code. You can do this with the Debug menu item Step Over (as shown) or the Step Over button on the Debug toolbar. Repeat the Step Over action and follow program execution. Position the cursor over any variable to view its value (called Data Tips).
  2. To view the values of certain variables as the program executes, we need to display the Variables or the Watch window. In the View menu, click the Debug Windows, Variables window item. In the Variables window, click the Locals tab to display the values of your local variables. To display non-local variables, display the Watch window. The Watch window also allows you to display expressions.
  3. If you have modified the source, you need to rebuild the application:

Viewing Fortran Data Types in the Debugger

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


Electronic Copy:
Created: 1-JAN-00 by Steve Mellema, Physics Department, Gustavus Adolphus College.
Revised: 2-JAN-02 by Tom Huber, Physics Department, Gustavus Adolphus College.