/*- Author: Brian Tiffin Dedicated to the public domain Date: November 2016 Modified: 2016-12-01/00:45-0500 +*/ /* unifortran.c loadfunc some Fortran functions in Unicon tectonics: gfortran -o fortran.o -fpic fortran.f gcc -o fortran.so -shared -fpic unifortran.c fortran.o */ #include #include #include "icall.h" /* Fortran is pass by reference */ int squareto_(int *, int *); int cube_(int *); /* unifortran: execute Fortran functions */ int unifortran (int argc, descriptor argv[]) { int n, m; if (argc != 1) Error(104); /* ensure argv[1] is an integer */ ArgInteger(1); n = IntegerVal(argv[1]); /* first call the subroutine, data comes back in second argument */ squareto_(&n, &m); /* invoke Fortran function, argument by address, add to previous */ m += cube_(&n); RetInteger(m); }