Recursion Not Supported by FORTRAN

Last reviewed: December 11, 1995
Article ID: Q63819
The information in this article applies to:
  • Microsoft FORTRAN for MS-DOS, versions 4.0, 4.01, 4.1, 5.0, 5.1
  • Microsoft FORTRAN for OS/2, versions 4.1, 5.0, 5.1
  • Microsoft FORTRAN PowerStation for MS-DOS, versions 1.0 and 1.0a
  • Microsoft FORTRAN PowerStation 32 for Windows NT, version 1.0 and 4.0

SUMMARY

Neither the FORTRAN 77 language, nor the Microsoft FORTRAN 77 Optimizing Compilers, Microsoft FORTRAN Compilers prior to FORTRAN PowerStation 4.0, supports recursion. For more information, see one of the following references:

  • Microsoft FORTRAN PowerStation Language Help, topics: CALL, ENTRY, FUNCTION, and SUBROUTINE.
  • The Microsoft FORTRAN "Reference" manual for versions 5.0 and 5.1, pages 127, 172, 225, and 231.
  • The Microsoft FORTRAN "Language Reference" manual for versions 4.0 and 4.1, pages 174, 218, and 273.
  • The ANSI X3.9-1978 FORTRAN 77 standard, page 15-1 (section 15.2).

NOTE: For more information on recursion with Microsoft FORTRAN 32, version 4.0, consult the FORTRAN PowerStation 4.0 manual, page 144.

MORE INFORMATION

The FORTRAN 77 standard includes the following statement regarding recursion:

   A subprogram must not reference itself, either directly or
   indirectly.

In direct recursion, a subprogram calls itself. According to page 231 of the "Reference" manual, "any attempt at direct recursion results in a compile-time error [F2600: name : directly recursive]."

In indirect recursion, a subprogram calls another subprogram that in turn calls the original subprogram before the first subprogram completed execution. According to page 231 of the "Reference" manual, Microsoft FORTRAN does not detect indirect recursion.

If an application uses indirect recursion, compile the subprograms involved with the /4Ya compiler option switch to place all local variables on the stack. Doing so provides each instance of the subroutine with its own set of local variables.

NOTE: The Fortran 90 standard includes the following statement regarding recursion:

   "Transcending a long-standing tradition, Fortran 90 procedures may be
   recursive."


Additional reference words: kbinf 1.00 4.00 4.01 4.10 5.00 5.10
KBCategory: kbprg
KBSubcategory: FORTLngIss


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: December 11, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.