Skip to content

Commit

Permalink
ice_domain: revert changes to 'max_blocks' computation from fcbea1d
Browse files Browse the repository at this point in the history
In fcbea1d (Added DMI/nuopc driver and fixed ANGLET (CICE-Consortium#377), 2019-11-22), the
computation in 'ice_domain::init_domain_blocks' that estimates 'max_blocks' if
the value '-1' is given in the namelist was changed without explanations.

The old computation was computing the number of blocks in the X and Y
directions, taking any necessary padding into account (by substracting 1 to
n[xy]_global, using integer division and adding 1), multiplying them to compute
the total number of blocs, and integer-dividing by `nprocs` to estimate the number
of blocks per processor.

The new computation does a similar computation, but it's unclear what it is
computing exactly. Since it uses floating point division and only casts the
result to an integer at the end of the computation, it systematically computes
a `max_blocks` value that is smaller than the old computation.

This leads to a `max_blocks` value that is systematically too small for the
cartesian decomposition when `block_size_x(y)` does not divide `nx(y)_global`
evenly.

Go back to the old computation.

Also, adjust the documentation to make it clearer that it's possible that
the `max_blocks` value computed by the model might not be appropriate.
  • Loading branch information
phil-blain committed Oct 21, 2020
1 parent 804e320 commit 2197290
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions cicecore/cicedynB/infrastructure/ice_domain.F90
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +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=int( &
( (dble(nx_global-1)/dble(block_size_x + 1)) * &
(dble(ny_global-1)/dble(block_size_y + 1)) ) &
/ dble(nprocs))
max_blocks=( ((nx_global-1)/block_size_x + 1) * &
((ny_global-1)/block_size_y + 1) ) / nprocs
max_blocks=max(1,max_blocks)
write(nu_diag,'(/,a52,i6,/)') &
'(ice_domain): max_block < 1: max_block estimated to ',max_blocks
Expand Down
2 changes: 1 addition & 1 deletion doc/source/user_guide/ug_implementation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ information to the log file, and if the block size or max blocks is
inconsistent with the task and thread size, the model will abort. The
code will also print a warning if the maximum number of blocks is too large.
Although this is not fatal, it does use extra memory. If ``max_blocks`` is
set to -1, the code will compute a ``max_blocks`` on the fly.
set to -1, the code will compute a tentative ``max_blocks`` on the fly.

A loop at the end of routine *create\_blocks* in module
**ice\_blocks.F90** will print the locations for all of the blocks on
Expand Down

0 comments on commit 2197290

Please sign in to comment.