FV3 Bundle
fv_control_tlmadm.F90
Go to the documentation of this file.
1 !***********************************************************************
2 !* GNU General Public License *
3 !* This file is a part of fvGFS. *
4 !* *
5 !* fvGFS is free software; you can redistribute it and/or modify it *
6 !* and are expected to follow the terms of the GNU General Public *
7 !* License as published by the Free Software Foundation; either *
8 !* version 2 of the License, or (at your option) any later version. *
9 !* *
10 !* fvGFS is distributed in the hope that it will be useful, but *
11 !* WITHOUT ANY WARRANTY; without even the implied warranty of *
12 !* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
13 !* General Public License for more details. *
14 !* *
15 !* For the full text of the GNU General Public License, *
16 !* write to: Free Software Foundation, Inc., *
17 !* 675 Mass Ave, Cambridge, MA 02139, USA. *
18 !* or see: http://www.gnu.org/licenses/gpl.html *
19 !***********************************************************************
20 !
21 !----------------
22 ! FV contro panel
23 !----------------
24 
25 !Prepare the FV_AtmP derived type that holds the perturbation variables and the
26 !coefficients used for advection, remapping and damping in the tangent linear
27 !and adjoint versions of FV3.
28 
30 
33  use fms_mod, only: open_namelist_file, check_nml_error, close_file
34  use mpp_mod, only: stdlog, mpp_pe, mpp_root_pe
35 
36  implicit none
37  private
38 
39  integer, public :: ngrids = 1
40 
41 !Convenience pointer to AtmP(n)
42  logical, pointer :: split_hord
43  integer, pointer :: hord_mt_pert
44  integer, pointer :: hord_vt_pert
45  integer, pointer :: hord_tm_pert
46  integer, pointer :: hord_dp_pert
47  integer, pointer :: hord_tr_pert
48  logical, pointer :: split_kord
49  integer, pointer :: kord_mt_pert
50  integer, pointer :: kord_wz_pert
51  integer, pointer :: kord_tm_pert
52  integer, pointer :: kord_tr_pert
53  logical, pointer :: split_damp
54  logical, pointer :: do_vort_damp_pert
55  integer, pointer :: nord_pert
56  real, pointer :: dddmp_pert
57  real, pointer :: d2_bg_pert
58  real, pointer :: d4_bg_pert
59  real, pointer :: vtdm4_pert
60  real, pointer :: d2_bg_k1_pert
61  real, pointer :: d2_bg_k2_pert
62  real, pointer :: d2_bg_ks_pert
63  logical, pointer :: split_damp_tr
64  integer, pointer :: nord_tr_pert
65  real, pointer :: trdm2_pert
66  integer, pointer :: n_sponge_pert
67  logical, pointer :: hord_ks_pert
68  integer, pointer :: hord_mt_ks_pert
69  integer, pointer :: hord_vt_ks_pert
70  integer, pointer :: hord_tm_ks_pert
71  integer, pointer :: hord_dp_ks_pert
72  integer, pointer :: hord_tr_ks_pert
73  logical, pointer :: hord_ks_traj
74  integer, pointer :: hord_mt_ks_traj
75  integer, pointer :: hord_vt_ks_traj
76  integer, pointer :: hord_tm_ks_traj
77  integer, pointer :: hord_dp_ks_traj
78  integer, pointer :: hord_tr_ks_traj
79 
80 
82 
83  contains
84 
85 !-------------------------------------------------------------------------------
86 
87  subroutine fv_init_pert(Atm, AtmP)
88 
89  type(fv_atmos_type), allocatable, intent(inout), target :: atm(:)
90  type(fv_atmos_pert_type), allocatable, intent(inout), target :: atmp(:)
91 
92  integer :: n, ntilesme
93 
94  allocate(atmp(ngrids))
95 
96  call run_setup_pert(atmp,atm)
97 
98  ntilesme = size(atmp(:))
99 
100  do n=1,ntilesme
101 
102  call allocate_fv_atmos_pert_type( atmp(n), atm(n)%bd%isd, atm(n)%bd%ied, atm(n)%bd%jsd, atm(n)%bd%jed, &
103  atm(n)%bd%isc, atm(n)%bd%iec, atm(n)%bd%jsc, atm(n)%bd%jec, &
104  atm(n)%flagstruct%npz, atm(n)%flagstruct%ncnst )
105 
106  enddo
107 
108  end subroutine fv_init_pert
109 
110 !-------------------------------------------------------------------------------
111 
112  subroutine fv_end_pert(AtmP)
114  type(fv_atmos_pert_type), intent(inout) :: atmp(:)
115 
116  integer :: n, ntilesme
117 
118  ntilesme = size(atmp(:))
119 
120  do n=1,ntilesme
121 
122  call deallocate_fv_atmos_pert_type(atmp(n))
123 
124  enddo
125 
126  end subroutine fv_end_pert
127 
128 !-------------------------------------------------------------------------------
129 
130  subroutine setup_pointers_pert(AtmP)
132  type(fv_atmos_pert_type), intent(INOUT), target :: AtmP
133 
134  !Linearized model pointers
135  split_hord => atmp%flagstruct%split_hord
136  hord_mt_pert => atmp%flagstruct%hord_mt_pert
137  hord_vt_pert => atmp%flagstruct%hord_vt_pert
138  hord_tm_pert => atmp%flagstruct%hord_tm_pert
139  hord_dp_pert => atmp%flagstruct%hord_dp_pert
140  hord_tr_pert => atmp%flagstruct%hord_tr_pert
141  split_kord => atmp%flagstruct%split_kord
142  kord_mt_pert => atmp%flagstruct%kord_mt_pert
143  kord_wz_pert => atmp%flagstruct%kord_wz_pert
144  kord_tm_pert => atmp%flagstruct%kord_tm_pert
145  kord_tr_pert => atmp%flagstruct%kord_tr_pert
146  split_damp => atmp%flagstruct%split_damp
147  nord_pert => atmp%flagstruct%nord_pert
148  dddmp_pert => atmp%flagstruct%dddmp_pert
149  d2_bg_pert => atmp%flagstruct%d2_bg_pert
150  d4_bg_pert => atmp%flagstruct%d4_bg_pert
151  do_vort_damp_pert => atmp%flagstruct%do_vort_damp_pert
152  d2_bg_k1_pert => atmp%flagstruct%d2_bg_k1_pert
153  d2_bg_k2_pert => atmp%flagstruct%d2_bg_k2_pert
154  d2_bg_ks_pert => atmp%flagstruct%d2_bg_ks_pert
155  vtdm4_pert => atmp%flagstruct%vtdm4_pert
156  split_damp_tr => atmp%flagstruct%split_damp_tr
157  nord_tr_pert => atmp%flagstruct%nord_tr_pert
158  trdm2_pert => atmp%flagstruct%trdm2_pert
159  n_sponge_pert => atmp%flagstruct%n_sponge_pert
160  hord_ks_pert => atmp%flagstruct%hord_ks_pert
161  hord_mt_ks_pert => atmp%flagstruct%hord_mt_ks_pert
162  hord_vt_ks_pert => atmp%flagstruct%hord_vt_ks_pert
163  hord_tm_ks_pert => atmp%flagstruct%hord_tm_ks_pert
164  hord_dp_ks_pert => atmp%flagstruct%hord_dp_ks_pert
165  hord_tr_ks_pert => atmp%flagstruct%hord_tr_ks_pert
166  hord_ks_traj => atmp%flagstruct%hord_ks_traj
167  hord_mt_ks_traj => atmp%flagstruct%hord_mt_ks_traj
168  hord_vt_ks_traj => atmp%flagstruct%hord_vt_ks_traj
169  hord_tm_ks_traj => atmp%flagstruct%hord_tm_ks_traj
170  hord_dp_ks_traj => atmp%flagstruct%hord_dp_ks_traj
171  hord_tr_ks_traj => atmp%flagstruct%hord_tr_ks_traj
172 
173  end subroutine setup_pointers_pert
174 
175 !-------------------------------------------------------------------------------
176 
177  subroutine run_setup_pert(AtmP,Atm)
179  type(fv_atmos_pert_type), intent(inout), target :: AtmP(:)
180  type(fv_atmos_type), intent(inout), target :: Atm(:)
181 
182  integer :: f_unit, n, ierr, ios, unit
183  character(len=80) :: nested_grid_filename
184 
185  namelist /fv_core_pert_nml/split_hord, hord_mt_pert, hord_vt_pert, hord_tm_pert, hord_dp_pert, hord_tr_pert, &
189  n_sponge_pert, &
192 
193  do n=1,size(atmp)
194 
195  call setup_pointers_pert(atmp(n))
196 
197  if (size(atmp) == 1) then
198  f_unit = open_namelist_file('inputpert.nml')
199  else if (n == 1) then
200  f_unit = open_namelist_file('inputpert.nml')
201  else
202  write(nested_grid_filename,'(A10, I2.2, A4)') 'input_nest_pert', n, '.nml'
203  f_unit = open_namelist_file(nested_grid_filename)
204  endif
205 
206  !Read linearized FVCORE namelist
207  rewind(f_unit)
208  read (f_unit,fv_core_pert_nml,iostat=ios)
209  ierr = check_nml_error(ios,'fv_core_pert_nml')
210 
211  call close_file(f_unit)
212 
213  unit = stdlog()
214  write(unit, nml=fv_core_pert_nml)
215 
216  !Unless specfied the trajectory uses the coeffs suitable for the perts
217  if (.not. atmp(n)%flagstruct%split_damp) then
218  atm(n)%flagstruct%nord = atmp(n)%flagstruct%nord_pert
219  atm(n)%flagstruct%dddmp = atmp(n)%flagstruct%dddmp_pert
220  atm(n)%flagstruct%d2_bg = atmp(n)%flagstruct%d2_bg_pert
221  atm(n)%flagstruct%d4_bg = atmp(n)%flagstruct%d4_bg_pert
222  atm(n)%flagstruct%do_vort_damp = atmp(n)%flagstruct%do_vort_damp_pert
223  atm(n)%flagstruct%vtdm4 = atmp(n)%flagstruct%vtdm4_pert
224  atm(n)%flagstruct%d2_bg_k1 = atmp(n)%flagstruct%d2_bg_k1_pert
225  atm(n)%flagstruct%d2_bg_k2 = atmp(n)%flagstruct%d2_bg_k2_pert
226  endif
227 
228  !Unless specfied the trajectory uses the coeffs suitable for the perts
229  if (.not. atmp(n)%flagstruct%split_damp_tr) then
230  atm(n)%flagstruct%nord_tr = atmp(n)%flagstruct%nord_tr_pert
231  atm(n)%flagstruct%trdm2 = atmp(n)%flagstruct%trdm2_pert
232  endif
233 
234  !Unless specfied the trajectory uses hord suitable for the perts
235  if (.not. atmp(n)%flagstruct%split_hord) then
236  atm(n)%flagstruct%hord_mt = atmp(n)%flagstruct%hord_mt_pert
237  atm(n)%flagstruct%hord_vt = atmp(n)%flagstruct%hord_vt_pert
238  atm(n)%flagstruct%hord_tm = atmp(n)%flagstruct%hord_tm_pert
239  atm(n)%flagstruct%hord_dp = atmp(n)%flagstruct%hord_dp_pert
240  atm(n)%flagstruct%hord_tr = atmp(n)%flagstruct%hord_tr_pert
241  endif
242 
243  !Unless specfied the trajectory uses hord suitable for the perts
244  if (.not. atmp(n)%flagstruct%split_kord) then
245  atm(n)%flagstruct%kord_mt = atmp(n)%flagstruct%kord_mt_pert
246  atm(n)%flagstruct%kord_wz = atmp(n)%flagstruct%kord_wz_pert
247  atm(n)%flagstruct%kord_tm = atmp(n)%flagstruct%kord_tm_pert
248  atm(n)%flagstruct%kord_tr = atmp(n)%flagstruct%kord_tr_pert
249  endif
250 
251  if (mpp_pe() == mpp_root_pe()) then
252 
253  print*, ''
254  print*, '|-----------------------------------------------|'
255  print*, '| Advection, remapping and damping coefficients |'
256  print*, '|-----------------------------------------------|'
257  print*, ''
258  print*, ' Splitting (off for speed, on for accuracy)'
259  print*, ' split_hord = ', split_hord
260  print*, ' split_kord = ', split_kord
261  print*, ' split_damp = ', split_damp
262  print*, ' split_damp_tr = ', split_damp_tr
263  print*, ''
264  print*, ' Advection of the trajectory'
265  print*, ' hord_mt = ', atm(n)%flagstruct%hord_mt
266  print*, ' hord_vt = ', atm(n)%flagstruct%hord_vt
267  print*, ' hord_tm = ', atm(n)%flagstruct%hord_tm
268  print*, ' hord_dp = ', atm(n)%flagstruct%hord_dp
269  print*, ' hord_tr = ', atm(n)%flagstruct%hord_tr
270  print*, ''
271  print*, ' Advection of the perturbations'
272  print*, ' hord_mt_pert = ', atmp(n)%flagstruct%hord_mt_pert
273  print*, ' hord_vt_pert = ', atmp(n)%flagstruct%hord_vt_pert
274  print*, ' hord_tm_pert = ', atmp(n)%flagstruct%hord_tm_pert
275  print*, ' hord_dp_pert = ', atmp(n)%flagstruct%hord_dp_pert
276  print*, ' hord_tr_pert = ', atmp(n)%flagstruct%hord_tr_pert
277  print*, ''
278  print*, ' Number of sponge layers for the perturbations'
279  print*, ' n_sponge_pert = ', atmp(n)%flagstruct%n_sponge_pert
280  print*, ''
281  print*, ' Sponge layer advection of the trajecotry'
282  print*, ' hord_ks_traj = ' , atmp(n)%flagstruct%hord_ks_traj
283  print*, ' hord_mt_ks_traj = ', atmp(n)%flagstruct%hord_mt_ks_traj
284  print*, ' hord_vt_ks_traj = ', atmp(n)%flagstruct%hord_vt_ks_traj
285  print*, ' hord_tm_ks_traj = ', atmp(n)%flagstruct%hord_tm_ks_traj
286  print*, ' hord_dp_ks_traj = ', atmp(n)%flagstruct%hord_dp_ks_traj
287  print*, ' hord_tr_ks_traj = ', atmp(n)%flagstruct%hord_tr_ks_traj
288  print*, ' '
289  print*, ' Sponge layer advection of the perturbations'
290  print*, ' hord_ks_pert = ' , atmp(n)%flagstruct%hord_ks_pert
291  print*, ' hord_mt_ks_pert = ', atmp(n)%flagstruct%hord_mt_ks_pert
292  print*, ' hord_vt_ks_pert = ', atmp(n)%flagstruct%hord_vt_ks_pert
293  print*, ' hord_tm_ks_pert = ', atmp(n)%flagstruct%hord_tm_ks_pert
294  print*, ' hord_dp_ks_pert = ', atmp(n)%flagstruct%hord_dp_ks_pert
295  print*, ' hord_tr_ks_pert = ', atmp(n)%flagstruct%hord_tr_ks_pert
296  print*, ''
297  print*, ' Remapping of the trajectory'
298  print*, ' kord_mt = ', atm(n)%flagstruct%kord_mt
299  print*, ' kord_wz = ', atm(n)%flagstruct%kord_wz
300  print*, ' kord_tm = ', atm(n)%flagstruct%kord_tm
301  print*, ' kord_tr = ', atm(n)%flagstruct%kord_tr
302  print*, ''
303  print*, ' Remapping of the perturbations'
304  print*, ' kord_mt_pert = ', atmp(n)%flagstruct%kord_mt_pert
305  print*, ' kord_wz_pert = ', atmp(n)%flagstruct%kord_wz_pert
306  print*, ' kord_tm_pert = ', atmp(n)%flagstruct%kord_tm_pert
307  print*, ' kord_tr_pert = ', atmp(n)%flagstruct%kord_tr_pert
308  print*, ''
309  print*, ' Dynamics damping, trajectory'
310  print*, ' nord = ', atm(n)%flagstruct%nord
311  print*, ' dddmp = ', atm(n)%flagstruct%dddmp
312  print*, ' d2_bg = ', atm(n)%flagstruct%d2_bg
313  print*, ' d4_bg = ', atm(n)%flagstruct%d4_bg
314  print*, ' do_vort_damp = ', atm(n)%flagstruct%do_vort_damp
315  print*, ' vtdm4 = ', atm(n)%flagstruct%vtdm4
316  print*, ' d2_bg_k1 = ', atm(n)%flagstruct%d2_bg_k1
317  print*, ' d2_bg_k2 = ', atm(n)%flagstruct%d2_bg_k2
318 
319  print*, ''
320  print*, ' Dynamics damping, perturbations'
321  print*, ' nord_pert = ', atmp(n)%flagstruct%nord_pert
322  print*, ' dddmp_pert = ', atmp(n)%flagstruct%dddmp_pert
323  print*, ' d2_bg_pert = ', atmp(n)%flagstruct%d2_bg_pert
324  print*, ' d4_bg_pert = ', atmp(n)%flagstruct%d4_bg_pert
325  print*, ' do_vort_damp_pert = ', atmp(n)%flagstruct%do_vort_damp_pert
326  print*, ' vtdm4_pert = ', atmp(n)%flagstruct%vtdm4_pert
327  print*, ' d2_bg_k1_pert = ', atmp(n)%flagstruct%d2_bg_k1_pert
328  print*, ' d2_bg_k2_pert = ', atmp(n)%flagstruct%d2_bg_k2_pert
329  print*, ' d2_bg_ks_pert = ', atmp(n)%flagstruct%d2_bg_ks_pert
330  print*, ''
331  print*, ' Tracer damping, trajectory'
332  print*, ' nord_tr = ', atm(n)%flagstruct%nord_tr
333  print*, ' trdm2 = ', atm(n)%flagstruct%trdm2
334  print*, ''
335  print*, ' Tracer damping, perturbations'
336  print*, ' nord_tr_pert = ', atmp(n)%flagstruct%nord_tr_pert
337  print*, ' trdm2_pert = ', atmp(n)%flagstruct%trdm2_pert
338  print*, ''
339  print*, '|-----------------------------------------------|'
340  print*, ''
341 
342  endif
343 
344  enddo
345 
346  end subroutine run_setup_pert
347 
348 end module fv_control_tlmadm_mod
Definition: fms.F90:20
logical, pointer hord_ks_pert
integer, pointer kord_wz_pert
integer, pointer hord_vt_ks_pert
integer, pointer hord_vt_ks_traj
subroutine allocate_fv_atmos_pert_type(AtmP, isd, ied, jsd, jed, is, ie, js, je, npz, ncnst)
subroutine deallocate_fv_atmos_pert_type(AtmP)
integer, pointer hord_tm_ks_traj
logical, pointer split_damp_tr
integer, pointer hord_tr_ks_traj
integer, pointer kord_tm_pert
integer, pointer hord_tr_ks_pert
subroutine, public fv_end_pert(AtmP)
integer, pointer hord_tr_pert
Definition: mpp.F90:39
integer function, public check_nml_error(IOSTAT, NML_NAME)
Definition: fms.F90:658
integer, pointer hord_dp_ks_pert
integer, pointer hord_mt_pert
integer, pointer hord_mt_ks_pert
integer, pointer hord_dp_pert
logical, pointer do_vort_damp_pert
integer, pointer nord_tr_pert
logical, pointer split_hord
integer, pointer hord_tm_pert
integer, pointer n_sponge_pert
subroutine, public fv_init_pert(Atm, AtmP)
integer, pointer kord_tr_pert
subroutine run_setup_pert(AtmP, Atm)
integer, pointer hord_vt_pert
logical, pointer split_kord
integer, pointer hord_mt_ks_traj
integer, pointer nord_pert
integer, pointer hord_tm_ks_pert
logical, pointer hord_ks_traj
subroutine setup_pointers_pert(AtmP)
integer, pointer hord_dp_ks_traj
integer, pointer kord_mt_pert
logical, pointer split_damp