Skip to main content
Jump to: navigation, search


< PTP‎ | photran‎ | documentation
Revision as of 14:31, 22 July 2009 by (Talk | contribs) (Setting bookmarks)

You are here: PTP > Photran > Documentation > Photran 5.0 User's Guide

Photran 5.0 User's Guide

IMPORTANT: PHOTRAN 5.0 HAS NOT BEEN PUBLICLY RELEASED. This is PRELIMINARY documentation for Photran 5.0's release in September, 2009. Parts of it DO NOT APPLY to the currently-available release.

Installing Photran

System Requirements

To install Photran 5.0...

You must have Eclipse 3.5 (Galileo) installed.

  1. You should have the C/C++ Development Tools (CDT) 6.0 installed. If you do not, they will be installed automatically when you install Photran.
  2. Eclipse must be running on a Java 1.5 or later Java Virtual Machine (JVM). To get reasonable performance, we recommend Sun's JVM [1] or IBM's [2]. GNU Classpath (the default JVM on Fedora Linux) is generally too slow to be useful.
  3. If you want to compile and build Fortran applications, you must have a make utility and a Fortran compiler in your system path. Many Linux/Unix systems include these; details on installing them in Windows and Mac are below.

Installation Procedure

To install Photran, start Eclipse, then...

  1. Download the latest Photran zip file from [3]
  2. Click on Help > Software Updates...
  3. Click on the "Available Software" tab
  4. Click on "Add Site..."
  5. Click Archive...
  6. Choose the zip file you downloaded from [4]
  7. Click OK to close the Add Site dialog
  8. The zip file should appear in the list as jar:file:/path/to/photran-master-4.0.5-something. Expand it.
  9. Expand "Photran (Eclipse Fortran Development Tools)" and check the box next to "Photran (Eclipse Fortran Development Tools)"
  10. If you are running Linux and have the Intel Fortran Compiler installed, or if you are on a Macintosh and have the IBM XL Fortran compiler installed, expand "Photran Compiler Support" and select the appropriate compiler.
  11. Click on the "Install..." button in the upper-right corner of the dialog box.

Additional Instructions for Windows Users

