- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
> 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.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.)
call sub1(33.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok, I understand it, thanks for the answers.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page