forked from lcompilers/lpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an examples/project1 with multiple files
- Loading branch information
Showing
5 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
cmake_minimum_required(VERSION 3.5 FATAL_ERROR) | ||
|
||
project(project1 C Fortran) | ||
|
||
add_executable(project1 | ||
project1.f90 | ||
a.f90 | ||
b.f90 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
To compile with LFortran: | ||
|
||
FC=lfortran cmake . | ||
|
||
To choose a backend: | ||
|
||
FC=lfortran FFLAGS="--backend=cpp" cmake . | ||
FC=lfortran FFLAGS="--backend=llvm" cmake . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module a | ||
use b, only: g | ||
implicit none | ||
private | ||
public f, fib | ||
|
||
contains | ||
|
||
integer function f() | ||
f = 3 + g() | ||
end function | ||
|
||
subroutine fib(n) | ||
integer, intent(in) :: n | ||
integer :: i, a, b, c | ||
a = 1 | ||
b = 1 | ||
do i = 1, n-2 | ||
c = a+b | ||
print *, "Fibonacci: ", i, " ", c | ||
a = b; | ||
b = c; | ||
end do | ||
end subroutine | ||
|
||
end module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module b | ||
implicit none | ||
private | ||
public g | ||
|
||
contains | ||
|
||
integer function g() | ||
g = 5 | ||
end function | ||
|
||
end module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
program project1 | ||
use a, only: f, fib | ||
implicit none | ||
|
||
if (f() /= 8) error stop | ||
|
||
call fib(10) | ||
|
||
print *, "OK" | ||
|
||
end |