Findent - man page
FINDENT(1) User Commands FINDENT(1)
NAME
findent - Indents, converts and relabels Fortran programs.
SYNOPSIS
findent [OPTION]...
Findent reads from STDIN and writes to STDOUT.
DESCRIPTION
Findent indents and optionally relabels a Fortran source. Findent can convert from fixed
form to free form and vice-versa, 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.
Options marked with [NO_ENV] are ignored if given via environment variable FINDENT_FLAGS.
In the long options, you can replace '_' with '-'.
Below: <n> denotes an unsigned decimal number.
<c> denotes a character.
General options:
-h, --help
print this text. [NO_ENV]
-H, --manpage
print man page. [NO_ENV]
--readme
print some background information. [NO_ENV]
--changelog
print ChangeLog. [NO_ENV]
-v, --version
prints findent version. [NO_ENV]
-q, --query_fix_free
guess free or fixed, prints 'fixed' or 'free' and exits. [NO_ENV]
--continuation=<c>
' ': (default) do not change continuation characters.
'0': create numbered continuation characters.
other: use that continuation character.
default for conversion from free to fixed is '&'.
--include_left=<n>
(0/1) 1: indent include statements to starting indent (default:0).
-l<n>, --label_left=<n>
(0/1) 1: move statement labels to start of line.
(default: free: 1, fixed: 0)
-lastindent, --last_indent
prints computed indentation of last line.
(for usage with vim) [NO_ENV]
-lastusable, --last_usable
prints line number of last line usable.
as start for indenting(for usage with vim). [NO_ENV]
-iauto, --input_format=auto
determine automatically input format (free or fixed).
-ifixed, --input_format=fixed
force input format fixed (default: auto).
-ifree, --input_format=free
force input format free (default:auto).
-i-, --indent=none
do not change indent (useful in combination with -R).
-L<n>, --input_line_length=<n>
use only first <n> characters of each line.
default=0: take whole lines.
-L<n>g, --input_line_length=<n>g
same as above, but use gfortran convention.
for counting the characters with tabbed lines.
example: --input_line_length=72g.
-M<n>, --max_indent=<n>
maximum output indent, default 100, 0: no limit.
-ofixed, --output_format=fixed
force fixed format output.
-ofree, --output_format=free
force free format output.
-osame, --output_format=same
output format same is input format.
--openmp=<n>
1/0: do/don't indent openmp conditionals (default: 1).
NOTE: for free format, the omp sentinel must be '!$ '.
-Rr, --refactor_end
refactor subroutines etc: 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>'
'end interface <name>'
'end type <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'.
NOTE3: the flag --refactor_procedures is deprecated, use --refactor_end.
-RR, --refactor_end=upcase
same as -Rr, but 'END SUBROUTINE <name>'. in stead of 'end subroutine <name>' etc.
--relabel=shuffle
shuffles existing labels,
primarily meant for demo and debugging.
see also the notes under --relabel below.
--relabel, --relabel=<n1>,<n2>
renumber labels: n1 = starting index,
n2 is increment (default:1000,10).
if n1=0 or n2=0, relabeling is disabled.
see also RELABEL below.
NOTE1: use only SYNTAX-CORRECT SOURCES with this option.
NOTE2: CHECK the functionality of your program after using this option.
NOTE3: after finding an error (missing label, ill formatted label list, ...)
findent will stop relabeling, but will continue indenting
and/or converting.
--relabel_reset=<n>
1: reset label numbering at start of subroutine/function/program. 0: do not reset
label numbering (default: 0).
--query_relabel[=<n>]
generate report. [NO_ENV]
n=0, or flag omitted: do not generate report.
n=1: generate summary (only error message or OK message).
n=2: generate report of original and renumbered labels (default).
NOTE: if n >= 0, no output of the fortran source.
--ws_remred[=<n>]
replace redundant white space with one space.
n=0, or flag omitted: do not replace redundant spaces.
NOTE1: use with care, avoid pieces of code with not terminated
strings and use Fortran code without syntax errors:
changes are irreversible.
NOTE2: for statements containing an hollerith, this flag is ignored.
--safe ignore next flags marked with [NO_ENV] (used by wfindent).
Indenting options:
-I<n>, --start_indent=<n>
starting indent (default:0).
-Ia, --start_indent=a
determine starting indent from first line.
-i<n>, --indent=<n>
all indents except I,c,C,e (default: 3).
-a<n>, --indent_associate=<n>
ASSOCIATE indent.
-b<n>, --indent_block=<n>
BLOCK indent.
-d<n>, --indent_do=<n>
DO indent.
-f<n>, --indent_if=<n>
IF indent.
-E<n>, --indent_enum=<n>
ENUM indent.
-F<n>, --indent_forall=<n>
FORALL indent.
-j<n>, --indent_interface=<n>
INTERFACE indent.
-m<n>, --indent_module=<n>
MODULE indent.
-r<n>, --indent_procedure=<n>
FUNCTION,
SUBROUTINE and PROGRAM indent.
-s<n>, --indent_select=<n>
SELECT indent.
-t<n>, --indent_type=<n>
TYPE indent.
-w<n>, --indent_where=<n>
WHERE indent.
-x<n>, --indent_critical=<n>
CRITICAL indent.
--indent_changeteam=<n>
CHANGE TEAM indent.
-C-, --indent_contains=restart,
restart indent after CONTAINS.
-k<n>, --indent_continuation=<n>
continuation indent except
for lines starting with '&' (see flag -K).
NOTE: free to free only.
-k-, --indent_continuation=none
continuation lines not preceded
by '&' are untouched.
NOTE: free to free only.
-kd, --indent_continuation=default
continuation lines not preceded
by '&' are default indented.
NOTE: free to free only.
-K, --indent_ampersand
indent lines starting with '&' (free only).
--align_paren[=<n>]
align continuation lines not preceded
by '&' with preceding unmatched left parenthesis.
n=0, or flag omitted: do not align.
n=1: do align (default).
NOTE1: free to free only.
NOTE1: for statements containing an hollerith, this flag is ignored.
Next defaults are: all - all/2.
-c<n>, --indent_case=<n>
CASE negative indent.
NOTE: also for RANK, TYPEIS and CLASSIS.
-C<n>, --indent_contains=<n>
CONTAINS negative indent.
-e<n>, --indent_entry=<n>
ENTRY negative indent.
Dependencies:
--deps output dependency information only, other flags are ignored. [NO_ENV]
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
--makefdeps
outputs a sh(1) script that serves as a an example
to generate dependencies for use in make(1). [NO_ENV]
Environment:
findent parses the environment variable FINDENT_FLAGS before the command-line flags.
Usage with vim:
--vim_help
outputs directions to use findent in (g)vim. [NO_ENV]
--vim_fortran
outputs file 'fortran.vim', see --vim_help. [NO_ENV]
--vim_findent
outputs file 'findent.vim', see --vim_help. [NO_ENV]
Usage with gedit:
--gedit_help
outputs directions to use findent in gedit. [NO_ENV]
--gedit_external
outputs script 'findent-gedit', see --gedit_help. [NO_ENV]
--gedit_plugin
outputs file 'findent.plugin', see --gedit_help. [NO_ENV]
--gedit_plugin_py
outputs file 'python.py', see --gedit_help. [NO_ENV]
Usage with emacs:
--emacs_help
outputs directions to use findent in emacs. [NO_ENV]
--emacs_findent
outputs script 'findent.el', see --emacs_help. [NO_ENV]
Self replication:
--selfrep
outputs source tar ball to stdout [NO_ENV]
Example: create the tar.gz file:
findent --selfrep > findent.tar.gz
Example: create the unpacked source tar ball:
findent --selfrep | tar zxf -
RELABEL:
The following constructs are candidates for relabeling:
- 100,110,120,130: label
- X: integer or real or logical expression
- I: identifier
- [,]: optional comma
- ...: not parsed by findent, can be anything except '=...'
- [IF]: optional IF(...)
100 ... ! statement or format label
IF(...) 110,120,130
IF(...) 110,120
DO 100[,] I=X,...
DO 100[,] WHILE(...)
DO 100[,] CONCURRENT(...)
DO 100
[IF] ACCEPT 100...
[IF] ASSIGN 100 TO I
[IF] BACKSPACE(...,ERR=100,...)
[IF] CALL I(...,*100,...,$110,...,&120,...)
[IF] CLOSE(...,ERR=100,...)
[IF] DECODE(...,100,...,ERR=110,...)
[IF] DELETE(...,ERR=110,...)
[IF] ENCODE(...,100,...,ERR=110,...)
[IF] ENDFILE(...,ERR=100,...)
[IF] FIND(...,ERR=110,...)
[IF] FLUSH(...,ERR=100,...)
[IF] GOTO 100
[IF] GOTO I[,](100,110,120)
[IF] GOTO(100,110,120)...
[IF] INQUIRE(...,ERR=100,...)
[IF] OPEN(...,ERR=100,...)
[IF] PRINT 100...
[IF] READ 100...
[IF] READ(...,100,...)
[IF] READ(...,ERR=100,...,END=110,EOR=120,...,FMT=130)...
[IF] REREAD 100...
[IF] REREAD(...,100,...)
[IF] REREAD(...,ERR=100,...,END=110,EOR=120,...,FMT=130)...
[IF] REWIND(...,ERR=100,...)
[IF] REWRITE(...,100) ...
[IF] REWRITE(...,ERR=100,...,FMT=110,...,EOR=120)...
[IF] TYPE 100...
[IF] WAIT(...,ERR=100,...,END=110,...,EOR=120,...)
[IF] WRITE(...,100) ...
[IF] WRITE(...,ERR=100,...,FMT=110,...,EOR=120)...
Examples:
Indent: findent < in.f > out.f
findent -i2 -r0 < in.f > out.f
Relabel: findent --relabel < 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
NOTE: In PowerShell use something like:
cat in.f | findent -i2 -r0 > out.f
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 con‐
tinuation 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"
* Relabel issues
In some cases, findent refuses to relabel.
To see the cause, use the flag '--query-relabel=1', e.g.:
findent --relabel=10,10 --query-relabel=1
If the fortran source contains label-related errors, or when findent misbehaves,
relabeling can create havoc. So: test.
DONATIONS
Donations to support the maintenance of this program are welcome: https://paypal.me/wver‐
min
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.
findent-4.3.3 2023 FINDENT(1)