Skip to content

Commit

Permalink
Make nprocs optional
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-seaice committed May 2, 2024
1 parent 2c85db3 commit a752208
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 23 deletions.
38 changes: 17 additions & 21 deletions cicecore/cicedyn/infrastructure/ice_domain.F90
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ module ice_domain
integer (int_kind) :: &
nprocs ! num of processors


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

contains
Expand Down Expand Up @@ -224,18 +223,25 @@ subroutine init_domain_blocks
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
! Set nprocs if not set in namelist
if (nprocs .eq. -1) then
nprocs = get_num_procs()
else if (nprocs .ne. get_num_procs()) then
write(nu_diag,*) subname,' ERROR: nprocs, get_num_procs = ',nprocs,get_num_procs()
call abort_ice(subname//' ERROR: Input nprocs not same as system request', file=__FILE__, line=__LINE__)
endif

! Determine max_blocks if not set
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


!----------------------------------------------------------------------
!
! perform some basic checks on domain
Expand All @@ -247,16 +253,6 @@ subroutine init_domain_blocks
!*** domain size zero or negative
!***
call abort_ice(subname//' ERROR: Invalid domain: size < 1', file=__FILE__, line=__LINE__) ! no domain
else if (nprocs /= get_num_procs()) then
!***
!*** input nprocs does not match system (eg MPI) request
!***
#if (defined CESMCOUPLED)
nprocs = get_num_procs()
#else
write(nu_diag,*) subname,' ERROR: nprocs, get_num_procs = ',nprocs,get_num_procs()
call abort_ice(subname//' ERROR: Input nprocs not same as system request', file=__FILE__, line=__LINE__)
#endif
else if (nghost < 1) then
!***
!*** must have at least 1 layer of ghost cells
Expand Down
2 changes: 1 addition & 1 deletion cicecore/shared/ice_distribution.F90
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module ice_distribution
ice_distributionGetBlockLoc, &
ice_distributionGetBlockID, &
create_local_block_ids, &
proc_decomposition ! mli: add
proc_decomposition

character (char_len), public :: &
processor_shape ! 'square-pop' (approx) POP default config
Expand Down
2 changes: 1 addition & 1 deletion configuration/scripts/ice_in
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@
/

&domain_nml
nprocs = 4
nprocs = -1
nx_global = 100
ny_global = 116
block_size_x = 25
Expand Down

0 comments on commit a752208

Please sign in to comment.