I want to check all rows of an array for a logical condition. I used function ALL
as described in GNU GCC guide https://gcc.gnu.org/onlinedocs/gfortran/ALL.html
Here is a sample code:
program test3
implicit none
real, allocatable, dimension (:,:) :: mat1
integer :: i,j,k,r
logical :: lg
r=3
allocate(mat1(r,r))
mat1=transpose( reshape( (/-1,-2,-3,-4,-5,-6,-7,-8,-9/), (/3,3/)))
lg=all (abs(mat1)<10,1)
write (*,*) lg
end program
In this program, I want to check whether absolute value of all elements along all rows is less than 10. But I am getting error
lg=all (abs(mat1)<10,1)
Error: Incompatible ranks 0 and 1 in assignment
Any idea about this error or how to do this check?
mat1
? Three, rather than one, results?