UFO
Locations.interface.F90
Go to the documentation of this file.
1 !
2 ! (C) Copyright 2017 UCAR
3 !
4 ! This software is licensed under the terms of the Apache Licence Version 2.0
5 ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6 !
7 
9 
10 use iso_c_binding
11 use ufo_locs_mod
12 use kinds
13 
14 implicit none
15 
16 public :: ufo_locs_registry
17 
18 private
19 
20 ! ------------------------------------------------------------------------------
21 
22 #define LISTED_TYPE ufo_locs
23 
24 !> Linked list interface - defines registry_t type
25 #include "oops/util/linkedList_i.f"
26 
27 !> Global registry
28 type(registry_t) :: ufo_locs_registry
29 
30 ! ------------------------------------------------------------------------------
31 contains
32 ! ------------------------------------------------------------------------------
33 !> Linked list implementation
34 #include "oops/util/linkedList_c.f"
35 
36 ! ------------------------------------------------------------------------------
37 
38 subroutine ufo_locs_create_c(key, klocs, c_obsspace, klats, klons) bind(c,name='ufo_locs_create_f90')
39 
40 implicit none
41 integer(c_int), intent(inout) :: key
42 integer(c_int), intent(in) :: klocs
43 type(c_ptr), value, intent(in) :: c_obsspace
44 real(c_double), intent(in) :: klats(klocs)
45 real(c_double), intent(in) :: klons(klocs)
46 
47 type(ufo_locs), pointer :: self
48 real(kind_real) :: lats(klocs)
49 real(kind_real) :: lons(klocs)
50 
51 call ufo_locs_registry%setup(key, self)
52 
53 lats(:) = klats(:)
54 lons(:) = klons(:)
55 
56 call ufo_locs_create(self, c_obsspace, klocs, lats, lons)
57 
58 end subroutine ufo_locs_create_c
59 
60 ! ------------------------------------------------------------------------------
61 
62 subroutine ufo_locs_setup_c(key, nlocs) bind(c,name='ufo_locs_setup_f90')
63 
64 implicit none
65 integer(c_int), intent(inout) :: key
66 integer(c_int), intent(in) :: nlocs
67 type(ufo_locs), pointer :: self
68 
69 call ufo_locs_registry%setup(key, self)
70 
71 call ufo_locs_setup(self, nlocs)
72 
73 end subroutine ufo_locs_setup_c
74 
75 !------------------------------------------------------------------------------
76 
77 subroutine ufo_locs_copy_c(key, key2) bind(c,name='ufo_locs_copy_f90')
78 
79 implicit none
80 integer(c_int), intent(inout) :: key
81 integer(c_int), intent(in) :: key2
82 
83 type(ufo_locs), pointer :: self
84 type(ufo_locs), pointer :: other
85 
86 call ufo_locs_registry%setup(key, self)
87 call ufo_locs_registry%get(key2, other)
88 
89 call ufo_locs_copy(self, other)
90 
91 end subroutine ufo_locs_copy_c
92 
93 ! ------------------------------------------------------------------------------
94 
95 subroutine ufo_locs_delete_c(key) bind(c,name='ufo_locs_delete_f90')
96 
97 implicit none
98 integer(c_int), intent(inout) :: key
99 type(ufo_locs), pointer :: self
100 
101 call ufo_locs_registry%get(key,self)
102 call ufo_locs_delete(self)
103 call ufo_locs_registry%remove(key)
104 
105 end subroutine ufo_locs_delete_c
106 
107 ! ------------------------------------------------------------------------------
108 
109 subroutine ufo_locs_nobs_c(key, kobs) bind(c,name='ufo_locs_nobs_f90')
110 
111 implicit none
112 integer(c_int), intent(in) :: key
113 integer(c_int), intent(inout) :: kobs
114 type(ufo_locs), pointer :: self
115 
116 call ufo_locs_registry%get(key,self)
117 kobs = self%nlocs
118 
119 end subroutine ufo_locs_nobs_c
120 ! ------------------------------------------------------------------------------
121 
122 subroutine ufo_locs_coords_c(key, idx, mylat, mylon) bind(c,name='ufo_locs_coords_f90')
123 
124 implicit none
125 integer(c_int), intent(in) :: key
126 integer(c_int), intent(in) :: idx
127 real(c_double), intent(inout) :: mylat,mylon
128 
129 type(ufo_locs), pointer :: self
130 
131 call ufo_locs_registry%get(key,self)
132 mylat = self%lat(idx+1)
133 mylon = self%lon(idx+1)
134 
135 end subroutine ufo_locs_coords_c
136 !---------------------------------------------------------------------------------
137 
138 subroutine ufo_locs_indx_c(key, idx, indx, max_indx) bind(c,name='ufo_locs_indx_f90')
139 
140 implicit none
141 integer(c_int), intent(in) :: key
142 integer(c_int), intent(in) :: idx
143 integer(c_int), intent(inout) :: indx
144 integer(c_int), intent(inout) :: max_indx
145 
146 type(ufo_locs), pointer :: self
147 
148 call ufo_locs_registry%get(key, self)
149 max_indx = self%max_indx
150 if (max_indx > 0) indx = self%indx(idx+1) - 1 ! the minus to take account of C++ starting from 0
151 
152 
153 end subroutine ufo_locs_indx_c
154 !------------------------------------------------------------------------------
155 subroutine ufo_locs_concatenate_c(key, key2) bind(c,name='ufo_locs_concatenate_f90')
156 
157 implicit none
158 integer(c_int), intent(in) :: key
159 integer(c_int), intent(in) :: key2
160 
161 type(ufo_locs), pointer :: self
162 type(ufo_locs), pointer :: other
163 
164 call ufo_locs_registry%get(key, self)
165 call ufo_locs_registry%get(key2, other)
166 call ufo_locs_concatenate(self, other)
167 
168 end subroutine ufo_locs_concatenate_c
169 ! ------------------------------------------------------------------------------
170 
171 subroutine ufo_locs_init_c(c_key_self, c_obsspace, c_t1, c_t2) bind(c,name='ufo_locs_init_f90')
172 use datetime_mod
173 implicit none
174 integer(c_int), intent(inout) :: c_key_self
175 type(c_ptr), value, intent(in) :: c_obsspace
176 type(c_ptr), value, intent(in) :: c_t1, c_t2
177 
178 type(ufo_locs), pointer :: self
179 
180 type(datetime) :: t1, t2
181 
182 call ufo_locs_registry%setup(c_key_self, self)
183 
184 call c_f_datetime(c_t1, t1)
185 call c_f_datetime(c_t2, t2)
186 
187 call ufo_locs_registry%get(c_key_self, self)
188 call ufo_locs_init(self, c_obsspace, t1, t2)
189 
190 end subroutine ufo_locs_init_c
191 
192 end module ufo_locs_mod_c
ufo_locs_mod_c::ufo_locs_registry
type(registry_t), public ufo_locs_registry
Linked list interface - defines registry_t type.
Definition: Locations.interface.F90:28
ufo_locs_mod_c::ufo_locs_concatenate_c
subroutine ufo_locs_concatenate_c(key, key2)
Definition: Locations.interface.F90:156
ufo_locs_mod::ufo_locs_create
subroutine, public ufo_locs_create(self, obss, nlocs, lats, lons)
Definition: ufo_locs_mod.F90:39
ufo_locs_mod::ufo_locs_copy
subroutine, public ufo_locs_copy(self, other)
Definition: ufo_locs_mod.F90:106
ufo_locs_mod_c::ufo_locs_copy_c
subroutine ufo_locs_copy_c(key, key2)
Definition: Locations.interface.F90:78
ufo_locs_mod::ufo_locs_delete
subroutine, public ufo_locs_delete(self)
Definition: ufo_locs_mod.F90:129
ufo_locs_mod_c::ufo_locs_nobs_c
subroutine ufo_locs_nobs_c(key, kobs)
Definition: Locations.interface.F90:110
ufo_locs_mod::ufo_locs_concatenate
subroutine, public ufo_locs_concatenate(self, other)
Definition: ufo_locs_mod.F90:144
ufo_locs_mod_c::ufo_locs_create_c
subroutine ufo_locs_create_c(key, klocs, c_obsspace, klats, klons)
Linked list implementation.
Definition: Locations.interface.F90:39
ufo_locs_mod::ufo_locs_setup
subroutine, public ufo_locs_setup(self, nlocs)
Definition: ufo_locs_mod.F90:81
ufo_locs_mod_c::ufo_locs_coords_c
subroutine ufo_locs_coords_c(key, idx, mylat, mylon)
Definition: Locations.interface.F90:123
ufo_locs_mod_c
Definition: Locations.interface.F90:8
ufo_locs_mod_c::ufo_locs_delete_c
subroutine ufo_locs_delete_c(key)
Definition: Locations.interface.F90:96
ufo_locs_mod
Fortran module handling observation locations.
Definition: ufo_locs_mod.F90:9
ufo_locs_mod_c::ufo_locs_init_c
subroutine ufo_locs_init_c(c_key_self, c_obsspace, c_t1, c_t2)
Definition: Locations.interface.F90:172
ufo_locs_mod::ufo_locs
Fortran derived type to hold observation locations.
Definition: ufo_locs_mod.F90:25
ufo_locs_mod_c::ufo_locs_setup_c
subroutine ufo_locs_setup_c(key, nlocs)
Definition: Locations.interface.F90:63
ufo_locs_mod_c::ufo_locs_indx_c
subroutine ufo_locs_indx_c(key, idx, indx, max_indx)
Definition: Locations.interface.F90:139
ufo_locs_mod::ufo_locs_init
subroutine, public ufo_locs_init(self, obss, t1, t2)
Definition: ufo_locs_mod.F90:223