-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_026.F90
63 lines (59 loc) · 1.09 KB
/
example_026.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
! -DIMPNONE can be problematic with compiler(s)
module type_1
implicit none
type :: type1
integer :: val
contains
procedure, PASS :: setval
end type
interface
module subroutine setval(this, what)
#if defined(IMPNONE)
implicit none
#endif
class(type1), intent(INOUT) :: this
integer, intent(IN) :: what
end
end interface
end
submodule (type_1) sub_type_1
implicit none
contains
module procedure setval
this%val = what
end
end
module type_2
implicit none
type :: type2
integer :: val
contains
procedure, PASS :: setval
end type
interface
module subroutine setval(this, what)
#if defined(IMPNONE)
implicit none
#endif
class(type2), intent(INOUT) :: this
integer, intent(IN) :: what
end
end interface
end
submodule (type_2) sub_type_2
implicit none
contains
module procedure setval
this%val = what
end
end
program example_025
use type_1
use type_2
implicit none
type(type1) :: t1
type(type2) :: t2
call t1%setval(12)
call t2%setval(13)
print *, 'expecting 12, 13', t1%val, t2%val
end