Skip to main content
Engineering LibreTexts

15.3: Arguments

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

    When writing and using Fortran subprograms, it is typically necessary to provide data to a subprogram and/or to obtain results back from the functions or subroutines. This information, in the form of variables, is referred to as an argument or arguments. The argument or arguments in the calling routine are referred to as actual arguments, and the argument or arguments in the function or subroutine are referred to as formal arguments. The formal arguments take on the values that are passed from the calling routine.

    The only way to transfer values in to or out of a subroutine is through the arguments. A function typically passes values in through the arguments with a single return value (via the function name). All other variables are independent and isolated.

    Argument Intent

    Subprograms often return values by altering or updating some of the arguments. When passing a variable, the information (value or values) can be passed into the function or subroutine. This is referred to as “intent(in)”. If the variable is to be set by the function or subroutine, that is referred to as “intent(out)”. If the variable contains a value or multiple values (i.e., an array) that are to be passed into the function or subroutine and altered in some way by the function or subroutine and returned back to the calling routine, that is referred to as “intent(inout)”.


    This page titled 15.3: Arguments 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?