10 use fckit_configuration_module,
only: fckit_configuration
11 use fckit_log_module,
only: fckit_log
14 use kinds,
only : kind_real
17 use gnssro_mod_transform,
only: geometric2geop
21 use mpas_derived_types
22 use mpas_field_routines
23 use mpas_kind_types,
only: rkind
24 use mpas_pool_routines
42 type(mpas_pool_type),
pointer :: trajectory => null()
58 subroutine create(self, geom, bg, fg, conf)
64 type(fckit_configuration),
intent(in) :: conf
68 character(len=MAXVARLEN),
parameter :: &
70 [ character(len=maxvarlen) :: &
77 call da_template_pool(geom, self%trajectory,
size(trajfieldnames), trajfieldnames)
79 do ivar = 1,
size(trajfieldnames)
80 call bg%copy_to(trajfieldnames(ivar), self%trajectory)
89 if (
associated(self%trajectory))
then
90 call mpas_pool_destroy_pool(self%trajectory)
103 type(mpas_pool_type),
pointer :: mFields_tl, gFields_tl
104 type(mpas_pool_data_type),
pointer :: gdata
107 real(kind=kind_real),
dimension(:),
pointer :: ptrr1_a
108 real(kind=kind_real),
dimension(:,:),
pointer :: ptrr2_a, ptrr2_b, traj_ptrr2_a, traj_ptrr2_b
109 real(kind=kind_real),
dimension(:,:),
allocatable :: r2, trajr2
112 character(len=MAXVARLEN) :: geovar
113 integer :: nCells, nVertLevels, nVertLevelsP1
117 real(kind=kind_real),
allocatable :: plevels(:,:)
120 mfields_tl => dxm % subFields
121 gfields_tl => dxg % subFields
122 ncells = geom%nCellsSolve
123 nvertlevels = geom%nVertLevels
124 nvertlevelsp1 = geom%nVertLevelsP1
127 allocate(plevels(1:nvertlevelsp1,1:ncells))
128 call mpas_pool_get_array(self%trajectory,
'pressure', ptrr2_a)
129 call mpas_pool_get_array(self%trajectory,
'surface_pressure', ptrr1_a)
131 ncells, nvertlevels, plevels)
134 do ivar = 1, dxg % nf
136 geovar = trim(dxg % fldnames(ivar))
138 if (geom%has_identity(geovar))
then
141 if (dxm%has(geom%identity(geovar)))
then
142 call dxm%copy_to(geom%identity(geovar), dxg, geovar)
146 'WARNING: mpasjedi_lvc_model2geovars::multiply: '&
147 &
'increment missing identity field for geovar => ', trim(geovar)
148 call fckit_log%warning(
message)
152 call dxg%get(geovar, gdata)
154 select case (trim(geovar))
158 call dxm%get(
'temperature', ptrr2_a)
159 call dxm%get(
'spechum', ptrr2_b)
162 allocate(r2(1:nvertlevels,1:ncells))
163 allocate(trajr2(1:nvertlevels,1:ncells))
166 call mpas_pool_get_array(self%trajectory,
'temperature', traj_ptrr2_a)
167 call mpas_pool_get_array(self%trajectory,
'spechum', traj_ptrr2_b)
168 call q_to_w(traj_ptrr2_b(:,1:ncells), trajr2(:,1:ncells))
171 call q_to_w_tl(ptrr2_b(:,1:ncells), traj_ptrr2_b(:,1:ncells), r2(:,1:ncells))
172 call tw_to_tv_tl(ptrr2_a(:,1:ncells), r2(:,1:ncells), &
173 traj_ptrr2_a(:,1:ncells), trajr2(:,1:ncells), &
174 gdata%r2%array(:,1:ncells))
177 deallocate(r2, trajr2)
181 call dxm%get(
'spechum', ptrr2_a)
184 call mpas_pool_get_array(self%trajectory,
'spechum', traj_ptrr2_a)
187 call q_to_w_tl(ptrr2_a(:,1:ncells), traj_ptrr2_a(:,1:ncells), gdata%r2%array(:,1:ncells))
199 call q_fields_tl(
'qc', mfields_tl, gdata%r2, plevels, ncells, nvertlevels)
202 call q_fields_tl(
'qi', mfields_tl, gdata%r2, plevels, ncells, nvertlevels)
205 call q_fields_tl(
'qr', mfields_tl, gdata%r2, plevels, ncells, nvertlevels)
208 call q_fields_tl(
'qs', mfields_tl, gdata%r2, plevels, ncells, nvertlevels)
211 call q_fields_tl(
'qg', mfields_tl, gdata%r2, plevels, ncells, nvertlevels)
214 call q_fields_tl(
'qh', mfields_tl, gdata%r2, plevels, ncells, nvertlevels)
236 type(mpas_pool_type),
pointer :: mFields_ad, gFields_ad
237 type(mpas_pool_data_type),
pointer :: gdata
240 real(kind=kind_real),
dimension(:),
pointer :: ptrr1_a
241 real(kind=kind_real),
dimension(:,:),
pointer :: ptrr2_a, ptrr2_b, traj_ptrr2_a, traj_ptrr2_b
242 real(kind=kind_real),
dimension(:,:),
allocatable :: r2, trajr2
245 character(len=MAXVARLEN) :: geovar
246 integer :: nCells, nVertLevels, nVertLevelsP1
250 real(kind=kind_real),
allocatable :: plevels(:,:)
253 mfields_ad => dxm % subFields
254 gfields_ad => dxg % subFields
255 ncells = geom%nCellsSolve
256 nvertlevels = geom%nVertLevels
257 nvertlevelsp1 = geom%nVertLevelsP1
260 allocate(plevels(1:nvertlevelsp1,1:ncells))
261 call mpas_pool_get_array(self%trajectory,
'pressure', ptrr2_a)
262 call mpas_pool_get_array(self%trajectory,
'surface_pressure', ptrr1_a)
264 ncells, nvertlevels, plevels)
267 do ivar = 1, dxg % nf
269 geovar = trim(dxg % fldnames(ivar))
271 if (geom%has_identity(geovar))
then
274 if (dxm%has(geom%identity(geovar)))
then
275 call dxm%copy_to_ad(geom%identity(geovar), dxg, geovar)
279 'WARNING: mpasjedi_lvc_model2geovars::multiplyadjoint: '&
280 &
'increment missing identity field for geovar => ', trim(geovar)
281 call fckit_log%warning(
message)
285 call dxg%get(geovar, gdata)
287 select case (trim(geovar))
291 call dxm%get(
'temperature', ptrr2_a)
292 call dxm%get(
'spechum', ptrr2_b)
295 allocate(r2(1:nvertlevels,1:ncells))
296 allocate(trajr2(1:nvertlevels,1:ncells))
299 call mpas_pool_get_array(self%trajectory,
'temperature', traj_ptrr2_a)
300 call mpas_pool_get_array(self%trajectory,
'spechum', traj_ptrr2_b)
301 call q_to_w(traj_ptrr2_b(:,1:ncells), trajr2(:,1:ncells))
305 call tw_to_tv_ad(ptrr2_a(:,1:ncells), r2(:,1:ncells), &
306 traj_ptrr2_a(:,1:ncells), trajr2(:,1:ncells), &
307 gdata%r2%array(:,1:ncells) )
308 call q_to_w_ad(ptrr2_b(:,1:ncells), traj_ptrr2_b(:,1:ncells), r2(:,1:ncells))
311 deallocate(r2, trajr2)
315 call dxm%get(
'spechum', ptrr2_a)
318 allocate(r2(1:nvertlevels,1:ncells))
321 call mpas_pool_get_array(self%trajectory,
'spechum', traj_ptrr2_a)
327 r2 = gdata%r2%array(1:nvertlevels,1:ncells)
334 call q_to_w_ad(ptrr2_a(:,1:ncells), traj_ptrr2_a(:,1:ncells), r2(:,1:ncells))
340 call q_fields_ad(
'qc', mfields_ad, gdata%r2, plevels, ncells, nvertlevels)
343 call q_fields_ad(
'qi', mfields_ad, gdata%r2, plevels, ncells, nvertlevels)
346 call q_fields_ad(
'qr', mfields_ad, gdata%r2, plevels, ncells, nvertlevels)
349 call q_fields_ad(
'qs', mfields_ad, gdata%r2, plevels, ncells, nvertlevels)
352 call q_fields_ad(
'qg', mfields_ad, gdata%r2, plevels, ncells, nvertlevels)
355 call q_fields_ad(
'qh', mfields_ad, gdata%r2, plevels, ncells, nvertlevels)
elemental subroutine, public q_to_w(specific_humidity, mixing_ratio)
subroutine, public pressure_half_to_full(pressure, zgrid, surface_pressure, nC, nV, pressure_f)
subroutine, public q_fields_tl(mqName, modelFields_tl, qGeo_tl, plevels, nCells, nVertLevels)
subroutine, public q_fields_ad(mqName, modelFields_ad, qGeo_ad, plevels, nCells, nVertLevels)
elemental subroutine, public q_to_w_tl(specific_humidity_tl, sh_traj, mixing_ratio_tl)
elemental subroutine, public q_to_w_ad(specific_humidity_ad, sh_traj, mixing_ratio_ad)
elemental subroutine, public tw_to_tv_tl(temperature_tl, mixing_ratio_tl, t_traj, m_traj, virtual_temperature_tl)
elemental subroutine, public tw_to_tv_ad(temperature_ad, mixing_ratio_ad, t_traj, m_traj, virtual_temperature_ad)
character(max_string) message
subroutine, public da_template_pool(geom, templatePool, nf, fieldnames)
Subset a pool from fields described in geom.
real(kind=kind_real), parameter mpas_jedi_thousand_kr
real(kind=kind_real), parameter mpas_jedi_zero_kr
subroutine create(self, geom, bg, fg, conf)
subroutine multiplyadjoint(self, geom, dxg, dxm)
subroutine multiply(self, geom, dxm, dxg)
Fortran derived type to hold MPAS field.
Fortran derived type to hold geometry definition.