Skip to content

Commit f1fe0cd

Browse files
Merge branch 'bishtgautam/lnd/add-mpi-barrier' (PR #5741)
A namelist option (mpi_sync_nstep_freq) is added to allow ELM to call an MPI_Barrier. By default, the MPI_Barrier is not called. [BFB]
2 parents 9e17b77 + a9ad253 commit f1fe0cd

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

components/elm/bld/namelist_files/namelist_definition.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2020,5 +2020,15 @@ explain the SZA dependence of direct irradiance.
20202020
Toggle to turn on the internal mixing of dust-snow.
20212021
</entry>
20222022

2023+
<!-- ======================================================================================== -->
2024+
<!-- Namelist option for MPI syncing -->
2025+
<!-- ======================================================================================== -->
2026+
2027+
<entry id="mpi_sync_nstep_freq" type="integer(6)" category="history"
2028+
group="elm_inparm" value="0">
2029+
The number of steps after which a MPI_Barrier is called. By default, a MPI_Barrier will
2030+
not be called.
2031+
<default>Default: 0</default>
2032+
</entry>
20232033

20242034
</namelist_definition>

components/elm/src/main/controlMod.F90

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,8 @@ subroutine control_init( )
225225
namelist /elm_inparm/ &
226226
clump_pproc, wrtdia, &
227227
create_crop_landunit, nsegspc, co2_ppmv, override_nsrest, &
228-
albice, more_vertlayers, subgridflag, irrigate, tw_irr, extra_gw_irr, firrig_data, all_active
228+
albice, more_vertlayers, subgridflag, irrigate, tw_irr, extra_gw_irr, firrig_data, all_active, &
229+
mpi_sync_nstep_freq
229230
! Urban options
230231

231232
namelist /elm_inparm/ &
@@ -318,7 +319,7 @@ subroutine control_init( )
318319

319320
namelist /elm_inparm/ &
320321
snow_shape, snicar_atm_type, use_dust_snow_internal_mixing
321-
322+
322323
! ----------------------------------------------------------------------
323324
! Default values
324325
! ----------------------------------------------------------------------
@@ -938,6 +939,8 @@ subroutine control_spmd()
938939
call mpi_bcast (snicar_atm_type, len(snicar_atm_type), MPI_CHARACTER, 0, mpicom, ier)
939940
call mpi_bcast (use_dust_snow_internal_mixing, 1, MPI_LOGICAL, 0, mpicom, ier)
940941

942+
call mpi_bcast (mpi_sync_nstep_freq, 1, MPI_INTEGER, 0, mpicom, ier)
943+
941944
end subroutine control_spmd
942945

943946
!------------------------------------------------------------------------
@@ -1195,6 +1198,7 @@ subroutine control_print ()
11951198
! land river two way coupling
11961199
write(iulog,*) ' use_lnd_rof_two_way = ', use_lnd_rof_two_way
11971200
write(iulog,*) ' lnd_rof_coupling_nstep = ', lnd_rof_coupling_nstep
1201+
write(iulog,*) ' mpi_sync_nstep_freq = ', mpi_sync_nstep_freq
11981202

11991203
end subroutine control_print
12001204

components/elm/src/main/elm_driver.F90

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module elm_driver
1515
use elm_varctl , only : wrtdia, iulog, create_glacier_mec_landunit, use_fates, use_betr, use_extrasnowlayers
1616
use elm_varctl , only : use_cn, use_lch4, use_voc, use_noio, use_c13, use_c14
1717
use elm_varctl , only : use_erosion, use_fates_sp
18+
use elm_varctl , only : mpi_sync_nstep_freq
1819
use clm_time_manager , only : get_step_size, get_curr_date, get_ref_date, get_nstep, is_beg_curr_day, get_curr_time_string
1920
use clm_time_manager , only : get_curr_calday, get_days_per_year
2021
use elm_varpar , only : nlevsno, nlevgrnd, crop_prog
@@ -251,6 +252,15 @@ subroutine elm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate)
251252
dayspyr_mod = get_days_per_year()
252253
jday_mod = get_curr_calday()
253254

255+
if (mpi_sync_nstep_freq > 0) then
256+
if (mod(nstep_mod,mpi_sync_nstep_freq) == 0) then
257+
call MPI_Barrier(mpicom, ier)
258+
if (masterproc) then
259+
write(iulog,*)' A MPI_Barrier is added in this timestep.'
260+
end if
261+
end if
262+
end if
263+
254264
if (do_budgets) then
255265
call WaterBudget_Reset()
256266

components/elm/src/main/elm_varctl.F90

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,10 @@ module elm_varctl
522522
character(len=256), public :: snicar_atm_type = 'default'
523523
logical, public :: use_dust_snow_internal_mixing = .false.
524524

525+
!----------------------------------------------------------
526+
! MPI syncing
527+
!----------------------------------------------------------
528+
integer, public :: mpi_sync_nstep_freq = 0
525529

526530
contains
527531

0 commit comments

Comments
 (0)