Skip to main content

Style Options

This section lists the supported style options. Value type is specified for each option. For enumeration types possible values are specified. In case an option or value is not specified a default value (here indicated in bold) is applied.

Tip

You can quickly try out these style options in your browser using the Codee Format Playground

BasedOnStyle (String)

The style used for all options not specifically set in the configuration. This option is supported within --style "{...}", the .codee-format file or the user specific config file.

Possible values are:

  • Codee: A style recommended by Codee.
  • Preserve: Preserving the original source code style. It can be used as a base configuration to create a specific style.
  • InheritParentConfig : Not a real style, but allows to use the .codee-format file from the parent directory (or its parent if there is none). If there is no parent file found it falls back to the Codee style, and applies the changes to that.

With this option you can overwrite some parts of your main style for your subdirectories. This is also possible through the command line, e.g.: --style "{BasedOnStyle: InheritParentConfig, ColumnLimit: 20}"

Casing (CasingStyle)

Control the letter casing.

Possible values:

  • Lowercase: All lowercase (e.g., real, integer, do)
  • Uppercase: All uppercase (e.g., REAL, INTEGER, DO)
  • Capitalized: First letter uppercase (e.g., Real, Integer, Do)
  • Preserve: Keep the original casing as it is

Nested configuration flags:

  • Identifiers: Set the casing of variable and function names
! Lowercase:
function foo()
real :: var
end function foo

! Uppercase:
function FOO()
real :: VAR
end function FOO

! Capitalize:
function Foo()
real :: Var
end function Foo
  • Keywords: Set the casing of Fortran keywords
! LowerCase:
function foo()
real :: var
end function foo

! UpperCase:
FUNCTION foo()
REAL :: var
END FUNCTION foo

! Capitalize:
Function foo()
Real :: var
End Function foo
  • LogicalConstants: Set the casing of logical constants
! LowerCase:
.true.
.false.

! UpperCase:
.TRUE.
.FALSE.

! Capitalize:
.True.
.False.
  • LogicalOperators: Set the casing of logical operators
! LowerCase:
.and.
.or.

! UpperCase:
.AND.
.OR.

! Capitalize:
.And.
.Or.
  • RelationalOperators: Set the casing of logical operators
! LowerCase:
.lt.
.eq.

! UpperCase:
.LT.
.EQ.

! Capitalize:
.Lt.
.Eq.
  • UserDefinedOperators: Set the casing of user defined operators
! LowerCase:
.useroperator.

! UpperCase:
.USEROPERATOR.

! Capitalize:
.Useroperator.

ColumnLimit (unsigned)

Set the line size, breaking lines longer than the specified limit. Default value is 0, meaning no limit.

! Column Limit 0:
subroutine foo()
result = operand1 + operand2 * operand3 * (operand4 - operand5) + operand6

print *, "Very very very very very very very very very very very very long line"
end subroutine foo

! Column Limit 72:
subroutine foo()
result = operand1 + operand2 * operand3 * (operand4 - operand5) + &
operand6

print *, "Very very very very very very very very very very very" // &
" very long line"
end subroutine foo

CommentDirectivePrefixes (List of Strings)

List of comment prefixes, i.e., text following the comment marker (!), that should be interpreted as directives, which may be needed for proper line breaking and continuation. For example, the $omp and $acc directives are already supported by default. Defaults to an empty list: []

#define USER_OMP $omp

!USER_OMP parallel do private(i) reduction(+:sum)
do i = 1, 10
! loop body
end do

With CommentDirectivePrefixes: ["USER_OMP"] becomes:

#define USER_OMP $omp

!USER_OMP parallel do private(i) &
!USER_OMP reduction(+:sum) ! Ok: Valid directive continuation
do i = 1, 10
! loop body
end do

DisabledDirectivePrefixes (List of Strings)

List of comment directive prefixes, i.e., text following the comment marker (!), that will disable formatting for the entire comment. Defaults to an empty list: []. Related: CommentDirectivePrefixes

#define USER_OMP_PARALLEL_DO $omp parallel do
!USER_OMP_PARALLEL_DO parallel do private(i) reduction(+: sum) ! Line isn't broken
do i = 1, 10
! loop body
end do

With DisabledDirectivePrefixes: ["USER_OMP_PARALLEL_DO"] the line isn't broken as it would make the directive invalid.

IndentSize (unsigned)

Set the number of columns to use for indentation.

Possible values:

  • unsigned integer
  • Preserve: Keep the original indent as it is
! IndentSize: 2
function foo(n)
integer, intent(in) :: n
integer :: i
do i=1,n
print *, i
end do
end function

! IndentSize: 8
function foo(n)
integer, intent(in) :: n
integer :: i
do i=1,n
print *, i
end do
end function

IndentExceptions (IndentExceptionsStyle)

Control specific indentation cases.

Possible values are:

  • IndentBeforeAndAfter: Increase the level of indentation before and after it
  • IndentBefore: Increase the level of indentation before it only
  • DoNotIndent: Keep the current indentation level

Nested configuration flags:

  • ModuleContains: Set the indentation before and after the contains statement in a module
