# Nested function/subroutine limit

**URL:** <https://fortran-lang.discourse.group/t/nested-function-subroutine-limit/3415>\
**Category:** Help\
**Created:** [May 9, 2022, 6:35am UTC](https://fortran-lang.discourse.group/t/nested-function-subroutine-limit/3415 "2022-05-09T06:35:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fortran4r](https://avatars.discourse-cdn.com/v4/letter/f/9de0a6/32.png) [@fortran4r](https://fortran-lang.discourse.group/u/fortran4r)\
**Post date:** [May 9, 2022, 6:35am UTC](https://fortran-lang.discourse.group/t/nested-function-subroutine-limit/3415/1 "2022-05-09T06:35:29Z")

</div>

Is there a limit to the number of layers in nested function/subroutine?

---

<div class="post-metadata">

**Author:** ![everythingfunctional](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/everythingfunctional/32/176_2.png) [@everythingfunctional](https://fortran-lang.discourse.group/u/everythingfunctional)\
**Post date:** [May 9, 2022, 3:53pm UTC](https://fortran-lang.discourse.group/t/nested-function-subroutine-limit/3415/2 "2022-05-09T15:53:58Z")

</div>

Yes, the limit is one layer.

A **subprogram** may have **internal procedures** , and these are considered different things in the standard. A **subprogram** is either a main program, a procedure in a module, or an external procedure. **Internal procedures** follow a `contains` statement in one of those things, and **internal procedure** cannot contain **internal procedures** , thus the limit is one layer of nesting.
