9 use fckit_configuration_module,
only: fckit_configuration
40 real(kind=
kind_real),
allocatable :: qsattraj(:,:,:)
49 subroutine create(self, geom, bg, fg, conf)
56 type(fckit_configuration),
intent(in) :: conf
60 real(kind=
kind_real),
pointer :: delp(:,:,:)
63 call bg%get_field(
't' , t)
64 call bg%get_field(
'sphum' , q)
65 call bg%get_field(
'delp', delp)
68 allocate(self%tvtraj (geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz))
69 call t_to_tv(geom,t,q,self%tvtraj)
72 allocate(self%ttraj (geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz))
76 allocate(self%qtraj (geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz))
80 allocate(self%qsattraj(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz))
83 call get_qsat(geom,delp,t,q,self%qsattraj)
94 if (
allocated(self%tvtraj))
deallocate(self%tvtraj)
95 if (
allocated(self%ttraj))
deallocate(self%ttraj)
96 if (
allocated(self%qtraj))
deallocate(self%qtraj)
97 if (
allocated(self%qsattraj))
deallocate(self%qsattraj)
112 character(len=field_clen),
allocatable :: fields_to_do(:)
113 real(kind=
kind_real),
pointer :: field_ptr(:,:,:)
117 real(kind=
kind_real),
pointer,
dimension(:,:,:) :: psip
118 real(kind=
kind_real),
pointer,
dimension(:,:,:) :: chip
119 real(kind=
kind_real),
allocatable,
dimension(:,:,:) :: psi
120 real(kind=
kind_real),
allocatable,
dimension(:,:,:) :: chi
121 real(kind=
kind_real),
allocatable,
dimension(:,:,:) :: ua
122 real(kind=
kind_real),
allocatable,
dimension(:,:,:) :: va
126 real(kind=
kind_real),
pointer,
dimension(:,:,:) :: rh
127 real(kind=
kind_real),
allocatable,
dimension(:,:,:) :: q
131 real(kind=
kind_real),
pointer,
dimension(:,:,:) :: tv
132 real(kind=
kind_real),
allocatable,
dimension(:,:,:) :: t
136 call copy_subset(dxc%fields, dxa%fields, fields_to_do)
140 if (.not.
allocated(fields_to_do))
return
145 if (dxc%has_field(
'psi') .and. dxc%has_field(
'chi'))
then
146 call dxc%get_field(
'psi', psip)
147 call dxc%get_field(
'chi', chip)
148 allocate(psi(geom%isd:geom%ied,geom%jsd:geom%jed,1:geom%npz))
149 allocate(chi(geom%isd:geom%ied,geom%jsd:geom%jed,1:geom%npz))
152 psi(geom%isc:geom%iec,geom%jsc:geom%jec,:) = psip(geom%isc:geom%iec,geom%jsc:geom%jec,:)
153 chi(geom%isc:geom%iec,geom%jsc:geom%jec,:) = chip(geom%isc:geom%iec,geom%jsc:geom%jec,:)
154 allocate(ua(geom%isc:geom%iec,geom%jsc:geom%jec,geom%npz))
155 allocate(va(geom%isc:geom%iec,geom%jsc:geom%jec,geom%npz))
163 if (dxc%has_field(
'rh'))
then
164 call dxc%get_field(
'rh', rh)
165 allocate(q(geom%isc:geom%iec,geom%jsc:geom%jec,geom%npz))
173 if (dxc%has_field(
't'))
then
174 call dxc%get_field(
't', t)
176 elseif (dxc%has_field(
'tv') .and. have_q)
then
177 call dxc%get_field(
'tv', tv)
178 allocate(t(geom%isc:geom%iec,geom%jsc:geom%jec,geom%npz))
179 call tv_to_t_tl(geom, self%tvtraj, tv, self%qtraj, q, t)
186 do f = 1,
size(fields_to_do)
188 call dxa%get_field(trim(fields_to_do(f)), field_ptr)
190 select case (trim(fields_to_do(f)))
194 if (.not. have_uava)
call field_fail(fields_to_do(f))
195 field_ptr(geom%isc:geom%iec,geom%jsc:geom%jec,:) = ua(geom%isc:geom%iec,geom%jsc:geom%jec,:)
199 if (.not. have_uava)
call field_fail(fields_to_do(f))
200 field_ptr(geom%isc:geom%iec,geom%jsc:geom%jec,:) = va(geom%isc:geom%iec,geom%jsc:geom%jec,:)
204 if (.not. have_t)
call field_fail(fields_to_do(f))
209 if (.not. have_q)
call field_fail(fields_to_do(f))
214 call abor1_ftn(
"fv3jedi_lvc_model2geovals_mod.multiply unknown field: "//trim(fields_to_do(f)) &
215 //
". Not in input field and no transform case specified.")
223 dxa%calendar_type = dxc%calendar_type
224 dxa%date_init = dxc%date_init
239 character(len=field_clen),
allocatable :: fields_to_do(:)
240 real(kind=
kind_real),
pointer :: field_ptr(:,:,:)
243 logical :: have_psichi
244 real(kind=
kind_real),
pointer,
dimension(:,:,:) :: ua
245 real(kind=
kind_real),
pointer,
dimension(:,:,:) :: va
246 real(kind=
kind_real),
allocatable,
dimension(:,:,:) :: psi
247 real(kind=
kind_real),
allocatable,
dimension(:,:,:) :: chi
251 real(kind=
kind_real),
pointer,
dimension(:,:,:) :: q
252 real(kind=
kind_real),
allocatable,
dimension(:,:,:) :: rh
256 real(kind=
kind_real),
pointer,
dimension(:,:,:) :: t
257 real(kind=
kind_real),
allocatable,
dimension(:,:,:) :: tv
265 call copy_subset(dxa%fields, dxc%fields, fields_to_do)
269 if (.not.
allocated(fields_to_do))
return
274 if (dxa%has_field(
't') .and. dxa%has_field(
'sphum'))
then
275 call dxa%get_field(
't', t)
276 call dxa%get_field(
'sphum', q)
277 allocate(tv(geom%isc:geom%iec,geom%jsc:geom%jec,geom%npz))
279 call tv_to_t_ad(geom, self%tvtraj, tv, self%qtraj, q, t)
286 if (dxa%has_field(
'sphum'))
then
287 call dxa%get_field(
'sphum', q)
288 allocate(rh(geom%isc:geom%iec,geom%jsc:geom%jec,geom%npz))
296 have_psichi = .false.
297 if (dxa%has_field(
'ua') .and. dxa%has_field(
'va'))
then
298 call dxa%get_field(
'ua', ua)
299 call dxa%get_field(
'va', va)
300 allocate(psi(geom%isd:geom%ied,geom%jsd:geom%jed,1:geom%npz))
301 allocate(chi(geom%isd:geom%ied,geom%jsd:geom%jed,1:geom%npz))
310 do f = 1,
size(fields_to_do)
312 call dxc%get_field(trim(fields_to_do(f)), field_ptr)
314 select case (trim(fields_to_do(f)))
318 if (.not. have_psichi)
call field_fail(fields_to_do(f))
319 field_ptr(geom%isc:geom%iec,geom%jsc:geom%jec,:) = psi(geom%isc:geom%iec,geom%jsc:geom%jec,:)
323 if (.not. have_psichi)
call field_fail(fields_to_do(f))
324 field_ptr(geom%isc:geom%iec,geom%jsc:geom%jec,:) = chi(geom%isc:geom%iec,geom%jsc:geom%jec,:)
328 if (.not. have_tv)
call field_fail(fields_to_do(f))
333 if (.not. have_rh)
call field_fail(fields_to_do(f))
338 call abor1_ftn(
"fv3jedi_lvc_model2geovals_mod.multiplyadjoint unknown field: "//trim(fields_to_do(f)) &
339 //
". Not in input field and no transform case specified.")
347 dxc%calendar_type = dxa%calendar_type
348 dxc%date_init = dxa%date_init
366 do f = 1,
size(dxc%fields)
367 dxc%fields(f)%array = dxa%fields(f)%array
372 dxc%calendar_type = dxa%calendar_type
373 dxc%date_init = dxa%date_init
391 do f = 1,
size(dxc%fields)
392 dxa%fields(f)%array = dxc%fields(f)%array
397 dxa%calendar_type = dxc%calendar_type
398 dxa%date_init = dxc%date_init
412 real(kind=
kind_real),
intent(in) :: psi(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
413 real(kind=
kind_real),
intent(in) :: chi(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
414 real(kind=
kind_real),
intent(in) :: tv(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
415 real(kind=
kind_real),
intent(in) :: rh(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
418 real(kind=
kind_real),
intent(inout) :: ua(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
419 real(kind=
kind_real),
intent(inout) :: va(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
420 real(kind=
kind_real),
intent(inout) :: t(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
421 real(kind=
kind_real),
intent(inout) :: q(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
424 real(kind=
kind_real),
intent(in) :: tvt(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
425 real(kind=
kind_real),
intent(in) :: qt(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
426 real(kind=
kind_real),
intent(in) :: qsat(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
428 real(kind=
kind_real),
allocatable,
dimension(:,:,:) :: psi_dom, chi_dom
437 allocate(psi_dom(geom%isd:geom%ied,geom%jsd:geom%jed,1:geom%npz))
438 allocate(chi_dom(geom%isd:geom%ied,geom%jsd:geom%jed,1:geom%npz))
439 psi_dom = 0.0_kind_real
440 chi_dom = 0.0_kind_real
442 psi_dom(geom%isc:geom%iec,geom%jsc:geom%jec,:) = psi
443 chi_dom(geom%isc:geom%iec,geom%jsc:geom%jec,:) = chi
447 deallocate(psi_dom, chi_dom)
471 real(kind=
kind_real),
intent(inout) :: psi(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
472 real(kind=
kind_real),
intent(inout) :: chi(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
473 real(kind=
kind_real),
intent(inout) :: tv(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
474 real(kind=
kind_real),
intent(inout) :: rh(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
477 real(kind=
kind_real),
intent(inout) :: ua(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
478 real(kind=
kind_real),
intent(inout) :: va(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
479 real(kind=
kind_real),
intent(inout) :: t(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
480 real(kind=
kind_real),
intent(inout) :: q(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
483 real(kind=
kind_real),
intent(in) :: tvt(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
484 real(kind=
kind_real),
intent(in) :: qt(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
485 real(kind=
kind_real),
intent(in) :: qsat(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
487 real(kind=
kind_real),
allocatable,
dimension(:,:,:) :: psi_dom, chi_dom
504 allocate(psi_dom(geom%isd:geom%ied,geom%jsd:geom%jed,1:geom%npz))
505 allocate(chi_dom(geom%isd:geom%ied,geom%jsd:geom%jed,1:geom%npz))
506 psi_dom = 0.0_kind_real
507 chi_dom = 0.0_kind_real
511 psi = psi_dom(geom%isc:geom%iec,geom%jsc:geom%jec,:)
512 chi = chi_dom(geom%isc:geom%iec,geom%jsc:geom%jec,:)
514 deallocate(psi_dom, chi_dom)