! IndentBeforeAndAfter:
module m
integer :: i
contains
function foo()
print *, i
end function foo
end module m

! IndentBefore:
module m
integer :: i
contains
function foo()
print *, i
end function foo
end module m

! DoNotIndent:
module m
integer :: i
contains
function foo()
print *, i
end function foo
end module m

FixedIndentSize (unsigned)

Set a number of whitespaces at the beginning of each line. Defaults to 0.

! FixedIndentSize: 0
function foo(n)
integer, intent(in) :: n
integer :: i
do i=1,n
print *, i
end do
end function

! FixedIndentSize: 6
function foo(n)
integer, intent(in) :: n
integer :: i
do i=1,n
print *, i
end do
end function

ContinuationIndentSize (unsigned)

Set the number of spaces for line continuations. Defaults to IndentSize * 2.

! ContinuationIndentSize: 0
subroutine foo()
integer :: &
bar
end

! ContinuationIndentSize: 4
subroutine foo()
integer :: &
bar
end

DoubleColonSeparator (DoubleColonSeparatorStyle)

Separates the variable name from its declaration with ::.

Possible values are:

  • AddAlways: Always add :: to separate the type from the variable name
  • Preserve: Keep the original separation as it is
! AddAlways:
real(kind=4), intent(in) :: x, y(:)
real(kind=8) :: z
integer :: a, b
character :: c

! Preserve:
real(kind=4), intent(in) :: x, y(:)
real(kind=8) z
integer :: a, b
character c

EndOfLineNormalization (EndOfLineNormalizationStyle)

Normalize end of line control character sequence.

Possible values are:

  • Autodected: Use the first detected EOL in the input
  • Unix: Use \n
  • Windows: Use \r\n
  • Preserve: Do not normalize end of line character sequences

EndStatementFormat (EndStatementFormatStyle)

Set the format to write the end keyword with its corresponding structure (e.g., end module or end do) and name.

Possible values are:

  • EndOnly: Set only the end keyword
  • EndAndStructure: Set the end with the corresponding structure kind
  • EndStructureAndName: Set the end with the corresponding structure kind and its name
  • Preserve Keep the original form as it is
! EndOnly:
module m
contains
function foo()
end
subroutine bar()
end
end

! EndAndStructure:
module m
contains
function foo()
end function
subroutine bar()
end subroutine
end module

! EndStructureAndName:
module m
contains
function foo()
end function foo
subroutine bar()
end subroutine bar
end module m

EndStatementSeparation (EndStatementSeparationStyle)

Set the separation between end and its corresponding statement.

Possible values are:

  • Joined: Prefer the joined form
  • Separated: Prefer the separated form
  • Preserve: Keep the original form as it is

Nested configuration flags:

  • EndAssociate: Set endassociate or end associate
! Joined:
associate v => myreal
endassociate

! Separated:
associate v => myreal
end associate
  • EndBlockConstruct: Set endblock or end block
! Joined:
block
endblock

! Separated:
block
end block
  • EndBlockData: Set endblockdata or end block data
! Joined:
block data
endendblockdata

! Separated
block data
end block data
  • EndCritical: Set endcritical or end critical
! Joined:
critical
endcritical

! Separated:
critical
end critical
  • EndTeam: Set endteam or end team
! Joined:
change team (t)
endteam

! Separated:
change team (t)
end team
  • EndDoLoop: Set enddo or end do
! Joined:
do i=0,n
enddo

! Separated:
do i=0,n
end do
  • EndEnum: Set endenum or end enum
! Joined:
enum
enumerator :: on, off
endenum

! Separated:
enum
enumerator :: on, off
end enum
  • EndEnumerationType: Set endenumerationtype or end enumeration type
! Joined:
enumeration type
enumerator :: on, off
endenumerationtype

! Separated
enumeration type
enumerator :: on, off
end enumeration type
  • EndForall: Set endforall or end forall
! Joined:
forall(i = 3:n)
c(i) = 0
endforall

! Separated:
forall(i = 3:n)
c(i) = 0
end forall
  • EndFunction: Set endfunction or end function
! Joined:
function foo()
endfunction foo

! Separated:
function foo()
end function foo()
  • EndIf: Set endif or end if
! Joined:
if (i == 0) then
endif

! Separated:
if (i == 0) then
end if
  • EndInterface: Set endinterface or end interface
! Joined:
interface i
endinterface i

! Separated:
interface i
end interface i
  • EndModule: Set endmodule or end module
! Joined:
module m
endmodule m

! Separated:
module m
end module m
  • EndModuleProcedure: Set endprocedure or end procedure
! Joined:
module procedure p
endprocedure p

! Separated:
module procedure p
end procedure p
  • EndProgram: Set endprogram or end program
! Joined:
program myapp
endprogram myapp

! Separated:
program myapp
end program myapp
  • EndSelect: Set endselect or end select
! Joined:
select case (k)
end select

! Separated:
select case (k)
end select
  • EndSubmodule: Set endsubmodule or end submodule
! Joined:
submodule
endsubmodule

