UFO
ObsAtmSfcInterp.interface.F90
Go to the documentation of this file.
1 ! (C) Copyright 2017-2018 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 atmsfcinterp module for functions on the interface between C++ and Fortran
7 ! to handle observation operators
8 
10 
11  use fckit_configuration_module, only: fckit_configuration
12  use iso_c_binding
14  use ufo_geovals_mod, only: ufo_geovals
16 
17  implicit none
18 
19  private
20 
21  ! ------------------------------------------------------------------------------
22 #define LISTED_TYPE ufo_atmsfcinterp
23 
24  !> Linked list interface - defines registry_t type
25 #include "oops/util/linkedList_i.f"
26 
27  !> Global registry
28  type(registry_t) :: ufo_atmsfcinterp_registry
29 
30  ! ------------------------------------------------------------------------------
31 
32 contains
33 
34  ! ------------------------------------------------------------------------------
35  !> Linked list implementation
36 #include "oops/util/linkedList_c.f"
37 
38 ! ------------------------------------------------------------------------------
39 
40 subroutine ufo_atmsfcinterp_setup_c(c_key_self, c_conf, c_obsvars, c_obsvarindices, c_nobsvars, &
41  c_geovars) bind(c,name='ufo_atmsfcinterp_setup_f90')
42 use oops_variables_mod
43 implicit none
44 integer(c_int), intent(inout) :: c_key_self
45 type(c_ptr), value, intent(in) :: c_conf
46 type(c_ptr), value, intent(in) :: c_obsvars ! variables to be simulated
47 integer(c_int), intent(in), value :: c_nobsvars
48 integer(c_int), intent(in) :: c_obsvarindices(c_nobsvars) ! ... and their global indices
49 type(c_ptr), value, intent(in) :: c_geovars ! variables requested from the model
50 
51 type(ufo_atmsfcinterp), pointer :: self
52 type(fckit_configuration) :: f_conf
53 
54 call ufo_atmsfcinterp_registry%setup(c_key_self, self)
55 f_conf = fckit_configuration(c_conf)
56 
57 self%obsvars = oops_variables(c_obsvars)
58 allocate(self%obsvarindices(self%obsvars%nvars()))
59 self%obsvarindices(:) = c_obsvarindices(:) + 1 ! Convert from C to Fortran indexing
60 self%geovars = oops_variables(c_geovars)
61 
62 call self%setup(f_conf)
63 
64 end subroutine ufo_atmsfcinterp_setup_c
65 
66 ! ------------------------------------------------------------------------------
67 
68 subroutine ufo_atmsfcinterp_delete_c(c_key_self) bind(c,name='ufo_atmsfcinterp_delete_f90')
69 implicit none
70 integer(c_int), intent(inout) :: c_key_self
71 
72 type(ufo_atmsfcinterp), pointer :: self
73 
74 call ufo_atmsfcinterp_registry%delete(c_key_self, self)
75 
76 end subroutine ufo_atmsfcinterp_delete_c
77 
78 ! ------------------------------------------------------------------------------
79 
80 subroutine ufo_atmsfcinterp_simobs_c(c_key_self, c_key_geovals, c_obsspace, c_nvars, c_nlocs, &
81  c_hofx) bind(c,name='ufo_atmsfcinterp_simobs_f90')
82 
83 implicit none
84 integer(c_int), intent(in) :: c_key_self
85 integer(c_int), intent(in) :: c_key_geovals
86 type(c_ptr), value, intent(in) :: c_obsspace
87 integer(c_int), intent(in) :: c_nvars, c_nlocs
88 real(c_double), intent(inout) :: c_hofx(c_nvars, c_nlocs)
89 
90 type(ufo_atmsfcinterp), pointer :: self
91 type(ufo_geovals), pointer :: geovals
92 character(len=*), parameter :: myname_="ufo_atmsfcinterp_simobs_c"
93 
94 
95 call ufo_atmsfcinterp_registry%get(c_key_self, self)
96 call ufo_geovals_registry%get(c_key_geovals, geovals)
97 
98 call self%simobs(geovals, c_obsspace, c_nvars, c_nlocs, c_hofx)
99 
100 end subroutine ufo_atmsfcinterp_simobs_c
101 
102 ! ------------------------------------------------------------------------------
103 
104 end module ufo_atmsfcinterp_mod_c
Fortran atmsfcinterp module for functions on the interface between C++ and Fortran.
subroutine ufo_atmsfcinterp_simobs_c(c_key_self, c_key_geovals, c_obsspace, c_nvars, c_nlocs, c_hofx)
subroutine ufo_atmsfcinterp_setup_c(c_key_self, c_conf, c_obsvars, c_obsvarindices, c_nobsvars, c_geovars)
Linked list implementation.
subroutine ufo_atmsfcinterp_delete_c(c_key_self)
type(registry_t) ufo_atmsfcinterp_registry
Linked list interface - defines registry_t type.
Fortran module for atmsfcinterp 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