##- # Author: Brian Tiffin # Dedicated to the public domain # # Date: November 2016 # Modified: 2016-12-01/00:50-0500 ##+ # # fortran.icn, invoke some gfortran programs and functions # # tectonics: # gfortran -o fortran-66.so -shared -fpic fortran-66.f # gfortran -o fortran-77.so -shared -fpic fortran-77.f # gfortran -ffree-form -c -fpic fortran.f # gcc -o fortran.so -shared -fpic unifortran.c fortran.o # procedure main() # load and invoke an old form Fortran main module # this could just as well be an open pipe or system call # but this is an alpha level proof of mechanism fortran66 := loadfunc("./fortran-66.so", "main") fortran66() # load and invoke another Fortran main module # a simple demonstration of variant forms of Fortran source fortran77 := loadfunc("./fortran-77.so", "main") fortran77() # load a Fortran module, and pass arguments # any realistic use of Fortran would build on this type of interface # or, would require fortran-ization of the C macros in icall.h fortran := loadfunc("./fortran.so", "unifortran") result := fortran(5) write("Subroutine square(5, result) + cube(5) from Fortran: ", result) end