- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What is the maximum number of nested loops in the 19 version of Intel Fortran?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This would be a stack size limitation. Larger stack size == more nest levels.
Note, the above is for runtime. At compile time, of a single procedure, the compiler may have an internal limit, possibly limited by its stack size and/or internal structure design for tracking tokens (variables).
If you are running into a problem, please state the particulars.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>>At compile time, of a single procedure, the compiler may have an internal limit,
I have to use about two hundred nested loops. I'm wondering if the translator can cope with this task?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is this in the same procedure? (same subroutine or function)
Why not simply try it?
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Considering the high-level of nesting in your loops, have you looked into recursive algorithm(s) and evaluated whether they can help you with your computing needs?
Starting Fortran 2018, unless marked as NON_RECURSIVE or dictated by some compiler option(s) to override the standard, every procedure is recursive. And one can thus hope a Fortran 2018-compliant compiler will be reasonably good (and striving toward being highly adept) at optimizing the program with respect to recursion, both in terms of run-time (e.g., stack usage) as well as compile-time processing.
Thus investment in recursive algorithms toward one's computing needs can prove valuable in the long-term.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Binary tree traversal with nested loops is much more efficient than any other algorithm. Don't the developers of the translator indicate the maximum nesting of loops?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The Intel documentation, under Compiler Limits, says "DO, CASE, FORALL, WHERE, and block IF statement nesting (combined): 512"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve beat me to it - 512 is correct.
Error Message if you exceed this:
/* 370 */
"The IF, DO, CASE, FORALL, and/or WHERE constructs are nested too deeply. The current limit is 512."
Speaking of limits, array ranks limit = 31
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>>The... DO... constructs are nested too deeply. ..
I would not say this: in advanced algorithms, the initial and final values of the loop parameter are variables, and if they match, the transition to the inner loops is linear in time.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page