Consider the following, greatly simplified, sections of code
type :: obj_rcd
type(net_rcd),dimension(:),allocatable :: rcd
integer :: cntr=0
type(rcd_desc),dimension(:), pointer :: def
end type
type,extends(obj_rcd) :: area_rcd
contains
procedure increment_counter
end type
subroutine increment_counter(this)
call increment_counter_object(this)
end subroutine increment_counter
subroutine increment_counter_object(obr)
type(obj_rcd) :: obr
if (obr%cntr >= size(obr%rcd)) call extend_obj(obr%rcd,obr%def)
obr%cntr = obr%cntr+1
end subroutine increment_counter_object
This fails to compile due to type mismatch calling increment_counter_object, and this makes perfect sense. I found that these two modifications both build and both seem to work properly:
[1]
subroutine increment_counter(this)
class(area_rcd),target :: this
class(obj_rcd),pointer :: that
that=>this
call increment_counter_object(that)
end subroutine increment_counter
subroutine increment_counter_object(obr)
type(obj_rcd) :: obr
if (obr%cntr >= size(obr%rcd)) call extend_obj(obr%rcd,obr%def)
obr%cntr = obr%cntr+1
end subroutine increment_counter_object
[2]
subroutine increment_counter(this)
call increment_counter_object(this)
end subroutine increment_counter
subroutine increment_counter_object(obr)
class(obj_rcd) :: obr
if (obr%cntr >= size(obr%rcd)) call extend_obj(obr%rcd,obr%def)
obr%cntr = obr%cntr+1
end subroutine increment_counter_object
I suspect that there is a difference between these two. I can make a reasoned guess as to what it might be, but I'm looking for a more definitive explanation. Anyone have one?