FV3-JEDI
fv3jedi_traj_mod.f90
Go to the documentation of this file.
1 ! (C) Copyright 2017-2020 UCAR
2 !
3 ! This software is licensed under the terms of the Apache Licence Version 2.0
4 ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5 
7 
8 ! fv3-jedi-lm
9 use fv3jedi_lm_utils_mod, only: fv3jedi_traj => fv3jedi_lm_traj, deallocate_traj
10 
11 ! fv3-jedi
14 
15 ! --------------------------------------------------------------------------------------------------
16 
17 implicit none
18 private
19 public :: fv3jedi_traj
20 public :: set
21 public :: wipe
22 
23 ! --------------------------------------------------------------------------------------------------
24 
25 contains
26 
27 ! --------------------------------------------------------------------------------------------------
28 
29 subroutine set(self, state)
30 
31 implicit none
32 type(fv3jedi_traj), intent(inout) :: self
33 type(fv3jedi_state), intent(in) :: state
34 
35 integer :: isc,iec,jsc,jec,npz
36 
37 ! Pointers to rank 2 state
38 real(kind=kind_real), allocatable, dimension(:,:,:) :: u_tmp
39 real(kind=kind_real), allocatable, dimension(:,:,:) :: v_tmp
40 
41 real(kind=kind_real), pointer, dimension(:,:,:) :: phis
42 real(kind=kind_real), pointer, dimension(:,:,:) :: frocean
43 real(kind=kind_real), pointer, dimension(:,:,:) :: frland
44 real(kind=kind_real), pointer, dimension(:,:,:) :: varflt
45 real(kind=kind_real), pointer, dimension(:,:,:) :: ustar
46 real(kind=kind_real), pointer, dimension(:,:,:) :: bstar
47 real(kind=kind_real), pointer, dimension(:,:,:) :: zpbl
48 real(kind=kind_real), pointer, dimension(:,:,:) :: cm
49 real(kind=kind_real), pointer, dimension(:,:,:) :: ct
50 real(kind=kind_real), pointer, dimension(:,:,:) :: cq
51 real(kind=kind_real), pointer, dimension(:,:,:) :: kcbl
52 real(kind=kind_real), pointer, dimension(:,:,:) :: tsm
53 real(kind=kind_real), pointer, dimension(:,:,:) :: khl
54 real(kind=kind_real), pointer, dimension(:,:,:) :: khu
55 
56 isc = state%isc
57 iec = state%iec
58 jsc = state%jsc
59 jec = state%jec
60 npz = state%npz
61 
62 ! Allocate traj
63 allocate(self%u (isc:iec, jsc:jec, npz))
64 allocate(self%v (isc:iec, jsc:jec, npz))
65 allocate(self%ua (isc:iec, jsc:jec, npz))
66 allocate(self%va (isc:iec, jsc:jec, npz))
67 allocate(self%t (isc:iec, jsc:jec, npz))
68 allocate(self%delp (isc:iec, jsc:jec, npz))
69 allocate(self%qv (isc:iec, jsc:jec, npz))
70 allocate(self%qi (isc:iec, jsc:jec, npz))
71 allocate(self%ql (isc:iec, jsc:jec, npz))
72 allocate(self%o3 (isc:iec, jsc:jec, npz))
73 allocate(self%w (isc:iec, jsc:jec, npz))
74 allocate(self%delz (isc:iec, jsc:jec, npz))
75 allocate(self%qls (isc:iec, jsc:jec, npz))
76 allocate(self%qcn (isc:iec, jsc:jec, npz))
77 allocate(self%cfcn (isc:iec, jsc:jec, npz))
78 allocate(self%phis (isc:iec, jsc:jec))
79 allocate(self%frocean(isc:iec, jsc:jec))
80 allocate(self%frland (isc:iec, jsc:jec))
81 allocate(self%varflt (isc:iec, jsc:jec))
82 allocate(self%ustar (isc:iec, jsc:jec))
83 allocate(self%bstar (isc:iec, jsc:jec))
84 allocate(self%zpbl (isc:iec, jsc:jec))
85 allocate(self%cm (isc:iec, jsc:jec))
86 allocate(self%ct (isc:iec, jsc:jec))
87 allocate(self%cq (isc:iec, jsc:jec))
88 allocate(self%kcbl (isc:iec, jsc:jec))
89 allocate(self%ts (isc:iec, jsc:jec))
90 allocate(self%khl (isc:iec, jsc:jec))
91 allocate(self%khu (isc:iec, jsc:jec))
92 
93 !Initialize all to zero incase not in state
94 self%u = 0.0_kind_real
95 self%v = 0.0_kind_real
96 self%ua = 0.0_kind_real
97 self%va = 0.0_kind_real
98 self%t = 0.0_kind_real
99 self%delp = 0.0_kind_real
100 self%qv = 0.0_kind_real
101 self%qi = 0.0_kind_real
102 self%ql = 0.0_kind_real
103 self%o3 = 0.0_kind_real
104 self%w = 0.0_kind_real
105 self%delz = 0.0_kind_real
106 self%qls = 0.0_kind_real
107 self%qcn = 0.0_kind_real
108 self%cfcn = 0.0_kind_real
109 self%phis = 0.0_kind_real
110 self%frocean = 0.0_kind_real
111 self%frland = 0.0_kind_real
112 self%varflt = 0.0_kind_real
113 self%ustar = 0.0_kind_real
114 self%bstar = 0.0_kind_real
115 self%zpbl = 0.0_kind_real
116 self%cm = 0.0_kind_real
117 self%ct = 0.0_kind_real
118 self%cq = 0.0_kind_real
119 self%kcbl = 0.0_kind_real
120 self%ts = 0.0_kind_real
121 self%khl = 0.0_kind_real
122 self%khu = 0.0_kind_real
123 
124 ! Copy mandatory parts of the trajecotry
125 allocate(u_tmp(isc:iec , jsc:jec+1, npz))
126 allocate(v_tmp(isc:iec+1, jsc:jec , npz))
127 
128 call state%get_field('ud' , u_tmp )
129 call state%get_field('vd' , v_tmp )
130 call state%get_field('t' , self%t )
131 call state%get_field('delp', self%delp )
132 call state%get_field('sphum' , self%qv )
133 
134 self%u = u_tmp(isc:iec, jsc:jec, :)
135 self%v = v_tmp(isc:iec, jsc:jec, :)
136 
137 deallocate(u_tmp, v_tmp)
138 
139 ! Copy optional parts of the trajecotry (Rank 3)
140 if (state%has_field('ua' )) call state%get_field('ua' , self%ua )
141 if (state%has_field('va' )) call state%get_field('va' , self%va )
142 if (state%has_field('ice_wat')) call state%get_field('ice_wat', self%qi )
143 if (state%has_field('liq_wat')) call state%get_field('liq_wat', self%ql )
144 if (state%has_field('o3mr' )) call state%get_field('o3mr' , self%o3 )
145 if (state%has_field('w' )) call state%get_field('w' , self%w )
146 if (state%has_field('delz' )) call state%get_field('delz' , self%delz)
147 if (state%has_field('qls' )) call state%get_field('qls' , self%qls )
148 if (state%has_field('qcn' )) call state%get_field('qcn' , self%qcn )
149 if (state%has_field('cfcn' )) call state%get_field('cfcn' , self%cfcn)
150 
151 ! Copy optional parts of the trajecotry (Rank 2)
152 if (state%has_field('phis')) then
153  call state%get_field('phis', phis)
154  self%phis = phis(:,:,1)
155 endif
156 if (state%has_field('frocean')) then
157  call state%get_field('frocean', frocean)
158  self%frocean = frocean(:,:,1)
159 endif
160 if (state%has_field('frland')) then
161  call state%get_field('frland', frland)
162  self%frland = frland(:,:,1)
163 endif
164 if (state%has_field('varflt')) then
165  call state%get_field('varflt', varflt)
166  self%varflt = varflt(:,:,1)
167 endif
168 if (state%has_field('ustar')) then
169  call state%get_field('ustar', ustar)
170  self%ustar = ustar(:,:,1)
171 endif
172 if (state%has_field('bstar')) then
173  call state%get_field('bstar', bstar)
174  self%bstar = bstar(:,:,1)
175 endif
176 if (state%has_field('zpbl')) then
177  call state%get_field('zpbl', zpbl)
178  self%zpbl = zpbl(:,:,1)
179 endif
180 if (state%has_field('cm')) then
181  call state%get_field('cm', cm)
182  self%cm = cm(:,:,1)
183 endif
184 if (state%has_field('ct')) then
185  call state%get_field('ct', ct)
186  self%ct = ct(:,:,1)
187 endif
188 if (state%has_field('cq')) then
189  call state%get_field('cq', cq)
190  self%cq = cq(:,:,1)
191 endif
192 if (state%has_field('kcbl')) then
193  call state%get_field('kcbl', kcbl)
194  self%kcbl = kcbl(:,:,1)
195 endif
196 if (state%has_field('tsm')) then
197  call state%get_field('tsm', tsm)
198  self%ts = tsm(:,:,1)
199 endif
200 if (state%has_field('khl')) then
201  call state%get_field('khl', khl)
202  self%khl = khl(:,:,1)
203 endif
204 if (state%has_field('khu')) then
205  call state%get_field('khu', khu)
206  self%khu = khu(:,:,1)
207 endif
208 
209 end subroutine set
210 
211 ! --------------------------------------------------------------------------------------------------
212 
213 subroutine wipe(self)
214 
215 implicit none
216 type(fv3jedi_traj), pointer :: self
217 
218 call deallocate_traj(self)
219 
220 end subroutine wipe
221 
222 ! --------------------------------------------------------------------------------------------------
223 
224 end module fv3jedi_traj_mod
fv3jedi_state_mod::fv3jedi_state
Fortran derived type to hold FV3JEDI state.
Definition: fv3jedi_state_mod.F90:30
fv3jedi_state_mod
Definition: fv3jedi_state_mod.F90:6
fv3jedi_traj_mod
Definition: fv3jedi_traj_mod.f90:6
fv3jedi_traj_mod::wipe
subroutine, public wipe(self)
Definition: fv3jedi_traj_mod.f90:214
fv3jedi_kinds_mod::kind_real
integer, parameter, public kind_real
Definition: fv3jedi_kinds_mod.f90:14
fv3jedi_kinds_mod
Definition: fv3jedi_kinds_mod.f90:6
fv3jedi_traj_mod::set
subroutine, public set(self, state)
Definition: fv3jedi_traj_mod.f90:30