Here is an attempt to read 10 white-space-separated integer values from a file into an array:
subroutine ReadFileIntoArray (filename, int_array)
implicit none
character(len = *), intent (in) :: filename
integer, dimension(:), intent(in out) :: int_array
integer :: current_index
open (1, file = filename, status = 'old')
do current_index = 1, 10, 1
read(1, *) int_array(current_index)
end do
close (1)
end subroutine ReadFileIntoArray
! ---------------------------------------------------------------------- !
program ReadFileCalculateAverage
implicit none
integer, dimension(10) :: int_array
character (len = 9) :: filename = 'makrs.txt'
call ReadFileIntoArray(filename, int_array) ! <--- error line
end program ReadFileCalculateAverage
The error I'm getting (using Code::Blocks 16.01 on Windows 10) is:
Error: explicit interface required for 'ReadFileIntoArray' : assumed-shape argument
Having in mind my limited knowledge of Fortran, what is the way to correct the above code? Are there any other significant (still unobserved) errors that I should correct?