| View previous topic :: View next topic |
| Author |
Message |
simon
Joined: 05 Jul 2006 Posts: 314
|
Posted: Thu Dec 18, 2025 11:23 pm Post subject: Abstract Interface |
|
|
| Is it easy to get FTN95 to support ABSTRACT INTERFACE? Blame ChatGPT for the request - it is making some suggestions to "improve" my code! I have just had it help me solve a long-term ClearWin+ problem so I'm giving it a bit more credibility than I would have done a little while back. |
|
| Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8320 Location: Salford, UK
|
Posted: Fri Dec 19, 2025 8:41 am Post subject: |
|
|
"abstract interface" is already supported, at least in some contexts.
See for example \Program Files (x86)\Silverfrost\FTN95\source64\clrwin.f95.
Please let us know if there are valid contexts where it is not supported. |
|
| Back to top |
|
 |
mecej4
Joined: 31 Oct 2006 Posts: 1943 Location: USA
|
Posted: Fri Dec 19, 2025 11:24 am Post subject: |
|
|
Here is an example, which Gfortran 13.4 accepts:
| Code: |
MODULE abstr_int
implicit none
ABSTRACT INTERFACE
function fun_2_args(x, y)
integer,parameter:: dp=kind(0.d0)
real(dp) :: fun_2_args
real(dp), intent(in) :: x, y
end function fun_2_args
END INTERFACE
INTERFACE
module function fun1(x,y)
integer,parameter:: dp=kind(0.d0)
real(dp) :: fun1
real(dp), intent(in) :: x, y
end function fun1
!***
module function fun2(x,y)
integer,parameter:: dp=kind(0.d0)
real(dp) :: fun2
real(dp), intent(in) :: x, y
end function fun2
END INTERFACE
END MODULE abstr_int
|
For this code, FTN95 says:
ERROR S:\absi.F90 13: MODULE cannot appear in a INTERFACE block |
|
| Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8320 Location: Salford, UK
|
Posted: Fri Dec 19, 2025 1:35 pm Post subject: |
|
|
mecej4
Thank you for the feedback. I have logged this for investigation. |
|
| Back to top |
|
 |
simon
Joined: 05 Jul 2006 Posts: 314
|
Posted: Sat Dec 20, 2025 8:21 am Post subject: |
|
|
It is great to see Abstract Interface available. I did find one problem. In the program below, FTN95 compiles with an error message stating that cbf0 is undefined. The error message goes away if Only is not used.
| Code: |
! FTN95 does not recognise cbf0, but does if Only is removed
Module m1
Public :: cbf0
Abstract Interface
Integer Function cbf0()
End Function cbf0
End Interface
End Module m1
Module m2
Use m1, Only: cbf0
Contains
Integer Function cbf( f1 )
Procedure(cbf0) :: f1
End Function cbf
End Module m2 |
|
|
| Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8320 Location: Salford, UK
|
Posted: Sat Dec 20, 2025 8:44 am Post subject: |
|
|
mecej4
I suspect that MODULE FUNCTIONs are only meaningful when used with SUBMODULEs. At the moment FTN95 does not support SUBMODULEs and this is likely to be a significant undertaking (given the intrinsic complexity of MODULEs). Maybe something for 2026.
simon
Thank you for the bug report. It appears that at the moment you can't USE an ABSTRACT INTERFACE it has to be copyied to the place where it is used. |
|
| Back to top |
|
 |
|