Skip to main content
Engineering LibreTexts

10.8: Advance Clause

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

    The advance clause instructs the computer whether or not to advance the cursor to the next line. The possible values are “yes” and “no”. If the advance clause is not included, the default value is “yes”. This clause is useful when prompting for user input to allow the input to be entered on the same line as the prompt. When using the advance clause, the free format (*) is not allowed. A format must be included.

    For example, the period program from the previous chapter included the statements:

    ! prompt for and read the n value
        write (*,'(a)') "Enter count to sum: "
        read (*,*) n
    

    Which, when executed, the input is entered on the line following the prompt.

    c:\mydir> sums
     Example Program
        Difference between sum of squares
        and square of sums
    
     Enter count to sum:
    10
     Difference:         2640
    

    When the advance clause is used with the setting of “no”, as follows:

    ! prompt for and read the n value
        write (*,'(a)', advance="no") "Enter count to sum: "
        read (*,*) n
    

    The resulting execution would be as follows:

    c:\mydir> sums
     Example Program
        Difference between sum of squares
        and square of sums
    
     Enter count to sum: 10
     Difference:         2640
    

    Which allows the input to be entered on the same line as the prompt.


    This page titled 10.8: Advance Clause 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?