Debian Codegraph @

src/atlas_f/functionspace/atlas_functionspace_NodeColumns_module.fypp

raw
1 ! (C) Copyright 2013 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
9 #include "atlas/atlas_f.h"
10 #:include "internals/atlas_generics.fypp"
11
12 #:set ranks = [0,1]
13
14 module atlas_functionspace_NodeColumns_module
15
16 use fckit_c_interop_module, only : c_str, c_ptr_to_string, c_ptr_free
17 use atlas_functionspace_module, only : atlas_FunctionSpace
18 use atlas_Field_module, only: atlas_Field
19 use atlas_FieldSet_module, only: atlas_FieldSet
20 use atlas_Mesh_module, only: atlas_Mesh
21 use atlas_mesh_Nodes_module, only: atlas_mesh_Nodes
22 use atlas_GatherScatter_module, only: atlas_GatherScatter
23 use atlas_HaloExchange_module, only: atlas_HaloExchange
24 use atlas_Checksum_module, only: atlas_Checksum
25 use atlas_Config_module, only: atlas_Config
26 use atlas_kinds_module, only: ATLAS_KIND_GIDX
27
28 implicit none
29
30 private :: c_str, c_ptr_to_string, c_ptr_free
31 private :: atlas_FunctionSpace
32 private :: atlas_Field
33 private :: atlas_FieldSet
34 private :: atlas_mesh_Nodes
35 private :: atlas_GatherScatter
36 private :: atlas_HaloExchange
37 private :: atlas_Checksum
38 private :: atlas_Mesh
39 private :: atlas_Config
40 private :: ATLAS_KIND_GIDX
41
42 public :: atlas_functionspace_NodeColumns
43
44 private
45
46 !------------------------------------------------------------------------------
47 TYPE, extends(atlas_FunctionSpace) :: atlas_functionspace_NodeColumns
48
49 ! Purpose :
50 ! -------
51 ! *atlas_functionspace_NodeColumns* : Interpretes fields defined in nodes
52
53 ! Methods :
54 ! -------
55
56 ! Author :
57 ! ------
58 ! August-2015 Willem Deconinck *ECMWF*
59
60 !------------------------------------------------------------------------------
61 contains
62
63
64 procedure, public :: nb_nodes
65 procedure, public :: mesh
66 procedure, public :: nodes
67
68 procedure, public :: get_halo_exchange
69
70 procedure, private :: gather_fieldset
71 procedure, private :: gather_field
72 generic, public :: gather => gather_fieldset, gather_field
73 procedure, public :: get_gather
74
75 procedure, private :: scatter_fieldset
76 procedure, private :: scatter_field
77 generic, public :: scatter => scatter_fieldset, scatter_field
78 procedure, public :: get_scatter
79
80 procedure, private :: checksum_fieldset
81 procedure, private :: checksum_field
82 generic, public :: checksum => checksum_fieldset, checksum_field
83 procedure, public :: get_checksum
84
85
86 procedure, public :: minimum_per_level
87
88 procedure, public :: maximum_per_level
89
90 procedure, public :: minimum_and_location_per_level => &
91 & minloc_per_level
92
93 procedure, public :: maximum_and_location_per_level => &
94 & maxloc_per_level
95
96 procedure, public :: sum_per_level
97
98 procedure, public :: order_independent_sum_per_level
99
100 procedure, public :: mean_per_level
101
102 @:generic_public_interface( minimum )
103 @:generic_public_interface( maximum )
104 @:generic_public_interface_2( minimum_and_location, prefix1=minloc, prefix2=minloclev )
105 @:generic_public_interface_2( maximum_and_location, prefix1=maxloc, prefix2=maxloclev )
106 @:generic_public_interface( sum )
107 @:generic_public_interface( order_independent_sum )
108 @:generic_public_interface( mean )
109 @:generic_public_interface( mean_and_standard_deviation, prefix=mean_and_stddev )
110
111 procedure, public :: mean_and_standard_deviation_per_level => &
112 & mean_and_stddev_per_level
113
114 #if FCKIT_FINAL_NOT_INHERITING
115 final :: atlas_functionspace_NodeColumns__final_auto
116 #endif
117
118 END TYPE atlas_functionspace_NodeColumns
119
120 interface atlas_functionspace_NodeColumns
121 module procedure constructor__cptr
122 module procedure constructor
123 end interface
124
125 !------------------------------------------------------------------------------
126
127 !========================================================
128 contains
129 !========================================================
130
131 !------------------------------------------------------------------------------
132
133 function constructor__cptr(cptr) result(this)
134 use, intrinsic :: iso_c_binding, only : c_ptr
135 type(atlas_functionspace_NodeColumns) :: this
136 type(c_ptr), intent(in) :: cptr
137 call this%reset_c_ptr( cptr )
138 call this%return()
139 end function
140
141 !------------------------------------------------------------------------------
142
143 function constructor(mesh,halo,levels) result(this)
144 use atlas_functionspace_NodeColumns_c_binding
145 type(atlas_functionspace_NodeColumns) :: this
146 type(atlas_Mesh), intent(inout) :: mesh
147 integer, intent(in), optional :: halo
148 integer, intent(in), optional :: levels
149 type(atlas_Config) :: config
150 config = atlas_Config()
151 if( present(halo) ) call config%set("halo",halo)
152 if( present(levels) ) call config%set("levels",levels)
153 call this%reset_c_ptr( atlas__NodesFunctionSpace__new(mesh%CPTR_PGIBUG_A,config%CPTR_PGIBUG_B) )
154 call config%final()
155 call this%return()
156 end function
157
158 !------------------------------------------------------------------------------
159
160 function nb_nodes(this)
161 use atlas_functionspace_NodeColumns_c_binding
162 integer :: nb_nodes
163 class(atlas_functionspace_NodeColumns), intent(in) :: this
164 nb_nodes = atlas__NodesFunctionSpace__nb_nodes(this%CPTR_PGIBUG_A)
165 end function
166
167 !------------------------------------------------------------------------------
168
169 function mesh(this)
170 use atlas_functionspace_NodeColumns_c_binding
171 type(atlas_Mesh) :: mesh
172 class(atlas_functionspace_NodeColumns), intent(in) :: this
173 call mesh%reset_c_ptr( atlas__NodesFunctionSpace__mesh(this%CPTR_PGIBUG_A) )
174 call mesh%return()
175 end function
176
177 !------------------------------------------------------------------------------
178
179 function nodes(this)
180 use atlas_functionspace_NodeColumns_c_binding
181 type(atlas_mesh_Nodes) :: nodes
182 class(atlas_functionspace_NodeColumns), intent(in) :: this
183 call nodes%reset_c_ptr( atlas__NodesFunctionSpace__nodes(this%CPTR_PGIBUG_A) )
184 call nodes%return()
185 end function
186
187 !------------------------------------------------------------------------------
188
189 function get_gather(this) result(gather)
190 use atlas_functionspace_NodeColumns_c_binding
191 type(atlas_GatherScatter) :: gather
192 class(atlas_functionspace_NodeColumns), intent(in) :: this
193 call gather%reset_c_ptr( atlas__NodesFunctioNSpace__get_gather(this%CPTR_PGIBUG_A) )
194 end function
195
196 !------------------------------------------------------------------------------
197
198 function get_scatter(this) result(gather)
199 use atlas_functionspace_NodeColumns_c_binding
200 type(atlas_GatherScatter) :: gather
201 class(atlas_functionspace_NodeColumns), intent(in) :: this
202 call gather%reset_c_ptr( atlas__NodesFunctioNSpace__get_scatter(this%CPTR_PGIBUG_A) )
203 end function
204
205 !------------------------------------------------------------------------------
206
207 subroutine gather_fieldset(this,local,global)
208 use atlas_functionspace_NodeColumns_c_binding
209 class(atlas_functionspace_NodeColumns), intent(in) :: this
210 type(atlas_FieldSet), intent(in) :: local
211 type(atlas_FieldSet), intent(inout) :: global
212 call atlas__NodesFunctionSpace__gather_fieldset(this%CPTR_PGIBUG_A,local%CPTR_PGIBUG_A,global%CPTR_PGIBUG_A)
213 end subroutine
214
215 !------------------------------------------------------------------------------
216
217 subroutine gather_field(this,local,global)
218 use atlas_functionspace_NodeColumns_c_binding
219 class(atlas_functionspace_NodeColumns), intent(in) :: this
220 type(atlas_Field), intent(in) :: local
221 type(atlas_Field), intent(inout) :: global
222 call atlas__NodesFunctionSpace__gather_field(this%CPTR_PGIBUG_A,local%CPTR_PGIBUG_A,global%CPTR_PGIBUG_A)
223 end subroutine
224
225 !------------------------------------------------------------------------------
226
227 subroutine scatter_fieldset(this,global,local)
228 use atlas_functionspace_NodeColumns_c_binding
229 class(atlas_functionspace_NodeColumns), intent(in) :: this
230 type(atlas_FieldSet), intent(in) :: global
231 type(atlas_FieldSet), intent(inout) :: local
232 call atlas__NodesFunctionSpace__scatter_fieldset(this%CPTR_PGIBUG_A,global%CPTR_PGIBUG_A,local%CPTR_PGIBUG_A)
233 end subroutine
234
235 !------------------------------------------------------------------------------
236
237 subroutine scatter_field(this,global,local)
238 use atlas_functionspace_NodeColumns_c_binding
239 class(atlas_functionspace_NodeColumns), intent(in) :: this
240 type(atlas_Field), intent(in) :: global
241 type(atlas_Field), intent(inout) :: local
242 call atlas__NodesFunctionSpace__scatter_field(this%CPTR_PGIBUG_A,global%CPTR_PGIBUG_A,local%CPTR_PGIBUG_A)
243 end subroutine
244
245 !------------------------------------------------------------------------------
246
247 function get_halo_exchange(this) result(halo_exchange)
248 use atlas_functionspace_NodeColumns_c_binding
249 type(atlas_HaloExchange) :: halo_exchange
250 class(atlas_functionspace_NodeColumns), intent(in) :: this
251 call halo_exchange%reset_c_ptr( atlas__NodesFunctioNSpace__get_halo_exchange(this%CPTR_PGIBUG_A) )
252 end function
253
254 !------------------------------------------------------------------------------
255
256 function get_checksum(this) result(checksum)
257 use atlas_functionspace_NodeColumns_c_binding
258 type(atlas_Checksum) :: checksum
259 class(atlas_functionspace_NodeColumns), intent(in) :: this
260 call checksum%reset_c_ptr( atlas__NodesFunctioNSpace__get_checksum(this%CPTR_PGIBUG_A) )
261 end function
262
263 !------------------------------------------------------------------------------
264
265 function checksum_fieldset(this,fieldset) result(checksum)
266 use atlas_functionspace_NodeColumns_c_binding
267 use, intrinsic :: iso_c_binding, only : c_ptr
268 character(len=:), allocatable :: checksum
269 class(atlas_functionspace_NodeColumns), intent(in) :: this
270 type(atlas_FieldSet), intent(in) :: fieldset
271 type(c_ptr) :: checksum_cptr
272 integer :: checksum_size, checksum_allocated
273 call atlas__NodesFunctionSpace__checksum_fieldset( &
274 this%CPTR_PGIBUG_A,fieldset%CPTR_PGIBUG_A,checksum_cptr,checksum_size,checksum_allocated)
275 allocate(character(len=checksum_size) :: checksum )
276 checksum = c_ptr_to_string(checksum_cptr)
277 if( checksum_allocated == 1 ) call c_ptr_free(checksum_cptr)
278 end function
279
280 !------------------------------------------------------------------------------
281
282 function checksum_field(this,field) result(checksum)
283 use atlas_functionspace_NodeColumns_c_binding
284 use, intrinsic :: iso_c_binding, only : c_ptr
285 character(len=:), allocatable :: checksum
286 class(atlas_functionspace_NodeColumns), intent(in) :: this
287 type(atlas_Field), intent(in) :: field
288 type(c_ptr) :: checksum_cptr
289 integer :: checksum_size, checksum_allocated
290 call atlas__NodesFunctionSpace__checksum_field( &
291 this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A,checksum_cptr,checksum_size,checksum_allocated)
292 allocate(character(len=checksum_size) :: checksum )
293 checksum = c_ptr_to_string(checksum_cptr)
294 if( checksum_allocated == 1 ) call c_ptr_free(checksum_cptr)
295 end function
296
297 !------------------------------------------------------------------------------
298
299 #:for dtype,ftype,ctype in types[:4]
300 subroutine minimum_${dtype}$_r0(this,field,minimum)
301 use atlas_functionspace_NodeColumns_c_binding
302 use, intrinsic :: iso_c_binding, only : c_${ctype}$
303 class(atlas_functionspace_NodeColumns), intent(in) :: this
304 type(atlas_Field) :: field
305 ${ftype}$, intent(out) :: minimum
306 call atlas__NodesFunctionSpace__min_${ctype}$(this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A,minimum)
307 end subroutine
308
309 !------------------------------------------------------------------------------
310
311 subroutine minimum_${dtype}$_r1(this,field,minimum)
312 use atlas_functionspace_NodeColumns_c_binding
313 use, intrinsic :: iso_c_binding, only : c_${ctype}$,c_ptr,c_f_pointer
314 class(atlas_functionspace_NodeColumns), intent(in) :: this
315 type(atlas_Field) :: field
316 ${ftype}$, allocatable, intent(out) :: minimum(:)
317 type(c_ptr) :: min_cptr
318 ${ftype}$, pointer :: min_fptr(:)
319 integer :: min_size
320 call atlas__NodesFunctionSpace__min_arr_${ctype}$(this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A,min_cptr,min_size)
321 call c_f_pointer(min_cptr,min_fptr,(/min_size/))
322 allocate(minimum(min_size))
323 minimum(:) = min_fptr(:)
324 call c_ptr_free(min_cptr)
325 end subroutine
326
327 !------------------------------------------------------------------------------
328
329 subroutine maximum_${dtype}$_r0(this,field,maximum)
330 use atlas_functionspace_NodeColumns_c_binding
331 use, intrinsic :: iso_c_binding, only : c_${ctype}$
332 class(atlas_functionspace_NodeColumns), intent(in) :: this
333 type(atlas_Field) :: field
334 ${ftype}$, intent(out) :: maximum
335 call atlas__NodesFunctionSpace__max_${ctype}$(this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A,maximum)
336 end subroutine
337
338 !------------------------------------------------------------------------------
339
340 subroutine maximum_${dtype}$_r1(this,field,maximum)
341 use atlas_functionspace_NodeColumns_c_binding
342 use, intrinsic :: iso_c_binding, only : c_${ctype}$, c_ptr, c_f_pointer
343 class(atlas_functionspace_NodeColumns), intent(in) :: this
344 type(atlas_Field) :: field
345 ${ftype}$, allocatable, intent(out) :: maximum(:)
346 type(c_ptr) :: max_cptr
347 ${ftype}$, pointer :: max_fptr(:)
348 integer :: max_size
349 call atlas__NodesFunctionSpace__max_arr_${ctype}$(this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A,max_cptr,max_size)
350 call c_f_pointer(max_cptr,max_fptr,(/max_size/))
351 allocate(maximum(max_size))
352 maximum(:) = max_fptr(:)
353 call c_ptr_free(max_cptr)
354 end subroutine
355
356 !------------------------------------------------------------------------------
357
358 subroutine minloc_${dtype}$_r0(this,field,minimum,location)
359 use atlas_functionspace_NodeColumns_c_binding
360 use, intrinsic :: iso_c_binding, only : c_${ctype}$, c_long
361 class(atlas_functionspace_NodeColumns), intent(in) :: this
362 type(atlas_Field) :: field
363 ${ftype}$, intent(out) :: minimum
364 integer(ATLAS_KIND_GIDX), intent(out) :: location
365 integer(c_long) :: loc
366 call atlas__NodesFunctionSpace__minloc_${ctype}$(this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A,minimum,loc)
367 location = loc
368 end subroutine
369
370 !------------------------------------------------------------------------------
371
372 subroutine maxloc_${dtype}$_r0(this,field,maximum,location)
373 use atlas_functionspace_NodeColumns_c_binding
374 use, intrinsic :: iso_c_binding, only : c_${ctype}$, c_long
375 class(atlas_functionspace_NodeColumns), intent(in) :: this
376 type(atlas_Field) :: field
377 ${ftype}$, intent(out) :: maximum
378 integer(ATLAS_KIND_GIDX), intent(out) :: location
379 integer(c_long) :: loc
380 call atlas__NodesFunctionSpace__maxloc_${ctype}$(this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A,maximum,loc)
381 location = loc
382 end subroutine
383
384 !------------------------------------------------------------------------------
385
386 subroutine minloc_${dtype}$_r1(this,field,minimum,location)
387 use atlas_functionspace_NodeColumns_c_binding
388 use, intrinsic :: iso_c_binding, only : c_${ctype}$, c_ptr, c_f_pointer, c_long
389 class(atlas_functionspace_NodeColumns), intent(in) :: this
390 type(atlas_Field) :: field
391 ${ftype}$, allocatable, intent(out) :: minimum(:)
392 integer(ATLAS_KIND_GIDX), allocatable, intent(out) :: location(:)
393 type(c_ptr) :: min_cptr, loc_cptr
394 ${ftype}$, pointer :: min_fptr(:)
395 integer(c_long),pointer :: loc_fptr(:)
396 integer :: min_size
397 call atlas__NodesFunctionSpace__minloc_arr_${ctype}$(this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A,min_cptr,loc_cptr,min_size)
398 call c_f_pointer(min_cptr,min_fptr,(/min_size/))
399 call c_f_pointer(loc_cptr,loc_fptr,(/min_size/))
400 allocate(minimum(min_size))
401 allocate(location(min_size))
402 minimum(:) = min_fptr(:)
403 location(:) = loc_fptr(:)
404 call c_ptr_free(min_cptr)
405 call c_ptr_free(loc_cptr)
406 end subroutine
407
408 !------------------------------------------------------------------------------
409
410 subroutine maxloc_${dtype}$_r1(this,field,maximum,location)
411 use atlas_functionspace_NodeColumns_c_binding
412 use, intrinsic :: iso_c_binding, only : c_${ctype}$, c_ptr, c_f_pointer, c_long
413 class(atlas_functionspace_NodeColumns), intent(in) :: this
414 type(atlas_Field) :: field
415 ${ftype}$, allocatable, intent(out) :: maximum(:)
416 integer(ATLAS_KIND_GIDX), allocatable, intent(out) :: location(:)
417 type(c_ptr) :: max_cptr, loc_cptr
418 ${ftype}$, pointer :: max_fptr(:)
419 integer(c_long),pointer :: loc_fptr(:)
420 integer :: max_size
421 call atlas__NodesFunctionSpace__maxloc_arr_${ctype}$(this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A,max_cptr,loc_cptr,max_size)
422 call c_f_pointer(max_cptr,max_fptr,(/max_size/))
423 call c_f_pointer(loc_cptr,loc_fptr,(/max_size/))
424 allocate(maximum(max_size))
425 allocate(location(max_size))
426 maximum(:) = max_fptr(:)
427 location(:) = loc_fptr(:)
428 call c_ptr_free(max_cptr)
429 call c_ptr_free(loc_cptr)
430 end subroutine
431
432 !------------------------------------------------------------------------------
433
434 subroutine sum_${dtype}$_r0(this,field,sum,N)
435 use atlas_functionspace_NodeColumns_c_binding
436 use, intrinsic :: iso_c_binding, only : c_${ctype}$, c_int
437 class(atlas_functionspace_NodeColumns), intent(in) :: this
438 type(atlas_Field) :: field
439 ${ftype}$, intent(out) :: sum
440 integer(c_int), intent(out), optional :: N
441 integer(c_int) :: opt_N
442 call atlas__NodesFunctionSpace__sum_${ctype}$(this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A,sum,opt_N)
443 if( present(N) ) N = opt_N
444 end subroutine
445
446 !------------------------------------------------------------------------------
447
448 subroutine sum_${dtype}$_r1(this,field,sum,N)
449 use atlas_functionspace_NodeColumns_c_binding
450 use, intrinsic :: iso_c_binding, only : c_${ctype}$, c_int, c_ptr, c_f_pointer
451 use fckit_c_interop_module, only : c_ptr_free
452 class(atlas_functionspace_NodeColumns), intent(in) :: this
453 type(atlas_Field) :: field
454 ${ftype}$, allocatable, intent(out) :: sum(:)
455 integer(c_int), intent(out), optional :: N
456 type(c_ptr) :: sum_cptr
457 ${ftype}$, pointer :: sum_fptr(:)
458 integer :: sum_size
459 integer(c_int) :: opt_N
460 call atlas__NodesFunctionSpace__sum_arr_${ctype}$(this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A,sum_cptr,sum_size,opt_N)
461 call c_f_pointer(sum_cptr,sum_fptr,(/sum_size/))
462 allocate(sum(sum_size))
463 sum(:) = sum_fptr(:)
464 call c_ptr_free(sum_cptr)
465 if( present(N) ) N = opt_N
466 end subroutine
467
468 !------------------------------------------------------------------------------
469
470 subroutine mean_${dtype}$_r0(this,field,mean,N)
471 use atlas_functionspace_NodeColumns_c_binding
472 use, intrinsic :: iso_c_binding
473 class(atlas_functionspace_NodeColumns), intent(in) :: this
474 type(atlas_Field) :: field
475 ${ftype}$, intent(out) :: mean
476 integer(c_int), intent(out), optional :: N
477 integer(c_int) :: opt_N
478 call atlas__NodesFunctionSpace__mean_${ctype}$(this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A,mean,opt_N)
479 if( present(N) ) N = opt_N
480 end subroutine
481
482 !------------------------------------------------------------------------------
483
484 subroutine mean_${dtype}$_r1(this,field,mean,N)
485 use atlas_functionspace_NodeColumns_c_binding
486 use, intrinsic :: iso_c_binding, only : c_${ctype}$, c_int, c_ptr, c_f_pointer
487 use fckit_c_interop_module, only : c_ptr_free
488 class(atlas_functionspace_NodeColumns), intent(in) :: this
489 type(atlas_Field) :: field
490 ${ftype}$, allocatable, intent(out) :: mean(:)
491 integer(c_int), intent(out), optional :: N
492 type(c_ptr) :: mean_cptr
493 ${ftype}$, pointer :: mean_fptr(:)
494 integer :: mean_size
495 integer(c_int) :: opt_N
496 call atlas__NodesFunctionSpace__mean_arr_${ctype}$(this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A,mean_cptr,mean_size,opt_N)
497 call c_f_pointer(mean_cptr,mean_fptr,(/mean_size/))
498 allocate(mean(mean_size))
499 mean(:) = mean_fptr(:)
500 call c_ptr_free(mean_cptr)
501 if( present(N) ) N = opt_N
502 end subroutine
503
504 !------------------------------------------------------------------------------
505
506 subroutine mean_and_stddev_${dtype}$_r0(this,field,mean,stddev,N)
507 use atlas_functionspace_NodeColumns_c_binding
508 use, intrinsic :: iso_c_binding, only : c_${ctype}$, c_int
509 class(atlas_functionspace_NodeColumns), intent(in) :: this
510 type(atlas_Field) :: field
511 ${ftype}$, intent(out) :: mean
512 ${ftype}$, intent(out) :: stddev
513 integer(c_int), intent(out), optional :: N
514 integer(c_int) :: opt_N
515 call atlas__NodesFunctionSpace__mean_and_stddev_${ctype}$( &
516 this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A,mean,stddev,opt_N)
517 if( present(N) ) N = opt_N
518 end subroutine
519
520 !------------------------------------------------------------------------------
521
522 subroutine mean_and_stddev_${dtype}$_r1(this,field,mean,stddev,N)
523 use atlas_functionspace_NodeColumns_c_binding
524 use, intrinsic :: iso_c_binding, only : c_${ctype}$, c_int ,c_ptr, c_f_pointer
525 use fckit_c_interop_module, only : c_ptr_free
526 class(atlas_functionspace_NodeColumns), intent(in) :: this
527 type(atlas_Field) :: field
528 ${ftype}$, allocatable, intent(out) :: mean(:)
529 ${ftype}$, allocatable, intent(out) :: stddev(:)
530 integer(c_int), intent(out), optional :: N
531 type(c_ptr) :: mean_cptr, stddev_cptr
532 ${ftype}$, pointer :: mean_fptr(:), stddev_fptr(:)
533 integer :: varsize
534 integer(c_int) :: opt_N
535 call atlas__NodesFunctionSpace__mean_and_stddev_arr_${ctype}$( &
536 this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A,mean_cptr,stddev_cptr,varsize,opt_N)
537 call c_f_pointer(mean_cptr,mean_fptr,(/varsize/))
538 call c_f_pointer(stddev_cptr,stddev_fptr,(/varsize/))
539 allocate(mean(varsize))
540 allocate(stddev(varsize))
541 mean(:) = mean_fptr(:)
542 stddev(:) = stddev_fptr(:)
543 call c_ptr_free(mean_cptr)
544 call c_ptr_free(stddev_cptr)
545 if( present(N) ) N = opt_N
546 end subroutine
547
548 !------------------------------------------------------------------------------
549
550 subroutine minloclev_${dtype}$_r0(this,field,minimum,location,level)
551 use atlas_functionspace_NodeColumns_c_binding
552 use, intrinsic :: iso_c_binding
553 class(atlas_functionspace_NodeColumns), intent(in) :: this
554 type(atlas_Field) :: field
555 ${ftype}$, intent(out) :: minimum
556 integer(ATLAS_KIND_GIDX), intent(out) :: location
557 integer(c_int), intent(out) :: level
558 integer(c_long) :: loc
559 integer(c_int) :: opt_lev
560 call atlas__NodesFunctionSpace__minloclev_${ctype}$(this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A,minimum,loc,opt_lev)
561 location = loc
562 level = opt_lev
563 end subroutine
564
565 !------------------------------------------------------------------------------
566
567 subroutine maxloclev_${dtype}$_r0(this,field,maximum,location,level)
568 use atlas_functionspace_NodeColumns_c_binding
569 use, intrinsic :: iso_c_binding
570 class(atlas_functionspace_NodeColumns), intent(in) :: this
571 type(atlas_Field) :: field
572 ${ftype}$, intent(out) :: maximum
573 integer(ATLAS_KIND_GIDX), intent(out) :: location
574 integer(c_int), intent(out) :: level
575 integer(c_long) :: loc
576 integer(c_int) :: opt_lev
577 call atlas__NodesFunctionSpace__maxloclev_${ctype}$(this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A,maximum,loc,opt_lev)
578 location = loc
579 level = opt_lev
580 end subroutine
581
582 !------------------------------------------------------------------------------
583
584 subroutine minloclev_${dtype}$_r1(this,field,minimum,location,level)
585 use atlas_functionspace_NodeColumns_c_binding
586 use, intrinsic :: iso_c_binding, only : c_int, c_${ctype}$, c_long, c_ptr, c_f_pointer
587 class(atlas_functionspace_NodeColumns), intent(in) :: this
588 type(atlas_Field) :: field
589 ${ftype}$, allocatable, intent(out) :: minimum(:)
590 integer(ATLAS_KIND_GIDX), allocatable, intent(out) :: location(:)
591 integer(c_int), allocatable, intent(out) :: level(:)
592 type(c_ptr) :: min_cptr, loc_cptr, lev_cptr
593 ${ftype}$, pointer :: min_fptr(:)
594 integer(c_long),pointer :: loc_fptr(:)
595 integer(c_long),pointer :: lev_fptr(:)
596 integer :: min_size, jlev
597 call atlas__NodesFunctionSpace__minloclev_arr_${ctype}$(this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A,min_cptr,loc_cptr,lev_cptr,min_size)
598 call c_f_pointer(min_cptr,min_fptr,(/min_size/))
599 call c_f_pointer(loc_cptr,loc_fptr,(/min_size/))
600 allocate(minimum(min_size))
601 allocate(location(min_size))
602 minimum(:) = min_fptr(:)
603 location(:) = loc_fptr(:)
604 call c_f_pointer(lev_cptr,lev_fptr,(/min_size/))
605 allocate(level(min_size))
606 do jlev=1,min_size
607 level(jlev) = int(lev_fptr(jlev),c_int)
608 enddo
609 call c_ptr_free(min_cptr)
610 call c_ptr_free(loc_cptr)
611 call c_ptr_free(lev_cptr)
612 end subroutine
613
614 !------------------------------------------------------------------------------
615
616 subroutine maxloclev_${dtype}$_r1(this,field,maximum,location,level)
617 use atlas_functionspace_NodeColumns_c_binding
618 use, intrinsic :: iso_c_binding, only : c_${ctype}$, c_int, c_long , c_f_pointer, c_ptr
619 class(atlas_functionspace_NodeColumns), intent(in) :: this
620 type(atlas_Field) :: field
621 ${ftype}$, allocatable, intent(out) :: maximum(:)
622 integer(ATLAS_KIND_GIDX), allocatable, intent(out) :: location(:)
623 integer(c_int), allocatable, intent(out) :: level(:)
624 type(c_ptr) :: max_cptr, loc_cptr, lev_cptr
625 ${ftype}$, pointer :: max_fptr(:)
626 integer(c_long),pointer :: loc_fptr(:)
627 integer(c_long),pointer :: lev_fptr(:)
628 integer :: max_size, jlev
629 call atlas__NodesFunctionSpace__maxloclev_arr_${ctype}$(this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A,max_cptr,loc_cptr,lev_cptr,max_size)
630 call c_f_pointer(max_cptr,max_fptr,(/max_size/))
631 call c_f_pointer(loc_cptr,loc_fptr,(/max_size/))
632 allocate(maximum(max_size))
633 allocate(location(max_size))
634 maximum(:) = max_fptr(:)
635 location(:) = loc_fptr(:)
636 call c_f_pointer(lev_cptr,lev_fptr,(/max_size/))
637 allocate(level(max_size))
638 do jlev=1,max_size
639 level(jlev) = int(lev_fptr(jlev),c_int)
640 enddo
641 call c_ptr_free(max_cptr)
642 call c_ptr_free(loc_cptr)
643 call c_ptr_free(lev_cptr)
644 end subroutine
645
646 !------------------------------------------------------------------------------
647
648 subroutine order_independent_sum_${dtype}$_r0(this,field,sum,N)
649 use atlas_functionspace_NodeColumns_c_binding
650 use, intrinsic :: iso_c_binding, only : c_${ctype}$, c_int
651 class(atlas_functionspace_NodeColumns), intent(in) :: this
652 type(atlas_Field) :: field
653 ${ftype}$, intent(out) :: sum
654 integer(c_int), intent(out), optional :: N
655 integer(c_int) :: opt_N
656 call atlas__NodesFunctionSpace__oisum_${ctype}$(this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A,sum,opt_N)
657 if( present(N) ) N = opt_N
658 end subroutine
659
660 !------------------------------------------------------------------------------
661
662 subroutine order_independent_sum_${dtype}$_r1(this,field,sum,N)
663 use atlas_functionspace_NodeColumns_c_binding
664 use, intrinsic :: iso_c_binding, only : c_${ctype}$, c_int, c_ptr, c_f_pointer
665 use fckit_c_interop_module, only : c_ptr_free
666 class(atlas_functionspace_NodeColumns), intent(in) :: this
667 type(atlas_Field) :: field
668 ${ftype}$, allocatable, intent(out) :: sum(:)
669 integer(c_int), intent(out), optional :: N
670 type(c_ptr) :: sum_cptr
671 ${ftype}$, pointer :: sum_fptr(:)
672 integer :: sum_size
673 integer(c_int) :: opt_N
674 call atlas__NodesFunctionSpace__oisum_arr_${ctype}$(this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A,sum_cptr,sum_size,opt_N)
675 call c_f_pointer(sum_cptr,sum_fptr,(/sum_size/))
676 allocate(sum(sum_size))
677 sum(:) = sum_fptr(:)
678 call c_ptr_free(sum_cptr)
679 if( present(N) ) N = opt_N
680 end subroutine
681
682 #:endfor
683
684 !------------------------------------------------------------------------------
685
686 subroutine minloc_per_level(this,field,minimum,location)
687 use atlas_functionspace_NodeColumns_c_binding
688 class(atlas_functionspace_NodeColumns), intent(in) :: this
689 type(atlas_Field), intent(in) :: field
690 type(atlas_Field), intent(inout) :: minimum
691 type(atlas_Field), intent(inout) :: location
692 call atlas__NodesFunctionSpace__minloc_per_level( &
693 this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A,minimum%CPTR_PGIBUG_A,location%CPTR_PGIBUG_A)
694 end subroutine
695
696 !------------------------------------------------------------------------------
697
698 subroutine maxloc_per_level(this,field,maximum,location)
699 use atlas_functionspace_NodeColumns_c_binding
700 class(atlas_functionspace_NodeColumns), intent(in) :: this
701 type(atlas_Field), intent(in) :: field
702 type(atlas_Field), intent(inout) :: maximum
703 type(atlas_Field), intent(inout) :: location
704 call atlas__NodesFunctionSpace__maxloc_per_level( &
705 this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A,maximum%CPTR_PGIBUG_A,location%CPTR_PGIBUG_A)
706 end subroutine
707
708 !------------------------------------------------------------------------------
709
710 subroutine minimum_per_level(this,field,minimum)
711 use atlas_functionspace_NodeColumns_c_binding
712 class(atlas_functionspace_NodeColumns), intent(in) :: this
713 type(atlas_Field), intent(in) :: field
714 type(atlas_Field), intent(inout) :: minimum
715 call atlas__NodesFunctionSpace__min_per_level( &
716 this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A,minimum%CPTR_PGIBUG_A)
717 end subroutine
718
719 !------------------------------------------------------------------------------
720
721 subroutine maximum_per_level(this,field,maximum)
722 use atlas_functionspace_NodeColumns_c_binding
723 class(atlas_functionspace_NodeColumns), intent(in) :: this
724 type(atlas_Field), intent(in) :: field
725 type(atlas_Field), intent(inout) :: maximum
726 call atlas__NodesFunctionSpace__max_per_level( &
727 this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A,maximum%CPTR_PGIBUG_A)
728 end subroutine
729
730 !------------------------------------------------------------------------------
731
732 subroutine sum_per_level(this,field,sum,N)
733 use atlas_functionspace_NodeColumns_c_binding
734 use, intrinsic :: iso_c_binding, only : c_int
735 class(atlas_functionspace_NodeColumns), intent(in) :: this
736 type(atlas_Field), intent(in) :: field
737 type(atlas_Field), intent(inout) :: sum
738 integer(c_int), intent(out), optional :: N
739 integer(c_int) :: opt_N
740 call atlas__NodesFunctionSpace__sum_per_level( &
741 this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A,sum%CPTR_PGIBUG_A,opt_N)
742 if( present(N) ) N = opt_N
743 end subroutine
744
745 !------------------------------------------------------------------------------
746
747 subroutine order_independent_sum_per_level(this,field,sum,N)
748 use atlas_functionspace_NodeColumns_c_binding
749 use, intrinsic :: iso_c_binding, only : c_int
750 class(atlas_functionspace_NodeColumns), intent(in) :: this
751 type(atlas_Field), intent(in) :: field
752 type(atlas_Field), intent(inout) :: sum
753 integer(c_int), intent(out), optional :: N
754 integer(c_int) :: opt_N
755 call atlas__NodesFunctionSpace__oisum_per_level( &
756 this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A,sum%CPTR_PGIBUG_A,opt_N)
757 if( present(N) ) N = opt_N
758 end subroutine
759
760 !------------------------------------------------------------------------------
761
762 subroutine mean_per_level(this,field,mean,N)
763 use atlas_functionspace_NodeColumns_c_binding
764 use, intrinsic :: iso_c_binding, only : c_int
765 class(atlas_functionspace_NodeColumns), intent(in) :: this
766 type(atlas_Field), intent(in) :: field
767 type(atlas_Field), intent(inout) :: mean
768 integer(c_int), intent(out), optional :: N
769 integer(c_int) :: opt_N
770 call atlas__NodesFunctionSpace__mean_per_level( &
771 this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A,mean%CPTR_PGIBUG_A,opt_N)
772 if( present(N) ) N = opt_N
773 end subroutine
774
775 !------------------------------------------------------------------------------
776
777 subroutine mean_and_stddev_per_level(this,field,mean,stddev,N)
778 use atlas_functionspace_NodeColumns_c_binding
779 use, intrinsic :: iso_c_binding
780 class(atlas_functionspace_NodeColumns), intent(in) :: this
781 type(atlas_Field), intent(in) :: field
782 type(atlas_Field), intent(inout) :: mean
783 type(atlas_Field), intent(inout) :: stddev
784 integer(c_int), intent(out), optional :: N
785 integer(c_int) :: opt_N
786 call atlas__NodesFunctionSpace__mean_and_stddev_per_level( &
787 & this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A,mean%CPTR_PGIBUG_A,stddev%CPTR_PGIBUG_A,opt_N)
788 if( present(N) ) N = opt_N
789 end subroutine
790
791 !-------------------------------------------------------------------------------
792
793 #if FCKIT_FINAL_NOT_INHERITING
794 ATLAS_FINAL subroutine atlas_functionspace_NodeColumns__final_auto(this)
795 type(atlas_functionspace_NodeColumns), intent(inout) :: this
796 #if FCKIT_FINAL_DEBUGGING
797 write(0,*) "atlas_functionspace_NodeColumns__final_auto"
798 #endif
799 #if FCKIT_FINAL_NOT_PROPAGATING
800 call this%final()
801 #endif
802 FCKIT_SUPPRESS_UNUSED( this )
803 end subroutine
804 #endif
805
806 !------------------------------------------------------------------------------
807
808 end module atlas_functionspace_NodeColumns_module
809