Embedding Julia

Julia is a relatively new programming language that has been designed with High-Performance Computing in mind. Some benchmarks for its speed can be found here. This programming language is extremely similar to both python and Fortran/C. The similarities of Julia to Python is that they are both have high-level dynamically-typed language. However, Julia is a compiled language that can offer better speed since it runs using machine code.

While Julia is something that can be used on its own today we will look at how to embed Julia in code such as Fortran and C. Embedding Julia can offer a wide range of use cases when interacting with legacy code. While our examples are simple, they can be adapted for wider more intricate problems. We will only be showing proof of concept.

The Git Repo can be found here

Calling Julia From C

Function Link (Click these) Description
C processing Julia Inline base function (Square Num) Calls a Julia function from C In the C code we pass in an argument of a base Julia function and print out the results. (param number)
C processing Julia user defined module (Square Num) Calls a Julia user module from C In the C code we load in a user defined Julia function and pass in a number and print the results. (param number)
C processing Julia user defined module (Square Array) Calls a Julia user module from C In the C code we load in a user defined Julia function and pass in an array and print the results. (param Array)
C processing Julia to write data to file Calls a Julia user module from C to save data In the C code we load in a user defined Julia function and pass in an array and write it to a file (param Array)

Calling Julia From FORTRAN to C

Function Link (Click these) Description
Fortran binding C processing Julia Inline base function to write data Fortran binding C Calling Julia Fortran binding C to Julia inline function to write data

For more information please see the Julia website here

Share this Post