Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "PTP/photran/documentation/photran5"

m (Compiling Fortran Programs)
m (Running and Debugging Fortran Programs)
Line 367: Line 367:
 
= Running and Debugging Fortran Programs  =
 
= 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.  
+
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, 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.  
+
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 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.  
+
Debugging programs works similarly, except you can choose Debug As > Local Fortran Application or Debug Configurations from the context menu.
  
== CDT  ==
+
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.''' [http://help.eclipse.org/ganymede/topic/org.eclipse.cdt.doc.user/tasks/cdt_o_run.htm?resultof=%22%72%75%6e%6e%69%6e%67%22%20%22%72%75%6e%22%20]
  
Running and Debugging Fortran applications is similar to running and debugging C/C++ applications.
+
== Setting Breakpoints  ==
  
Refer to the [http://help.eclipse.org/ganymede/topic/org.eclipse.cdt.doc.user/tasks/cdt_o_run.htm?resultof=%22%72%75%6e%6e%69%6e%67%22%20%22%72%75%6e%22%20|CDT documentation] for a more detailed guide to run/debug configurations.
+
There are two ways to set breakpoints in the editor.  
 
+
== 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.  
 
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.  
 
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.  
<center>[[Image:Photran-set-breakpoint.png|Setting Breakpoints]]</center>  
+
<center>[[Image:Photran-set-breakpoint.png|Setting Breakpoints]]</center>
 +
 
 +
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 &gt; Help Contents in Eclipse, and navigate to
 +
'''C/C++ Development User Guide &gt; Tasks &gt; Running and debugging projects &gt; Debugging.'''
 +
 
 
== Known Run/Debug Issues  ==
 
== Known Run/Debug Issues  ==
  
When using Cygwin in Windows, Debugging a program can result in a "cannot find gcc source" error as described in [https://bugs.eclipse.org/bugs/show_bug.cgi?id=280492|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.  
+
When using Cygwin in Windows, debugging a program can result in a "cannot find gcc source" error as described in [https://bugs.eclipse.org/bugs/show_bug.cgi?id=280492 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  ==
 
== Compiler-specific problems  ==

Revision as of 17:01, 12 October 2009

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 October, 2009. Parts of it DO NOT APPLY to the currently-available release.

Contents

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]. 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.
  3. If you want to compile and build Fortran applications, you must have a make utility (such as GNU Make) and a Fortran compiler (such as GNU Fortran) 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 > Install New Software...
  3. Click on the "Add..." button
  4. Click on the "Archive..." button
  5. Choose the zip file you downloaded from [4]
  6. Click OK to close the Add Site dialog. This will return you to the Install dialog.
  7. Expand "Photran (Fortran Development Tools)" and check the box next to "Photran End-User Runtime"
  8. 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.
  9. Click on the "Next" button
  10. If you get an error message, see below for troubleshooting information.
  11. Click the Finish button and agree to the license to complete the installation.


Troubleshooting

The installer in Eclipse 3.5 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: 1255366915760 0.0.0.1255366915760 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 5.0.0.xxxx (org.eclipse.photran.feature.group 5.0.0.xxxx)
Missing requirement: Photran End-User Runtime 5.0.0.xxxx (org.eclipse.photran.feature.group 5.0.0.xxxx) requires 'org.eclipse.cdt.feature.group [xxx)' but it could not be found
Solution: You do not have CDT 6.0 installed, and it couldn't be downloaded and installed automatically. Try installing CDT 6.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 [5] (which optionally includes gfortran and GNU Make) 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 gtlib.gatech.edu 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
      ;C:\Cygwin\bin;C:\Cygwin\usr\bin;C:\Cygwin\usr\local\bin;C:\Cygwin\lib;C:\Cygwin\usr\lib
    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" "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".

  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.


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 [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.


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

Creating a Project by Importing Existing Source Code

TODO

Converting C/C++ Projects to Fortran Projects

TODO

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.

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

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.

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.
Choosing a Fortran project type

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. [10]

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. [11]

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.

Fortran Error Parsers

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.

Fortran Binary Parsers
Run as Local Fortran Application

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. [12]

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

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 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.

Troubleshooting

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

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

Beyond Photran

TODO

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

Back to the top