To compile and run Fortran programs in Photran, you will need to have a Fortran compiler and make utility installed. Most Linux/Unix distributions include these; gfortran is commonly used (and free). Under Windows, you will need to install Cygwin [5] or MinGW [6] and put them on your Windows PATH.
Instructions for Cygwin:

  1. Install [Cygwin]; the defaults are mostly OK, but you will need to explicitly tell it to include the "Devel" packages (at least gcc4-fortran, gdb, and make) when the installer asks you to select what packages to install. (If gcc4-fortran is not listed under the "Devel" packages, you may have chosen a bad mirror; restart the Cygwin installation, and choose a different mirror instead. Georgia Tech's mirror at is generally quite fast and reliable, for example.)
  2. Add the Cygwin directories to your Windows PATH. Under Windows XP, the process is as follows:
    1. Make sure you are logged in under an administrator account.
    2. Open the Control Panel.
    3. Double-click the System icon.
    4. Switch to the Advanced tab.
    5. Click the Environment Variables button.
    6. Under System Variables, find the variable "Path" in the list, and click on it.
    7. Click Edit.
    8. At the end of the "Variable Value" text, add
    9. Click OK, click OK, click OK, and close the Control Panel.
    10. Close and re-open Photran. Windows should now search C:\Cygwin\bin, C:\Cygwin\usr\bin, etc. when it's looking for executables (including make.exe, gcc.exe, and gfortran.exe).

Additional Instructions for Mac OS X Users

If you install gfortran on Mac OS X, it may be installed in /usr/local/bin, which is not (by default) on the PATH. If you are launching Eclipse from a Terminal, the PATH can be set by modifying /etc/paths. However, if you are launching Eclipse from the Finder (by double clicking on it) or the Dock, then the PATH is not obtained from the shell or /etc/paths. Instead, it's obtained from ~/.MacOSX/environment.plist. The format of the environment.plist file is as follows (change the path appropriately). If you create or edit this file, you will need to log out (or reboot) before the changes will take effect.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "">
<plist version="1.0">

Getting Started

Photran is an integrated development environment and refactoring tool for Fortran 77, 90, 95, and 2003. It includes an editor with "smart" syntax highlighting, a GUI debugger, CVS support, Makefile-based compilation, error message recognition for many common Fortran compilers, Fortran language-based search and code navigation, content assist, a Fortran declaration view, and many refactorings, including popular refactorings such as Rename and Extract Procedure as well as Fortran-specific refactorings like Introduce Implicit None.

Photran is based on Eclipse, and some of its components are reused from the Eclipse C/C++ Development Tools (CDT). Throughout this documentation, you will see references to relevant parts of the Eclipse and CDT documentation, which can be accessed by clicking on the Help menu (inside Photran/Eclipse) and clicking Help Contents.

If you have never used Eclipse before, please work through the Eclipse Workbench tutorial before attempting to use Photran. Click on Help > Help Contents in Eclipse, and navigate to Workbench User Guide > Getting started > Basic tutorial. This will introduce you to Eclipse concepts such as perspectives and views; such terminology will be used throughout this manual.

Starting a New Project

One of the advantages (or disadvantages) of using Photran is that it does not include a Fortran compiler. Instead, it uses make to compile Fortran programs. This allows you to use any Fortran compiler you want, but it also means that a Makefile must be written which tells the make program how to compile your Fortran program.

  • For small, simple projects, Photran can auto-generate a Makefile which will use the GNU Fortran compiler (gfortran).
  • For more complex projects, you can write a custom Makefile.

For more information on project types, click on Help > Help Contents in Eclipse, and navigate to C/C++ Development User Guide > Concepts > CDT Projects.

Starting a Project with an Auto-Generated Makefile

The following is a typical procedure for starting a new project using an auto-generated Makefile. Your system must have the GNU Fortran (gfortran) compiler installed for this procedure to work. To make sure that gfortran is installed, you can open a command prompt (Windows) or terminal window (Linux/Mac) and type "gfortran" (without the quotes); it should respond with "gfortran: no input files".

  1. Click File > New > Fortran Project
  2. Call it HelloFortran
  3. Choose "Executable (Gnu Fortran)" from the project type list
  4. Choose "GCC Toolchain" from the toolchain list (you may need to first uncheck the "Show project types..." check box at the bottom of the window before you can see this)
  5. Click Next
  6. Click on Advanced Settings
  7. Expand C/C++ Build in the list on the left, and click on Settings
  8. Click on the Binary Parsers tab. Check the appropriate parsers for your platform. If you are using Windows, check PE Windows Parser and/or Cygwin PE Parser; if you are using Linux, check Elf Parser; if you are using Mac, check Mach-O parser.
  9. Click on the Error Parsers tab. Check the error parser(s) for the Fortran compiler(s) you will use.
  10. Click OK
  11. Click Finish
  12. Click File > New > Source File
  13. Call it hello.f90; click Finish
  14. Type the standard "Hello, World" program shown below, and click File > Save.
  15. Open the Console view, and make sure "make" ran OK and compiled your program
  16. In the Fortran Projects view, expand the Binaries entry, and click on your executable (e.g., "HelloFortran.exe - [x86le]")
  17. Run | Run As | Run Local Fortran Application
  18. Choose GDB Debugger (Cygwin GDB Debugger if you're under Windows)
  19. Check the Console view, and make sure "Hello World" appeared.


program hello
    print *, "Hello World"
end program

Starting a Project with a Hand-Written Makefile

The following is a typical procedure for starting a new project using a hand-written Makefile. The following example uses the GNU Fortran (gfortran) compiler, but any Fortran compiler can be used instead. We will assume that you are familiar with how to write a Makefile. If not, there are plenty of resources on the Web, including a tutorial from an introductory Computer Science course at UIUC [7] and another from the University of Hawaii [8]... and, of course, you can always read the entire manual for GNU Make [9].

  1. Click File > New > Fortran Project
  2. Call it HelloFortran
  3. Expand "Makefile project" in the project type list (it has a folder icon), and choose "Empty Project"
  4. Select "-- Other Toolchain --" in the toolchain list in the right-hand column, and click Next
  5. Click on Advanced Settings
  6. Expand C/C++ Build in the list on the left, and click on Settings
  7. Click on the Binary Parsers tab.  Check the appropriate parsers for your platform. If you are using Windows, check PE Windows Parser and/or Cygwin PE Parser; if you are using Linux, check Elf Parser; if you are using Mac, check Mach-O parser.
  8. Click on the Error Parsers tab. Check the error parser(s) for the Fortran compiler(s) you will use.
  9. Click OK
  10. Click Finish
  11. Click File > New > Source File
  12. Call it hello.f90
  13. Click Finish
  14. Type the standard "Hello, World" program shown below.
  15. Click File > New > File
  16. Call it Makefile
  17. Click Finish
  18. Create a Makefile similar to the one shown below. Again, we assume you are familiar with the structure of a Makefile. You cannot simply copy-and-paste this example because the gfortran and rm lines must start with a tab, not spaces. The -g switch instructs gfortran to include debugging symbols in the generated executable so that it can be debugged later. The -o switch tells it what to name the generated executable.
  19. Click Project > Clean, then click OK
  20. Open the Console view, and make sure "make" ran OK and compiled your program
  21. In the Fortran Projects view, expand the Binaries entry, and click on your executable (e.g., "hello.exe - [x86le]")
  22. Click Run > Run As > Local Fortran Application
  23. Choose GDB Debugger (Cygwin GDB Debugger if you're under Windows)
  24. Check the Console view, and make sure "Hello World" appeared.


program hello
    print *, "Hello World"
end program

Makefile: (You MUST replace the spaces beginning the gfortran and rm lines with a tab character!)

        gfortran -o hello.exe -g hello.f90

        rm -f hello.exe

Writing Code

The Fortran Perspective

When you write Fortran code, ordinarily you will work in the Fortran perspective. When you create a new Fortran project (as described above), the wizard will ask if you want to switch to the Fortran perspective, or you can do it manually by clicking Window > Open Perspective > Other... and selecting Fortran from the list.

For more information on perspectives, click on Help > Help Contents in Eclipse, and navigate to Workbench User Guide > Concepts > Perspectives. Perspectives are also covered in the Eclipse tutorial, which can be found in Workbench User Guide > Getting started > Basic tutorial.

In particular, note that you can add views to a perspective by clicking Window > Show View > Other... and selecting a new view from the Show View dialog. You can also reset the current perspective to its original layout: From the menu bar, choose Window > Reset Perspective.

By default, the Fortran perspective contains a central area for editing code, as well as the following views:

  • The Fortran Projects view displays your project(s) and any files and folders in it.
  • The Problems view will show errors from your Fortran compiler, if Photran can recognize them. (This requires configuring an error parser, described elsewhere in this manual.)
  • The Console view shows the output from your Fortran compiler. When you run your Fortran program, its output is also displayed in the Console view.
  • The Fortran Declaration view is described in the Photran Advanced Features manual.
  • The Outline view shows the high-level structure of your program, i.e., the subprograms, modules, derived types, etc. comprising it.
  • The Make Targets view allows you to quickly run make on a particular target defined in a custom Makefile.

For more information on the Make Targets view, click on Help > Help Contents in Eclipse, and navigate to C/C++ Development User Guide > Reference > C/C++ Views and Editors > Make Targets view.

The Fortran Projects View

The Fortran Projects view displays project files in a tree structure. In this view you can do the following:

  • Open files in the Fortran editor
  • Manage existing files (cut, paste, delete, move or rename)
  • Create new projects, files, or folders
  • Import or Export files and projects
  • Browse the high-level structures in Fortran files
  • Open projects in a new window
  • Perform some multi-file refactorings (such as Introduce Implicit None; see the Photran Advanced Features Manual)

Files can be opened by double-clicking on the filename or by right-clicking on the file and choosing "Open With" from the context menu. Most other actions are performed by right-clicking on the file and choosing an action from the context menu.

The Fortran projects view is similar to the C/C++ Projects View. For more information on the Fortran Projects view, refer to the documentation on the C/C++ Projects view by clicking on Help > Help Contents in Eclipse and navigating to C/C++ Development User Guide > Reference > C/C++ Views and Editors > C/C++ Projects view.

Configuring Content Types: Free vs. Fixed Form

Photran supports both fixed-form and free-form Fortran code. Each source form has its own editor.

Fixed form is an older form designed for punch cards. It is more common in Fortran 77 and earlier programs, although it is still part of Fortran 2003. In fixed form, a "c", "C", "*", or "!" in column 1 indicates a comment; columns 1 through 5 are used for a statement label; a character in column 6 indicates a continuation line; and program statements are contained in columns 7 through 72. Anything after column 72 is ignored.

Photran uses filename extensions to determine whether a file is in fixed- or free-form. By default, .f, .fix, .for, .fpp, and .ftn are assumed to be in fixed source form, while .f03, .f95, .f90, and .f77 are assumed to be in free source form. Additional extensions can be added to this list by changing the Eclipse Content Type preferences.

For more information on configuring content types, click on Help > Help Contents in Eclipse and navigate to Workbench User Guide > Reference > Preferences > Content Types.

Using the Fortran editor and Fortran perspective

Selecting free vs. fixed form

Free Form Fortran Editor

Photran has different editors for free- and fixed-form files. The free-form editor is pictured above. The fixed-form editor has vertical bars delineating column six and marking the right-hand side of column 72; it is pictured below.

When you double-click on a file in the Fortran Projects view, Photran will open it in either the free- or fixed-form editor according to its filename extension. (See the previous section on how to customize this.)

You can explicitly choose whether to open a file in the free-form or fixed-form editor by right-clicking on the file in the Fortran Projects view and selecting either Open With > Fortran Editor (Fixed Form) or Open With > Fortran Editor (Free Form). Opening free-form code in the fixed-form editor (or vice versa) will result in a watermark reading "Warning: Content Type Mismatch" being displayed in the upper right corner of the editor.

Do not ignore the "Warning: Content Type Mismatch" watermark. Photran always uses the content type of the file to populate the Outline view and to operate the features described in the Advanced Features Manual. So if you are editing a fixed form file but this watermark is being displayed, Photran thinks it is a free form file. You MUST change the content types in the Eclipse preferences, as described in the previous section, for the Outline view to display and for any of the advanced features to work.

Fixed Form Fortran Editor

Outline view

Outline View

When a Fortran file is open in the Fortran editor, the Outline view shows an outline of the structural elements of that file: subprograms, main programs, modules, derived types, etc. The Outline view notes the content type of the file (free form or fixed form); it will also note when there is an error in the code. To add the Outline view to the current perspective go to Window > Show View > Other... > General > Outline.

Outline Error

Overview of the Fortran editors

The free form and fixed form editors generally support the same features. The main features to note are the horizontal ruler at the top of the editor, code folding, and smart syntactic highlighting.

The horizontal ruler measures the width of the editor in characters: There is either a symbol (-/+) or number for each column in the editor. A plus sign (+) is shown every fifth character, and every tenth character is numbered. It is also possible to turn on the print margin (gray vertical line) in the 80th column; this is discussed further below in the section titled "Configuring the Editor."

Editor Ruler

Code folding is also supported in the free form editor, but turning on code folding will disable the horizontal ruler; how to do this is described below as well. When folding is turned on, a minus sign (-) will be displayed in the left margin of the editor next to each program, function, subroutine, etc.; clicking on the minus sign will temporarily collapse the display of that entity to a single line.

Editor Folding

The editors also support smart syntactic highlighting. As you write programs in Fortran, you will notice that different colors are applied to comments, identifiers, intrinsics, keywords, and strings to make code more readable. It is possible to change the colors for each of the previously mentioned code components in the Fortran editor preferences (this is discussed in the section "Configuring the Editor," below). Often, the editor can even distinguish between, for example, the keyword "if" and a variable named "if." However, it is not perfect; it uses a faster, but less reliable, heuristic than the actual Fortran parser that drives the Outline view and all of the Advanced Features.


Photran can comment or uncomment a block of Fortran statements, placing an exclamation point (!) before the statements or removing it, respectively. Select the statements in the Fortran editor. Then right-click the selection, and choose Comment/Uncomment from the context menu.


Setting bookmarks

Bookmarks are an Eclipse feature which allows you to mark important lines in a file and then quickly jump to those lines using the Bookmarks view. To set a bookmark, right-click the grey bar on the left side of the editor at the line where the bookmark should be located and select "Add Bookmark..." from the popup menu. A bookmark can also be placed on a line by locating the cursor on the line, going to Edit > Add Bookmark... in the menu bar. Type in the desired name for the bookmark in the dialog box and click OK. A blue bookmark will show up in the grey bar on the left side of the editor.

Bookmarks can then be viewed in the Bookmarks view (Window > Show View > Other..., select Bookmarks in the General folder).

Go to line (Ctrl+L)

To navigate to a specific line of code in the editor, there are two ways to access the "Go To Line..." feature. Open the file to navigate and

while the editor window is active, in the menu bar, go to Navigate > Go To Line... or press Ctrl+L to open the Go To Line dialog box. Typing in the line you wish to navigate to and clicking OK will locate the cursor at the beginning of the specified line and jump to that location.

Configuring The Editor

Selecting horizontal ruler vs. folding

The horizontal ruler at the top of the editor is enabled by default. To enable code folding and disable the horizontal ruler, go to Window > Preferences in the menu bar. Expand Fortran and select Editor. Check the appropriate box(es) to enable folding in the free-form and/or fixed form Fortran editor.

Setting Colors for syntax highlighting

The colors for Fortran syntax highlighting can be modified in the Fortran editor preferences. To modify the color settings, go to Window > Preferences in the menu bar. Expand Fortran and select Editor. The color choosers for Comments, Identifiers, Intrinsics, Keywords, and Strings are available on this page.

Showing Print Margin

To enable display of the print margin (column 80 in the editor) go to Window > Preferences in the menu bar. Under General, expand Editors, and select Text Editors. Check the box for "Show print margin". Click Apply and the print margin should now display in the editor.

Converting Tabs to spaces

To enable conversion of Tabs to spaces, go to Window > Preferences in the menu bar. Under General, expand Editors, and select Text Editors. Check the box for "Insert spaces for tabs" to have Eclipse automatically convert Tabs to spaces.

Show whitespace

Whitespace characters can be displayed by going to Window > Preferences. Under General > Editors > Text Editors, check the box next to "Show whitespace characters" and click Apply. Whitespace characters will now show up in the editor as grey dots.

Set Font

Changing font in the Fortran editor is currently not supported.

Show line numbers

Line numbers can be displayed in the editor in the Text Editor preferences page. Go to Window > Preferences. Under General > Editors > Text Editors, check the box "Show line numbers" and click Apply.

Compiling Fortran Programs

Photran allows you to build projects with automatically generated Makefiles as well as custom makefiles, which allow the use of compilers other than gFortran which is Photran's default Fortran compiler. Photran also comes packaged with support for Intel's Fortran compiler and IBM's XLF compiler.

When you create a new Fortran project, you will be asked to name your project as well as choose a type and toolchain.

  • To use an automatically generated makefile, choose "Executable (Gnu Fortran)" from the Project type menu. Yo may need to uncheck the box below reading "Show project types and toolchains if they are supported on the platform" in order to be able to select the GCC toolchain in the toolchain selection box.
  • To create a project using your own custom makefile, in the project type selection box, expand the Makefile Project folder, and select Empty Project. Name the project and select the toolchain of your choise (For example, Windows users will likely choose Cygwin GCC).
Choosing a Fortran project type


Building Fortran projects is very similar to Building C/C++ Projects.

Check out the Documentation to find out more about the required tools and other information (like Makefiles and build settings) about building projects.

Setting make targets

Setting make targets for Fortran programs is the same as make targets with CDT. Refer to the previous link for an easy guide to creating make targets and more information on creating make targets.

Error parser

In order to get feedback about any errors in your Fortran programs, you will need to have some Error parsers selected in your Fortran project's build settings. To modify these settings, right-click on your Fortran project, go to Properties > Fortran Build > Settings and select the Error Parsers tab. A list of error parsers available to you is displayed.

You will notice that most of the default error parsers are the CDT parsers, which is partly why Photran requires CDT to be installed in your Eclipse environment. Select the error parser(s) you wish to use (usually depending on which compiler you are using) and click Apply and/or OK.

Fortran Error Parsers

Binary parsers - need to change if no "Run as Local Fortran App" menu item

In order to actually be able to compile and run your Fortran application, you will need to tell Eclipse which Binary Parser(s) to use for your project. This can be done in the project properties (Right-click project > Properties > Fortran Build > Settings > Binary Parsers Tab).

Which binary parser you want to use will depend on the operating system environment you are working in. For example, the default choice is the Elf Parser which is for Linux environments. Windows users would need to deselect the Elf Parser and select the PE Windows Parser and/or the Cygwin PE Parser.

Fortran Binary Parsers
Run as Local Fortran Application

Running and Debugging Fortran Programs

If you want to simply run a Fortran application, you can right-click the project in the project explorer > Run As > Local Fortran Application. This will build and run the Fortran application and output will be printed to the console. Note: If you are using a custom makefile, the makefile will need to be written correctly so the project can be built.

If you want to manage the run configuration, such as adding arguments or environment variables, Right-click your project in the explorer > Run As > Run Configurations... Create a new launch configuration under Fortran Local Application and modify the settings as needed to meet your run configuration specification.

Debugging programs works similarly, except Right-Click your project > Debug As > Local Fortran Application or Debug Configurations. Note that if you create a new Run/Debug configuration for your project, there is a Debug tab where you can choose the debugger you wish to use. GDB is the default debugger used by Photran.


Running and Debugging Fortran applications is similar to running and debugging C/C++ applications.

Refer to the documentation for a more detailed guide to run/debug configurations.

Setting breakpoints

There are two ways to set breakpoints in the editor view.

The easiest way to set a breakpoint in the editor is to double click in the left margin (gray vertical bar) on the line at which you wish to set the breakpoint. A blue dot will appear in the margin on the line where the breakpoint is set. Double clicking again at the same location will remove the breakpoint.

You can also set a breakpoint by right-clicking in the left margin on the line where you wish to set the breakpoint and clicking "Toggle Breakpoint." The blue dot indicating the breakpoint will appear or disappear (if already set) in the left margin of the editor.

Setting Breakpoints

Known Run/Debug Issues

When using Cygwin in Windows, Debugging a program can result in a "cannot find gcc source" error as described in 280492. Note that this error does not have an effect on the running of the program. The program will still run correctly in Debug mode.

Compiler-specific problems


In debug mode, using the step button to step through the code line-by-line sometimes jumps ("leapfrog" effect) around in the source code editor view. For example, pressing F6 (step) after a breakpoint several times, might sometimes result in a jump to line 1 and stepping again will return to the correct line in the code.


No known issues.

Intel Fortran Compiler

No known issues.


No known issues.

Advanced Features

Photran 5.0 includes a number of sophisticated features that are designed to make it easier to write, modify, search, and maintain Fortran code. These include content assist, which can "auto-complete" variable and function names as you type; a declaration view, which can show the leading comments for the selected variable or procedure; Fortran Search, which allows you to find declarations and references to modules, variables, procedures, etc.; and refactorings, which change your source code to improve its design while preserving its behavior.
Documentation for Photran's advanced features is available here.


If you are experiencing troubles with installing or working with Photran, you might want to check out our FAQ[10]

And if you don't find your answer there, feel free to e-mail them to our Mailing List[11]

Beyond Photran


  • Using Photran with other Eclipse plug-ins
    • Subversion support
    • PTP/RDT
    • RSE

Back to the top