forked from ESCOMP/atmospheric_physics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkessler_update.F90
119 lines (87 loc) · 3.79 KB
/
kessler_update.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
module kessler_update
use ccpp_kinds, only: kind_phys
implicit none
private
public :: kessler_update_init
public :: kessler_update_timestep_init
public :: kessler_update_run
public :: kessler_update_timestep_final
! Private module variables
real(kind_phys) :: gravit
real(kind_phys) :: cpair
CONTAINS
!> \section arg_table_kessler_update_init Argument Table
!! \htmlinclude kessler_update_init.html
subroutine kessler_update_init(gravit_in, cpair_in)
real(kind_phys), intent(in) :: gravit_in
real(kind_phys), intent(in) :: cpair_in
gravit = gravit_in
cpair = cpair_in
end subroutine kessler_update_init
!> \section arg_table_kessler_update_timestep_init Argument Table
!! \htmlinclude kessler_update_timestep_init.html
subroutine kessler_update_timestep_init(temp, temp_prev, ttend_t, &
errmsg, errflg)
real(kind_phys), intent(in) :: temp(:,:)
real(kind_phys), intent(out) :: temp_prev(:,:)
real(kind_phys), intent(out) :: ttend_t(:,:)
character(len=512), intent(out) :: errmsg
integer, intent(out) :: errflg
! Initialize the previous temperature and its tendency to zero
temp_prev(:,:) = temp(:,:)
ttend_t(:,:) = 0._kind_phys
errmsg = ''
errflg = 0
end subroutine kessler_update_timestep_init
!> \section arg_table_kessler_update_run Argument Table
!! \htmlinclude kessler_update_run.html
subroutine kessler_update_run(nz, ncol, phis, temp, theta, exner, dt, &
temp_prev, ttend_t, errmsg, errflg)
integer, intent(in) :: nz
integer, intent(in) :: ncol
real(kind_phys), intent(in) :: phis(:)
real(kind_phys), intent(in) :: temp(:,:) ! temperature
real(kind_phys), intent(in) :: exner(:,:)
real(kind_phys), intent(in) :: dt
real(kind_phys), intent(inout) :: theta(:,:)
real(kind_phys), intent(inout) :: temp_prev(:,:)
real(kind_phys), intent(inout) :: ttend_t(:,:)
character(len=512), intent(out) :: errmsg
integer, intent(out) :: errflg
integer :: klev
real(kind_phys) :: ptend_s(ncol)
errmsg = ''
errflg = 0
! Back out tendencies from updated fields
do klev = 1, nz
ptend_s(:ncol) = ((theta(:ncol,klev) * exner(:ncol,klev)) - &
temp_prev(:ncol,klev)) * cpair / dt
ttend_t(:ncol,klev) = ttend_t(:ncol,klev) + (ptend_s(:ncol) / cpair)
end do
! Save the temperature for the next time step
!!XXgoldyXX ==> @cacraigucar: Does this have any effect?
temp_prev(:,:) = temp(:,:)
! surf_state%precl(:ncol) = surf_state%precl(:ncol) + precl(:ncol) ! KEEPING THIS HERE AS A REMINDER
end subroutine kessler_update_run
!> \section arg_table_kessler_update_timestep_final Argument Table
!! \htmlinclude kessler_update_timestep_final.html
subroutine kessler_update_timestep_final(nz, temp, zm, phis, st_energy, &
errflg, errmsg)
! Dummy arguments
integer, intent(in) :: nz
real(kind_phys), intent(in) :: temp(:,:) ! temperature
real(kind_phys), intent(in) :: zm(:,:)
real(kind_phys), intent(in) :: phis(:)
real(kind_phys), intent(out) :: st_energy(:,:)
character(len=512), intent(out) :: errmsg
integer, intent(out) :: errflg
! Local variable
integer :: klev
errmsg = ''
errflg = 0
do klev = 1, nz
st_energy(:,klev) = (temp(:,klev) * cpair) + (gravit * zm(:,klev)) + &
phis(:)
end do
end subroutine kessler_update_timestep_final
end module kessler_update