Scroll to navigation

FINDENT(1) User Commands FINDENT(1)

NAME

findent - Indents and optionally converts Fortran program source

SYNOPSIS

findent [OPTION]...

Findent reads from STDIN and writes to STDOUT.

DESCRIPTION

Findent indents a Fortran source. Findent uses various kinds of indentations, see OPTIONS. Findent can convert from fixed form to free form, and can supplement single END statements, see 'Refactor' below. Comment lines with '!' in column one are not indented.
You can correct findent related indenting errors by inserting comment lines:
! findentfix: <fortran statement>
where <fortran statement> is for example DO, END, WHERE() etcetera. Findent will adjust the indentation according to <fortran statement>.
Errors in OPTIONS are silently ignored.

General options:

Below: <n> denotes an unsigned decimal number.
<c> denotes a character.

In the long options, you can replace '_' with '-'.

print this text
print man page
print some background information
prints findent version
guess free or fixed, prints 'fixed' or 'free' and exits

' ': (default) do not change continuation characters
'0': create numbered continuation characters
other: use that continuation character
default for conversion from free to fixed is '&'
(0/1) 1: indent include statements to starting indent (default:0)
(0/1) 1: move statement labels to start of line (default:1)
(only for free format)
prints computed indentation of last line
(for usage with vim)
prints line number of last line usable
as start for indenting(for usage with vim)
determine automatically input format (free or fixed)
force input format fixed (default: auto)
force input format free (default: auto)
do not change indent (useful in combination with -R)
use only first <n> characters of each line default=0: take whole lines
same as above, but use gfortran convention for counting the characters with tabbed lines
example: --input_line_length=72g
maximum output indent, default 100, 0: no limit
force fixed format output
force free format output
output format same is input format

0: do not indent openmp conditionals
1: indent openmp conditionals (default)
NOTE: for free format, the omp sentinel must be '!$ '
refactor procedures and modules: the END line
of a subroutine, program etc. is, if possible, replaced by
'end subroutine <name>' or
'end function <name>' or
'end procedure <name>' or
'end program <name>' or
'end block data <name>' or
'end module <name>' or
'end submodule <name>'
where <name> is the name of the appropriate procedure, subroutine etc.
NOTE1: if the END line contains a continuation the results are undefined
NOTE2: a line like 'end function fun' will be replaced by
'end subroutine sub' if the END line ends 'subroutine sub'
same as -Rr, but 'END SUBROUTINE <name>' in stead of 'end subroutine <name>' etc.

Indenting options:

starting indent (default:0)
determine starting indent from first line
all indents except I,c,C,e (default: 3)
ASSOCIATE indent
BLOCK indent
DO indent
IF indent
ENUM indent
FORALL indent
INTERFACE indent
MODULE indent
FUNCTION,
SUBROUTINE and PROGRAM indent
SELECT indent
TYPE indent
WHERE indent
CRITICAL indent
CHANGE TEAM indent
restart indent after CONTAINS
continuation indent except
for lines starting with '&'
free to free only
continuation lines not preceded
by '&' are untouched
free to free only
next defaults are: all - all/2
CASE negative indent
CONTAINS negative indent
ENTRY negative indent

Dependencies:

output dependency information only, other flags are ignored. This can be used to generate a dependencies file for usage with make(1).
The format of this information:
Fortran source -> findent output
include "file1" -> inc file1
#include "file2" -> cpp file2
#include <file3> -> std file3
??include 'file4' -> coc file4
use module1 -> use module1
submodule(m) subm -> use m
mod m:subm
module module2 -> mod module2
outputs a sh(1) script that serves as a an example
to generate dependencies for use in make(1).

Environment:

findent parses the environment variable FINDENT_FLAGS before the command-line flags

Usage with vim:

outputs directions to use findent in (g)vim
outputs file 'fortran.vim', see --vim_help
outputs file 'findent.vim', see --vim_help

Usage with gedit:

outputs directions to use findent in gedit
outputs script 'findent-gedit', see --gedit_help
outputs file 'findent.plugin', see --gedit_help
outputs file 'python.py', see --gedit_help

Usage with emacs:

outputs directions to use findent in emacs
outputs script 'findent.el', see --emacs_help

Examples:

indent: findent < in.f > out.f
findent -i2 -r0 < in.f > out.f

convert fixed to free form: findent -ofree < prog.f > prog.f90

convert free to fixed form: findent -ofixed < prog.f90 > prog.f

refactor 'end': findent -Rr < in.f90 > out.f90

BUGS:

*
Also for free-format, findent is space-insensitive, while the standard states that space must be used as general separator.

*
There are some issues with labels in a continuation when converting from free to fixed format. For example:

123&
4 continue

The problems arise because it is not possible to define a statement label in a continuation in fixed format.

*
When converting from fixed format to free format, findent discards white space in a string if the string contains a continuation, e.g:
print *,"a
+b"

is converted to:
print *,"a&
&b"

DONATIONS

Donations to support the maintenance of this program are welcome: https://paypal.me/wvermin

COPYRIGHT

This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

2019 findent-3.1.7