Debian Codegraph @

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