File: derived_types_10.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 (50 lines) | stat: -rw-r--r-- 1,112 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
49
50
module my_module

   type :: my_super_type
      integer :: x
   end type


   type :: my_type
      integer :: x
      type(my_super_type) :: super
      ! procedure(print_something), pointer :: p_ptr
   contains
      final :: finalize
      procedure :: proc => print_something
      procedure :: unary, plus
      generic :: operator(+) => unary, plus
      generic :: g_proc => plus, unary
   end type my_type

contains

   subroutine finalize(self)
      type(my_type), intent(inout) :: self
   end subroutine finalize


   subroutine print_something(self, str)
      class(my_type), intent(inout) :: self
      character(len=*), intent(in) :: str
      print *, str
   end subroutine print_something


   subroutine say_something(self, msg)
      class(my_type), intent(inout) :: self
      character(len=*), intent(in) :: msg
      print *, msg
   end subroutine


   pure type(my_type) function unary(self, x)
      class(my_type), intent(in) :: self, x
   end function unary


   pure type(my_type) function plus(self)
      class(my_type), intent(in) :: self
   end function plus

end module my_module