SOCA
soca_vertconv.interface.F90
Go to the documentation of this file.
1 ! (C) Copyright 2017-2021 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 !> C++ interfaces for soca_vertconv_mod::soca_vertconv
8 
9 use fckit_configuration_module, only: fckit_configuration
10 use iso_c_binding
11 use kinds, only: kind_real
12 
13 ! soca modules
15 use soca_geom_mod, only: soca_geom
18 use soca_state_mod, only: soca_state
21 
22 implicit none
23 private
24 
25 #define LISTED_TYPE soca_vertconv
26 
27 !> Linked list interface - defines registry_t type
28 #include "oops/util/linkedList_i.f"
29 
30 !> Global registry for soca_vertconv
31 type(registry_t), public :: soca_vertconv_registry
32 
33 ! ------------------------------------------------------------------------------
34 contains
35 ! ------------------------------------------------------------------------------
36 
37 !> Linked list implementation
38 #include "oops/util/linkedList_c.f"
39 
40 
41 ! ------------------------------------------------------------------------------
42 !> C++ interface for soca_vertconv_mod::soca_vertconv::setup()
43 !!
44 !! Constructor for Vertconv
45 subroutine soca_vertconv_setup_c(c_key_self, c_conf, c_key_bkg, c_key_geom) &
46  bind(c,name='soca_vertconv_setup_f90')
47 
48  integer(c_int), intent(inout) :: c_key_self !< The Vertconv structure
49  type(c_ptr), intent(in) :: c_conf !< The configuration
50  integer(c_int), intent(in) :: c_key_bkg !< background
51  integer(c_int), intent(in) :: c_key_geom !< geometry
52 
53  type(soca_vertconv), pointer :: self
54  type(soca_state), pointer :: bkg
55  type(soca_geom), pointer :: geom
56 
57  call soca_vertconv_registry%init()
58  call soca_vertconv_registry%add(c_key_self)
59  call soca_vertconv_registry%get(c_key_self, self)
60  call soca_state_registry%get(c_key_bkg, bkg)
61  call soca_geom_registry%get(c_key_geom, geom)
62 
63  call self%setup(bkg, geom, fckit_configuration(c_conf))
64 
65 end subroutine soca_vertconv_setup_c
66 
67 
68 ! ------------------------------------------------------------------------------
69 !> C++ interface for soca_vertconv_mod::soca_vertconv destructor
70 !!
71 !! Destructor for Vertconv
72 subroutine soca_vertconv_delete_c(c_key_self) bind(c,name='soca_vertconv_delete_f90')
73 
74  integer(c_int), intent(inout) :: c_key_self !< The background covariance structure
75 
76  type(soca_vertconv), pointer :: self
77 
78  ! Deallocate background
79  ! TODO
80  ! Deallocate ocean depth array
81  ! TODO
82 
83  call soca_vertconv_registry%get(c_key_self, self)
84 
85  if (associated(self%bkg)) nullify(self%bkg)
86 
87  call soca_vertconv_registry%remove(c_key_self)
88 
89 end subroutine soca_vertconv_delete_c
90 
91 
92 ! ------------------------------------------------------------------------------
93 !> C++ interface for soca_vertconv_mod::soca_vertconv::mult()
94 !!
95 !! Multiplication
96 subroutine soca_vertconv_mult_c(c_key_a, c_key_m, c_key_self)&
97  bind(c,name='soca_vertconv_mult_f90')
98 
99  integer(c_int), intent(in) :: c_key_a !< Increment in
100  integer(c_int), intent(in) :: c_key_m !< Increment out
101  integer(c_int), intent(in) :: c_key_self !< config
102 
103  type(soca_increment), pointer :: dxa ! in
104  type(soca_increment), pointer :: dxm ! out
105  type(soca_vertconv), pointer :: self
106 
107  call soca_increment_registry%get(c_key_a, dxa)
108  call soca_increment_registry%get(c_key_m, dxm)
109  call soca_vertconv_registry%get(c_key_self, self)
110 
111  !< Computes dxm = Vertconv dxa
112 
113  ! dxm = dxa
114  call dxm%copy( dxa)
115 
116  ! Apply forward convolution operator to T & S
117  call self%mult(dxm, dxa)
118 
119 end subroutine soca_vertconv_mult_c
120 
121 
122 ! ------------------------------------------------------------------------------
123 !> C++ interface for soca_vertconv_mod::soca_vertconv::mult_ad()
124 !!
125 !! Multiplication adjoint
126 subroutine soca_vertconv_multad_c(c_key_m, c_key_a, c_key_self)&
127  bind(c,name='soca_vertconv_multad_f90')
128 
129  integer(c_int), intent(in) :: c_key_a !< Increment out
130  integer(c_int), intent(in) :: c_key_m !< Increment in
131  integer(c_int), intent(in) :: c_key_self !< config
132 
133  type(soca_increment), pointer :: dxa
134  type(soca_increment), pointer :: dxm
135  type(soca_vertconv), pointer :: self
136 
137  call soca_increment_registry%get(c_key_a,dxa)
138  call soca_increment_registry%get(c_key_m,dxm)
139  call soca_vertconv_registry%get(c_key_self, self)
140 
141  ! dxa = dxm
142  call dxa%copy(dxm)
143 
144  ! Apply adjoint of convolution operator
145  call self%mult_ad(dxm, dxa)
146 
147 end subroutine soca_vertconv_multad_c
148 
149 end module soca_vertconv_mod_c
C++ interfaces for soca_geom_mod::soca_geom.
type(registry_t), public soca_geom_registry
Linked list interface - defines registry_t type.
Geometry module.
Increment fields.
registry for soca_increment_mod::soca_increment instances for use in Fortran/C++ interface of soca_in...
type(registry_t), public soca_increment_registry
Linked list interface - defines registry_t type.
State fields.
registry for soca_state_mod::soca_state instances for use in Fortran/C++ interfaces of soca_state_mod...
type(registry_t), public soca_state_registry
Linked list interface - defines registry_t type.
C++ interfaces for soca_vertconv_mod::soca_vertconv.
subroutine soca_vertconv_delete_c(c_key_self)
C++ interface for soca_vertconv_mod::soca_vertconv destructor.
subroutine soca_vertconv_setup_c(c_key_self, c_conf, c_key_bkg, c_key_geom)
Linked list implementation.
subroutine soca_vertconv_multad_c(c_key_m, c_key_a, c_key_self)
C++ interface for soca_vertconv_mod::soca_vertconv::mult_ad()
subroutine soca_vertconv_mult_c(c_key_a, c_key_m, c_key_self)
C++ interface for soca_vertconv_mod::soca_vertconv::mult()
type(registry_t), public soca_vertconv_registry
Linked list interface - defines registry_t type.
variable transform: vertical convolution
Geometry data structure.
Variable transform for vertical convolution.