diff --git a/examples/fortran_array.f90 b/examples/fortran_array.f90 new file mode 100644 index 0000000..f65edb3 --- /dev/null +++ b/examples/fortran_array.f90 @@ -0,0 +1,28 @@ +program array + integer, parameter :: n=3 + integer :: ii + real, dimension(n) :: a, b + real, dimension(n,n) :: c + + a = [( real(ii), ii=1, n )] + + do ii = 1,n + print *, a(ii) + enddo + + b = 0. + do ii = 1, n + ! You could just write b = a ** 2., but I want to see the loop progress + b(ii) = a(ii) ** 2. + enddo + + do ii = 1, n + print *, b(ii) + enddo + + c = reshape( [( real(ii), ii=1,n**2 )], [n,n] ) + do ii = 1, n + print *, c(ii,:) + enddo + +end program diff --git a/examples/makefile b/examples/makefile index 9dc35e4..8e66316 100644 --- a/examples/makefile +++ b/examples/makefile @@ -24,5 +24,9 @@ tree: tree.c linked_list: linked_list.cpp g++ linked_list.cpp -o linked_list_cpp.a -std=c++11 -g - ../gdbgui/backend.py linked_list.a + ../gdbgui/backend.py linked_list_cpp.a + +fortran: fortran_array.f90 + gfortran fortran_array.f90 -o fortran_array.a -g + ../gdbgui/backend.py fortran_array.a