Porting Compaq Visual Fortran 6.6 projects to MS Visual Studio .NET 2003

The CTC is in the process of phasing out Microsoft Visual Studio 6. Once this occurs, Compaq Visual Fortran will no longer be available. It will be replaced with the Intel 8.1 Fortran compiler, which is integrated into Microsoft Visual Studio .NET 2003. This document will provide a guide to converting Compaq Visual Fortran 6.6 projects to Intel Fortran in Visual Studio .NET 2003. It pertains only to Visual Studio. The steps listed work for both serial and parallel codes. If you use the command-line implementation of Fortran, it does not apply to you. The advantage of converting your project, rather than rebuilding it from scratch, is that you will not need to redo the steps involved in creating a new project.
 
As the first project conversion, use the default "Hello World" project to make sure that you understand the procedure. Use either ctclogin1 or ctclogin4, the two login nodes that still have Visual Studio 6. To build such a project, open Visual Studio 6 and navigate File | New | Projects | Fortran Console Application. Supply a project name and location. Then click OK. Select A "Hello World" sample project. Then Finish and OK. The new project is open. Build the project and execute it. The output in a new command window should be Hello World.

As a precaution, make a backup copy of your projects before you convert them. Do this both for the Hello World project and your research projects.
 
  1. Open your project in Visual Studio .NET 2003 on a machine that has Intel 8.1 Fortran installed. This will be on a login node or in the collaboratory.
  2. Say yes when told that you have to convert the project, even though the discussion is for Visual C++.
  3. Right click on the project name in Solution Explorer.
  4. Click on Extract Compaq Visual Fortran Project Items. If there are files that can't be processed, they may not be in the build. Files that will be in the build have an arrow pointing down in the icon to the left of the file name. To add a file to the build, right click on the file | select Properties | Build. Set Exclude File From Build to No.
  5. Build the project and check for a .exe file. If you didn't Extract Compaq Visual Fortran Project Items in the previous step, it may still look as though your project has built successfully. However it didn't and there will not be a .exe file.
  6. Execute by clicking on Debug and then Start Without Debugging.
  7. Open the project and observe that there is a .vfproj file as well as a .vcproj file.
    Not everything gets translated, but it comes close enough to make it fairly easy to get it working. One thing that isn't so neat is that if the original project had been set up to use the Intel Fortran compiler (using the Intel Fortran build tool) the source files have their "custom build step" property enabled. This has to be disabled on a file-by-file and configuration-by-configuration basis in the converted project.
 
Comparison of Intel 8.1 Fortran with Compaq Fortran
 
Allocation of variables
Compaq Fortran's default behavior is /Qsave, static allocation of variables. The Intel 8.1 Fortran default is /Qauto, which makes all local variables automatic. If your program ran correctly with Compaq, but generated the following error message with Intel, "forrtl: severe (157): Program Exception - access violation", try using the /Qsave flag.
  • You may see differences in the behavior of your code, even without seeing an error message. This could occur for a code that sets a local variable in a subroutine and depends on that value upon a subsequent call to the routine. /Qsave causes persistence of variables between subroutine calls.
  • As an alternative, you may wish to allocate and deallocate memory using Fortran 90/95 syntax. Variables that are declared "allocatable" will be saved in memory between subroutine calls if their declarations include the "save" attribute. This alternative requires rewriting the relevant declarations in Fortran 77 or earlier code and adding "allocate" and "deallocate" commands.
Stack size
The maximum amount of data that can be put on the stack may be different and possibly insufficient. If you encounter the following runtime message,"forrtl: severe (170): Program Exception - stack overflow", then you need to increase the space on the stack. You do this by setting the option /F<n>, where n is the number of bytes. (The Intel compiler passes this option to the linker.) The default is 1048576 bytes, or 1 MByte.
 
If you have any questions, please send electronic mail to consult@tc.cornell.edu or call (607) 254-8686 and press 2 to speak to a consultant.