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

Trivial style question: end element of array

eos_pengwern
Beginner
432 Views

This is trivial, really, and I feel I should know the answer, but I can't seem to put my finger on it...

Suppose I am in a subroutine and have an array, let's call it A, which is a dummy argument with an assumed shape, i.e. it was declared as:

subroutine test(A)
real(kind(1e0)), dimension(:) :: A

Suppose now I want toreference the 'tail' of the array, i.e. all the elements of the array from the n'th through to the end. Is there an elegant syntax for doing this? In MATLAB, one would use A(n:end), but I can't find an equivalent in IVF. The best I can find so far is A(n:size(A, 1)) which seems clunky and inelegant. Is there any better way of doing this?

0 Kudos
2 Replies
Steven_L_Intel1
Employee
432 Views

Even more elegant than MATLAB:

A(N:)

0 Kudos
eos_pengwern
Beginner
432 Views
Thanks Steve; I agree that that notation is more elegant, and I had in fact tried it. The problem is that when I compile in debug mode and then run, I get bombarded with rather inelegant "An array temporary was created" warning messages. I could of course turn these off, buttheymademe think that there's something about this notation that the compiler doesn't like. It's perfectly happy with the clunkier A(N:SIZE(A, 1)) notation, which to my eyes should be exactly equivalent.
0 Kudos
Reply