Skip to content

Commit

Permalink
add interface-limit-2
Browse files Browse the repository at this point in the history
  • Loading branch information
zoziha committed Aug 4, 2023
1 parent c3d079f commit 1499040
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
9 changes: 7 additions & 2 deletions fpm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,13 @@ name = "wrapper"
source-dir = "src/structural/wrapper"
main = "wrapper_main.f90"

# interface-limit
# others
[[test]]
name = "interface-limit"
source-dir = "src/interface-limit"
source-dir = "src/others/interface-limit"
main = "interface_limit_main.f90"

[[test]]
name = "interface-specific"
source-dir = "src/others/interface-specific"
main = "interface_specific_main.f90"
15 changes: 15 additions & 0 deletions src/others/interface-specific/interface_specific_main.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
!> @note use `select type` is a limited form of polymorphism
program interface_specific_main

use interface_specific_module, only: shape, circle, print_circle
implicit none
class(shape), allocatable :: s1

allocate (circle :: s1)

select type (s1)
type is (circle)
call print_circle(s1)
end select

end program interface_specific_main
24 changes: 24 additions & 0 deletions src/others/interface-specific/interface_specific_module.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module interface_specific_module

implicit none

private
public :: shape, circle, print_circle

type, abstract :: shape
end type shape

type, extends(shape) :: circle
end type circle

contains

!> print circle
subroutine print_circle(this)
type(circle), intent(in) :: this

print *, 'circle'

end subroutine print_circle

end module interface_specific_module

0 comments on commit 1499040

Please sign in to comment.