Skip to content
GitLab
    • GitLab: the DevOps platform
    • Explore GitLab
    • Install GitLab
    • How GitLab compares
    • Get started
    • GitLab docs
    • GitLab Learn
  • Pricing
  • Talk to an expert
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
    Projects Groups Topics Snippets
  • Register
  • Sign in
  • lfortran lfortran
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 432
    • Issues 432
    • List
    • Boards
    • Service Desk
    • Milestones
    • Requirements
  • Merge requests 72
    • Merge requests 72
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
    • Test cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
    • Model experiments
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • lfortranlfortran
  • lfortranlfortran
  • Issues
  • #44
Closed
Open
Issue created Nov 11, 2018 by Ondřej Čertík@certikOwner

Bridge to Python and other languages

Use the approach explained here: https://eli.thegreenplace.net/2015/calling-back-into-python-from-llvmlite-jited-code/ to bridge with Python.

The syntax from Fortran side should be (thanks to @nncarlson for the suggestion):

use, external(python) :: numpy, only: sin
print *, sin(5)

For plotting, without lfortran knowing anything about matplotlib:

use, external(python) :: pylab, only: plot, savefig
call plot([1, 2, 3], [1, 2, 1])
call savefig("someplot.pdf")

For nested Python modules, we need some syntax to do that, here are three suggestions:

use, external(python) :: numpy.linalg, only: cholesky
use, external(python) :: numpy:linalg, only: cholesky
use, external(python) :: numpy%linalg, only: cholesky

Essentially this boils down to allowing Fortran modules to be nested (by convincing the Fortran committee to), and then reuse the syntax for that (whatever syntax the committee agrees upon).

Calling C++ could be something along the lines:

use, external(cpp) :: xtensor, only: sin

Calling C would be (see #48 for details):

use, external(c) :: math, only: sin
print *, sin(5._dp)
Edited Dec 05, 2018 by Ondřej Čertík
Assignee
Assign to
Time tracking