From a7522080a585bffffbda6fdaec60728ed8a6f455 Mon Sep 17 00:00:00 2001 From: Anton Steketee Date: Thu, 2 May 2024 15:25:08 +1000 Subject: [PATCH] Make nprocs optional --- .../cicedyn/infrastructure/ice_domain.F90 | 38 +++++++++---------- cicecore/shared/ice_distribution.F90 | 2 +- configuration/scripts/ice_in | 2 +- 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/cicecore/cicedyn/infrastructure/ice_domain.F90 b/cicecore/cicedyn/infrastructure/ice_domain.F90 index 87d181a51..74ac62b79 100644 --- a/cicecore/cicedyn/infrastructure/ice_domain.F90 +++ b/cicecore/cicedyn/infrastructure/ice_domain.F90 @@ -90,7 +90,6 @@ module ice_domain integer (int_kind) :: & nprocs ! num of processors - !*********************************************************************** contains @@ -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 @@ -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 diff --git a/cicecore/shared/ice_distribution.F90 b/cicecore/shared/ice_distribution.F90 index 0ba62f4a2..6e06069ab 100644 --- a/cicecore/shared/ice_distribution.F90 +++ b/cicecore/shared/ice_distribution.F90 @@ -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 diff --git a/configuration/scripts/ice_in b/configuration/scripts/ice_in index 63a97d7d8..ad29e05ce 100644 --- a/configuration/scripts/ice_in +++ b/configuration/scripts/ice_in @@ -302,7 +302,7 @@ / &domain_nml - nprocs = 4 + nprocs = -1 nx_global = 100 ny_global = 116 block_size_x = 25