# Does a SUBROUTINE know its own name?

**URL:** <https://fortran-lang.discourse.group/t/does-a-subroutine-know-its-own-name/7616>\
**Category:** Help\
**Created:** [March 14, 2024, 11:09am UTC](https://fortran-lang.discourse.group/t/does-a-subroutine-know-its-own-name/7616 "2024-03-14T11:09:34Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![urbanjost](https://avatars.discourse-cdn.com/v4/letter/u/0ea827/32.png) [@urbanjost](https://fortran-lang.discourse.group/u/urbanjost)\
**Post date:** [March 15, 2024, 6:45pm UTC](https://fortran-lang.discourse.group/t/does-a-subroutine-know-its-own-name/7616/13 "2024-03-15T18:45:53Z")

</div>

It is a shame. Once people can easily access the procedure names a stack trace is so useful people will implement it with a linked list or some other pop/push, probably conditionally and far less efficiently than the compiler/loader could, creating a lot of duplicate efforts.

I already have seen codes that manually pass the name of the caller procedure to the callee to provide this. I would guess there were be several fpm(1) projects as soon as the feature is in Fortran to create libraries for generating a stack trace using the proposed feature.

It does seem many Fortran compilers provide at least an optional backtrace ability; albeit often only at low optimization and with symbol tables available. That indicates it might not be too big an ask to make it standard at least in some “conditionally available” way; but most (all?) of the system interface procedures like date\_and\_time are only optionally required to fully function.

## See Also:

> [@Getting a backtrace](https://fortran-lang.discourse.group/t/getting-a-backtrace/2332):
>
> When a code has painted itself into a corner, or discovered an unexpected catastrophic error, it is useful to the developer if the code provides a back trace. Although it’s probably a source of confusion for the user, at least the user can send it to the developer. One can get a back trace in a debugger such as gdb, but not after the code has stopped . Otherwise, one must know where the problem was detected or reported, to plant a break in the debugger. Most of us have some kind of CRASH\_BURN ro…

> [@How to print a human-readable backtrace with \`nvfortran\`?](https://fortran-lang.discourse.group/t/how-to-print-a-human-readable-backtrace-with-nvfortran/4843):
>
> How to print a human-readable backtrace with nvfortran when an exception occurs? First of all, let me acknowledge that this question is better asked on the NVIDIA Developer Forum. However, I cannot log in the forum because the verification email takes an eternity to arrive. So I try here in case someone knows the answer. Here is a minimal example. ! test.f90 program test …

---

_[View the full topic](https://fortran-lang.discourse.group/t/does-a-subroutine-know-its-own-name/7616)._
