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/photran7advanced
You are here: PTP > Photran > Documentation > Photran 7.0 Advanced Features
Photran 7.0 Advanced Features
Contents
- 1 Introduction
- 2 Advanced Editing Features
- 3 Search and Navigation
- 4 Refactoring
- 4.1 Introduction
- 4.2 Rename
- 4.3 Extract Procedure
- 4.4 Extract Local Variable
- 4.5 Subprogram Refactorings
- 4.6 Module Refactorings
- 4.7 Use Statement Refactorings
- 4.8 Common Block Refactorings
- 4.9 Loop Refactorings
- 4.10 Refactorings to Remove Obsolete Language Features
- 4.10.1 Remove Arithmetic If
- 4.10.2 Remove Assigned Goto
- 4.10.3 Remove Branch to End If
- 4.10.4 Replace Character* with Character(len=)
- 4.10.5 Remove Computed Goto
- 4.10.6 Replace Obsolete Operators
- 4.10.7 Replace Old-Style Do Loops
- 4.10.8 Remove Pause Statement
- 4.10.9 Remove Real/Double Precision Loop Counter
- 4.11 Refactorings to Improve Coding Style
- 4.11.1 Add Identifier to End Statement
- 4.11.2 Change Keyword Case
- 4.11.3 Convert Between If Statement and If Construct
- 4.11.4 Convert Data Statement to Parameter Statements
- 4.11.5 Introduce Implicit None
- 4.11.6 Make Save Attributes Explicit
- 4.11.7 Remove Unreferenced Labels
- 4.11.8 Remove Unused Local Variables
- 4.11.9 Standardize Statements
- 4.12 Debugging
- 4.12.1 Highlight Variable Accesses
- 4.12.2 Display Symbol Table for Current File
- 4.12.3 Find All Declarations in Scope
- 4.12.4 Select Enclosing Scope
- 4.12.5 Display Error/Warning Log
- 4.12.6 Resolve Interface Binding
- 4.12.7 Find Matching Interface Declarations
- 4.12.8 Display Binder Statistics
- 4.12.9 Reset Binder Statistics
- 4.12.10 Display Database Statistics
- 4.12.11 Reset Database Statistics
- 4.12.12 Display Database
- 4.12.13 Display Edge Model of Current File
- 4.12.14 Ensure Database is Up-to-Date
- 4.12.15 Clear and Rebuild Database
- 4.12.16 Browse VPG Database
- 4.13 Not Yet Available
Introduction
Photran 7.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.
Enabling Advanced Features
In order to use any of the advanced features described in this document, you must specifically enable them as described below. After you do this, Photran will index your project; that is, it will build a database of what modules, subprograms, etc. are declared in every file in your project. This information will be updated incrementally every time you save a file. Although this process is usually reasonably fast, it may become disruptive when working on very large projects, so it has been disabled by default. Note that the first time your project is indexed, it may take a while, because Photran must analyze every file in your project; after that, it will only index files that have changed (and files that depend on a file that has changed), so it will generally be much faster.
How to Enable Advanced Features
- Right-click on your project in the Fortran Projects view
- Click on Properties
- Expand Fortran General in the list on the left, and click on Analysis/Refactoring (see screenshot below)
- Check the "Enable Fortran analysis/refactoring" check box
- If you want to enable content assist, the Fortran Declaration view, etc., check those boxes as well
- You may also want to set module and include paths at this point (see below)
- Click OK
Setting Module and Include Paths
If your source code contains INCLUDE lines or USE lines referencing modules in other files, Photran needs to know where to look in order to find these. It will not figure this out automatically. For each project in which you plan to use refactoring support,
- Right-click on your project's folder in the Fortran Projects view
- Click on Properties
- Expand Fortran General in the list on the left, and click on Analysis/Refactoring
- List the folders in which Photran should search for INCLUDE files and modules when refactoring. They will be searched in order from the first folder listed to the last. Subfolders are not searched automatically; you must include them explicitly.
- Click OK
Advanced Features and C Preprocessed Code
Starting with Photran 6, C preprocessor directives are supported in Fortran code, as described in the Photran User's Guide. While most of the advanced features described in this manual can handle C preprocessed code, refactorings currently cannot. If you attempt to refactor C preprocessed code, you will receive an error message.
Advanced Editing Features
Content Assist
As you are typing a Fortran program, content assist pops up a list of the subprograms, variables, intrinsics, etc. that are in scope. It is invoked by pressing Ctrl+Space. As you start typing a name, the list is refined based on what you have typed; you can then use the arrow keys to choose from the list and press Enter to complete the definition. Content assist is useful when you don't remember the exact name of a function, or when a function has a long name and you don't want to type all of it. An example is shown below.
To use content assist, you will need to open the project properties, switch to the Fortran Analysis/Refactoring category, and check the "Enable Fortran content assist (Ctrl+space)" box. You will need to close and re-open any Fortran editors before you can start using content assist, however.
Fortran Declaration View
The Fortran Declaration view displays the statement where a variable, program, or subprogram is declared. If you place the text editor cursor within (or highlight) a variable name or the name of a subroutine in a CALL statement, the Fortran Declaration view will then display the actual declaration. For variables, the declaration view displays the variable declaration as well as a comment regarding the type of variable and other information, such as dimension information for an array as shown in the example below. For subprograms, it displays the FUNCTION or SUBROUTINE statement, including any comments that precede it.
Hover Tips
Hover tips display the same text as the Fortran Declaration view (described above); however, they display it in a popup window when the mouse cursor is hovered over an identifier.
Fortran hover tips are enabled in a project's analysis/refactoring properties. To turn them on or off, check the box labeled "Enable Fortran Hover Tips" in the project properties under Fortran General > Analysis/Refactoring. (Note that Analysis/Refactoring must also be enabled.)
Open Declaration
The Open Declaration command allows you to quickly find the declaration of a particular variable or subprogram. In the Fortran editor, click on (or select) an identifier. Then either
- click on the Navigate menu, and select Open Declaration, or
- right-click on the identifier, and, and select Open Declaration, or
- press the F3 key on your keyboard.
This feature is particularly useful when the declaration is in another file. For example, if your program contains a CALL statement which invokes a subroutine imported from a module in another file, invoking Open Declaration on the subroutine name in the CALL statement will open the module in a new editor, and the cursor will be located on the declaration of that subroutine.
Fortran Search
Fortran Search is a syntax-aware, multi-file search tool. Unlike textual searches, Fortran Search "understands" Fortran programs. It is used to search for a particular type of declaration (e.g., only modules, or only subroutines), or it can find all of the uses of a particular variable or subroutine. It also allows to you to limit the scope of the search (e.g., it can search every file in the workspace, or just a particular project).
In order to use Fortran Search, click on the Search menu and select Fortran...
This will open the Eclipse Search dialog, and the Fortran tab will be active. There, you can specify several things:
- The Search for frame allows you to specify whether it should search for subroutines, functions, modules, variables, etc.
- The Scope frame allows you to specify what file(s) will be searched.
- The Limit to frame allows you to specify whether you want to find declarations, references, or both.
Wildcards
Wildcards are special symbols used for pattern matching. For more information, click on Help > Help Contents in Eclipse, and navigate to Workbench User Guide > Reference > User interface information > Search.
- * - represents any number of any symbols. For example, a search for *d would match bad, rescued, d, assembled, etc.
- ? - represents any one single character. For example, a search for ?ad would match bad, mad, sad, dad, zad, etc.
Regular expressions are an even more advanced pattern matching languages. For more information, click on Help > Help Contents in Eclipse and navigating to Workbench User Guide > Getting started > Basic tutorial > Searching
Refactoring
Introduction
What is Refactoring?
Refactorings are changes to a program that improve its internal design but do not change its behavior. These include minor, coding style changes (like using IMPLICIT NONE statements), code readability improvements (like replacing a variable named N with one called NUM_POINTS), performance improvements (like interchanging loops under certain conditions), and even larger-scale design changes (like moving a procedure from one module to another).
Although these types of changes can be done by hand, making them is often tedious and error-prone. Photran automates many such refactorings. For example, the Refactor > Rename command can automatically locate the declaration(s) and uses of a particular subroutine, and change its name in all of those locations. It is "smart," too; if there is a subroutine named d and a variable named d in a different context, it won't confuse the two. Moreover, before making such a change, Photran will attempt to verify that the change is safe to make. For example, a subroutine A cannot be renamed to B if there is already a variable named B in a context where that subroutine is called.
For more information on refactoring, see M. Fowler, Refactoring: Improving the Design of Existing Code, Addison-Wesley, 1999.
Refactoring in Photran
Most refactorings can be accessed via the Refactor menu in the menu bar, as described below. However, the most common refactorings also have hotkeys (e.g., Alt+Shift+R for Rename; hotkeys are listed in the Refactoring menu next to each command). Also, most refactorings can be accessed by right-clicking in an editor and choosing Refactor from the popup menu.
Some refactorings (such as Introduce Implicit None and Replace Obsolete Operators) can be applied to several files at once. As described below, this involves selecting one or more files in the Fortran Projects view, then right-clicking on any of the selected filenames and choosing Refactor from the popup menu.
- Clicking on a filename in the Fortran Projects view selects that file (and only that file).
- Ctrl+click (Command+click on Mac OS X) can be used to select or deselect additional files.
- To select a range of files, click on one filename, and Shift+click on a later filename; those files and all of the files in between will be selected as well.
Caution: Photran can only refactor free-format Fortran source code. It is not possible to refactor fixed-form code. Make sure that only free-form Fortran files are selected. The Refactor menu may not be available if any of the files are fixed-form or non-Fortran files.
Rename
- Description: Rename is essentially a "smart" search and replace: It allows you to change the name of a variable, subprogram, etc. It correctly observes scoping and shadowing rules can also rename subprograms and module entities across files.
- Applies To:
- Local variables1,2
- Subprograms3 (including external and interface declarations)
- Derived types
- Module entities (variables and subprograms)
- Main programs
- Namelists
- Common blocks
- Block data subprograms
- Operation:
- Click on the name of a local variable, subprogram, etc.
- Click Refactor > Rename... The Rename dialog will appear.
- Enter a new name for the variable/subprogram/etc.
- If you are renaming an external subprogram or a subprogram declared in an interface block, you may want to (un)check the box labeled Match external subprograms with interfaces and external declarations. If this is checked, the refactoring will attempt to find all external subprograms, EXTERNAL statements, and subprogram declarations in INTERFACE blocks that have the given name, and they will all be renamed.
- Click Preview to see what changes will be made, then click OK to apply them.
- Example:
1. Dummy subprogram arguments cannot be renamed
2. Components of derived types cannot be renamed
3. Intrinsic subprograms and type-bound procedures (Fortran 2003) cannot be renamed
Extract Procedure
- Description: Extract Procedure removes a sequence of statements from a procedure, places them into a new subroutine, and replaces the original statements with a call to that subroutine. Any local variables used by those statements will be passed as parameters to the new procedure. This refactoring is generally used to make long procedures shorter.
- Applies To: A sequence of one or more action statements inside a procedure or main program.
- Operation:
- Select a sequence of one or more action statements in the editor. Be sure to include the newline following the last statement in the selection.
- Click Refactor > Extract Procedure... The Extract Procedure dialog will appear.
- Enter a name for the new procedure that will be created.
- Click Preview to see what changes will be made, then click OK to apply them.
- Example:
Extract Local Variable
- Description: Extract Local Variable removes a subexpression from a larger expression and assigns that subexpression to a local variable, replacing the original subexpression with a reference to that variable. This refactoring is usually used to eliminate duplicated subexpressions or to introduce explanatory variable names into complex expressions.
- Caveats: The refactoring will only be allowed to proceed if extracting the subexpression will preserve the associativity and precedence of the original expression. This refactoring assumes that the extracted expression has no side effects; it does not check whether moving the computation of the extracted expression will change the behavior of the program.
- Operation:
- Select an expression in the editor.
- Click Refactor > Extract Local Variable... The Extract Local Variable dialog will appear.
- Enter the type and name for the new local variable that will be created.
- Click Preview to see what changes will be made, then click OK to apply them.
Subprogram Refactorings
Add Subroutine Parameter
- Description: This refactoring will add a parameter to a subroutine.
- Applies To: A subroutine.
- Operation:
- Select the subroutine name or subroutine statement
- Click Refactoring > Subprogram > Add Subroutine Parameter (or press Shift+Alt+P)
- Use the input page to choose the type, intent, and name of the parameter.
- Type in numbers for the default value and position.
- Click preview to view the changes without applying, or OK to apply the changes.
- Example:
Permute Subprogram Arguments
- Description: This refactoring will change the order of the arguments to a subroutine and adjust all call sites accordingly.
- Applies To: All files calling the selected subroutine.
- Operation:
- Select the subroutine name or subroutine statement
- Click Refactoring > Subprogram > Change Subroutine Signature.
- Use the input page's up and down buttons to rearrange the order of the arguments for the subroutine.
- Click preview to view the changes without applying, or OK to apply the changes.
- Example:
Safe Delete
- Description: This refactoring will remove all Internal Subprograms from a given Host. The refactoring fails if there are any references to the subprogram.
- Applies To: A file.
- Operation:
- Select the subroutine name or subroutine statement to remove
- Click Refactoring > Subprogram > Safe Delete
- Click preview to view the changes without applying, or OK to apply the changes.
- Example:
Module Refactorings
Make Private Entity Public
- Description: Changes a module variable or subprogram from PRIVATE to PUBLIC visibility, and checks that it won't conflict with any existing name where that module is USEd.
- Applies To: Variables, subroutines, functions.
- Does Not Apply To: Intrinsics, Externals, Interfaces.
- Operation:
- Select the name of the private entity you wish to make public.
- Choose Refactor > Module > Make Private Entity Public.
- Click Preview to see what changes will be made, then click OK to apply them.
- Example
Encapsulate Variable
- Description: Encapsulate variable creates getter and setter methods for the selected variable in the module where it is defined and changes variable's visibility to private. It also replaces all uses of that variable in all files to use getter and setter method calls1.
- Applies To:
- Variables defined in the module.
- Variables of all basic as well as user-defined types
- Does Not Apply To:
- Arrays
- Variables that are not defined in a module
- Parameters (i.e. integer, parameter :: CANNOT_ENCAPSULATE)
- Pointers (i.e. real, pointer :: CANNOT_ENCAPSULATE)
- Targes (i.e. integer, target :: CANNOT_ENCAPSULATE)
- Operation:
- Click on or select the name of variable you want to encapsulate.
- Click Refactor > Module > Encapsulate Variable. The Encapsulate Variable dialog will appear.
- Enter names for getter and setter methods. You will be warned if the names that you want to assign to your getter and setter methods will be conflicting with some other identifier in any of the involved files.
- Click Preview to see what changes will be made, then click OK to apply them.
- Example:
1. If a variable is used as a parameter to a function/subroutine call, and that function changes
the value of the variable as a side-effect, that change will not be preserved.
Use Statement Refactorings
Add ONLY Clause to USE Statement
- Description: Creates a list of the symbols that are being used from a module, and adds it to the USE statement.
- Applies To: All modules containing public definitions.
- Does not apply to: Empty modules or modules with only private entities.
- Operation:
- Select the name of the module in the USE statement you wish to add an ONLY clause to.
- Choose Refactor > Use Statement > Add Only Clause to Use Statement.
- Select which module entities you wish to include in the ONLY list. Any entities in an existing ONLY list will already be selected and can be deselected to be removed.
- Click Preview to see what changes will be made, then click OK to apply them.
- Example
Minimize ONLY List
- Description: Deletes symbols that are not being used from the ONLY list in a USE statement.
- Applies To: USE statements with an ONLY clause.
- Operation:
- Select the name of the module in the USE statement you wish to minimize the ONLY list for.
- Choose Refactor > > Use Statement > Minimize Only List.
- Click Preview to see what changes will be made, then click OK to apply them.
- Example
Common Block Refactorings
Make Common Block Variable Names Consistent
- Description: Fortran allows different definitions of a COMMON block to give the same variable different names. This is confusing. This refactoring gives the variables the same names in all definitions of the COMMON block.
- Applies To: All COMMON blocks with a valid name.
- Does not apply to: COMMON blocks with a NULL name.
- Operation:
- Select the name of the COMMON block in the editor which you wish to make variable names consistent for.
- Choose Refactor > Common Block > Make Common Block Variable Names Consistent.
- Enter the new names which you wish to give the COMMON variables. The default new names are the original names in the selected block with "_common" appended.
- Click Preview to see what changes will be made, then click OK to apply them.
- Example
Move Saved Variables to Common Block
- Description: Move Saved Variables to Common Block creates a common block for all "saved" variables of a subprogram. Declarations of these variables in the subprogram are transformed such that they are no longer "saved". The generated common block is declared both in the main PROGRAM and in the affected subprogram. Variables placed in the common block are renamed such that they do not conflict or shadow other variables. The current implementation assumes that the subprogram is in the CONTAINS section of the PROGRAM.
- Applies To: Subprograms.
- Operation:
- Click on the declaration statement of a subprogram.
- Click Refactor > Common Block > Move Saved Variables to Common Block.
- Click Preview to see what changes will be made, then click OK to apply them.
- Example:
Loop Refactorings
Interchange Loops
- Description: Swaps inner and outer loops of the selected nested do-loop1. This refactoring merely switches the inner and outer do-headers. It will not make any changes to the body of the loop.
- Applies To: Selected nested do-loop
- Operation:
- Select the nested loops you wish to interchange
- Click Refactor > Do Loop > Interchange Loops. The Interchange loops dialog will appear.
- Click Preview to see what changes will be made, then click OK to apply them.
- Example:
1. In order for refactoring to work correctly, there must be no statements before the second loop. If such statements exist, correctness of the refactoring is not guaranteed.
Fuse Loops
- Description: Takes two do-loops, normalizes their bounds, and finally puts the loop bodies in a single do-loop.
- Applies To: Find the two do-loops you want to fuse, and select only the first one1. If there are any statements in between the two loops, the statements will remain after the fused do-loop. In order for the loops to be compatible, the loops need to have the same number of iterations (the bounds do not need to be the same, just the number of times the body of the loop is accessed).
- Operation:
- Select the first do-loop to be fused.
- Click Refactor > Do Loop > Fuse Loops.
- Click Preview to see a comparison view of the changes made, and OK to apply the changes.
- Example:
1. The refactoring will find the next listed do-loop in your code (even with other lines of code in between them).
Reverse Loop
- Description: Takes an incrementing or decrementing loop, swaps the lower and upper bounds, and negates the step.
- Applies To: Selected do-loop
- Operation:
- Select full do-loop or do-loop header
- Click Refactor > Do Loop > Reverse Loop.
- Click Preview to see a comparison view of the changes made, and OK to apply the changes.
- Example:
Tile Loop
- Description: This refactoring takes a double nested do-loop, and creates a nested do-loop with four levels of depth. Instead of iterating through a two dimensional array (for example) by going through each row, it will loop over smaller tile blocks
- Applies To: A double nested do-loop where both step values are 1.
- Inputs:
- Tile Size: The size of the accessing block or tile. So, if the tile size is 3, an array will be accessed in 3x3 blocks.
- Tile Offset: Adjusts where the blocks start (all the data will always be covered no matter where it starts).
- Operation:
- Select the whole nested do-loop, or the header of the top nested do-loop.
- Click Refactoring > Do Loop > Tile Loop.
- Enter a tile step and tile offset, then click preview to view changes, or OK to apply changes.
- Example:
Unroll Loop
- Description: Takes the selected do-loop and either completely or partially unrolls it. This will also optionally include a conditional statement to make sure the loop stays in bounds.
- Applies To: A do-loop that doesn't contain labels, and never writes to the index variable (Ex: read(*,*) indexVar)
- Operation:
- Select the loop to unroll (or just the header).
- Click Refactoring > Do Loop > Unroll Loop.
- Select either the number of times you would like to unroll the loop, or check the "Complete unrolling" box. Uncheck the "Include bounds checking" box if you don't want a conditional statement to ensure proper loop bounds in numbered loop unrolling.
- Click Preview to see the changes this refactoring will make, and OK to make the changes.
- Example(Numbered):
- Example(Complete):
Refactorings to Remove Obsolete Language Features
Remove Arithmetic If
- Description: This refactoring will remove all arithmetic if statements, a feature that became obsolete in Fortran 90, from a single file or all the files in a project.
- Applies To: A project or file.
- Operation:
- Select the project or file with arithmetic if statements to remove.
- Click Refactoring > Obsolete Language Features > Remove Arithmetic If Statements
- Click preview to view the changes without applying, or OK to apply the changes.
- Example:
Remove Assigned Goto
- Description: This refactoring will remove all assigned goto statements and replace them with case blocks.
- Applies To: All assigned goto statements.
- Operation:
- Click Refactoring > > Obsolete Language Features > Remove Assigned Goto.
- Choose Yes if you want to add a default case, otherwise choose No.
- Click preview to view the changes without applying, or OK to apply the changes.
- Example:
Remove Branch to End If
- Description: Removes the branch to END IF statements. The GOTO statements carry outbranching. Branching to end if is replaced with branching to CONTINUE statement that immediately follows the END IF statement.
- Applies To: Selected end if statement
- Operation:
- Select an end if statement with a statement label
- Click Refactor > Obsolete Language Features > Remove Branch to End If
- Click Preview to see what changes will be made, then click OK to apply them.
- Example:
Replace Character* with Character(len=)
- Description: Replaces character*n declaration with character(len=n) declaration.
- Applies To: All character declarations
- Operation:
- Select one of the character declaration statements
- Click Refactor > Obsolete Language Features > Replace Character* with Character(len=)... The Replace Character* with Character(len=) will appear.
- Click Preview to see what changes will be made, then click OK to apply them.
- Example:
Remove Computed Goto
- Description: Replaces computed goto statement with select case statement
- Applies To: Selected computed goto statement
- Operation:
- Select the computed goto statement you wish to remove
- Click Refactor > Obsolete Language Features > Remove Computed Goto. The Remove Computed Goto dialog will appear.
- Click Preview to see what changes will be made, then click OK to apply them.
- Example:
Replace Obsolete Operators
- Description: Replace Obsolete Operators replaces all uses of old-style comparison operators (such as .LT. and .EQ.) with their newer equivalents (symbols such as < and ==). and adds explicit declarations for all variables that were previously declared implicitly.
- Applies To: All uses of the following operators in one or more files: .LT. .LE. .EQ. .NE. .GT. .GE.
- Operation:
- This is a multiple-file refactoring.
- To Replace Obsolete Operators in a single file, open the file in the editor and choose Refactor > Obsolete Language Features > Replace Obsolete Operators from the menu bar.
- To Replace Obsolete Operators in multiple files, select the files in the Fortran Projects view, right-click on any of the selected filenames, and choose Refactor > Obsolete Language Features > Replace Obsolete Operators from the popup menu.
- Click Preview to see what changes will be made, then click OK to apply them.
- This is a multiple-file refactoring.
- Example:
Replace Old-Style Do Loops
- Description: Replaces old-style do loops with the modern style of do loops
- Applies To: All old-style do loops
- Operation:
- Click Refactor > Obsolete Language Features > Remove Old-Style Do Loops.
- Click Preview to see what changes will be made, then click OK to apply them.
- Click Refactor > Obsolete Language Features > Remove Old-Style Do Loops.
- Example:
Remove Pause Statement
- Description: Replaces pause statement with empty print and read statements
- Applies To: Selected pause statement
- Operation:
- Select the pause statement you wish to remove
- Click Refactor > Obsolete Language Features > Remove Pause Statement.
- Click Preview to see what changes will be made, then click OK to apply them.
- Example:
Remove Real/Double Precision Loop Counter
- Description: Transforms a do or do while loop with control to a do or do while loop without control.
- Applies To: Selected loop
- Operation:
- Select the loop you wish to transform
- Click Refactor > Obsolete Language Features > Remove Real/Double Precision Loop Counter.
- Choose either do loop or do while loop.
- Click Preview to see what changes will be made, then click OK to apply them.
- Example:
Refactorings to Improve Coding Style
Add Identifier to End Statement
- Description: This refactoring will add the program/subprogram name to an end statement.
- Applies To: A file or project.
- Operation:
- Select the file or project.
- Click Refactoring > Coding Style > Add Identifier to End Statement
- Click preview to view the changes without applying, or OK to apply the changes.
- Example:
Change Keyword Case
- Description: Makes all applicable keywords the same case throughout the selected Fortran program files.
- Applies To: All keywords except those listed below.
- Does not apply to:
- Identifiers
- All constants except for integer constants and real constants
- Operation:
- This is a multiple-file refactoring.
- To Change Keyword Case in a single file, open the file in the editor and choose Refactor > Coding Style > Change Keyword Case from the menu bar.
- To Introduce Implicit None in multiple files, select the files in the Fortran Projects view, right-click on any of the selected filenames, and choose Refactor > Coding Style > Change Keyword Case from the popup menu.
- Select Upper or Lower Case
- Click Preview to see what changes will be made, then click OK to apply them.
- This is a multiple-file refactoring.
- Example
Convert Between If Statement and If Construct
- Description: Converts a simple if statement to an if construct with a then block and possible else block.
- Applies To: Selected if statement.
- Operation:
- Refactor > Coding Style > Convert Between If Statement and If Construct
- Select whether or not you want an empty else block.
- Click Preview to see what changes will be made, then click OK to apply them.
- Example:
Convert Data Statement to Parameter Statements
- Description: When a variable declared in a DATA statement is intended to be a constant, Data to Parameter can be used to change it to a variable with the PARAMETER attribute. Using the PARAMETER attribute makes it more clear which variables are constants and which ones are not; it can also result in performance gains, since it may allow an optimizing compiler to replace some variable accesses with the constant value.
- Applies To: All main programs, subprograms, and modules in one or more files.
- Operation:
- This is a multiple-file refactoring.
- To transform variables declared as data in variables declared with parameter attribute in a single file, open the file in the editor and choose Refactor > Coding Style > Convert Data Statement to Parameter Statements from the menu bar.
- To transform variables declared as data in variables declared with parameter attribute in multiple files, select the files in the Fortran Projects view, right-click on any of the selected filenames, and choose Refactor > Coding Style > Convert Data Statement to Parameter Statements from the popup menu.
- Click Preview to see what changes will be made, then click OK to apply them.
- This is a multiple-file refactoring.
- Example:
Introduce Implicit None
- Description: Adds IMPLICIT NONE statements to a file and adds explicit declarations for all variables that were previously declared implicitly.
- Applies To: All main programs, subprograms, and modules in one or more files.
- Operation:
- This is a multiple-file refactoring.
- To Introduce Implicit None in a single file, open the file in the editor and choose Refactor > Coding Style > Introduce Implicit None from the menu bar.
- To Introduce Implicit None in multiple files, select the files in the Fortran Projects view, right-click on any of the selected filenames, and choose Refactor > Coding Style > Introduce Implicit None from the popup menu.
- Click Preview to see what changes will be made, then click OK to apply them.
- This is a multiple-file refactoring.
- Example:
Make Save Attributes Explicit
- Description: Makes Save Attributes Explicit.
- Applies To: The entire program.
- Operation:
- Refactor > Coding Style > Make Save Attributes Explicit
- Click Preview to see what changes will be made, then click OK to apply them.
- Example:
Remove Unreferenced Labels
- Description: Removes any unreferenced labels.
- Applies To: All unreferenced labels.
- Operation:
- Refactor > Coding Style > Remove Unreferenced Labels
- Click Preview to see what changes will be made, then click OK to apply them.
- Example:
Remove Unused Local Variables
- Description: Remove Unused Variables removes declarations of local variables that are never used.
- Applies To: All main programs, subprograms, and modules in one or more files.
- Operation:
- This is a multiple-file refactoring.
- To Remove Unused Variables in a single file, open the file in the editor and choose Refactor > Coding Style > Remove Unused Local Variables from the menu bar.
- To Remove Unused Variables in multiple files, select the files in the Fortran Projects view, right-click on any of the selected filenames, and choose Refactor > Coding Style > Remove Unused Local Variables from the popup menu.
- Click Preview to see what changes will be made, then click OK to apply them.
- This is a multiple-file refactoring.
- Example:
Standardize Statements
- Description: Standardize Statements rewrites all variables declarations, so that
- there is only one variable declaration per line, and
- every variable declaration contains a double colon (::).
- Applies To: All main programs, subprograms, and modules in one or more files.
- Operation:
- This is a multiple-file refactoring.
- To Standardize Statements in a single file, open the file in the editor and choose Refactor > Coding Style > Standardize Statements from the menu bar.
- To Standardize Statements in multiple files, select the files in the Fortran Projects view, right-click on any of the selected filenames, and choose Refactor > Coding Style > Standardize Statements from the popup menu.
- Click Preview to see what changes will be made, then click OK to apply them.
- This is a multiple-file refactoring.
- Example:
Debugging
These refactorings are used to debug your program.
Highlight Variable Accesses
- Description: Creates a file of your code where the variables are highlighted according to whether they are read or write variables.
- Applies To: The entire program.
- Operation:
- Refactor > Debugging > Highlight Variable Accesses
- Example:
Display Symbol Table for Current File
- Description: Creates file with a list of all the variables. Lists the name and type of variable and the line where the variable was declared.
- Applies To: The entire program.
- Operation:
- Refactor > Debugging > Display Symbol Table for Current File
- Example:
Find All Declarations in Scope
- Description: Gives a list of all the declarations that are in the scope of the line you're on.
- Operation:
- Refactor > Debugging > Find All Declarations in Scope
- You will see a list of all the variables that are in scope. You can type in a variable to see if it is in scope.
- Example:
Select Enclosing Scope
- Description: Highlights the entire range of source text corresponding to a token’s enclosing ScopingNode.
- Operation:
- Click on a token in the editor.
- Refactor > Debugging > Select Enclosing Scope
Display Error/Warning Log
- Description: Creates file with a log of errors and warnings.
- Operation:
- Refactor > Debugging > Display Error/Warning Log
Resolve Interface Binding
- Description: Resolves all interface binding.
- Operation:
- Refactor > Debugging > Resolve Interface Binding
Find Matching Interface Declarations
- Description: Finds matching interface declaration for an identifier in a subprogram declaration.
- Operation:
- Refactor > Debugging > Find Matching Interface Declarations
Display Binder Statistics
- Description: Creates file with a list of average and maximum times for ReferenceCollider, ModuleLoader, etc.
- Operation:
- Refactor > Debugging > Display Binder Statistics
- Example:
Reset Binder Statistics
- Description: Resets the Binder Statistics. If you Display Binder Statistics, there will be no data under Average Times.
- Operation:
- Refactor > Debugging > Reset Binder Statistic
Display Database Statistics
- Description: Creates file with stats on how many times methods such as getIncomingEdgesTo, getAnnotation, and isOutOfDate have been called.
- Operation:
- Refactor > Debugging > Display Database Statistics
- Example:
Reset Database Statistics
- Description: Resets the Database Statistics. If you Display Database Statistics, there will be no data.
- Operation:
- Refactor > Debugging > Reset Database Statistic
Display Database
- Description: Creates file with database statistics on dependencies, edges, and modification stamps.
- Operation:
- Refactor > Debugging > Display Database
- Example:
Display Edge Model of Current File
- Description: Creates file that has info on all of the edges.
- Operation:
- Refactor > Debugging > Display Edge Model of Current File
- Example:
Ensure Database is Up-to-Date
- Description: Makes sure that the database is up-to-date.
- Operation:
- Refactor > Debugging > Ensure Database is Up-to-Date
Clear and Rebuild Database
- Description: Clears and rebuilds the database.
- Operation:
- Refactor > Debugging > Clear and Rebuild Database
Browse VPG Database
- Description: Allows you to view all edges, dependencies, and annotations for all files.
- Operation:
- Refactor > Debugging > Browse VPG Database
- Select a file and switch between edges, dependencies, and annotations on the right side of the box.
- Example:
Not Yet Available
The following refactorings have been submitted but are not yet included in Photran.
Add Use Of Named Entities
- Description: This refactoring adds the statement use M, only: ... to another module, if a similar statement does not already exist. It fails if this will result in a naming conflict, the introduction of circular dependencies between modules, or if a statement use M already exists but renames any named entities.
- Applies To: A list of named entities.
- Operation:
- Move your cursor to the module you want to "use".
- Click Refactoring > Add Use Of Named Entities to Modules.
- Select the named entities you would like to use, and the module you want to use them in.
- Click preview to view the changes, and OK to apply the changes.
- Example:
Move Module Entities
- Description: This refactoring moves a set of named entities from one module to another, and updates all use statements that reference these modules.
- Applies To: A list of named entities.
- Operation:
- Move your cursor to the module with the entities you would like to move.
- Click Refactoring > Move Module Entities.
- Select the named entities you would like to move, and the module you want to move them to.
- Click preview to view the changes, and OK to apply the changes.
- Example:
Change Subroutine to Function
- Description: This refactoring will change a subroutine to a function. The refactoring fails if there are no intent out arguments.
- Applies To: A file.
- Operation:
- Select the subroutine name or subroutine statement that needs to be changed to a function
- Click Refactoring > Change Subroutine To Function.
- Click preview to view the changes without applying, or OK to apply the changes.
- Example:
Convert Specification Statement to Declaration Attribute
TODO
Toggle End Name
TODO
Standardize Input Output Format
TODO