Skip to content

Commit

Permalink
update max_blocks in ice_domain.F90, enabling max_blocks set on the fly
Browse files Browse the repository at this point in the history
  • Loading branch information
minghangli-uni committed Apr 22, 2024
1 parent 138adab commit 32f5d69
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
17 changes: 14 additions & 3 deletions cicecore/cicedyn/infrastructure/ice_domain.F90
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ module ice_domain
use ice_broadcast, only: broadcast_scalar, broadcast_array
use ice_blocks, only: block, get_block, create_blocks, nghost, &
nblocks_x, nblocks_y, nblocks_tot, nx_block, ny_block, debug_blocks
use ice_distribution, only: distrb
! mli: proc_decomposition imported
use ice_distribution, only: distrb,proc_decomposition
use ice_boundary, only: ice_halo
use ice_exit, only: abort_ice
use ice_fileunits, only: nu_nml, nml_filename, nu_diag, &
Expand Down Expand Up @@ -90,6 +91,10 @@ module ice_domain
integer (int_kind) :: &
nprocs ! num of processors

!mli: update optimal 2d processors
integer (int_kind) :: &
nprocs_x_mli,nprocs_y_mli ! num of processors after
! finding optimal 2d processor
!***********************************************************************

contains
Expand Down Expand Up @@ -217,10 +222,16 @@ subroutine init_domain_blocks
call broadcast_scalar(maskhalo_bound, master_task)
call broadcast_scalar(add_mpi_barriers, master_task)
call broadcast_scalar(debug_blocks, master_task)

! mli: update nprocs_x and nprocs_y
call proc_decomposition(nprocs, nprocs_x_mli, nprocs_y_mli)

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) - 1) / nprocs + 1
! max_blocks=( ((nx_global-1)/block_size_x + 1) * &
! ((ny_global-1)/block_size_y + 1) - 1) / nprocs + 1
max_blocks=((nx_global-1)/block_size_x/nprocs_x_mli+1) * &
((ny_global-1)/block_size_y/nprocs_y_mli+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
3 changes: 2 additions & 1 deletion cicecore/shared/ice_distribution.F90
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ module ice_distribution
ice_distributionGet, &
ice_distributionGetBlockLoc, &
ice_distributionGetBlockID, &
create_local_block_ids
create_local_block_ids, &
proc_decomposition ! mli: add

character (char_len), public :: &
processor_shape ! 'square-pop' (approx) POP default config
Expand Down

0 comments on commit 32f5d69

Please sign in to comment.