dim can't be less than 5
incorrect function names fixed
new subroutine det_20140704()