FV3 Bundle
fv3jedi_lm_mod.F90
Go to the documentation of this file.
2 
5 
8 
9 !> Top level for fv3jedi linearized model
10 
11 !> Combines fv3 tlm/adm with the GEOS tlm/adm physics
12 !> All developed by NASA's Global Modeling and Assimilation Office
13 !> daniel.holdaway@nasa.gov, Code 610.1 Goddard Space Flight Center,
14 !> Greenbelt, MD 20771 USA
15 
16 implicit none
17 private
18 public :: fv3jedi_lm_type
19 
22  type(fv3jedi_lm_pert) :: pert
23  type(fv3jedi_lm_traj) :: traj
24  type(fv3jedi_lm_dynamics_type) :: fv3jedi_lm_dynamics
25  type(fv3jedi_lm_physics_type) :: fv3jedi_lm_physics
26  contains
27  procedure :: create
28  procedure :: init_nl
29  procedure :: init_tl
30  procedure :: init_ad
31  procedure :: step_nl
32  procedure :: step_tl
33  procedure :: step_ad
34  procedure :: final_nl
35  procedure :: final_tl
36  procedure :: final_ad
37  procedure :: delete
38 end type
39 
40 contains
41 
42 ! ------------------------------------------------------------------------------
43 
44 subroutine create(self,dt,npx,npy,npz,ptop,ak,bk)
45 
46  implicit none
47 
48  class(fv3jedi_lm_type), intent(inout) :: self
49 
50  real(kind=kind_real), intent(in) :: dt, ptop
51  integer, intent(in) :: npx,npy,npz
52  real(kind=kind_real), intent(in) :: ak(npz+1), bk(npz+1)
53 
54  self%conf%dt = dt
55  self%conf%ptop = ptop
56 
57  allocate(self%conf%ak(npz+1))
58  allocate(self%conf%bk(npz+1))
59  self%conf%ak = ak
60  self%conf%bk = bk
61 
62  !Call dynamics create, provides the model grid
63  call self%fv3jedi_lm_dynamics%create(self%conf)
64 
65  !Make grid available to all components
66  self%conf%isc = self%fv3jedi_lm_dynamics%FV_Atm(1)%bd%isc
67  self%conf%iec = self%fv3jedi_lm_dynamics%FV_Atm(1)%bd%iec
68  self%conf%jsc = self%fv3jedi_lm_dynamics%FV_Atm(1)%bd%jsc
69  self%conf%jec = self%fv3jedi_lm_dynamics%FV_Atm(1)%bd%jec
70  self%conf%isd = self%fv3jedi_lm_dynamics%FV_Atm(1)%bd%isd
71  self%conf%ied = self%fv3jedi_lm_dynamics%FV_Atm(1)%bd%ied
72  self%conf%jsd = self%fv3jedi_lm_dynamics%FV_Atm(1)%bd%jsd
73  self%conf%jed = self%fv3jedi_lm_dynamics%FV_Atm(1)%bd%jed
74  self%conf%npx = self%fv3jedi_lm_dynamics%FV_Atm(1)%npx
75  self%conf%npy = self%fv3jedi_lm_dynamics%FV_Atm(1)%npy
76  self%conf%npz = self%fv3jedi_lm_dynamics%FV_Atm(1)%npz
77  self%conf%hydrostatic = self%fv3jedi_lm_dynamics%FV_Atm(1)%flagstruct%hydrostatic
78 
79  !Physics grid
80  self%conf%im = (self%conf%iec-self%conf%isc+1)
81  self%conf%jm = (self%conf%jec-self%conf%jsc+1)
82  self%conf%lm = self%conf%npz
83 
84  !All physics switch
85  if (self%conf%do_phy_trb == 0 .and. self%conf%do_phy_mst == 0) self%conf%do_phy = 0
86 
87  !Call the physics create
88  if (self%conf%do_phy == 1) call self%fv3jedi_lm_physics%create(self%conf)
89 
90  !Sanity checks
91  if ((self%conf%npx .ne. npx) .or. (self%conf%npy .ne. npy) .or. (self%conf%npz .ne. npz) ) then
92  if (self%conf%rpe) print*, 'fv3jedi tlm/adm problem: dynamics creating different grid than inputs created for'
93  call exit(1)
94  endif
95 
96  !Allocate main traj and pert structures
97  call allocate_traj(self%traj,self%conf%isc,self%conf%iec,self%conf%jsc,self%conf%jec,&
98  self%conf%npz,self%conf%hydrostatic,self%conf%do_phy_mst)
99  call allocate_pert(self%pert,self%conf%isc,self%conf%iec,self%conf%jsc,self%conf%jec,self%conf%npz,self%conf%hydrostatic)
100 
101 endsubroutine create
102 
103 ! ------------------------------------------------------------------------------
104 
105 subroutine init_nl(self)
107  implicit none
108 
109  class(fv3jedi_lm_type), intent(inout) :: self
110 
111  if (self%conf%do_dyn == 1) call self%fv3jedi_lm_dynamics%init_nl(self%conf,self%pert,self%traj)
112  if (self%conf%do_phy == 1) call self%fv3jedi_lm_physics%init_nl(self%conf,self%pert,self%traj)
113 
114 endsubroutine init_nl
115 
116 ! ------------------------------------------------------------------------------
117 
118 subroutine init_tl(self)
120  implicit none
121 
122  class(fv3jedi_lm_type), intent(inout) :: self
123 
124  call ipert_to_zero(self%pert)
125 
126  if (self%conf%do_dyn == 1) call self%fv3jedi_lm_dynamics%init_tl(self%conf,self%pert,self%traj)
127  if (self%conf%do_phy == 1) call self%fv3jedi_lm_physics%init_tl(self%conf,self%pert,self%traj)
128 
129 endsubroutine init_tl
130 
131 ! ------------------------------------------------------------------------------
132 
133 subroutine init_ad(self)
135  implicit none
136 
137  class(fv3jedi_lm_type), intent(inout) :: self
138 
139  call ipert_to_zero(self%pert)
140 
141  if (self%conf%do_dyn == 1) call self%fv3jedi_lm_dynamics%init_ad(self%conf,self%pert,self%traj)
142  if (self%conf%do_phy == 1) call self%fv3jedi_lm_physics%init_ad(self%conf,self%pert,self%traj)
143 
144 endsubroutine init_ad
145 
146 ! ------------------------------------------------------------------------------
147 
148 subroutine step_nl(self)
150  implicit none
151 
152  class(fv3jedi_lm_type), intent(inout) :: self
153 
154  if (self%conf%do_dyn == 1) call self%fv3jedi_lm_dynamics%step_nl(self%conf,self%traj)
155  if (self%conf%do_phy == 1) call self%fv3jedi_lm_physics%step_nl(self%conf,self%traj)
156 
157 endsubroutine step_nl
158 
159 ! ------------------------------------------------------------------------------
160 
161 subroutine step_tl(self)
163  implicit none
164 
165  class(fv3jedi_lm_type), intent(inout) :: self
166 
167  call ipert_to_zero(self%pert)
168  if (self%conf%do_dyn == 1) call self%fv3jedi_lm_dynamics%step_tl(self%conf,self%traj,self%pert)
169  if (self%conf%do_phy == 1) call self%fv3jedi_lm_physics%step_tl(self%conf,self%traj,self%pert)
170  call ipert_to_zero(self%pert)
171 
172 endsubroutine step_tl
173 
174 ! ------------------------------------------------------------------------------
175 
176 subroutine step_ad(self)
178  implicit none
179 
180  class(fv3jedi_lm_type), intent(inout) :: self
181 
182  call ipert_to_zero(self%pert)
183  if (self%conf%do_phy == 1) call self%fv3jedi_lm_physics%step_ad(self%conf,self%traj,self%pert)
184  if (self%conf%do_dyn == 1) call self%fv3jedi_lm_dynamics%step_ad(self%conf,self%traj,self%pert)
185  call ipert_to_zero(self%pert)
186 
187 endsubroutine step_ad
188 
189 ! ------------------------------------------------------------------------------
190 
191 subroutine final_nl(self)
193  implicit none
194  class(fv3jedi_lm_type), intent(inout) :: self
195 
196 
197 endsubroutine final_nl
198 
199 ! ------------------------------------------------------------------------------
200 
201 subroutine final_tl(self)
203  implicit none
204  class(fv3jedi_lm_type), intent(inout) :: self
205 
206  call ipert_to_zero(self%pert)
207 
208 endsubroutine final_tl
209 
210 ! ------------------------------------------------------------------------------
211 
212 subroutine final_ad(self)
214  implicit none
215  class(fv3jedi_lm_type), intent(inout) :: self
216 
217  call ipert_to_zero(self%pert)
218 
219 endsubroutine final_ad
220 
221 ! ------------------------------------------------------------------------------
222 
223 subroutine delete(self)
225  implicit none
226 
227  class(fv3jedi_lm_type), intent(inout) :: self
228 
229  if (self%conf%do_dyn == 1) call self%fv3jedi_lm_dynamics%delete(self%conf)
230  if (self%conf%do_phy == 1) call self%fv3jedi_lm_physics%delete(self%conf)
231 
232  deallocate(self%conf%ak)
233  deallocate(self%conf%bk)
234 
235  call deallocate_traj(self%traj)
236  call deallocate_pert(self%pert)
237 
238 endsubroutine delete
239 
240 ! ------------------------------------------------------------------------------
241 
242 subroutine ipert_to_zero(pert)
244  !> Intenal part of pert to zero
245 
246  implicit none
247  type(fv3jedi_lm_pert), intent(inout) :: pert
248 
249  pert%ua = 0.0_kind_real
250  pert%va = 0.0_kind_real
251  pert%cfcn = 0.0_kind_real
252 
253 endsubroutine ipert_to_zero
254 
255 ! ------------------------------------------------------------------------------
256 
257 end module fv3jedi_lm_mod
subroutine step_nl(self)
subroutine final_ad(self)
Top level for fv3jedi linearized model.
subroutine step_tl(self)
subroutine, public allocate_traj(traj, isc, iec, jsc, jec, npz, hydrostatic, dpm)
Fortran derived type to hold the linearized model increment.
Definition: conf.py:1
subroutine, public deallocate_traj(traj)
subroutine step_ad(self)
subroutine init_tl(self)
subroutine, public delete(self)
Top level for fv3jedi linearized dynamical core.
subroutine, public deallocate_pert(pert)
Physics driver for fv3-jedi linearized model Just calls its children in turn if turned on...
Fortran derived type to hold the linearized model trajectory.
subroutine ipert_to_zero(pert)
subroutine final_nl(self)
subroutine init_nl(self)
Fortran derived type to hold the linearized model configuration.
subroutine final_tl(self)
subroutine init_ad(self)
subroutine, public create(self, geom, vars)
subroutine, public allocate_pert(pert, isc, iec, jsc, jec, npz, hydrostatic)