Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add v2 examples for Vector #239

Merged
merged 14 commits into from
Oct 28, 2024
Prev Previous commit
Remove unused code
  • Loading branch information
EmilyBourne committed Oct 15, 2024
commit df24d7c29ca375a75364a9ce89fb36064d1cb407
21 changes: 0 additions & 21 deletions examples/v2/Vector/VecMyPolyPtr.F90
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,8 @@ module MyBase_mod
type,abstract:: MyBase
real :: r
contains
procedure(equal_),deferred :: equal
generic :: operator(==) => equal
procedure(display_),deferred :: display
end type MyBase

abstract interface
logical function equal_(m1,m2) result(l)
import MyBase
class(MyBase),intent(in) :: m1
class(MyBase),intent(in) :: m2
end function equal_
end interface

abstract interface
subroutine display_(m1)
Expand All @@ -39,7 +29,6 @@ module MyType_mod
use MyBase_mod
type,extends(MyBase) :: MyType
contains
procedure :: equal
procedure :: display
end type

Expand All @@ -55,12 +44,6 @@ function newMyType(r) result(m)
m%r = r
end function

logical function equal(m1,m2) result(l)
class(MyType),intent(in) :: m1
class(MyBase),intent(in) :: m2
l = (abs(m1%r- m2%r) <= 1.0e-7)
end function equal

subroutine display(m1)
class(MyType),intent(in) :: m1
print *, m1%r
Expand All @@ -78,15 +61,11 @@ module VecMyPolyPtr_mod
#define T MyBase
! Specify that the elements of the vector are polymorphic
#define T_polymorphic
! Define the == operator for elements of the vector.
! This allows two vectors to be compared with the equal method
#define T_EQ(x,y) (x == y)
! Include the vector template file to define the vector type
! The type will be called Vector
#include "vector/template.inc"
#undef T
#undef T_polymorphic
#undef T_EQ
end Module

program main
Expand Down