In fact, on every system I've tried so far, this routine works perfectly. N) THEN X = X + 1 PRINT *, 'x = ', X CALL DUMSUB(X,DUMSUB) END IF ENDI've read in some texts that indirect reference is not allowed, but ask yourself "How can SUB1 possibly know that it's actually calling itself when it calls the dummy subroutine?" It can't, and thus this must work. PROGRAM MAIN INTEGER N, X EXTERNAL SUB1 COMMON /GLOBALS/ N X = 0 PRINT *, 'Enter number of repeats' READ (*,*) N CALL SUB1(X,SUB1) END SUBROUTINE SUB1(X,DUMSUB) INTEGER N, X EXTERNAL DUMSUB COMMON /GLOBALS/ N IF(X. The subroutine can then call itself by calling the dummy subroutine. However, one can implement recursion in a round about way by passing the subroutine as an argument to itself. Attempting to do such will result in a compile time error with compilers that adhere to the FORTRAN 77 standard. FORTRAN 77 subroutines and functions are not allowed to call themselves directly. Information on product installation, new and changed features, and issues that are not described in the product documentation.Īsk questions and find answers in the Intel® Fortran Compiler forum.Īdd oneAPI components to a Yocto project build using the meta-intel layers.Īccess general help for compiler options at the command line after setting up the environment.Example 1: How to write recursive routines in FORTRAN 77Įxample 2: Behavior of local variables in recursive routines in FORTRAN 77Įxample 3: Use of the DATA statement in recursive routines in FORTRAN 77Įxample 4: Summary of local variable behavior on several platforms.Įxample 1: Recursive Routines in FORTRAN 77 (and Fortran 90)First let me say that I think every serious Fortran programmer should always write new code in Fortran 90 or Fortran 95, but for those of you stuck on a desert island with only a FORTRAN 77 compiler at your disposal, here's a way to write a recursive subroutine. Intel® Fortran Compiler Classic and Intel® Fortran Compiler Release Notes ![]() Compiler reference material, including options, program structures, class and math libraries, and much moreĮxplore the latest oneAPI Fortran code samples.Įxplore tutorials, training materials, and other Fortran documentation.Support for the latest compiler technologies and architectures. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |