Entrades

S'estan mostrant les entrades d'aquesta data: maig, 2021

gFortran allocatable arrays and intrinsic all function

Be carefull when using allocatable arrays and all builtin method. The compiler is not able to detect the different sizes. So it provides a false positive when tested with the first value  of the array. Check below an example: program allbug implicit none real, allocatable :: values(:,:) allocate(values(3,1)) values(:, 1) = [26., 27., 28.] write(*,*) "values= ", values write(*,*) "the same vs 26?", all(values(:, 1) == [26.] ) write(*,*) "the same vs 27?", all(values(:, 1) == [27.] ) end program    The output: bash:~/projects$ ./a.out values= 26.0000000 27.0000000 28.0000000 the same vs 26? T <---- HERE! the same vs 27? F On the other hand, when it is done with an explicit array an error is raised at compilation time. all-fixed.f90:10:36-51: 10 | write(*,*) "the same vs 26?", all(values(:, 1) == [26.] ) | 1 2 Error: Shapes for operands at...