IODA
obsspace_interface.f
Go to the documentation of this file.
1 !
2 ! (C) Copyright 2017-2019 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 !> Define interface for C++ ObsSpace code called from Fortran
8 
9 !-------------------------------------------------------------------------------
10 interface
11 !-------------------------------------------------------------------------------
12 
13 type(c_ptr) function c_obsspace_construct(conf, tbegin, tend) bind(c, name='obsspace_construct_f')
14  use, intrinsic :: iso_c_binding
15  implicit none
16 
17  type(c_ptr), value :: conf, tbegin, tend
18 end function c_obsspace_construct
19 
20 subroutine c_obsspace_destruct(obss) bind(C, name='obsspace_destruct_f')
21  use, intrinsic :: iso_c_binding
22  implicit none
23  type(c_ptr), value :: obss
24 end subroutine c_obsspace_destruct
25 
26 type(c_ptr) function c_obsspace_obsvariables(obss) bind(c, name='obsspace_obsvariables_f')
27  use, intrinsic :: iso_c_binding, only : c_ptr
28  implicit none
29  type(c_ptr), value :: obss
30 end function c_obsspace_obsvariables
31 
32 integer(kind=c_size_t) function c_obsspace_get_gnlocs(obss) bind(C,name='obsspace_get_gnlocs_f')
33  use, intrinsic :: iso_c_binding
34  implicit none
35 
36  type(c_ptr), value :: obss
37 end function c_obsspace_get_gnlocs
38 
39 integer(kind=c_size_t) function c_obsspace_get_nlocs(obss) bind(C,name='obsspace_get_nlocs_f')
40  use, intrinsic :: iso_c_binding
41  implicit none
42 
43  type(c_ptr), value :: obss
44 end function c_obsspace_get_nlocs
45 
46 integer(kind=c_size_t) function c_obsspace_get_nrecs(obss) bind(C,name='obsspace_get_nrecs_f')
47  use, intrinsic :: iso_c_binding
48  implicit none
49 
50  type(c_ptr), value :: obss
51 end function c_obsspace_get_nrecs
52 
53 integer(kind=c_size_t) function c_obsspace_get_nvars(obss) bind(C,name='obsspace_get_nvars_f')
54  use, intrinsic :: iso_c_binding
55  implicit none
56 
57  type(c_ptr), value :: obss
58 end function c_obsspace_get_nvars
59 
60 subroutine c_obsspace_obsname(obss, lcname, cname) bind (C,name='obsspace_obsname_f')
61  use, intrinsic :: iso_c_binding, only : c_ptr, c_char, c_size_t
62  implicit none
63  type(c_ptr), value :: obss
64  integer(c_size_t),intent(inout) :: lcname
65  character(kind=c_char,len=1), intent(inout) :: cname(*)
66 end subroutine c_obsspace_obsname
67 
68 subroutine c_obsspace_get_comm(obss, lcname, cname) bind(C,name='obsspace_get_comm_f')
69  use, intrinsic :: iso_c_binding
70  implicit none
71 
72  type(c_ptr), value :: obss
73  integer(c_int),intent(inout) :: lcname !< Communicator name length
74  character(kind=c_char,len=1), intent(inout) :: cname(*) !< Communicator name
75 end subroutine c_obsspace_get_comm
76 
77 subroutine c_obsspace_get_recnum(obss, length, recnum) &
78  & bind(c,name='obsspace_get_recnum_f')
79  use, intrinsic :: iso_c_binding, only : c_ptr, c_size_t
80  implicit none
81  type(c_ptr), value :: obss
82  integer(c_size_t), intent(in) :: length
83  integer(c_size_t), intent(inout) :: recnum(length)
84 end subroutine c_obsspace_get_recnum
85 
86 subroutine c_obsspace_get_index(obss, length, indx) &
87  & bind(c,name='obsspace_get_index_f')
88  use, intrinsic :: iso_c_binding, only : c_ptr, c_size_t
89  implicit none
90  type(c_ptr), value :: obss
91  integer(c_size_t), intent(in) :: length
92  integer(c_size_t), intent(inout) :: indx(length)
93 end subroutine c_obsspace_get_index
94 
95 logical(kind=c_bool) function c_obsspace_has(obss, group, vname) bind(C,name='obsspace_has_f')
96  use, intrinsic :: iso_c_binding
97  implicit none
98 
99  type(c_ptr), value :: obss
100  character(kind=c_char, len=1), intent(in) :: group(*)
101  character(kind=c_char, len=1), intent(in) :: vname(*)
102 end function c_obsspace_has
103 
104 !-------------------------------------------------------------------------------
105 ! get data from ObsSpace
106 
107 subroutine c_obsspace_get_int32(obss, group, vname, length, vect) &
108  & bind(c,name='obsspace_get_int32_f')
109  use, intrinsic :: iso_c_binding, only : c_ptr,c_char,c_size_t,c_int32_t
110  implicit none
111  type(c_ptr), value :: obss
112  character(kind=c_char, len=1), intent(in) :: group(*)
113  character(kind=c_char, len=1), intent(in) :: vname(*)
114  integer(c_size_t), intent(in) :: length
115  integer(c_int32_t), intent(inout) :: vect(length)
116 end subroutine c_obsspace_get_int32
117 
118 subroutine c_obsspace_get_int64(obss, group, vname, length, vect) &
119  & bind(c,name='obsspace_get_int64_f')
120  use, intrinsic :: iso_c_binding, only : c_ptr,c_char,c_size_t,c_int64_t
121  implicit none
122  type(c_ptr), value :: obss
123  character(kind=c_char, len=1), intent(in) :: group(*)
124  character(kind=c_char, len=1), intent(in) :: vname(*)
125  integer(c_size_t), intent(in) :: length
126  integer(c_int64_t), intent(inout) :: vect(length)
127 end subroutine c_obsspace_get_int64
128 
129 subroutine c_obsspace_get_real32(obss, group, vname, length, vect) &
130  & bind(c,name='obsspace_get_real32_f')
131  use, intrinsic :: iso_c_binding, only : c_ptr,c_char,c_size_t,c_float
132  implicit none
133  type(c_ptr), value :: obss
134  character(kind=c_char, len=1), intent(in) :: group(*)
135  character(kind=c_char, len=1), intent(in) :: vname(*)
136  integer(c_size_t), intent(in) :: length
137  real(c_float), intent(inout) :: vect(length)
138 end subroutine c_obsspace_get_real32
139 
140 subroutine c_obsspace_get_real64(obss, group, vname, length, vect) &
141  & bind(c,name='obsspace_get_real64_f')
142  use, intrinsic :: iso_c_binding, only : c_ptr,c_char,c_size_t,c_double
143  implicit none
144  type(c_ptr), value :: obss
145  character(kind=c_char, len=1), intent(in) :: group(*)
146  character(kind=c_char, len=1), intent(in) :: vname(*)
147  integer(c_size_t), intent(in) :: length
148  real(c_double), intent(inout) :: vect(length)
149 end subroutine c_obsspace_get_real64
150 
151 subroutine c_obsspace_get_datetime(obss, group, vname, length, date, time) &
152  & bind(c,name='obsspace_get_datetime_f')
153  use, intrinsic :: iso_c_binding, only : c_ptr,c_char,c_size_t,c_int32_t
154  implicit none
155  type(c_ptr), value :: obss
156  character(kind=c_char, len=1), intent(in) :: group(*)
157  character(kind=c_char, len=1), intent(in) :: vname(*)
158  integer(c_size_t), intent(in) :: length
159  integer(c_int32_t), intent(inout) :: date(length)
160  integer(c_int32_t), intent(inout) :: time(length)
161 end subroutine c_obsspace_get_datetime
162 
163 !-------------------------------------------------------------------------------
164 ! store data in ObsSpace
165 
166 subroutine c_obsspace_put_int32(obss, group, vname, length, vect) &
167  & bind(c,name='obsspace_put_int32_f')
168  use, intrinsic :: iso_c_binding, only : c_ptr,c_char,c_size_t,c_int32_t
169  implicit none
170  type(c_ptr), value :: obss
171  character(kind=c_char, len=1), intent(in) :: group(*)
172  character(kind=c_char, len=1), intent(in) :: vname(*)
173  integer(c_size_t), intent(in) :: length
174  integer(c_int32_t), intent(in) :: vect(length)
175 end subroutine c_obsspace_put_int32
176 
177 subroutine c_obsspace_put_int64(obss, group, vname, length, vect) &
178  & bind(c,name='obsspace_put_int64_f')
179  use, intrinsic :: iso_c_binding, only : c_ptr,c_char,c_size_t,c_int64_t
180  implicit none
181  type(c_ptr), value :: obss
182  character(kind=c_char, len=1), intent(in) :: group(*)
183  character(kind=c_char, len=1), intent(in) :: vname(*)
184  integer(c_size_t), intent(in) :: length
185  integer(c_int64_t), intent(in) :: vect(length)
186 end subroutine c_obsspace_put_int64
187 
188 subroutine c_obsspace_put_real32(obss, group, vname, length, vect) &
189  & bind(c,name='obsspace_put_real32_f')
190  use, intrinsic :: iso_c_binding, only : c_ptr,c_char,c_size_t,c_float
191  implicit none
192  type(c_ptr), value :: obss
193  character(kind=c_char, len=1), intent(in) :: group(*)
194  character(kind=c_char, len=1), intent(in) :: vname(*)
195  integer(c_size_t), intent(in) :: length
196  real(c_float), intent(in) :: vect(length)
197 end subroutine c_obsspace_put_real32
198 
199 subroutine c_obsspace_put_real64(obss, group, vname, length, vect) &
200  & bind(c,name='obsspace_put_real64_f')
201  use, intrinsic :: iso_c_binding, only : c_ptr,c_char,c_size_t,c_double
202  implicit none
203  type(c_ptr), value :: obss
204  character(kind=c_char, len=1), intent(in) :: group(*)
205  character(kind=c_char, len=1), intent(in) :: vname(*)
206  integer(c_size_t), intent(in) :: length
207  real(c_double), intent(in) :: vect(length)
208 end subroutine c_obsspace_put_real64
209 
210 !-------------------------------------------------------------------------------
211 end interface
212 !-------------------------------------------------------------------------------
c_obsspace_put_int32
Definition: obsspace_interface.f:166
c_obsspace_get_nrecs
Definition: obsspace_interface.f:46
c_obsspace_put_real64
Definition: obsspace_interface.f:199
c_obsspace_get_comm
Definition: obsspace_interface.f:68
c_obsspace_get_int64
Definition: obsspace_interface.f:118
c_obsspace_get_real32
Definition: obsspace_interface.f:129
c_obsspace_get_nlocs
Definition: obsspace_interface.f:39
c_obsspace_get_recnum
Definition: obsspace_interface.f:77
c_obsspace_has
Definition: obsspace_interface.f:95
c_obsspace_construct
Define interface for C++ ObsSpace code called from Fortran.
Definition: obsspace_interface.f:13
c_obsspace_put_int64
Definition: obsspace_interface.f:177
c_obsspace_obsvariables
Definition: obsspace_interface.f:26
c_obsspace_get_datetime
Definition: obsspace_interface.f:151
c_obsspace_get_real64
Definition: obsspace_interface.f:140
c_obsspace_put_real32
Definition: obsspace_interface.f:188
c_obsspace_get_int32
Definition: obsspace_interface.f:107
c_obsspace_destruct
Definition: obsspace_interface.f:20
c_obsspace_obsname
Definition: obsspace_interface.f:60
c_obsspace_get_nvars
Definition: obsspace_interface.f:53
c_obsspace_get_index
Definition: obsspace_interface.f:86
c_obsspace_get_gnlocs
Definition: obsspace_interface.f:32