Skip to content

Instantly share code, notes, and snippets.

Avatar

Paul Anton Letnes pletnes

  • Trondheim, Norway
View GitHub Profile
@pletnes
pletnes / pylintexample.py
Created Oct 28, 2020
Function scope pylint rules
View pylintexample.py
# Both foo and bar trigger the "blacklisted-name" pylint rule.
# Placing a #pylint pragma inside the foo block ensures that only this function is not triggering the rule.
def foo():
"""docstr"""
# pylint: disable=blacklisted-name
a=2
return a
def bar():
@pletnes
pletnes / shellcheck
Created Jun 3, 2020
Shellcheck - run on git-bash on windows
View shellcheck
#!/bin/bash
exec docker run --rm -v "$(cygpath -aw .):/mnt" koalaman/shellcheck:stable "$@"
@pletnes
pletnes / cd.py
Created May 25, 2020
Contextmanager `cd` to enter/leave directory
View cd.py
@contextlib.contextmanager
def cd(directory):
pre_directory = os.getcwd()
os.chdir(str(directory))
try:
yield
finally:
os.chdir(str(pre_directory))
View foo.f90
program archaic
implicit none
! This is actually a program input
integer, parameter :: M = 10000
integer, allocatable, dimension(:) :: iwork
integer, pointer, dimension(:) :: ptr
integer, pointer, dimension(:,:) :: ptr_remap
integer :: i, start, length
nullify(ptr)
@pletnes
pletnes / Makefile
Last active Apr 4, 2016
Makefile and code - illegal fortran syntax?
View Makefile
.PHONY: all pgi intel gcc nag clean
all: gcc intel nag pgi
pgi:
pgfortran -V
pgfortran -Minform=inform -Mbounds intertest.f90 -o intertest-pgi
./intertest-pgi
intel:
View gist:73d52a4a71a4b0074dd9
program test_nearest
integer, parameter :: R8P = 8
real(R8P) :: z
#ifdef __GFORTRAN__
real(R8P), parameter:: ZeroR8 = nearest(1._R8P, 1._R8P) - nearest(1._R8P,-1._R8P)
real(R8P), parameter:: ZeroR8_2 = nearest(1._R8P, 1._R8P) - 1._R8P
#endif
real(R8P), parameter:: ZeroR8_3 = epsilon(z)
You can’t perform that action at this time.