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
Next Next commit
Add examples of comparison operators
  • Loading branch information
EmilyBourne committed Oct 15, 2024
commit ec92cb78021b017f0e40e96e0b1ed786de2f9525
15 changes: 11 additions & 4 deletions examples/v2/Vector/VecMyType.F90
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,27 @@ program main
use VecMyType_mod

implicit none
type (Vector) :: mv
type (Vector) :: mv1
type (Vector) :: mv2
type (MyType), pointer :: mv_p

! Initialise the vector type
mv=Vector()
mv1=Vector()
mv2=Vector()

! Add an element to the vector
call mv%push_back(MyType(2.0))
call mv1%push_back(MyType(2.0))
call mv2%push_back(MyType(2.0))

! Access an element of the vector
mv_p => mv%at(1)
mv_p => mv1%at(1)

! Use the element as you would a derived type object normally
call mv_p%display()

! Compare the two vectors
print *, (mv1 == mv2)
print *, (mv1 < mv2)

end program main