I have a code in which I wolud like to define i as the end value, let me make it clear by writing here:
integer function cornerio real :: term1, term2, term3, term4 do i=1,nelem !...... if(abs(term1)<=1e-20) then term1=0. end if if(abs(term2)<=1e-20) then term2=0. end if if(abs(term3)<=1e-20) then term3=0. end if if(abs(term4)<=1e-20) then term4=0. end if if( term1==0 .and. term2==0 .and. term3==0 .and. term4==0 ) then cornerio=-1 i=nelem else if(term1/=0) then if((term1*term2)>=0 .and. (term1*term3)>=0 .and. (term1*term4)>=0) then cornerio=-1 i=nelem end if else if(term2/=0) then if((term2*term1)>=0 .and. (term2*term3)>=0 .and. (term2*term4)>=0) then cornerio=-1 i=nelem end if else if(term3/=0) then if((term3*term1)>=0 .and. (term3*term2)>=0 .and. (term3*term4)>=0) then cornerio=-1 i=nelem end if else if(term4/=0) then if((term4*term1)>=0 .and. (term4*term2)>=0 .and. (term4*term3)>=0) then cornerio=-1 i=nelem end if else print*, "ERROR" end if end if end do return end function cornerio
When I compile this simple code, I got the error "A do-variable within a DO body shall not appear in a variable definition context. [I]" for the lines including "i=nelem". How can I solve this problem, without changing the logic ( İ=nelem inside the if-else statements). Thanks..
Emre





