jeudi 27 juin 2019

How to logically check the shape of an array in an IF-statement?

Is it possible to check if an array is a certain shape using an IF-statement? I have tried the following with no success.

program main

   implicit none

 ! Local variables. 

   integer, dimension(3,3) :: a
   integer, dimension(3,3) :: b

  ! Check if a is a 3x3 array.

    if (shape(a) == shape(b)) print *, "Works"

end program main

But I get the error:

Error: IF clause at (1) requires a scalar LOGICAL expression

Aucun commentaire:

Enregistrer un commentaire