Skip to main content
Engineering LibreTexts

4.5: Continuation Lines

  • Page ID
    54252
  • \( \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}}\)

    A statement must start on a new line. If a statement is too long to fit on a line, it can be continued on the next line with an ampersand ('&'). Even shorter lines can be split and continued on multiple lines for more readable formatting.

    For example,

    A = 174.5 * year    &
        + count / 100.0 
    

    Is equivalent to the following

    A = 174.5 * year + count / 100.0
    

    Note that the '&' is not part of the statement.

    Example

    The following trivial program illustrates the program formatting requirements and variable declarations.

    ! Example Program
    
    program example1
    
    implicit none
    integer :: radius, diameter
    integer :: height=100, width=150
    real :: area, perimeter
    real :: length = 123.5, distance=413.761
    real, parameter :: pi = 3.14159
    character(11) :: msg = "Hello World"
        write (*,*) "Greeting: ", msg
    
    end program example1
    

    In this example, a series of variables are defined (as examples) with most not used. The program will display Greeting: Hello World when executed. The following chapters will address how to use the variables to perform calculations and display results. Additional information regarding character variables is provided in chapter 11.


    This page titled 4.5: Continuation Lines 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?