I have two derived types (child1 and child2) that extend from the same abstract type ( type, abstract :: parent
). An abstract type has a deferred related procedure.
I want to call a subroutine that does some things (critical to performance) depending on the type of child passed as input. I can imagine two options:
- The routine accepts the input
class(parent), intent(inout) :: type_in
. Implementations for descendants are performed within the construct select type (type_in)
. - I am writing two routines: one s
type(child1), intent(inout) :: type_in
and one s type(child2), intent(inout) :: type_in
and providing an explicit interface for overloading the name of the subroutine.
The first option allows you to implement implementations in which the parent extension is unknown at compile time, but this is not necessary in my case. It also saves some lines of code because only part of it is different for children.
My question is: is there any additional overhead in the first option, because I implemented the input as polymorphic data when the type is known at compile time?
source
share