Skip to content

Instantly share code, notes, and snippets.

View awvwgk's full-sized avatar

Sebastian Ehlert awvwgk

View GitHub Profile
@awvwgk
awvwgk / drsqrt.f
Created September 5, 2017 19:38
fast reverse/inverse square root (Quake III style)
pure function drsqrt(rev) result(res)
use, intrinsic :: iso_fortran_env, only : int64
implicit none
real*8,intent(in) :: rev
real*8 :: rsq
integer(int64) :: isq
real*8 :: res
real*8,parameter :: onehalf = 0.5
real*8,parameter :: threehalfs = 1.5
integer(int64) :: magic
@awvwgk
awvwgk / coord.f
Created September 5, 2017 19:49
reader for xmol and turbomole geometry files
subroutine readxyz(fname)
implicit real*8(x-z)
integer,parameter :: idx = 42
character(len=*) :: fname
character(len=100) :: line
real*8, allocatable :: xyz(:,:)
integer,allocatable :: atom(:)
logical :: exist
integer :: c
@awvwgk
awvwgk / hf.rb
Created April 14, 2018 20:58
Hacked together in about an hour after I discovered matrix.rb in ruby's stdlib
#!/bin/env ruby
# ------------------------------------------------------------------------
# Copyright (C) 2018 Sebastian Ehlert
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@awvwgk
awvwgk / leipniz.f90
Created April 15, 2018 08:22
Different ways to get pi in FORTRAN (apart from 4*atan(1.0))
use,intrinsic :: iso_fortran_env, only : output_unit
implicit none
intrinsic :: kind,command_argument_count,get_command,index,sum,abs,epsilon
integer,parameter :: sp = kind(1.0e0)
integer,parameter :: dp = kind(1.0d0)
integer,parameter :: qp = kind(1.0q0)
integer(kind=8) :: i
integer(kind=8) :: i_max
character(len=:),allocatable :: line
character(len=2) :: ch
"++++++++++++++++++++++++++++++++++++++++"
"+ vimrc von awvwgk +"
"++++++++++++++++++++++++++++++++++++++++"
set history=700
"----------------------------------------"
filetype plugin on
filetype indent on
"----------------------------------------"
set autoread
"----------------------------------------"
@awvwgk
awvwgk / tbdef_atomlist.f90
Created October 17, 2019 20:01
A simplistic list of atoms for easy IO
!> implemenation of a list of atoms
module tbdef_atomlist
implicit none
public :: tb_atomlist
public :: size, len, assignment(=), write(formatted), read(formatted)
private
character, parameter :: p_delimiter = ','
character, parameter :: p_skip = '-'
@awvwgk
awvwgk / zoom2ics.awk
Last active April 21, 2020 18:57
Convert a zoom email invitation to ics, in case the host forgot the to attach an ics
BEGIN {
print "BEGIN:VCALENDAR";
print "VERSION:2.0";
print "BEGIN:VEVENT";
"date -u +'%Y%m%dT%H%M%SZ'" | getline datetime;
print "CREATED:"datetime;
description = "DESCRIPTION:"
}
/Amsterdam, Berlin, Rome, Stockholm, Vienna$/ {
tzid = "Europe/Berlin";
@awvwgk
awvwgk / diag3x3.f90
Last active May 10, 2020 22:22
Diagonalization of 3x3 matrices
! This is free and unencumbered software released into the public domain.
!
! Anyone is free to copy, modify, publish, use, compile, sell, or
! distribute this software, either in source code form or as a compiled
! binary, for any purpose, commercial or non-commercial, and by any
! means.
!
! In jurisdictions that recognize copyright laws, the author or authors
! of this software dedicate any and all copyright interest in the
! software to the public domain. We make this dedication for the benefit
@awvwgk
awvwgk / bug3.adoc
Last active May 19, 2020 15:55
Bugs with pgfortran 19.10-0 LLVM 64-bit target on x86-64 Linux -tp sandybridge
pgfortran -Mallocatable=03 bug3.f90
PGF90-S-0000-Internal compiler error. transform_call:Array Expression can't be here     168  (bug3.f90: 35)
Lowering Error: bad ast optype in expression [ast=163,asttype=12,datatype=0]
PGF90-F-0000-Internal compiler error. Errors in Lowering       1  (bug3.f90: 39)
PGF90/x86-64 Linux 19.10-0: compilation aborted
@awvwgk
awvwgk / gather-outcar.awk
Created August 24, 2021 09:55
Extract DFTB+ compatibile tagged data from Vasp's OUTCAR file
#!/usr/bin/awk -f
BEGIN {
evtoau = 1.0 / 27.21138505
aatoau = 1.0 / 0.52917726
poscar = 0
tag = 1
}
$1 ~ /Total/ && NF == 7 {