Section Arrays: Array Elements#
Adapted from: gjbex/Fortran-MOOC
This program demonstrates array element indexing.#
program array_elements
implicit none
integer, dimension(5) :: A
integer :: i
A(1) = 1
do i = 2, size(A)
A(i) = 2*A(i - 1)
end do
print *, A
end program array_elements
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_Arrays_Array_Elements"
os.chdir(code_dir)
build_status = os.system("fpm build 2>/dev/null")
exec_status = os.system("fpm run 2>/dev/null")
1 2 4 8 16