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 0d8f07f
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 5 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/fpm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ jobs:
--slave /usr/bin/gcov gcov /usr/bin/gcov-${GCC_V}
- name: Install fpm
uses: fortran-lang/setup-fpm@v3
with:
fpm-version: 'v0.4.0'
uses: fortran-lang/setup-fpm@v5

- name: Build & Test
run: |
Expand Down
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 0d8f07f

Please sign in to comment.