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
Co-authored-by: anton-seaice <[email protected]>
  • Loading branch information
2 people authored and Anton Steketee committed May 2, 2024
1 parent 3e30553 commit 2c85db3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
27 changes: 16 additions & 11 deletions cicecore/cicedyn/infrastructure/ice_domain.F90
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ module ice_domain
integer (int_kind) :: &
nprocs ! num of processors


!***********************************************************************

contains
Expand All @@ -101,7 +102,7 @@ subroutine init_domain_blocks
! This routine reads in domain information and calls the routine
! to set up the block decomposition.

use ice_distribution, only: processor_shape
use ice_distribution, only: processor_shape, proc_decomposition
use ice_domain_size, only: ncat, nilyr, nslyr, max_blocks, &
nx_global, ny_global, block_size_x, block_size_y
use ice_fileunits, only: goto_nml
Expand All @@ -112,7 +113,8 @@ subroutine init_domain_blocks
!----------------------------------------------------------------------

integer (int_kind) :: &
nml_error ! namelist read error flag
nml_error, & ! namelist read error flag
nprocs_x, nprocs_y ! procs decomposed into blocks

character(len=char_len) :: nml_name ! text namelist name
character(len=char_len_long) :: tmpstr2 ! for namelist check
Expand Down Expand Up @@ -216,21 +218,24 @@ 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)
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=max(1,max_blocks)
write(nu_diag,'(/,a52,i6,/)') &
'(ice_domain): max_block < 1: max_block estimated to ',max_blocks
endif
endif
call broadcast_scalar(max_blocks, master_task)
call broadcast_scalar(block_size_x, master_task)
call broadcast_scalar(block_size_y, master_task)
call broadcast_scalar(nx_global, master_task)
call broadcast_scalar(ny_global, master_task)

! Automatically determine max_blocks if not set.
if (my_task == master_task) then
if (max_blocks < 1) then
call proc_decomposition(nprocs, nprocs_x, nprocs_y)
max_blocks=((nx_global-1)/block_size_x/nprocs_x+1) * &
((ny_global-1)/block_size_y/nprocs_y+1)
max_blocks=max(1,max_blocks)
write(nu_diag,'(/,a52,i6,/)') &
'(ice_domain): max_block < 1: max_block estimated to ',max_blocks
endif
endif

!----------------------------------------------------------------------
!
! perform some basic checks on domain
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 2c85db3

Please sign in to comment.