copied fortran code