-
Notifications
You must be signed in to change notification settings - Fork 45
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
25 changed files
with
765 additions
and
209 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
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
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
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
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,43 @@ | ||
! Array wrappers allow the framework to treat arrays as single | ||
! objects. This separates concerns of overloading by type (via | ||
! unlimited polymorphic) vs overloading by rank. | ||
|
||
module pf_AbstractArrayWrapper | ||
implicit none | ||
private | ||
|
||
public :: AbstractArrayWrapper | ||
|
||
type, abstract :: AbstractArrayWrapper | ||
contains | ||
procedure(get_ith), deferred :: get_ith | ||
procedure(get), deferred :: get | ||
procedure(to_list), deferred :: to_list | ||
end type AbstractArrayWrapper | ||
|
||
abstract interface | ||
|
||
function get_ith(this, i) result(item) | ||
import AbstractArrayWrapper | ||
class(*), allocatable :: item | ||
class(AbstractArrayWrapper), target, intent(in) :: this | ||
integer, intent(in) :: i | ||
end function get_ith | ||
|
||
function get(this) result(list) | ||
import AbstractArrayWrapper | ||
class(*), allocatable :: list(:) | ||
class(AbstractArrayWrapper), intent(in) :: this | ||
end function get | ||
|
||
subroutine to_list(this, list) | ||
import AbstractArrayWrapper | ||
class(AbstractArrayWrapper), intent(in) :: this | ||
class(*), allocatable, intent(out) :: list(:) | ||
end subroutine to_list | ||
|
||
end interface | ||
|
||
end module pf_AbstractArrayWrapper | ||
|
||
|
This file was deleted.
Oops, something went wrong.
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,96 @@ | ||
! -*-f90-*- | ||
! This module allows pFUnit to treat arrays as single objects which | ||
! greatly simplifies the overloading of hamcrest matcher interfaces. | ||
! Once SELECT RANK (Fortran 2015) is widely available, this should | ||
! be re-engineered. | ||
|
||
module pf_ArrayWrapper_{rank}d | ||
use pf_AbstractArrayWrapper | ||
{use_rank_minus_1} | ||
implicit none | ||
private | ||
|
||
public :: ArrayWrapper | ||
public :: ArrayWrapper_{rank}d | ||
|
||
interface ArrayWrapper | ||
module procedure wrap | ||
end interface ArrayWrapper | ||
|
||
type, extends(AbstractArrayWrapper) :: ArrayWrapper_{rank}d | ||
class(*), allocatable :: items {dims} | ||
contains | ||
procedure :: get | ||
procedure :: get_ith | ||
procedure :: to_list | ||
end type ArrayWrapper_{rank}d | ||
|
||
contains | ||
|
||
function wrap(items) result(a) | ||
type (ArrayWrapper_{rank}d) :: a | ||
class(*), intent(in) :: items {dims} | ||
allocate(a%items, source=items) | ||
end function wrap | ||
|
||
function get(this) result(list) | ||
class(*), allocatable :: list(:) | ||
class (ArrayWrapper_{rank}d), intent(in) :: this | ||
|
||
#if {rank} > 1 | ||
integer :: i, n | ||
type (ArrayWrapper_{rank_minus_1}d), allocatable :: items(:) | ||
#endif | ||
|
||
#if {rank}==1 | ||
! GFortran 9.2 has some issues with polymorphic intrinsic | ||
! assignment in this context. | ||
allocate(list, source=this%items) | ||
#else | ||
n = size(this%items) | ||
allocate(items(n)) | ||
do i = 1, n | ||
items(i) = {get_ith} | ||
end do | ||
! GFortran 9.2 has some issues with polymorphic intrinsic | ||
! assignment in this context. | ||
allocate(list, source=items) | ||
#endif | ||
|
||
end function get | ||
|
||
function get_ith(this, i) result(item) | ||
class(*), allocatable :: item | ||
class(ArrayWrapper_{rank}d), target, intent(in) :: this | ||
integer, intent(in) :: i | ||
|
||
item = {get_ith} | ||
|
||
end function get_ith | ||
|
||
subroutine to_list(this, list) | ||
class (ArrayWrapper_{rank}d), intent(in) :: this | ||
class(*), allocatable, intent(out) :: list(:) | ||
|
||
#if {rank} > 1 | ||
integer :: i, n | ||
type (ArrayWrapper_{rank_minus_1}d), allocatable :: items(:) | ||
#endif | ||
#if {rank}==1 | ||
! GFortran 9.2 has some issues with polymorphic intrinsic | ||
! assignment in this context. | ||
allocate(list, source=this%items) | ||
#else | ||
n = size(this%items) | ||
allocate(items(n)) | ||
do i = 1, n | ||
items(i) = {get_ith} | ||
end do | ||
! GFortran 9.2 has some issues with polymorphic intrinsic | ||
! assignment in this context. | ||
allocate(list, source=items) | ||
#endif | ||
|
||
end subroutine to_list | ||
|
||
end module pf_ArrayWrapper_{rank}d |
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
Oops, something went wrong.