- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The following code does not compile with ifort Version 2021.3.0 on MacOS:
module my_mod
implicit none
type my_type(rkind)
integer, kind :: rkind
real(kind=rkind) :: val
procedure(sub_interface), pointer, nopass :: sub => NULL()
end type my_type
abstract interface
subroutine sub_interface(x, y)
real(kind=8), intent(in) :: x
real(kind=8), intent(out) :: y
end subroutine sub_interface
end interface
contains
subroutine bla_my_type_8(m_in,m_out)
implicit none
type(my_type(8)), intent(out) :: m_out
type(my_type(8)), intent(in) :: m_in
! do something here, e.g.
m_out%val = 2*m_in%val
m_out%sub => m_in%sub
end subroutine bla_my_type_8
subroutine sqrt_sub(x, y)
implicit none
real(kind=8), intent(in) :: x
real(kind=8), intent(out) :: y
y = sqrt(x)
end subroutine sqrt_sub
end module my_mod
program my_prog
use my_mod
implicit none
type(my_type(8)) :: m
real(kind=8) :: x, y
x = 16
m%sub => sqrt_sub
call m%sub(x, y)
write(*,*) 'y =', y
end program my_prog
As an error message, I get:
prog.f90(44): error #8178: The procedure pointer and the procedure target must have matching arguments.
m%sub => sqrt_sub
--^
prog.f90(45): error #6784: The number of actual arguments cannot be greater than the number of dummy arguments. [SUB]
call m%sub(x, y)
---------^
compilation aborted for prog.f90 (code 1)
Strangely, if I either remove the subroutine bla_my_type_8 *or* if I use a non-parameterized derived type, everything works as expected.
It may be important to note explicitly here that the above code does not do anything useful. It is the result of me trying to isolate an error in a large project. I also know that the need to use a parameterized derived type (PDT) is not apparent from the example, but PDTs make a lot of sense in the original application this example was distilled from.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Per my understanding of the Fortran standard, the errors are due to issues with Intel compiler. If you have support subscription, please submit a request at Intel OSC: https://supporttickets.intel.com/servicecenter?lang=en-US
Otherwise, you can hope Intel staff will pick up the incident from here.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Per my understanding of the Fortran standard, the errors are due to issues with Intel compiler. If you have support subscription, please submit a request at Intel OSC: https://supporttickets.intel.com/servicecenter?lang=en-US
Otherwise, you can hope Intel staff will pick up the incident from here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the quick reply! I will check if we have support subscription and file a request if possible.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for the report. This issue has been escalated to engineering.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page