Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/test_language_bindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
needs:
- test_Cpp
- test_csharp
- test_fortran
- test_go
- test_haskell
- test_java
Expand Down Expand Up @@ -66,6 +67,18 @@ jobs:
run: |
make cs

test_fortran:
name: "Test: FORTRAN"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: fortran install
run: sudo apt-get install gfortran
- name: make FORTRAN
run: make fortran


test_go:
name: "Test: GoLang"
Expand Down
22 changes: 22 additions & 0 deletions src/FORTRAN/gnoll.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
program main
use, intrinsic :: iso_c_binding, only: c_char, c_int
implicit none

interface
function roll_and_write(s, f) bind(c, name="roll_and_write")
import :: c_char, c_int
character(kind=c_char), dimension(*), intent(in) :: s, f
integer(c_int) :: roll_and_write
end function roll_and_write
end interface

character(len=4, kind=c_char), target :: s
character(len=11, kind=c_char), target :: f
integer(c_int) :: result

s = 'd20'C
f = 'output.die'C

result = roll_and_write(s, f)
print *, "Result:", result
end program main
7 changes: 7 additions & 0 deletions src/FORTRAN/target.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

.PHONY: fortran
fortran: all
cp build/dice.so build/libdice.so
cd src/FORTRAN && ln -s ../../build c_build
cd src/FORTRAN && ln -s ../../src/grammar c_includes
cd src/FORTRAN && LD_LIBRARY_PATH="${PWD}/build:${LD_LIBRARY_PATH}" gfortran -o main gnoll.f90 -lroll_and_write && ls output.die