Refactorings to Improve Maintainability
The refactorings in this category are intended to improve internal
quality attributes of the code such as: readability,
understandability, flexibility and extensibility (attributes that
refactoring has been recognized to improve) and also refactorings
that allow upgrading the code to newer versions of Fortran, removing
obsolete features.
Refactorings to Improve Presentation / Readability
- Rename: change
the name of a variable, subprogram, etc.
- Extract Local Variable:
remove a subexpression from a larger expression and
assign it to a local variable.
- Extract Local
Procedure: remove a sequence of statements from a
procedure, place them into a new subroutine, and replace the
original statements with a call to that subroutine.
- Canonicalize Keyword
Capitalization: make all applicable
keywords the same case throughout the selected Fortran program
files.
- Change
Variable Case : make all pvariable names
aplicable the same case throughout the selected Fortran
program files.Added 27/06/2012
- Standarize
Statements: rewrites all variables declarations,
so that there is only one variable declaration per line, and
every variable declaration contains a double colon (::).This is
intended to make the code more readable.
- Convert
Specification Statement to Declaration Attribute:
Replaces the various specification statements (DIMENSION,
PARAMETER, SAVE, etc.), with the attribute declarations in the
variables' type declaration statements.Added
15/04/2011
Refactorings to Facilitate Design/Interface Change
- Encapsulate
Variable: create getter and setter methods for
the selected variable.
- Make Private
Entity Public: switch a module variable or
subprogram from Private to Public visibility.
- Permute
Subroutine
Arguments: change the order of the
arguments to a subroutine and adjust all call sites accordingly.
- Add
Only
Clause To Use Statements: create a list of the
symbols that are being used from a module, and adds it to the
Use statement.
- Move
Entity
Between Modules: move a module variable or procedure
from one module to another and adjust Use statements
accordingly.
- Add Use of
Named Entities To Module: allow to
select entities in a module and add a use only statement in a
target module (or alter the existing one).
- Safe-Delete Internal Subprograms: This
refactoring will remove all Internal Subprograms from dource
code. Added 13/09/2010
- Change
Subroutine to Function: This
refactoring will transform a subroutine to a function. Added 13/09/2010
- Change
Subroutine Signature: This
refactoring will change the order of the arguments to a
subroutine and adjust all call sites accordingly. Added 13/09/2010
- Add Subroutine Parameter : This refactoring
will add arguments to a subroutine and adjust all call sites
accordingly.Added 15/04/2011
Refactorings to Avoid Poor Fortran Coding Practices
- Remove
Unreferenced Labels: delete a label if it is
never referenced.
- Remove
Real Type Iteration Index: change non-integer Do
parameters or control variables.
- Remove
Reserved
Words As Variables: rename variables named equal to
Fortran reserved keywords.
- Introduce
Implicit
None: add Implicit None statements to a file and
add explicit declarations for all variables that were previously
declared implicitly.
- Introduce
Intent
In/ Out: introduce intent In or Out in each variable
declaration within functions and subroutines.
- Remove
Unused Local Variables: remove declarations of
local variables that are never used.
- Minimize
Only
List: delete
symbols that are not being used from the Only list in a Use
statement.
- Make
Common Variable Names Consistent: give variables
the same names in all definitions of the Common block.
- Delete
Unused
Common Block Variable: remove unused variables declared
in a Common Block.
- Add
Dimension
Statement: add the Dimension statement to declare an
array.
- Remove
Format Statement Labels: replace the format
code in the read/write statement directly with a parameter
string, instead of specifying the format code in a separate
format statement.
- Add identifier to END
statement (e.g. END SUBROUTINE FOO):
add the identifier that belongs to End statements. Added 17/05/2010
- Toggle End
Name: The toggle-end-name refactoring is
designed to automatically add or remove the end-name of a
nameable construct, provided the end-name is optional (with
several exceptions).Added 15/04/2011
Refactorings to Remove Outdated, Obsolete and Non-Standard
Constructs
- Replace
Obsolete Operators: replace all uses of
old-style comparison operators (such as .LT. and .EQ.) with
their newer equivalents (symbols such as < and ==).
- Change
Fixed
Form To Free Form: change Fortran fixed format files to
Fortran free format files.
- Transform
Character*
to Character(Len =) declaration: replace
Character* with the equivalent Character(Len =) for string
declaration.
- Remove
Computed Go To statement: replace a
computed Go To statement with an equivalent Select-Case
construct containing Go To or if possible remove the Go Tos
statement entirely.
- Remove
Arithmetic If Statement: replace an old
arithmetic If statement, being analogous to removing computed Go
To.
- Remove
Assigned
Go Tos: remove assigned Go To statements.
- Replace Old
Styles DO loops: replace old styles Do Loop
Continue with the equivalent Do Loop with End Do statement.
- Replace
Shared Do Loop Termination: replace all
shared Do Loop termination construct with the equivalent Do Loop
with End Do statement.
- Transform
To
While Sentence: remove simulated While made by If and
Go To statement.
- Move
Common
Block to Module: remove all declarations of a
particular Common block, moving its variable declarations into a
module and introducing Use statements as necessary.
- Move
Saved
Variables To Common Block: create a Common block
for all saved variables of a subprogram.
- Data To
Parameter: change a Data declaration to
Parameter declaration making more clear which variables are
constant and which ones are not.
Performance Refactorings
This category currently has two examples of how refactoring can be
used to improve performance while preserving not only the behavior
of the program but also the readability and maintainability of the
code. This is one of the factors that sets refactoring apart form
optimization.
Refactorings For Performance
- Change To Vector
Form: rewrite a Do Loop into an equivalent
Fortran vectorial notation, which allows the compiler to make
better optimizations.
- Make DO
Loop Concurrent/Non-Concurrent (Fortran 2008) :
Added 15/04/2011
Loop Refactorings
- Interchange
Loops: swaps inner and outer loops of the
selected nested do-loop, in the case that doing so allows to
optimizes memory access pattern and allows to take advantage of
data prefetching techniques.
- Fuse Loops: Takes two
do-loops, normalizes their bounds, and finally puts the loop
bodies in a single do-loop.Added 15/04/2011
- Reverse Loop:
Takes an incrementing or decrementing loop, swaps the lower and
upper bounds, and negates the step.Added
15/04/2011
- Tile Loop: 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.Added
15/04/2011
- Unroll
Loop: 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. Added 15/04/2011
- Replace Do
Loop By Forall: This refactoring is used to
substitute DO loops by FORALL, when you have only assignments in
the loop body. Added 27/06/2012