Section 2.1: Statement Blocks#
Adapted from: “Guide to Fortran 2008 Programming” by Walter S. Brainerd (Springer 2015)
Program to demonstrate the block construct in Fortran#
program block_test
implicit none
real, parameter :: x = 1.1
block
integer :: x
do x = 1, 3
print *, x
end do
end block
print *, x
end program block_test
The above program is compiled and run using Fortran Package Manager (fpm):
import os
root_dir = os.getcwd()
code_dir = root_dir + "/" + "Fortran_Code/Section_2_1_Statement_Blocks"
os.chdir(code_dir)
build_status = os.system("fpm build 2>/dev/null")
exec_status = os.system("fpm run 2>/dev/null")
1
2
3
1.10000002