Refactoring

This should simplify the code quite a bit.

More can be done --- in the populate_weights() function you are still passing the sizes of arrays as arguments (i.e. the F77 style), which you don't need to if you used the F90 arrays. See http://www.fortran90.org/src/best-practices.html#arrays for more info on this.