Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
PTP/photran/documentation/photran6
You are here: PTP > Photran > Documentation > Photran 6.0 User's Guide
Photran 6.0 User's Guide
Contents
- 1 Installing Photran
- 2 Getting Started
- 3 Starting a New Project
- 4 Upgrading Projects Created with Earlier Versions of Photran
- 5 Writing Code
- 5.1 Configuring Source Forms and Filename Extensions
- 5.2 Configuring Fixed Form Line Width
- 5.3 The Fortran Perspective
- 5.4 The Fortran Projects View
- 5.5 Using the Fortran editor and Fortran perspective
- 6 Compiling Fortran Programs
- 7 Running and Debugging Fortran Programs
- 8 Advanced Features
- 9 Troubleshooting
Installing Photran
System Requirements
To install Photran 6.0...
You must have Eclipse 3.6 (Helios) installed.
- You should have the C/C++ Development Tools (CDT) 7.0 installed. If you do not...
- If you downloaded Eclipse from eclipse.org and you will be following the instructions below for "Installing on a Machine With Internet Access," then CDT should be installed automatically when you install Photran.
- Otherwise, CDT probably will not be installed automatically. You will need to install CDT manually. Follow the instructions below for "Installing on a Machine Without Internet Access." You should also follow these instructions if you did not download Eclipse from eclipse.org (e.g., if you installed it from a Linux distribution like Ubuntu).
- 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 J9 [2]. OpenJDK (the default JVM on newer versions Fedora Linux) also works well, although GNU Classpath (the default JVM on older versions of Fedora) is generally too slow to be useful.
- If you want to compile and build Fortran applications, you must have a make program (such as GNU Make) and a Fortran compiler (such as gfortran, the GNU Fortran compiler) in your system path. Many Linux/Unix systems include these; details on installing them in Windows and Mac are below.
Installation Procedure
Installing on a Machine With Internet Access
To install Photran, start Eclipse, then...
- Click on Help > Install New Software...
- Click on the "Add..." button
- In the Location field, type http://download.eclipse.org/tools/ptp/releases/helios
- Click OK to close the Add Site dialog. This will return you to the Install dialog.
- Expand "Fortran Development Tools (Photran)" and check the box next to "Photran End-User Runtime"
- 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 "Fortran Compiler Support" and select the appropriate compiler. Note that you cannot install Intel Fortran compiler support unless you are running Linux!
- Click on the "Next" button
- If you get an error message, see below for troubleshooting information.
- Click the Finish button and agree to the license to complete the installation.
Installing on a Machine Without Internet Access
You will the following files:
- If you do not have CDT installed, you will need to download the latest 7.0.x "CDT master update archive" from http://download.eclipse.org/tools/cdt/releases/helios/). This should be a file named cdt-master-7.0.x.zip (for some value of x)
- To install Photran, you will need the latest PTP update site archive from http://wiki.eclipse.org/PTP/builds/4.0.0). This should be a file named ptp-master-4.0.0-I2010xxxxxxxx.zip
If you do not have CDT installed, start Eclipse, then...
- Click on Help > Install New Software...
- Click on the "Add..." button
- Click on the "Archive..." button
- Point it to the file cdt-master-7.0.x.zip
- Click OK to close the Add Site dialog. This will return you to the Install dialog.
- Expand "CDT Main Features" and check the box next to "Eclipse C/C++ Development Tools"
- Click on the "Next" button
- Click the Finish button and agree to the license to complete the installation.
- After CDT is installed, you will be asked to restart Eclipse. You may then proceed to install Photran.
To install Photran, start Eclipse, then...
- Click on Help > Install New Software...
- Click on the "Add..." button
- Click on the "Archive..." button
- Point it to the file ptp-master-4.0.0-I2010xxxxxxxx.zip
- Click OK to close the Add Site dialog. This will return you to the Install dialog.
- Expand "Fortran Development Tools (Photran)" and check the boxes next to "Photran End-User Runtime" and "Rephraser Engine End-User Runtime" (the latter is a supporting component)
- 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 "Fortran Compiler Support" and select the appropriate compiler. Note that you cannot install Intel Fortran compiler support unless you are running Linux!
- Click on the "Next" button
- If you get an error message, see below for troubleshooting information.
- Click the Finish button and agree to the license to complete the installation.
Troubleshooting
- Eclipse's installer gives notoriously cryptic error messages, which, unfortunately, are out of Photran's control. Some of the more common ones are below. If you run into a different error message and cannot resolve it, please ask for help on the Photran mailing list.
- Problem: You receive the following error message during installation.
- Cannot complete the install because one or more required items could not be found.
- Missing requirement: 125xxxxxxxxxx 0.0.0.125xxxxxxxxxx requires 'org.eclipse.photran.intel.feature.group [5.0.0.xxxx]' but it could not be found
- Solution: You are attempting to install support for the Intel Fortran compiler, but you are not running Linux. Go back in the installation wizard, and uncheck "Linux Intel(R) Fortran Compiler Support."
- Problem: You receive the following error message during installation.
- Cannot complete the install because one or more required items could not be found.
- Software being installed: Photran End-User Runtime 6.0.x.xxxxxxxxxxxx (org.eclipse.photran.feature.group 6.0.x.xxxxxxxxxxxx)
- Missing requirement: Photran VPG CDT Interface Plug-in 6.0.x.xxxxxxxxxxxx (org.eclipse.photran.cdtinterface.vpg 6.0.x.xxxxxxxxxxxx) requires 'bundle org.eclipse.cdt.core 0.0.0' but it could not be found
- Cannot satisfy dependency:
- From: Photran End-User Runtime 6.0.x.xxxxxxxxxxxx (org.eclipse.photran.feature.group 6.0.x.xxxxxxxxxxxx)
- To: org.eclipse.photran.cdtinterface.vpg [6.0.x.xxxxxxxxxxxx]
- Solution: You do not have CDT 7.0 installed, and it couldn't be downloaded and installed automatically. Try installing CDT 7.0 first, then retry installing Photran.
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. gfortran and GNU Make are commonly used (and free). Most Linux/Unix distributions include these. Under Windows, you will need to install Cygwin [3] (which optionally includes gfortran and GNU Make) or MinGW [4] and put them on your Windows PATH.
Instructions for Cygwin
- 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 gtlib.gatech.edu is generally quite fast and reliable, for example.)
- Add the Cygwin directories to your Windows PATH. Under Windows XP, the process is as follows:
- Make sure you are logged in under an administrator account.
- Open the Control Panel.
- Double-click the System icon.
- Switch to the Advanced tab.
- Click the Environment Variables button.
- Under System Variables, find the variable "Path" in the list, and click on it.
- Click Edit.
- At the end of the "Variable Value" text, add
;C:\Cygwin\bin;C:\Cygwin\usr\bin;C:\Cygwin\usr\local\bin;C:\Cygwin\lib;C:\Cygwin\usr\lib
- Click OK, click OK, click OK, and close the Control Panel.
- 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" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>PATH</key> <string>/usr/local/mpi/bin:/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin:/sbin:/usr/sbin:/Developer/Tools:/usr/texbin:/Users/greg/bin</string> </dict> </plist>
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".
- Click File > New > Fortran Project
- Call it HelloFortran
- Choose "Executable (Gnu Fortran)" from the project type list
- 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)
- Click Next
- Click on Advanced Settings
- Expand C/C++ Build in the list on the left, and click on Settings
- 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.
- Click on the Error Parsers tab. Check the error parser(s) for the Fortran compiler(s) you will use.
- Click OK
- Click Finish
- Click File > New > Source File
- Call it hello.f90; click Finish
- Type the standard "Hello, World" program shown below, and click File > Save.
- Open the Console view, and make sure "make" ran OK and compiled your program
- In the Fortran Projects view, expand the Binaries entry, and click on your executable (e.g., "HelloFortran.exe - [x86le]")
- Run | Run As | Run Local Fortran Application
- Choose GDB Debugger (Cygwin GDB Debugger if you're under Windows)
- Check the Console view, and make sure "Hello World" appeared.
hello.f90:
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 [5] and another from the University of Hawaii [6]... and, of course, you can always read the entire manual for GNU Make [7].
- Click File > New > Fortran Project
- Call it HelloFortran
- Expand "Makefile project" in the project type list (it has a folder icon), and choose "Empty Project"
- Select "-- Other Toolchain --" in the toolchain list in the right-hand column, and click Next
- Click on Advanced Settings
- Expand C/C++ Build in the list on the left, and click on Settings
- 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.
- Click on the Error Parsers tab. Check the error parser(s) for the Fortran compiler(s) you will use.
- Click OK
- Click Finish
- Click File > New > Source File
- Call it hello.f90
- Click Finish
- Type the standard "Hello, World" program shown below.
- Click File > New > File
- Call it Makefile
- Click Finish
- 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.
- Click Project > Clean, then click OK
- Open the Console view, and make sure "make" ran OK and compiled your program
- In the Fortran Projects view, expand the Binaries entry, and click on your executable (e.g., "hello.exe - [x86le]")
- Click Run > Run As > Local Fortran Application
- Choose GDB Debugger (Cygwin GDB Debugger if you're under Windows)
- Check the Console view, and make sure "Hello World" appeared.
hello.f90
program hello print *, "Hello World" end program
Makefile: (You MUST replace the spaces beginning the gfortran and rm lines with a tab character!)
all: gfortran -o hello.exe -g hello.f90 clean: rm -f hello.exe
Converting C/C++ Projects to Fortran Projects
Every Fortran project is also a C project, so CDT's functionality will work as expected on Fortran projects. However, a C/C++ is not a Fortran project until it has been explicitly converted. (In the Fortran Projects view, a Fortran project will have an "F" icon, while a C/C++ project will have a "C" icon.)
To convert an existing C/C++ project to a Fortran project:
- Switch to the Fortran perspective.
- In the Fortran Projects view, right-click on the project you want to convert, and select Convert to Fortran Project from the pop-up menu.
- The project should now have an "F" icon in the Fortran Projects view.
![Photran-f-vs-c-project.png](/images/a/ae/Photran-f-vs-c-project.png)
Upgrading Projects Created with Earlier Versions of Photran
There are three major changes in Photran 6 that affect users of previous versions of Photran:
- Projects must be converted to Fortran projects. In the past, Photran would treat C projects and Fortran projects similarly. In fact, in Photran 4 and earlier versions, Photran's new project wizard actually created C projects! But in Photran 6, many of Photran's features will only be available after a project is converted to a Fortran project. (Every Fortran project is a C project too, so CDT's features will still work on the project.) Learn how to convert projects.
- Project properties must be reset. Photran 6 uses a new mechanism for storing project properties. Unfortunately, this means that the project properties for old projects must be re-created. This includes enabling analysis/refactoring and setting include paths and module paths.
- Source form settings must be set for the project. Previous versions of Photran used Eclipse's workspace-wide settings to distinguish free and fixed form files. In Photran 6, each project has its own settings that determine which filename extensions correspond to free and fixed source form (and which files contain C preprocessor directives). Learn about source form settings.
Writing Code
Configuring Source Forms and Filename Extensions
Photran supports both fixed-form and free-form Fortran code. Photran also supports C preprocessor directives, such as #define, #ifdef, #include, __FILE__, and __LINE__ in Fortran code.
- 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. (Although column 72 is specified in the Fortran standard, most compilers allow you to change this to permit longer lines; Photran allows you to change it as well, as described in the next section.)
Photran uses filename extensions to determine whether a file is in fixed- or free-form and whether or not it is C-preprocessed. The default filename extensions are as follows.
Filename Extensions | Source Form/Preprocessing |
.f, .fix, .for, .fpp, .ftn .F, .F77, .FIX, .FOR, .FTN, .FPP, .fpp |
Fixed source form |
.f08, .f03, .f95, .f90 | Free source form with INCLUDE lines |
.F08, .F03, .F95, .F90 | Free source form with C preprocessor directives |
Configuring Source Form/Filename Extension Associations
The filename extensions listed above are the defaults for new Fortran projects. To change them:
- In the Fortran Projects view, right-click on a project, and choose Properties.
- In the tree on the left, navigate to Fortran General > Source Form.
- For each filename extension(s) you want to change, select the appropriate source form from the dropdown box.
- Click OK to close the dialog box.
![Photran-source-form-config.png](/images/b/bc/Photran-source-form-config.png)
Adding Additional Filename Extensions
Additional filename extensions can be added by changing the Eclipse Content Type preferences.
- Click on Window > Preferences... (Eclipse > Preferences... on Mac OS X).
- In the "Content types:" tree in the right pane, navigate to Text > Fortran Source File.
- Click the Add... button.
- To make all files with a ".fre" filename extension be recognized as Fortran source code, enter *.fre in the dialog. You can also specify individual filenames by omitting the *. prefix; for example, entering old-fortran-code.txt will make any file named old-fortran-code.txt be recognized as Fortran source code, but not other .txt files.
- Click OK to close the dialogs.
For more information on configuring content types, click on Help > Help Contents in Eclipse and navigate to Workbench User Guide > Reference > Preferences > Content Types.
Configuring Fixed Form Line Width
While free source form allows lines to be arbitrarily long, in fixed form, there is a predetermined maximum line width. Often, this is 72 characters (i.e., anything after column 72 is ignored and treated as a comment), although most compilers allow you to change this to permit longer lines. Photran allows you to change it as well.
To change the maximum line width in fixed form sources...
- Open the workbench preferences. On Windows or Linux, click Window > Preferences; on Mac OS X, click Eclipse > Preferences.
- Expand the Fortran category, and choose Editor.
- Change the value of the field labeled "fixed form line length." The value must be at least 72.
If you have any fixed form editors open, close and reopen them; notice that the rightmost, gray vertical bar has been moved to the column indicated, and the parser (which constructs the Outline view) has adjusted accordingly.
NOTE: This is a workspace-wide preference: It affects all fixed form files in the workspace. It is not currently possible to adjust this setting per project or per file.
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.
Using the Fortran editor and Fortran perspective
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.
Overview of the Fortran editor
The Fortran editor includes a number of features. The main features to note are the horizontal ruler at the top of the editor, code folding, and syntax 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."
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.
The editors also support syntax 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.
Comment/uncomment
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.
![Photran-comment-action.png](/images/c/cc/Photran-comment-action.png)
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)
The "Go To Line..." feature allows you to jump to a specific line number in a file when it is open in a Fortran editor. In the menu bar, go to Navigate > Go To Line... (or press the hotkey, Ctrl+L on Windows/Linux or Command+L on Mac) to open the Go To Line dialog box. Typing in the line you wish to navigate to, and clickg OK. The cursor will be moved to the beginning of the specified line.
Configuring The Editor
Selecting horizontal ruler vs. folding
Fortran editors can either display the horizontal ruler, or they can have code folding enabled, but not both. To determine which will be enabled, 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 the print margin
Editors can optionally display a gray vertical bar at a specified column; generally, this is set in column 80 to act as a visual "print margin." To enable display of the print margin, go to Window > Preferences in the menu bar. Under General, expand Editors, and select Text Editors. Check the box for "Show print margin". Optionally, you can also change the column in which the print margin will be displayed. Click Apply and the print margin should now display in the editor.
Setting fixed-form line length
In fixed form, Fortran specifies that anything past column 72 (default) is a comment. However, that can be changed to a value other than 72. To change the length of the line, go to Window > Preferences in the menu bar. Under Fortran, select Editor. Change the value of field labeled "Fixed-form line length" to the desired length of the line. Note that the accepted range for the length of the line is 72-999 inclusive.
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.
Note that this will only apply to new tabs that you type; it will not change your existing files.
- It is easy to replace tabs with spaces in an existing file, as long as the tabs all occur at the beginning of a line. (For tabs in the middle of a line, this won't work quite right.) (1) Move the cursor to the beginning of the file; (2) click on Edit > Find/Replace...; (3) in the Find box, type "\t" (without the quotes); (4) in the Replace With box, type 4 or 8 spaces (each tab character will be replaced with exactly what you type, so if you type four spaces, each tab character will be replaced with four spaces); (5) select Search: Forward and Scope: All; (6) check the "regular expression" box; and (7) click Replace All. This will replace every tab character with 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. Spaces, tabs, and newlines will now be shown as light gray double-angle quotes (»), dots (·), and paragraph symbols (¶), respectively.
Set Font
Photran uses the same font as the basic Eclipse text editor. To change it, click on Window > Preferences in the menu bar. Under General, expand Appearance, and select Colors and Fonts. In the list on the right, select Text Font. Click the "Change..." button to change the font.
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
To compile a project, Photran generally executes whatever make command is on your system path. (On most systems, this will invoke GNU Make.) As noted above, when you create a project, you can decide if Photran will auto-generate a Makefile that uses GNU Fortran, Intel Fortran, or IBM XL Fortran, or you can elect to hand-write your own Makefile.
- To use an automatically generated Makefile, choose "Executable (Gnu Fortran on XYZ)" from the Project type menu, where XYZ is your platform (Windows, Linux, or Mac OS X). There are similar options available for Intel Fortran and IBM XL Fortran.
- To create a project using a custom Makefile, in the project type selection box, expand the Makefile Project folder, and select Empty Project.
Building Projects
Compiling Fortran projects is identical to compiling C/C++ Projects.
For more information on building projects, click on Help > Help Contents in Eclipse, and navigate to C/C++ Development User Guide > Concepts > Build > Building C/C++ Projects. [8]
Setting Make Targets
Setting make targets for Fortran programs is also identical to setting make targets for C/C++ programs.
For more information on make targets, click on Help > Help Contents in Eclipse, and navigate to C/C++ Development User Guide > Tasks > Building projects > Creating a make target. [9]
Marking Error Messages from Your Fortran Compiler (Error Parsers)
When you build (compile) your Fortran program, the output from your Fortran compiler (including any error messages) will be displayed in the Console view. However, for many compilers, Photran can "recognize" error messages, placing the problem description in the Problems view and marking the corresponding line in the source file with a red X icon.
To do this, you must have the correct 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 is displayed; select the one(s) corresponding to the Fortran compiler(s) you are using and click OK.
Recognizing Executables (Binary Parsers)
In order to run (execute) 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. Mac users should choose the Mach-O parser.
![Run as Local Fortran Application](/images/6/68/Photran-run-as-local-fortran.png)
Running and Debugging Fortran Programs
To run a Fortran application, right-click the project in the Fortran Projects view, and click Run As > Local Fortran Application. This will build and run the Fortran application, and output will be printed to the console. (Remember, if you are using a custom makefile, the makefile will need to be written correctly for the project to be built.)
If you want to manage the run configuration (for example, if you want to pass command line arguments to your Fortran application or set certain environment variables), right-click on the project in the Fortran Projects view, click Run As > Run Configurations... Create a new launch configuration under Fortran Local Application (or edit an existing one) and modify the settings as needed.
Debugging programs works similarly, except you can choose Debug As > Local Fortran Application or Debug Configurations from the context menu.
Running and debugging Fortran applications is similar to running and debugging C/C++ applications. For more information on running and debugging binary applications, click on Help > Help Contents in Eclipse, and navigate to C/C++ Development User Guide > Tasks > Running and debugging projects. [10]
Setting Breakpoints
There are two ways to set breakpoints in the editor.
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](/images/9/95/Photran-set-breakpoint.png)
When you switch to the Debug perspective, the breakpoints you set will be listed in the Breakpoints view.
For more information on debugging, click on Help > Help Contents in Eclipse, and navigate to C/C++ Development User Guide > Tasks > Running and debugging projects > Debugging.
Known Run/Debug Issues
When using Cygwin in Windows, debugging a program can result in a "cannot find gcc source" error as described in Bug 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
G95
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.
gFortran
No known issues.
Intel Fortran Compiler
No known issues.
IBM XLF
No known issues.
Advanced Features
Photran 6.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.
Troubleshooting
If you are experiencing problems installing or working with Photran, please review the FAQ [11]. If you don't find an answer there, please join the Photran mailing list [12]; a large number of users (as well as Photran's developers) monitor that list, and they are generally eager to help.