fortran code for computing dynamic programming table