SOCA
soca_balance.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++ interface for soca_balance_mod::soca_balance
8 
9 use fckit_configuration_module, only: fckit_configuration
10 use iso_c_binding
11 
12 ! soca modules
15 use soca_geom_mod, only: soca_geom
18 use soca_state_mod, only: soca_state
20 
21 implicit none
22 private
23 
24 
25 #define LISTED_TYPE soca_balance
26 
27 !> Linked list interface - defines registry_t type
28 #include "oops/util/linkedList_i.f"
29 
30 !> Global registry for soca_balance_mod::soca_balance
31 type(registry_t), public :: soca_balance_registry
32 
33 
34 ! ------------------------------------------------------------------------------
35 contains
36 ! ------------------------------------------------------------------------------
37 
38 
39 !> Linked list implementation
40 #include "oops/util/linkedList_c.f"
41 
42 ! ------------------------------------------------------------------------------
43 !> C++ interface for soca_balance_mod::soca_balance::setup()
44 subroutine soca_balance_setup_c(c_key_self, c_conf, c_key_traj, c_key_geom) &
45  bind(c,name='soca_balance_setup_f90')
46 
47  integer(c_int), intent(inout) :: c_key_self !< The D structure
48  type(c_ptr), intent(in) :: c_conf !< The configuration
49  integer(c_int), intent(in) :: c_key_traj !< Background field
50  integer(c_int), intent(in) :: c_key_geom !< Geometry
51 
52  type(soca_state), pointer :: traj
53  type(soca_balance), pointer :: self
54  type(soca_geom), pointer :: geom
55 
56  call soca_balance_registry%init()
57  call soca_balance_registry%add(c_key_self)
58  call soca_balance_registry%get(c_key_self, self)
59  call soca_state_registry%get(c_key_traj, traj)
60  call soca_geom_registry%get(c_key_geom, geom)
61 
62  call self%setup(fckit_configuration(c_conf), traj, geom)
63 end subroutine soca_balance_setup_c
64 
65 
66 ! ------------------------------------------------------------------------------
67 !> C++ interface for soca_balance_mod::soca_balance::delete()
68 subroutine soca_balance_delete_c(c_key_self) &
69  bind(c,name='soca_balance_delete_f90')
70 
71  integer(c_int), intent(inout) :: c_key_self
72 
73  type(soca_balance), pointer :: self
74 
75  call soca_balance_registry%get(c_key_self,self)
76  call self%delete()
77  call soca_balance_registry%remove(c_key_self)
78 end subroutine soca_balance_delete_c
79 
80 
81 ! ------------------------------------------------------------------------------
82 !> C++ interface for soca_balance_mod::soca_balance::mult()
83 subroutine soca_balance_mult_c(c_key_self, c_key_a, c_key_m)&
84  bind(c,name='soca_balance_mult_f90')
85 
86  integer(c_int), intent(in) :: c_key_a !< " to Increment in
87  integer(c_int), intent(in) :: c_key_m !< " to Increment out
88  integer(c_int), intent(in) :: c_key_self
89 
90  type(soca_increment), pointer :: dxa
91  type(soca_increment), pointer :: dxm
92  type(soca_balance), pointer :: self
93 
94  call soca_increment_registry%get(c_key_a,dxa)
95  call soca_increment_registry%get(c_key_m,dxm)
96  call soca_balance_registry%get(c_key_self,self)
97 
98  !< Computes dxm = K dxa
99  call self%mult(dxa, dxm)
100 end subroutine soca_balance_mult_c
101 
102 
103 ! ------------------------------------------------------------------------------
104 !> C++ interface for soca_balance_mod::soca_balance::multinv()
105 !!
106 !! Multiplication inverse
107 subroutine soca_balance_multinv_c(c_key_self, c_key_m, c_key_a)&
108  bind(c,name='soca_balance_multinv_f90')
109 
110  integer(c_int), intent(in) :: c_key_a !< " to Increment in
111  integer(c_int), intent(in) :: c_key_m !< " to Increment out
112  integer(c_int), intent(in) :: c_key_self
113 
114  type(soca_increment), pointer :: dxa
115  type(soca_increment), pointer :: dxm
116  type(soca_balance), pointer :: self
117 
118  call soca_increment_registry%get(c_key_a,dxa)
119  call soca_increment_registry%get(c_key_m,dxm)
120  call soca_balance_registry%get(c_key_self,self)
121 
122  !< Computes dxa = K^-1 dxm
123  call self%multinv(dxa, dxm)
124 end subroutine soca_balance_multinv_c
125 
126 
127 ! ------------------------------------------------------------------------------
128 !> C++ interface for soca_balance_mod::soca_balance::multad()
129 !!
130 !! Multiplication adjoint
131 subroutine soca_balance_multad_c(c_key_self, c_key_m, c_key_a)&
132  bind(c,name='soca_balance_multad_f90')
133 
134  integer(c_int), intent(in) :: c_key_a !< " to Increment in
135  integer(c_int), intent(in) :: c_key_m !< " to Increment out
136  integer(c_int), intent(in) :: c_key_self
137 
138  type(soca_increment), pointer :: dxa
139  type(soca_increment), pointer :: dxm
140  type(soca_balance), pointer :: self
141 
142  call soca_increment_registry%get(c_key_a,dxa)
143  call soca_increment_registry%get(c_key_m,dxm)
144  call soca_balance_registry%get(c_key_self,self)
145 
146  !< Computes dxa = K^T dxm
147  call self%multad(dxa, dxm)
148 end subroutine soca_balance_multad_c
149 
150 
151 ! ------------------------------------------------------------------------------
152 !> C++ interface for soca_balance_mod::soca_balance::multinvad()
153 !!
154 !! Multiplication inverse adjoint
155 subroutine soca_balance_multinvad_c(c_key_self, c_key_a, c_key_m)&
156  bind(c,name='soca_balance_multinvad_f90')
157 
158  integer(c_int), intent(in) :: c_key_a !< " to Increment in
159  integer(c_int), intent(in) :: c_key_m !< " to Increment out
160  integer(c_int), intent(in) :: c_key_self
161 
162  type(soca_increment), pointer :: dxa
163  type(soca_increment), pointer :: dxm
164  type(soca_balance), pointer :: self
165 
166  call soca_increment_registry%get(c_key_a,dxa)
167  call soca_increment_registry%get(c_key_m,dxm)
168  call soca_balance_registry%get(c_key_self,self)
169 
170  !< Computes dxm = (K^-1)^T dxa
171  call self%multinvad(dxa, dxm)
172 end subroutine soca_balance_multinvad_c
173 
174 end module soca_balance_mod_c
C++ interface for soca_balance_mod::soca_balance.
subroutine soca_balance_multad_c(c_key_self, c_key_m, c_key_a)
C++ interface for soca_balance_mod::soca_balance::multad()
subroutine soca_balance_setup_c(c_key_self, c_conf, c_key_traj, c_key_geom)
Linked list implementation.
subroutine soca_balance_delete_c(c_key_self)
C++ interface for soca_balance_mod::soca_balance::delete()
subroutine soca_balance_multinvad_c(c_key_self, c_key_a, c_key_m)
C++ interface for soca_balance_mod::soca_balance::multinvad()
type(registry_t), public soca_balance_registry
Linked list interface - defines registry_t type.
subroutine soca_balance_multinv_c(c_key_self, c_key_m, c_key_a)
C++ interface for soca_balance_mod::soca_balance::multinv()
subroutine soca_balance_mult_c(c_key_self, c_key_a, c_key_m)
C++ interface for soca_balance_mod::soca_balance::mult()
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.
Variable transform for the balance operators (K)
Geometry data structure.