! Separated:
submodule
end submodule
  • EndSubroutine: Set endsubroutine or end subroutine
! Joined:
subroutine foo()
endsubroutine foo

! Separated:
subroutine foo()
end subroutine foo()
  • EndType: Set endtype or end type
! Joined:
type myType
integer :: x
endtype

! Separated:
type integer :: x
end type
  • EndWhere: Set endwhere or end where
! Joined:
where(i < 1.0)
endwhere

! Separated:
where(i < 1.0)
end where

EnsureNewlineAtEOF (Boolean)

If true, add a newline sequence at the end of the file if it was missing.

ConsecutiveEmptyLines (unsigned)

Ensures that at most MaxToKeep consecutive empty lines appear in the file, by trimming longer sequences down to that value. BetweenProcedures overrides it for the lines that separate procedures, where it will also add empty lines to maintain that exact number.

Valid values are:

  • Positive integer number (Default: 1)
  • Preserve: Keep consecutive empty lines as found
subroutine foo()
a = 0


b = 1
end subroutine foo

With MaxToKeep: 1 becomes:

subroutine foo()
a = 0

b = 1
end subroutine foo
subroutine foo()
end subroutine foo
subroutine bar()
end subroutine bar

With BetweenProcedures: 1 becomes:

subroutine foo()
end subroutine foo

subroutine bar()
end subroutine bar
  • RemoveAtStartOfFile: If true, removes all empty lines in the begining of the file (Default: true)


subroutine foo()
end subroutine foo()

Becomes:

subroutine foo()
end subroutine foo()
  • RemoveAtEndOfFile: If true, removes all empty lines at the end of the file
subroutine foo()
end subroutine foo()


Becomes:

subroutine foo()
end subroutine foo()

KindKeywordPrefix (KindKeywordPrefixStyle)

Add or remove the optional kind= keyword for intrinsic type variable declarations that already specify it.

Possible values are:

  • AddAlways: Always add kind=
  • RemoveAlways: Always remove kind=
  • Preserve: Keep the original form as it is
! AddAlways:
real(kind=4) :: i
real(kind=dp) :: d

! RemoveAlways:
real(4) :: i
real(dp) :: d

RelationalOperators (RelationalOperatorsStyle)

Replace legacy textual relational operators (e.g., .lt., .eq.) by its symbol form.

Possible values are:

  • UseSymbols: Convert the legacy textual way into the corresponding symbol
  • Preserve Keep the original form as it is
! UseSymbols:
i < 10
i == 10

! vs

i .lt. 10
i .eq. 10

SpacesAroundOperators (OperatorSpacingStyle)

Control the use of a space before (leading) and after (trailing) operators like +.

Possible values of OperatorSpacingStyle are:

OperatorSpacingStyleLeadingTrailingAfter formatting
NoSpacesRemoveRemovea+b
BothAddAdda + b
OnlyLeadingAddRemovea +b
OnlyTrailingRemoveAdda+ b
LeadingAddPreservea +b or a + b
NoLeadingRemovePreservea+b or a+ b
TrailingPreserveAdda+ b or a + b
NoTrailingRemovePreservea+b or a +b
PreservePreservePreserveAny of the above

These values can be applied to + and other operators with the following nested configuration flags. Examples are shown with Both spaces and the relevant operator in this format:

OperatorClassExample
LeftParenthesisExpressiona / ( b + c)
RightParenthesisExpression(a + b ) / c
LeftParenthesisGenericfunction ( a)
RightParenthesisGenericfunction(a ) result(b)*
LeftParenthesisKeyworddo while ( a > 0)
RightParenthesisKeywordif (a ) then
Assignmenta = b
Associationa => b
ControlFlowAssignmentdo i = 1, 5
KeywordAssignmentkind = 4
ParameterAssignmentparameter (PI = 3.141593)
BinaryArithmetica + b
Exponentiationa ** b
DefinedBinarya .defbinop. b
DefinedUnary.defunop. a
Relationala < b
RelationalLegacya .lt. b
LogicalBinarya .and. b
LogicalNot.not.` a
UnaryPlusMinus.not.` a
Commaa , b
Concata // b
DoubleColona :: b

RemoveConsecutiveWhitespace (Boolean)

If true, turns any sequence of whitespace characters between visible characters of a line into a single space. With the exception of string literals and comments. For example:

answer = 'forty   two'   ! precomputed   answer

becomes

answer = 'forty   two' ! precomputed   answer

RemoveSemicolons (Boolean)

If true, removes semicolons whenever possible

! true:
a = 5

! false:
a = 5;

RemoveTrailingWhitespace (Boolean)

If true, any tabs and spaces between the last visible character and the end of each line are removed.

! true:
function foo()
real :: x
! ^--- end of line
end function foo

! false:
function foo()
real :: x
! ^--- end of line
end foo

SeparateMultipleInlineStatements (Boolean)

If true, separates statements that are in the same line, delimited with a ;, into different lines. See RemoveSemicolons if you also want to remove the separating semicolons.

! true:
a = 5;
b = 6

! false:
a = 5; b = 6