Fortran implementation with lots of 'magic' numbers.