Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

using ANY with derived type arrays?

alexismor
Beginner
340 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
340 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