Skip to content

Commit

Permalink
ice_domain: improve 'max_blocks' computation
Browse files Browse the repository at this point in the history
The value of 'max_blocks' as currently computed can still be too small
if the number of procs does not divide the number of blocks evenly.

Use the same 'minus one, integer divide, plus one' trick as is done for
the number of blocks in the X and Y directions in order to always
compute a 'max_blocks' value that is large enough.

This estimates the same value for 'max_blocks' as the 'cice_decomp.csh'
script computes:

    @ bx = $nxglob / ${blckx}
    if ($bx * ${blckx} != $nxglob) @ bx = $bx + 1
    @ by = $nyglob / ${blcky}
    if ($by * ${blcky} != $nyglob) @ by = $by + 1

    @ m = ($bx * $by) / ${task}
    if ($m * ${task} != $bx * $by) @ m = $m + 1
    set mxblcks = $m
  • Loading branch information
phil-blain committed Mar 30, 2021
1 parent f254490 commit d64b061
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cicecore/cicedynB/infrastructure/ice_domain.F90
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ subroutine init_domain_blocks
call broadcast_scalar(add_mpi_barriers, master_task)
if (my_task == master_task) then
if (max_blocks < 1) then
max_blocks=( ((nx_global-1)/block_size_x + 1) * &
((ny_global-1)/block_size_y + 1) ) / nprocs
max_blocks=( (((nx_global-1)/block_size_x + 1) * &
((ny_global-1)/block_size_y + 1) - 1) / nprocs + 1
max_blocks=max(1,max_blocks)
write(nu_diag,'(/,a52,i6,/)') &
'(ice_domain): max_block < 1: max_block estimated to ',max_blocks
Expand Down

0 comments on commit d64b061

Please sign in to comment.