Skip to content

Instantly share code, notes, and snippets.

View krystophny's full-sized avatar

Christopher Albert krystophny

View GitHub Profile
@krystophny
krystophny / grow_type_array.f90
Created June 14, 2025 20:19
GFortran 15 bug
program grow_type_array
type :: string_t
character(:), allocatable :: s
end type string_t
type(string_t) :: str
type(string_t), allocatable :: list(:)
! This works
allocate(list(0))
@krystophny
krystophny / issue_interface.f90
Last active May 27, 2025 10:42
GFortran 15 bug
module odeint_allroutines_sub
implicit none
abstract interface
subroutine compute_derivative(x, y, dydx)
real(8), intent(in) :: x
real(8), intent(in) :: y(:)
real(8), intent(out) :: dydx(:)
end subroutine compute_derivative
end interface
@krystophny
krystophny / setup.py
Created January 10, 2025 07:33
setup.py for f2py with legacy support
from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext
from importlib.machinery import EXTENSION_SUFFIXES
import os
import shutil
import sys
import subprocess
import sysconfig
@krystophny
krystophny / parallel_plot.py
Created May 14, 2019 06:58
Exporting plots in parallel using concurrent.futures
import concurrent.futures
import matplotlib.pyplot as plt
import numpy as np
import time, random
def do_stuff(a): # these are examples.
x = np.linspace(1,10)
plt.plot(x, np.cos(a*x))
plt.savefig('{}.png'.format(a))
time.sleep(random.random())
@krystophny
krystophny / triplot_sample.py
Created May 7, 2019 11:13
Plotting on a mesh
import matplotlib.pyplot as plt
import matplotlib.tri as mpltri
import meshio # von https://github.com/nschloe/meshio
mesh = meshio.read('any_known_mesh_format.msh')
tria = mpltri.Triangulation(mesh.points[:,0], mesh.points[:,1], mesh.cells['triangle'])
for k in range(nplots):
plt.figure()
plt.tricontourf(tria, plot_data[k])