| 1 |
module typebound_item |
| 2 |
use typebound_header |
| 3 |
implicit none |
| 4 |
|
| 5 |
type some_type |
| 6 |
contains |
| 7 |
procedure, nopass :: routine => module_routine |
| 8 |
procedure :: some_routine |
| 9 |
procedure, pass :: other_routine |
| 10 |
procedure :: routine1, & |
| 11 |
& routine2 => routine |
| 12 |
! procedure :: routine1 |
| 13 |
! procedure :: routine2 => routine |
| 14 |
end type some_type |
| 15 |
contains |
| 16 |
subroutine module_routine |
| 17 |
integer m |
| 18 |
m = 2 |
| 19 |
end subroutine module_routine |
| 20 |
|
| 21 |
subroutine some_routine(self) |
| 22 |
class(some_type) :: self |
| 23 |
|
| 24 |
call self%routine |
| 25 |
end subroutine some_routine |
| 26 |
|
| 27 |
subroutine other_routine(self, m) |
| 28 |
class(some_type), intent(inout) :: self |
| 29 |
integer, intent(in) :: m |
| 30 |
integer :: j |
| 31 |
|
| 32 |
if (m < 0) call abor1('Error with unbalanced parenthesis)') |
| 33 |
|
| 34 |
j = m |
| 35 |
call self%routine1 |
| 36 |
call self%routine2 |
| 37 |
end subroutine other_routine |
| 38 |
|
| 39 |
subroutine routine(self) |
| 40 |
class(some_type) :: self |
| 41 |
call self%some_routine |
| 42 |
end subroutine routine |
| 43 |
|
| 44 |
subroutine routine1(self) |
| 45 |
class(some_type) :: self |
| 46 |
call module_routine |
| 47 |
end subroutine routine1 |
| 48 |
end module typebound_item |
| 49 |
|
| 50 |
subroutine driver |
| 51 |
use typebound_item |
| 52 |
use typebound_header |
| 53 |
use typebound_other, only: other => other_type |
| 54 |
implicit none |
| 55 |
|
| 56 |
integer, parameter :: constant = 2 |
| 57 |
type(some_type), allocatable :: obj(:), obj2(:,:) |
| 58 |
type(header_type) :: header |
| 59 |
type(other) :: other_obj, derived(constant) |
| 60 |
real :: x |
| 61 |
integer :: i |
| 62 |
|
| 63 |
allocate(obj(1)) |
| 64 |
allocate(obj2(1,1)) |
| 65 |
call obj(1)%other_routine(5) |
| 66 |
call obj2(1,1)%some_routine |
| 67 |
call header%member_routine(1) |
| 68 |
call header%routine(x) |
| 69 |
call header%routine(i) |
| 70 |
call other_obj%member(2, 2) |
| 71 |
call derived(1)% var( 2 ) % member_routine(2) |
| 72 |
end subroutine driver |