You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just a small change in the code snippet to showcase what @Beliavsky tried to show:
program main
implicit noneinteger:: i
do i=1,5
block
integer:: isq !> variables can be defined here
isq = i**2print*,i,isq
end block
end doend program main
The statement that "the Fortran programming language does not allow to declare variables inside loops, in the statements of the loop body." at https://github.com/codee-com/open-catalog/tree/main/Checks/PWR002 is incorrect, since Fortran 2008 introduced the BLOCK construct, described at https://www.ibm.com/docs/en/xffbg/121.141?topic=control-block-construct-fortran-2008 . For example, the following code compiles and runs with gfortran:
Note: the original code did not correctly demonstrate that
isq
can be declared within a loop, as @jalvesz points out below. I have corrected the code.The text was updated successfully, but these errors were encountered: