Debian Codegraph @

src/atlas_f/mesh/atlas_Mesh_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_module
12
13 use fckit_owned_object_module, only: fckit_owned_object
14 use atlas_mesh_Cells_module, only: atlas_mesh_Cells
15 use atlas_mesh_Nodes_module, only: atlas_mesh_Nodes
16 use atlas_mesh_Edges_module, only: atlas_mesh_Edges
17 use, intrinsic :: iso_c_binding, only : c_size_t, c_ptr
18
19 implicit none
20
21 private :: fckit_owned_object
22 private :: atlas_mesh_Cells
23 private :: atlas_mesh_Nodes
24 private :: atlas_mesh_Edges
25 private :: c_size_t
26 private :: c_ptr
27
28 public :: atlas_Mesh
29
30 private
31
32 !-----------------------------
33 ! atlas_Mesh !
34 !-----------------------------
35
36 TYPE, extends(fckit_owned_object) :: atlas_Mesh
37
38 ! Purpose :
39 ! -------
40 ! *Mesh* : Container type holding an entire mesh
41
42 ! Methods :
43 ! -------
44
45 ! Author :
46 ! ------
47 ! 20-Nov-2013 Willem Deconinck *ECMWF*
48
49 !------------------------------------------------------------------------------
50 contains
51
52 procedure, public :: nodes => Mesh__nodes
53 procedure, public :: cells => Mesh__cells
54 procedure, public :: edges => Mesh__edges
55 procedure, public :: footprint
56
57 procedure, public :: update_device
58 procedure, public :: update_host
59 procedure, public :: sync_host_device
60
61 #if FCKIT_FINAL_NOT_INHERITING
62 final :: atlas_Mesh__final_auto
63 #endif
64 END TYPE atlas_Mesh
65
66 interface atlas_Mesh
67 module procedure atlas_Mesh__cptr
68 module procedure atlas_Mesh__ctor
69 end interface
70
71 !========================================================
72 contains
73 !========================================================
74
75 function atlas_Mesh__cptr(cptr) result(this)
76 use atlas_mesh_c_binding
77 type(atlas_Mesh) :: this
78 type(c_ptr), intent(in) :: cptr
79 call this%reset_c_ptr( cptr )
80 call this%return()
81 end function atlas_Mesh__cptr
82
83 !-------------------------------------------------------------------------------
84
85 function atlas_Mesh__ctor() result(this)
86 use atlas_mesh_c_binding
87 type(atlas_Mesh) :: this
88 call this%reset_c_ptr( atlas__Mesh__new() )
89 call this%return()
90 end function atlas_Mesh__ctor
91
92 !-------------------------------------------------------------------------------
93
94 function Mesh__nodes(this) result(nodes)
95 use atlas_mesh_c_binding
96 class(atlas_Mesh), intent(in) :: this
97 type(atlas_mesh_Nodes) :: nodes
98 nodes = atlas_mesh_Nodes( atlas__Mesh__nodes(this%CPTR_PGIBUG_A) )
99 call nodes%return()
100 end function
101
102 !-------------------------------------------------------------------------------
103
104 function Mesh__cells(this) result(cells)
105 use atlas_mesh_c_binding
106 class(atlas_Mesh), intent(in) :: this
107 type(atlas_mesh_Cells) :: cells
108 cells = atlas_mesh_Cells( atlas__Mesh__cells(this%CPTR_PGIBUG_A) )
109 call cells%return()
110 end function
111
112 !-------------------------------------------------------------------------------
113
114 function Mesh__edges(this) result(edges)
115 use atlas_mesh_c_binding
116 class(atlas_Mesh), intent(in) :: this
117 type(atlas_mesh_Edges) :: edges
118 edges = atlas_mesh_Edges( atlas__Mesh__Edges(this%CPTR_PGIBUG_A) )
119 call edges%return()
120 end function
121
122 !-------------------------------------------------------------------------------
123
124 function footprint(this)
125 use atlas_mesh_c_binding
126 integer(c_size_t) :: footprint
127 class(atlas_Mesh) :: this
128 footprint = atlas__Mesh__footprint(this%CPTR_PGIBUG_A)
129 end function
130
131 !-------------------------------------------------------------------------------
132
133 subroutine update_device(this)
134 use atlas_mesh_c_binding
135 class(atlas_Mesh), intent(inout) :: this
136 call atlas__Mesh__update_device(this%CPTR_PGIBUG_A)
137 end subroutine
138
139 !-------------------------------------------------------------------------------
140
141 subroutine update_host(this)
142 use atlas_mesh_c_binding
143 class(atlas_Mesh), intent(inout) :: this
144 call atlas__Mesh__update_host(this%CPTR_PGIBUG_A)
145 end subroutine
146
147 ! ----------------------------------------------------------------------------------------
148
149 subroutine sync_host_device(this)
150 use atlas_mesh_c_binding
151 class(atlas_Mesh), intent(inout) :: this
152 call atlas__Mesh__sync_host_device(this%CPTR_PGIBUG_A)
153 end subroutine
154
155 !-------------------------------------------------------------------------------
156
157 #if FCKIT_FINAL_NOT_INHERITING
158 ATLAS_FINAL subroutine atlas_Mesh__final_auto(this)
159 type(atlas_Mesh), intent(inout) :: this
160 #if FCKIT_FINAL_DEBUGGING
161 write(0,*) "atlas_Mesh__final_auto"
162 #endif
163 #if FCKIT_FINAL_NOT_PROPAGATING
164 call this%final()
165 #endif
166 FCKIT_SUPPRESS_UNUSED( this )
167 end subroutine
168 #endif
169
170 !-------------------------------------------------------------------------------
171
172 end module atlas_Mesh_module