Skip to main content
Engineering LibreTexts

27.1: Fortran 95/2003/2008 Keywords

  • Page ID
    54813
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    In programming, a keyword is a word or identifier that has a special Fortran 95/2003/2008 meaning. Keywords are reserved in that they cannot be used for anything else such variable names.

    The Type as listed in the table refers to the following:

    • statement \(\rightarrow\) implies a keyword that starts a statement, usually one line unless there is a continuation "&"
    • construct \(\rightarrow\) implies multiple lines, usually ending with "end ..."
    • attribute \(\rightarrow\) implies it is used in a statement to further clarify or specify additional information.

    For reference, below is a partial list of keywords or reserved words. For a complete list of keywords, refer to the on-line GNU Fortran 95/2003/2008 documentation.

    Keyword Type Meaning
    allocatable attribute no space allocated here later allocate
    allocate statement allocate memory space now for variable
    assignment attribute means subroutine is assignment (=)
    backspace statement back up one record
    call statement call a subroutine
    case statement used in select case structure
    character statement intrinsic data type
    close statement close a file
    complex statement intrinsic data type
    contains statement internal subroutines and functions follow
    cycle statement continue the next iteration of a do loop (skipping the subsequent statements)
    deallocate statement free up storage used by specified variable
    default statement in a select case structure - all others
    do construct start a do loop
    else construct part of if, else if, else, end if
    else if construct part of if, else if, else, end if
    elsewhere construct part of where, elsewhere, end where
    end do construct ends do loop
    end function construct ends function
    end if construct ends if
    end interface construct ends interface
    end module construct ends module
    end program construct ends program
    end select construct ends select case
    end subroutine construct ends subroutine
    end type construct ends type
    end where construct ends where
    endfile statement mark the end of a file
    exit statement continue execution outside of a do loop
    format statement defines a format
    function statement starts the definition of a function
    if statement and construct if(...) statement
    implicit statement "none" is preferred to help find errors
    in a keyword for intent the argument is read only
    inout a keyword for intent the argument is read/write
    integer statement intrinsic data type
    intent attribute intent(in) or intent(out) or intent(inout)
    interface construct begins an interface definition
    intrinsic statement says that following names are intrinsic
    inquire statement get the status of a unit
    kind attribute sets the kind of the following variables
    len attribute sets the length of a character string
    logical statement intrinsic data type
    module construct beginning of a module definition
    namelist statement defines a namelist of input/output
    nullify statement nullify a pointer
    only attribute restrict what comes from a module
    open statement open or create a file
    operator attribute indicates function is an operator like +
    optional attribute a parameter or argument is optional
    out a keyword for intent the argument will be written
    print statement performs output to screen
    pointer attribute defined the variable as a pointer alias
    private statement and attribute in a module
    program construct start of a main program
    public statement and attribute in a module - visible outside
    read statement performs input
    real statement intrinsic data type
    recursive attribute allows functions and derived type recursion
    result attribute allows naming of function result
    return statement returns from exits subroutine or function
    rewind statement move read or write position to beginning
    select case construct start of a case construct
    stop statement terminate execution of the main procedure
    subroutine construct start of a subroutine definition
    target attribute allows a variable to take a pointer alias
    then construct part of if construct
    type construct start of user defined type
    use statement brings in a module
    where construct conditional assignment
    while construct a while form of a do loop
    write statement performs output

    This page titled 27.1: Fortran 95/2003/2008 Keywords is shared under a CC BY-NC-SA 3.0 license and was authored, remixed, and/or curated by Ed Jorgensen via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.

    • Was this article helpful?