I have a Fortran 90 program formatted in the following way
program main
<bulk of code that uses update_board>
end program main
integer function update_board(board, tochange, N) result(tochange)
integer, dimension(:, :) :: board, tochange
integer N
do i=2,N+1
do j=2,(N+2)/2
nna = board(i+1, j+1) + board(i, j+1) + board(i-1, j+1) &
+ board(i-1, j) + board(i-1, j-1) + board(i, j-1) &
+ board(i+1, j-1) + board(i+1,j)
if (nna .eq. 3) then
tochange(i, j) = 1
else if (nna .eq. 2) then
tochange(i, j) = board(i, j)
else
tochange(i, j) = 0
end if
end do
end do
end function update_board
However, when I run the code, I get the compilation error of
integer function update_board(board, tochange, N) result(tochange)
1
Error: DUMMY attribute conflicts with RESULT attribute in 'tochange' at (1)
parallel_game_of_life.f90:1.12:
program main
1
parallel_game_of_life.f90:144.47:
integer, dimension(:, :) :: board, tochange
2
Error: Two main PROGRAMs at (1) and (2)
I'm sure the latter two main PROGRAMs
error is a direct result of the first. However, I am pretty stuck here. I would like to update an input variable and use that as the result ,since I can't declare a function like integer, dimension(:, :) function ...