Debian Codegraph @

src/atlas_f/functionspace/atlas_functionspace_CellColumns_module.F90

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
11 module atlas_functionspace_CellColumns_module
12
13 use fckit_c_interop_module, only : c_str, c_ptr_to_string, c_ptr_free
14 use atlas_functionspace_module, only : atlas_FunctionSpace
15 use atlas_Field_module, only: atlas_Field
16 use atlas_FieldSet_module, only: atlas_FieldSet
17 use atlas_Mesh_module, only: atlas_Mesh
18 use atlas_mesh_Cells_module, only: atlas_mesh_Cells
19 use atlas_GatherScatter_module, only: atlas_GatherScatter
20 use atlas_HaloExchange_module, only: atlas_HaloExchange
21 use atlas_Checksum_module, only: atlas_Checksum
22 use atlas_Config_module, only: atlas_Config
23 use atlas_kinds_module, only: ATLAS_KIND_GIDX
24
25 implicit none
26
27 private :: c_str, c_ptr_to_string, c_ptr_free
28 private :: atlas_FunctionSpace
29 private :: atlas_Field
30 private :: atlas_FieldSet
31 private :: atlas_mesh_Cells
32 private :: atlas_GatherScatter
33 private :: atlas_HaloExchange
34 private :: atlas_Checksum
35 private :: atlas_Mesh
36 private :: atlas_Config
37 private :: ATLAS_KIND_GIDX
38
39 public :: atlas_functionspace_CellColumns
40
41 private
42
43 !------------------------------------------------------------------------------
44 TYPE, extends(atlas_FunctionSpace) :: atlas_functionspace_CellColumns
45
46 ! Purpose :
47 ! -------
48 ! *atlas_functionspace_CellColumns* : Interpretes fields defined in cells
49
50 ! Methods :
51 ! -------
52
53 ! Author :
54 ! ------
55 ! August-2015 Willem Deconinck *ECMWF*
56
57 !------------------------------------------------------------------------------
58 contains
59
60
61 procedure, public :: nb_cells
62 procedure, public :: mesh
63 procedure, public :: cells
64
65 procedure, public :: get_halo_exchange
66
67 procedure, private :: gather_fieldset
68 procedure, private :: gather_field
69 generic, public :: gather => gather_fieldset, gather_field
70 procedure, public :: get_gather
71
72 procedure, private :: scatter_fieldset
73 procedure, private :: scatter_field
74 generic, public :: scatter => scatter_fieldset, scatter_field
75 procedure, public :: get_scatter
76
77 procedure, private :: checksum_fieldset
78 procedure, private :: checksum_field
79 generic, public :: checksum => checksum_fieldset, checksum_field
80 procedure, public :: get_checksum
81
82 #if FCKIT_FINAL_NOT_INHERITING
83 final :: atlas_functionspace_CellColumns__final_auto
84 #endif
85
86 END TYPE atlas_functionspace_CellColumns
87
88 interface atlas_functionspace_CellColumns
89 module procedure constructor__cptr
90 module procedure constructor
91 end interface
92
93 !------------------------------------------------------------------------------
94
95 !========================================================
96 contains
97 !========================================================
98
99 !------------------------------------------------------------------------------
100
101 function constructor__cptr(cptr) result(this)
102 use, intrinsic :: iso_c_binding, only : c_ptr
103 type(atlas_functionspace_CellColumns) :: this
104 type(c_ptr), intent(in) :: cptr
105 call this%reset_c_ptr( cptr )
106 call this%return()
107 end function
108
109 !------------------------------------------------------------------------------
110
111 function constructor(mesh,halo,levels) result(this)
112 use atlas_functionspace_CellColumns_c_binding
113 type(atlas_functionspace_CellColumns) :: this
114 type(atlas_Mesh), intent(inout) :: mesh
115 integer, intent(in), optional :: halo
116 integer, intent(in), optional :: levels
117 type(atlas_Config) :: config
118 config = atlas_Config()
119 if( present(halo) ) call config%set("halo",halo)
120 if( present(levels) ) call config%set("levels",levels)
121 call this%reset_c_ptr( atlas__CellsFunctionSpace__new(mesh%CPTR_PGIBUG_A,config%CPTR_PGIBUG_B) )
122 call config%final()
123 call this%return()
124 end function
125
126 !------------------------------------------------------------------------------
127
128 function nb_cells(this)
129 use atlas_functionspace_CellColumns_c_binding
130 integer :: nb_cells
131 class(atlas_functionspace_CellColumns), intent(in) :: this
132 nb_cells = atlas__CellsFunctionSpace__nb_cells(this%CPTR_PGIBUG_A)
133 end function
134
135 !------------------------------------------------------------------------------
136
137 function mesh(this)
138 use atlas_functionspace_CellColumns_c_binding
139 type(atlas_Mesh) :: mesh
140 class(atlas_functionspace_CellColumns), intent(in) :: this
141 call mesh%reset_c_ptr( atlas__CellsFunctionSpace__mesh(this%CPTR_PGIBUG_A) )
142 call mesh%return()
143 end function
144
145 !------------------------------------------------------------------------------
146
147 function cells(this)
148 use atlas_functionspace_CellColumns_c_binding
149 type(atlas_mesh_Cells) :: cells
150 class(atlas_functionspace_CellColumns), intent(in) :: this
151 call cells%reset_c_ptr( atlas__CellsFunctionSpace__cells(this%CPTR_PGIBUG_A) )
152 call cells%return()
153 end function
154
155 !------------------------------------------------------------------------------
156
157 function get_gather(this) result(gather)
158 use atlas_functionspace_CellColumns_c_binding
159 type(atlas_GatherScatter) :: gather
160 class(atlas_functionspace_CellColumns), intent(in) :: this
161 call gather%reset_c_ptr( atlas__CellsFunctioNSpace__get_gather(this%CPTR_PGIBUG_A) )
162 end function
163
164 !------------------------------------------------------------------------------
165
166 function get_scatter(this) result(gather)
167 use atlas_functionspace_CellColumns_c_binding
168 type(atlas_GatherScatter) :: gather
169 class(atlas_functionspace_CellColumns), intent(in) :: this
170 call gather%reset_c_ptr( atlas__CellsFunctioNSpace__get_scatter(this%CPTR_PGIBUG_A) )
171 end function
172
173 !------------------------------------------------------------------------------
174
175 subroutine gather_fieldset(this,local,global)
176 use atlas_functionspace_CellColumns_c_binding
177 class(atlas_functionspace_CellColumns), intent(in) :: this
178 type(atlas_FieldSet), intent(in) :: local
179 type(atlas_FieldSet), intent(inout) :: global
180 call atlas__CellsFunctionSpace__gather_fieldset(this%CPTR_PGIBUG_A,local%CPTR_PGIBUG_A,global%CPTR_PGIBUG_A)
181 end subroutine
182
183 !------------------------------------------------------------------------------
184
185 subroutine gather_field(this,local,global)
186 use atlas_functionspace_CellColumns_c_binding
187 class(atlas_functionspace_CellColumns), intent(in) :: this
188 type(atlas_Field), intent(in) :: local
189 type(atlas_Field), intent(inout) :: global
190 call atlas__CellsFunctionSpace__gather_field(this%CPTR_PGIBUG_A,local%CPTR_PGIBUG_A,global%CPTR_PGIBUG_A)
191 end subroutine
192
193 !------------------------------------------------------------------------------
194
195 subroutine scatter_fieldset(this,global,local)
196 use atlas_functionspace_CellColumns_c_binding
197 class(atlas_functionspace_CellColumns), intent(in) :: this
198 type(atlas_FieldSet), intent(in) :: global
199 type(atlas_FieldSet), intent(inout) :: local
200 call atlas__CellsFunctionSpace__scatter_fieldset(this%CPTR_PGIBUG_A,global%CPTR_PGIBUG_A,local%CPTR_PGIBUG_A)
201 end subroutine
202
203 !------------------------------------------------------------------------------
204
205 subroutine scatter_field(this,global,local)
206 use atlas_functionspace_CellColumns_c_binding
207 class(atlas_functionspace_CellColumns), intent(in) :: this
208 type(atlas_Field), intent(in) :: global
209 type(atlas_Field), intent(inout) :: local
210 call atlas__CellsFunctionSpace__scatter_field(this%CPTR_PGIBUG_A,global%CPTR_PGIBUG_A,local%CPTR_PGIBUG_A)
211 end subroutine
212
213 !------------------------------------------------------------------------------
214
215 function get_halo_exchange(this) result(halo_exchange)
216 use atlas_functionspace_CellColumns_c_binding
217 type(atlas_HaloExchange) :: halo_exchange
218 class(atlas_functionspace_CellColumns), intent(in) :: this
219 call halo_exchange%reset_c_ptr( atlas__CellsFunctioNSpace__get_halo_exchange(this%CPTR_PGIBUG_A) )
220 end function
221
222 !------------------------------------------------------------------------------
223
224 function get_checksum(this) result(checksum)
225 use atlas_functionspace_CellColumns_c_binding
226 type(atlas_Checksum) :: checksum
227 class(atlas_functionspace_CellColumns), intent(in) :: this
228 call checksum%reset_c_ptr( atlas__CellsFunctioNSpace__get_checksum(this%CPTR_PGIBUG_A) )
229 end function
230
231 !------------------------------------------------------------------------------
232
233 function checksum_fieldset(this,fieldset) result(checksum)
234 use atlas_functionspace_CellColumns_c_binding
235 use, intrinsic :: iso_c_binding, only : c_ptr
236 character(len=:), allocatable :: checksum
237 class(atlas_functionspace_CellColumns), intent(in) :: this
238 type(atlas_FieldSet), intent(in) :: fieldset
239 type(c_ptr) :: checksum_cptr
240 integer :: checksum_size, checksum_allocated
241 call atlas__CellsFunctionSpace__checksum_fieldset( &
242 this%CPTR_PGIBUG_A,fieldset%CPTR_PGIBUG_A,checksum_cptr,checksum_size,checksum_allocated)
243 allocate(character(len=checksum_size) :: checksum )
244 checksum = c_ptr_to_string(checksum_cptr)
245 if( checksum_allocated == 1 ) call c_ptr_free(checksum_cptr)
246 end function
247
248 !------------------------------------------------------------------------------
249
250 function checksum_field(this,field) result(checksum)
251 use atlas_functionspace_CellColumns_c_binding
252 use, intrinsic :: iso_c_binding, only : c_ptr
253 character(len=:), allocatable :: checksum
254 class(atlas_functionspace_CellColumns), intent(in) :: this
255 type(atlas_Field), intent(in) :: field
256 type(c_ptr) :: checksum_cptr
257 integer :: checksum_size, checksum_allocated
258 call atlas__CellsFunctionSpace__checksum_field( &
259 this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A,checksum_cptr,checksum_size,checksum_allocated)
260 allocate(character(len=checksum_size) :: checksum )
261 checksum = c_ptr_to_string(checksum_cptr)
262 if( checksum_allocated == 1 ) call c_ptr_free(checksum_cptr)
263 end function
264
265 !------------------------------------------------------------------------------
266
267 #if FCKIT_FINAL_NOT_INHERITING
268 ATLAS_FINAL subroutine atlas_functionspace_CellColumns__final_auto(this)
269 type(atlas_functionspace_CellColumns), intent(inout) :: this
270 #if FCKIT_FINAL_DEBUGGING
271 write(0,*) "atlas_functionspace_CellColumns__final_auto"
272 #endif
273 #if FCKIT_FINAL_NOT_PROPAGATING
274 call this%final()
275 #endif
276 FCKIT_SUPPRESS_UNUSED( this )
277 end subroutine
278 #endif
279
280 !------------------------------------------------------------------------------
281
282 end module atlas_functionspace_CellColumns_module
283