This is a brief Julia tutorial for oceanographers. Please consult additional tutorials, like the following ones, if you are new to julia (or programming in general):
- An Introduction to Julia by Jane Herriman
- Julia language: a concise tutorial by A. Lobianco
These notebooks can either be used:
- on the computers in the computer room (2/25, 2nd floor of the B5A building)
- on your machine following the introductions below
- on MyBinder.org using the link (this can take 2 to 10 minutes to start). Do not forget to download and save your notebook and results. Remember to stop the notebooks (File -> Closes and Halt) to free resources.
Required software:
- Julia available from https://julialang.org/downloads/. The exercise is tested with the version 1.6 of Julia. Some additional information is available here: https://github.com/gher-ulg/Documentation/wiki/Installing-Julia
- Some Julia packages, which can be installed with these commands once you started Julia:
using Pkg
cd("/home/abarth/Lectures/JuliaTutorial")
using Pkg
Pkg.activate(".")
Pkg.instantiate()
where you replace "/home/abarth/Lectures/JuliaTutorial"
by the folder where you downloaded (and extracted) the notebook files. Note on Windows you need to use the backslash as path separator a raw
string for example raw"C:\Users\Name\Documents\JuliaTutorial"
.
using IJulia
notebook(dir = "/home/abarth/Lectures/JuliaTutorial")
By following the link to nbviewer.jupyter.org you see a list of all notebooks. For the example the Introduction notebook is available at https://nbviewer.jupyter.org/github/Alexander-Barth/JuliaTutorial/blob/master/JuliaIntroduction.ipynb .
- Editor with julia support. For example, install emacs and the file
julia-mode.el
as follows:
mkdir ~/site-lisp
cd ~/site-lisp
wget https://raw.githubusercontent.com/JuliaEditorSupport/julia-emacs/master/julia-mode.el
wget https://raw.githubusercontent.com/JuliaEditorSupport/julia-emacs/master/julia-latexsubs.el
cat >> ~/.emacs <<EOF
;; Add a local lisp folder to your load-path
(setq load-path (append load-path (list "~/site-lisp")))
(require 'julia-mode)
(setq auto-mode-alist (append '(("\\.jl$" . julia-mode)) auto-mode-alist))
EOF
- Install a desktop launcher and icon for julia
wget -O /tmp/julia.desktop https://raw.githubusercontent.com/JuliaLang/julia/e90f29db30f81f340d4f36669b27ac5a281e2a7f/contrib/julia.desktop
desktop-file-install --dir=$HOME/.local/share/applications /tmp/julia.desktop
mkdir -p ~/.local/share/icons/hicolor/scalable/apps/
cd ~/.local/share/icons/hicolor/scalable/apps/
wget https://raw.githubusercontent.com/JuliaLang/julia/30bf89f3d8e564b588b8e48993e92a551b384f2c/contrib/julia.svg
cd ~