Debian Codegraph @

src/atlas_f/grid/atlas_Vertical_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_Vertical_module
12
13 use fckit_shared_object_module, only : fckit_shared_object, fckit_c_deleter, fckit_c_nodeleter
14 use atlas_field_module, only : atlas_Field
15
16 use, intrinsic :: iso_c_binding, only : c_ptr, c_double
17
18 implicit none
19
20 public :: atlas_Vertical
21
22 private
23
24 !-----------------------------
25 ! atlas_Vertical !
26 !-----------------------------
27
28
29 !------------------------------------------------------------------------------
30 TYPE, extends(fckit_shared_object) :: atlas_Vertical
31
32 ! Purpose :
33 ! -------
34 ! *Vertical* : Object describing vertical levels
35
36 ! Methods :
37 ! -------
38
39 ! Author :
40 ! ------
41 ! 28-Nov-2018 Willem Deconinck *ECMWF*
42
43 !------------------------------------------------------------------------------
44 contains
45 procedure, public :: z
46 procedure, public :: size => vsize
47
48 #if FCKIT_FINAL_NOT_INHERITING
49 final :: atlas_Vertical__final_auto
50 #endif
51 END TYPE atlas_Vertical
52
53 !------------------------------------------------------------------------------
54
55 interface atlas_Vertical
56 module procedure atlas_Vertical__ctor_from_cptr
57 module procedure atlas_Vertical__ctor_from_array
58 module procedure atlas_Vertical__ctor_from_array_with_interval
59 end interface
60
61 private :: c_ptr, c_double
62 private :: fckit_shared_object
63 private :: fckit_c_deleter
64 private :: fckit_c_nodeleter
65 private :: atlas_Field
66
67 !========================================================
68 contains
69 !========================================================
70 ! -----------------------------------------------------------------------------
71 ! Vertical routines
72
73 function atlas_Vertical__ctor_from_cptr( cptr, delete ) result(this)
74 use atlas_vertical_c_binding
75 type(c_ptr), value :: cptr
76 type(atlas_Vertical) :: this
77 logical, optional :: delete
78 logical :: opt_delete
79 opt_delete = .true.
80 if( present(delete) ) opt_delete = delete
81 if( opt_delete ) then
82 call this%reset_c_ptr( cptr, fckit_c_deleter(atlas__Vertical__delete) )
83 else
84 call this%reset_c_ptr( cptr, fckit_c_nodeleter() )
85 endif
86 call this%return()
87 end function
88
89 function atlas_Vertical__ctor_from_array( levels ) result(this)
90 use atlas_vertical_c_binding
91 use atlas_kinds_module, only : ATLAS_KIND_IDX
92 type(atlas_Vertical) :: this
93 real(c_double), intent(in) :: levels(:)
94 integer(ATLAS_KIND_IDX) :: nb_levels
95 nb_levels = size(levels)
96 call this%reset_c_ptr( atlas__Vertical__new(nb_levels, levels), &
97 & fckit_c_deleter(atlas__Vertical__delete) )
98 call this%return()
99 end function
100
101 function atlas_Vertical__ctor_from_array_with_interval( levels, interval ) result(this)
102 use atlas_vertical_c_binding
103 use atlas_kinds_module, only : ATLAS_KIND_IDX
104 type(atlas_Vertical) :: this
105 real(c_double), intent(in) :: levels(:)
106 real(c_double), intent(in) :: interval(2)
107 integer(ATLAS_KIND_IDX) :: nb_levels
108 nb_levels = size(levels)
109 call this%reset_c_ptr( atlas__Vertical__new_interval(nb_levels, levels, interval), &
110 & fckit_c_deleter(atlas__Vertical__delete) )
111 call this%return()
112 end function
113
114 ! ----------------------------------------------------------------------------------------
115
116 function z( this )
117 use atlas_vertical_c_binding
118 type(atlas_Field) :: z
119 class(atlas_Vertical), intent(in) :: this
120 z = atlas_Field( atlas__Vertical__z( this%CPTR_PGIBUG_B ) )
121 call z%return()
122 end function
123
124 ! ----------------------------------------------------------------------------------------
125
126 function vsize( this )
127 use atlas_vertical_c_binding
128 use, intrinsic :: iso_c_binding, only : c_int
129 integer(c_int) :: vsize
130 class(atlas_Vertical), intent(in) :: this
131 vsize = atlas__Vertical__size( this%CPTR_PGIBUG_B )
132 end function
133
134 ! ----------------------------------------------------------------------------------------
135
136 #if FCKIT_FINAL_NOT_INHERITING
137 ATLAS_FINAL subroutine atlas_Vertical__final_auto(this)
138 type(atlas_Vertical), intent(inout) :: this
139 #if FCKIT_FINAL_DEBUGGING
140 write(0,*) "atlas_Vertical__final_auto"
141 #endif
142 #if FCKIT_FINAL_NOT_PROPAGATING
143 call this%final()
144 #endif
145 FCKIT_SUPPRESS_UNUSED( this )
146 end subroutine
147 #endif
148
149 ! ----------------------------------------------------------------------------------------
150
151 end module atlas_Vertical_module