File: procedure_24.f90

package info (click to toggle)
lfortran 0.60.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 58,416 kB
  • sloc: cpp: 173,406; f90: 80,491; python: 17,586; ansic: 9,610; yacc: 2,356; sh: 1,401; fortran: 895; makefile: 38; javascript: 15
file content (48 lines) | stat: -rw-r--r-- 805 bytes parent folder | download
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
module procedure_24_mod
  implicit none

  type :: type1_t
  contains
    procedure :: printme
  end type type1_t

contains

  subroutine printme(this)
    class(type1_t), intent(in) :: this
  end subroutine printme

end module procedure_24_mod


module procedure_24_mod2
  implicit none
  type :: type2_t
    integer :: key
  contains
    procedure :: printme
  end type type2_t

contains

  subroutine printme(this, n)
    class(type2_t), intent(inout) :: this
    integer, intent(in) :: n
    this%key = n
  end subroutine printme

end module procedure_24_mod2

program procedure_24
  use procedure_24_mod
  use procedure_24_mod2
  implicit none

  type(type1_t) :: obj1
  type(type2_t) :: obj2

  call obj1%printme()
  call obj2%printme(422)

  if (obj2%key /= 422) error stop
end program procedure_24