LinuxCommandLibrary

gfortran

TLDR

Compile Fortran file

$ gfortran [source.f90] -o [output]
copy
Compile with optimization
$ gfortran -O3 [source.f90] -o [output]
copy
Enable warnings
$ gfortran -Wall [source.f90] -o [output]
copy
Debug build
$ gfortran -g [source.f90] -o [output]
copy
Link math library
$ gfortran [source.f90] -o [output] -lm
copy

SYNOPSIS

gfortran [options] files...

DESCRIPTION

gfortran is the GNU Fortran compiler, part of GCC. It compiles Fortran 77, 90, 95, 2003, and 2008 standards to native executables.
The compiler provides extensive optimization, debugging support, and interoperability with C code. It benefits from GCC's mature infrastructure.
gfortran is the standard open source Fortran compiler for scientific computing.

PARAMETERS

FILES

Fortran source files (.f, .f90, .f95).
-o FILE
Output filename.
-c
Compile only, no linking.
-g
Generate debug info.
-O LEVEL
Optimization level (0-3).
-Wall
Enable warnings.
-l LIBRARY
Link library.
--help
Display help information.

CAVEATS

Standard compliance varies by feature. Array bounds checking optional. Legacy code may need adaptation.

HISTORY

gfortran replaced g77 as GCC's Fortran compiler starting with GCC 4.0. It supports modern Fortran standards while maintaining compatibility with older code.

SEE ALSO

gcc(1), f2py(1), ifort(1)

Copied to clipboard