I was shocked to lose heck of time to find that neither FTN95 or gFortran allows this code. I declared TYPEd array (the only reason it is TYPEd is because i want arbitrary allocatable number or elements in this 3D matrix and usual method of allocation does not allow that. Below though I put them of same size) and zeroised its elements at the end
type lostPart
real*4, allocatable, Dimension (:,:) :: Particles
end type lostPart
Type (lostPart) ispecies(0:2)
do icase=0,2
allocate (ispecies(icase)%Particles(12,10:20) )
enddo
ispecies(:)%Particles(:,:) = 0
end
FTN95 gives the diagnostics
22537) ispecie(:)%Particles(:,:) = 0
*** Error 852: The array expression involving the array component
particles is invalid, as the components to the left of the '%' are
also array-valued
while gFortran diagnoses and SHOWS it like this ('showing is 100x better than saying', proverb says. It is much more clear and specific as opposed to 'general ruling' of FTN95 requiring good knowledge of English language and Fortran rules what 99% of programmers who are mostly not English speaking of course do not know. This simplicity in part is why gFortran for example has 240 variations and versions for all processor types on Linux and FTN95 has not a single one and requires Linux-Windows emulator like Wine)
11 | ispecies(:)%Particles(:,:) = 0
| 1
Error: Component to the right of a part reference with nonzero rank must not have the ALLOCATABLE attribute at (1)
The same exact thing but zeroising the array 'manually', arranging for it additional DO loop, works with no problem
type lostPart
real*4, allocatable, Dimension (:,:) :: Particles
end type lostPart
Type (lostPart) ispecies(0:2)
do icase=0,2
allocate (ispecies(icase)%Particles(12,10:20) )
enddo
do icase=0,2
ispecies(icase)%Particles(:,:) = 0
enddo
end
What is going on ? Putting aside how compilers diagnose the code (which i think FTN95 should also copy and use) , how come both do not allow zeroising first way?