completed sod calc code pre-test