Debian Codegraph @

src/atlas_f/numerics/atlas_Nabla_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_Nabla_module
12
13 use fckit_owned_object_module, only : fckit_owned_object
14
15 implicit none
16
17 private :: fckit_owned_object
18
19 public :: atlas_Nabla
20
21 private
22
23 !------------------------------------------------------------------------------
24 TYPE, extends(fckit_owned_object) :: atlas_Nabla
25
26 ! Purpose :
27 ! -------
28 ! *Nabla* :
29
30 ! Methods :
31 ! -------
32
33 ! Author :
34 ! ------
35 ! October-2015 Willem Deconinck *ECMWF*
36
37 !------------------------------------------------------------------------------
38 contains
39 procedure, public :: gradient => atlas_Nabla__gradient
40 procedure, public :: divergence => atlas_Nabla__divergence
41 procedure, public :: curl => atlas_Nabla__curl
42 procedure, public :: laplacian => atlas_Nabla__laplacian
43
44 procedure, public :: functionspace => atlas_Nabla__functionspace
45
46 #if FCKIT_FINAL_NOT_INHERITING
47 final :: atlas_Nabla__final_auto
48 #endif
49 END TYPE atlas_Nabla
50
51 interface atlas_Nabla
52 module procedure atlas_Nabla__cptr
53 module procedure atlas_Nabla__method_config
54 end interface
55
56 !========================================================
57 contains
58 !========================================================
59
60 function atlas_Nabla__cptr(cptr) result(this)
61 use, intrinsic :: iso_c_binding, only: c_ptr
62 type(atlas_Nabla) :: this
63 type(c_ptr), intent(in) :: cptr
64 call this%reset_c_ptr( cptr )
65 call this%return()
66 end function
67
68 function atlas_Nabla__method_config(method,config) result(this)
69 use atlas_Nabla_c_binding
70 use atlas_Method_module, only : atlas_Method
71 use atlas_Config_module, only : atlas_Config
72 type(atlas_Nabla) :: this
73 class(atlas_Method), intent(in) :: method
74 type(atlas_Config), intent(in), optional :: config
75 type(atlas_Config) :: opt_config
76 if( present(config) ) then
77 call this%reset_c_ptr( atlas__Nabla__create(method%CPTR_PGIBUG_A,config%CPTR_PGIBUG_B) )
78 else
79 opt_config = atlas_Config()
80 call this%reset_c_ptr( atlas__Nabla__create(method%CPTR_PGIBUG_A,opt_config%CPTR_PGIBUG_B) )
81 call opt_config%final()
82 endif
83 call this%return()
84 end function
85
86 subroutine atlas_Nabla__gradient(this,scalar,grad)
87 use atlas_Nabla_c_binding
88 use atlas_Field_module, only : atlas_Field
89 class(atlas_Nabla), intent(in) :: this
90 class(atlas_Field), intent(in) :: scalar
91 class(atlas_Field), intent(inout) :: grad
92 call atlas__Nabla__gradient(this%CPTR_PGIBUG_A,scalar%CPTR_PGIBUG_A,grad%CPTR_PGIBUG_A)
93 end subroutine
94
95
96 subroutine atlas_Nabla__divergence(this,vector,div)
97 use atlas_Nabla_c_binding
98 use atlas_Field_module, only : atlas_Field
99 class(atlas_Nabla), intent(in) :: this
100 class(atlas_Field), intent(in) :: vector
101 class(atlas_Field), intent(inout) :: div
102 call atlas__Nabla__divergence(this%CPTR_PGIBUG_A,vector%CPTR_PGIBUG_A,div%CPTR_PGIBUG_A)
103 end subroutine
104
105 subroutine atlas_Nabla__curl(this,vector,curl)
106 use atlas_Nabla_c_binding
107 use atlas_Field_module, only : atlas_Field
108 class(atlas_Nabla), intent(in) :: this
109 class(atlas_Field), intent(in) :: vector
110 class(atlas_Field), intent(inout) :: curl
111 call atlas__Nabla__curl(this%CPTR_PGIBUG_A,vector%CPTR_PGIBUG_A,curl%CPTR_PGIBUG_A)
112 end subroutine
113
114 subroutine atlas_Nabla__laplacian(this,scalar,lapl)
115 use atlas_Nabla_c_binding
116 use atlas_Field_module, only : atlas_Field
117 class(atlas_Nabla), intent(in) :: this
118 class(atlas_Field), intent(in) :: scalar
119 class(atlas_Field), intent(inout) :: lapl
120 call atlas__Nabla__laplacian(this%CPTR_PGIBUG_A,scalar%CPTR_PGIBUG_A,lapl%CPTR_PGIBUG_A)
121 end subroutine
122
123 function atlas_Nabla__functionspace(this) result(functionspace)
124 use atlas_Nabla_c_binding
125 use atlas_Functionspace_module, only : atlas_FunctionSpace
126 type(atlas_FunctionSpace) :: functionspace
127 class(atlas_Nabla), intent(in) :: this
128 call functionspace%reset_c_ptr( atlas__Nabla__functionspace(this%CPTR_PGIBUG_A) )
129 call functionspace%return()
130 end function
131
132 !-------------------------------------------------------------------------------
133
134 #if FCKIT_FINAL_NOT_INHERITING
135 ATLAS_FINAL subroutine atlas_Nabla__final_auto(this)
136 type(atlas_Nabla), intent(inout) :: this
137 #if FCKIT_FINAL_DEBUGGING
138 write(0,*) "atlas_Nabla__final_auto"
139 #endif
140 #if FCKIT_FINAL_NOT_PROPAGATING
141 call this%final()
142 #endif
143 FCKIT_SUPPRESS_UNUSED( this )
144 end subroutine
145 #endif
146
147 ! -----------------------------------------------------------------------------
148
149 end module atlas_Nabla_module
150