UFO
Example.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
13 use fckit_configuration_module, only: fckit_configuration
14 implicit none
15 private
16 
17 #define LISTED_TYPE ufo_example
18 
19 !> Linked list interface - defines registry_t type
20 #include "oops/util/linkedList_i.f"
21 
22 !> Global registry
23 type(registry_t) :: ufo_example_registry
24 
25 ! ------------------------------------------------------------------------------
26 contains
27 ! ------------------------------------------------------------------------------
28 !> Linked list implementation
29 #include "oops/util/linkedList_c.f"
30 ! ------------------------------------------------------------------------------
31 
32 subroutine ufo_example_create_c(c_self, c_conf, c_varlist) bind(c,name='ufo_example_create_f90')
33 use string_f_c_mod
34 use oops_variables_mod
35 implicit none
36 integer(c_int), intent(inout) :: c_self
37 type(c_ptr), value, intent(in) :: c_conf
38 type(c_ptr), intent(in), value :: c_varlist ! list of geovals variables to be requested
39 
40 type(ufo_example), pointer :: self
41 type(fckit_configuration) :: f_conf
42 type(oops_variables) :: oops_vars
43 
44 call ufo_example_registry%setup(c_self, self)
45 
46 f_conf = fckit_configuration(c_conf)
47 call ufo_example_create(self, f_conf)
48 
49 !> Update C++ ObsFilter with geovals variables list
50 oops_vars = oops_variables(c_varlist)
51 if (allocated(self%geovars)) then
52  call oops_vars%push_back(self%geovars)
53 end if
54 
55 end subroutine ufo_example_create_c
56 
57 ! ------------------------------------------------------------------------------
58 
59 subroutine ufo_example_delete_c(c_self) bind(c,name='ufo_example_delete_f90')
60 implicit none
61 integer(c_int), intent(inout) :: c_self
62 
63 type(ufo_example), pointer :: self
64 
65 call ufo_example_registry%get(c_self, self)
66 call ufo_example_delete(self)
67 call ufo_example_registry%delete(c_self, self)
68 
69 end subroutine ufo_example_delete_c
70 
71 ! ------------------------------------------------------------------------------
72 
73 subroutine ufo_example_prior_c(c_self, c_obspace, c_geovals) bind(c,name='ufo_example_prior_f90')
74 implicit none
75 integer(c_int), intent(in) :: c_self
76 type(c_ptr), value, intent(in) :: c_obspace
77 integer(c_int), intent(in) :: c_geovals
78 
79 type(ufo_example), pointer :: self
80 type(ufo_geovals), pointer :: geovals
81 
82 call ufo_example_registry%get(c_self, self)
83 call ufo_geovals_registry%get(c_geovals, geovals)
84 
85 call ufo_example_prior(self, c_obspace, geovals)
86 
87 end subroutine ufo_example_prior_c
88 
89 ! ------------------------------------------------------------------------------
90 
91 subroutine ufo_example_post_c(c_self, c_obspace, c_nvars, c_nlocs, c_hofx, c_hofxbias, c_key_hofxdiags) bind(c,name='ufo_example_post_f90')
92 implicit none
93 integer(c_int), intent(in) :: c_self
94 type(c_ptr), value, intent(in) :: c_obspace
95 integer(c_int), intent(in) :: c_nvars, c_nlocs
96 real(c_double), intent(in) :: c_hofx(c_nvars, c_nlocs)
97 real(c_double), intent(in) :: c_hofxbias(c_nvars, c_nlocs)
98 integer(c_int), intent(in) :: c_key_hofxdiags
99 
100 type(ufo_example), pointer :: self
101 type(ufo_geovals), pointer :: hofxdiags
102 
103 call ufo_example_registry%get(c_self, self)
104 call ufo_geovals_registry%get(c_key_hofxdiags, hofxdiags)
105 
106 call ufo_example_post(self, c_obspace, c_nvars, c_nlocs, c_hofx, c_hofxbias, hofxdiags)
107 
108 end subroutine ufo_example_post_c
109 
110 ! ------------------------------------------------------------------------------
111 
112 end module ufo_example_mod_c
Fortran example module for functions on the interface between C++ and Fortran.
subroutine ufo_example_post_c(c_self, c_obspace, c_nvars, c_nlocs, c_hofx, c_hofxbias, c_key_hofxdiags)
subroutine ufo_example_create_c(c_self, c_conf, c_varlist)
Linked list implementation.
subroutine ufo_example_delete_c(c_key_self)
subroutine ufo_example_prior_c(c_self, c_obspace, c_geovals)
Fortran module for example observation operator.
subroutine, public ufo_example_delete(self)
subroutine, public ufo_example_prior(self, obspace, geovals)
subroutine, public ufo_example_create(self, f_conf)
subroutine, public ufo_example_post(self, obspace, nvars, nlocs, hofx, hofxbias, hofxdiags)
type(registry_t), public ufo_geovals_registry
Linked list interface - defines registry_t type.
Fortran derived type for the observation type.
type to hold interpolated fields required by the obs operators