I have the following fortran code defined under. I am trying to change the length of the do loop if i change the value of n. When i try to compile i get the error:
‘a’ argument of ‘floor’ intrinsic at (1) must be REAL. But when i change q and w to be defined as real i get another error message. How can i fix this? q and w is clearly a integer when i use floor(...)
subroutine boundrycon(n,bc,u,v)
!input
integer :: n,bc
!output
real(8) :: u(n+2,n+2), v(n+2,n+2)
!lokale
integer :: j,i,w,q
n=30
q=floor(n/2)
w=(floor(n/2)+floor(n/6))
do j=q,w
u(q,j)=0.0;
v(q+1,j)=-v(q,j);
u(w,j)=0.0;
v(w+1,j)=-v(w,j);
end do
do i=q,w
v(i,q)=0.0;
u(i,q)=-u(i,q+1);
u(i,w+1)=-u(i,w);
v(i,w)=0;
end do
end subroutine boundrycon
qis clearly an integer because it is declared as an integer, not because it is assigned an integer function result. The argument toflooris, in the first one, an integer, and that is the problem.qisn't the argument to the function:n/2is. [n/2is integer, fornan integer.] You are, then, asking, how to haven/2as a real?n/2( for positiven) IS the "floor" of the division, so you most likely just don't need the intrinsicfloorfunction here at all.q, it's aboutfloor(n/2).n/2is an integer (and as @agentp says, the flooring is redundant) and one cannot pass an integer to floor. If you must keep flooring, tryfloor(n/2.)which has a real argument.