14 use fckit_log_module,
only : fckit_log
28 real(kind_real),
allocatable,
dimension(:) :: lat
29 real(kind_real),
allocatable,
dimension(:) :: lon
30 type(datetime),
allocatable,
dimension(:) :: time
31 integer,
allocatable,
dimension(:) :: indx
40 type(
ufo_locs),
intent(inout) :: self
41 type(c_ptr),
value,
intent(in) :: obss
42 integer,
intent(in) :: nlocs
43 real(kind_real),
intent(in) :: lats(nlocs)
44 real(kind_real),
intent(in) :: lons(nlocs)
47 character(len=20),
allocatable :: fstring(:)
48 type(datetime),
dimension(:),
allocatable :: date_time
51 allocate(self%lat(nlocs), self%lon(nlocs), self%time(nlocs))
52 allocate(self%indx(nlocs))
56 allocate(fstring(nlocs))
58 if (obsspace_has(obss,
"MetaData",
"datetime"))
then
59 allocate(date_time(nlocs))
60 call obsspace_get_db(obss,
"MetaData",
"datetime", date_time)
62 call datetime_to_string(date_time(n), fstring(n))
66 fstring(:) =
"9999-09-09T09:09:09Z"
70 call datetime_create(fstring(n), self%time(n))
82 type(
ufo_locs),
intent(inout) :: self
83 integer,
intent(in) :: nlocs
85 character(len=20) :: fstring
92 allocate(self%lat(nlocs), self%lon(nlocs), self%time(nlocs), self%indx(nlocs))
95 fstring=
"9999-09-09T09:09:09Z"
97 call datetime_create(fstring, self%time(n))
108 type(
ufo_locs),
intent(inout) :: self
111 self%nlocs = other%nlocs
112 self%max_indx = other%max_indx
114 allocate(self%lat (self%nlocs))
115 allocate(self%lon (self%nlocs))
116 allocate(self%time(self%nlocs))
117 allocate(self%indx(self%nlocs))
121 self%time = other%time
122 self%indx = other%indx
130 type(
ufo_locs),
intent(inout) :: self
132 if (
allocated(self%lat))
deallocate(self%lat)
133 if (
allocated(self%lon))
deallocate(self%lon)
134 if (
allocated(self%time))
deallocate(self%time)
135 if (
allocated(self%indx))
deallocate(self%indx)
145 type(
ufo_locs),
intent(inout) :: self
148 type(
ufo_locs) :: temp_self, temp_other
149 character(255) :: message
152 if ((self%max_indx < 0) .OR. (other%max_indx < 0))
then
153 write(message,
'(A, A, I6, A, I6)') &
154 'ufo_locs_concatenate: either self or other needs to be constructed valid indices ', &
155 ' self%max_indx =', self%max_indx,
' other%max_indx = ', other%max_indx
156 call fckit_log%info(message)
161 temp_self%nlocs = self%nlocs
162 temp_self%max_indx = self%max_indx
163 allocate(temp_self%lat(self%nlocs), temp_self%lon(self%nlocs), &
164 temp_self%time(self%nlocs), temp_self%indx(self%nlocs))
166 temp_self%lat(:) = self%lat(:)
167 temp_self%lon(:) = self%lon(:)
168 temp_self%indx(:) = self%indx(:)
170 temp_self%time(n) = self%time(n)
174 temp_other%nlocs = other%nlocs
175 temp_other%max_indx = other%max_indx
176 allocate(temp_other%lat(other%nlocs), temp_other%lon(other%nlocs), &
177 temp_other%time(other%nlocs), temp_other%indx(other%nlocs))
179 temp_other%lat(:) = other%lat(:)
180 temp_other%lon(:) = other%lon(:)
181 temp_other%indx(:) = other%indx(:)
182 do n = 1, other%nlocs
183 temp_other%time(n) = other%time(n)
190 self%nlocs = temp_self%nlocs + temp_other%nlocs
191 allocate(self%lat(self%nlocs), self%lon(self%nlocs), &
192 self%time(self%nlocs), self%indx(self%nlocs))
194 self%lat(1:temp_self%nlocs) = temp_self%lat(1:temp_self%nlocs)
195 self%lat(temp_self%nlocs+1:) = temp_other%lat(1:temp_other%nlocs)
197 self%lon(1:temp_self%nlocs) = temp_self%lon(1:temp_self%nlocs)
198 self%lon(temp_self%nlocs+1:) = temp_other%lon(1:temp_other%nlocs)
200 do n = 1, temp_self%nlocs
201 self%time(n) = temp_self%time(n)
203 do n = 1, temp_other%nlocs
204 self%time(temp_self%nlocs + n) = temp_other%time(n)
207 self%indx(1:temp_self%nlocs) = temp_self%indx(1:temp_self%nlocs)
208 do n = 1, temp_other%nlocs
209 self%indx(temp_self%nlocs + n) = temp_other%indx(n) + &
212 self%max_indx = temp_self%max_indx + temp_other%max_indx
226 type(
ufo_locs),
intent(inout) :: self
227 type(c_ptr),
value,
intent(in) :: obss
228 type(datetime),
intent(in) :: t1, t2
232 character(len=*),
parameter:: &
233 myname =
"ufo_locs_init"
236 integer,
dimension(:),
allocatable :: tw_indx
237 real(kind_real),
dimension(:),
allocatable :: lon, lat
238 type(datetime),
dimension(:),
allocatable :: date_time
241 nlocs = obsspace_get_nlocs(obss)
243 allocate(date_time(nlocs), lon(nlocs), lat(nlocs))
245 call obsspace_get_db(obss,
"MetaData",
"datetime", date_time)
248 allocate(tw_indx(nlocs))
251 if (date_time(i) > t1 .and. date_time(i) <= t2)
then
252 tw_nlocs = tw_nlocs + 1
253 tw_indx(tw_nlocs) = i
257 call obsspace_get_db(obss,
"MetaData",
"longitude", lon)
258 call obsspace_get_db(obss,
"MetaData",
"latitude", lat)
263 self%lon(i) = lon(tw_indx(i))
264 self%lat(i) = lat(tw_indx(i))
265 self%time(i) = date_time(tw_indx(i))
267 self%indx = tw_indx(1:tw_nlocs)
270 call datetime_delete(date_time(i))
272 deallocate(date_time, lon, lat, tw_indx)
274 self%max_indx = obsspace_get_gnlocs(obss)
284 type(datetime),
intent(in) :: t1
285 type(datetime),
intent(in) :: t2
286 logical,
allocatable,
intent(inout) :: time_mask(:)
294 if (t1>t2)
call abor1_ftn(
"ufo_locs_mod.ufo_locs_time_mask t2 is not greater than or equal to t1")
297 if (.not.
allocated(time_mask))
allocate(time_mask(self%nlocs))
304 if (self%time(n) > t1 .and. self%time(n) <= t2 )
then
305 time_mask(n) = .true.