FE-Project
Loading...
Searching...
No Matches
scale_timeint_rk.F90
Go to the documentation of this file.
1!-------------------------------------------------------------------------------
2! Warning: This file was generated from common/scale_timeint_rk.F90.erb.
3! Do not edit this file.
4!-------------------------------------------------------------------------------
5!-------------------------------------------------------------------------------
13#include "scaleFElib.h"
15 !-----------------------------------------------------------------------------
16 !
17 !++ Used modules
18 !
19 use scale_precision
20 use scale_io
21 use scale_prc
22 use scale_prof
23 use scale_prc
24
25 !-----------------------------------------------------------------------------
26 implicit none
27 private
28
29 !-----------------------------------------------------------------------------
30 !
31 !++ Public type, procedures
32 !
33 type, public :: timeint_rk
34 real(RP), private :: dt
35
36 integer, private :: rk_scheme_id_ex
37 integer, private :: rk_scheme_id_im
38
39 integer, public :: var_num
40 integer, private, allocatable :: size_each_var(:)
41 integer, public :: nstage
42 integer, public :: var_buf_size
43 integer, public :: tend_buf_size
44
45 ! For Butcher representation (explicit part)
46 real(rp), public, allocatable :: coef_a_ex(:,:)
47 real(rp), public, allocatable :: coef_b_ex(:)
48 real(rp), public, allocatable :: coef_c_ex(:)
49
50 ! For Shu-Osher representation (explicit part)
51 real(rp), public, allocatable :: coef_sig_ex(:,:)
52 real(rp), public, allocatable :: coef_gam_ex(:,:)
53
54 ! For Butcher representation (implicit part)
55 real(rp), public, allocatable :: coef_a_im(:,:)
56 real(rp), public, allocatable :: coef_b_im(:)
57 real(rp), public, allocatable :: coef_c_im(:)
58
59 integer, allocatable :: tend_buf_indmap(:)
60 real(rp), public, allocatable :: var_buf1d_ex(:,:,:)
61 real(rp), public, allocatable :: tend_buf1d_ex(:,:,:)
62 real(rp), public, allocatable :: tend_buf1d_im(:,:,:)
63 real(rp), public, allocatable :: var0_1d(:,:)
64 real(rp), private, allocatable :: vartmp_1d(:,:)
65 real(rp), public, allocatable :: var_buf2d_ex(:,:,:,:)
66 real(rp), public, allocatable :: tend_buf2d_ex(:,:,:,:)
67 real(rp), public, allocatable :: tend_buf2d_im(:,:,:,:)
68 real(rp), public, allocatable :: var0_2d(:,:,:)
69 real(rp), private, allocatable :: vartmp_2d(:,:,:)
70 real(rp), public, allocatable :: var_buf3d_ex(:,:,:,:,:)
71 real(rp), public, allocatable :: tend_buf3d_ex(:,:,:,:,:)
72 real(rp), public, allocatable :: tend_buf3d_im(:,:,:,:,:)
73 real(rp), public, allocatable :: var0_3d(:,:,:,:)
74 real(rp), private, allocatable :: vartmp_3d(:,:,:,:)
75
76 logical, private :: low_storage_flag
77 logical, public :: imex_flag
78 integer, public :: ndim
79 contains
80 procedure, public :: init => timeint_rk_init
81 procedure, public :: final => timeint_rk_final
82 procedure, public :: get_implicit_diagfac => timeint_rk_get_implicit_diagfac
83 procedure, public :: get_deltime => timeint_rk_get_deltime
84 procedure, public :: advance1d => timeint_rk_advance1d
85 procedure, public :: advance_trcvar_1d => timeint_rk_advance_trcvar1d
86 procedure, public :: storevar0_1d => timeint_rk_store_var0_1d
87 procedure, public :: storeimplicit1d => timeint_rk_storeimpl1d
88 procedure, public :: advance2d => timeint_rk_advance2d
89 procedure, public :: advance_trcvar_2d => timeint_rk_advance_trcvar2d
90 procedure, public :: storevar0_2d => timeint_rk_store_var0_2d
91 procedure, public :: storeimplicit2d => timeint_rk_storeimpl2d
92 procedure, public :: advance3d => timeint_rk_advance3d
93 procedure, public :: advance_trcvar_3d => timeint_rk_advance_trcvar3d
94 procedure, public :: storevar0_3d => timeint_rk_store_var0_3d
95 procedure, public :: storeimplicit3d => timeint_rk_storeimpl3d
96 generic, public :: advance => advance1d, advance2d, advance3d
97 generic, public :: advance_trcvar => advance_trcvar_1d, advance_trcvar_2d, advance_trcvar_3d
98 generic, public :: storevar0 => storevar0_1d, storevar0_2d, storevar0_3d
99 generic, public :: storeimplicit => storeimplicit1d, storeimplicit2d, storeimplicit3d
100 end type timeint_rk
101
102 !-----------------------------------------------------------------------------
103 !
104 !++ Public parameters & variables
105 !
106 !-----------------------------------------------------------------------------
107 !
108 !++ Private procedures
109 !
110 !-------------------
111
112contains
113
114!----------------
115
116 subroutine timeint_rk_init( this, &
117 rk_scheme_name, dt, var_num, ndim, size_each_var )
118
122 implicit none
123 class(timeint_rk), intent(inout) :: this
124 character(*), intent(in) :: rk_scheme_name
125 real(RP), intent(in) :: dt
126 integer, intent(in) :: var_num
127 integer, intent(in) :: ndim
128 integer, intent(in) :: size_each_var(ndim)
129 !----------------------------------------
130
131 this%dt = dt
132 this%ndim = ndim
133 this%var_num = 1
134 allocate( this%size_each_var(ndim) )
135 this%size_each_var(:) = size_each_var(:)
136
137 call timeint_rk_butcher_tab_get_info( rk_scheme_name, & ! (in)
138 this%nstage, this%tend_buf_size, & ! (out)
139 this%low_storage_flag, this%imex_flag ) ! (out)
140
141 allocate ( this%coef_a_ex(this%nstage,this%nstage), this%coef_b_ex(this%nstage), this%coef_c_ex(this%nstage) )
142 allocate ( this%coef_sig_ex(this%nstage+1,this%nstage), this%coef_gam_ex(this%nstage+1,this%nstage) )
143! if (this%imex_flag) then
144 allocate ( this%coef_a_im(this%nstage,this%nstage), this%coef_b_im(this%nstage), this%coef_c_im(this%nstage) )
145! end if
146
147 select case(this%ndim)
148 case(1)
149 allocate( this%tend_buf1D_ex(size_each_var(1), var_num, this%tend_buf_size) )
150 if ( this%imex_flag ) then
151 allocate( this%tend_buf1D_im(size_each_var(1), var_num, this%tend_buf_size) )
152 end if
153 allocate( this%var0_1D(size_each_var(1), var_num) )
154 allocate( this%varTmp_1D(size_each_var(1), var_num) )
155 case(2)
156 allocate( this%tend_buf2D_ex(size_each_var(1),size_each_var(2), var_num, this%tend_buf_size) )
157 if ( this%imex_flag ) then
158 allocate( this%tend_buf2D_im(size_each_var(1),size_each_var(2), var_num, this%tend_buf_size) )
159 end if
160 allocate( this%var0_2D(size_each_var(1),size_each_var(2), var_num) )
161 allocate( this%varTmp_2D(size_each_var(1),size_each_var(2), var_num) )
162 case(3)
163 allocate( this%tend_buf3D_ex(size_each_var(1),size_each_var(2),size_each_var(3), var_num, this%tend_buf_size) )
164 if ( this%imex_flag ) then
165 allocate( this%tend_buf3D_im(size_each_var(1),size_each_var(2),size_each_var(3), var_num, this%tend_buf_size) )
166 end if
167 allocate( this%var0_3D(size_each_var(1),size_each_var(2),size_each_var(3), var_num) )
168 allocate( this%varTmp_3D(size_each_var(1),size_each_var(2),size_each_var(3), var_num) )
169 end select
170 allocate( this%tend_buf_indmap(this%nstage) )
171
173 rk_scheme_name, this%nstage, this%imex_flag, & ! (in)
174 this%coef_a_ex, this%coef_b_ex, this%coef_c_ex, & ! (out)
175 this%coef_sig_ex, this%coef_gam_ex, & ! (out)
176 this%coef_a_im, this%coef_b_im, this%coef_c_im, & ! (out)
177 this%tend_buf_indmap ) ! (out)
178
179 return
180 end subroutine timeint_rk_init
181
182 subroutine timeint_rk_final( this )
183 implicit none
184 class(timeint_rk), intent(inout) :: this
185 !----------------------------------------
186
187 deallocate( this%coef_a_ex, this%coef_b_ex, this%coef_c_ex )
188 deallocate( this%coef_sig_ex, this%coef_gam_ex )
189! if (this%imex_flag) then
190 deallocate( this%coef_a_im, this%coef_b_im, this%coef_c_im )
191! end if
192
193 deallocate( this%size_each_var, this%tend_buf_indmap )
194
195 select case(this%ndim)
196 case(1)
197 deallocate( this%var0_1d )
198 deallocate( this%tend_buf1D_ex )
199 if (this%imex_flag) deallocate( this%tend_buf1D_im )
200 deallocate( this%varTmp_1d )
201 case(2)
202 deallocate( this%var0_2d )
203 deallocate( this%tend_buf2D_ex )
204 if (this%imex_flag) deallocate( this%tend_buf2D_im )
205 deallocate( this%varTmp_2d )
206 case(3)
207 deallocate( this%var0_3d )
208 deallocate( this%tend_buf3D_ex )
209 if (this%imex_flag) deallocate( this%tend_buf3D_im )
210 deallocate( this%varTmp_3d )
211 end select
212
213 return
214 end subroutine timeint_rk_final
215
216 elemental function timeint_rk_get_deltime( this ) result(dt)
217 implicit none
218 class(timeint_rk), intent(in) :: this
219 real(RP) :: dt
220 !-----------------------------------------------------
221
222 dt = this%dt
223
224 return
225 end function timeint_rk_get_deltime
226
227 elemental function timeint_rk_get_implicit_diagfac( this, nowstage ) result(fac)
228 implicit none
229 class(timeint_rk), intent(in) :: this
230 integer, intent(in) :: nowstage
231 real(RP) :: fac
232 !-----------------------------------------------------
233
234 fac = this%coef_a_im(nowstage,nowstage) * this%dt
235
236 return
237 end function timeint_rk_get_implicit_diagfac
238 !----------------
239
240
241 subroutine timeint_rk_advance1d( this, nowstage, q, varID, is, ie )
242 implicit none
243 class(timeint_rk), intent(inout) :: this
244 integer, intent(in) :: nowstage
245 real(RP), intent(inout) :: q(:)
246 integer, intent(in) :: varID
247 integer, intent(in) :: is, ie
248 !----------------------------------------
249
250 if (this%low_storage_flag) then
251 call rk_advance_low_storage1d( this, nowstage, q, varid, is, ie )
252 else
253 call rk_advance_general1d( this, nowstage, q, varid, is, ie )
254 end if
255
256 return
257 end subroutine timeint_rk_advance1d
258
259 subroutine timeint_rk_advance_trcvar1d( this, nowstage, q, varID, is, ie , &
260 DENS, DENS0, DENS_hyd )
261 implicit none
262 class(timeint_rk), intent(inout) :: this
263 integer, intent(in) :: nowstage
264 real(RP), intent(inout) :: q(:)
265 integer, intent(in) :: varID
266 integer, intent(in) :: is, ie
267 real(RP), intent(in) :: DENS (:)
268 real(RP), intent(in) :: DENS0(:)
269 real(RP), intent(in) :: DENS_hyd(:)
270 !----------------------------------------
271
272 if ( this%imex_flag ) then
273 if ( prc_ismaster ) write(*,*) "timeint_rk_advence_trcvar: IMEX is not supported. Check!"
274 call prc_abort
275 end if
276
277 if (this%low_storage_flag) then
278 call rk_advance_trcvar_low_storage1d( this, nowstage, q, varid, is, ie , &
279 dens, dens0, dens_hyd )
280 else
281 call rk_advance_trcvar_general1d( this, nowstage, q, varid, is, ie , &
282 dens, dens0, dens_hyd )
283 end if
284
285 return
286 end subroutine timeint_rk_advance_trcvar1d
287
288 subroutine timeint_rk_store_var0_1d( this, q, varID, is, ie )
289 implicit none
290 class(timeint_rk), intent(inout) :: this
291 real(RP), intent(inout) :: q(:)
292 integer, intent(in) :: varID
293 integer, intent(in) :: is, ie
294
295 integer :: i
296 !----------------------------------------
297
298 !$omp parallel private(i)
299 !$omp do
300 do i=is, ie
301 this%var0_1D(i,varid) = q(i)
302 end do
303 !$omp end parallel
304
305 return
306 end subroutine timeint_rk_store_var0_1d
307
308 subroutine timeint_rk_storeimpl1d( this, nowstage, q, varID, is, ie )
309 implicit none
310 class(timeint_rk), intent(inout) :: this
311 integer, intent(in) :: nowstage
312 real(RP), intent(inout) :: q(:)
313 integer, intent(in) :: varID
314 integer, intent(in) :: is, ie
315
316 !----------------------------------------
317
318 call rk_storeimpl_general1d( this, nowstage, q, varid, is, ie )
319
320 return
321 end subroutine timeint_rk_storeimpl1d
322
323 subroutine timeint_rk_advance2d( this, nowstage, q, varID, is, ie ,js, je )
324 implicit none
325 class(timeint_rk), intent(inout) :: this
326 integer, intent(in) :: nowstage
327 real(RP), intent(inout) :: q(:,:)
328 integer, intent(in) :: varID
329 integer, intent(in) :: is, ie ,js, je
330 !----------------------------------------
331
332 if (this%low_storage_flag) then
333 call rk_advance_low_storage2d( this, nowstage, q, varid, is, ie ,js, je )
334 else
335 call rk_advance_general2d( this, nowstage, q, varid, is, ie ,js, je )
336 end if
337
338 return
339 end subroutine timeint_rk_advance2d
340
341 subroutine timeint_rk_advance_trcvar2d( this, nowstage, q, varID, is, ie ,js, je , &
342 DENS, DENS0, DENS_hyd )
343 implicit none
344 class(timeint_rk), intent(inout) :: this
345 integer, intent(in) :: nowstage
346 real(RP), intent(inout) :: q(:,:)
347 integer, intent(in) :: varID
348 integer, intent(in) :: is, ie ,js, je
349 real(RP), intent(in) :: DENS (:,:)
350 real(RP), intent(in) :: DENS0(:,:)
351 real(RP), intent(in) :: DENS_hyd(:,:)
352 !----------------------------------------
353
354 if ( this%imex_flag ) then
355 if ( prc_ismaster ) write(*,*) "timeint_rk_advence_trcvar: IMEX is not supported. Check!"
356 call prc_abort
357 end if
358
359 if (this%low_storage_flag) then
360 call rk_advance_trcvar_low_storage2d( this, nowstage, q, varid, is, ie ,js, je , &
361 dens, dens0, dens_hyd )
362 else
363 call rk_advance_trcvar_general2d( this, nowstage, q, varid, is, ie ,js, je , &
364 dens, dens0, dens_hyd )
365 end if
366
367 return
368 end subroutine timeint_rk_advance_trcvar2d
369
370 subroutine timeint_rk_store_var0_2d( this, q, varID, is, ie ,js, je )
371 implicit none
372 class(timeint_rk), intent(inout) :: this
373 real(RP), intent(inout) :: q(:,:)
374 integer, intent(in) :: varID
375 integer, intent(in) :: is, ie ,js, je
376
377 integer :: i,j
378 !----------------------------------------
379
380 !$omp parallel private(i,j)
381 !$omp do
382 do j=js, je
383 do i=is, ie
384 this%var0_2D(i,j,varid) = q(i,j)
385 end do
386 end do
387 !$omp end parallel
388
389 return
390 end subroutine timeint_rk_store_var0_2d
391
392 subroutine timeint_rk_storeimpl2d( this, nowstage, q, varID, is, ie ,js, je )
393 implicit none
394 class(timeint_rk), intent(inout) :: this
395 integer, intent(in) :: nowstage
396 real(RP), intent(inout) :: q(:,:)
397 integer, intent(in) :: varID
398 integer, intent(in) :: is, ie ,js, je
399
400 !----------------------------------------
401
402 call rk_storeimpl_general2d( this, nowstage, q, varid, is, ie ,js, je )
403
404 return
405 end subroutine timeint_rk_storeimpl2d
406
407 subroutine timeint_rk_advance3d( this, nowstage, q, varID, is, ie ,js, je ,ks, ke )
408 implicit none
409 class(timeint_rk), intent(inout) :: this
410 integer, intent(in) :: nowstage
411 real(RP), intent(inout) :: q(:,:,:)
412 integer, intent(in) :: varID
413 integer, intent(in) :: is, ie ,js, je ,ks, ke
414 !----------------------------------------
415
416 if (this%low_storage_flag) then
417 call rk_advance_low_storage3d( this, nowstage, q, varid, is, ie ,js, je ,ks, ke )
418 else
419 call rk_advance_general3d( this, nowstage, q, varid, is, ie ,js, je ,ks, ke )
420 end if
421
422 return
423 end subroutine timeint_rk_advance3d
424
425 subroutine timeint_rk_advance_trcvar3d( this, nowstage, q, varID, is, ie ,js, je ,ks, ke , &
426 DENS, DENS0, DENS_hyd )
427 implicit none
428 class(timeint_rk), intent(inout) :: this
429 integer, intent(in) :: nowstage
430 real(RP), intent(inout) :: q(:,:,:)
431 integer, intent(in) :: varID
432 integer, intent(in) :: is, ie ,js, je ,ks, ke
433 real(RP), intent(in) :: DENS (:,:,:)
434 real(RP), intent(in) :: DENS0(:,:,:)
435 real(RP), intent(in) :: DENS_hyd(:,:,:)
436 !----------------------------------------
437
438 if ( this%imex_flag ) then
439 if ( prc_ismaster ) write(*,*) "timeint_rk_advence_trcvar: IMEX is not supported. Check!"
440 call prc_abort
441 end if
442
443 if (this%low_storage_flag) then
444 call rk_advance_trcvar_low_storage3d( this, nowstage, q, varid, is, ie ,js, je ,ks, ke , &
445 dens, dens0, dens_hyd )
446 else
447 call rk_advance_trcvar_general3d( this, nowstage, q, varid, is, ie ,js, je ,ks, ke , &
448 dens, dens0, dens_hyd )
449 end if
450
451 return
452 end subroutine timeint_rk_advance_trcvar3d
453
454 subroutine timeint_rk_store_var0_3d( this, q, varID, is, ie ,js, je ,ks, ke )
455 implicit none
456 class(timeint_rk), intent(inout) :: this
457 real(RP), intent(inout) :: q(:,:,:)
458 integer, intent(in) :: varID
459 integer, intent(in) :: is, ie ,js, je ,ks, ke
460
461 integer :: i,j,k
462 !----------------------------------------
463
464 !$omp parallel private(i,j,k)
465 !$omp do collapse(2)
466 do k=ks, ke
467 do j=js, je
468 do i=is, ie
469 this%var0_3D(i,j,k,varid) = q(i,j,k)
470 end do
471 end do
472 end do
473 !$omp end parallel
474
475 return
476 end subroutine timeint_rk_store_var0_3d
477
478 subroutine timeint_rk_storeimpl3d( this, nowstage, q, varID, is, ie ,js, je ,ks, ke )
479 implicit none
480 class(timeint_rk), intent(inout) :: this
481 integer, intent(in) :: nowstage
482 real(RP), intent(inout) :: q(:,:,:)
483 integer, intent(in) :: varID
484 integer, intent(in) :: is, ie ,js, je ,ks, ke
485
486 !----------------------------------------
487
488 call rk_storeimpl_general3d( this, nowstage, q, varid, is, ie ,js, je ,ks, ke )
489
490 return
491 end subroutine timeint_rk_storeimpl3d
492
493!-------------------
494
495
496
497!OCL SERIAL
498 subroutine rk_advance_low_storage1d( this, nowstage, q, varID, is, ie )
499 use scale_const, only: &
500 eps => const_eps
501 implicit none
502 class(timeint_rk), intent(inout) :: this
503 integer, intent(in) :: nowstage
504 real(RP), intent(inout) :: q(:)
505 integer, intent(in) :: varID
506 integer, intent(in) :: is, ie
507
508 integer :: i
509 real(RP) :: sig_ss
510 real(RP) :: gam_ss
511 real(RP) :: one_Minus_sig_ss
512 real(RP) :: sig_Ns
513 real(RP) :: gam_Ns
514
515 !----------------------------------------
516
517 call prof_rapstart( 'rk_advance_low_storage1D', 3)
518
519 sig_ss = this%coef_sig_ex(nowstage+1,nowstage)
520 sig_ns = this%coef_sig_ex(this%nstage+1,nowstage)
521 one_minus_sig_ss = 1.0_rp - sig_ss
522 gam_ss = this%dt * this%coef_gam_ex(nowstage+1,nowstage)
523 gam_ns = this%dt * this%coef_gam_ex(this%nstage+1,nowstage)
524
525 if ( nowstage == this%nstage ) then
526 !$omp parallel private(i)
527 !$omp do
528 do i=is, ie
529 q(i) = this%varTmp_1d(i,varid) &
530 + sig_ss * q(i) + gam_ss * this%tend_buf1D_ex(i,varid,1)
531 end do
532 !$omp end parallel
533 call prof_rapend( 'rk_advance_low_storage1D', 3)
534
535 return
536 end if
537
538 !$omp parallel private(i)
539 if (nowstage == 1) then
540 !$omp do
541 do i=is, ie
542 this%var0_1D(i,varid) = q(i)
543 this%varTmp_1D(i,varid) = 0.0_rp
544 end do
545 end if
546
547 if ( abs(sig_ns) > eps .or. abs(gam_ns) > eps ) then
548 !$omp do
549 do i=is, ie
550 this%varTmp_1d(i,varid) = this%varTmp_1d(i,varid) &
551 + sig_ns * q(i) + gam_ns * this%tend_buf1D_ex(i,varid,1)
552 end do
553 end if
554
555 !$omp do
556 do i=is, ie
557 q(i) = one_minus_sig_ss * this%var0_1d(i,varid) &
558 + sig_ss * q(i) + gam_ss * this%tend_buf1D_ex(i,varid,1)
559 end do
560
561 !$omp end parallel
562
563 call prof_rapend( 'rk_advance_low_storage1D', 3)
564
565 return
566 end subroutine rk_advance_low_storage1d
567
568 !OCL SERIAL
569 subroutine rk_advance_trcvar_low_storage1d( this, nowstage, q, varID, is, ie , &
570 DDENS, DDENS0, DENS_hyd )
571 use scale_const, only: &
572 eps => const_eps
573 implicit none
574 class(timeint_rk), intent(inout) :: this
575 integer, intent(in) :: nowstage
576 real(RP), intent(inout) :: q(:)
577 integer, intent(in) :: varID
578 integer, intent(in) :: is, ie
579 real(RP), intent(in) :: DDENS (:)
580 real(RP), intent(in) :: DDENS0(:)
581 real(RP), intent(in) :: DENS_hyd(:)
582
583 integer :: i
584 real(RP) :: sig_ss
585 real(RP) :: gam_ss
586 real(RP) :: one_Minus_sig_ss
587 real(RP) :: sig_Ns
588 real(RP) :: gam_Ns
589 real(RP) :: c_ssm1
590 real(RP) :: c_ss
591
592 real(RP) :: dens_ssm1
593 real(RP) :: dens_ss
594
595 !----------------------------------------
596
597 call prof_rapstart( 'rk_advance_trcvar_low_storage1D', 3)
598
599 sig_ss = this%coef_sig_ex(nowstage+1,nowstage)
600 sig_ns = this%coef_sig_ex(this%nstage+1,nowstage)
601 one_minus_sig_ss = 1.0_rp - sig_ss
602 gam_ss = this%dt * this%coef_gam_ex(nowstage+1,nowstage)
603 gam_ns = this%dt * this%coef_gam_ex(this%nstage+1,nowstage)
604 c_ssm1 = this%coef_c_ex(nowstage)
605
606 if ( nowstage == this%nstage ) then
607 !$omp parallel private(i)
608 !$omp do
609 do i=is, ie
610 dens_ssm1 = dens_hyd(i) + ddens0(i) + c_ssm1 * ( ddens(i) - ddens0(i) )
611 q(i) = ( this%varTmp_1d(i,varid) &
612 + sig_ss * q(i) * dens_ssm1 + gam_ss * this%tend_buf1D_ex(i,varid,1) ) &
613 / ( dens_hyd(i) + ddens(i) )
614 end do
615 !$omp end parallel
616 call prof_rapend( 'rk_advance_trcvar_low_storage1D', 3)
617
618 return
619 end if
620
621 c_ss = this%coef_c_ex(nowstage+1)
622
623 !$omp parallel private(i,dens_ss,dens_ssm1)
624 if (nowstage == 1) then
625 !$omp do
626 do i=is, ie
627 this%var0_1D(i,varid) = q(i) * ( dens_hyd(i) + ddens0(i) )
628 this%varTmp_1D(i,varid) = 0.0_rp
629 end do
630 end if
631
632 if ( abs(sig_ns) > eps .or. abs(gam_ns) > eps ) then
633 !$omp do
634 do i=is, ie
635 dens_ssm1 = dens_hyd(i) + ddens0(i) + c_ssm1 * ( ddens(i) - ddens0(i) )
636 this%varTmp_1d(i,varid) = this%varTmp_1d(i,varid) &
637 + sig_ns * q(i) * dens_ssm1 + gam_ns * this%tend_buf1D_ex(i,varid,1)
638 end do
639 end if
640
641 !$omp do
642 do i=is, ie
643 dens_ssm1 = dens_hyd(i) + ddens0(i) + c_ssm1 * ( ddens(i) - ddens0(i) )
644 dens_ss = dens_hyd(i) + ddens0(i) + c_ss * ( ddens(i) - ddens0(i) )
645
646 q(i) = ( one_minus_sig_ss * this%var0_1d(i,varid) &
647 + sig_ss * q(i) * dens_ssm1 + gam_ss * this%tend_buf1D_ex(i,varid,1) ) &
648 / dens_ss
649 end do
650
651 !$omp end parallel
652
653 call prof_rapend( 'rk_advance_trcvar_low_storage1D', 3)
654
655 return
656 end subroutine rk_advance_trcvar_low_storage1d
657
658
659
660!OCL SERIAL
661 subroutine rk_advance_low_storage2d( this, nowstage, q, varID, is, ie ,js, je )
662 use scale_const, only: &
663 eps => const_eps
664 implicit none
665 class(timeint_rk), intent(inout) :: this
666 integer, intent(in) :: nowstage
667 real(RP), intent(inout) :: q(:,:)
668 integer, intent(in) :: varID
669 integer, intent(in) :: is, ie ,js, je
670
671 integer :: i,j
672 real(RP) :: sig_ss
673 real(RP) :: gam_ss
674 real(RP) :: one_Minus_sig_ss
675 real(RP) :: sig_Ns
676 real(RP) :: gam_Ns
677
678 !----------------------------------------
679
680 call prof_rapstart( 'rk_advance_low_storage2D', 3)
681
682 sig_ss = this%coef_sig_ex(nowstage+1,nowstage)
683 sig_ns = this%coef_sig_ex(this%nstage+1,nowstage)
684 one_minus_sig_ss = 1.0_rp - sig_ss
685 gam_ss = this%dt * this%coef_gam_ex(nowstage+1,nowstage)
686 gam_ns = this%dt * this%coef_gam_ex(this%nstage+1,nowstage)
687
688 if ( nowstage == this%nstage ) then
689 !$omp parallel private(i,j)
690 !$omp do
691 do j=js, je
692 do i=is, ie
693 q(i,j) = this%varTmp_2d(i,j,varid) &
694 + sig_ss * q(i,j) + gam_ss * this%tend_buf2D_ex(i,j,varid,1)
695 end do
696 end do
697 !$omp end parallel
698 call prof_rapend( 'rk_advance_low_storage2D', 3)
699
700 return
701 end if
702
703 !$omp parallel private(i,j)
704 if (nowstage == 1) then
705 !$omp do
706 do j=js, je
707 do i=is, ie
708 this%var0_2D(i,j,varid) = q(i,j)
709 this%varTmp_2D(i,j,varid) = 0.0_rp
710 end do
711 end do
712 end if
713
714 if ( abs(sig_ns) > eps .or. abs(gam_ns) > eps ) then
715 !$omp do
716 do j=js, je
717 do i=is, ie
718 this%varTmp_2d(i,j,varid) = this%varTmp_2d(i,j,varid) &
719 + sig_ns * q(i,j) + gam_ns * this%tend_buf2D_ex(i,j,varid,1)
720 end do
721 end do
722 end if
723
724 !$omp do
725 do j=js, je
726 do i=is, ie
727 q(i,j) = one_minus_sig_ss * this%var0_2d(i,j,varid) &
728 + sig_ss * q(i,j) + gam_ss * this%tend_buf2D_ex(i,j,varid,1)
729 end do
730 end do
731
732 !$omp end parallel
733
734 call prof_rapend( 'rk_advance_low_storage2D', 3)
735
736 return
737 end subroutine rk_advance_low_storage2d
738
739 !OCL SERIAL
740 subroutine rk_advance_trcvar_low_storage2d( this, nowstage, q, varID, is, ie ,js, je , &
741 DDENS, DDENS0, DENS_hyd )
742 use scale_const, only: &
743 eps => const_eps
744 implicit none
745 class(timeint_rk), intent(inout) :: this
746 integer, intent(in) :: nowstage
747 real(RP), intent(inout) :: q(:,:)
748 integer, intent(in) :: varID
749 integer, intent(in) :: is, ie ,js, je
750 real(RP), intent(in) :: DDENS (:,:)
751 real(RP), intent(in) :: DDENS0(:,:)
752 real(RP), intent(in) :: DENS_hyd(:,:)
753
754 integer :: i,j
755 real(RP) :: sig_ss
756 real(RP) :: gam_ss
757 real(RP) :: one_Minus_sig_ss
758 real(RP) :: sig_Ns
759 real(RP) :: gam_Ns
760 real(RP) :: c_ssm1
761 real(RP) :: c_ss
762
763 real(RP) :: dens_ssm1
764 real(RP) :: dens_ss
765
766 !----------------------------------------
767
768 call prof_rapstart( 'rk_advance_trcvar_low_storage2D', 3)
769
770 sig_ss = this%coef_sig_ex(nowstage+1,nowstage)
771 sig_ns = this%coef_sig_ex(this%nstage+1,nowstage)
772 one_minus_sig_ss = 1.0_rp - sig_ss
773 gam_ss = this%dt * this%coef_gam_ex(nowstage+1,nowstage)
774 gam_ns = this%dt * this%coef_gam_ex(this%nstage+1,nowstage)
775 c_ssm1 = this%coef_c_ex(nowstage)
776
777 if ( nowstage == this%nstage ) then
778 !$omp parallel private(i,j)
779 !$omp do
780 do j=js, je
781 do i=is, ie
782 dens_ssm1 = dens_hyd(i,j) + ddens0(i,j) + c_ssm1 * ( ddens(i,j) - ddens0(i,j) )
783 q(i,j) = ( this%varTmp_2d(i,j,varid) &
784 + sig_ss * q(i,j) * dens_ssm1 + gam_ss * this%tend_buf2D_ex(i,j,varid,1) ) &
785 / ( dens_hyd(i,j) + ddens(i,j) )
786 end do
787 end do
788 !$omp end parallel
789 call prof_rapend( 'rk_advance_trcvar_low_storage2D', 3)
790
791 return
792 end if
793
794 c_ss = this%coef_c_ex(nowstage+1)
795
796 !$omp parallel private(i,j,dens_ss,dens_ssm1)
797 if (nowstage == 1) then
798 !$omp do
799 do j=js, je
800 do i=is, ie
801 this%var0_2D(i,j,varid) = q(i,j) * ( dens_hyd(i,j) + ddens0(i,j) )
802 this%varTmp_2D(i,j,varid) = 0.0_rp
803 end do
804 end do
805 end if
806
807 if ( abs(sig_ns) > eps .or. abs(gam_ns) > eps ) then
808 !$omp do
809 do j=js, je
810 do i=is, ie
811 dens_ssm1 = dens_hyd(i,j) + ddens0(i,j) + c_ssm1 * ( ddens(i,j) - ddens0(i,j) )
812 this%varTmp_2d(i,j,varid) = this%varTmp_2d(i,j,varid) &
813 + sig_ns * q(i,j) * dens_ssm1 + gam_ns * this%tend_buf2D_ex(i,j,varid,1)
814 end do
815 end do
816 end if
817
818 !$omp do
819 do j=js, je
820 do i=is, ie
821 dens_ssm1 = dens_hyd(i,j) + ddens0(i,j) + c_ssm1 * ( ddens(i,j) - ddens0(i,j) )
822 dens_ss = dens_hyd(i,j) + ddens0(i,j) + c_ss * ( ddens(i,j) - ddens0(i,j) )
823
824 q(i,j) = ( one_minus_sig_ss * this%var0_2d(i,j,varid) &
825 + sig_ss * q(i,j) * dens_ssm1 + gam_ss * this%tend_buf2D_ex(i,j,varid,1) ) &
826 / dens_ss
827 end do
828 end do
829
830 !$omp end parallel
831
832 call prof_rapend( 'rk_advance_trcvar_low_storage2D', 3)
833
834 return
835 end subroutine rk_advance_trcvar_low_storage2d
836
837
838
839!OCL SERIAL
840 subroutine rk_advance_low_storage3d( this, nowstage, q, varID, is, ie ,js, je ,ks, ke )
841 use scale_const, only: &
842 eps => const_eps
843 implicit none
844 class(timeint_rk), intent(inout) :: this
845 integer, intent(in) :: nowstage
846 real(RP), intent(inout) :: q(:,:,:)
847 integer, intent(in) :: varID
848 integer, intent(in) :: is, ie ,js, je ,ks, ke
849
850 integer :: i,j,k
851 real(RP) :: sig_ss
852 real(RP) :: gam_ss
853 real(RP) :: one_Minus_sig_ss
854 real(RP) :: sig_Ns
855 real(RP) :: gam_Ns
856
857 !----------------------------------------
858
859 call prof_rapstart( 'rk_advance_low_storage3D', 3)
860
861 sig_ss = this%coef_sig_ex(nowstage+1,nowstage)
862 sig_ns = this%coef_sig_ex(this%nstage+1,nowstage)
863 one_minus_sig_ss = 1.0_rp - sig_ss
864 gam_ss = this%dt * this%coef_gam_ex(nowstage+1,nowstage)
865 gam_ns = this%dt * this%coef_gam_ex(this%nstage+1,nowstage)
866
867 if ( nowstage == this%nstage ) then
868 !$omp parallel private(i,j,k)
869 !$omp do collapse(2)
870 do k=ks, ke
871 do j=js, je
872 do i=is, ie
873 q(i,j,k) = this%varTmp_3d(i,j,k,varid) &
874 + sig_ss * q(i,j,k) + gam_ss * this%tend_buf3D_ex(i,j,k,varid,1)
875 end do
876 end do
877 end do
878 !$omp end parallel
879 call prof_rapend( 'rk_advance_low_storage3D', 3)
880
881 return
882 end if
883
884 !$omp parallel private(i,j,k)
885 if (nowstage == 1) then
886 !$omp do collapse(2)
887 do k=ks, ke
888 do j=js, je
889 do i=is, ie
890 this%var0_3D(i,j,k,varid) = q(i,j,k)
891 this%varTmp_3D(i,j,k,varid) = 0.0_rp
892 end do
893 end do
894 end do
895 end if
896
897 if ( abs(sig_ns) > eps .or. abs(gam_ns) > eps ) then
898 !$omp do collapse(2)
899 do k=ks, ke
900 do j=js, je
901 do i=is, ie
902 this%varTmp_3d(i,j,k,varid) = this%varTmp_3d(i,j,k,varid) &
903 + sig_ns * q(i,j,k) + gam_ns * this%tend_buf3D_ex(i,j,k,varid,1)
904 end do
905 end do
906 end do
907 end if
908
909 !$omp do collapse(2)
910 do k=ks, ke
911 do j=js, je
912 do i=is, ie
913 q(i,j,k) = one_minus_sig_ss * this%var0_3d(i,j,k,varid) &
914 + sig_ss * q(i,j,k) + gam_ss * this%tend_buf3D_ex(i,j,k,varid,1)
915 end do
916 end do
917 end do
918
919 !$omp end parallel
920
921 call prof_rapend( 'rk_advance_low_storage3D', 3)
922
923 return
924 end subroutine rk_advance_low_storage3d
925
926 !OCL SERIAL
927 subroutine rk_advance_trcvar_low_storage3d( this, nowstage, q, varID, is, ie ,js, je ,ks, ke , &
928 DDENS, DDENS0, DENS_hyd )
929 use scale_const, only: &
930 eps => const_eps
931 implicit none
932 class(timeint_rk), intent(inout) :: this
933 integer, intent(in) :: nowstage
934 real(RP), intent(inout) :: q(:,:,:)
935 integer, intent(in) :: varID
936 integer, intent(in) :: is, ie ,js, je ,ks, ke
937 real(RP), intent(in) :: DDENS (:,:,:)
938 real(RP), intent(in) :: DDENS0(:,:,:)
939 real(RP), intent(in) :: DENS_hyd(:,:,:)
940
941 integer :: i,j,k
942 real(RP) :: sig_ss
943 real(RP) :: gam_ss
944 real(RP) :: one_Minus_sig_ss
945 real(RP) :: sig_Ns
946 real(RP) :: gam_Ns
947 real(RP) :: c_ssm1
948 real(RP) :: c_ss
949
950 real(RP) :: dens_ssm1
951 real(RP) :: dens_ss
952
953 !----------------------------------------
954
955 call prof_rapstart( 'rk_advance_trcvar_low_storage3D', 3)
956
957 sig_ss = this%coef_sig_ex(nowstage+1,nowstage)
958 sig_ns = this%coef_sig_ex(this%nstage+1,nowstage)
959 one_minus_sig_ss = 1.0_rp - sig_ss
960 gam_ss = this%dt * this%coef_gam_ex(nowstage+1,nowstage)
961 gam_ns = this%dt * this%coef_gam_ex(this%nstage+1,nowstage)
962 c_ssm1 = this%coef_c_ex(nowstage)
963
964 if ( nowstage == this%nstage ) then
965 !$omp parallel private(i,j,k)
966 !$omp do collapse(2)
967 do k=ks, ke
968 do j=js, je
969 do i=is, ie
970 dens_ssm1 = dens_hyd(i,j,k) + ddens0(i,j,k) + c_ssm1 * ( ddens(i,j,k) - ddens0(i,j,k) )
971 q(i,j,k) = ( this%varTmp_3d(i,j,k,varid) &
972 + sig_ss * q(i,j,k) * dens_ssm1 + gam_ss * this%tend_buf3D_ex(i,j,k,varid,1) ) &
973 / ( dens_hyd(i,j,k) + ddens(i,j,k) )
974 end do
975 end do
976 end do
977 !$omp end parallel
978 call prof_rapend( 'rk_advance_trcvar_low_storage3D', 3)
979
980 return
981 end if
982
983 c_ss = this%coef_c_ex(nowstage+1)
984
985 !$omp parallel private(i,j,k,dens_ss,dens_ssm1)
986 if (nowstage == 1) then
987 !$omp do collapse(2)
988 do k=ks, ke
989 do j=js, je
990 do i=is, ie
991 this%var0_3D(i,j,k,varid) = q(i,j,k) * ( dens_hyd(i,j,k) + ddens0(i,j,k) )
992 this%varTmp_3D(i,j,k,varid) = 0.0_rp
993 end do
994 end do
995 end do
996 end if
997
998 if ( abs(sig_ns) > eps .or. abs(gam_ns) > eps ) then
999 !$omp do collapse(2)
1000 do k=ks, ke
1001 do j=js, je
1002 do i=is, ie
1003 dens_ssm1 = dens_hyd(i,j,k) + ddens0(i,j,k) + c_ssm1 * ( ddens(i,j,k) - ddens0(i,j,k) )
1004 this%varTmp_3d(i,j,k,varid) = this%varTmp_3d(i,j,k,varid) &
1005 + sig_ns * q(i,j,k) * dens_ssm1 + gam_ns * this%tend_buf3D_ex(i,j,k,varid,1)
1006 end do
1007 end do
1008 end do
1009 end if
1010
1011 !$omp do collapse(2)
1012 do k=ks, ke
1013 do j=js, je
1014 do i=is, ie
1015 dens_ssm1 = dens_hyd(i,j,k) + ddens0(i,j,k) + c_ssm1 * ( ddens(i,j,k) - ddens0(i,j,k) )
1016 dens_ss = dens_hyd(i,j,k) + ddens0(i,j,k) + c_ss * ( ddens(i,j,k) - ddens0(i,j,k) )
1017
1018 q(i,j,k) = ( one_minus_sig_ss * this%var0_3d(i,j,k,varid) &
1019 + sig_ss * q(i,j,k) * dens_ssm1 + gam_ss * this%tend_buf3D_ex(i,j,k,varid,1) ) &
1020 / dens_ss
1021 end do
1022 end do
1023 end do
1024
1025 !$omp end parallel
1026
1027 call prof_rapend( 'rk_advance_trcvar_low_storage3D', 3)
1028
1029 return
1030 end subroutine rk_advance_trcvar_low_storage3d
1031
1032
1033
1034!OCL SERIAL
1035 subroutine rk_advance_general1d( this, nowstage, q, varID, is, ie )
1036 implicit none
1037 class(timeint_rk), intent(inout) :: this
1038 integer, intent(in) :: nowstage
1039 real(RP), intent(inout) :: q(:)
1040 integer, intent(in) :: varID
1041 integer, intent(in) :: is, ie
1042
1043 integer :: i
1044 integer :: s
1045 integer :: tintbuf_ind
1046 !----------------------------------------
1047
1048 call prof_rapstart( 'rk_advance_general1D', 3)
1049
1050 tintbuf_ind = this%tend_buf_indmap(nowstage)
1051
1052 if ( this%nstage == 1 ) then
1053 !$omp parallel do
1054 do i=is, ie
1055 this%varTmp_1d(i,varid) = q(i)
1056 end do
1057 end if
1058
1059 if ( nowstage == this%nstage ) then
1060 if ( this%imex_flag ) then
1061
1062 !$omp parallel do
1063 do i=is, ie
1064 q(i) = this%varTmp_1d(i,varid) + this%dt * ( &
1065 + this%coef_b_ex(nowstage) * this%tend_buf1D_ex(i,varid,tintbuf_ind) &
1066 + this%coef_b_im(nowstage) * this%tend_buf1D_im(i,varid,tintbuf_ind) )
1067 end do
1068 else
1069
1070 !$omp parallel do
1071 do i=is, ie
1072 q(i) = this%varTmp_1d(i,varid) &
1073 + this%dt * this%coef_b_ex(nowstage) * this%tend_buf1D_ex(i,varid,tintbuf_ind)
1074 end do
1075 end if
1076 call prof_rapend( 'rk_advance_general1D', 3)
1077
1078 return
1079 end if
1080
1081 !$omp parallel private( s ) &
1082 !$omp private( i )
1083
1084 if ( nowstage == 1 .and. (.not. this%imex_flag) ) then
1085 !$omp do
1086 do i=is, ie
1087 this%var0_1D(i,varid) = q(i)
1088 this%varTmp_1D(i,varid) = q(i)
1089 end do
1090 end if
1091
1092 if ( this%imex_flag ) then
1093 !$omp do
1094 do i=is, ie
1095 q(i) = this%var0_1d(i,varid)
1096 this%varTmp_1d(i,varid) = this%varTmp_1d(i,varid) + this%dt * ( &
1097 + this%coef_b_ex(nowstage) * this%tend_buf1D_ex(i,varid,tintbuf_ind) &
1098 + this%coef_b_im(nowstage) * this%tend_buf1D_im(i,varid,tintbuf_ind) )
1099 end do
1100 else
1101 !$omp do
1102 do i=is, ie
1103 q(i) = this%var0_1d(i,varid)
1104 this%varTmp_1d(i,varid) = this%varTmp_1d(i,varid) &
1105 + this%dt * this%coef_b_ex(nowstage) * this%tend_buf1D_ex(i,varid,tintbuf_ind)
1106 end do
1107 end if
1108
1109 if ( this%tend_buf_size == 1 .and. (.not. this%imex_flag) ) then
1110 !$omp do
1111 do i=is, ie
1112 q(i) = this%var0_1d(i,varid) &
1113 + this%dt * this%coef_a_ex(nowstage+1,nowstage)*this%tend_buf1D_ex(i,varid,1)
1114 end do
1115 else if ( .not. this%imex_flag ) then
1116 do s=1, nowstage
1117 !$omp do
1118 do i=is, ie
1119 q(i) = q(i) &
1120 + this%dt * this%coef_a_ex(nowstage+1,s)*this%tend_buf1D_ex(i,varid,s)
1121 end do
1122 end do
1123 else ! IMEX
1124 do s=1, nowstage
1125 !$omp do
1126 do i=is, ie
1127 q(i) = q(i) &
1128 + this%dt * ( this%coef_a_ex(nowstage+1,s)*this%tend_buf1D_ex(i,varid,s) &
1129 + this%coef_a_im(nowstage+1,s)*this%tend_buf1D_im(i,varid,s) )
1130 end do
1131 end do
1132 end if
1133
1134 !$omp end parallel
1135 call prof_rapend( 'rk_advance_general1D', 3)
1136
1137 return
1138 end subroutine rk_advance_general1d
1139
1140 !OCL SERIAL
1141 subroutine rk_advance_trcvar_general1d( this, nowstage, q, varID, is, ie , &
1142 DDENS, DDENS0, DENS_hyd )
1143 implicit none
1144 class(timeint_rk), intent(inout) :: this
1145 integer, intent(in) :: nowstage
1146 real(RP), intent(inout) :: q(:)
1147 integer, intent(in) :: varID
1148 integer, intent(in) :: is, ie
1149 real(RP), intent(in) :: DDENS (:)
1150 real(RP), intent(in) :: DDENS0(:)
1151 real(RP), intent(in) :: DENS_hyd(:)
1152
1153 integer :: i
1154 integer :: s
1155 integer :: tintbuf_ind
1156
1157 real(RP) :: dens_
1158 real(RP) :: c_ss
1159 !----------------------------------------
1160
1161 call prof_rapstart( 'rk_advance_trcvar_general1D', 3)
1162
1163 tintbuf_ind = this%tend_buf_indmap(nowstage)
1164
1165 if ( this%nstage == 1 ) then
1166 !$omp parallel do
1167 do i=is, ie
1168 this%varTmp_1d(i,varid) = q(i) * ( dens_hyd(i) + ddens0(i) )
1169 end do
1170 end if
1171
1172 if ( nowstage == this%nstage ) then
1173 !$omp parallel do
1174 do i=is, ie
1175 q(i) = ( this%varTmp_1d(i,varid) &
1176 + this%dt * this%coef_b_ex(nowstage) * this%tend_buf1D_ex(i,varid,tintbuf_ind) ) &
1177 / ( dens_hyd(i) + ddens(i) )
1178 end do
1179 call prof_rapend( 'rk_advance_trcvar_general1D', 3)
1180
1181 return
1182 end if
1183
1184 c_ss = this%coef_c_ex(nowstage+1)
1185
1186 !$omp parallel private( s, dens_ ) &
1187 !$omp private( i )
1188
1189 if ( nowstage == 1 .and. (.not. this%imex_flag) ) then
1190 !$omp do
1191 do i=is, ie
1192 this%var0_1D(i,varid) = q(i) * ( dens_hyd(i) + ddens0(i) )
1193 this%varTmp_1D(i,varid) = this%var0_1D(i,varid)
1194 end do
1195 end if
1196
1197 !$omp do
1198 do i=is, ie
1199 q(i) = this%var0_1d(i,varid)
1200 this%varTmp_1d(i,varid) = this%varTmp_1d(i,varid) &
1201 + this%dt * this%coef_b_ex(nowstage) * this%tend_buf1D_ex(i,varid,tintbuf_ind)
1202 end do
1203
1204 if ( this%tend_buf_size == 1 .and. (.not. this%imex_flag) ) then
1205 !$omp do
1206 do i=is, ie
1207 dens_ = ( dens_hyd(i) + ddens0(i) ) &
1208 + this%coef_a_ex(nowstage+1,nowstage)*( ddens(i) - ddens0(i) )
1209 q(i) = ( this%var0_1d(i,varid) &
1210 + this%dt * this%coef_a_ex(nowstage+1,nowstage)*this%tend_buf1D_ex(i,varid,1) ) &
1211 / dens_
1212 end do
1213 else if ( .not. this%imex_flag ) then
1214 do s=1, nowstage
1215 !$omp do
1216 do i=is, ie
1217 q(i) = q(i) &
1218 + this%dt * this%coef_a_ex(nowstage+1,s)*this%tend_buf1D_ex(i,varid,s)
1219 end do
1220 end do
1221 !$omp do
1222 do i=is, ie
1223 dens_ = dens_hyd(i) + ddens0(i) + c_ss * ( ddens(i) - ddens0(i) )
1224 q(i) = q(i) / dens_
1225 end do
1226 end if
1227
1228 !$omp end parallel
1229 call prof_rapend( 'rk_advance_trcvar_generall1D', 3)
1230
1231 return
1232 end subroutine rk_advance_trcvar_general1d
1233
1234!OCL SERIAL
1235 subroutine rk_storeimpl_general1d( this, nowstage, q, varID, is, ie )
1236 implicit none
1237 class(timeint_rk), intent(inout) :: this
1238 integer, intent(in) :: nowstage
1239 real(RP), intent(inout) :: q(:)
1240 integer, intent(in) :: varID
1241 integer, intent(in) :: is, ie
1242
1243 integer :: i
1244 integer :: tintbuf_ind
1245 !----------------------------------------
1246
1247 if (.not. this%imex_flag ) return
1248
1249 tintbuf_ind = this%tend_buf_indmap(nowstage)
1250
1251 !$omp parallel
1252
1253 if ( nowstage == 1 ) then
1254 !$omp do
1255 do i=is, ie
1256 this%var0_1D(i,varid) = q(i)
1257 this%varTmp_1D(i,varid) = q(i)
1258 end do
1259 end if
1260
1261 !$omp do
1262 do i=is, ie
1263 q(i) = q(i) &
1264 + this%dt * this%coef_a_im(nowstage,nowstage)*this%tend_buf1D_im(i,varid,tintbuf_ind)
1265 end do
1266 !$omp end parallel
1267
1268 return
1269 end subroutine rk_storeimpl_general1d
1270
1271
1272!OCL SERIAL
1273 subroutine rk_advance_general2d( this, nowstage, q, varID, is, ie ,js, je )
1274 implicit none
1275 class(timeint_rk), intent(inout) :: this
1276 integer, intent(in) :: nowstage
1277 real(RP), intent(inout) :: q(:,:)
1278 integer, intent(in) :: varID
1279 integer, intent(in) :: is, ie ,js, je
1280
1281 integer :: i,j
1282 integer :: s
1283 integer :: tintbuf_ind
1284 !----------------------------------------
1285
1286 call prof_rapstart( 'rk_advance_general2D', 3)
1287
1288 tintbuf_ind = this%tend_buf_indmap(nowstage)
1289
1290 if ( this%nstage == 1 ) then
1291 !$omp parallel do
1292 do j=js, je
1293 do i=is, ie
1294 this%varTmp_2d(i,j,varid) = q(i,j)
1295 end do
1296 end do
1297 end if
1298
1299 if ( nowstage == this%nstage ) then
1300 if ( this%imex_flag ) then
1301
1302 !$omp parallel do
1303 do j=js, je
1304 do i=is, ie
1305 q(i,j) = this%varTmp_2d(i,j,varid) + this%dt * ( &
1306 + this%coef_b_ex(nowstage) * this%tend_buf2D_ex(i,j,varid,tintbuf_ind) &
1307 + this%coef_b_im(nowstage) * this%tend_buf2D_im(i,j,varid,tintbuf_ind) )
1308 end do
1309 end do
1310 else
1311
1312 !$omp parallel do
1313 do j=js, je
1314 do i=is, ie
1315 q(i,j) = this%varTmp_2d(i,j,varid) &
1316 + this%dt * this%coef_b_ex(nowstage) * this%tend_buf2D_ex(i,j,varid,tintbuf_ind)
1317 end do
1318 end do
1319 end if
1320 call prof_rapend( 'rk_advance_general2D', 3)
1321
1322 return
1323 end if
1324
1325 !$omp parallel private( s ) &
1326 !$omp private( i,j )
1327
1328 if ( nowstage == 1 .and. (.not. this%imex_flag) ) then
1329 !$omp do
1330 do j=js, je
1331 do i=is, ie
1332 this%var0_2D(i,j,varid) = q(i,j)
1333 this%varTmp_2D(i,j,varid) = q(i,j)
1334 end do
1335 end do
1336 end if
1337
1338 if ( this%imex_flag ) then
1339 !$omp do
1340 do j=js, je
1341 do i=is, ie
1342 q(i,j) = this%var0_2d(i,j,varid)
1343 this%varTmp_2d(i,j,varid) = this%varTmp_2d(i,j,varid) + this%dt * ( &
1344 + this%coef_b_ex(nowstage) * this%tend_buf2D_ex(i,j,varid,tintbuf_ind) &
1345 + this%coef_b_im(nowstage) * this%tend_buf2D_im(i,j,varid,tintbuf_ind) )
1346 end do
1347 end do
1348 else
1349 !$omp do
1350 do j=js, je
1351 do i=is, ie
1352 q(i,j) = this%var0_2d(i,j,varid)
1353 this%varTmp_2d(i,j,varid) = this%varTmp_2d(i,j,varid) &
1354 + this%dt * this%coef_b_ex(nowstage) * this%tend_buf2D_ex(i,j,varid,tintbuf_ind)
1355 end do
1356 end do
1357 end if
1358
1359 if ( this%tend_buf_size == 1 .and. (.not. this%imex_flag) ) then
1360 !$omp do
1361 do j=js, je
1362 do i=is, ie
1363 q(i,j) = this%var0_2d(i,j,varid) &
1364 + this%dt * this%coef_a_ex(nowstage+1,nowstage)*this%tend_buf2D_ex(i,j,varid,1)
1365 end do
1366 end do
1367 else if ( .not. this%imex_flag ) then
1368 do s=1, nowstage
1369 !$omp do
1370 do j=js, je
1371 do i=is, ie
1372 q(i,j) = q(i,j) &
1373 + this%dt * this%coef_a_ex(nowstage+1,s)*this%tend_buf2D_ex(i,j,varid,s)
1374 end do
1375 end do
1376 end do
1377 else ! IMEX
1378 do s=1, nowstage
1379 !$omp do
1380 do j=js, je
1381 do i=is, ie
1382 q(i,j) = q(i,j) &
1383 + this%dt * ( this%coef_a_ex(nowstage+1,s)*this%tend_buf2D_ex(i,j,varid,s) &
1384 + this%coef_a_im(nowstage+1,s)*this%tend_buf2D_im(i,j,varid,s) )
1385 end do
1386 end do
1387 end do
1388 end if
1389
1390 !$omp end parallel
1391 call prof_rapend( 'rk_advance_general2D', 3)
1392
1393 return
1394 end subroutine rk_advance_general2d
1395
1396 !OCL SERIAL
1397 subroutine rk_advance_trcvar_general2d( this, nowstage, q, varID, is, ie ,js, je , &
1398 DDENS, DDENS0, DENS_hyd )
1399 implicit none
1400 class(timeint_rk), intent(inout) :: this
1401 integer, intent(in) :: nowstage
1402 real(RP), intent(inout) :: q(:,:)
1403 integer, intent(in) :: varID
1404 integer, intent(in) :: is, ie ,js, je
1405 real(RP), intent(in) :: DDENS (:,:)
1406 real(RP), intent(in) :: DDENS0(:,:)
1407 real(RP), intent(in) :: DENS_hyd(:,:)
1408
1409 integer :: i,j
1410 integer :: s
1411 integer :: tintbuf_ind
1412
1413 real(RP) :: dens_
1414 real(RP) :: c_ss
1415 !----------------------------------------
1416
1417 call prof_rapstart( 'rk_advance_trcvar_general2D', 3)
1418
1419 tintbuf_ind = this%tend_buf_indmap(nowstage)
1420
1421 if ( this%nstage == 1 ) then
1422 !$omp parallel do
1423 do j=js, je
1424 do i=is, ie
1425 this%varTmp_2d(i,j,varid) = q(i,j) * ( dens_hyd(i,j) + ddens0(i,j) )
1426 end do
1427 end do
1428 end if
1429
1430 if ( nowstage == this%nstage ) then
1431 !$omp parallel do
1432 do j=js, je
1433 do i=is, ie
1434 q(i,j) = ( this%varTmp_2d(i,j,varid) &
1435 + this%dt * this%coef_b_ex(nowstage) * this%tend_buf2D_ex(i,j,varid,tintbuf_ind) ) &
1436 / ( dens_hyd(i,j) + ddens(i,j) )
1437 end do
1438 end do
1439 call prof_rapend( 'rk_advance_trcvar_general2D', 3)
1440
1441 return
1442 end if
1443
1444 c_ss = this%coef_c_ex(nowstage+1)
1445
1446 !$omp parallel private( s, dens_ ) &
1447 !$omp private( i,j )
1448
1449 if ( nowstage == 1 .and. (.not. this%imex_flag) ) then
1450 !$omp do
1451 do j=js, je
1452 do i=is, ie
1453 this%var0_2D(i,j,varid) = q(i,j) * ( dens_hyd(i,j) + ddens0(i,j) )
1454 this%varTmp_2D(i,j,varid) = this%var0_2D(i,j,varid)
1455 end do
1456 end do
1457 end if
1458
1459 !$omp do
1460 do j=js, je
1461 do i=is, ie
1462 q(i,j) = this%var0_2d(i,j,varid)
1463 this%varTmp_2d(i,j,varid) = this%varTmp_2d(i,j,varid) &
1464 + this%dt * this%coef_b_ex(nowstage) * this%tend_buf2D_ex(i,j,varid,tintbuf_ind)
1465 end do
1466 end do
1467
1468 if ( this%tend_buf_size == 1 .and. (.not. this%imex_flag) ) then
1469 !$omp do
1470 do j=js, je
1471 do i=is, ie
1472 dens_ = ( dens_hyd(i,j) + ddens0(i,j) ) &
1473 + this%coef_a_ex(nowstage+1,nowstage)*( ddens(i,j) - ddens0(i,j) )
1474 q(i,j) = ( this%var0_2d(i,j,varid) &
1475 + this%dt * this%coef_a_ex(nowstage+1,nowstage)*this%tend_buf2D_ex(i,j,varid,1) ) &
1476 / dens_
1477 end do
1478 end do
1479 else if ( .not. this%imex_flag ) then
1480 do s=1, nowstage
1481 !$omp do
1482 do j=js, je
1483 do i=is, ie
1484 q(i,j) = q(i,j) &
1485 + this%dt * this%coef_a_ex(nowstage+1,s)*this%tend_buf2D_ex(i,j,varid,s)
1486 end do
1487 end do
1488 end do
1489 !$omp do
1490 do j=js, je
1491 do i=is, ie
1492 dens_ = dens_hyd(i,j) + ddens0(i,j) + c_ss * ( ddens(i,j) - ddens0(i,j) )
1493 q(i,j) = q(i,j) / dens_
1494 end do
1495 end do
1496 end if
1497
1498 !$omp end parallel
1499 call prof_rapend( 'rk_advance_trcvar_generall2D', 3)
1500
1501 return
1502 end subroutine rk_advance_trcvar_general2d
1503
1504!OCL SERIAL
1505 subroutine rk_storeimpl_general2d( this, nowstage, q, varID, is, ie ,js, je )
1506 implicit none
1507 class(timeint_rk), intent(inout) :: this
1508 integer, intent(in) :: nowstage
1509 real(RP), intent(inout) :: q(:,:)
1510 integer, intent(in) :: varID
1511 integer, intent(in) :: is, ie ,js, je
1512
1513 integer :: i,j
1514 integer :: tintbuf_ind
1515 !----------------------------------------
1516
1517 if (.not. this%imex_flag ) return
1518
1519 tintbuf_ind = this%tend_buf_indmap(nowstage)
1520
1521 !$omp parallel
1522
1523 if ( nowstage == 1 ) then
1524 !$omp do
1525 do j=js, je
1526 do i=is, ie
1527 this%var0_2D(i,j,varid) = q(i,j)
1528 this%varTmp_2D(i,j,varid) = q(i,j)
1529 end do
1530 end do
1531 end if
1532
1533 !$omp do
1534 do j=js, je
1535 do i=is, ie
1536 q(i,j) = q(i,j) &
1537 + this%dt * this%coef_a_im(nowstage,nowstage)*this%tend_buf2D_im(i,j,varid,tintbuf_ind)
1538 end do
1539 end do
1540 !$omp end parallel
1541
1542 return
1543 end subroutine rk_storeimpl_general2d
1544
1545
1546!OCL SERIAL
1547 subroutine rk_advance_general3d( this, nowstage, q, varID, is, ie ,js, je ,ks, ke )
1548 implicit none
1549 class(timeint_rk), intent(inout) :: this
1550 integer, intent(in) :: nowstage
1551 real(RP), intent(inout) :: q(:,:,:)
1552 integer, intent(in) :: varID
1553 integer, intent(in) :: is, ie ,js, je ,ks, ke
1554
1555 integer :: i,j,k
1556 integer :: s
1557 integer :: tintbuf_ind
1558 !----------------------------------------
1559
1560 call prof_rapstart( 'rk_advance_general3D', 3)
1561
1562 tintbuf_ind = this%tend_buf_indmap(nowstage)
1563
1564 if ( this%nstage == 1 ) then
1565 !$omp parallel do collapse(2)
1566 do k=ks, ke
1567 do j=js, je
1568 do i=is, ie
1569 this%varTmp_3d(i,j,k,varid) = q(i,j,k)
1570 end do
1571 end do
1572 end do
1573 end if
1574
1575 if ( nowstage == this%nstage ) then
1576 if ( this%imex_flag ) then
1577
1578 !$omp parallel do collapse(2)
1579 do k=ks, ke
1580 do j=js, je
1581 do i=is, ie
1582 q(i,j,k) = this%varTmp_3d(i,j,k,varid) + this%dt * ( &
1583 + this%coef_b_ex(nowstage) * this%tend_buf3D_ex(i,j,k,varid,tintbuf_ind) &
1584 + this%coef_b_im(nowstage) * this%tend_buf3D_im(i,j,k,varid,tintbuf_ind) )
1585 end do
1586 end do
1587 end do
1588 else
1589
1590 !$omp parallel do collapse(2)
1591 do k=ks, ke
1592 do j=js, je
1593 do i=is, ie
1594 q(i,j,k) = this%varTmp_3d(i,j,k,varid) &
1595 + this%dt * this%coef_b_ex(nowstage) * this%tend_buf3D_ex(i,j,k,varid,tintbuf_ind)
1596 end do
1597 end do
1598 end do
1599 end if
1600 call prof_rapend( 'rk_advance_general3D', 3)
1601
1602 return
1603 end if
1604
1605 !$omp parallel private( s ) &
1606 !$omp private( i,j,k )
1607
1608 if ( nowstage == 1 .and. (.not. this%imex_flag) ) then
1609 !$omp do collapse(2)
1610 do k=ks, ke
1611 do j=js, je
1612 do i=is, ie
1613 this%var0_3D(i,j,k,varid) = q(i,j,k)
1614 this%varTmp_3D(i,j,k,varid) = q(i,j,k)
1615 end do
1616 end do
1617 end do
1618 end if
1619
1620 if ( this%imex_flag ) then
1621 !$omp do collapse(2)
1622 do k=ks, ke
1623 do j=js, je
1624 do i=is, ie
1625 q(i,j,k) = this%var0_3d(i,j,k,varid)
1626 this%varTmp_3d(i,j,k,varid) = this%varTmp_3d(i,j,k,varid) + this%dt * ( &
1627 + this%coef_b_ex(nowstage) * this%tend_buf3D_ex(i,j,k,varid,tintbuf_ind) &
1628 + this%coef_b_im(nowstage) * this%tend_buf3D_im(i,j,k,varid,tintbuf_ind) )
1629 end do
1630 end do
1631 end do
1632 else
1633 !$omp do collapse(2)
1634 do k=ks, ke
1635 do j=js, je
1636 do i=is, ie
1637 q(i,j,k) = this%var0_3d(i,j,k,varid)
1638 this%varTmp_3d(i,j,k,varid) = this%varTmp_3d(i,j,k,varid) &
1639 + this%dt * this%coef_b_ex(nowstage) * this%tend_buf3D_ex(i,j,k,varid,tintbuf_ind)
1640 end do
1641 end do
1642 end do
1643 end if
1644
1645 if ( this%tend_buf_size == 1 .and. (.not. this%imex_flag) ) then
1646 !$omp do collapse(2)
1647 do k=ks, ke
1648 do j=js, je
1649 do i=is, ie
1650 q(i,j,k) = this%var0_3d(i,j,k,varid) &
1651 + this%dt * this%coef_a_ex(nowstage+1,nowstage)*this%tend_buf3D_ex(i,j,k,varid,1)
1652 end do
1653 end do
1654 end do
1655 else if ( .not. this%imex_flag ) then
1656 do s=1, nowstage
1657 !$omp do collapse(2)
1658 do k=ks, ke
1659 do j=js, je
1660 do i=is, ie
1661 q(i,j,k) = q(i,j,k) &
1662 + this%dt * this%coef_a_ex(nowstage+1,s)*this%tend_buf3D_ex(i,j,k,varid,s)
1663 end do
1664 end do
1665 end do
1666 end do
1667 else ! IMEX
1668 do s=1, nowstage
1669 !$omp do collapse(2)
1670 do k=ks, ke
1671 do j=js, je
1672 do i=is, ie
1673 q(i,j,k) = q(i,j,k) &
1674 + this%dt * ( this%coef_a_ex(nowstage+1,s)*this%tend_buf3D_ex(i,j,k,varid,s) &
1675 + this%coef_a_im(nowstage+1,s)*this%tend_buf3D_im(i,j,k,varid,s) )
1676 end do
1677 end do
1678 end do
1679 end do
1680 end if
1681
1682 !$omp end parallel
1683 call prof_rapend( 'rk_advance_general3D', 3)
1684
1685 return
1686 end subroutine rk_advance_general3d
1687
1688 !OCL SERIAL
1689 subroutine rk_advance_trcvar_general3d( this, nowstage, q, varID, is, ie ,js, je ,ks, ke , &
1690 DDENS, DDENS0, DENS_hyd )
1691 implicit none
1692 class(timeint_rk), intent(inout) :: this
1693 integer, intent(in) :: nowstage
1694 real(RP), intent(inout) :: q(:,:,:)
1695 integer, intent(in) :: varID
1696 integer, intent(in) :: is, ie ,js, je ,ks, ke
1697 real(RP), intent(in) :: DDENS (:,:,:)
1698 real(RP), intent(in) :: DDENS0(:,:,:)
1699 real(RP), intent(in) :: DENS_hyd(:,:,:)
1700
1701 integer :: i,j,k
1702 integer :: s
1703 integer :: tintbuf_ind
1704
1705 real(RP) :: dens_
1706 real(RP) :: c_ss
1707 !----------------------------------------
1708
1709 call prof_rapstart( 'rk_advance_trcvar_general3D', 3)
1710
1711 tintbuf_ind = this%tend_buf_indmap(nowstage)
1712
1713 if ( this%nstage == 1 ) then
1714 !$omp parallel do collapse(2)
1715 do k=ks, ke
1716 do j=js, je
1717 do i=is, ie
1718 this%varTmp_3d(i,j,k,varid) = q(i,j,k) * ( dens_hyd(i,j,k) + ddens0(i,j,k) )
1719 end do
1720 end do
1721 end do
1722 end if
1723
1724 if ( nowstage == this%nstage ) then
1725 !$omp parallel do collapse(2)
1726 do k=ks, ke
1727 do j=js, je
1728 do i=is, ie
1729 q(i,j,k) = ( this%varTmp_3d(i,j,k,varid) &
1730 + this%dt * this%coef_b_ex(nowstage) * this%tend_buf3D_ex(i,j,k,varid,tintbuf_ind) ) &
1731 / ( dens_hyd(i,j,k) + ddens(i,j,k) )
1732 end do
1733 end do
1734 end do
1735 call prof_rapend( 'rk_advance_trcvar_general3D', 3)
1736
1737 return
1738 end if
1739
1740 c_ss = this%coef_c_ex(nowstage+1)
1741
1742 !$omp parallel private( s, dens_ ) &
1743 !$omp private( i,j,k )
1744
1745 if ( nowstage == 1 .and. (.not. this%imex_flag) ) then
1746 !$omp do collapse(2)
1747 do k=ks, ke
1748 do j=js, je
1749 do i=is, ie
1750 this%var0_3D(i,j,k,varid) = q(i,j,k) * ( dens_hyd(i,j,k) + ddens0(i,j,k) )
1751 this%varTmp_3D(i,j,k,varid) = this%var0_3D(i,j,k,varid)
1752 end do
1753 end do
1754 end do
1755 end if
1756
1757 !$omp do collapse(2)
1758 do k=ks, ke
1759 do j=js, je
1760 do i=is, ie
1761 q(i,j,k) = this%var0_3d(i,j,k,varid)
1762 this%varTmp_3d(i,j,k,varid) = this%varTmp_3d(i,j,k,varid) &
1763 + this%dt * this%coef_b_ex(nowstage) * this%tend_buf3D_ex(i,j,k,varid,tintbuf_ind)
1764 end do
1765 end do
1766 end do
1767
1768 if ( this%tend_buf_size == 1 .and. (.not. this%imex_flag) ) then
1769 !$omp do collapse(2)
1770 do k=ks, ke
1771 do j=js, je
1772 do i=is, ie
1773 dens_ = ( dens_hyd(i,j,k) + ddens0(i,j,k) ) &
1774 + this%coef_a_ex(nowstage+1,nowstage)*( ddens(i,j,k) - ddens0(i,j,k) )
1775 q(i,j,k) = ( this%var0_3d(i,j,k,varid) &
1776 + this%dt * this%coef_a_ex(nowstage+1,nowstage)*this%tend_buf3D_ex(i,j,k,varid,1) ) &
1777 / dens_
1778 end do
1779 end do
1780 end do
1781 else if ( .not. this%imex_flag ) then
1782 do s=1, nowstage
1783 !$omp do collapse(2)
1784 do k=ks, ke
1785 do j=js, je
1786 do i=is, ie
1787 q(i,j,k) = q(i,j,k) &
1788 + this%dt * this%coef_a_ex(nowstage+1,s)*this%tend_buf3D_ex(i,j,k,varid,s)
1789 end do
1790 end do
1791 end do
1792 end do
1793 !$omp do collapse(2)
1794 do k=ks, ke
1795 do j=js, je
1796 do i=is, ie
1797 dens_ = dens_hyd(i,j,k) + ddens0(i,j,k) + c_ss * ( ddens(i,j,k) - ddens0(i,j,k) )
1798 q(i,j,k) = q(i,j,k) / dens_
1799 end do
1800 end do
1801 end do
1802 end if
1803
1804 !$omp end parallel
1805 call prof_rapend( 'rk_advance_trcvar_generall3D', 3)
1806
1807 return
1808 end subroutine rk_advance_trcvar_general3d
1809
1810!OCL SERIAL
1811 subroutine rk_storeimpl_general3d( this, nowstage, q, varID, is, ie ,js, je ,ks, ke )
1812 implicit none
1813 class(timeint_rk), intent(inout) :: this
1814 integer, intent(in) :: nowstage
1815 real(RP), intent(inout) :: q(:,:,:)
1816 integer, intent(in) :: varID
1817 integer, intent(in) :: is, ie ,js, je ,ks, ke
1818
1819 integer :: i,j,k
1820 integer :: tintbuf_ind
1821 !----------------------------------------
1822
1823 if (.not. this%imex_flag ) return
1824
1825 tintbuf_ind = this%tend_buf_indmap(nowstage)
1826
1827 !$omp parallel
1828
1829 if ( nowstage == 1 ) then
1830 !$omp do collapse(2)
1831 do k=ks, ke
1832 do j=js, je
1833 do i=is, ie
1834 this%var0_3D(i,j,k,varid) = q(i,j,k)
1835 this%varTmp_3D(i,j,k,varid) = q(i,j,k)
1836 end do
1837 end do
1838 end do
1839 end if
1840
1841 !$omp do collapse(2)
1842 do k=ks, ke
1843 do j=js, je
1844 do i=is, ie
1845 q(i,j,k) = q(i,j,k) &
1846 + this%dt * this%coef_a_im(nowstage,nowstage)*this%tend_buf3D_im(i,j,k,varid,tintbuf_ind)
1847 end do
1848 end do
1849 end do
1850 !$omp end parallel
1851
1852 return
1853 end subroutine rk_storeimpl_general3d
1854
1855end module scale_timeint_rk
1856
module common / Runge-Kutta scheme
subroutine, public timeint_rk_butcher_tab_get_info(rk_scheme_name, nstage, tend_buf_size, low_storage_flag, imex_flag)
subroutine, public timeint_rk_butcher_tab_get(rk_scheme_name, nstage, imex_flag, coef_a_ex, coef_b_ex, coef_c_ex, coef_sig_ex, coef_gam_ex, coef_a_im, coef_b_im, coef_c_im, tend_buf_indmap)
module common / Runge-Kutta scheme
subroutine timeint_rk_init(this, rk_scheme_name, dt, var_num, ndim, size_each_var)