OOPS
qg_gom_interface.F90
Go to the documentation of this file.
1 ! (C) Copyright 2009-2016 ECMWF.
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 ! In applying this licence, ECMWF does not waive the privileges and immunities
6 ! granted to it by virtue of its status as an intergovernmental organisation nor
7 ! does it submit to any jurisdiction.
8 
10 
11 use atlas_module, only: atlas_field
12 use fckit_configuration_module, only: fckit_configuration
13 use iso_c_binding
14 use qg_geom_mod
15 use qg_gom_mod
16 use qg_locs_mod
18 
19 implicit none
20 
21 private
22 ! ------------------------------------------------------------------------------
23 contains
24 ! ------------------------------------------------------------------------------
25 !> Setup GOM
26 subroutine qg_gom_setup_c(c_key_self,c_locs,c_vars) bind(c,name='qg_gom_setup_f90')
27 
28 implicit none
29 
30 ! Passed variables
31 integer(c_int),intent(inout) :: c_key_self !< GOM
32 type(c_ptr),value,intent(in) :: c_locs !< Locations
33 type(c_ptr),value,intent(in) :: c_vars !< Variables
34 
35 ! Local variables
36 type(qg_gom),pointer :: self
37 type(qg_locs) :: locs
38 type(oops_variables) :: vars
39 
40 ! Interface
41 call qg_gom_registry%init()
42 call qg_gom_registry%add(c_key_self)
43 call qg_gom_registry%get(c_key_self,self)
44 locs = qg_locs(c_locs)
45 vars = oops_variables(c_vars)
46 
47 ! Call Fortran
48 call qg_gom_setup(self,locs%nlocs(),vars)
49 
50 end subroutine qg_gom_setup_c
51 ! ------------------------------------------------------------------------------
52 !> Create GOM
53 subroutine qg_gom_create_c(c_key_self) bind(c,name='qg_gom_create_f90')
54 
55 implicit none
56 
57 ! Passed variables
58 integer(c_int),intent(inout) :: c_key_self !< GOM
59 
60 ! Local variables
61 type(qg_gom),pointer :: self
62 
63 ! Interface
64 call qg_gom_registry%init()
65 call qg_gom_registry%add(c_key_self)
66 call qg_gom_registry%get(c_key_self,self)
67 
68 ! Call Fortran
69 call qg_gom_create(self)
70 
71 end subroutine qg_gom_create_c
72 ! ------------------------------------------------------------------------------
73 !> Delete GOM
74 subroutine qg_gom_delete_c(c_key_self) bind(c,name='qg_gom_delete_f90')
75 
76 implicit none
77 
78 ! Passed variables
79 integer(c_int),intent(inout) :: c_key_self !< GOM
80 
81 ! Local variables
82 type(qg_gom),pointer :: self
83 
84 
85 ! Interface
86 call qg_gom_registry%get(c_key_self,self)
87 
88 ! Call Fortran
89 call qg_gom_delete(self)
90 
91 ! Clear interface
92 call qg_gom_registry%remove(c_key_self)
93 
94 end subroutine qg_gom_delete_c
95 ! ------------------------------------------------------------------------------
96 !> Copy GOM
97 subroutine qg_gom_copy_c(c_key_self,c_key_other) bind(c,name='qg_gom_copy_f90')
98 
99 implicit none
100 
101 ! Passed variables
102 integer(c_int),intent(in) :: c_key_self !< GOM
103 integer(c_int),intent(in) :: c_key_other !< Other GOM
104 
105 ! Local variables
106 type(qg_gom),pointer :: self
107 type(qg_gom),pointer :: other
108 
109 ! Interface
110 call qg_gom_registry%get(c_key_self,self)
111 call qg_gom_registry%get(c_key_other,other)
112 
113 ! Call Fortran
114 call qg_gom_copy(self,other)
115 
116 end subroutine qg_gom_copy_c
117 ! ------------------------------------------------------------------------------
118 !> Set GOM to zero
119 subroutine qg_gom_zero_c(c_key_self) bind(c,name='qg_gom_zero_f90')
120 
121 implicit none
122 
123 ! Passed variables
124 integer(c_int),intent(in) :: c_key_self !< GOM
125 
126 ! Local variables
127 type(qg_gom),pointer :: self
128 
129 ! Interface
130 call qg_gom_registry%get(c_key_self,self)
131 
132 ! Call Fortran
133 call qg_gom_zero(self)
134 
135 end subroutine qg_gom_zero_c
136 ! ------------------------------------------------------------------------------
137 !> Get GOM absolute value
138 subroutine qg_gom_abs_c(c_key_self) bind(c,name='qg_gom_abs_f90')
139 
140 implicit none
141 
142 ! Passed variables
143 integer(c_int),intent(in) :: c_key_self !< GOM
144 
145 ! Local variables
146 type(qg_gom),pointer :: self
147 
148 ! Interface
149 call qg_gom_registry%get(c_key_self,self)
150 
151 ! Call Fortran
152 call qg_gom_abs(self)
153 
154 end subroutine qg_gom_abs_c
155 ! ------------------------------------------------------------------------------
156 !> Generate random GOM
157 subroutine qg_gom_random_c(c_key_self) bind(c,name='qg_gom_random_f90')
158 
159 implicit none
160 
161 ! Passed variables
162 integer(c_int),intent(in) :: c_key_self !< GOM
163 
164 ! Local variables
165 type(qg_gom),pointer :: self
166 
167 ! Interface
168 call qg_gom_registry%get(c_key_self,self)
169 
170 ! Call Fortran
171 call qg_gom_random(self)
172 
173 end subroutine qg_gom_random_c
174 ! ------------------------------------------------------------------------------
175 !> Multiply GOM with a scalar
176 subroutine qg_gom_mult_c(c_key_self,zz) bind(c,name='qg_gom_mult_f90')
177 
178 implicit none
179 
180 ! Passed variables
181 integer(c_int),intent(in) :: c_key_self !< GOM
182 real(c_double),intent(in) :: zz !< Multiplier
183 
184 ! Local variables
185 type(qg_gom),pointer :: self
186 integer :: jo,jv
187 
188 ! Interface
189 call qg_gom_registry%get(c_key_self,self)
190 
191 ! Call Fortran
192 do jo=1,self%nobs
193  do jv=1,self%nv
194  self%values(jv,jo) = zz * self%values(jv,jo)
195  enddo
196 enddo
197 
198 end subroutine qg_gom_mult_c
199 ! ------------------------------------------------------------------------------
200 !> Add GOM
201 subroutine qg_gom_add_c(c_key_self,c_key_other) bind(c,name='qg_gom_add_f90')
202 
203 implicit none
204 
205 ! Passed variables
206 integer(c_int),intent(in) :: c_key_self !< GOM
207 integer(c_int),intent(in) :: c_key_other !< Other GOM
208 
209 ! Local variables
210 type(qg_gom),pointer :: self
211 type(qg_gom),pointer :: other
212 
213 ! Interface
214 call qg_gom_registry%get(c_key_self,self)
215 call qg_gom_registry%get(c_key_other,other)
216 
217 ! Call Fortran
218 call qg_gom_add(self,other)
219 
220 end subroutine qg_gom_add_c
221 ! ------------------------------------------------------------------------------
222 !> Subtract GOM
223 subroutine qg_gom_diff_c(c_key_self,c_key_other) bind(c,name='qg_gom_diff_f90')
224 
225 implicit none
226 
227 ! Passed variables
228 integer(c_int),intent(in) :: c_key_self !< GOM
229 integer(c_int),intent(in) :: c_key_other !< Other GOM
230 
231 ! Local variables
232 type(qg_gom),pointer :: self
233 type(qg_gom),pointer :: other
234 
235 ! Interface
236 call qg_gom_registry%get(c_key_self,self)
237 call qg_gom_registry%get(c_key_other,other)
238 
239 ! Call Fortran
240 call qg_gom_diff(self,other)
241 
242 end subroutine qg_gom_diff_c
243 ! ------------------------------------------------------------------------------
244 !> Schur product for GOM
245 subroutine qg_gom_schurmult_c(c_key_self,c_key_other) bind(c,name='qg_gom_schurmult_f90')
246 
247 implicit none
248 
249 ! Passed variables
250 integer(c_int),intent(in) :: c_key_self !< GOM
251 integer(c_int),intent(in) :: c_key_other !< Other GOM
252 
253 ! Local variables
254 type(qg_gom),pointer :: self
255 type(qg_gom),pointer :: other
256 
257 ! Interface
258 call qg_gom_registry%get(c_key_self,self)
259 call qg_gom_registry%get(c_key_other,other)
260 
261 ! Call Fortran
262 call qg_gom_schurmult(self,other)
263 
264 end subroutine qg_gom_schurmult_c
265 ! ------------------------------------------------------------------------------
266 !> Schur division for GOM
267 subroutine qg_gom_divide_c(c_key_self,c_key_other) bind(c,name='qg_gom_divide_f90')
268 
269 implicit none
270 
271 ! Passed variables
272 integer(c_int),intent(in) :: c_key_self !< GOM
273 integer(c_int),intent(in) :: c_key_other !< Other GOM
274 
275 ! Local variables
276 type(qg_gom),pointer :: self
277 type(qg_gom),pointer :: other
278 
279 ! Interface
280 call qg_gom_registry%get(c_key_self,self)
281 call qg_gom_registry%get(c_key_other,other)
282 
283 ! Call Fortran
284 call qg_gom_divide(self,other)
285 
286 end subroutine qg_gom_divide_c
287 ! ------------------------------------------------------------------------------
288 !> Compute GOM RMS
289 subroutine qg_gom_rms_c(c_key_self,rms) bind(c,name='qg_gom_rms_f90')
290 
291 implicit none
292 
293 ! Passed variables
294 integer(c_int),intent(in) :: c_key_self !< GOM
295 real(c_double),intent(inout) :: rms !< RMS
296 
297 ! Local variables
298 type(qg_gom),pointer :: self
299 
300 ! Interface
301 call qg_gom_registry%get(c_key_self,self)
302 
303 ! Call Fortran
304 call qg_gom_rms(self,rms)
305 
306 end subroutine qg_gom_rms_c
307 ! ------------------------------------------------------------------------------
308 !> GOM dot product
309 subroutine qg_gom_dotprod_c(c_key_gom1,c_key_gom2,prod) bind(c,name='qg_gom_dotprod_f90')
310 
311 implicit none
312 
313 ! Passed variables
314 integer(c_int),intent(in) :: c_key_gom1 !< GOM 1
315 integer(c_int),intent(in) :: c_key_gom2 !< GOM 2
316 real(c_double),intent(inout) :: prod !< Dot product
317 
318 ! Local variables
319 type(qg_gom),pointer :: gom1,gom2
320 
321 ! Interface
322 call qg_gom_registry%get(c_key_gom1,gom1)
323 call qg_gom_registry%get(c_key_gom2,gom2)
324 
325 ! Call Fortran
326 call qg_gom_dotprod(gom1,gom2,prod)
327 
328 end subroutine qg_gom_dotprod_c
329 ! ------------------------------------------------------------------------------
330 !> Compute GOM statistics
331 subroutine qg_gom_stats_c(c_key_self,kobs,scaling,pmin,pmax,prms) bind(c,name='qg_gom_stats_f90')
332 
333 implicit none
334 
335 ! Passed variables
336 integer(c_int),intent(in) :: c_key_self !< GOM
337 integer(c_int),intent(inout) :: kobs !< Number of observations
338 real(c_double),intent(inout) :: scaling !< Scaling value
339 real(c_double),intent(inout) :: pmin !< Minimum value
340 real(c_double),intent(inout) :: pmax !< Maximum value
341 real(c_double),intent(inout) :: prms !< RMS
342 
343 ! Local variables
344 type(qg_gom),pointer :: self
345 
346 ! Interface
347 call qg_gom_registry%get(c_key_self,self)
348 
349 ! Call Fortran
350 call qg_gom_stats(self,kobs,scaling,pmin,pmax,prms)
351 
352 end subroutine qg_gom_stats_c
353 ! ------------------------------------------------------------------------------
354 !> Find and locate GOM max. value
355 subroutine qg_gom_maxloc_c(c_key_self,mxval,iloc,ivar) bind(c,name='qg_gom_maxloc_f90')
356 
357 implicit none
358 
359 ! Passed variables
360 integer(c_int),intent(in) :: c_key_self !< GOM
361 real(c_double),intent(inout) :: mxval !< Maximum value
362 integer(c_int),intent(inout) :: iloc !< Location of maximum value
363 integer(c_int),intent(inout) :: ivar !< Variable with maximum value
364 
365 ! Local variables
366 type(qg_gom),pointer :: self
367 
368 ! Interface
369 call qg_gom_registry%get(c_key_self,self)
370 
371 ! Call Fortran
372 call qg_gom_maxloc(self,mxval,iloc,ivar)
373 
374 end subroutine qg_gom_maxloc_c
375 ! ------------------------------------------------------------------------------
376 !> Read GOM from file
377 subroutine qg_gom_read_file_c(c_key_self,c_conf) bind(c,name='qg_gom_read_file_f90')
378 
379 implicit none
380 
381 ! Passed variables
382 integer(c_int),intent(in) :: c_key_self !< GOM
383 type(c_ptr),value,intent(in) :: c_conf !< Configuration
384 
385 ! Local variables
386 type(fckit_configuration) :: f_conf
387 type(qg_gom),pointer :: self
388 
389 ! Interface
390 f_conf = fckit_configuration(c_conf)
391 call qg_gom_registry%get(c_key_self,self)
392 
393 ! Call Fortran
394 call qg_gom_read_file(self,f_conf)
395 
396 end subroutine qg_gom_read_file_c
397 ! ------------------------------------------------------------------------------
398 !> Write GOM to file
399 subroutine qg_gom_write_file_c(c_key_self,c_conf) bind(c,name='qg_gom_write_file_f90')
400 
401 implicit none
402 
403 ! Passed variables
404 integer(c_int),intent(in) :: c_key_self !< GOM
405 type(c_ptr),value,intent(in) :: c_conf !< Configuration
406 
407 ! Local variables
408 type(fckit_configuration) :: f_conf
409 type(qg_gom),pointer :: self
410 
411 ! Interface
412 f_conf = fckit_configuration(c_conf)
413 call qg_gom_registry%get(c_key_self,self)
414 
415 ! Call Fortran
416 call qg_gom_write_file(self,f_conf)
417 
418 end subroutine qg_gom_write_file_c
419 ! ------------------------------------------------------------------------------
420 !> GOM analytic initialization
421 subroutine qg_gom_analytic_init_c(c_key_self,c_locs,c_conf) bind(c,name='qg_gom_analytic_init_f90')
422 
423 implicit none
424 
425 ! Passed variables
426 integer(c_int),intent(in) :: c_key_self !< GOM
427 type(c_ptr),value,intent(in) :: c_locs !< Locations
428 type(c_ptr),value,intent(in) :: c_conf !< Configuration
429 
430 ! Local variables
431 type(fckit_configuration) :: f_conf
432 type(qg_gom),pointer :: self
433 type(qg_locs) :: locs
434 
435 ! Interface
436 f_conf = fckit_configuration(c_conf)
437 call qg_gom_registry%get(c_key_self,self)
438 locs = qg_locs(c_locs)
439 
440 ! Call Fortran
441 call qg_gom_analytic_init(self,locs,f_conf)
442 
443 end subroutine qg_gom_analytic_init_c
444 ! ------------------------------------------------------------------------------
445 end module qg_gom_interface
qg_gom_interface::qg_gom_delete_c
subroutine qg_gom_delete_c(c_key_self)
Delete GOM.
Definition: qg_gom_interface.F90:75
qg_geom_mod
Definition: qg_geom_mod.F90:9
qg_gom_interface::qg_gom_rms_c
subroutine qg_gom_rms_c(c_key_self, rms)
Compute GOM RMS.
Definition: qg_gom_interface.F90:290
qg_gom_mod::qg_gom_zero
subroutine, public qg_gom_zero(self)
Set GOM to zero.
Definition: qg_gom_mod.F90:161
qg_gom_interface::qg_gom_random_c
subroutine qg_gom_random_c(c_key_self)
Generate random GOM.
Definition: qg_gom_interface.F90:158
qg_gom_interface::qg_gom_add_c
subroutine qg_gom_add_c(c_key_self, c_key_other)
Add GOM.
Definition: qg_gom_interface.F90:202
qg_gom_mod::qg_gom_copy
subroutine, public qg_gom_copy(self, other)
Copy GOM.
Definition: qg_gom_mod.F90:133
qg_gom_interface
Definition: qg_gom_interface.F90:9
qg_gom_mod::qg_gom_setup
subroutine, public qg_gom_setup(self, nobs, vars)
Linked list implementation.
Definition: qg_gom_mod.F90:62
qg_gom_interface::qg_gom_analytic_init_c
subroutine qg_gom_analytic_init_c(c_key_self, c_locs, c_conf)
GOM analytic initialization.
Definition: qg_gom_interface.F90:422
oops_variables_mod
Fortran interface to Variables.
Definition: variables_mod.F90:9
qg_locs_mod
Definition: qg_locs_mod.F90:9
qg_gom_mod::qg_gom_dotprod
subroutine, public qg_gom_dotprod(gom1, gom2, prod)
GOM dot product.
Definition: qg_gom_mod.F90:340
qg_gom_mod::qg_gom_stats
subroutine, public qg_gom_stats(self, kobs, scaling, pmin, pmax, prms)
Compute GOM stats.
Definition: qg_gom_mod.F90:368
qg_gom_mod::qg_gom_registry
type(registry_t), public qg_gom_registry
Linked list interface - defines registry_t type.
Definition: qg_gom_mod.F90:51
qg_locs_mod::qg_locs
Definition: qg_locs_mod.F90:22
qg_gom_mod::qg_gom
Definition: qg_gom_mod.F90:33
qg_gom_interface::qg_gom_maxloc_c
subroutine qg_gom_maxloc_c(c_key_self, mxval, iloc, ivar)
Find and locate GOM max. value.
Definition: qg_gom_interface.F90:356
qg_gom_interface::qg_gom_zero_c
subroutine qg_gom_zero_c(c_key_self)
Set GOM to zero.
Definition: qg_gom_interface.F90:120
qg_gom_mod::qg_gom_delete
subroutine, public qg_gom_delete(self)
Delete GOM.
Definition: qg_gom_mod.F90:118
qg_gom_mod::qg_gom_create
subroutine, public qg_gom_create(self)
Create GOM.
Definition: qg_gom_mod.F90:105
qg_gom_interface::qg_gom_schurmult_c
subroutine qg_gom_schurmult_c(c_key_self, c_key_other)
Schur product for GOM.
Definition: qg_gom_interface.F90:246
qg_gom_mod::qg_gom_diff
subroutine, public qg_gom_diff(self, other)
Subtract GOM.
Definition: qg_gom_mod.F90:242
qg_gom_mod::qg_gom_read_file
subroutine, public qg_gom_read_file(self, f_conf)
Read GOM from file.
Definition: qg_gom_mod.F90:429
qg_gom_interface::qg_gom_create_c
subroutine qg_gom_create_c(c_key_self)
Create GOM.
Definition: qg_gom_interface.F90:54
qg_gom_mod::qg_gom_abs
subroutine, public qg_gom_abs(self)
Get GOM absolute value.
Definition: qg_gom_mod.F90:174
qg_gom_mod::qg_gom_rms
subroutine, public qg_gom_rms(self, rms)
Compute GOM RMS.
Definition: qg_gom_mod.F90:313
qg_gom_interface::qg_gom_stats_c
subroutine qg_gom_stats_c(c_key_self, kobs, scaling, pmin, pmax, prms)
Compute GOM statistics.
Definition: qg_gom_interface.F90:332
qg_gom_interface::qg_gom_read_file_c
subroutine qg_gom_read_file_c(c_key_self, c_conf)
Read GOM from file.
Definition: qg_gom_interface.F90:378
qg_gom_interface::qg_gom_copy_c
subroutine qg_gom_copy_c(c_key_self, c_key_other)
Copy GOM.
Definition: qg_gom_interface.F90:98
qg_gom_mod::qg_gom_maxloc
subroutine, public qg_gom_maxloc(self, mxval, iloc, ivar)
Find and locate GOM max. value.
Definition: qg_gom_mod.F90:405
qg_gom_interface::qg_gom_write_file_c
subroutine qg_gom_write_file_c(c_key_self, c_conf)
Write GOM to file.
Definition: qg_gom_interface.F90:400
qg_gom_interface::qg_gom_divide_c
subroutine qg_gom_divide_c(c_key_self, c_key_other)
Schur division for GOM.
Definition: qg_gom_interface.F90:268
qg_gom_mod::qg_gom_write_file
subroutine, public qg_gom_write_file(self, f_conf)
Write GOM to file.
Definition: qg_gom_mod.F90:488
oops_variables_mod::oops_variables
Definition: variables_mod.F90:16
qg_gom_mod::qg_gom_random
subroutine, public qg_gom_random(self)
Generate random GOM values.
Definition: qg_gom_mod.F90:187
qg_gom_mod
Definition: qg_gom_mod.F90:9
qg_gom_interface::qg_gom_diff_c
subroutine qg_gom_diff_c(c_key_self, c_key_other)
Subtract GOM.
Definition: qg_gom_interface.F90:224
qg_gom_mod::qg_gom_add
subroutine, public qg_gom_add(self, other)
Add GOM.
Definition: qg_gom_mod.F90:221
qg_gom_interface::qg_gom_mult_c
subroutine qg_gom_mult_c(c_key_self, zz)
Multiply GOM with a scalar.
Definition: qg_gom_interface.F90:177
qg_gom_mod::qg_gom_schurmult
subroutine, public qg_gom_schurmult(self, other)
Schur product for GOM.
Definition: qg_gom_mod.F90:263
qg_gom_interface::qg_gom_dotprod_c
subroutine qg_gom_dotprod_c(c_key_gom1, c_key_gom2, prod)
GOM dot product.
Definition: qg_gom_interface.F90:310
qg_gom_mod::qg_gom_analytic_init
subroutine, public qg_gom_analytic_init(self, locs, f_conf)
GOM analytic initialization.
Definition: qg_gom_mod.F90:539
qg_gom_interface::qg_gom_abs_c
subroutine qg_gom_abs_c(c_key_self)
Get GOM absolute value.
Definition: qg_gom_interface.F90:139
qg_gom_mod::qg_gom_divide
subroutine, public qg_gom_divide(self, other)
Schur division for GOM.
Definition: qg_gom_mod.F90:284
qg_gom_interface::qg_gom_setup_c
subroutine qg_gom_setup_c(c_key_self, c_locs, c_vars)
Setup GOM.
Definition: qg_gom_interface.F90:27