ComIn 0.5.1
ICON Community Interface
Loading...
Searching...
No Matches
comin_state.F90
Go to the documentation of this file.
1!> @file comin_state.F90
2!! @brief Data shared between host and plugins.
3!
4! @authors 10/2023 :: ICON Community Interface <comin@icon-model.org>
5!
6! SPDX-License-Identifier: BSD-3-Clause
7!
8! See LICENSES for license information.
9! Where software is supplied by third parties, it is indicated in the
10! headers of the routines.
11!
13
14 USE iso_c_binding, ONLY: c_bool, c_int, c_ptr, c_funptr, c_funloc
19
20 IMPLICIT NONE
21
22 PRIVATE
27 PUBLIC :: comin_current_get_ep
45
46#include "comin_global.inc"
47
48 TYPE, PUBLIC :: t_comin_state
49
50 ! (Non-public) data structure
51 TYPE(t_comin_parallel_info) :: parallel_info
52
53 !> Create descriptive data structures
54 TYPE(t_comin_descrdata_global_data) :: comin_descrdata_global_data
55 TYPE(t_comin_descrdata_domain_data), ALLOCATABLE :: comin_descrdata_domain_data(:)
56
57 END TYPE t_comin_state
58
59 ! Global variable holding the ComIn state.
60 ! The C++ part of the state is declared in comin_state.hpp.
61 TYPE(t_comin_state), PUBLIC, POINTER :: state => null()
62
63 INTERFACE
64
65 SUBROUTINE comin_state_set_num_plugins(num_plugins) BIND(C)
66 IMPORT c_int
67 INTEGER(KIND=C_INT), INTENT(IN), VALUE :: num_plugins
68 END SUBROUTINE comin_state_set_num_plugins
69
70 FUNCTION comin_state_get_num_plugins() BIND(C)
71 IMPORT c_int
72 INTEGER(KIND=C_INT) :: comin_state_get_num_plugins
74
75 SUBROUTINE comin_setup_set_verbosity_level(iverbosity) BIND(C)
76 IMPORT c_int
77 INTEGER(KIND=C_INT), INTENT(IN), VALUE :: iverbosity
79
81 IMPORT c_int
82 INTEGER(KIND=C_INT) :: comin_setup_get_verbosity_level
84
85 SUBROUTINE comin_state_set_error_code(errcode) BIND(C)
86 IMPORT c_int
87 INTEGER(KIND=C_INT), INTENT(IN), VALUE :: errcode
88 END SUBROUTINE comin_state_set_error_code
89
90 FUNCTION comin_state_get_error_code() BIND(C)
91 IMPORT c_int
92 INTEGER(KIND=C_INT) :: comin_state_get_error_code
94
95 SUBROUTINE comin_state_set_lstdout(lstdout) BIND(C)
96 IMPORT c_bool
97 LOGICAL(KIND=C_BOOL), INTENT(IN), VALUE :: lstdout
98 END SUBROUTINE comin_state_set_lstdout
99
100 FUNCTION comin_state_get_lstdout() BIND(C)
101 IMPORT c_bool
102 LOGICAL(KIND=C_BOOL) :: comin_state_get_lstdout
103 END FUNCTION comin_state_get_lstdout
104
105 SUBROUTINE comin_state_set_output_unit(unit) BIND(C)
106 IMPORT c_int
107 INTEGER(KIND=C_INT), INTENT(IN), VALUE :: unit
108 END SUBROUTINE comin_state_set_output_unit
109
111 IMPORT c_int
112 INTEGER(KIND=C_INT) :: comin_state_get_output_unit
113 END FUNCTION comin_state_get_output_unit
114
115 FUNCTION comin_state_get_var_list() BIND(C)
116 IMPORT c_ptr
117 TYPE(c_ptr) :: comin_state_get_var_list
118 END FUNCTION comin_state_get_var_list
119
120 !> Get current entry point
121 !! @ingroup fortran_interface
122 FUNCTION comin_current_get_ep() BIND(C)
123 IMPORT c_int
124 INTEGER(c_int) :: comin_current_get_ep
125 END FUNCTION comin_current_get_ep
126
127 !> Returns the current domain ID if the entry point is called in a domain loop
128 !! @see COMIN_DOMAIN_OUTSIDE_LOOP
129 !! @ingroup fortran_interface
131 IMPORT c_int
132 INTEGER(c_int) :: comin_current_get_domain_id
133 END FUNCTION comin_current_get_domain_id
134
135 SUBROUTINE comin_current_set_plugin_id(plugin_id) BIND(C)
136 IMPORT c_int
137 INTEGER(c_int), VALUE :: plugin_id
138 END SUBROUTINE comin_current_set_plugin_id
139
141 IMPORT c_int
142 INTEGER(c_int) :: comin_current_get_plugin_id
143 END FUNCTION comin_current_get_plugin_id
144
146 IMPORT c_bool
147 LOGICAL(c_bool) :: comin_state_is_primary_done
148 END FUNCTION comin_state_is_primary_done
149
150 SUBROUTINE comin_state_set_primary_done() BIND(C)
151 END SUBROUTINE comin_state_set_primary_done
152
153 SUBROUTINE comin_descrdata_set_fct_glb2loc_cell_c(fct_ptr) bind(C, NAME='comin_descrdata_set_fct_glb2loc_cell')
154 IMPORT :: c_funptr
155 TYPE(c_funptr), VALUE, INTENT(IN) :: fct_ptr
156 END SUBROUTINE comin_descrdata_set_fct_glb2loc_cell_c
157
158 SUBROUTINE comin_descrdata_set_fct_glb2loc_edge_c(fct_ptr) bind(C, NAME='comin_descrdata_set_fct_glb2loc_edge')
159 IMPORT :: c_funptr
160 TYPE(c_funptr), VALUE, INTENT(IN) :: fct_ptr
161 END SUBROUTINE comin_descrdata_set_fct_glb2loc_edge_c
162
163 SUBROUTINE comin_descrdata_set_fct_glb2loc_vert_c(fct_ptr) bind(C, NAME='comin_descrdata_set_fct_glb2loc_vert')
164 IMPORT :: c_funptr
165 TYPE(c_funptr), VALUE, INTENT(IN) :: fct_ptr
166 END SUBROUTINE comin_descrdata_set_fct_glb2loc_vert_c
167
168 SUBROUTINE comin_state_set_host_errhandler_fct(fct_ptr) bind(C, NAME='comin_state_set_host_errhandler_fct')
169 IMPORT :: c_funptr
170 TYPE(c_funptr), VALUE, INTENT(IN) :: fct_ptr
172
174 IMPORT c_bool
175 LOGICAL(c_bool) :: comin_state_is_host_errhandler_set
177
178 END INTERFACE
179
180CONTAINS
181
182 !> Sets the "global-to-local" index lookup function.
184 PROCEDURE(comin_glb2loc_index_lookup_fct) :: fct !< index lookup function
185 TYPE(c_funptr) :: fct_ptr
186 fct_ptr = c_funloc(fct)
187 CALL comin_descrdata_set_fct_glb2loc_cell_c(fct_ptr)
189
191 PROCEDURE(comin_glb2loc_index_lookup_fct) :: fct !< index lookup function
192 TYPE(c_funptr) :: fct_ptr
193 fct_ptr = c_funloc(fct)
194 CALL comin_descrdata_set_fct_glb2loc_edge_c(fct_ptr)
196
198 PROCEDURE(comin_glb2loc_index_lookup_fct) :: fct !< index lookup function
199 TYPE(c_funptr) :: fct_ptr
200 fct_ptr = c_funloc(fct)
201 CALL comin_descrdata_set_fct_glb2loc_vert_c(fct_ptr)
203
204END MODULE comin_state
void comin_descrdata_set_fct_glb2loc_cell(t_comin_glb2loc_index_lookup_fct_ptr fct)
void comin_descrdata_set_fct_glb2loc_edge(t_comin_glb2loc_index_lookup_fct_ptr fct)
void comin_descrdata_set_fct_glb2loc_vert(t_comin_glb2loc_index_lookup_fct_ptr fct)
Global data is invariant wrt the computational grid and never changed or updated.
Patch grid data structure, gathering information on grids.
Get current entry point.
Returns the current domain ID if the entry point is called in a domain loop.
type(t_comin_state), pointer, public state