Hello, Fortran Community! I am currently writing a subroutine in Fortran that works with arrays. Among other dummy variables, there is an input array y0 and an output one y1. Part of the header of my subroutine looks like this:
integer, parameter :: rp = kind(1.0d0)
real(kind = rp), intent(in) :: x0, y0(:), h, smin, smax
real(kind = rp), intent(out) :: y1(size(y0))
I am wondering, in the spirit of good programming practices/preferred programming styles, is it preferred to declare the arrays y0 and y1 with the dimension attribute? Like this:
integer, parameter :: rp = kind(1.0d0)
real(kind = rp), intent(in) :: x0, h, smin, smax
real(kind = rp), dimension(:), intent(in) :: y0
real(kind = rp), dimension(size(y0)), intent(out) :: y1
The first one seems shorter and more elegant to me, but the latter seems more clear.
On a second related matter, considering that y1 has the same shape as y0, would it be considered correct to declare it as follows?
real(kind = rp), intent(out) :: y1(:)
Or should I use the y1(size(y0)) version?
Thank you very much in advance for your answers!