This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# run with e.g. mpiexec -np 8 julia ./mpihello.jl | |
using MPI | |
MPI.Init() | |
comm = MPI.COMM_WORLD | |
size = MPI.Comm_size(comm) | |
rank = MPI.Comm_rank(comm) | |
print("Hello from $rank of $size processors!\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## --- | |
using StatGeochem, Plots | |
# Calculate a histogram of three variables in ternary space | |
function ternaryhist(a,b,c; nbins::Int=10) | |
# Normalize input data | |
d = a + b + c | |
a ./= d | |
b ./= d | |
c ./= d |
We can make this file beautiful and searchable if this error is corrected: It looks like row 6 should actually have 17 columns, instead of 4 in line 5.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Compilation Reference Locality Glacier Region Type Methodology Area (km2) Time interval (yr) Sediment flux (km3/yr) Exhumation Exhumation min Exhumation max Erosion rate (mm/yr) Erosion rate min Erosion rate max Comments | |
This study Lasabuda et al., 2018 NE Svalbard margin Fennoscandian Icesheet Fennoscandia Continental Volumetric 47500 2700000 530 410 650 0.196296296296296 0.151851851851852 0.240740740740741 | |
This study Laberg et al., 2012 SW Barents / Bjørnøya Fan Fennoscandian Icesheet Fennoscandia Continental Volumetric 576000 2700001 1100 0.407407256515831 | |
This study Laberg et al., 2012 SW Barents / Bjørnøya Fan Fennoscandian Icesheet Fennoscandia Continental Volumetric 576000 800000 375 330 420 0.46875 0.4125 0.525 | |
This study Laberg et al., 2012 SW Barents / Bjørnøya Fan Fennoscandian Icesheet Fennoscandia Continental Volumetric 200000 700000 485 440 530 0.692857142857143 0.628571428571429 0.757142857142857 | |
This study Hjelstuen et al., 1996 NW Barents / Storfjorden Fan Fennoscandian Iceshee |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
julia> using StaticCompiler, StaticTools | |
julia> hello() = println(c"Hello from compiled Julia!") | |
hello (generic function with 1 method) | |
julia> # Functions to compile into a single shlib | |
# add more (name, (argtypes..)) tuples to the array to add more functions | |
funcs = [(hello, ())] | |
1-element Vector{Tuple{typeof(hello), Tuple{}}}: | |
(hello, ()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using StaticCompiler, StaticTools, StaticMPI, MPICH_jll | |
function mpihello(argc, argv) | |
MPI_Init(argc, argv) | |
comm = MPI_COMM_WORLD | |
world_size, world_rank = MPI_Comm_size(comm), MPI_Comm_rank(comm) | |
printf((c"Hello from ", world_rank, c" of ", world_size, c" processors!\n")) | |
MPI_Finalize() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## --- Reproduce HEFTY-type t-T paths using _only_ the boxes | |
using Plots, Colors | |
struct TtBox | |
Tmin::Float64 | |
Tmax::Float64 | |
tmin::Float64 | |
tmax::Float64 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Looks best when run in a terminal with the tab stop width set to four spaces. | |
using StaticTools, StaticCompiler | |
function mandelbrot(zᵣ, zᵢ) | |
cᵣ, cᵢ = zᵣ, zᵢ | |
maxiter = 999 | |
for n = 1:maxiter | |
zᵣ², zᵢ² = zᵣ^2, zᵢ^2 | |
if zᵣ² + zᵢ² > 4 | |
return n-1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (c) 2016, Johan Mabille, Sylvain Corlay, Wolf Vollprecht and Martin Renou | |
# Copyright (c) 2016, QuantStack | |
# All rights reserved. | |
# | |
# Redistribution and use in source and binary forms, with or without | |
# modification, are permitted provided that the following conditions are met: | |
# | |
# * Redistributions of source code must retain the above copyright notice, this | |
# list of conditions and the following disclaimer. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
to_expr(x) = x | |
to_expr(t::Tuple) = Expr(to_expr.(t)...) # Recursive to_expr implementation suggested by Mason Protter | |
lisparse(x) = to_expr(eval(Meta.parse(x))) # Note that the `eval` in here means that any normal (non-s-expression) Julia syntax gets treated a bit like a preprocessor macro: evaluated _before_ the s-expression syntax is compiled and evaluated | |
function lispmode() | |
printstyled("\nlisp> ", color=:magenta, bold=true) | |
l = readline() # READ | |
while l !== "(:exit)" | |
try # So we don't get thrown out of the mode | |
result = eval(lisparse(l)) # EVAL | |
if isa(result, Expr) # PRINT, in s-expression syntax |