File: test_submod.F90

package info (click to toggle)
fortran-language-server 3.2.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,268 kB
  • sloc: python: 9,688; f90: 1,195; fortran: 30; makefile: 28; ansic: 20
file content (44 lines) | stat: -rw-r--r-- 1,277 bytes parent folder | download | duplicates (2)
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
module points
  type :: point
     real :: x, y
  end type point

  interface
     module function point_dist(a, b) result(distance)
       type(point), intent(in) :: a, b
       real :: distance
     end function point_dist

     module logical function is_point_equal_a(a, b)
      type(point), intent(in) :: a, b
    end function is_point_equal_a

    module subroutine is_point_equal_sub(a, b, test)
      type(point), intent(in) :: a, b
      logical, intent(out) :: test
    end subroutine is_point_equal_sub
  end interface
contains
  logical function is_point_equal(a, b)
    type(point), intent(in) :: a, b
    is_point_equal = merge(.true., .false., a%x == b%x .and. a%y == b%y)
  end function is_point_equal
end module points
#define __PARENT_MOD__ points
submodule (__PARENT_MOD__) points_a
contains
  module function point_dist(a, b)
    type(point), intent(in) :: a, b
    distance = sqrt((a%x - b%x)**2 + (a%y - b%y)**2)
  end function point_dist

  module procedure is_point_equal_a
    type(point) :: c
    is_point_equal_a = merge(.true., .false., a%x == b%x .and. a%y == b%y)
  end procedure is_point_equal_a

  module procedure is_point_equal_sub
    type(point) :: c
    test = is_point_equal(a,b)
  end procedure is_point_equal_sub
end submodule points_a