Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Getting arguments name

hkausl
Beginner
508 Views
Is there any possibilty to get not only the value, but also the name of an paramter in a function or subroutine. Here's a simply example

Program main
real * 4 value
value = 25.
call sub1 ( 'value', value )
call exit end
subroutine sub ( value_name, value_value )
character * (*) value_name
write ( *,* ) value_name = ', value_value
return end

So it would be written : value = 25.


Would it be possible to get the name of the parameter in the subroutine, so I could avoid the first parameter

call sub1 ( value )
subroutine sub1 ( value )
character * 40) value_name
value_name = ????
value_value = value


This would make a lot of my programs much easier. Thanks for all answers
0 Kudos
3 Replies
mecej4
Honored Contributor III
508 Views
> Would it be possible to get the name of the parameter argument in the subroutine?

No, because variable names (some of which may be argument names) do not exist in the object code. Likewise, after linking, subprogram names do not exist in the executable image file.

When you enable source-level debugging, variable names and subprogram names are available to the debugger, but not to a Fortran program.

What you ask for is reasonable to expect in an interpreted language. Fortran is (almost always) compiled and linked before running. Many of the transformations that the source code undergoes are irreversible.

0 Kudos
anishtain4
Beginner
508 Views
Assume that it was possible, what would happened if instead of a variable you passed a constant to the sub? for example
call sub1(33.)
0 Kudos
hkausl
Beginner
508 Views
Ok, I understand it, thanks for the answers.
0 Kudos
Reply