|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
davidb
Joined: 17 Jul 2009 Posts: 560 Location: UK
|
Posted: Thu Mar 09, 2017 9:53 am Post subject: FTN95 version 8.10 Bug with function argument |
|
|
In the following code a function is passed to subroutine foo, which then passes it to function foo2 (where it is used). When compiled with /checkmate you get a run-time saying that the second argument of the call to foo is not a procedure. This is the bug.
If the call to foo2 is removed, the program runs OK.
This bug has appeared since version 8.10; previously it worked in 8.05 and in earlier versions.
Note: I have only tried using the 32 bit compiler.
Code: |
module kinds
integer, parameter :: dp=kind(1.0d0)
end module kinds
module mmm
use kinds, only: dp
type p_t
real(dp) :: a
real(dp) :: b
end type
contains
function mult(x)
real(dp) :: mult
real(dp), intent(in) :: x
mult = 2.0_dp*x
end function mult
subroutine foo(p, func)
type(p_t), intent(in) :: p
interface
function func(x)
use kinds, only: dp
real(dp) :: func
real(dp), intent(in) :: x
end function func
end interface
print *, foo2(func, 1.0_dp)
! If you replace the above line with this one it runs
!print *, func(1.0_dp)
print *, p%a, p%b
end subroutine foo
function foo2(func, x)
real(dp) :: foo2
real(dp), intent(in) :: x
interface
function func(x)
use kinds, only: dp
real(dp) :: func
real(dp), intent(in) :: x
end function func
end interface
foo2 = func(x)
end function foo2
end module mmm
program test
use mmm
type(p_t) :: p
p%a = 0.0_dp
p%b = 1.0_dp
call foo(p, mult)
end program test
|
Regards,
David. _________________ Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl |
|
Back to top |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Thu Mar 09, 2017 12:54 pm Post subject: |
|
|
Curiously, I see the bug even with 8.05-32 bit when I use /check or /checkmate. I wonder if you and I see different behaviour because our Salflibc.dll versions are different -- I did install the updated Salflibc.dll when Paul L. posted them on Dropbox. |
|
Back to top |
|
|
davidb
Joined: 17 Jul 2009 Posts: 560 Location: UK
|
Posted: Thu Mar 09, 2017 10:00 pm Post subject: Re: |
|
|
mecej4 wrote: | Curiously, I see the bug even with 8.05-32 bit when I use /check or /checkmate. I wonder if you and I see different behaviour because our Salflibc.dll versions are different -- I did install the updated Salflibc.dll when Paul L. posted them on Dropbox. |
I had been running 8.05 and had included updates to 8.05 supplied by Paul on two separate occasions. First he provided on this forum a link to salflibc.dll (modified 16/07/2016 08:20). Then he provided a further updated salflibc.dll (modified 05/09/2016 09:10). I got the modification times by right clicking, then properties on the dll file.
As far as I recall, my "real" code with the above features worked correctly with all versions of 8.05 as I successively applied these updates. However, I don't know if my "test" code above worked because I have only just written it. I will have to revert back to 8.05 until this is fixed, so I can go through the successive updates and check again.
Meanwhile, it would help me if you could confirm the above details about the different versions, if you have saved them somewhere. _________________ Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl |
|
Back to top |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Fri Mar 10, 2017 3:19 am Post subject: |
|
|
The version of salflibc.dll that I have in the 8.05 directory has a modification date of 28 Oct. 2016, and a creation date of 13 July 2016.
That version did not allow /check with /64. The bug can be seen with 8.1 and /64 /check. |
|
Back to top |
|
|
davidb
Joined: 17 Jul 2009 Posts: 560 Location: UK
|
Posted: Fri Mar 10, 2017 8:32 am Post subject: |
|
|
Well it turns out to be a bit more complicated. I successively re-installed version 7.2, then 8.05, then each of the DLL updates I have (I could not find the one you have used mecej4).
I found my "real" code worked fine with all of these, but my "test" code posted above failed with the run-time error. Only version 8.10 fails for both my test code and my real code:
Code: |
Version salflibc.dll test code real code
7.2 16/03/2015 failed ok
8.05 17/06/2016 failed ok
8.05 16/07/2016 failed ok
8.05 05/09/2016 failed ok
8.05 28/10/2016 failed <- mecej4's version
8.10 failed failed
|
This means that, while the code above illustrates a bug in 8.1, the same bug probably has been present since 7.2. It also means my test program isn't good enough. I will see if I can post some code later that is closer to my real code, as this may help Paul to track this bug down.
I was hoping to purchase 8.10 but will I have to hold off until this is fixed. _________________ Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Fri Mar 10, 2017 9:07 am Post subject: |
|
|
I have made a note of this. |
|
Back to top |
|
|
davidb
Joined: 17 Jul 2009 Posts: 560 Location: UK
|
Posted: Fri Mar 10, 2017 5:29 pm Post subject: |
|
|
When I change the test code so there is an additional argument "i" after the procedure argument (see below), the code works in versions 7.2, 8.05 but fails in version 8.10.
This is now the same behavior as my "real" code across all versions:
Code: |
Version salflibc.dll new test code real code
7.2 16/03/2015 ok ok
8.05 17/06/2016 ok ok
8.05 16/07/2016 ok ok
8.05 05/09/2016 ok ok
8.05 28/10/2016 ok <- mecej4's version
8.10 failed failed
|
Perhaps mecej4's would kindly confirm the result for his row.
The new test code is
Code: |
module kinds
integer, parameter :: dp=kind(1.0d0)
end module kinds
module mmm
use kinds, only: dp
type p_t
real(dp) :: a
real(dp) :: b
end type
contains
function mult(x, i)
real(dp) :: mult
real(dp), intent(in) :: x
integer, intent(in) :: i(:)
mult = 2.0_dp*x
end function mult
subroutine foo(p, func, i)
type(p_t), intent(in) :: p
integer, intent(in) :: i(:)
interface
function func(x, i)
use kinds, only: dp
real(dp) :: func
real(dp), intent(in) :: x
integer, intent(in) :: i(:)
end function func
end interface
print *, foo2(1.0_dp, func, i)
! If you replace the above line with this one it runs
!print *, func(1.0_dp, i)
print *, p%a, p%b
end subroutine foo
function foo2(x, func, i)
real(dp) :: foo2
real(dp), intent(in) :: x
integer, intent(in) :: i(:)
interface
function func(x, i)
use kinds, only: dp
real(dp) :: func
real(dp), intent(in) :: x
integer, intent(in) :: i(:)
end function func
end interface
foo2 = func(x, i)
end function foo2
end module mmm
program test
use mmm
type(p_t) :: p
integer :: i(1)
p%a = 0.0_dp
p%b = 1.0_dp
call foo(p, mult, i)
end program test
|
Paul, when debugging this is it important to check both test programs work with 8.10 because there may be two bugs here. _________________ Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl |
|
Back to top |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Fri Mar 10, 2017 7:15 pm Post subject: |
|
|
DavidB,
I can confirm that your new test code works with /check on 8.05 with my DLL version, and fails with 8.10.
By the way, the strange modification date may be the result of an event that I vaguely remember. My antivirus program deleted salflibc.dll for some reason, but placed a copy in quarantine. I had to rescue the file from that location. The file is 2,273,280 bytes long. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Tue Mar 21, 2017 3:17 pm Post subject: |
|
|
This has now been fixed in FTN95 for the next release. |
|
Back to top |
|
|
davidb
Joined: 17 Jul 2009 Posts: 560 Location: UK
|
Posted: Tue Mar 21, 2017 6:59 pm Post subject: |
|
|
Thanks very much Paul. Did you check both test codes? _________________ Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Wed Mar 22, 2017 7:42 am Post subject: |
|
|
Both programs now run OK. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|