34 real(
rp),
allocatable :: rkcoef_a(:,:)
35 real(
rp),
allocatable :: rkcoef_b(:)
36 real(
rp),
allocatable :: work0(:,:,:,:)
37 real(
rp),
allocatable :: work(:,:,:,:,:)
38 real(
rp),
allocatable :: buf(:,:,:,:)
40 integer :: register_num
43 integer,
allocatable :: comm_ind(:)
79 rk_stage_num, rk_register_num, rkcoef_a, rkcoef_b, &
80 varname_list, is_type_flux, alloc_rkwork_flag, comm_id_offset )
85 type(
rkinfo),
intent(inout) :: this
86 integer,
intent(in) :: rk_stage_num
87 integer,
intent(in) :: rk_register_num
88 real(
rp),
intent(in) :: rkcoef_a(rk_stage_num,rk_stage_num)
89 real(
rp),
intent(in) :: rkcoef_b(rk_stage_num)
90 character(*),
intent(in) :: varname_list(:)
91 logical,
intent(in),
optional :: is_type_flux
92 logical,
intent(in),
optional :: alloc_rkwork_flag
93 integer,
intent(in),
optional :: comm_id_offset
97 character(H_MID) :: rktag
100 this%var_num =
size(varname_list)
101 this%stage_num = rk_stage_num
102 this%register_num = rk_register_num
103 if (
present(is_type_flux))
then
104 this%flux_flag = is_type_flux
106 this%flux_flag = .false.
110 allocate( this%rkcoef_a(this%stage_num,this%stage_num) )
111 allocate( this%rkcoef_b(this%stage_num) )
112 this%rkcoef_a(:,:) = rkcoef_a(:,:)
113 this%rkcoef_b(:) = rkcoef_b(:)
117 if (
present(alloc_rkwork_flag) )
then
123 allocate( this%buf(
ka,
ia,
ja,this%var_num) )
126 this%buf(:,:,:,:) = undef
131 if ( .not. this%flux_flag )
then
132 allocate( this%comm_ind(this%var_num) )
133 do var_id = 1, this%var_num
134 this%comm_ind(var_id) = var_id
136 if (
present(comm_id_offset)) &
137 this%comm_ind(:) = comm_id_offset + this%comm_ind(:)
139 do var_id = 1, this%var_num
140 write(rktag,
'(a,a)') trim(varname_list(var_id)),
'RK'
141 call comm_vars8_init( trim(rktag), this%buf(:,:,:,var_id), this%comm_ind(var_id) )
151 type(
rkinfo),
intent(inout) :: this
154 if (this%register_num > 0 .and. (.not. this%flux_flag) )
then
156 allocate( this%work0(
ka,
ia,
ja,this%var_num) )
157 allocate( this%work(
ka,
ia,
ja,this%var_num,this%register_num) )
161 this%work0 (:,:,:,:) = undef
162 this%work (:,:,:,:,:) = undef
173 type(
rkinfo),
intent(inout) :: this
176 if (
allocated(this%work) )
then
177 deallocate( this%work0 )
178 deallocate( this%work )
188 type(
rkinfo),
intent(inout) :: this
193 do var_id = 1, this%var_num
194 call comm_vars8( this%buf(:,:,:,var_id), this%comm_ind(var_id) )
204 type(
rkinfo),
intent(inout) :: this
209 do var_id = 1, this%var_num
210 call comm_wait( this%buf(:,:,:,var_id), this%comm_ind(var_id), .false. )
218 type(
rkinfo),
intent(inout) :: this
219 integer,
intent(in) :: nowstage
220 integer,
intent(in) :: io(this%var_num)
221 integer,
intent(in) :: jo(this%var_num)
222 integer,
intent(in) :: ko(this%var_num)
223 real(
rp),
intent(in) :: dt
225 integer :: i, j, k, iv, rks
228 real(
rp) :: a_(this%stage_num)
231 a_(:) = dt * this%RKCoef_a(nowstage+1,:)
235 do iv=1, this%var_num
240 var0 = this%work0(k,i,j,iv)
241 this%work(k,i,j,iv,nowstage) = this%work(k,i,j,iv,nowstage) - var0
242 this%buf(k,i,j,iv) = var0 + a_(nowstage) * this%work(k,i,j,iv,nowstage)
250 if ( abs(this%RKCoef_a(nowstage+1,rks)) < eps ) cycle
251 do iv=1, this%var_num
256 this%buf(k,i,j,iv) = this%buf(k,i,j,iv) + a_(rks) * this%work(k,i,j,iv,rks)
272 type(
rkinfo),
intent(inout) :: this
273 integer,
intent(in) :: io(this%var_num)
274 integer,
intent(in) :: jo(this%var_num)
275 integer,
intent(in) :: ko(this%var_num)
276 real(
rp),
intent(in) :: dt
277 integer,
intent(in) :: vs, ve
278 real(
rp),
intent(inout) :: var(
ka,
ia,
ja,vs:ve)
280 integer :: i, j, k, iv, rks
283 real(
rp) :: b_(this%stage_num)
286 b_(:) = dt * this%rkcoef_b(:)
296 var0 = this%work0(k,i,j,iv)
297 var(k,i,j,iv) = var0 + b_(rks) * ( this%work(k,i,j,iv,rks) - var0 )
302 do rks=1, this%stage_num-1
308 var(k,i,j,iv) = var(k,i,j,iv) + b_(rks) * this%work(k,i,j,iv,rks)
322 type(
rkinfo),
intent(inout) :: this
323 integer,
intent(in) :: nowstage
324 integer,
intent(in) :: va_
325 integer,
intent(in) :: io, jo, ko
326 real(
rp),
intent(inout) :: flux(
ka,
ia,
ja,va_)
328 integer :: i, j, k, iv
331 if ( nowstage == 1)
then
337 flux(k,i,j,iv) = this%rkcoef_b(nowstage) * this%buf(k,i,j,iv)
348 flux(k,i,j,iv) = flux(k,i,j,iv) + this%rkcoef_b(nowstage) * this%buf(k,i,j,iv)
358 end module scale_atmos_dyn_tinteg_rkcommon