---
name: "findent"
section: "1"
platform: "linux"
package: "findent"
version: "4.3.5-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/findent"
---

# findent(1)

Indents, converts and relabels Fortran programs.

## 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)](/make/1.md). \
    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)](/sh/1.md) script that serves as a an example\
    to generate dependencies for use in [make(1)](/make/1.md). \[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 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"

- **\***

  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/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.
