The array arr
is declared as being of rank 1. So, assuming the compiler is pointing to the line where size(arr,2)
is given, this is not valid code: it is asking for the size of the second (non-existent) dimension.
From the rest of the function print_coeffs
it appears desirable that arr
be declared as rank-2: real, intent(in), dimension(:,:) :: arr
.
It should, however, be noted that a function like this (arr
is an assumed-shape array) will require an explicit interface for the caller. That is, if you want to call this function eventually from the main program then integer, external :: print_coeffs
isn't going to be sufficient. See other questions and answers on SO---such as here---for more details.