- #1
kubota
- 4
- 0
What Is Actually Being Passed in a Fortran Sub Call??
I'm trying to understand exactly what is being passed from a calling routine to a called routine in an older Fortran program. Perhaps if I could present a simple example to illustrate my dilemma:
Say the calling routine includes this code:
'
Real Array1
Integer Array2
Dimension Array1(20,100), Array2(100)
'
which established Array1 as a two-dimension Real array of size 20x100, and Array2 as a single-dimension Integer array of size 100. So far so good.
A call to a subroutine is then made:
CALL SUB1(Array1(1,err1), Array2(err2))
'
where err1 and err2 are some index values.
Now, the Subroutine is declared as:
SUBROUTINE SUB1(Z, L)
Real Z
Integer L
Dimension Z(100)
'
where Z is a Real array of size 100, and L is an Integer variable.
Thus we have a two-dimension array, Array1, being passed to a single-dimension array, Z, and a single-dimension array, Array2, being passed to an integer variable L.
I do not understand how such code is able to successfully work, nor can I determine exactly what is being passed to/received by the called sub.
BTW, this type of code usage is used in Quadpack, so I presume the code does operate correctly.
I'm hoping someone can advise me how this Fortran code is able to work. I haven't been able to find this information to date, nor in any books I have.
TIA for any assistance.
I'm trying to understand exactly what is being passed from a calling routine to a called routine in an older Fortran program. Perhaps if I could present a simple example to illustrate my dilemma:
Say the calling routine includes this code:
'
Real Array1
Integer Array2
Dimension Array1(20,100), Array2(100)
'
which established Array1 as a two-dimension Real array of size 20x100, and Array2 as a single-dimension Integer array of size 100. So far so good.
A call to a subroutine is then made:
CALL SUB1(Array1(1,err1), Array2(err2))
'
where err1 and err2 are some index values.
Now, the Subroutine is declared as:
SUBROUTINE SUB1(Z, L)
Real Z
Integer L
Dimension Z(100)
'
where Z is a Real array of size 100, and L is an Integer variable.
Thus we have a two-dimension array, Array1, being passed to a single-dimension array, Z, and a single-dimension array, Array2, being passed to an integer variable L.
I do not understand how such code is able to successfully work, nor can I determine exactly what is being passed to/received by the called sub.
BTW, this type of code usage is used in Quadpack, so I presume the code does operate correctly.
I'm hoping someone can advise me how this Fortran code is able to work. I haven't been able to find this information to date, nor in any books I have.
TIA for any assistance.