UFO
ObsExample.interface.F90
Go to the documentation of this file.
1 ! (C) Copyright 2017-2019 UCAR
2 !
3 ! This software is licensed under the terms of the Apache Licence Version 2.0
4 ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5 
6 !> Fortran example module for functions on the interface between C++ and Fortran
7 ! to handle observation operators
8 
10 
11  use iso_c_binding
12  use ufo_example_mod
13  implicit none
14  private
15 
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 
27 contains
28 
29  ! ------------------------------------------------------------------------------
30  !> Linked list implementation
31 #include "oops/util/linkedList_c.f"
32 
33 ! ------------------------------------------------------------------------------
34 
35 subroutine ufo_example_setup_c(c_key_self, c_conf, c_obsvars, c_geovars) bind(c,name='ufo_example_setup_f90')
36 use fckit_configuration_module, only: fckit_configuration
37 use oops_variables_mod
38 implicit none
39 integer(c_int), intent(inout) :: c_key_self
40 type(c_ptr), value, intent(in) :: c_conf
41 type(c_ptr), value, intent(in) :: c_obsvars ! variables to be simulated
42 type(c_ptr), value, intent(in) :: c_geovars ! variables requested from the model
43 
44 type(ufo_example), pointer :: self
45 type(fckit_configuration) :: f_conf
46 
47 call ufo_example_registry%setup(c_key_self, self)
48 f_conf = fckit_configuration(c_conf)
49 
50 self%obsvars = oops_variables(c_obsvars)
51 self%geovars = oops_variables(c_geovars)
52 
53 call self%setup(f_conf)
54 
55 end subroutine ufo_example_setup_c
56 
57 ! ------------------------------------------------------------------------------
58 
59 subroutine ufo_example_delete_c(c_key_self) bind(c,name='ufo_example_delete_f90')
60 implicit none
61 integer(c_int), intent(inout) :: c_key_self
62 
63 type(ufo_example), pointer :: self
64 
65 call ufo_example_registry%delete(c_key_self, self)
66 
67 end subroutine ufo_example_delete_c
68 
69 ! ------------------------------------------------------------------------------
70 
71 subroutine ufo_example_simobs_c(c_key_self, c_key_geovals, c_obsspace, c_nvars, c_nlocs, &
72  c_hofx) bind(c,name='ufo_example_simobs_f90')
75 implicit none
76 integer(c_int), intent(in) :: c_key_self
77 integer(c_int), intent(in) :: c_key_geovals
78 type(c_ptr), value, intent(in) :: c_obsspace
79 integer(c_int), intent(in) :: c_nvars, c_nlocs
80 real(c_double), intent(inout) :: c_hofx(c_nvars, c_nlocs)
81 
82 type(ufo_example), pointer :: self
83 type(ufo_geovals), pointer :: geovals
84 
85 call ufo_example_registry%get(c_key_self, self)
86 call ufo_geovals_registry%get(c_key_geovals, geovals)
87 call self%simobs(geovals, c_obsspace, c_nvars, c_nlocs, c_hofx)
88 
89 end subroutine ufo_example_simobs_c
90 
91 ! ------------------------------------------------------------------------------
92 
93 end module ufo_example_mod_c
Fortran example module for functions on the interface between C++ and Fortran.
subroutine ufo_example_simobs_c(c_key_self, c_key_geovals, c_obsspace, c_nvars, c_nlocs, c_hofx)
subroutine ufo_example_delete_c(c_key_self)
subroutine ufo_example_setup_c(c_key_self, c_conf, c_obsvars, c_geovars)
Linked list implementation.
type(registry_t) ufo_example_registry
Linked list interface - defines registry_t type.
Fortran module for example observation operator.
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