From 79b01e701e8e82c1cee77dd7189555270e77f8e1 Mon Sep 17 00:00:00 2001 From: Chris Coutinho Date: Tue, 1 Aug 2017 19:14:02 +0200 Subject: [PATCH] Fix makefile, add simple fortran program (#93) * Add simple fortran program to examples * Fix makefile bug --- examples/fortran_array.f90 | 28 ++++++++++++++++++++++++++++ examples/makefile | 6 +++++- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 examples/fortran_array.f90 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