MODFLOW 6  version 6.8.0.dev0
USGS Modular Hydrologic Model
ParallelAts.f90
Go to the documentation of this file.
2  use mpi
3  use simvariablesmodule, only: proc_id
5  use kindmodule, only: i4b, dp
7  implicit none
8  private
9 
10  public :: parallelatstype
11 
12  !> @brief Extends ATS so we can do synchronization
13  !< of time step size (including dtstable!) across ranks
14  type, extends(atstype) :: parallelatstype
15  contains
16  procedure, public :: ats_submit_delt => par_ats_submit_delt
17  procedure, public :: ats_set_delt => par_ats_set_delt
18  end type parallelatstype
19 
20 contains
21 
22  !> @ brief Allow and external caller to submit preferred time step
23  !!
24  !! Submit a preferred time step length. Alternatively, if idir is
25  !! is passed, then either increase or decrease the submitted time
26  !! step by the dtadj input variable.
27  !!
28  !<
29  subroutine par_ats_submit_delt(this, kstp, kper, dt, sloc, idir)
30  class(parallelatstype) :: this
31  integer(I4B), intent(in) :: kstp
32  integer(I4B), intent(in) :: kper
33  real(DP), intent(in) :: dt
34  character(len=*), intent(in) :: sloc
35  integer(I4B), intent(in), optional :: idir
36  ! local
37  type(mpiworldtype), pointer :: mpi_world
38  integer :: ierr
39  real(DP) :: global_dt
40 
41  if (.not. this%isAdaptivePeriod(kper)) return
42 
43  ! reduce dtstable over all ranks
44  mpi_world => get_mpi_world()
45  call mpi_allreduce(this%dtstable, global_dt, 1, mpi_double_precision, &
46  mpi_min, mpi_world%comm, ierr)
47  call check_mpi(ierr)
48 
49  this%dtstable = global_dt
50 
51  call this%AtsType%ats_submit_delt(kstp, kper, dt, sloc, idir)
52 
53  end subroutine par_ats_submit_delt
54 
55  !> @ brief Set time step
56  !!
57  !! Set the time step length (delt) for this time step using the ATS
58  !! controls, but with synchronization across ranks.
59  !<
60  subroutine par_ats_set_delt(this, kstp, kper, pertim, perlencurrent, delt)
61  class(parallelatstype) :: this
62  integer(I4B), intent(in) :: kstp
63  integer(I4B), intent(in) :: kper
64  real(DP), intent(inout) :: pertim
65  real(DP), intent(in) :: perlencurrent
66  real(DP), intent(inout) :: delt
67  ! local
68  type(mpiworldtype), pointer :: mpi_world
69  integer :: ierr
70  real(DP) :: global_delt
71 
72  ! reduce delt over all ranks
73  mpi_world => get_mpi_world()
74  call mpi_allreduce(delt, global_delt, 1, mpi_double_precision, &
75  mpi_min, mpi_world%comm, ierr)
76  call check_mpi(ierr)
77 
78  delt = global_delt
79 
80  call this%AtsType%ats_set_delt(kstp, kper, pertim, perlencurrent, delt)
81 
82  end subroutine par_ats_set_delt
83 
84 end module parallelatsmodule
subroutine ats_submit_delt(this, kstp, kper, dt, sloc, idir)
@ brief Allow and external caller to submit preferred time step
Definition: ats.f90:527
subroutine ats_set_delt(this, kstp, kper, pertim, perlencurrent, delt)
@ brief Set time step
Definition: ats.f90:577
This module defines variable data types.
Definition: kind.f90:8
type(mpiworldtype) function, pointer, public get_mpi_world()
Definition: MpiWorld.f90:32
subroutine, public check_mpi(mpi_error_code)
Check the MPI error code, report, and.
Definition: MpiWorld.f90:116
subroutine par_ats_submit_delt(this, kstp, kper, dt, sloc, idir)
@ brief Allow and external caller to submit preferred time step
Definition: ParallelAts.f90:30
subroutine par_ats_set_delt(this, kstp, kper, pertim, perlencurrent, delt)
@ brief Set time step
Definition: ParallelAts.f90:61
This module contains simulation variables.
Definition: SimVariables.f90:9
integer(i4b) proc_id
Extends ATS so we can do synchronization.
Definition: ParallelAts.f90:14