3 use machine,
only : kind_phys
7 public :: mp_tempo_post_init, mp_tempo_post_run, mp_tempo_post_final
11 logical :: is_initialized = .false.
13 logical :: apply_limiter
20 subroutine mp_tempo_post_init(ttendlim, errmsg, errflg)
25 real(kind_phys),
intent(in) :: ttendlim
28 character(len=*),
intent( out) :: errmsg
29 integer,
intent( out) :: errflg
39 if (is_initialized)
return
41 if (ttendlim < 0)
then
42 apply_limiter = .false.
44 apply_limiter = .true.
47 is_initialized = .true.
49 end subroutine mp_tempo_post_init
54 subroutine mp_tempo_post_run(ncol, nlev, dtgrs, tgrs, prslk, dtp, ttendlim, &
60 integer,
intent(in) :: ncol
61 integer,
intent(in) :: nlev
62 real(kind_phys),
dimension(:,:),
intent(in) :: tgrs
63 real(kind_phys),
dimension(:,:),
intent(inout) :: dtgrs
64 real(kind_phys),
dimension(:,:),
intent(in) :: prslk
65 real(kind_phys),
intent(in) :: dtp
66 real(kind_phys),
intent(in) :: ttendlim
67 integer,
intent(in) :: kdt
70 character(len=*),
intent( out) :: errmsg
71 integer,
intent( out) :: errflg
74 real(kind_phys),
dimension(1:ncol,1:nlev) :: mp_tend
85 if (.not.is_initialized)
then
86 write(errmsg, fmt=
'((a))')
'mp_tempo_post_run called before mp_tempo_post_init'
92 if (.not.apply_limiter)
return
102 mp_tend(i,k) = max( -ttendlim, min( ttendlim, mp_tend(i,k) ) )
105 if (mp_tend(i,k)*prslk(i,k) .ne. dtgrs(i,k))
then
106 write(0,
'(a,3i6,3e16.7)')
"mp_tempo_post_run mp_tend limiter: kdt, i, k, t_old, t_new, t_lim:", &
107 & kdt, i, k, tgrs(i,k), tgrs(i,k) + dtp*dtgrs(i,k), tgrs(i,k) + dtp*mp_tend(i,k)*prslk(i,k)
111 dtgrs(i,k) = mp_tend(i,k)*prslk(i,k)
117 write(0,
'(a,i0,a,i0,a,i0)')
"mp_tempo_post_run: ttendlim applied ", events,
"/", nlev*ncol, &
118 &
" times at timestep ", kdt
122 end subroutine mp_tempo_post_run
127 subroutine mp_tempo_post_final(errmsg, errflg)
132 character(len=*),
intent( out) :: errmsg
133 integer,
intent( out) :: errflg
140 if (.not. is_initialized)
return
142 is_initialized = .false.
144 end subroutine mp_tempo_post_final
146end module mp_tempo_post