Li Dong
Li Dong

Reputation: 1108

How to get subroutine calling hierarchy in Fortran?

In a subroutine, I would like to know which upper subroutine is calling it when error occurs. Is there any way without using arguments? So users of the subroutine could be notified the upper subroutine.

Upvotes: 0

Views: 429

Answers (1)

High Performance Mark
High Performance Mark

Reputation: 78364

There is nothing built in to Fortran which will give you the sort of information you seek. You could, as you suggest, write your own programs to report the information but it strikes me that doing so might burden your code with a lot of error-reporting infrastructure which obscures its meaning and materially affects its importance.

I suggest that you investigate your compiler's capabilities. Intel Fortran, for example, offers a traceback option which is often useful for diagnosing the causes of problems. Start your reading here. All the other Fortran compilers I've worked with offer similar facilities, check the documentation.

Upvotes: 2

Related Questions