11 use fckit_mpi_module,
only: fckit_mpi_sum
12 use fckit_configuration_module,
only: fckit_configuration
13 use fckit_log_module,
only: fckit_log
16 use datetime_mod,
only: datetime, datetime_to_string
17 use kinds,
only: kind_real
20 use interpolatorbump_mod,
only: bump_interpolator
24 use ufo_geovals_mod,
only: ufo_geovals
29 use mpas_derived_types
30 use mpas_field_routines
31 use mpas_kind_types,
only: strkind
32 use mpas_pool_routines
51 real(kind=kind_real),
allocatable :: obs_field(:,:), mod_field(:,:)
52 logical(c_bool),
allocatable :: time_mask(:)
63 #define LISTED_TYPE mpasjedi_lineargetvalues
66 #include <oops/util/linkedList_i.f>
77 #include <oops/util/linkedList_c.f>
85 subroutine create(self, geom, locs, f_conf)
89 type(ufo_locations),
intent(in) :: locs
90 type(fckit_configuration),
intent(in) :: f_conf
92 integer :: nlocs, maxlevels
98 nlocs = locs % nlocs()
99 maxlevels = geom%nVertLevelsP1
101 if (
allocated(self%time_mask) .or.
allocated(self%obs_field) .or.
allocated(self%mod_field))
then
103 call abor1_ftn(
'--> mpasjedi_lineargetvalues::create subroutine called when member arrays already allocated.')
109 allocate(self%time_mask(nlocs))
110 allocate(self%obs_field(nlocs,maxlevels))
111 if (.not. self%use_bump_interp)
then
112 allocate(self%mod_field(geom%nCellsSolve, maxlevels))
128 if (
allocated(self%time_mask))
deallocate(self%time_mask)
129 if (
allocated(self%obs_field))
deallocate(self%obs_field)
130 if (
allocated(self%mod_field))
deallocate(self%mod_field)
142 type(datetime),
intent(in) :: t1
143 type(datetime),
intent(in) :: t2
144 type(ufo_locations),
intent(in) :: locs
145 type(ufo_geovals),
intent(inout) :: gom
147 character(len=*),
parameter :: myname =
'fill_geovals_tl'
149 integer :: jvar, jlev, ilev, jloc, nDims
150 integer :: nCells, nlevels, nlocs, nlocsg
152 type (mpas_pool_data_type),
pointer :: gdata
153 type (mpas_pool_iterator_type) :: poolItr
154 character (len=MAXVARLEN) :: geovar
156 logical :: allocateGeo
160 ncells = geom % nCellsSolve
161 nlocs = locs % nlocs()
165 call geom%f_comm%allreduce(nlocs,nlocsg,fckit_mpi_sum())
166 if (nlocsg == 0)
then
172 call locs%get_timemask(t1, t2, self%time_mask)
176 call mpas_pool_begin_iteration(inc%subFields)
177 do while ( mpas_pool_get_next_member(inc%subFields, poolitr) )
178 if (poolitr % memberType == mpas_pool_field)
then
180 geovar = trim(poolitr % memberName)
181 ndims = poolitr % nDims
182 call inc%get(geovar, gdata)
184 jvar = ufo_vars_getindex(gom%variables, geovar)
185 if ( jvar < 1 ) cycle
189 nlevels = gom%geovals(jvar)%nval
191 if (poolitr % dataType == mpas_pool_real)
then
193 if (self%use_bump_interp)
then
194 call self%bumpinterp%apply(gdata%r1%array(1:ncells), &
197 call self%unsinterp%apply(gdata%r1%array(1:ncells), &
200 else if (ndims == 2)
then
201 if (self%use_bump_interp)
then
202 call self%bumpinterp%apply(gdata%r2%array(1:nlevels,1:ncells), &
203 self%obs_field(:,1:nlevels), &
207 self%mod_field(:,1:nlevels) = transpose(gdata%r2%array(1:nlevels,1:ncells))
209 call self%unsinterp%apply(self%mod_field(:,jlev), &
210 self%obs_field(:,jlev))
215 call abor1_ftn(
'--> fill_geovals_tl: not a real field')
219 ilev = nlevels - jlev + 1
222 if (self%time_mask(jloc)) gom%geovals(jvar)%vals(ilev,jloc) = self%obs_field(jloc,jlev)
235 type(datetime),
intent(in) :: t1
236 type(datetime),
intent(in) :: t2
237 type(ufo_locations),
intent(in) :: locs
238 type(ufo_geovals),
intent(in) :: gom
240 character(len=*),
parameter :: myname =
'fill_geovals_ad'
242 integer :: jvar, jlev, ilev, jloc, nDims
243 integer :: nCells, nlevels, nlocs, nlocsg
245 type (mpas_pool_data_type),
pointer :: gdata
246 type (mpas_pool_iterator_type) :: poolItr
247 character (len=MAXVARLEN) :: geovar
251 ncells = geom % nCellsSolve
252 nlocs = locs % nlocs()
253 write(
message,*)
'fill_geovals_ad: nlocs : ',nlocs
258 call locs%get_timemask(t1, t2, self%time_mask)
262 call geom%f_comm%allreduce(nlocs,nlocsg,fckit_mpi_sum())
263 if (nlocsg == 0)
then
272 call mpas_pool_begin_iteration(inc%subFields)
273 do while ( mpas_pool_get_next_member(inc%subFields, poolitr) )
274 if (poolitr % memberType == mpas_pool_field)
then
276 geovar = trim(poolitr % memberName)
277 ndims = poolitr % nDims
278 call inc%get(geovar, gdata)
280 jvar = ufo_vars_getindex(gom%variables, geovar)
281 if ( jvar < 1 ) cycle
285 write(
message,*)
'fill_geovals_ad: nDims, geovar =', ndims , geovar
287 nlevels = gom%geovals(jvar)%nval
291 ilev = nlevels - jlev + 1
293 if (self%time_mask(jloc))
then
294 self%obs_field(jloc,jlev) = gom%geovals(jvar)%vals(ilev, jloc)
298 if (poolitr % dataType == mpas_pool_real)
then
299 if (self%use_bump_interp)
then
301 call self%bumpinterp%apply_ad(self%obs_field(:,1), &
302 gdata%r1%array(1:ncells))
303 else if (ndims == 2)
then
304 call self%bumpinterp%apply_ad(self%obs_field(:,1:nlevels), &
305 gdata%r2%array(1:nlevels,1:ncells), &
310 call self%unsinterp%apply_ad(self%mod_field(:,jlev), &
311 self%obs_field(:,jlev))
314 gdata%r1%array(1:ncells) = self%mod_field(:,1)
315 else if (ndims == 2)
then
316 gdata%r2%array(1:nlevels,1:ncells) = transpose(self%mod_field(:,1:nlevels))
320 call abor1_ftn(
'--> fill_geovals_ad: not a real field')
real(kind=kind_real), parameter mpas_jedi_zero_kr
character(len=1024) message
subroutine create(self, geom, locs, f_conf)
GetValues class 'create' logic.
subroutine, public getvalues_base_create(self, geom, locs, f_conf)
Linked list implementation.
subroutine, public getvalues_base_delete(self)
GetValues base class 'delete' logic.
subroutine delete(self)
GetValues class 'delete' logic.
integer, parameter max_string
subroutine fill_geovals_ad(self, geom, inc, t1, t2, locs, gom)
type(registry_t), public mpas_lineargetvalues_registry
Linked list interface - defines registry_t type.
subroutine fill_geovals_tl(self, geom, inc, t1, t2, locs, gom)
Fortran derived type to hold MPAS field.
Fortran derived type to hold geometry definition.