FV3 Bundle
ufo_geovals_interface.F90
Go to the documentation of this file.
1 !
2 ! (C) Copyright 2017-2018 UCAR
3 !
4 ! This software is licensed under the terms of the Apache Licence Version 2.0
5 ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6 !
8 
9 use iso_c_binding
11 use ioda_locs_mod
13 use ufo_vars_mod
14 use kinds
15 
16 implicit none
17 
18 public :: ufo_geovals_registry
19 
20 private
21 integer, parameter :: max_string=800
22 
23 #define LISTED_TYPE ufo_geovals
24 
25 !> Linked list interface - defines registry_t type
26 #include "linkedList_i.f"
27 
28 !> Global registry
29 type(registry_t) :: ufo_geovals_registry
30 
31 ! ------------------------------------------------------------------------------
32 contains
33 ! ------------------------------------------------------------------------------
34 !> Linked list implementation
35 #include "linkedList_c.f"
36 ! ------------------------------------------------------------------------------
37 
38 subroutine ufo_geovals_setup_c(c_key_self, c_key_locs, c_vars) bind(c,name='ufo_geovals_setup_f90')
39 use config_mod
40 implicit none
41 integer(c_int), intent(in) :: c_key_self
42 integer(c_int), intent(in) :: c_key_locs
43 type(c_ptr), intent(in) :: c_vars
44 
45 type(ufo_geovals), pointer :: self
46 type(ioda_locs), pointer :: locs
47 type(ufo_vars) :: vars
48 
49 call ufo_geovals_registry%init()
50 call ufo_geovals_registry%add(c_key_self)
51 call ufo_geovals_registry%get(c_key_self, self)
52 
53 call ioda_locs_registry%get(c_key_locs,locs)
54 
55 call ufo_vars_setup(vars, c_vars)
56 
57 call ufo_geovals_init(self)
58 call ufo_geovals_setup(self, vars, locs%nlocs)
59 
60 end subroutine ufo_geovals_setup_c
61 
62 ! ------------------------------------------------------------------------------
63 !> Copy one GeoVaLs object into another
64 
65 subroutine ufo_geovals_copy_c(c_key_self, c_key_other) bind(c,name='ufo_geovals_copy_f90')
66 implicit none
67 integer(c_int), intent(in) :: c_key_self
68 integer(c_int), intent(in) :: c_key_other
69 type(ufo_geovals), pointer :: self
70 type(ufo_geovals), pointer :: other
71 
72 call ufo_geovals_registry%get(c_key_self, self)
73 call ufo_geovals_registry%get(c_key_other, other)
74 
75 call ufo_geovals_copy(self, other)
76 
77 end subroutine ufo_geovals_copy_c
78 
79 ! ------------------------------------------------------------------------------
80 
81 subroutine ufo_geovals_analytic_init_c(c_key_self, c_key_locs, c_conf) bind(c,name='ufo_geovals_analytic_init_f90')
82 use config_mod
83 implicit none
84 integer(c_int), intent(in) :: c_key_self
85 integer(c_int), intent(in) :: c_key_locs
86 type(c_ptr), intent(in) :: c_conf
87 
88 type(ufo_geovals), pointer :: self
89 type(ioda_locs), pointer :: locs
90 character(len=30) :: ic
91 
92 call ufo_geovals_registry%get(c_key_self, self)
93 call ioda_locs_registry%get(c_key_locs,locs)
94 
95 ic = config_get_string(c_conf,len(ic),"analytic_init")
96 
97 call ufo_geovals_analytic_init(self,locs,ic)
98 
99 end subroutine ufo_geovals_analytic_init_c
100 
101 ! ------------------------------------------------------------------------------
102 
103 subroutine ufo_geovals_create_c(c_key_self) bind(c,name='ufo_geovals_create_f90')
105 implicit none
106 integer(c_int), intent(inout) :: c_key_self
107 
108 type(ufo_geovals), pointer :: self
109 
110 call ufo_geovals_registry%init()
111 call ufo_geovals_registry%add(c_key_self)
112 call ufo_geovals_registry%get(c_key_self, self)
113 
114 call ufo_geovals_init(self)
115 
116 end subroutine ufo_geovals_create_c
117 
118 ! ------------------------------------------------------------------------------
119 
120 subroutine ufo_geovals_delete_c(c_key_self) bind(c,name='ufo_geovals_delete_f90')
122 implicit none
123 integer(c_int), intent(inout) :: c_key_self
124 
125 type(ufo_geovals), pointer :: self
126 
127 call ufo_geovals_registry%get(c_key_self, self)
128 
129 call ufo_geovals_delete(self)
130 
131 call ufo_geovals_registry%remove(c_key_self)
132 
133 end subroutine ufo_geovals_delete_c
134 
135 ! ------------------------------------------------------------------------------
136 
137 subroutine ufo_geovals_setup_allocone_c(c_key_self, c_conf, c_vars) bind(c,name='ufo_geovals_setup_allocone_f90')
138 use config_mod
139 implicit none
140 integer(c_int), intent(in) :: c_key_self
141 type(c_ptr), intent(in) :: c_conf
142 type(c_ptr), intent(in) :: c_vars
143 
144 type(ufo_geovals), pointer :: self
145 type(ufo_vars) :: vars
146 integer :: nobs
147 
148 call ufo_geovals_registry%init()
149 call ufo_geovals_registry%add(c_key_self)
150 call ufo_geovals_registry%get(c_key_self, self)
151 
152 !> read variables
153 call ufo_vars_setup(vars, c_vars)
154 
155 ! allocate one
156 nobs = config_get_int(c_conf, "nobs")
157 call ufo_geovals_init(self)
158 call ufo_geovals_setup(self, vars, nobs)
159 call ufo_geovals_allocone(self)
160 
161 end subroutine ufo_geovals_setup_allocone_c
162 
163 ! ------------------------------------------------------------------------------
164 
165 subroutine ufo_geovals_zero_c(c_key_self) bind(c,name='ufo_geovals_zero_f90')
166 implicit none
167 integer(c_int), intent(in) :: c_key_self
168 type(ufo_geovals), pointer :: self
169 
170 call ufo_geovals_registry%get(c_key_self, self)
171 
172 call ufo_geovals_zero(self)
173 
174 end subroutine ufo_geovals_zero_c
175 
176 ! ------------------------------------------------------------------------------
177 
178 subroutine ufo_geovals_abs_c(c_key_self) bind(c,name='ufo_geovals_abs_f90')
179 implicit none
180 integer(c_int), intent(in) :: c_key_self
181 type(ufo_geovals), pointer :: self
182 
183 call ufo_geovals_registry%get(c_key_self, self)
184 
185 call ufo_geovals_abs(self)
186 
187 end subroutine ufo_geovals_abs_c
188 
189 ! ------------------------------------------------------------------------------
190 
191 subroutine ufo_geovals_rms_c(c_key_self,vrms) bind(c,name='ufo_geovals_rms_f90')
192 implicit none
193 integer(c_int), intent(in) :: c_key_self
194 real(c_double), intent(inout) :: vrms
195 type(ufo_geovals), pointer :: self
196 
197 call ufo_geovals_registry%get(c_key_self, self)
198 
199 call ufo_geovals_rms(self,vrms)
200 
201 end subroutine ufo_geovals_rms_c
202 
203 ! ------------------------------------------------------------------------------
204 
205 subroutine ufo_geovals_setup_random_c(c_key_self, c_conf, c_vars) bind(c,name='ufo_geovals_setup_random_f90')
206 use config_mod
207 implicit none
208 integer(c_int), intent(in) :: c_key_self
209 type(c_ptr), intent(in) :: c_conf
210 type(c_ptr), intent(in) :: c_vars
211 
212 type(ufo_geovals), pointer :: self
213 type(ufo_vars) :: vars
214 integer :: nobs
215 
216 call ufo_geovals_registry%init()
217 call ufo_geovals_registry%add(c_key_self)
218 call ufo_geovals_registry%get(c_key_self, self)
219 
220 !> read variables
221 call ufo_vars_setup(vars, c_vars)
222 
223 ! randomize
224 nobs = config_get_int(c_conf, "nobs")
225 call ufo_geovals_init(self)
226 call ufo_geovals_setup(self, vars, nobs)
227 call ufo_geovals_random(self)
228 
229 end subroutine ufo_geovals_setup_random_c
230 
231 ! ------------------------------------------------------------------------------
232 
233 subroutine ufo_geovals_random_c(c_key_self) bind(c,name='ufo_geovals_random_f90')
234 implicit none
235 integer(c_int), intent(in) :: c_key_self
236 type(ufo_geovals), pointer :: self
237 
238 call ufo_geovals_registry%get(c_key_self, self)
239 
240 call ufo_geovals_random(self)
241 
242 end subroutine ufo_geovals_random_c
243 
244 ! ------------------------------------------------------------------------------
245 
246 subroutine ufo_geovals_scalmult_c(c_key_self, zz) bind(c,name='ufo_geovals_scalmult_f90')
247 implicit none
248 integer(c_int), intent(in) :: c_key_self
249 real(c_double), intent(in) :: zz
250 type(ufo_geovals), pointer :: self
251 
252 call ufo_geovals_registry%get(c_key_self, self)
253 
254 call ufo_geovals_scalmult(self, zz)
255 
256 end subroutine ufo_geovals_scalmult_c
257 
258 ! ------------------------------------------------------------------------------
259 
260 subroutine ufo_geovals_assign_c(c_key_self, c_key_rhs) bind(c,name='ufo_geovals_assign_f90')
261 implicit none
262 integer(c_int), intent(in) :: c_key_self
263 integer(c_int), intent(in) :: c_key_rhs
264 type(ufo_geovals), pointer :: self
265 type(ufo_geovals), pointer :: rhs
266 
267 call ufo_geovals_registry%get(c_key_self, self)
268 call ufo_geovals_registry%get(c_key_rhs, rhs)
269 
270 call ufo_geovals_assign(self, rhs)
271 
272 end subroutine ufo_geovals_assign_c
273 
274 ! ------------------------------------------------------------------------------
275 
276 subroutine ufo_geovals_add_c(c_key_self, c_key_other) bind(c,name='ufo_geovals_add_f90')
277 implicit none
278 integer(c_int), intent(in) :: c_key_self
279 integer(c_int), intent(in) :: c_key_other
280 type(ufo_geovals), pointer :: self
281 type(ufo_geovals), pointer :: other
282 
283 call ufo_geovals_registry%get(c_key_self, self)
284 call ufo_geovals_registry%get(c_key_other, other)
285 
286 call ufo_geovals_add(self, other)
287 
288 end subroutine ufo_geovals_add_c
289 
290 ! ------------------------------------------------------------------------------
291 
292 subroutine ufo_geovals_diff_c(c_key_self, c_key_other) bind(c,name='ufo_geovals_diff_f90')
293 implicit none
294 integer(c_int), intent(in) :: c_key_self
295 integer(c_int), intent(in) :: c_key_other
296 type(ufo_geovals), pointer :: self
297 type(ufo_geovals), pointer :: other
298 
299 call ufo_geovals_registry%get(c_key_self, self)
300 call ufo_geovals_registry%get(c_key_other, other)
301 
302 call ufo_geovals_diff(self, other)
303 
304 end subroutine ufo_geovals_diff_c
305 
306 ! ------------------------------------------------------------------------------
307 
308 subroutine ufo_geovals_normalize_c(c_key_self, c_key_other) bind(c,name='ufo_geovals_normalize_f90')
309 implicit none
310 integer(c_int), intent(in) :: c_key_self
311 integer(c_int), intent(in) :: c_key_other
312 type(ufo_geovals), pointer :: self
313 type(ufo_geovals), pointer :: other
314 
315 call ufo_geovals_registry%get(c_key_self, self)
316 call ufo_geovals_registry%get(c_key_other, other)
317 
318 call ufo_geovals_normalize(self, other)
319 
320 end subroutine ufo_geovals_normalize_c
321 
322 ! ------------------------------------------------------------------------------
323 
324 subroutine ufo_geovals_dotprod_c(c_key_self, c_key_other, prod) bind(c,name='ufo_geovals_dotprod_f90')
325 implicit none
326 integer(c_int), intent(in) :: c_key_self, c_key_other
327 real(c_double), intent(inout) :: prod
328 type(ufo_geovals), pointer :: self, other
329 
330 call ufo_geovals_registry%get(c_key_self, self)
331 call ufo_geovals_registry%get(c_key_other, other)
332 
333 call ufo_geovals_dotprod(self, other, prod)
334 
335 end subroutine ufo_geovals_dotprod_c
336 
337 ! ------------------------------------------------------------------------------
338 
339 subroutine ufo_geovals_minmaxavg_c(c_key_self, kobs, pmin, pmax, prms) bind(c,name='ufo_geovals_minmaxavg_f90')
340 implicit none
341 integer(c_int), intent(in) :: c_key_self
342 integer(c_int), intent(inout) :: kobs
343 real(c_double), intent(inout) :: pmin, pmax, prms
344 type(ufo_geovals), pointer :: self
345 
346 call ufo_geovals_registry%get(c_key_self, self)
347 
348 call ufo_geovals_minmaxavg(self, kobs, pmin, pmax, prms)
349 
350 end subroutine ufo_geovals_minmaxavg_c
351 
352 ! ------------------------------------------------------------------------------
353 
354 subroutine ufo_geovals_maxloc_c(c_key_self, mxval, iobs, ivar) bind(c,name='ufo_geovals_maxloc_f90')
355 implicit none
356 integer(c_int), intent(in) :: c_key_self
357 real(c_double), intent(inout) :: mxval
358 integer(c_int), intent(inout) :: iobs, ivar
359 type(ufo_geovals), pointer :: self
360 
361 call ufo_geovals_registry%get(c_key_self, self)
362 
363 call ufo_geovals_maxloc(self, mxval, iobs, ivar)
364 
365 end subroutine ufo_geovals_maxloc_c
366 
367 ! ------------------------------------------------------------------------------
368 
369 subroutine ufo_geovals_read_file_c(c_key_self, c_conf, c_vars) bind(c,name='ufo_geovals_read_file_f90')
370 use config_mod
371 
372 implicit none
373 integer(c_int), intent(in) :: c_key_self
374 type(c_ptr), intent(in) :: c_conf
375 type(c_ptr), intent(in) :: c_vars
376 
377 type(ufo_geovals), pointer :: self
378 type(ufo_vars) :: vars
379 character(max_string) :: filename
380 
381 call ufo_geovals_registry%init()
382 call ufo_geovals_registry%add(c_key_self)
383 call ufo_geovals_registry%get(c_key_self, self)
384 
385 !> read variables
386 call ufo_vars_setup(vars, c_vars)
387 
388 ! read filename for config
389 filename = config_get_string(c_conf,len(filename),"filename")
390 
391 ! read geovals
392 call ufo_geovals_read_netcdf(self, filename, vars)
393 
394 end subroutine ufo_geovals_read_file_c
395 
396 ! ------------------------------------------------------------------------------
397 
398 subroutine ufo_geovals_write_file_c(c_key_self, c_conf) bind(c,name='ufo_geovals_write_file_f90')
399 use config_mod
400 implicit none
401 integer(c_int), intent(in) :: c_key_self
402 type(c_ptr), intent(in) :: c_conf
403 type(ufo_geovals), pointer :: self
404 
405 call ufo_geovals_registry%get(c_key_self, self)
406 
407 end subroutine ufo_geovals_write_file_c
408 
409 ! ------------------------------------------------------------------------------
410 
411 end module ufo_geovals_mod_c
subroutine ufo_geovals_rms_c(c_key_self, vrms)
subroutine, public ufo_geovals_delete(self)
subroutine, public ufo_geovals_minmaxavg(self, kobs, pmin, pmax, prms)
subroutine ufo_geovals_abs_c(c_key_self)
subroutine, public ufo_geovals_add(self, other)
Sum of two GeoVaLs objects.
subroutine ufo_geovals_minmaxavg_c(c_key_self, kobs, pmin, pmax, prms)
subroutine ufo_geovals_write_file_c(c_key_self, c_conf)
subroutine, public ufo_geovals_analytic_init(self, locs, ic)
Initialize a GeoVaLs object based on an analytic state.
subroutine, public ufo_geovals_init(self)
subroutine, public ufo_geovals_read_netcdf(self, filename, vars)
subroutine, public ufo_geovals_diff(self, other)
Difference between two GeoVaLs objects.
subroutine ufo_geovals_diff_c(c_key_self, c_key_other)
integer, parameter max_string
subroutine, public ufo_geovals_rms(self, vrms)
subroutine ufo_geovals_setup_c(c_key_self, c_key_locs, c_vars)
Linked list implementation.
subroutine, public ufo_geovals_dotprod(self, other, gprod)
type(registry_t), public ioda_locs_registry
Linked list interface - defines registry_t type.
subroutine, public ufo_geovals_abs(self)
subroutine ufo_geovals_assign_c(c_key_self, c_key_rhs)
subroutine, public ufo_geovals_random(self)
subroutine ufo_geovals_maxloc_c(c_key_self, mxval, iobs, ivar)
subroutine, public ufo_geovals_zero(self)
subroutine, public ufo_geovals_allocone(self)
subroutine, public ufo_geovals_normalize(self, other)
Normalization of one GeoVaLs object by another.
subroutine ufo_geovals_setup_allocone_c(c_key_self, c_conf, c_vars)
subroutine ufo_geovals_delete_c(c_key_self)
subroutine, public ufo_geovals_maxloc(self, mxval, iobs, ivar)
Location where the summed geovals value is maximum.
subroutine ufo_geovals_read_file_c(c_key_self, c_conf, c_vars)
type(registry_t), public ufo_geovals_registry
Linked list interface - defines registry_t type.
subroutine ufo_geovals_dotprod_c(c_key_self, c_key_other, prod)
subroutine ufo_geovals_add_c(c_key_self, c_key_other)
subroutine ufo_geovals_zero_c(c_key_self)
subroutine ufo_geovals_copy_c(c_key_self, c_key_other)
Copy one GeoVaLs object into another.
subroutine ufo_geovals_random_c(c_key_self)
subroutine ufo_geovals_scalmult_c(c_key_self, zz)
subroutine, public ufo_geovals_setup(self, vars, nobs)
Fortran module handling observation locations.
subroutine ufo_geovals_create_c(c_key_self)
subroutine ufo_geovals_setup_random_c(c_key_self, c_conf, c_vars)
subroutine, public ufo_geovals_assign(self, rhs)
subroutine ufo_geovals_normalize_c(c_key_self, c_key_other)
subroutine, public ufo_geovals_scalmult(self, zz)
subroutine ufo_geovals_analytic_init_c(c_key_self, c_key_locs, c_conf)
subroutine, public ufo_geovals_copy(self, other)
Copy one GeoVaLs object into another.
subroutine, public ufo_vars_setup(self, c_vars)