Skip to content

Julia

Julia is a dynamically-typed programming language that was originally designed to address the needs of high-performance numerical analysis and computational science, without the typical need of separate compilation.

Julia is available as a module on Apocrita.

Usage

To run the default installed version of Julia, simply load the Julia module:

module load julia

then run Julia with a script file:

julia example.jl

Example job

Serial job

Here is an example job running on 1 core.

#!/bin/bash
#$ -cwd
#$ -j y
#$ -pe smp 1
#$ -l h_rt=1:0:0
#$ -l h_vmem=1G

module load julia
julia example.py

Julia package management

The standard package manager for Julia 1.0 and newer is Pkg. To interface with Pkg, start the Julia application and press the ] key. To return to the original prompt, either press backspace when the input line is empty or press Ctrl+c.

Adding packages

Packages can be added with the add command followed by the name of the package. It is also possible to add multiple packages in one command.

(v1.0) pkg> add Example
 Resolving package versions...
 Installed Example - v0.5.1
  Updating `~/.julia/environments/v1.0/Project.toml`
  [7876af07] + Example v0.5.1
  (output redacted)

Removing packages

Packages can be removed using the rm command. If the package has not been loaded in the current project, the removal command will fail with a warning message.

(v1.0) pkg> rm Example
  Updating `~/.julia/environments/v1.0/Project.toml`
  [7876af07] - Example v0.5.1
  (output redacted)

Listing installed packages

To list the installed packages, run st (short for status).

(v1.0) pkg> st
    Status `~/.julia/environments/v1.0/Project.toml`
  [7876af07] Example v0.5.1

Testing packages

The tests for a package can be run using the test command:

(v1.0) pkg> test Example
   Testing Example
    Status `/tmp/456364.1.test.q/tmpgFlC6Y/Manifest.toml`
  [7876af07] Example v0.5.1
  [2a0f44e3] Base64  [`@stdlib/Base64`]
  [8ba89e20] Distributed  [`@stdlib/Distributed`]
  [b77e0a4c] InteractiveUtils  [`@stdlib/InteractiveUtils`]
  [8f399da3] Libdl  [`@stdlib/Libdl`]
  [37e2e46d] LinearAlgebra  [`@stdlib/LinearAlgebra`]
  [56ddb016] Logging  [`@stdlib/Logging`]
  [d6f4376e] Markdown  [`@stdlib/Markdown`]
  [9a3f8284] Random  [`@stdlib/Random`]
  [9e88b42a] Serialization  [`@stdlib/Serialization`]
  [6462fe0b] Sockets  [`@stdlib/Sockets`]
  [8dfed614] Test  [`@stdlib/Test`]
   Testing Example tests passed

References