Debian Codegraph @

src/atlas_f/mesh/atlas_mesh_Nodes_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_mesh_Nodes_module
12
13 use, intrinsic :: iso_c_binding, only: c_ptr, c_int, c_long
14 use fckit_owned_object_module, only: fckit_owned_object
15 use atlas_Metadata_module, only: atlas_Metadata
16 use atlas_Field_module, only: atlas_Field
17 use atlas_Connectivity_module, only: atlas_Connectivity
18 use atlas_kinds_module, only : ATLAS_KIND_IDX
19
20 implicit none
21
22 private :: fckit_owned_object
23 private :: c_ptr, c_int
24 private :: atlas_Metadata
25 private :: atlas_Field
26 private :: atlas_Connectivity
27 public :: atlas_mesh_Nodes
28
29 private
30
31 !-----------------------------
32 ! atlas_mesh_Nodes !
33 !-----------------------------
34
35 TYPE, extends(fckit_owned_object) :: atlas_mesh_Nodes
36 contains
37 procedure, public :: size => atlas_mesh_Nodes__size
38 procedure, private :: resize_int
39 procedure, private :: resize_long
40 generic, public :: resize => resize_int, resize_long
41 procedure, private :: add_field
42 procedure, private :: add_connectivity
43 generic, public :: add => &
44 & add_field, &
45 & add_connectivity
46 procedure, public :: remove_field
47 procedure, private :: field_by_idx_int
48 procedure, private :: field_by_idx_long
49 procedure, private :: field_by_name
50 generic, public :: field => &
51 & field_by_idx_long, field_by_idx_int, &
52 & field_by_name
53 procedure, public :: nb_fields
54 procedure, public :: has_field
55 procedure, public :: metadata
56 procedure, public :: str
57
58 procedure, public :: xy
59 procedure, public :: lonlat
60 procedure, public :: global_index
61 procedure, public :: remote_index
62 procedure, public :: partition
63 procedure, public :: ghost
64
65 procedure, public :: edge_connectivity
66 procedure, public :: cell_connectivity
67
68 procedure, public :: connectivity
69
70 #if FCKIT_FINAL_NOT_INHERITING
71 final :: atlas_mesh_Nodes__final_auto
72 #endif
73 end type
74
75 interface atlas_mesh_Nodes
76 module procedure atlas_mesh_Nodes__cptr
77 module procedure atlas_mesh_Nodes__constructor
78 end interface
79
80 !========================================================
81 contains
82 !========================================================
83
84 function atlas_mesh_Nodes__cptr(cptr) result(this)
85 use atlas_nodes_c_binding
86 type(atlas_mesh_Nodes) :: this
87 type(c_ptr), intent(in) :: cptr
88 call this%reset_c_ptr( cptr )
89 call this%return()
90 end function
91
92 function atlas_mesh_Nodes__constructor() result(this)
93 use atlas_nodes_c_binding
94 type(atlas_mesh_Nodes) :: this
95 call this%reset_c_ptr( atlas__mesh__Nodes__create() )
96 call this%return()
97 end function
98
99 function atlas_mesh_Nodes__size(this) result(val)
100 use atlas_nodes_c_binding
101 integer(ATLAS_KIND_IDX) :: val
102 class(atlas_mesh_Nodes), intent(in) :: this
103 val = atlas__mesh__Nodes__size(this%CPTR_PGIBUG_A)
104 end function
105
106 function edge_connectivity(this) result(connectivity)
107 use atlas_nodes_c_binding
108 use atlas_Connectivity_module, only: atlas_Connectivity
109 class(atlas_mesh_Nodes), intent(in) :: this
110 type(atlas_Connectivity) :: connectivity
111 connectivity = atlas_Connectivity( &
112 atlas__mesh__Nodes__edge_connectivity(this%CPTR_PGIBUG_A) )
113 call connectivity%return()
114 end function
115
116 function cell_connectivity(this) result(connectivity)
117 use atlas_nodes_c_binding
118 class(atlas_mesh_Nodes), intent(in) :: this
119 type(atlas_Connectivity) :: connectivity
120 connectivity = atlas_Connectivity( &
121 atlas__mesh__Nodes__cell_connectivity(this%CPTR_PGIBUG_A) )
122 call connectivity%return()
123 end function
124
125 function connectivity(this,name)
126 use atlas_nodes_c_binding
127 use fckit_c_interop_module, only: c_str
128 type(atlas_Connectivity) :: connectivity
129 class(atlas_mesh_Nodes), intent(in) :: this
130 character(len=*), intent(in) :: name
131 connectivity = atlas_Connectivity( &
132 atlas__mesh__Nodes__connectivity(this%CPTR_PGIBUG_A,c_str(name)) )
133 call connectivity%return()
134 end function
135
136 subroutine add_connectivity(this,connectivity)
137 use atlas_nodes_c_binding
138 class(atlas_mesh_Nodes), intent(inout) :: this
139 type(atlas_Connectivity), intent(in) :: connectivity
140 call atlas__mesh__Nodes__add_connectivity(this%CPTR_PGIBUG_A, connectivity%CPTR_PGIBUG_A)
141 end subroutine
142
143
144 subroutine add_field(this,field)
145 use atlas_nodes_c_binding
146 class(atlas_mesh_Nodes), intent(inout) :: this
147 type(atlas_Field), intent(in) :: field
148 call atlas__mesh__Nodes__add_field(this%CPTR_PGIBUG_A, field%CPTR_PGIBUG_A)
149 end subroutine
150
151 subroutine remove_field(this,name)
152 use atlas_nodes_c_binding
153 use fckit_c_interop_module, only: c_str
154 class(atlas_mesh_Nodes), intent(in) :: this
155 character(len=*), intent(in) :: name
156 call atlas__mesh__Nodes__remove_field(this%CPTR_PGIBUG_A,c_str(name))
157 end subroutine
158
159 function nb_fields(this) result(val)
160 use atlas_nodes_c_binding
161 integer(ATLAS_KIND_IDX) :: val
162 class(atlas_mesh_Nodes), intent(in) :: this
163 val = atlas__mesh__Nodes__nb_fields(this%CPTR_PGIBUG_A)
164 end function
165
166 function has_field(this,name) result(val)
167 use atlas_nodes_c_binding
168 use fckit_c_interop_module, only: c_str
169 logical :: val
170 class(atlas_mesh_Nodes), intent(in) :: this
171 character(len=*), intent(in) :: name
172 if( atlas__mesh__Nodes__has_field(this%CPTR_PGIBUG_A,c_str(name)) == 0 ) then
173 val = .False.
174 else
175 val = .True.
176 endif
177 end function
178
179 function field_by_name(this,name) result(field)
180 use atlas_nodes_c_binding
181 use fckit_c_interop_module, only: c_str
182 type(atlas_Field) :: field
183 class(atlas_mesh_Nodes), intent(in) :: this
184 character(len=*), intent(in) :: name
185 field = atlas_Field( atlas__mesh__Nodes__field_by_name(this%CPTR_PGIBUG_A,c_str(name)) )
186 call field%return()
187 end function
188
189 function field_by_idx_long(this,idx) result(field)
190 use atlas_nodes_c_binding
191 use, intrinsic :: iso_c_binding, only: c_long
192 type(atlas_Field) :: field
193 class(atlas_mesh_Nodes), intent(in) :: this
194 integer(c_long), intent(in) :: idx
195 field = atlas_Field( atlas__mesh__Nodes__field_by_idx(this%CPTR_PGIBUG_A,int(idx-1_c_long,ATLAS_KIND_IDX) ) )
196 call field%return()
197 end function
198
199 function field_by_idx_int(this,idx) result(field)
200 use atlas_nodes_c_binding
201 use, intrinsic :: iso_c_binding, only: c_int
202 type(atlas_Field) :: field
203 class(atlas_mesh_Nodes), intent(in) :: this
204 integer(c_int), intent(in) :: idx
205 field = atlas_Field( atlas__mesh__Nodes__field_by_idx(this%CPTR_PGIBUG_A,int(idx-1_c_long,ATLAS_KIND_IDX) ) )
206 call field%return()
207 end function
208
209 function xy(this) result(field)
210 use atlas_nodes_c_binding
211 type(atlas_Field) :: field
212 class(atlas_mesh_Nodes), intent(in) :: this
213 field = atlas_Field( atlas__mesh__Nodes__xy(this%CPTR_PGIBUG_A) )
214 call field%return()
215 end function
216
217 function lonlat(this) result(field)
218 use atlas_nodes_c_binding
219 type(atlas_Field) :: field
220 class(atlas_mesh_Nodes), intent(in) :: this
221 field = atlas_Field( atlas__mesh__Nodes__lonlat(this%CPTR_PGIBUG_A) )
222 call field%return()
223 end function
224
225 function global_index(this) result(field)
226 use atlas_nodes_c_binding
227 type(atlas_Field) :: field
228 class(atlas_mesh_Nodes), intent(in) :: this
229 field = atlas_Field( atlas__mesh__Nodes__global_index(this%CPTR_PGIBUG_A) )
230 call field%return()
231 end function
232
233 function remote_index(this) result(field)
234 use atlas_nodes_c_binding
235 type(atlas_Field) :: field
236 class(atlas_mesh_Nodes), intent(in) :: this
237 field = atlas_Field( atlas__mesh__Nodes__remote_index(this%CPTR_PGIBUG_A) )
238 call field%return()
239 end function
240
241 function partition(this) result(field)
242 use atlas_nodes_c_binding
243 type(atlas_Field) :: field
244 class(atlas_mesh_Nodes), intent(in) :: this
245 field = atlas_Field( atlas__mesh__Nodes__partition(this%CPTR_PGIBUG_A) )
246 call field%return()
247 end function
248
249 function ghost(this) result(field)
250 use atlas_nodes_c_binding
251 type(atlas_Field) :: field
252 class(atlas_mesh_Nodes), intent(in) :: this
253 field = atlas_Field( atlas__mesh__Nodes__ghost(this%CPTR_PGIBUG_A) )
254 call field%return()
255 end function
256
257 function metadata(this)
258 use atlas_nodes_c_binding
259 type(atlas_Metadata) :: metadata
260 class(atlas_mesh_Nodes), intent(in) :: this
261 call metadata%reset_c_ptr( atlas__mesh__Nodes__metadata(this%CPTR_PGIBUG_A) )
262 end function
263
264 subroutine resize_int(this,size)
265 use, intrinsic :: iso_c_binding
266 use atlas_nodes_c_binding
267 class(atlas_mesh_Nodes), intent(in) :: this
268 integer(c_int), intent(in) :: size
269 call atlas__mesh__Nodes__resize(this%CPTR_PGIBUG_A,int(size,ATLAS_KIND_IDX))
270 end subroutine
271
272 subroutine resize_long(this,size)
273 use, intrinsic :: iso_c_binding
274 use atlas_nodes_c_binding
275 class(atlas_mesh_Nodes), intent(in) :: this
276 integer(c_long), intent(in) :: size
277 call atlas__mesh__Nodes__resize(this%CPTR_PGIBUG_A,int(size,ATLAS_KIND_IDX))
278 end subroutine
279
280 function str(this)
281 use atlas_nodes_c_binding
282 use fckit_c_interop_module, only: c_ptr_to_string, c_ptr_free
283 character(len=:), allocatable :: str
284 class(atlas_mesh_Nodes), intent(in) :: this
285 type(c_ptr) :: str_cptr
286 integer(c_int) :: str_size
287 call atlas__mesh__Nodes__str(this%CPTR_PGIBUG_A,str_cptr,str_size)
288 allocate(character(len=str_size) :: str )
289 str = c_ptr_to_string(str_cptr)
290 call c_ptr_free(str_cptr)
291 end function
292
293 !-------------------------------------------------------------------------------
294
295 #if FCKIT_FINAL_NOT_INHERITING
296 ATLAS_FINAL subroutine atlas_mesh_Nodes__final_auto(this)
297 type(atlas_mesh_Nodes), intent(inout) :: this
298 #if FCKIT_FINAL_DEBUGGING
299 write(0,*) "atlas_mesh_Nodes__final_auto"
300 #endif
301 #if FCKIT_FINAL_NOT_PROPAGATING
302 call this%final()
303 #endif
304 FCKIT_SUPPRESS_UNUSED( this )
305 end subroutine
306 #endif
307
308 ! ----------------------------------------------------------------------------------------
309
310 end module atlas_mesh_Nodes_module
311