ifort -c module_procedures_abstract_interface_MOD.f90module_procedures_abstract_interface_MOD.f90(16): error #6651: The PROCEDURE specification is allowed only if the interface-block has a generic-spec.
..
So it seems to me that I only have the more verbose solution allowed.
Or am I missing something?
On Tuesday, April 5, 2022 at 12:42:03 PM UTC-4, rgae...@gmail.com wrote:
..@rgae...@gmail.com,
So it seems to me that I only have the more verbose solution allowed.
Or am I missing something?
First, you may want to post this at Fortran Discourse also: https://fortran-lang.discourse.group/
Two benefits with this:
1) you are dealing with modern Fortran code specifically and it will be much easier for you and anyone else interested to read and follow the details,
2) you will get a wider engagement and feedback on such matters
Your concerns with verbosity are valid, you may bring it up at GitHub J3-Fortran proposals site by posting a thread under Issues and see where that leads:
https://github.com/j3-fortran/fortran_proposals
In the mean time, note a slightly modified approach you can consider is with procedure pointer and you might find it is a tad less verbose in terms of repeated INTERFACE declarations - see below (with a simple function example):
module implementations_m
contains
function fun1(x,y) result(z)
integer, intent(in) :: x
integer, intent(in) :: y
integer :: z
z = x + y
end function
function fun2(x,y) result(z)
integer, intent(in) :: x
integer, intent(in) :: y
integer :: z
z = 2*x + 3*y
end function
end module
module m
use implementations_m
abstract interface
function Ifun(x,y) result(z)
integer, intent(in) :: x
integer, intent(in) :: y
integer :: z
end function
end interface
procedure(Ifun), pointer :: fun => null() ! or set to default
contains
subroutine setfun( fun_name )
character(len=*), intent(in) :: fun_name
select case ( fun_name )
case ( "fun1" )
fun => fun1
case ( "fun2" )
fun => fun1
case default
! error stop?
end select
end subroutine
end module
use m
call setfun( "fun2" )
print *, fun(3, 4)
end
So with above, your SUBMODULE approach is eschewed and the interface and implementation are separated out in a way as suggested since Fortran 90 revision.
To reiterate, I recommend you initiate a dialogue on this at Fortran Discourse.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 159 |
Nodes: | 16 (0 / 16) |
Uptime: | 98:18:07 |
Calls: | 3,209 |
Files: | 10,563 |
Messages: | 3,009,579 |