Closed weather4evr closed 5 months ago
To figure out the MPAS parallelization, this is used in model_grid.F90:
nCellsPerPET = ceiling(real(nCells)/real(npets)) cell_start = localpet*nCellsPerPET+1 cell_end = min(localpet*nCellsPerPET+nCellsPerPET,nCells) nCellsPerPET = cell_end - cell_start + 1
But, this will sometimes lead to nCellsPerPET < 0 for certain combinations of grid sizes and npets, probably because use of "ceiling" in the above. This algorithm is arguably safer:
call para_range(1, nCells, npets, localpet, cell_start, cell_end) nCellsPerPET = cell_end - cell_start + 1 subroutine para_range(n1, n2, nprocs, irank, ista, iend) integer, intent(in) :: n1, n2, nprocs, irank integer, intent(out) :: ista, iend integer :: iwork1, iwork2 iwork1 = (n2 - n1 + 1) / nprocs iwork2 = mod(n2 - n1 + 1, nprocs) ista = irank * iwork1 + n1 + min(irank, iwork2) iend = ista + iwork1 - 1 if (iwork2 > irank) iend = iend + 1 return end subroutine para_range
`
This was fixed using your suggested solution in PR #18
To figure out the MPAS parallelization, this is used in model_grid.F90:
But, this will sometimes lead to nCellsPerPET < 0 for certain combinations of grid sizes and npets, probably because use of "ceiling" in the above. This algorithm is arguably safer:
`