FV3 Bundle
obsspace_interface.f
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 !> Define interface for C++ ObsSpace code called from Fortran
8 
9 !-------------------------------------------------------------------------------
10 interface
11 !-------------------------------------------------------------------------------
12 
13 integer(kind=c_int) function c_obsspace_get_nobs(dom) bind(C,name='obsspace_get_nobs_f')
14  use, intrinsic :: iso_c_binding
15  implicit none
16 
17  type(c_ptr), value :: dom
18 end function c_obsspace_get_nobs
19 
20 integer(kind=c_int) function c_obsspace_get_nlocs(dom) bind(C,name='obsspace_get_nlocs_f')
21  use, intrinsic :: iso_c_binding
22  implicit none
23 
24  type(c_ptr), value :: dom
25 end function c_obsspace_get_nlocs
26 
27 !-------------------------------------------------------------------------------
28 ! get data from ObsSpace
29 
30 subroutine c_obsspace_get_int32(obss, group, vname, length, vect) &
31  & bind(c,name='obsspace_get_int32_f')
32  use, intrinsic :: iso_c_binding, only : c_ptr,c_char,c_size_t,c_int32_t
33  implicit none
34  type(c_ptr), value :: obss
35  character(kind=c_char, len=1), intent(in) :: group(*)
36  character(kind=c_char, len=1), intent(in) :: vname(*)
37  integer(c_size_t), intent(in) :: length
38  integer(c_int32_t), intent(inout) :: vect(length)
39 end subroutine c_obsspace_get_int32
40 
41 subroutine c_obsspace_get_int64(obss, group, vname, length, vect) &
42  & bind(c,name='obsspace_get_int64_f')
43  use, intrinsic :: iso_c_binding, only : c_ptr,c_char,c_size_t,c_int64_t
44  implicit none
45  type(c_ptr), value :: obss
46  character(kind=c_char, len=1), intent(in) :: group(*)
47  character(kind=c_char, len=1), intent(in) :: vname(*)
48  integer(c_size_t), intent(in) :: length
49  integer(c_int64_t), intent(inout) :: vect(length)
50 end subroutine c_obsspace_get_int64
51 
52 subroutine c_obsspace_get_real32(obss, group, vname, length, vect) &
53  & bind(c,name='obsspace_get_real32_f')
54  use, intrinsic :: iso_c_binding, only : c_ptr,c_char,c_size_t,c_float
55  implicit none
56  type(c_ptr), value :: obss
57  character(kind=c_char, len=1), intent(in) :: group(*)
58  character(kind=c_char, len=1), intent(in) :: vname(*)
59  integer(c_size_t), intent(in) :: length
60  real(c_float), intent(inout) :: vect(length)
61 end subroutine c_obsspace_get_real32
62 
63 subroutine c_obsspace_get_real64(obss, group, vname, length, vect) &
64  & bind(c,name='obsspace_get_real64_f')
65  use, intrinsic :: iso_c_binding, only : c_ptr,c_char,c_size_t,c_double
66  implicit none
67  type(c_ptr), value :: obss
68  character(kind=c_char, len=1), intent(in) :: group(*)
69  character(kind=c_char, len=1), intent(in) :: vname(*)
70  integer(c_size_t), intent(in) :: length
71  real(c_double), intent(inout) :: vect(length)
72 end subroutine c_obsspace_get_real64
73 
74 !-------------------------------------------------------------------------------
75 ! store data in ObsSpace
76 
77 subroutine c_obsspace_put_int32(obss, group, vname, length, vect) &
78  & bind(c,name='obsspace_put_int32_f')
79  use, intrinsic :: iso_c_binding, only : c_ptr,c_char,c_size_t,c_int32_t
80  implicit none
81  type(c_ptr), value :: obss
82  character(kind=c_char, len=1), intent(in) :: group(*)
83  character(kind=c_char, len=1), intent(in) :: vname(*)
84  integer(c_size_t), intent(in) :: length
85  integer(c_int32_t), intent(in) :: vect(length)
86 end subroutine c_obsspace_put_int32
87 
88 subroutine c_obsspace_put_int64(obss, group, vname, length, vect) &
89  & bind(c,name='obsspace_put_int64_f')
90  use, intrinsic :: iso_c_binding, only : c_ptr,c_char,c_size_t,c_int64_t
91  implicit none
92  type(c_ptr), value :: obss
93  character(kind=c_char, len=1), intent(in) :: group(*)
94  character(kind=c_char, len=1), intent(in) :: vname(*)
95  integer(c_size_t), intent(in) :: length
96  integer(c_int64_t), intent(in) :: vect(length)
97 end subroutine c_obsspace_put_int64
98 
99 subroutine c_obsspace_put_real32(obss, group, vname, length, vect) &
100  & bind(c,name='obsspace_put_real32_f')
101  use, intrinsic :: iso_c_binding, only : c_ptr,c_char,c_size_t,c_float
102  implicit none
103  type(c_ptr), value :: obss
104  character(kind=c_char, len=1), intent(in) :: group(*)
105  character(kind=c_char, len=1), intent(in) :: vname(*)
106  integer(c_size_t), intent(in) :: length
107  real(c_float), intent(in) :: vect(length)
108 end subroutine c_obsspace_put_real32
109 
110 subroutine c_obsspace_put_real64(obss, group, vname, length, vect) &
111  & bind(c,name='obsspace_put_real64_f')
112  use, intrinsic :: iso_c_binding, only : c_ptr,c_char,c_size_t,c_double
113  implicit none
114  type(c_ptr), value :: obss
115  character(kind=c_char, len=1), intent(in) :: group(*)
116  character(kind=c_char, len=1), intent(in) :: vname(*)
117  integer(c_size_t), intent(in) :: length
118  real(c_double), intent(in) :: vect(length)
119 end subroutine c_obsspace_put_real64
120 
121 !-------------------------------------------------------------------------------
122 end interface
123 !-------------------------------------------------------------------------------
124 
Define interface for C++ ObsSpace code called from Fortran.