-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
24
src/others/interface-specific/interface_specific_module.f90
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |