modify: replace loops with fortran subroutines in the cube_partition_run.py