- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi everybody,
I was wondering if it was possible to use the ANY function with derived types. For example, I have defined a type called particle (which holds different integer quantum numbers of a particle) in a module called particle_module, along with interfaces for the assignment (=) and equivalence operators (==).
This is what I want to do:
program test
use particle_module
type(particle), dimension(3) :: p
type(particle) :: p_test
integer :: i
do i=1,3
p(i) = i !particle_module describes how to do this
enddo
p_test==4
if (ANY(p==p_test)) then
print*,'there is a match'
else
print*,'There is no match'
endif
stop
end
Is this possible? I was thinking that since I've allready defined how to do the equivalency operator in the particle_module this should be possible, but I can't get it to work. Is there some special trick?
Thanks!
I was wondering if it was possible to use the ANY function with derived types. For example, I have defined a type called particle (which holds different integer quantum numbers of a particle) in a module called particle_module, along with interfaces for the assignment (=) and equivalence operators (==).
This is what I want to do:
program test
use particle_module
type(particle), dimension(3) :: p
type(particle) :: p_test
integer :: i
do i=1,3
p(i) = i !particle_module describes how to do this
enddo
p_test==4
if (ANY(p==p_test)) then
print*,'there is a match'
else
print*,'There is no match'
endif
stop
end
Is this possible? I was thinking that since I've allready defined how to do the equivalency operator in the particle_module this should be possible, but I can't get it to work. Is there some special trick?
Thanks!
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No, this is not defined by Fortran. You are, of course, free to extend the ANY generic with your own implementation for your type.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page