14 integer(I4B) :: tmr_convergence = -1
15 integer(I4B) :: tmr_pkg_cnvg = -1
16 integer(I4B) :: tmr_sync_nur = -1
17 integer(I4B) :: tmr_nur_cnvg = -1
18 integer(I4B) :: tmr_calcptc = -1
19 integer(I4B) :: tmr_underrelax = -1
20 integer(I4B) :: tmr_backtracking = -1
43 logical(LGP) :: has_converged
45 real(dp) :: global_max_dvc
46 real(dp) :: abs_max_dvc
50 call g_prof%start(
"Parallel Solution (cnvg check)", this%tmr_convergence)
54 has_converged = .false.
55 abs_max_dvc = abs(max_dvc)
56 call mpi_allreduce(abs_max_dvc, global_max_dvc, 1, mpi_double_precision, &
57 mpi_max, mpi_world%comm, ierr)
59 if (global_max_dvc <= this%dvclose)
then
60 has_converged = .true.
63 call g_prof%stop(this%tmr_convergence)
70 real(dp),
intent(in) :: dpak
71 character(len=LENPAKLOC),
intent(in) :: cpakout
72 integer(I4B),
intent(in) :: iend
74 integer(I4B) :: icnvg_global
75 integer(I4B) :: icnvg_local
79 call g_prof%start(
"Parallel Solution (package cnvg)", this%tmr_pkg_cnvg)
84 this%NumericalSolutionType%sln_package_convergence(dpak, cpakout, iend)
86 call mpi_allreduce(icnvg_local, icnvg_global, 1, mpi_integer, &
87 mpi_min, mpi_world%comm, ierr)
90 call g_prof%stop(this%tmr_pkg_cnvg)
96 integer(I4B),
intent(in) :: inewtonur
98 integer(I4B) :: ivalue
102 call g_prof%start(
"Parallel Solution (NUR)", this%tmr_sync_nur)
105 call mpi_allreduce(inewtonur, ivalue, 1, mpi_integer, &
106 mpi_max, mpi_world%comm, ierr)
109 call g_prof%stop(this%tmr_sync_nur)
114 result(has_converged)
116 real(dp),
intent(in) :: dxold_max
117 real(dp),
intent(in) :: hncg
118 logical(LGP) :: has_converged
120 integer(I4B) :: icnvg_local
121 integer(I4B) :: icnvg_global
125 call g_prof%start(
"Parallel Solution (NUR cnvg)", this%tmr_nur_cnvg)
129 has_converged = .false.
131 if (this%NumericalSolutionType%sln_nur_has_converged( &
132 dxold_max, hncg))
then
136 call mpi_allreduce(icnvg_local, icnvg_global, 1, mpi_integer, &
137 mpi_min, mpi_world%comm, ierr)
139 if (icnvg_global == 1) has_converged = .true.
141 call g_prof%stop(this%tmr_nur_cnvg)
152 integer(I4B) :: iptc_loc
153 real(DP) :: ptcf_loc, ptcf_glo_max
157 call g_prof%start(
"Parallel Solution (PTC calc)", this%tmr_calcptc)
160 call this%NumericalSolutionType%sln_calc_ptc(iptc_loc, ptcf_loc)
161 if (iptc_loc == 0) ptcf_loc =
dzero
164 call mpi_allreduce(ptcf_loc, ptcf_glo_max, 1, mpi_double_precision, &
165 mpi_max, mpi_world%comm, ierr)
170 if (ptcf_glo_max >
dzero)
then
175 call g_prof%stop(this%tmr_calcptc)
183 integer(I4B),
intent(in) :: kiter
184 real(DP),
intent(in) :: bigch
185 integer(I4B),
intent(in) :: neq
186 integer(I4B),
dimension(neq),
intent(in) :: active
187 real(DP),
dimension(neq),
intent(inout) :: x
188 real(DP),
dimension(neq),
intent(in) :: xtemp
190 real(DP) :: dvc_global_max, dvc_global_min
194 call g_prof%start(
"Parallel Solution (underrelax)", this%tmr_underrelax)
199 call mpi_allreduce(bigch, dvc_global_max, 1, mpi_double_precision, &
200 mpi_max, mpi_world%comm, ierr)
202 call mpi_allreduce(bigch, dvc_global_min, 1, mpi_double_precision, &
203 mpi_min, mpi_world%comm, ierr)
206 if (abs(dvc_global_min) > abs(dvc_global_max))
then
207 dvc_global_max = dvc_global_min
211 call this%NumericalSolutionType%sln_underrelax(kiter, dvc_global_max, &
212 neq, active, x, xtemp)
214 call g_prof%stop(this%tmr_underrelax)
223 integer(I4B),
intent(inout) :: bt_flag
225 integer(I4B) :: btflag_local
229 call g_prof%start(
"Parallel Solution (backtrack)", this%tmr_backtracking)
234 btflag_local = this%NumericalSolutionType%get_backtracking_flag()
237 call mpi_allreduce(btflag_local, bt_flag, 1, mpi_integer, &
238 mpi_max, mpi_world%comm, ierr)
242 if (bt_flag > 0)
then
243 call this%NumericalSolutionType%apply_backtracking()
246 call g_prof%stop(this%tmr_backtracking)
255 integer(I4B) :: idv_scale_global
257 integer(I4B) :: idv_scale_local
264 idv_scale_local = this%NumericalSolutionType%sln_get_idvscale()
267 call mpi_allreduce(idv_scale_local, idv_scale_global, 1, mpi_integer, &
268 mpi_min, mpi_world%comm, ierr)
278 integer(I4B),
intent(in) :: nsize
279 real(DP),
dimension(nsize),
intent(in) :: v
280 real(DP),
intent(inout) :: vmax
282 real(DP) :: vmax_local
283 real(DP) :: vmin_global
290 call this%NumericalSolutionType%sln_maxval(nsize, v, vmax_local)
293 call mpi_allreduce(vmax_local, vmax, 1, mpi_double_precision, &
294 mpi_max, mpi_world%comm, ierr)
297 call mpi_allreduce(vmax_local, vmin_global, 1, mpi_double_precision, &
298 mpi_min, mpi_world%comm, ierr)
301 if (abs(vmin_global) > abs(vmax))
then
This module contains simulation constants.
integer(i4b), parameter lenpakloc
maximum length of a package location
real(dp), parameter dzero
real constant zero
real(dp), parameter done
real constant 1
This module defines variable data types.
type(mpiworldtype) function, pointer, public get_mpi_world()
subroutine, public check_mpi(mpi_error_code)
Check the MPI error code, report, and.
logical(lgp) function par_has_converged(this, max_dvc)
Check global convergence. The local maximum dependent variable change is reduced over MPI with all ot...
integer(i4b) function par_package_convergence(this, dpak, cpakout, iend)
logical(lgp) function par_nur_has_converged(this, dxold_max, hncg)
integer(i4b) function par_sync_newtonur_flag(this, inewtonur)
integer(i4b) function par_get_idvscale(this)
synchronize idvscale flag over processes
subroutine par_underrelax(this, kiter, bigch, neq, active, x, xtemp)
apply under-relaxation in sync over all processes
subroutine par_backtracking_xupdate(this, bt_flag)
synchronize backtracking flag over processes
subroutine par_calc_ptc(this, iptc, ptcf)
Calculate pseudo-transient continuation factor.
subroutine par_maxval(this, nsize, v, vmax)
synchronize maxval over processes
type(profilertype), public g_prof
the global timer object (to reduce trivial lines of code)