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 439026d
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 15 deletions.
18 changes: 5 additions & 13 deletions .github/workflows/fpm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ name: fpm
on:
push:
paths:
- ".github/workflows/fpm.yml"
- "src/**.f90"
- "fpm.toml"

pull_request:
branches:
- main
paths:
- ".github/workflows/fpm.yml"
- "src/**.f90"
- "fpm.toml"

Expand All @@ -19,15 +21,12 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
os: [ubuntu-latest]
gcc_v: [11] # Version of GFortran we want to use.
include:
- os: ubuntu-latest
os-arch: linux-x86_64

- os: macos-latest
os-arch: macos-x86_64

env:
FC: gfortran
GCC_V: ${{ matrix.gcc_v }}
Expand All @@ -36,13 +35,6 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

- name: Install GFortran macOS
if: contains(matrix.os, 'macos')
run: |
ln -s /usr/local/bin/gfortran-${GCC_V} /usr/local/bin/gfortran
which gfortran-${GCC_V}
which gfortran
- name: Install GFortran Linux
if: contains(matrix.os, 'ubuntu')
run: |
Expand All @@ -51,9 +43,9 @@ jobs:
--slave /usr/bin/gcov gcov /usr/bin/gcov-${GCC_V}
- name: Install fpm
uses: fortran-lang/setup-fpm@v3
uses: fortran-lang/setup-fpm@v5
with:
fpm-version: 'v0.4.0'
fpm-version: 'v0.9.0'

- 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 439026d

Please sign in to comment.