Does a SUBROUTINE know its own name?

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:

2 Likes