Line data Source code
1 : !----------------------------------------------------------------------
2 : ! this module computes the total advection tendencies of advected
3 : ! constituents for the finite volume dycore
4 : !----------------------------------------------------------------------
5 : module advect_tend
6 :
7 : use shr_kind_mod, only : r8 => shr_kind_r8
8 :
9 : save
10 : private
11 :
12 : public :: compute_adv_tends_xyz
13 :
14 : real(r8), allocatable :: adv_tendxyz(:,:,:,:)
15 :
16 : contains
17 :
18 : !----------------------------------------------------------------------
19 : ! computes the total advective tendencies
20 : ! called twice each time step:
21 : ! - first call sets the initial mixing ratios
22 : ! - second call computes and outputs the tendencies
23 : !----------------------------------------------------------------------
24 32256 : subroutine compute_adv_tends_xyz( grid, tracer )
25 : use dynamics_vars, only : T_FVDYCORE_GRID
26 : use cam_history, only : outfld
27 : use time_manager, only : get_step_size
28 : use constituents, only : tottnam
29 :
30 : implicit none
31 :
32 : type (T_FVDYCORE_GRID), intent(in) :: grid
33 : real (r8) :: tracer(grid%ifirstxy:grid%ilastxy, grid%jfirstxy:grid%jlastxy, grid%km, grid%nq )
34 :
35 : real(r8) :: dt,idt
36 : integer :: iq, idim, i, j,ic
37 : logical :: init
38 64512 : real(r8) :: tmpxy(grid%ifirstxy:grid%ilastxy,grid%km)
39 :
40 :
41 32256 : init = .false.
42 :
43 32256 : if ( .not. allocated( adv_tendxyz ) ) then
44 16128 : init = .true.
45 96768 : allocate( adv_tendxyz(grid%ifirstxy:grid%ilastxy, grid%jfirstxy:grid%jlastxy, grid%km, grid%nq ) )
46 16889612544 : adv_tendxyz(:,:,:,:) = 0._r8
47 : endif
48 :
49 : !!$ adv_tendxyz(:,:,:,:grid%nq) = q(:,:,:,:grid%nq) - adv_tendxyz(:,:,:,:grid%nq)
50 :
51 7967232 : do ic=1,grid%nq
52 33779225088 : adv_tendxyz(:,:,:,ic) = tracer(:,:,:,ic) - adv_tendxyz(:,:,:,ic)
53 : enddo
54 :
55 32256 : if ( .not. init ) then
56 16128 : dt = get_step_size()
57 16128 : idt = 1._r8/dt
58 :
59 3983616 : do i = 1,grid%nq
60 : ! call outfld
61 15886080 : do j = grid%jfirstxy, grid%jlastxy
62 11902464 : idim = grid%ilastxy - grid%ifirstxy + 1
63 16675352064 : tmpxy(:,:) = adv_tendxyz(:,j,:,i)*idt
64 :
65 15869952 : call outfld( tottnam(i), tmpxy, idim, j)
66 : enddo
67 : enddo
68 :
69 16128 : deallocate(adv_tendxyz)
70 : endif
71 :
72 32256 : end subroutine compute_adv_tends_xyz
73 :
74 : end module advect_tend
|