View previous topic :: View next topic |
Author |
Message |
simon
Joined: 05 Jul 2006 Posts: 268
|
Posted: Mon Apr 04, 2022 7:02 am Post subject: Undefined function argument |
|
|
The following program creates an array ia, and then calls function f1, which in turn calls function f2 to assign some values to the array. Function f2 apparently is returning ia as undefined. If you change f2 to a subroutine, the behaviour is as expected.
I am using FTN95 version 8.83. I have not tried this program with other versions.
Code: | Module m
Integer, Dimension(:), Allocatable, Public :: ia
Contains
!
Subroutine s1 (n)
Integer, Intent(In) :: n
!
Allocate (ia(n))
Return
End Subroutine s1
!
Function f1()
Integer :: f1
f1 = f2(ia(:))
print*,'f1:',ia(:)
!
Return
End Function f1
!
Function f2(ia2)
Integer :: f2
Integer, Dimension(:), Intent(Out) :: ia2
!
ia2(:) = 1
Print*,'f2:',ia2(:)
f2 = 0
Return
End Function f2
End Module m
!
Program p
Use m
Integer :: i
Call s1(5)
i = f1()
End Program p |
|
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7924 Location: Salford, UK
|
Posted: Mon Apr 04, 2022 8:16 am Post subject: |
|
|
Simon
At the moment I don't think that this is a regression in FTN95 and it is probably a bug that needs fixing.
The failure relates to passing the array section in the line
If you replace this line with
then the program runs correctly. |
|
Back to top |
|
|
simon
Joined: 05 Jul 2006 Posts: 268
|
Posted: Mon Apr 04, 2022 4:09 pm Post subject: |
|
|
Thanks Paul.
I can certainly implement
in a few cases. But since it is not always a simple option, I will look into converting f2 to a subroutine, which seems to avoid the problem too. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7924 Location: Salford, UK
|
Posted: Sat Oct 08, 2022 5:34 pm Post subject: |
|
|
This failure has now been fixed for the next release of FTN95. |
|
Back to top |
|
|
|