I have following subroutine:
subroutine invertCell( a1vec,a2vec,a3vec, rlvec ) !(icluster)
implicit none
! ======= Parameters
real, dimension (3), intent(in) :: a1vec, a2vec, a3vec
real, dimension (3,3),intent(out) :: rlvec
! ... Body ...
end subroutine
When I call it with argument vectors sliced from 3x3 matrix like this
real, dimension (3,3) :: ervec
real, dimension (3,3) :: elvec
...
call invertCell( ervec(1,:),ervec(2,:),ervec(3,:), elvec )
I produces warrnings Fortran runtime warning: An array temporary was created
I can avoid this by making temporary array explicitly:
real, dimension (3) :: ervec1,ervec2,ervec3
...
ervec1(:) = ervec(1,:)
ervec2(:) = ervec(2,:)
ervec3(:) = ervec(3,:)
call invertCell( ervec1,ervec2,ervec3, elvec )
But this is some obfuscation I want to avoid.
NOTE: I come from C/C++ background. In C/C++ this would be very easy since arrays are just pointers, so slicing arrays can be always done by pointer arithmetics without copy. I wonder why this is not possible in Fortran.