SOCA
soca_geom.interface.F90
Go to the documentation of this file.
1 ! (C) Copyright 2017-2021 UCAR
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 
6 
7 !> C++ interfaces for soca_geom_mod::soca_geom
9 
10 use atlas_module, only: atlas_fieldset, atlas_functionspace_pointcloud
11 use fckit_configuration_module, only: fckit_configuration
12 use fckit_mpi_module, only: fckit_mpi_comm
13 use iso_c_binding
14 use oops_variables_mod, only: oops_variables
15 
16 ! soca modules
17 use soca_geom_mod, only: soca_geom
19 
20 
21 implicit none
22 private
23 
24 
25 #define LISTED_TYPE soca_geom
26 
27 !> Linked list interface - defines registry_t type
28 #include "oops/util/linkedList_i.f"
29 
30 !> Global registry for soca_geom instances
31 type(registry_t), public :: soca_geom_registry
32 
33 ! ------------------------------------------------------------------------------
34 contains
35 ! ------------------------------------------------------------------------------
36 
37 !> Linked list implementation
38 #include "oops/util/linkedList_c.f"
39 
40 
41 ! ------------------------------------------------------------------------------
42 !> C++ interface for soca_geom_mod::soca_geom::init()
43 subroutine soca_geo_setup_c(c_key_self, c_conf, c_comm) bind(c,name='soca_geo_setup_f90')
44  integer(c_int), intent(inout) :: c_key_self
45  type(c_ptr), intent(in) :: c_conf
46  type(c_ptr), value, intent(in) :: c_comm
47 
48  type(soca_geom), pointer :: self
49 
50  call soca_geom_registry%init()
51  call soca_geom_registry%add(c_key_self)
52  call soca_geom_registry%get(c_key_self,self)
53 
54  call self%init(fckit_configuration(c_conf), fckit_mpi_comm(c_comm) )
55 end subroutine soca_geo_setup_c
56 
57 
58 ! --------------------------------------------------------------------------------------------------
59 !> C++ interface for soca_geom_mod::soca_geom::set_atlas_lonlat()
60 subroutine soca_geo_set_atlas_lonlat_c(c_key_self, c_afieldset) bind(c,name='soca_geo_set_atlas_lonlat_f90')
61  integer(c_int), intent(in) :: c_key_self
62  type(c_ptr), intent(in), value :: c_afieldset
63 
64  type(soca_geom), pointer :: self
65  type(atlas_fieldset) :: afieldset
66 
67  call soca_geom_registry%get(c_key_self,self)
68  afieldset = atlas_fieldset(c_afieldset)
69 
70  call self%set_atlas_lonlat(afieldset)
71 end subroutine soca_geo_set_atlas_lonlat_c
72 
73 
74 ! --------------------------------------------------------------------------------------------------
75 !> C++ interface to get atlas functionspace pointr from soca_geom_mod::soca_geom
76 subroutine soca_geo_set_atlas_functionspace_pointer_c(c_key_self,c_afunctionspace) &
77  bind(c,name='soca_geo_set_atlas_functionspace_pointer_f90')
78  integer(c_int), intent(in) :: c_key_self
79  type(c_ptr), intent(in), value :: c_afunctionspace
80 
81  type(soca_geom),pointer :: self
82 
83  call soca_geom_registry%get(c_key_self,self)
84 
85  self%afunctionspace = atlas_functionspace_pointcloud(c_afunctionspace)
87 
88 
89 ! --------------------------------------------------------------------------------------------------
90 !> C++ interface for soca_geom_mod::soca_geom::fill_atlas_fieldset()
91 subroutine soca_geo_fill_atlas_fieldset_c(c_key_self, c_afieldset) &
92  & bind(c,name='soca_geo_fill_atlas_fieldset_f90')
93 
94  integer(c_int), intent(in) :: c_key_self
95  type(c_ptr), value, intent(in) :: c_afieldset
96 
97  type(soca_geom), pointer :: self
98  type(atlas_fieldset) :: afieldset
99 
100  call soca_geom_registry%get(c_key_self,self)
101  afieldset = atlas_fieldset(c_afieldset)
102 
103  call self%fill_atlas_fieldset(afieldset)
104 end subroutine soca_geo_fill_atlas_fieldset_c
105 
106 
107 ! ------------------------------------------------------------------------------
108 !> C++ interface for soca_geom_mod::soca_geom::clone()
109 subroutine soca_geo_clone_c(c_key_self, c_key_other) bind(c,name='soca_geo_clone_f90')
110  integer(c_int), intent(inout) :: c_key_self
111  integer(c_int), intent(in) :: c_key_other
112 
113  type(soca_geom), pointer :: self, other
114 
115  call soca_geom_registry%add(c_key_self)
116  call soca_geom_registry%get(c_key_self, self)
117  call soca_geom_registry%get(c_key_other, other )
118 
119  call self%clone(other)
120 end subroutine soca_geo_clone_c
121 
122 
123 ! ------------------------------------------------------------------------------
124 !> C++ interface for soca_geom_mod::soca_geom::gridgen()
125 subroutine soca_geo_gridgen_c(c_key_self) bind(c,name='soca_geo_gridgen_f90')
126  integer(c_int), intent(inout) :: c_key_self
127 
128  type(soca_geom), pointer :: self
129 
130  call soca_geom_registry%get(c_key_self, self)
131 
132  call self%gridgen()
133 end subroutine soca_geo_gridgen_c
134 
135 
136 ! ------------------------------------------------------------------------------
137 !> C++ interface for soca_geom_mod::soca_geom::end()
138 subroutine soca_geo_delete_c(c_key_self) bind(c,name='soca_geo_delete_f90')
139  integer(c_int), intent(inout) :: c_key_self
140 
141  type(soca_geom), pointer :: self
142 
143  call soca_geom_registry%get(c_key_self, self)
144  call self%end()
145  call soca_geom_registry%remove(c_key_self)
146 end subroutine soca_geo_delete_c
147 
148 
149 ! ------------------------------------------------------------------------------
150 !> C++ interface to return begin and end of local geometry in soca_geom
151 subroutine soca_geo_start_end_c(c_key_self, ist, iend, jst, jend) bind(c, name='soca_geo_start_end_f90')
152  integer(c_int), intent( in) :: c_key_self
153  integer(c_int), intent(out) :: ist, iend, jst, jend
154 
155  type(soca_geom), pointer :: self
156  call soca_geom_registry%get(c_key_self, self)
157 
158  ist = self%isc
159  iend = self%iec
160  jst = self%jsc
161  jend = self%jec
162 end subroutine soca_geo_start_end_c
163 
164 
165 ! ------------------------------------------------------------------------------
166 !> C++ interface to get number of levels for soca_geom
167 subroutine soca_geo_get_num_levels_c(c_key_self, c_vars, c_levels_size, c_levels) &
168  bind(c, name='soca_geo_get_num_levels_f90')
169  integer(c_int), intent(in) :: c_key_self
170  type(c_ptr), value, intent(in) :: c_vars
171  integer(c_size_t), intent(in) :: c_levels_size
172  integer(c_size_t), intent(out) :: c_levels(c_levels_size)
173 
174  type(soca_geom), pointer :: self
175  type(oops_variables) :: vars
176  integer :: i
177  character(len=:), allocatable :: field_name
178  type(soca_field_metadata) :: field
179 
180  call soca_geom_registry%get(c_key_self, self)
181  vars = oops_variables(c_vars)
182 
183  do i = 1,vars%nvars()
184  field_name = vars%variable(i)
185  field = self%fields_metadata%get(field_name)
186  select case(field%levels)
187  case ("1")
188  c_levels(i) = 1
189  case ("full_ocn")
190  if (field_name == field%getval_name_surface) then
191  c_levels(i) = 1
192  else
193  c_levels(i) = self%nzo
194  end if
195  case default
196  call abor1_ftn('ERROR in c_soca_geo_get_num_levels, unknown "levels" '//field%levels)
197  end select
198  end do
199 end subroutine soca_geo_get_num_levels_c
200 
201 ! ------------------------------------------------------------------------------
202 
203 end module soca_geom_mod_c
Metadata for soca_fields.
C++ interfaces for soca_geom_mod::soca_geom.
subroutine soca_geo_get_num_levels_c(c_key_self, c_vars, c_levels_size, c_levels)
C++ interface to get number of levels for soca_geom.
subroutine soca_geo_set_atlas_functionspace_pointer_c(c_key_self, c_afunctionspace)
C++ interface to get atlas functionspace pointr from soca_geom_mod::soca_geom.
subroutine soca_geo_clone_c(c_key_self, c_key_other)
C++ interface for soca_geom_mod::soca_geom::clone()
subroutine soca_geo_delete_c(c_key_self)
C++ interface for soca_geom_mod::soca_geom::end()
subroutine soca_geo_start_end_c(c_key_self, ist, iend, jst, jend)
C++ interface to return begin and end of local geometry in soca_geom.
type(registry_t), public soca_geom_registry
Linked list interface - defines registry_t type.
subroutine soca_geo_gridgen_c(c_key_self)
C++ interface for soca_geom_mod::soca_geom::gridgen()
subroutine soca_geo_setup_c(c_key_self, c_conf, c_comm)
Linked list implementation.
subroutine soca_geo_set_atlas_lonlat_c(c_key_self, c_afieldset)
C++ interface for soca_geom_mod::soca_geom::set_atlas_lonlat()
subroutine soca_geo_fill_atlas_fieldset_c(c_key_self, c_afieldset)
C++ interface for soca_geom_mod::soca_geom::fill_atlas_fieldset()
Geometry module.
Holds all of the user configurable meta data associated with a single field.
Geometry data structure.