module firstTypeMod
type, abstract:: firstType
    character(len=30):: tempChar
contains
  procedure(defProc), deferred:: deferredProcedure
  procedure:: setChar
end type

abstract interface
  subroutine defProc(self)
     import firstType
    class(firstType), intent(inout):: self
  end subroutine defProc
end interface
 
contains
 subroutine setChar(self, charIn)
   class(firstType), intent(inout):: self
  character(len=*), intent(in):: charIn
 
  self%tempChar = charIn
 end subroutine setChar
end module firstTypeMod

module secondTypeMod
 use firstTypeMod
type, extends(firstType):: secondType
   character(len=100):: tempChar2
  contains
  procedure:: deferredProcedure => secondDef
  procedure:: setChar => overRideSetChar
end type
contains
subroutine secondDef(self)
class(secondType), intent(inout):: self

write(*,*) "OVERRIDDEN"
end subroutine secondDef

subroutine overRideSetChar(self, charIn)
 class(secondType), intent(inout):: self
 character(len=*), intent(in):: charIn

 call self%firstType%setChar(charIn)

 self%tempChar2 = charIn
end subroutine overRideSetChar

end module secondTypeMod

program P
  use secondTypeMod

  type(secondType):: Other

  call Other%setChar("A long long character here")
end program
