Mesh Oriented datABase  (version 5.6.0)
An array-based unstructured mesh library
iMOABF.F90
Go to the documentation of this file.
1 ! iMOAB Interface for Fortran 90/2003/2008 compatible compilers
2 
3 #include "moab/MOABConfig.h"
4 
5 module imoab
6 
7  use iso_c_binding
8  implicit none
9 
10 ! Interface to all the API routines
11  interface
12 
13  integer(c_int) function imoab_initialize() bind(C, name='iMOAB_InitializeFortran')
14  ! Directly forward the call
15  use, intrinsic :: iso_c_binding, only: c_int
16  end function imoab_initialize
17 
18  integer(c_int) function imoab_finalize() bind(C, name='iMOAB_Finalize')
19  ! Directly forward the call
20  use, intrinsic :: iso_c_binding, only: c_int
21  end function imoab_finalize
22 
23 #ifdef MOAB_HAVE_MPI
24  integer(c_int) function imoab_registerapplication(app_name, fcomm, compid, pid) &
25  bind(c, name='iMOAB_RegisterApplicationFortran')
26 #else
27  integer(c_int) function imoab_registerapplication(app_name, compid, pid) &
28  bind(c, name='iMOAB_RegisterApplicationFortran')
29 #endif
30  ! Interface blocks don't know about their context,
31  ! so we need to use iso_c_binding inside all interface functions again
32  use, intrinsic :: iso_c_binding, only: c_int, c_char, c_ptr
33  character(kind=c_char), intent(in) :: app_name(*)
34 #ifdef MOAB_HAVE_MPI
35  integer, intent(in) :: fcomm
36 #endif
37  integer(c_int), intent(in) :: compid
38  integer(c_int), intent(out) :: pid
39  end function imoab_registerapplication
40 
41  integer(c_int) function imoab_deregisterapplication(pid) bind(C, name='iMOAB_DeregisterApplicationFortran')
42  use, intrinsic :: iso_c_binding, only: c_int
43  integer(c_int), intent(in) :: pid
44  end function imoab_deregisterapplication
45 
46  integer(c_int) function imoab_readheaderinfo(filename, num_global_vertices, num_global_elements, &
47  num_dimension, num_parts) bind(C, name='iMOAB_ReadHeaderInfo')
48  use, intrinsic :: iso_c_binding, only: c_int, c_char
49  character(kind=c_char), intent(in) :: filename(*)
50  integer(c_int), intent(out) :: num_global_vertices
51  integer(c_int), intent(out) :: num_global_elements
52  integer(c_int), intent(out) :: num_dimension
53  integer(c_int), intent(out) :: num_parts
54  end function imoab_readheaderinfo
55 
56  integer(c_int) function imoab_loadmesh(pid, filename, read_options, num_ghost_layers) bind(C, name='iMOAB_LoadMesh')
57  use, intrinsic :: iso_c_binding, only: c_int, c_char
58  integer(c_int), intent(in) :: pid
59  character(kind=c_char), intent(in) :: filename(*)
60  character(kind=c_char), intent(in) :: read_options(*)
61  integer(c_int), intent(in) :: num_ghost_layers
62  end function imoab_loadmesh
63 
64  integer(c_int) function imoab_createvertices(pid, coords_len, dim, coordinates) bind(C, name='iMOAB_CreateVertices')
65  use, intrinsic :: iso_c_binding, only: c_int, c_double
66  integer(c_int), intent(in) :: pid
67  integer(c_int), intent(in) :: coords_len
68  integer(c_int), intent(in) :: dim
69  real(c_double), intent(in) :: coordinates(*)
70  end function imoab_createvertices
71 
72  integer(c_int) function imoab_createelements(pid, num_elem, type, num_nodes_per_element, &
73  connectivity, block_ID) bind(C, name='iMOAB_CreateElements')
74  use, intrinsic :: iso_c_binding, only: c_int
75  integer(c_int), intent(in) :: pid
76  integer(c_int), intent(in) :: num_elem
77  integer(c_int), intent(in) :: type
78  integer(c_int), intent(in) :: num_nodes_per_element
79  integer(c_int), intent(in) :: connectivity(*)
80  integer(c_int), intent(in) :: block_id
81  end function imoab_createelements
82 
83 #ifdef MOAB_HAVE_MPI
84  integer(c_int) function imoab_resolvesharedentities(pid, num_verts, marker) bind(C, name='iMOAB_ResolveSharedEntities')
85  use, intrinsic :: iso_c_binding, only: c_int
86  integer(c_int), intent(in) :: pid
87  integer(c_int), intent(in) :: num_verts
88  integer(c_int), intent(in) :: marker(*)
89  end function imoab_resolvesharedentities
90 
91  integer(c_int) function imoab_determineghostentities(pid, ghost_dim, num_ghost_layers, bridge_dim) &
92  bind(c, name='iMOAB_DetermineGhostEntities')
93  use, intrinsic :: iso_c_binding, only: c_int
94  integer(c_int), intent(in) :: pid
95  integer(c_int), intent(in) :: ghost_dim
96  integer(c_int), intent(in) :: num_ghost_layers
97  integer(c_int), intent(in) :: bridge_dim
98  end function imoab_determineghostentities
99 ! closing endif: MOAB_HAVE_MPI
100 #endif
101 
102  integer(c_int) function imoab_writemesh(pid, filename, write_options) bind(C, name='iMOAB_WriteMesh')
103  use, intrinsic :: iso_c_binding, only: c_int, c_char
104  integer(c_int), intent(in) :: pid
105  character(kind=c_char), intent(in) :: filename(*)
106  character(kind=c_char), intent(in) :: write_options(*)
107  end function imoab_writemesh
108 
109  integer(c_int) function imoab_updatemeshinfo(pid) bind(C, name='iMOAB_UpdateMeshInfo')
110  use, intrinsic :: iso_c_binding, only: c_int
111  integer(c_int), intent(in) :: pid
112  end function imoab_updatemeshinfo
113 
114  integer(c_int) function imoab_getmeshinfo(pid, num_visible_vertices, num_visible_elements, &
115  num_visible_blocks, num_visible_surfaceBC, &
116  num_visible_vertexBC) bind(C, name='iMOAB_GetMeshInfo')
117  use, intrinsic :: iso_c_binding, only: c_int
118  integer(c_int), intent(in) :: pid
119  integer(c_int), intent(out) :: num_visible_vertices(3)
120  integer(c_int), intent(out) :: num_visible_elements(3)
121  integer(c_int), intent(out) :: num_visible_blocks(3)
122  integer(c_int), intent(out) :: num_visible_surfacebc(3)
123  integer(c_int), intent(out) :: num_visible_vertexbc(3)
124  end function imoab_getmeshinfo
125 
126  integer(c_int) function imoab_getvertexid(pid, vertices_length, global_vertex_ID) bind(C, name='iMOAB_GetVertexID')
127  use, intrinsic :: iso_c_binding, only: c_int
128  integer(c_int), intent(in) :: pid
129  integer(c_int), intent(in) :: vertices_length
130  integer(c_int), intent(out) :: global_vertex_id(*)
131  end function imoab_getvertexid
132 
133  integer(c_int) function imoab_getvertexownership(pid, vertices_length, visible_global_rank_ID) &
134  bind(c, name='iMOAB_GetVertexOwnership')
135  use, intrinsic :: iso_c_binding, only: c_int
136  integer(c_int), intent(in) :: pid
137  integer(c_int), intent(in) :: vertices_length
138  integer(c_int), intent(out) :: visible_global_rank_id(*)
139  end function imoab_getvertexownership
140 
141  integer(c_int) function imoab_getvisibleverticescoordinates(pid, coords_length, coordinates) &
142  bind(c, name='iMOAB_GetVisibleVerticesCoordinates')
143  use, intrinsic :: iso_c_binding, only: c_int, c_double
144  integer(c_int), intent(in) :: pid
145  integer(c_int), intent(in) :: coords_length
146  real(c_double), intent(out) :: coordinates(*)
147  end function imoab_getvisibleverticescoordinates
148 
149  integer(c_int) function imoab_getblockid(pid, block_length, global_block_IDs) bind(C, name='iMOAB_GetBlockID')
150  use, intrinsic :: iso_c_binding, only: c_int
151  integer(c_int), intent(in) :: pid
152  integer(c_int), intent(in) :: block_length
153  integer(c_int), intent(out) :: global_block_ids(*)
154  end function imoab_getblockid
155 
156  integer(c_int) function imoab_getblockinfo(pid, global_block_ID, vertices_per_element, &
157  num_elements_in_block) bind(C, name='iMOAB_GetBlockInfo')
158  use, intrinsic :: iso_c_binding, only: c_int
159  integer(c_int), intent(in) :: pid
160  integer(c_int), intent(in) :: global_block_id
161  integer(c_int), intent(out) :: vertices_per_element
162  integer(c_int), intent(out) :: num_elements_in_block
163  end function imoab_getblockinfo
164 
165  integer(c_int) function imoab_getvisibleelementsinfo(pid, num_visible_elements, element_global_IDs, &
166  ranks, block_IDs) bind(C, name='iMOAB_GetVisibleElementsInfo')
167  use, intrinsic :: iso_c_binding, only: c_int
168  integer(c_int), intent(in) :: pid
169  integer(c_int), intent(out) :: num_visible_elements
170  integer(c_int), intent(out) :: element_global_ids(*)
171  integer(c_int), intent(out) :: ranks(*)
172  integer(c_int), intent(out) :: block_ids(*)
173  end function imoab_getvisibleelementsinfo
174 
175  integer(c_int) function imoab_getblockelementconnectivities(pid, global_block_ID, connectivity_length, &
176  element_connectivity) &
177  bind(c, name='iMOAB_GetBlockElementConnectivities')
178  use, intrinsic :: iso_c_binding, only: c_int
179  integer(c_int), intent(in) :: pid
180  integer(c_int), intent(in) :: global_block_id
181  integer(c_int), intent(in) :: connectivity_length
182  integer(c_int), intent(out) :: element_connectivity(*)
183  end function imoab_getblockelementconnectivities
184 
185  integer(c_int) function imoab_getelementconnectivity(pid, elem_index, connectivity_length, &
186  element_connectivity) bind(C, name='iMOAB_GetElementConnectivity')
187  use, intrinsic :: iso_c_binding, only: c_int
188  integer(c_int), intent(in) :: pid
189  integer(c_int), intent(in) :: elem_index
190  integer(c_int), intent(in) :: connectivity_length
191  integer(c_int), intent(out) :: element_connectivity(*)
192  end function imoab_getelementconnectivity
193 
194  integer(c_int) function imoab_getelementownership(pid, global_block_ID, num_elements_in_block, &
195  element_ownership) bind(C, name='iMOAB_GetElementOwnership')
196  use, intrinsic :: iso_c_binding, only: c_int
197  integer(c_int), intent(in) :: pid
198  integer(c_int), intent(in) :: global_block_id
199  integer(c_int), intent(out) :: num_elements_in_block
200  integer(c_int), intent(out) :: element_ownership(*)
201  end function imoab_getelementownership
202 
203  integer(c_int) function imoab_getelementid(pid, global_block_ID, num_elements_in_block, &
204  global_element_ID, local_element_ID) bind(C, name='iMOAB_GetElementID')
205  use, intrinsic :: iso_c_binding, only: c_int
206  integer(c_int), intent(in) :: pid
207  integer(c_int), intent(in) :: global_block_id
208  integer(c_int), intent(in) :: num_elements_in_block
209  integer(c_int), intent(in) :: global_element_id
210  integer(c_int), intent(out) :: local_element_id
211  end function imoab_getelementid
212 
213  integer(c_int) function imoab_getpointertosurfacebc(pid, surface_BC_length, local_element_ID, &
214  reference_surface_ID, boundary_condition_value) &
215  bind(c, name='iMOAB_GetPointerToSurfaceBC')
216  use, intrinsic :: iso_c_binding, only: c_int
217  integer(c_int), intent(in) :: pid
218  integer(c_int), intent(in) :: surface_bc_length
219  integer(c_int), intent(in) :: local_element_id
220  integer(c_int), intent(in) :: reference_surface_id
221  integer(c_int), intent(out) :: boundary_condition_value
222  end function imoab_getpointertosurfacebc
223 
224  integer(c_int) function imoab_getpointertovertexbc(pid, vertex_BC_length, local_vertex_ID, &
225  boundary_condition_value) bind(C, name='iMOAB_GetPointerToVertexBC')
226  use, intrinsic :: iso_c_binding, only: c_int
227  integer(c_int), intent(in) :: pid
228  integer(c_int), intent(in) :: vertex_bc_length
229  integer(c_int), intent(in) :: local_vertex_id
230  integer(c_int), intent(out) :: boundary_condition_value
231  end function imoab_getpointertovertexbc
232 
233  integer(c_int) function imoab_definetagstorage(pid, tag_storage_name, tag_type, components_per_entity, &
234  tag_index) bind(C, name='iMOAB_DefineTagStorage')
235  use, intrinsic :: iso_c_binding, only: c_int, c_char
236  integer(c_int), intent(in) :: pid
237  character(kind=c_char), intent(in) :: tag_storage_name(*)
238  integer(c_int), intent(in) :: tag_type
239  integer(c_int), intent(in) :: components_per_entity
240  integer(c_int), intent(in) :: tag_index
241  end function imoab_definetagstorage
242 
243  integer(c_int) function imoab_setinttagstorage(pid, tag_storage_name, num_tag_storage_length, entity_type, &
244  tag_storage_data) bind(C, name='iMOAB_SetIntTagStorage')
245  use, intrinsic :: iso_c_binding, only: c_int, c_char
246  integer(c_int), intent(in) :: pid
247  character(kind=c_char), intent(in) :: tag_storage_name(*)
248  integer(c_int), intent(in) :: num_tag_storage_length
249  integer(c_int), intent(in) :: entity_type
250  integer(c_int), intent(in) :: tag_storage_data(*)
251  end function imoab_setinttagstorage
252 
253  integer(c_int) function imoab_getinttagstorage(pid, tag_storage_name, num_tag_storage_length, entity_type, &
254  tag_storage_data) bind(C, name='iMOAB_GetIntTagStorage')
255  use, intrinsic :: iso_c_binding, only: c_int, c_char
256  integer(c_int), intent(in) :: pid
257  character(kind=c_char), intent(in) :: tag_storage_name(*)
258  integer(c_int), intent(in) :: num_tag_storage_length
259  integer(c_int), intent(in) :: entity_type
260  integer(c_int), intent(out) :: tag_storage_data(*)
261  end function imoab_getinttagstorage
262 
263  integer(c_int) function imoab_setdoubletagstorage(pid, tag_storage_name, num_tag_storage_length, entity_type, &
264  tag_storage_data) bind(C, name='iMOAB_SetDoubleTagStorage')
265  use, intrinsic :: iso_c_binding, only: c_int, c_char, c_double
266  integer(c_int), intent(in) :: pid
267  character(kind=c_char), intent(in) :: tag_storage_name(*)
268  integer(c_int), intent(in) :: num_tag_storage_length
269  integer(c_int), intent(in) :: entity_type
270  real(c_double), intent(in) :: tag_storage_data(*)
271  end function imoab_setdoubletagstorage
272 
273  integer(c_int) function imoab_setdoubletagstoragewithgid(pid, tag_storage_name, num_tag_storage_length, entity_type, &
274  tag_storage_data, globalIds) bind(C, name='iMOAB_SetDoubleTagStorageWithGid')
275  use, intrinsic :: iso_c_binding, only: c_int, c_char, c_double
276  integer(c_int), intent(in) :: pid
277  character(kind=c_char), intent(in) :: tag_storage_name(*)
278  integer(c_int), intent(in) :: num_tag_storage_length
279  integer(c_int), intent(in) :: entity_type
280  real(c_double), intent(in) :: tag_storage_data(*)
281  integer(c_int), intent(in) :: globalids(*)
282  end function imoab_setdoubletagstoragewithgid
283 
284 
285  integer(c_int) function imoab_getdoubletagstorage(pid, tag_storage_name, num_tag_storage_length, entity_type, &
286  tag_storage_data) bind(C, name='iMOAB_GetDoubleTagStorage')
287  use, intrinsic :: iso_c_binding, only: c_int, c_char, c_double
288  integer(c_int), intent(in) :: pid
289  character(kind=c_char), intent(in) :: tag_storage_name(*)
290  integer(c_int), intent(in) :: num_tag_storage_length
291  integer(c_int), intent(in) :: entity_type
292  real(c_double), intent(out) :: tag_storage_data(*)
293  end function imoab_getdoubletagstorage
294 
295  integer(c_int) function imoab_synchronizetags(pid, num_tag, tag_indices, entity_type) bind(C, name='iMOAB_SynchronizeTags')
296  use, intrinsic :: iso_c_binding, only: c_int
297  integer(c_int), intent(in) :: pid
298  integer(c_int), intent(in) :: num_tag
299  integer(c_int), intent(in) :: tag_indices(*)
300  integer(c_int), intent(in) :: entity_type(*)
301  end function imoab_synchronizetags
302 
303  integer(c_int) function imoab_reducetagsmax(pid, tag_index, entity_type) bind(C, name='iMOAB_ReduceTagsMax')
304  use, intrinsic :: iso_c_binding, only: c_int
305  integer(c_int), intent(in) :: pid
306  integer(c_int), intent(in) :: tag_index
307  integer(c_int), intent(in) :: entity_type
308  end function imoab_reducetagsmax
309 
310  integer(c_int) function imoab_getneighborelements(pid, local_index, num_adjacent_elements, adjacent_element_IDs) &
311  bind(c, name='iMOAB_GetNeighborElements')
312  use, intrinsic :: iso_c_binding, only: c_int
313  integer(c_int), intent(in) :: pid
314  integer(c_int), intent(in) :: local_index
315  integer(c_int), intent(inout) :: num_adjacent_elements
316  integer(c_int), intent(out) :: adjacent_element_ids(*)
317  end function imoab_getneighborelements
318 
319  integer(c_int) function imoab_getneighborvertices(pid, local_index, num_adjacent_vertices, adjacent_vertex_IDs) &
320  bind(c, name='iMOAB_GetNeighborVertices')
321  use, intrinsic :: iso_c_binding, only: c_int
322  integer(c_int), intent(in) :: pid
323  integer(c_int), intent(in) :: local_index
324  integer(c_int), intent(out) :: num_adjacent_vertices
325  integer(c_int), intent(out) :: adjacent_vertex_ids
326  end function imoab_getneighborvertices
327 
328  integer(c_int) function imoab_setglobalinfo(pid, num_global_verts, num_global_elems) bind(C, name='iMOAB_SetGlobalInfo')
329  use, intrinsic :: iso_c_binding, only: c_int
330  integer(c_int), intent(in) :: pid
331  integer(c_int), intent(in) :: num_global_verts
332  integer(c_int), intent(in) :: num_global_elems
333  end function imoab_setglobalinfo
334 
335  integer(c_int) function imoab_getglobalinfo(pid, num_global_verts, num_global_elems) bind(C, name='iMOAB_GetGlobalInfo')
336  use, intrinsic :: iso_c_binding, only: c_int
337  integer(c_int), intent(in) :: pid
338  integer(c_int), intent(out) :: num_global_verts
339  integer(c_int), intent(out) :: num_global_elems
340  end function imoab_getglobalinfo
341 
342  integer(c_int) function imoab_writelocalmesh(pid, prefix) bind(C, name='iMOAB_WriteLocalMesh')
343  use, intrinsic :: iso_c_binding, only : c_int, c_char
344  integer(c_int), intent(in) :: pid
345  character(kind=c_char), intent(in) :: prefix(*)
346  end function imoab_writelocalmesh
347 
348 #ifdef MOAB_HAVE_MPI
349 
350  integer(c_int) function imoab_sendmesh(pid, joint_comm, receivingGroup, rcompid, method) bind(C, name='iMOAB_SendMesh')
351  use, intrinsic :: iso_c_binding, only: c_int, c_ptr
352  integer(c_int), intent(in) :: pid
353  integer, intent(in) :: joint_comm ! MPI_Comm
354  integer, intent(in) :: receivinggroup ! MPI_Group
355  integer(c_int), intent(in) :: rcompid
356  integer(c_int), intent(in) :: method
357  end function imoab_sendmesh
358 
359  integer(c_int) function imoab_receivemesh(pid, joint_comm, sendingGroup, scompid) bind(C, name='iMOAB_ReceiveMesh')
360  use, intrinsic :: iso_c_binding, only: c_int, c_ptr
361  integer(c_int), intent(in) :: pid
362  integer, intent(in) :: joint_comm ! MPI_Comm
363  integer, intent(in) :: sendinggroup ! MPI_Group
364  integer(c_int), intent(in) :: scompid
365  end function imoab_receivemesh
366 
367  integer(c_int) function imoab_freesenderbuffers(pid, context_id) bind(C, name='iMOAB_FreeSenderBuffers')
368  use, intrinsic :: iso_c_binding, only: c_int
369  integer(c_int), intent(in) :: pid
370  integer(c_int), intent(in) :: context_id
371  end function imoab_freesenderbuffers
372 
373  integer(c_int) function imoab_sendelementtag(pid, tag_storage_name, joint_comm, context_id) &
374  bind(c, name='iMOAB_SendElementTag')
375  use, intrinsic :: iso_c_binding, only: c_int, c_char, c_ptr
376  integer(c_int), intent(in) :: pid
377  character(kind=c_char), intent(in) :: tag_storage_name(*)
378  integer, intent(in) :: joint_comm ! MPI_Comm
379  integer(c_int), intent(in) :: context_id
380  end function imoab_sendelementtag
381 
382  integer(c_int) function imoab_receiveelementtag(pid, tag_storage_name, joint_comm, context_id) &
383  bind(c, name='iMOAB_ReceiveElementTag')
384  use, intrinsic :: iso_c_binding, only: c_int, c_char, c_ptr
385  integer(c_int), intent(in) :: pid
386  character(kind=c_char), intent(in) :: tag_storage_name(*)
387  integer, intent(in) :: joint_comm ! MPI_Comm
388  integer(c_int), intent(in) :: context_id
389  end function imoab_receiveelementtag
390 
391  integer(c_int) function imoab_computecommgraph(pid1, pid2, joint_comm, group1, group2, type1, type2, &
392  comp1, comp2) bind(C, name='iMOAB_ComputeCommGraph')
393  use, intrinsic :: iso_c_binding, only: c_int, c_ptr
394  integer(c_int), intent(in) :: pid1
395  integer(c_int), intent(in) :: pid2
396  integer, intent(in) :: joint_comm ! MPI_Comm
397  integer, intent(in) :: group1 ! MPI_Group
398  integer, intent(in) :: group2 ! MPI_Group
399  integer(c_int), intent(in) :: type1
400  integer(c_int), intent(in) :: type2
401  integer(c_int), intent(in) :: comp1
402  integer(c_int), intent(in) :: comp2
403  end function imoab_computecommgraph
404 
405 #ifdef MOAB_HAVE_TEMPESTREMAP
406  ! CoverageGraph operates on the TempestRemapper covering set, so it requires TempestRemap.
407  integer(c_int) function imoab_coveragegraph(joint_comm, pid_source, pid_migration, pid_intx, source_id, &
408  migration_id, context_id) bind(C, name='iMOAB_CoverageGraph')
409  use, intrinsic :: iso_c_binding, only: c_int, c_ptr
410  integer, intent(in) :: joint_comm ! MPI_Comm
411  integer(c_int), intent(in) :: pid_source
412  integer(c_int), intent(in) :: pid_migration
413  integer(c_int), intent(in) :: pid_intx
414  integer(c_int), intent(in) :: source_id
415  integer(c_int), intent(in) :: migration_id
416  integer(c_int), intent(in) :: context_id
417  end function imoab_coveragegraph
418 #endif
419 
420  integer(c_int) function imoab_dumpcommgraph(pid, context_id, is_sender, prefix) bind(C, name='iMOAB_DumpCommGraph')
421  use, intrinsic :: iso_c_binding, only: c_int, c_char
422  integer(c_int), intent(in) :: pid
423  integer(c_int), intent(in) :: context_id
424  integer(c_int), intent(in) :: is_sender
425  character(kind=c_char), intent(in) :: prefix(*)
426  end function imoab_dumpcommgraph
427 
428  integer(c_int) function imoab_mergevertices(pid) bind(C, name='iMOAB_MergeVertices')
429  use, intrinsic :: iso_c_binding, only: c_int
430  integer(c_int), intent(in) :: pid
431  end function imoab_mergevertices
432 
433 ! closing endif: MOAB_HAVE_MPI
434 #endif
435 
436 #ifdef MOAB_HAVE_TEMPESTREMAP
437  integer(c_int) function imoab_computecoveragemesh(pid_source, pid_target, pid_intersection) &
438  bind(c, name='iMOAB_ComputeCoverageMesh')
439  use, intrinsic :: iso_c_binding, only: c_int
440  integer(c_int), intent(in) :: pid_source
441  integer(c_int), intent(in) :: pid_target
442  integer(c_int), intent(in) :: pid_intersection
443  end function imoab_computecoveragemesh
444 
445 #ifdef MOAB_HAVE_MPI
446  ! MigrateMapMesh does no NC I/O; it needs TempestRemap + MPI only.
447  integer(c_int) function imoab_migratemapmesh( pid1, pid2, jointcomm, groupA, groupB, type, comp1, comp2) &
448  bind(c, name='iMOAB_MigrateMapMesh')
449  use, intrinsic :: iso_c_binding, only : c_int
450  integer(c_int), intent(in) :: pid1
451  integer(c_int), intent(in) :: pid2
452  integer, intent(in) :: jointcomm ! MPI_Comm
453  integer, intent(in) :: groupa ! MPI_Group
454  integer, intent(in) :: groupb ! MPI_Group
455  integer(c_int), intent(in) :: type
456  integer(c_int), intent(in) :: comp1
457  integer(c_int), intent(in) :: comp2
458  end function imoab_migratemapmesh
459 ! closing endif: MOAB_HAVE_MPI
460 #endif
461 
462  integer(c_int) function imoab_setmapghostlayers(pid, num_src_layers, num_tgt_layers) bind(C, name='iMOAB_SetMapGhostLayers')
463  use, intrinsic :: iso_c_binding, only: c_int
464  integer(c_int), intent(in) :: pid
465  integer(c_int), intent(in) :: num_src_layers
466  integer(c_int), intent(in) :: num_tgt_layers
467  end function imoab_setmapghostlayers
468 
469  integer(c_int) function imoab_writecoveragemesh( pid, prefix )&
470  bind(c, name='iMOAB_WriteCoverageMesh')
471  use, intrinsic :: iso_c_binding, only: c_int, c_char
472  integer(c_int), intent(in) :: pid
473  character(kind=c_char), intent(in) :: prefix
474  end function imoab_writecoveragemesh
475 
476  integer(c_int) function imoab_computemeshintersectiononsphere(pid_source, pid_target, pid_intersection) &
477  bind(c, name='iMOAB_ComputeMeshIntersectionOnSphere')
478  use, intrinsic :: iso_c_binding, only: c_int
479  integer(c_int), intent(in) :: pid_source
480  integer(c_int), intent(in) :: pid_target
481  integer(c_int), intent(in) :: pid_intersection
482  end function imoab_computemeshintersectiononsphere
483 
484  integer(c_int) function imoab_computepointdofintersection(pid_source, pid_target, pid_intersection) &
485  bind(c, name='iMOAB_ComputePointDoFIntersection')
486  use, intrinsic :: iso_c_binding, only: c_int
487  integer(c_int), intent(in) :: pid_source
488  integer(c_int), intent(in) :: pid_target
489  integer(c_int), intent(in) :: pid_intersection
490  end function imoab_computepointdofintersection
491 
492 #if defined( MOAB_HAVE_NETCDF ) || defined( MOAB_HAVE_PNETCDF )
493 
494  integer(c_int) function imoab_loadmapfile(pid_source, pid_target, pid_intersection, src_disc_type, tgt_disc_type, &
495  arearead, solution_weights_identifier, remap_weights_filename) &
496  bind(c, name='iMOAB_LoadMapFile')
497  use, intrinsic :: iso_c_binding, only : c_int, c_char
498  integer(c_int), intent(in) :: pid_source
499  integer(c_int), intent(in) :: pid_target
500  integer(c_int), intent(in) :: pid_intersection
501  integer(c_int), intent(in) :: src_disc_type
502  integer(c_int), intent(in) :: tgt_disc_type
503  integer(c_int), intent(in) :: arearead
504  character(kind=c_char), intent(in) :: solution_weights_identifier(*)
505  character(kind=c_char), intent(in) :: remap_weights_filename(*)
506  end function imoab_loadmapfile
507 
508  integer(c_int) function imoab_writemapfile(pid_intersection, solution_weights_identifier, &
509  remap_weights_filename) bind(C, name='iMOAB_WriteMapFile')
510  use, intrinsic :: iso_c_binding, only: c_int, c_char
511  integer(c_int), intent(in) :: pid_intersection
512  character(kind=c_char), intent(in) :: solution_weights_identifier(*)
513  character(kind=c_char), intent(in) :: remap_weights_filename(*)
514  end function imoab_writemapfile
515 
516 ! closing endif: MOAB_HAVE_NETCDF || MOAB_HAVE_PNETCDF
517 #endif
518 
519  integer(c_int) function imoab_computescalarprojectionweights(pid_intersection, solution_weights_identifier, &
520  disc_method_source, disc_order_source, &
521  disc_method_target, disc_order_target, &
522  fv_methods, fNoBubble, fMonotoneTypeID, fVolumetric, &
523  fInverseDistanceMap, fNoConservation, fValidate, &
524  source_solution_tag_dof_name, target_solution_tag_dof_name) &
525  bind(c, name='iMOAB_ComputeScalarProjectionWeights')
526  use, intrinsic :: iso_c_binding, only: c_int, c_char
527  integer(c_int), intent(in) :: pid_intersection
528  character(kind=c_char), intent(in) :: solution_weights_identifier(*)
529  character(kind=c_char), intent(in) :: disc_method_source(*)
530  integer(c_int), intent(in) :: disc_order_source
531  character(kind=c_char), intent(in) :: disc_method_target(*)
532  character(kind=c_char), intent(in) :: fv_methods(*)
533  integer(c_int), intent(in) :: disc_order_target
534  integer(c_int), intent(in) :: fnobubble
535  integer(c_int), intent(in) :: fmonotonetypeid
536  integer(c_int), intent(in) :: fvolumetric
537  integer(c_int), intent(in) :: finversedistancemap
538  integer(c_int), intent(in) :: fnoconservation
539  integer(c_int), intent(in) :: fvalidate
540  character(kind=c_char), intent(in) :: source_solution_tag_dof_name(*)
541  character(kind=c_char), intent(in) :: target_solution_tag_dof_name(*)
542  end function imoab_computescalarprojectionweights
543 
544  integer(c_int) function imoab_applyscalarprojectionweights(pid_intersection, filter_type, solution_weights_identifier, &
545  source_solution_tag_name, target_solution_tag_name) &
546  bind(c, name='iMOAB_ApplyScalarProjectionWeights')
547  use, intrinsic :: iso_c_binding, only: c_int, c_char
548  integer(c_int), intent(in) :: pid_intersection
549  integer(c_int), intent(in) :: filter_type
550  character(kind=c_char), intent(in) :: solution_weights_identifier(*)
551  character(kind=c_char), intent(in) :: source_solution_tag_name(*)
552  character(kind=c_char), intent(in) :: target_solution_tag_name(*)
553  end function imoab_applyscalarprojectionweights
554 
555 ! closing endif: MOAB_HAVE_TEMPESTREMAP
556 #endif
557 
558 #ifdef MOAB_HAVE_MPI
559 
560 ! Add some helper MPI converter functions
561 
562  ! Convert a C-based MPI-Comm handle to fortran
563  integer function imoab_mpi_comm_c2f(c_handle) bind(C, name="MOAB_MPI_Comm_c2f")
564  use, intrinsic :: iso_c_binding, only: c_ptr
565  type(c_ptr), value :: c_handle
566  end function
567 
568  ! Convert a Fortran-based MPI-integer handle to MPI-Comm pointer
569  type(c_ptr) function imoab_mpi_comm_f2c(f_handle) bind(C, name="MOAB_MPI_Comm_f2c")
570  use, intrinsic :: iso_c_binding, only: c_ptr
571  integer, intent(in) :: f_handle
572  end function
573 
574  ! Convert a C-based MPI-Group handle to fortran
575  integer function imoab_mpi_group_c2f(c_handle) bind(C, name="MOAB_MPI_Group_c2f")
576  use, intrinsic :: iso_c_binding, only: c_ptr
577  type(c_ptr), value :: c_handle
578  end function
579 
580  ! Convert a Fortran-based MPI-integer handle to MPI-Group pointer
581  type(c_ptr) function imoab_mpi_group_f2c(f_handle) bind(C, name="MOAB_MPI_Group_f2c")
582  use, intrinsic :: iso_c_binding, only: c_ptr
583  integer, intent(in) :: f_handle
584  end function
585 
586 #endif
587 
588  end interface
589 
590 end module imoab