Function now 100 percent successfully being called from fortran, needs lots of cleanup.