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 fckit_configuration_module, only: fckit_configuration
10 use fckit_mpi_module, only: fckit_mpi_comm
11 use iso_c_binding
13 use ufo_locs_mod
15 use kinds
16 
17 implicit none
18 
19 public :: ufo_geovals_registry
20 
21 private
22 integer, parameter :: max_string=800
23 
24 #define LISTED_TYPE ufo_geovals
25 
26 !> Linked list interface - defines registry_t type
27 #include "oops/util/linkedList_i.f"
28 
29 !> Global registry
30 type(registry_t) :: ufo_geovals_registry
31 
32 ! ------------------------------------------------------------------------------
33 contains
34 ! ------------------------------------------------------------------------------
35 !> Linked list implementation
36 #include "oops/util/linkedList_c.f"
37 ! ------------------------------------------------------------------------------
38 !> Setup GeoVaLs (don't store anything; don't do allocation yet)
39 subroutine ufo_geovals_default_constr_c(c_key_self) bind(c,name='ufo_geovals_default_constr_f90')
40 implicit none
41 integer(c_int), intent(inout) :: c_key_self
42 type(ufo_geovals), pointer :: self
43 
44 call ufo_geovals_registry%init()
45 call ufo_geovals_registry%add(c_key_self)
46 call ufo_geovals_registry%get(c_key_self, self)
48 
49 end subroutine ufo_geovals_default_constr_c
50 
51 !> Setup GeoVaLs (store nlocs, variables; don't do allocation yet)
52 subroutine ufo_geovals_setup_c(c_key_self, c_nlocs, c_vars) bind(c,name='ufo_geovals_setup_f90')
53 use oops_variables_mod
54 implicit none
55 integer(c_int), intent(inout) :: c_key_self
56 integer(c_int), intent(in) :: c_nlocs
57 type(c_ptr), value, intent(in) :: c_vars
58 
59 type(ufo_geovals), pointer :: self
60 type(oops_variables) :: vars
61 
62 call ufo_geovals_registry%init()
63 call ufo_geovals_registry%add(c_key_self)
64 call ufo_geovals_registry%get(c_key_self, self)
65 
66 vars = oops_variables(c_vars)
67 call ufo_geovals_setup(self, vars, c_nlocs)
68 
69 end subroutine ufo_geovals_setup_c
70 
71 ! ------------------------------------------------------------------------------
72 !> Copy one GeoVaLs object into another
73 
74 subroutine ufo_geovals_copy_c(c_key_self, c_key_other) bind(c,name='ufo_geovals_copy_f90')
75 implicit none
76 integer(c_int), intent(in) :: c_key_self
77 integer(c_int), intent(in) :: c_key_other
78 type(ufo_geovals), pointer :: self
79 type(ufo_geovals), pointer :: other
80 
81 call ufo_geovals_registry%get(c_key_self, self)
82 call ufo_geovals_registry%get(c_key_other, other)
83 
84 call ufo_geovals_copy(self, other)
85 
86 end subroutine ufo_geovals_copy_c
87 
88 ! ------------------------------------------------------------------------------
89 !> Copy one GeoVaLs location into another object
90 
91 subroutine ufo_geovals_copy_one_c(c_key_self, c_key_other, ind) bind(c,name='ufo_geovals_copy_one_f90')
92 implicit none
93 integer(c_int), intent(in) :: c_key_self
94 integer(c_int), intent(in) :: c_key_other
95 integer(c_int), intent(in) :: ind
96 type(ufo_geovals), pointer :: self
97 type(ufo_geovals), pointer :: other
98 
99 call ufo_geovals_registry%get(c_key_self, self)
100 call ufo_geovals_registry%get(c_key_other, other)
101 
102 call ufo_geovals_copy_one(self, other, ind)
103 
104 end subroutine ufo_geovals_copy_one_c
105 
106 ! ------------------------------------------------------------------------------
107 !> Analytic init
108 
109 subroutine ufo_geovals_analytic_init_c(c_key_self, c_key_locs, c_conf) bind(c,name='ufo_geovals_analytic_init_f90')
110 
111 implicit none
112 integer(c_int), intent(in) :: c_key_self
113 integer(c_int), intent(in) :: c_key_locs
114 type(c_ptr), value, intent(in) :: c_conf
115 
116 type(ufo_geovals), pointer :: self
117 type(ufo_locs), pointer :: locs
118 character(len=30) :: ic
119 character(len=:), allocatable :: str
120 type(fckit_configuration) :: f_conf
121 
122 call ufo_geovals_registry%get(c_key_self, self)
123 call ufo_locs_registry%get(c_key_locs,locs)
124 
125 f_conf = fckit_configuration(c_conf)
126 call f_conf%get_or_die("analytic_init",str)
127 ic = str
128 call ufo_geovals_analytic_init(self,locs,ic)
129 
130 end subroutine ufo_geovals_analytic_init_c
131 
132 ! ------------------------------------------------------------------------------
133 
134 subroutine ufo_geovals_delete_c(c_key_self) bind(c,name='ufo_geovals_delete_f90')
135 
136 implicit none
137 integer(c_int), intent(inout) :: c_key_self
138 
139 type(ufo_geovals), pointer :: self
140 
141 call ufo_geovals_registry%get(c_key_self, self)
142 
143 call ufo_geovals_delete(self)
144 
145 call ufo_geovals_registry%remove(c_key_self)
146 
147 end subroutine ufo_geovals_delete_c
148 
149 ! ------------------------------------------------------------------------------
150 
151 subroutine ufo_geovals_zero_c(c_key_self) bind(c,name='ufo_geovals_zero_f90')
152 implicit none
153 integer(c_int), intent(in) :: c_key_self
154 type(ufo_geovals), pointer :: self
155 
156 call ufo_geovals_registry%get(c_key_self, self)
157 
158 call ufo_geovals_zero(self)
159 
160 end subroutine ufo_geovals_zero_c
161 
162 ! ------------------------------------------------------------------------------
163 
164 subroutine ufo_geovals_reorderzdir_c(c_key_self, lvar, c_var, lvar1, c_var1) bind(c,name='ufo_geovals_reorderzdir_f90')
165 use ufo_vars_mod, only: maxvarlen
166 use string_f_c_mod
167 implicit none
168 integer(c_int), intent(in) :: c_key_self
169 integer(c_int), intent(in) :: lvar
170 character(kind=c_char, len=1), intent(in) :: c_var(lvar+1)
171 integer(c_int), intent(in) :: lvar1
172 character(kind=c_char, len=1), intent(in) :: c_var1(lvar1+1)
173 character(len=MAXVARLEN) :: varname
174 character(len=MAXVARLEN) :: vardir
175 type(ufo_geovals), pointer :: self
176 
177 call c_f_string(c_var, varname)
178 call c_f_string(c_var1, vardir)
179 call ufo_geovals_registry%get(c_key_self, self)
180 
181 call ufo_geovals_reorderzdir(self, varname, vardir)
182 
183 end subroutine ufo_geovals_reorderzdir_c
184 
185 ! ------------------------------------------------------------------------------
186 
187 subroutine ufo_geovals_abs_c(c_key_self) bind(c,name='ufo_geovals_abs_f90')
188 implicit none
189 integer(c_int), intent(in) :: c_key_self
190 type(ufo_geovals), pointer :: self
191 
192 call ufo_geovals_registry%get(c_key_self, self)
193 
194 call ufo_geovals_abs(self)
195 
196 end subroutine ufo_geovals_abs_c
197 
198 ! ------------------------------------------------------------------------------
199 
200 subroutine ufo_geovals_rms_c(c_key_self,vrms) bind(c,name='ufo_geovals_rms_f90')
201 implicit none
202 integer(c_int), intent(in) :: c_key_self
203 real(c_double), intent(inout) :: vrms
204 type(ufo_geovals), pointer :: self
205 
206 call ufo_geovals_registry%get(c_key_self, self)
207 
208 call ufo_geovals_rms(self,vrms)
209 
210 end subroutine ufo_geovals_rms_c
211 
212 ! ------------------------------------------------------------------------------
213 
214 subroutine ufo_geovals_random_c(c_key_self) bind(c,name='ufo_geovals_random_f90')
215 implicit none
216 integer(c_int), intent(in) :: c_key_self
217 type(ufo_geovals), pointer :: self
218 
219 call ufo_geovals_registry%get(c_key_self, self)
220 
221 call ufo_geovals_random(self)
222 
223 end subroutine ufo_geovals_random_c
224 
225 ! ------------------------------------------------------------------------------
226 
227 subroutine ufo_geovals_scalmult_c(c_key_self, zz) bind(c,name='ufo_geovals_scalmult_f90')
228 implicit none
229 integer(c_int), intent(in) :: c_key_self
230 real(c_double), intent(in) :: zz
231 type(ufo_geovals), pointer :: self
232 
233 call ufo_geovals_registry%get(c_key_self, self)
234 
235 call ufo_geovals_scalmult(self, zz)
236 
237 end subroutine ufo_geovals_scalmult_c
238 
239 ! ------------------------------------------------------------------------------
240 
241 subroutine ufo_geovals_profmult_c(c_key_self, nlocs, values) bind(c,name='ufo_geovals_profmult_f90')
242 implicit none
243 integer(c_int), intent(in) :: c_key_self
244 integer(c_int), intent(in) :: nlocs
245 real(c_float), intent(in) :: values(nlocs)
246 type(ufo_geovals), pointer :: self
247 
248 call ufo_geovals_registry%get(c_key_self, self)
249 
250 call ufo_geovals_profmult(self, nlocs, values)
251 
252 end subroutine ufo_geovals_profmult_c
253 
254 ! ------------------------------------------------------------------------------
255 
256 subroutine ufo_geovals_assign_c(c_key_self, c_key_rhs) bind(c,name='ufo_geovals_assign_f90')
257 implicit none
258 integer(c_int), intent(in) :: c_key_self
259 integer(c_int), intent(in) :: c_key_rhs
260 type(ufo_geovals), pointer :: self
261 type(ufo_geovals), pointer :: rhs
262 
263 call ufo_geovals_registry%get(c_key_self, self)
264 call ufo_geovals_registry%get(c_key_rhs, rhs)
265 
266 call ufo_geovals_assign(self, rhs)
267 
268 end subroutine ufo_geovals_assign_c
269 
270 ! ------------------------------------------------------------------------------
271 
272 subroutine ufo_geovals_add_c(c_key_self, c_key_other) bind(c,name='ufo_geovals_add_f90')
273 implicit none
274 integer(c_int), intent(in) :: c_key_self
275 integer(c_int), intent(in) :: c_key_other
276 type(ufo_geovals), pointer :: self
277 type(ufo_geovals), pointer :: other
278 
279 call ufo_geovals_registry%get(c_key_self, self)
280 call ufo_geovals_registry%get(c_key_other, other)
281 
282 call ufo_geovals_add(self, other)
283 
284 end subroutine ufo_geovals_add_c
285 
286 ! ------------------------------------------------------------------------------
287 
288 subroutine ufo_geovals_diff_c(c_key_self, c_key_other) bind(c,name='ufo_geovals_diff_f90')
289 implicit none
290 integer(c_int), intent(in) :: c_key_self
291 integer(c_int), intent(in) :: c_key_other
292 type(ufo_geovals), pointer :: self
293 type(ufo_geovals), pointer :: other
294 
295 call ufo_geovals_registry%get(c_key_self, self)
296 call ufo_geovals_registry%get(c_key_other, other)
297 
298 call ufo_geovals_diff(self, other)
299 
300 end subroutine ufo_geovals_diff_c
301 
302 ! ------------------------------------------------------------------------------
303 
304 subroutine ufo_geovals_schurmult_c(c_key_self, c_key_other) bind(c,name='ufo_geovals_schurmult_f90')
305 implicit none
306 integer(c_int), intent(in) :: c_key_self
307 integer(c_int), intent(in) :: c_key_other
308 type(ufo_geovals), pointer :: self
309 type(ufo_geovals), pointer :: other
310 
311 call ufo_geovals_registry%get(c_key_self, self)
312 call ufo_geovals_registry%get(c_key_other, other)
313 
314 call ufo_geovals_schurmult(self, other)
315 
316 end subroutine ufo_geovals_schurmult_c
317 
318 ! ------------------------------------------------------------------------------
319 
320 subroutine ufo_geovals_normalize_c(c_key_self, c_key_other) bind(c,name='ufo_geovals_normalize_f90')
321 implicit none
322 integer(c_int), intent(in) :: c_key_self
323 integer(c_int), intent(in) :: c_key_other
324 type(ufo_geovals), pointer :: self
325 type(ufo_geovals), pointer :: other
326 
327 call ufo_geovals_registry%get(c_key_self, self)
328 call ufo_geovals_registry%get(c_key_other, other)
329 
330 call ufo_geovals_normalize(self, other)
331 
332 end subroutine ufo_geovals_normalize_c
333 
334 ! ------------------------------------------------------------------------------
335 
336 subroutine ufo_geovals_dotprod_c(c_key_self, c_key_other, prod, c_comm) bind(c,name='ufo_geovals_dotprod_f90')
337 implicit none
338 integer(c_int), intent(in) :: c_key_self, c_key_other
339 real(c_double), intent(inout) :: prod
340 type(c_ptr), value, intent(in) :: c_comm
341 
342 type(ufo_geovals), pointer :: self, other
343 type(fckit_mpi_comm) :: f_comm
344 
345 call ufo_geovals_registry%get(c_key_self, self)
346 call ufo_geovals_registry%get(c_key_other, other)
347 
348 f_comm = fckit_mpi_comm(c_comm)
349 
350 call ufo_geovals_dotprod(self, other, prod, f_comm)
351 
352 end subroutine ufo_geovals_dotprod_c
353 
354 ! ------------------------------------------------------------------------------
355 
356 subroutine ufo_geovals_split_c(c_key_self, c_key_other1, c_key_other2) bind(c,name='ufo_geovals_split_f90')
357 implicit none
358 integer(c_int), intent(in) :: c_key_self, c_key_other1, c_key_other2
359 type(ufo_geovals), pointer :: self, other1, other2
360 
361 call ufo_geovals_registry%get(c_key_self, self)
362 call ufo_geovals_registry%get(c_key_other1, other1)
363 call ufo_geovals_registry%get(c_key_other2, other2)
364 
365 call ufo_geovals_split(self, other1, other2)
366 
367 end subroutine ufo_geovals_split_c
368 
369 ! ------------------------------------------------------------------------------
370 
371 subroutine ufo_geovals_merge_c(c_key_self, c_key_other1, c_key_other2) bind(c,name='ufo_geovals_merge_f90')
372 implicit none
373 integer(c_int), intent(in) :: c_key_self, c_key_other1, c_key_other2
374 type(ufo_geovals), pointer :: self, other1, other2
375 
376 call ufo_geovals_registry%get(c_key_self, self)
377 call ufo_geovals_registry%get(c_key_other1, other1)
378 call ufo_geovals_registry%get(c_key_other2, other2)
379 
380 call ufo_geovals_merge(self, other1, other2)
381 
382 end subroutine ufo_geovals_merge_c
383 
384 ! ------------------------------------------------------------------------------
385 
386 subroutine ufo_geovals_minmaxavg_c(c_key_self, kobs, kvar, pmin, pmax, prms) bind(c,name='ufo_geovals_minmaxavg_f90')
387 implicit none
388 integer(c_int), intent(in) :: c_key_self
389 integer(c_int), intent(inout) :: kobs
390 integer(c_int), intent(in) :: kvar
391 real(c_double), intent(inout) :: pmin, pmax, prms
392 type(ufo_geovals), pointer :: self
393 
394 call ufo_geovals_registry%get(c_key_self, self)
395 
396 call ufo_geovals_minmaxavg(self, kobs, kvar, pmin, pmax, prms)
397 
398 end subroutine ufo_geovals_minmaxavg_c
399 
400 ! ------------------------------------------------------------------------------
401 
402 subroutine ufo_geovals_nlocs_c(c_key_self, kobs) bind(c, name='ufo_geovals_nlocs_f90')
403 implicit none
404 integer(c_int), intent(in) :: c_key_self
405 integer(c_size_t), intent(inout) :: kobs
406 type(ufo_geovals), pointer :: self
407 
408 call ufo_geovals_registry%get(c_key_self, self)
409 kobs = self%nlocs
410 
411 end subroutine ufo_geovals_nlocs_c
412 
413 ! ------------------------------------------------------------------------------
414 
415 subroutine ufo_geovals_nlevs_c(c_key_self, lvar, c_var, nlevs) bind(c, name='ufo_geovals_nlevs_f90')
416 use ufo_vars_mod, only: maxvarlen
417 use string_f_c_mod
418 implicit none
419 integer(c_int), intent(in) :: c_key_self
420 integer(c_int), intent(in) :: lvar
421 character(kind=c_char, len=1), intent(in) :: c_var(lvar+1)
422 integer(c_int), intent(out) :: nlevs
423 
424 type(ufo_geoval), pointer :: geoval
425 character(len=MAXVARLEN) :: varname
426 type(ufo_geovals), pointer :: self
427 
428 call c_f_string(c_var, varname)
429 call ufo_geovals_registry%get(c_key_self, self)
430 
431 call ufo_geovals_get_var(self, varname, geoval)
432 
433 nlevs = size(geoval%vals,1)
434 
435 end subroutine ufo_geovals_nlevs_c
436 
437 ! ------------------------------------------------------------------------------
438 
439 subroutine ufo_geovals_get2d_c(c_key_self, lvar, c_var, nlocs, values) bind(c, name='ufo_geovals_get2d_f90')
440 use ufo_vars_mod, only: maxvarlen
441 use string_f_c_mod
442 implicit none
443 integer(c_int), intent(in) :: c_key_self
444 integer(c_int), intent(in) :: lvar
445 character(kind=c_char, len=1), intent(in) :: c_var(lvar+1)
446 integer(c_int), intent(in) :: nlocs
447 real(c_float), intent(inout) :: values(nlocs)
448 
449 character(max_string) :: err_msg
450 type(ufo_geoval), pointer :: geoval
451 character(len=MAXVARLEN) :: varname
452 type(ufo_geovals), pointer :: self
453 
454 call c_f_string(c_var, varname)
455 call ufo_geovals_registry%get(c_key_self, self)
456 
457 call ufo_geovals_get_var(self, varname, geoval)
458 
459 if (size(geoval%vals,1) /= 1) then
460  write(err_msg,*)'ufo_geovals_get2d_f90',trim(varname),'is not a 2D var:',size(geoval%vals,1), ' levels'
461  call abor1_ftn(err_msg)
462 endif
463 if (nlocs /= size(geoval%vals,2)) then
464  write(err_msg,*)'ufo_geovals_get2d_f90',trim(varname),'error locs number:',nlocs,size(geoval%vals,2)
465  call abor1_ftn(err_msg)
466 endif
467 
468 values(:) = geoval%vals(1,:)
469 
470 end subroutine ufo_geovals_get2d_c
471 
472 ! ------------------------------------------------------------------------------
473 
474 subroutine ufo_geovals_get_c(c_key_self, lvar, c_var, lev, nlocs, values) bind(c, name='ufo_geovals_get_f90')
475 use ufo_vars_mod, only: maxvarlen
476 use string_f_c_mod
477 implicit none
478 integer(c_int), intent(in) :: c_key_self
479 integer(c_int), intent(in) :: lvar
480 character(kind=c_char, len=1), intent(in) :: c_var(lvar+1)
481 integer(c_int), intent(in) :: lev
482 integer(c_int), intent(in) :: nlocs
483 real(c_float), intent(inout) :: values(nlocs)
484 
485 character(max_string) :: err_msg
486 type(ufo_geoval), pointer :: geoval
487 character(len=MAXVARLEN) :: varname
488 type(ufo_geovals), pointer :: self
489 
490 call c_f_string(c_var, varname)
491 call ufo_geovals_registry%get(c_key_self, self)
492 
493 call ufo_geovals_get_var(self, varname, geoval)
494 
495 if (lev<1 .or. lev>size(geoval%vals,1)) then
496  write(err_msg,*)'ufo_geovals_get_f90',trim(varname),'level out of range:',lev,size(geoval%vals,1)
497  call abor1_ftn(err_msg)
498 endif
499 if (nlocs /= size(geoval%vals,2)) then
500  write(err_msg,*)'ufo_geovals_get_f90',trim(varname),'error locs number:',nlocs,size(geoval%vals,2)
501  call abor1_ftn(err_msg)
502 endif
503 
504 values(:) = geoval%vals(lev,:)
505 
506 end subroutine ufo_geovals_get_c
507 
508 ! ------------------------------------------------------------------------------
509 
510 subroutine ufo_geovals_getdouble_c(c_key_self, lvar, c_var, lev, nlocs, values)&
511  bind(c, name='ufo_geovals_getdouble_f90')
512 use ufo_vars_mod, only: maxvarlen
513 use string_f_c_mod
514 implicit none
515 integer(c_int), intent(in) :: c_key_self
516 integer(c_int), intent(in) :: lvar
517 character(kind=c_char, len=1), intent(in) :: c_var(lvar+1)
518 integer(c_int), intent(in) :: lev
519 integer(c_int), intent(in) :: nlocs
520 real(c_double), intent(inout) :: values(nlocs)
521 
522 type(ufo_geoval), pointer :: geoval
523 character(len=MAXVARLEN) :: varname
524 type(ufo_geovals), pointer :: self
525 
526 call c_f_string(c_var, varname)
527 call ufo_geovals_registry%get(c_key_self, self)
528 call ufo_geovals_get_var(self, varname, geoval)
529 values(:) = geoval%vals(lev,:)
530 
531 end subroutine ufo_geovals_getdouble_c
532 
533 ! ------------------------------------------------------------------------------
534 
535 subroutine ufo_geovals_putdouble_c(c_key_self, lvar, c_var, lev, nlocs, values) bind(c, name='ufo_geovals_putdouble_f90')
536 use ufo_vars_mod, only: maxvarlen
537 use oops_variables_mod
538 use string_f_c_mod
539 integer(c_int), intent(in) :: c_key_self
540 integer(c_int), intent(in) :: lvar
541 character(kind=c_char, len=1), intent(in) :: c_var(lvar+1)
542 integer(c_int), intent(in) :: lev
543 integer(c_int), intent(in) :: nlocs
544 real(c_double), intent(inout) :: values(nlocs)
545 
546 type(ufo_geoval) :: geoval
547 character(len=MAXVARLEN) :: varname
548 type(ufo_geovals), pointer :: self
549 type(oops_variables) :: var
550 integer :: nlev
551 
552 call c_f_string(c_var, varname)
553 call ufo_geovals_registry%get(c_key_self, self)
554 self%geovals(1)%nval=5
555 geoval%nval=self%geovals(1)%nval
556 geoval%nlocs=nlocs
557 allocate(geoval%vals(geoval%nval,geoval%nlocs))
558 geoval%vals(lev,:) = values(:)
559 call ufo_geovals_put_var(self, varname, geoval, lev)
560 
561 end subroutine ufo_geovals_putdouble_c
562 
563 ! ------------------------------------------------------------------------------
564 
565 subroutine ufo_geovals_maxloc_c(c_key_self, mxval, iloc, ivar) bind(c,name='ufo_geovals_maxloc_f90')
566 implicit none
567 integer(c_int), intent(in) :: c_key_self
568 real(c_double), intent(inout) :: mxval
569 integer(c_int), intent(inout) :: iloc, ivar
570 type(ufo_geovals), pointer :: self
571 
572 call ufo_geovals_registry%get(c_key_self, self)
573 
574 call ufo_geovals_maxloc(self, mxval, iloc, ivar)
575 
576 end subroutine ufo_geovals_maxloc_c
577 
578 ! ------------------------------------------------------------------------------
579 
580 subroutine ufo_geovals_read_file_c(c_key_self, c_conf, c_obspace, c_vars) bind(c,name='ufo_geovals_read_file_f90')
581 use oops_variables_mod
582 use datetime_mod
583 
584 implicit none
585 integer(c_int), intent(inout) :: c_key_self
586 type(c_ptr), value, intent(in) :: c_conf
587 type(c_ptr), value, intent(in) :: c_obspace
588 type(c_ptr), value, intent(in) :: c_vars
589 
590 type(ufo_geovals), pointer :: self
591 character(max_string) :: filename
592 integer :: loc_multiplier
593 character(len=:), allocatable :: str
594 type(fckit_configuration) :: f_conf
595 type(oops_variables) :: vars
596 
597 call ufo_geovals_registry%init()
598 call ufo_geovals_registry%add(c_key_self)
599 call ufo_geovals_registry%get(c_key_self, self)
600 
601 ! read filename for config
602 f_conf = fckit_configuration(c_conf)
603 call f_conf%get_or_die("filename",str)
604 filename = str
605 
606 if (f_conf%has("loc_multiplier")) then
607  call f_conf%get_or_die("loc_multiplier", loc_multiplier)
608 else
609  loc_multiplier = 1
610 endif
611 
612 vars = oops_variables(c_vars)
613 ! read geovals
614 call ufo_geovals_read_netcdf(self, filename, loc_multiplier, c_obspace, vars)
615 
616 end subroutine ufo_geovals_read_file_c
617 
618 ! ------------------------------------------------------------------------------
619 
620 subroutine ufo_geovals_write_file_c(c_key_self, c_conf, c_comm) bind(c,name='ufo_geovals_write_file_f90')
621 implicit none
622 integer(c_int), intent(in) :: c_key_self
623 type(c_ptr), value, intent(in) :: c_conf
624 type(c_ptr), value, intent(in) :: c_comm
625 
626 type(ufo_geovals), pointer :: self
627 character(max_string) :: fout, filename
628 
629 type(fckit_mpi_comm) :: comm
630 character(len=10) :: cproc
631 integer :: ppos
632 character(len=:), allocatable :: str
633 type(fckit_configuration) :: f_conf
634 
635 ! read filename for config
636 f_conf = fckit_configuration(c_conf)
637 call f_conf%get_or_die("filename",str)
638 filename = str
639 
640 ! get the process rank number
641 comm = fckit_mpi_comm(c_comm)
642 
643 write(cproc,fmt='(i4.4)') comm%rank()
644 
645 ! Find the left-most dot in the file name, and use that to pick off the file name
646 ! and file extension.
647 ppos = scan(trim(filename), '.', back=.true.)
648 if (ppos > 0) then
649  ! found a file extension
650  fout = filename(1:ppos-1) // '_' // trim(adjustl(cproc)) // trim(filename(ppos:))
651 else
652  ! no file extension
653  fout = trim(filename) // '_' // trim(adjustl(cproc))
654 endif
655 
656 call ufo_geovals_registry%get(c_key_self, self)
657 call ufo_geovals_write_netcdf(self, fout)
658 
659 end subroutine ufo_geovals_write_file_c
660 
661 ! ------------------------------------------------------------------------------
662 
663 end module ufo_geovals_mod_c
ufo_locs_mod_c::ufo_locs_registry
type(registry_t), public ufo_locs_registry
Linked list interface - defines registry_t type.
Definition: Locations.interface.F90:28
ufo_geovals_mod::ufo_geovals_add
subroutine, public ufo_geovals_add(self, other)
Sum of two GeoVaLs objects.
Definition: ufo_geovals_mod.F90:388
ufo_geovals_mod_c::ufo_geovals_analytic_init_c
subroutine ufo_geovals_analytic_init_c(c_key_self, c_key_locs, c_conf)
Analytic init.
Definition: GeoVaLs.interface.F90:110
ufo_geovals_mod::ufo_geovals_default_constr
subroutine, public ufo_geovals_default_constr(self)
Definition: ufo_geovals_mod.F90:68
ufo_geovals_mod_c::ufo_geovals_zero_c
subroutine ufo_geovals_zero_c(c_key_self)
Definition: GeoVaLs.interface.F90:152
ufo_geovals_mod_c::ufo_geovals_add_c
subroutine ufo_geovals_add_c(c_key_self, c_key_other)
Definition: GeoVaLs.interface.F90:273
ufo_geovals_mod_c::ufo_geovals_write_file_c
subroutine ufo_geovals_write_file_c(c_key_self, c_conf, c_comm)
Definition: GeoVaLs.interface.F90:621
ufo_geovals_mod_c::ufo_geovals_nlevs_c
subroutine ufo_geovals_nlevs_c(c_key_self, lvar, c_var, nlevs)
Definition: GeoVaLs.interface.F90:416
ufo_geovals_mod::ufo_geovals_assign
subroutine, public ufo_geovals_assign(self, rhs)
Definition: ufo_geovals_mod.F90:295
ufo_geovals_mod::ufo_geovals_diff
subroutine, public ufo_geovals_diff(self, other)
Difference between two GeoVaLs objects.
Definition: ufo_geovals_mod.F90:427
ufo_geovals_mod_c::ufo_geovals_copy_one_c
subroutine ufo_geovals_copy_one_c(c_key_self, c_key_other, ind)
Copy one GeoVaLs location into another object.
Definition: GeoVaLs.interface.F90:92
ufo_geovals_mod_c::ufo_geovals_rms_c
subroutine ufo_geovals_rms_c(c_key_self, vrms)
Definition: GeoVaLs.interface.F90:201
ufo_geovals_mod_c::ufo_geovals_schurmult_c
subroutine ufo_geovals_schurmult_c(c_key_self, c_key_other)
Definition: GeoVaLs.interface.F90:305
ufo_geovals_mod_c::ufo_geovals_getdouble_c
subroutine ufo_geovals_getdouble_c(c_key_self, lvar, c_var, lev, nlocs, values)
Definition: GeoVaLs.interface.F90:512
ufo_geovals_mod_c::ufo_geovals_diff_c
subroutine ufo_geovals_diff_c(c_key_self, c_key_other)
Definition: GeoVaLs.interface.F90:289
ufo_geovals_mod::ufo_geovals_delete
subroutine, public ufo_geovals_delete(self)
Definition: ufo_geovals_mod.F90:107
ufo_geovals_mod_c::ufo_geovals_dotprod_c
subroutine ufo_geovals_dotprod_c(c_key_self, c_key_other, prod, c_comm)
Definition: GeoVaLs.interface.F90:337
ufo_geovals_mod::ufo_geovals_setup
subroutine, public ufo_geovals_setup(self, vars, nlocs)
Definition: ufo_geovals_mod.F90:80
ufo_geovals_mod_c::ufo_geovals_minmaxavg_c
subroutine ufo_geovals_minmaxavg_c(c_key_self, kobs, kvar, pmin, pmax, prms)
Definition: GeoVaLs.interface.F90:387
ufo_geovals_mod::ufo_geovals_scalmult
subroutine, public ufo_geovals_scalmult(self, zz)
Definition: ufo_geovals_mod.F90:251
ufo_geovals_mod::ufo_geovals_rms
subroutine, public ufo_geovals_rms(self, vrms)
Definition: ufo_geovals_mod.F90:208
ufo_geovals_mod::ufo_geovals_zero
subroutine, public ufo_geovals_zero(self)
Definition: ufo_geovals_mod.F90:176
ufo_geovals_mod_c::ufo_geovals_delete_c
subroutine ufo_geovals_delete_c(c_key_self)
Definition: GeoVaLs.interface.F90:135
ufo_geovals_mod::ufo_geovals_merge
subroutine, public ufo_geovals_merge(self, other1, other2)
Definition: ufo_geovals_mod.F90:849
ufo_geovals_mod::ufo_geovals_copy_one
subroutine, public ufo_geovals_copy_one(self, other, loc_index)
Copy one location from GeoVaLs into a new object.
Definition: ufo_geovals_mod.F90:540
ufo_geovals_mod_c::ufo_geovals_putdouble_c
subroutine ufo_geovals_putdouble_c(c_key_self, lvar, c_var, lev, nlocs, values)
Definition: GeoVaLs.interface.F90:536
ufo_geovals_mod::ufo_geovals_split
subroutine, public ufo_geovals_split(self, other1, other2)
Definition: ufo_geovals_mod.F90:816
ufo_geovals_mod_c::ufo_geovals_profmult_c
subroutine ufo_geovals_profmult_c(c_key_self, nlocs, values)
Definition: GeoVaLs.interface.F90:242
ufo_geovals_mod::ufo_geovals_random
subroutine, public ufo_geovals_random(self)
Definition: ufo_geovals_mod.F90:233
ufo_geovals_mod_c::ufo_geovals_assign_c
subroutine ufo_geovals_assign_c(c_key_self, c_key_rhs)
Definition: GeoVaLs.interface.F90:257
ufo_geovals_mod::ufo_geovals_normalize
subroutine, public ufo_geovals_normalize(self, other)
Normalization of one GeoVaLs object by another.
Definition: ufo_geovals_mod.F90:700
ufo_geovals_mod::ufo_geovals_abs
subroutine, public ufo_geovals_abs(self)
Definition: ufo_geovals_mod.F90:192
ufo_geovals_mod::ufo_geovals_dotprod
subroutine, public ufo_geovals_dotprod(self, other, gprod, f_comm)
Definition: ufo_geovals_mod.F90:752
ufo_geovals_mod_c::ufo_geovals_default_constr_c
subroutine ufo_geovals_default_constr_c(c_key_self)
Linked list implementation.
Definition: GeoVaLs.interface.F90:40
ufo_geovals_mod_c::ufo_geovals_get2d_c
subroutine ufo_geovals_get2d_c(c_key_self, lvar, c_var, nlocs, values)
Definition: GeoVaLs.interface.F90:440
ufo_geovals_mod
Definition: ufo_geovals_mod.F90:7
ufo_geovals_mod_c::ufo_geovals_random_c
subroutine ufo_geovals_random_c(c_key_self)
Definition: GeoVaLs.interface.F90:215
ufo_geovals_mod::ufo_geovals_profmult
subroutine, public ufo_geovals_profmult(self, nlocs, values)
Definition: ufo_geovals_mod.F90:273
ufo_geovals_mod_c
Definition: GeoVaLs.interface.F90:7
ufo_geovals_mod_c::ufo_geovals_reorderzdir_c
subroutine ufo_geovals_reorderzdir_c(c_key_self, lvar, c_var, lvar1, c_var1)
Definition: GeoVaLs.interface.F90:165
ufo_geovals_mod_c::ufo_geovals_scalmult_c
subroutine ufo_geovals_scalmult_c(c_key_self, zz)
Definition: GeoVaLs.interface.F90:228
ufo_geovals_mod_c::ufo_geovals_split_c
subroutine ufo_geovals_split_c(c_key_self, c_key_other1, c_key_other2)
Definition: GeoVaLs.interface.F90:357
ufo_geovals_mod::ufo_geovals_analytic_init
subroutine, public ufo_geovals_analytic_init(self, locs, ic)
Initialize a GeoVaLs object based on an analytic state.
Definition: ufo_geovals_mod.F90:599
ufo_geovals_mod::ufo_geovals_read_netcdf
subroutine, public ufo_geovals_read_netcdf(self, filename, loc_multiplier, c_obspace, vars)
Definition: ufo_geovals_mod.F90:955
ufo_vars_mod
Definition: ufo_variables_mod.F90:8
ufo_geovals_mod_c::ufo_geovals_nlocs_c
subroutine ufo_geovals_nlocs_c(c_key_self, kobs)
Definition: GeoVaLs.interface.F90:403
ufo_geovals_mod::ufo_geovals_put_var
subroutine, public ufo_geovals_put_var(self, varname, geoval, k)
Definition: ufo_geovals_mod.F90:161
ufo_geovals_mod_c::ufo_geovals_normalize_c
subroutine ufo_geovals_normalize_c(c_key_self, c_key_other)
Definition: GeoVaLs.interface.F90:321
ufo_geovals_mod_c::ufo_geovals_setup_c
subroutine ufo_geovals_setup_c(c_key_self, c_nlocs, c_vars)
Setup GeoVaLs (store nlocs, variables; don't do allocation yet)
Definition: GeoVaLs.interface.F90:53
ufo_geovals_mod::ufo_geovals_schurmult
subroutine, public ufo_geovals_schurmult(self, other)
Schur product of two GeoVaLs objects.
Definition: ufo_geovals_mod.F90:466
ufo_geovals_mod::ufo_geovals_minmaxavg
subroutine, public ufo_geovals_minmaxavg(self, kobs, kvar, pmin, pmax, prms)
Definition: ufo_geovals_mod.F90:877
ufo_geovals_mod::ufo_geovals_get_var
subroutine, public ufo_geovals_get_var(self, varname, geoval)
Definition: ufo_geovals_mod.F90:128
ufo_geovals_mod::ufo_geovals_maxloc
subroutine, public ufo_geovals_maxloc(self, mxval, iobs, ivar)
Location where the summed geovals value is maximum.
Definition: ufo_geovals_mod.F90:913
ufo_geovals_mod_c::ufo_geovals_merge_c
subroutine ufo_geovals_merge_c(c_key_self, c_key_other1, c_key_other2)
Definition: GeoVaLs.interface.F90:372
ufo_locs_mod_c
Definition: Locations.interface.F90:8
ufo_geovals_mod_c::ufo_geovals_maxloc_c
subroutine ufo_geovals_maxloc_c(c_key_self, mxval, iloc, ivar)
Definition: GeoVaLs.interface.F90:566
ufo_geovals_mod_c::ufo_geovals_copy_c
subroutine ufo_geovals_copy_c(c_key_self, c_key_other)
Copy one GeoVaLs object into another.
Definition: GeoVaLs.interface.F90:75
ufo_vars_mod::maxvarlen
integer, parameter, public maxvarlen
Definition: ufo_variables_mod.F90:17
ufo_geovals_mod::ufo_geovals_write_netcdf
subroutine, public ufo_geovals_write_netcdf(self, filename)
Definition: ufo_geovals_mod.F90:1110
ufo_geovals_mod_c::ufo_geovals_get_c
subroutine ufo_geovals_get_c(c_key_self, lvar, c_var, lev, nlocs, values)
Definition: GeoVaLs.interface.F90:475
ufo_locs_mod
Fortran module handling observation locations.
Definition: ufo_locs_mod.F90:9
ufo_geovals_mod_c::max_string
integer, parameter max_string
Definition: GeoVaLs.interface.F90:22
ufo_geovals_mod::ufo_geovals
type to hold interpolated fields required by the obs operators
Definition: ufo_geovals_mod.F90:47
ufo_geovals_mod::ufo_geoval
type to hold interpolated field for one variable, one observation
Definition: ufo_geovals_mod.F90:40
ufo_locs_mod::ufo_locs
Fortran derived type to hold observation locations.
Definition: ufo_locs_mod.F90:25
ufo_geovals_mod::ufo_geovals_reorderzdir
subroutine, public ufo_geovals_reorderzdir(self, varname, zdir)
Definition: ufo_geovals_mod.F90:334
ufo_geovals_mod_c::ufo_geovals_registry
type(registry_t), public ufo_geovals_registry
Linked list interface - defines registry_t type.
Definition: GeoVaLs.interface.F90:30
ufo_geovals_mod::ufo_geovals_copy
subroutine, public ufo_geovals_copy(self, other)
Copy one GeoVaLs object into another.
Definition: ufo_geovals_mod.F90:506
ufo_geovals_mod_c::ufo_geovals_read_file_c
subroutine ufo_geovals_read_file_c(c_key_self, c_conf, c_obspace, c_vars)
Definition: GeoVaLs.interface.F90:581
ufo_geovals_mod_c::ufo_geovals_abs_c
subroutine ufo_geovals_abs_c(c_key_self)
Definition: GeoVaLs.interface.F90:188