Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

using ANY with derived type arrays?

alexismor
Beginner
319 Views
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!
0 Kudos
1 Reply
Steven_L_Intel1
Employee
319 Views
No, this is not defined by Fortran. You are, of course, free to extend the ANY generic with your own implementation for your type.
0 Kudos
Reply