Octopus
mesh_init.F90
Go to the documentation of this file.
1!! Copyright (C) 2002-2006 M. Marques, A. Castro, A. Rubio, G. Bertsch
2!! Copyright (C) 2021 S. Ohlmann
3!!
4!! This program is free software; you can redistribute it and/or modify
5!! it under the terms of the GNU General Public License as published by
6!! the Free Software Foundation; either version 2, or (at your option)
7!! any later version.
8!!
9!! This program is distributed in the hope that it will be useful,
10!! but WITHOUT ANY WARRANTY; without even the implied warranty of
11!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12!! GNU General Public License for more details.
13!!
14!! You should have received a copy of the GNU General Public License
15!! along with this program; if not, write to the Free Software
16!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17!! 02110-1301, USA.
18!!
19
20#include "global.h"
21
24module mesh_init_oct_m
26 use box_oct_m
30 use debug_oct_m
31 use global_oct_m
32 use iihash_oct_m
33 use index_oct_m
34 use math_oct_m
36 use mesh_oct_m
40 use mpi_oct_m
45 use parser_oct_m
49 use sort_oct_m
50 use space_oct_m
52 use utils_oct_m
53
54 implicit none
55
56 private
57 public :: &
61
62
63 integer, parameter :: INNER_POINT = 1
64 integer, parameter :: ENLARGEMENT_POINT = 2
65 integer, parameter :: BOUNDARY = -1
66
67contains
68
69! ---------------------------------------------------------
76 subroutine mesh_init_stage_1(mesh, namespace, space, box, coord_system, spacing, enlarge)
77 class(mesh_t), intent(inout) :: mesh
78 type(namespace_t), intent(in) :: namespace
79 class(space_t), intent(in) :: space
80 class(box_t), target, intent(in) :: box
81 class(coordinate_system_t), target, intent(in) :: coord_system
82 real(real64), intent(in) :: spacing(1:space%dim)
83 integer, intent(in) :: enlarge(1:space%dim)
84
85 integer :: idir, jj, delta
86 real(real64) :: x(space%dim), chi(space%dim), spacing_new(-1:1), box_bounds(2, space%dim)
87 logical :: out
88
89 push_sub_with_profile(mesh_init_stage_1)
90
91 mesh%box => box
92
93 safe_allocate(mesh%spacing(1:space%dim))
94 mesh%spacing = spacing ! this number can change in the following
95
96 mesh%use_curvilinear = coord_system%local_basis
97 mesh%coord_system => coord_system
98
99 call index_init(mesh%idx, space%dim)
100 mesh%idx%enlarge = enlarge
101
102 ! get box bounds along the axes that generate the grid points
103 select type (coord_system)
104 class is (affine_coordinates_t)
105 box_bounds = box%bounds(coord_system%basis)
106 class default
107 box_bounds = box%bounds()
108 end select
109
110 ! adjust nr
111 do idir = 1, space%dim
112 chi = m_zero
113 ! the upper border
114 jj = 0
115 out = .false.
116 do while(.not.out)
117 jj = jj + 1
118 chi(idir) = real(jj, real64) * mesh%spacing(idir)
119 if (mesh%use_curvilinear) then
120 x = coord_system%to_cartesian(chi)
121 out = x(idir) > maxval(abs(box_bounds(:, idir))) + box_boundary_delta
122 else
123 ! do the same comparison here as in simul_box_contains_points
124 out = chi(idir) > maxval(abs(box_bounds(:, idir))) + box_boundary_delta
125 end if
126 end do
127 mesh%idx%nr(2, idir) = jj - 1
128 end do
129
130 ! we have a symmetric mesh (for now)
131 mesh%idx%nr(1,:) = -mesh%idx%nr(2,:)
132
133 ! we have to adjust a couple of things for the periodic directions
134 do idir = 1, space%periodic_dim
135 if (mesh%idx%nr(2, idir) == 0) then
136 ! this happens if Spacing > box size
137 mesh%idx%nr(2, idir) = 1
138 mesh%idx%nr(1, idir) = -1
139 end if
140
141 ! We have to adjust the spacing to be commensurate with the box,
142 ! for this we scan the possible values of the grid size around the
143 ! one we selected. We choose the size that has the spacing closest
144 ! to the requested one.
145 do delta = -1, 1
146 spacing_new(delta) = m_two*maxval(abs(box_bounds(:, idir))) / real(2 * mesh%idx%nr(2, idir) + 1 - delta, real64)
147 spacing_new(delta) = abs(spacing_new(delta) - spacing(idir))
148 end do
149
150 delta = minloc(spacing_new, dim = 1) - 2
151
152 assert(delta >= -1)
153 assert(delta <= 1)
154
155 mesh%spacing(idir) = m_two*maxval(abs(box_bounds(:, idir))) / real(2 * mesh%idx%nr(2, idir) + 1 - delta, real64)
156
157 ! we need to adjust the grid by adding or removing one point
158 if (delta == -1) then
159 mesh%idx%nr(1, idir) = mesh%idx%nr(1, idir) - 1
160 else if (delta == 1) then
161 mesh%idx%nr(2, idir) = mesh%idx%nr(2, idir) - 1
162 end if
163
164 end do
165
166 if ( any(abs(mesh%spacing - spacing) > 1.e-6_real64) ) then
167 call messages_write('The spacing has been modified to make it commensurate with the periodicity of the system.')
168 call messages_warning()
169 end if
170
171 do idir = space%periodic_dim + 1, space%dim
172 if (mesh%idx%nr(2, idir) == 0) then
173 write(message(1),'(a,i2)') 'Spacing > box size in direction ', idir
174 call messages_fatal(1, namespace=namespace)
175 end if
176 end do
177
178 mesh%idx%ll = mesh%idx%nr(2, :) - mesh%idx%nr(1, :) + 1
179 ! compute strides for cubic indices
180 mesh%idx%stride(:) = 1
181 do idir = 2, space%dim+1
182 mesh%idx%stride(idir) = mesh%idx%stride(idir-1) * &
183 (mesh%idx%ll(idir-1) + 2*mesh%idx%enlarge(idir-1))
184 end do
185
186 pop_sub_with_profile(mesh_init_stage_1)
187 end subroutine mesh_init_stage_1
188
189 ! ---------------------------------------------------------
195 !
196 subroutine mesh_init_stage_2(mesh, namespace, space, box, stencil, grp, regenerate)
197 class(mesh_t), intent(inout) :: mesh
198 type(namespace_t), intent(in) :: namespace
199 class(space_t), intent(in) :: space
200 class(box_t), intent(in) :: box
201 type(stencil_t), intent(in) :: stencil
202 type(mpi_grp_t), intent(in) :: grp
203 logical, optional, intent(in) :: regenerate
204
205 integer :: is
206 real(real64) :: chi(1:space%dim)
207 real(real64) :: pos(space%dim)
208 integer :: point(space%dim), point_stencil(space%dim), grid_sizes(space%dim)
209 integer(int64) :: global_size
210 integer(int32) :: local_size
211 integer(int64) :: ispatial, ispatialb, istart, iend, spatial_size, ipg
212 integer :: ip, ib, ib2, np, np_boundary, ii
213 logical :: found
214 type(lihash_t) :: spatial_to_boundary
215 integer(int64), allocatable :: boundary_to_spatial(:), boundary_to_spatial_reordered(:)
216 integer(int64), allocatable :: grid_to_spatial(:), grid_to_spatial_initial(:), grid_to_spatial_reordered(:)
217 integer(int64), allocatable :: spatial_to_grid(:)
218 integer, allocatable :: sizes(:)
219 integer(int64), allocatable :: offsets(:)
220 integer :: size_boundary
221#ifdef HAVE_MPI
222 integer(int64), pointer :: ptr(:)
223 type(mpi_grp_t) :: internode_grp, intranode_grp
224#endif
225
226 push_sub_with_profile(mesh_init_stage_2)
227
228 if (.not. optional_default(regenerate, .false.)) then
229 ! enlarge mesh for boundary points
230 mesh%idx%nr(1, :) = mesh%idx%nr(1, :) - mesh%idx%enlarge(:)
231 mesh%idx%nr(2, :) = mesh%idx%nr(2, :) + mesh%idx%enlarge(:)
232 end if
233
234 !%Variable MeshIndexType
235 !%Type integer
236 !%Default idx_cubic
237 !%Section Mesh
238 !%Description
239 !% Determine index type. Must be the same for restarting a calculation.
240 !%Option idx_cubic 1
241 !% Cubic indices are used to map the spatial information to the grid points.
242 !%Option idx_hilbert 2
243 !% A Hilbert space-filling curve is used to map the spatial information to
244 !% the grid points.
245 !%End
246 call parse_variable(namespace, 'MeshIndexType', idx_cubic, mesh%idx%type)
247
248 grid_sizes = mesh%idx%nr(2, :) - mesh%idx%nr(1, :) + 1
249 mesh%idx%offset = grid_sizes/2
250 if (space%dim > 1 .and. any(grid_sizes > 2**(int(63/space%dim, int64)))) then
251 write(message(1), '(A, I10, A, I2, A)') "Error: grid too large, more than ", 2**(int(63/space%dim, int64)), &
252 " points in one direction for ", space%dim, " dimensions. This is not supported."
253 call messages_fatal(1, namespace=namespace)
254 end if
255 global_size = product(int(grid_sizes, int64))
256 ! compute the bits per dimension: grid_sizes(i) <= 2**bits
257 mesh%idx%bits = maxval(ceiling(log(real(grid_sizes, real64) )/log(2.0_real64)))
258
259 if (mesh%idx%type == idx_cubic) then
260 spatial_size = global_size
261 else if (mesh%idx%type == idx_hilbert) then
262 spatial_size = 2**(space%dim*mesh%idx%bits)
263 end if
264
265 ! use block data decomposition of spatial indices
266 istart = spatial_size * grp%rank/grp%size
267 iend = spatial_size * (grp%rank+1)/grp%size - 1
268 if (.not. (iend - istart + 1 < huge(0_int32))) then
269 write(message(1), '(A, I10, A, I2, A)') "Error: local grid too large, more than ", &
270 huge(0_int32), " points. This is not supported. Maybe use more MPI ranks?"
271 call messages_fatal(1, namespace=namespace)
272 end if
273 local_size = int(iend - istart + 1, int32)
274
275 safe_allocate(grid_to_spatial_initial(1:local_size))
276
277 ! get inner grid indices
278 ip = 1
279 do ispatial = istart, iend
280 call index_spatial_to_point(mesh%idx, space%dim, ispatial, point)
281 ! first check if point is outside bounding box
282 if (any(point < mesh%idx%nr(1, :) + mesh%idx%enlarge)) cycle
283 if (any(point > mesh%idx%nr(2, :) - mesh%idx%enlarge)) cycle
284 ! then check if point is inside simulation box
285 chi = real(point, real64) * mesh%spacing
286 pos = mesh%coord_system%to_cartesian(chi)
287 if (.not. box%contains_point(pos)) cycle
288 grid_to_spatial_initial(ip) = ispatial
289 assert(ip + 1 < huge(ip))
290 ip = ip + 1
291 end do
292 np = ip - 1
293
294 call rebalance_array(grp,grid_to_spatial_initial(1:np), grid_to_spatial, sizes)
295 np = sizes(grp%rank)
296
297 safe_deallocate_a(grid_to_spatial_initial)
298
299 safe_allocate(spatial_to_grid(grid_to_spatial(1):grid_to_spatial(np)))
300 safe_deallocate_a(sizes)
301
302 !$omp parallel do
303 do ispatial = grid_to_spatial(1), grid_to_spatial(np)
304 spatial_to_grid(ispatial) = -1
305 end do
306 !$omp parallel do
307 do ip = 1, np
308 spatial_to_grid(grid_to_spatial(ip)) = ip
309 end do
310
311 ! get local boundary indices
312 call lihash_init(spatial_to_boundary)
313 size_boundary = np
314 safe_allocate(boundary_to_spatial(1:size_boundary))
315 ib = 1
316 do ip = 1, np
317 call index_spatial_to_point(mesh%idx, space%dim, grid_to_spatial(ip), point)
318 do is = 1, stencil%size
319 if (stencil%center == is) cycle
320 point_stencil(1:space%dim) = point(1:space%dim) + stencil%points(1:space%dim, is)
321 ! check if point is in inner part
322 call index_point_to_spatial(mesh%idx, space%dim, ispatialb, point_stencil)
323 assert(ispatialb >= 0)
324 if (ispatialb >= lbound(spatial_to_grid, dim=1, kind=int64) .and. &
325 ispatialb <= ubound(spatial_to_grid, dim=1, kind=int64)) then
326 if (spatial_to_grid(ispatialb) > 0) cycle
327 end if
328 ! then check if point is inside simulation box
329 chi = real(point_stencil, real64) * mesh%spacing
330 pos = mesh%coord_system%to_cartesian(chi)
331 if (box%contains_point(pos)) cycle
332 ! it has to be a boundary point now
333 ! check if already counted
334 ib2 = lihash_lookup(spatial_to_boundary, ispatialb, found)
335 if (found) cycle
336 boundary_to_spatial(ib) = ispatialb
337 call lihash_insert(spatial_to_boundary, ispatialb, ib)
338 ib = ib + 1
339 ! enlarge array
340 if (ib >= size_boundary) then
341 size_boundary = size_boundary * 2
342 call make_array_larger(boundary_to_spatial, size_boundary)
343 end if
344 end do
345 end do
346 np_boundary = ib - 1
347 call lihash_end(spatial_to_boundary)
348 safe_deallocate_a(spatial_to_grid)
349
350 ! reorder inner points
351 call reorder_points(namespace, space, grp, mesh%idx, grid_to_spatial, grid_to_spatial_reordered)
352 safe_deallocate_a(grid_to_spatial)
353
354 call rebalance_array(grp,grid_to_spatial_reordered, grid_to_spatial, sizes)
355 np = sizes(grp%rank)
356 mesh%np_global = sizes(0)
357 do ii = 1, grp%size - 1
358 mesh%np_global = mesh%np_global + sizes(ii)
359 end do
360 safe_deallocate_a(sizes)
361 safe_deallocate_a(grid_to_spatial_reordered)
362
363 ! reorder boundary points
364 call make_array_larger(boundary_to_spatial, np_boundary)
365 call reorder_points(namespace, space, grp, mesh%idx, boundary_to_spatial, boundary_to_spatial_reordered)
366 safe_deallocate_a(boundary_to_spatial)
367
368 call rebalance_array(grp,boundary_to_spatial_reordered, boundary_to_spatial, sizes)
369 safe_deallocate_a(boundary_to_spatial_reordered)
370
371 ! global grid size
372 np_boundary = sizes(grp%rank)
373 mesh%np_part_global = mesh%np_global + sizes(0)
374 do ii = 1, grp%size - 1
375 mesh%np_part_global = mesh%np_part_global + sizes(ii)
376 end do
377 safe_deallocate_a(sizes)
378
379
380 ! get global indices
381#ifdef HAVE_MPI
382 ! create shared memory window and fill it only on root
383 call create_intranode_communicator(grp, intranode_grp, internode_grp)
384 call lmpi_create_shared_memory_window(mesh%np_part_global, intranode_grp, &
385 mesh%idx%window_grid_to_spatial, mesh%idx%grid_to_spatial_global)
386#else
387 safe_allocate(mesh%idx%grid_to_spatial_global(1:mesh%np_part_global))
388#endif
389 ! inner grid
390 call get_sizes_offsets(np, sizes, offsets, grp)
391 call grp%gatherv(grid_to_spatial, np, mpi_integer8, &
392 mesh%idx%grid_to_spatial_global, sizes, offsets, mpi_integer8, 0)
393
394 ! boundary indices
395 call get_sizes_offsets(np_boundary, sizes, offsets, grp)
396 call grp%gatherv(boundary_to_spatial, np_boundary, mpi_integer8, &
397 mesh%idx%grid_to_spatial_global(mesh%np_global+1:), sizes, offsets, mpi_integer8, 0)
398
399 ! fill global hash map
400#ifdef HAVE_MPI
401 ! create shared memory window and fill it only on root
402 call lmpi_create_shared_memory_window(spatial_size, intranode_grp, &
403 mesh%idx%window_spatial_to_grid, ptr)
404 mesh%idx%spatial_to_grid_global(0:spatial_size-1) => ptr(1:spatial_size)
405#else
406 safe_allocate(mesh%idx%spatial_to_grid_global(0:spatial_size-1))
407#endif
408 if (grp%is_root()) then
409 ! fill only on root, then broadcast
410 !$omp parallel do
411 do ispatial = 0, spatial_size-1
412 mesh%idx%spatial_to_grid_global(ispatial) = 0
413 end do
414 !$omp parallel do
415 do ipg = 1, mesh%np_part_global
416 mesh%idx%spatial_to_grid_global(mesh%idx%grid_to_spatial_global(ipg)) = ipg
417 end do
418 end if
419
420#ifdef HAVE_MPI
421 ! now broadcast the global arrays to local rank 0 on each node
422 if (intranode_grp%is_root()) then
423 call internode_grp%bcast(mesh%idx%grid_to_spatial_global(1), mesh%np_part_global, mpi_integer8, 0)
424 call internode_grp%bcast(mesh%idx%spatial_to_grid_global(0), spatial_size, mpi_integer8, 0)
425 end if
426 call lmpi_sync_shared_memory_window(mesh%idx%window_grid_to_spatial, intranode_grp)
427 call lmpi_sync_shared_memory_window(mesh%idx%window_spatial_to_grid, intranode_grp)
428#endif
429
430 safe_deallocate_a(offsets)
431 safe_deallocate_a(sizes)
432
433 safe_deallocate_a(boundary_to_spatial)
434 safe_deallocate_a(grid_to_spatial)
435
436 pop_sub_with_profile(mesh_init_stage_2)
437 end subroutine mesh_init_stage_2
438
439! ---------------------------------------------------------
444! ---------------------------------------------------------
445 subroutine mesh_init_stage_3(mesh, namespace, space, stencil, mc, parent, regenerate)
446 class(mesh_t), intent(inout) :: mesh
447 type(namespace_t), intent(in) :: namespace
448 class(space_t), intent(in) :: space
449 type(stencil_t), intent(in) :: stencil
450 type(multicomm_t), intent(in) :: mc
451 type(mesh_t), optional, intent(in) :: parent
452 logical, optional, intent(in) :: regenerate
453
454 integer :: ip, jj(space%dim), np
455
456 push_sub_with_profile(mesh_init_stage_3)
457
458 call mpi_grp_init(mesh%mpi_grp, mc%group_comm(p_strategy_domains))
459
460 ! check if we are running in parallel in domains
461 mesh%parallel_in_domains = (mesh%mpi_grp%size > 1)
462
463 call checksum_calculate(1, mesh%np_part_global, mesh%idx%grid_to_spatial_global(1), &
464 mesh%idx%checksum)
465
466 if (mesh%parallel_in_domains) then
467 call do_partition()
468 else
469 ! When running serially those two are the same.
470 assert(mesh%np_part_global < huge(mesh%np_part))
471 mesh%np = i8_to_i4(mesh%np_global)
472 mesh%np_part = i8_to_i4(mesh%np_part_global)
473
474 ! These must be initialized for par_vec_gather, par_vec_scatter to work
475 ! as copy operations when running without domain parallelization.
476 mesh%pv%np_global = mesh%np_global
477 mesh%pv%np_ghost = 0
478 mesh%pv%np_bndry = mesh%np_part - mesh%np
479 mesh%pv%npart = 1
480 mesh%pv%xlocal = 1
481 end if
482
483 ! Compute mesh%x
484 safe_allocate(mesh%x(1:space%dim, 1:mesh%np_part))
485 safe_allocate(mesh%x_t(1:mesh%np_part, 1:space%dim))
486 do ip = 1, mesh%np_part
487 mesh%x(1:space%dim, ip) = mesh_x_global(mesh, mesh_local2global(mesh, ip))
488 mesh%x_t(ip, 1:space%dim) = mesh%x(1:space%dim, ip)
489 end do
490
491 ! save chi, i.e. primitive coordinates
492 safe_allocate(mesh%chi(1:space%dim, 1:mesh%np_part))
493 do ip = 1, mesh%np_part
494 call mesh_local_index_to_coords(mesh, ip, jj)
495 mesh%chi(:, ip) = jj*mesh%spacing
496 end do
497
498 call mesh_get_vol_pp()
499
500 ! save inverse jacobian
501 if (mesh%coord_system%local_basis) then
502 np = mesh%np_part
503 else
504 np = 1
505 end if
506 safe_allocate(mesh%jacobian_inverse(1:space%dim, 1:space%dim, np))
507 do ip = 1, np
508 mesh%jacobian_inverse(:, :, ip) = mesh%coord_system%jacobian_inverse(mesh%chi(:, ip))
509 end do
510
511 pop_sub_with_profile(mesh_init_stage_3)
512
513 contains
514 ! ---------------------------------------------------------
515 subroutine do_partition()
516#ifdef HAVE_MPI
517 integer :: jj, ipart, jpart
518 integer(int64) :: ipg, jpg
519 integer, allocatable :: gindex(:), gedges(:)
520 logical, allocatable :: nb(:, :)
521 integer :: idx(space%dim), jx(space%dim)
522 type(mpi_comm) :: graph_comm
523 integer :: iedge, nnb
524 logical :: use_topo, reorder, partition_print
525 integer :: ierr
526
527 logical :: has_virtual_partition = .false.
528 integer :: vsize
529 type(restart_t) :: restart_load, restart_dump
530 integer, allocatable :: part_vec(:)
531
533
534 !Try to load the partition from the restart files
535 if (.not. optional_default(regenerate, .false.)) then
536 call restart_load%init(namespace, restart_partition, restart_type_load, mc, ierr, mesh=mesh, exact=.true.)
537 if (ierr == 0) call mesh_partition_load(restart_load, mesh, ierr)
538 call restart_load%end()
539 else
540 ierr = 0
541 end if
542
543 if (ierr /= 0) then
544
545 !%Variable MeshPartitionVirtualSize
546 !%Type integer
547 !%Default mesh mpi_grp size
548 !%Section Execution::Parallelization
549 !%Description
550 !% Gives the possibility to change the partition nodes.
551 !% Afterward, it crashes.
552 !%End
553 call parse_variable(namespace, 'MeshPartitionVirtualSize', mesh%mpi_grp%size, vsize)
554
555 if (vsize /= mesh%mpi_grp%size) then
556 write(message(1),'(a,I7)') "Changing the partition size to", vsize
557 write(message(2),'(a)') "The execution will crash."
558 call messages_warning(2, namespace=namespace)
559 has_virtual_partition = .true.
560 else
561 has_virtual_partition = .false.
562 end if
563
564 if (.not. present(parent)) then
565 call mesh_partition(mesh, namespace, space, stencil, vsize)
566 else
567 ! if there is a parent grid, use its partition
568 call mesh_partition_from_parent(mesh, parent)
569 end if
570
571 !Now that we have the partitions, we save them
572 call restart_dump%init(namespace, restart_partition, restart_type_dump, mc, ierr, mesh=mesh)
573 call mesh_partition_dump(restart_dump, mesh, vsize, ierr)
574 call restart_dump%end()
575 end if
576
577 if (has_virtual_partition) then
578 call profiling_end(namespace)
579 call print_date("Calculation ended on ")
580 write(message(1),'(a)') "Execution has ended."
581 write(message(2),'(a)') "If you want to run your system, do not use MeshPartitionVirtualSize."
582 call messages_warning(2, namespace=namespace)
583 call messages_end()
584 call global_end()
585 stop
586 end if
587
588 !%Variable MeshUseTopology
589 !%Type logical
590 !%Default false
591 !%Section Execution::Parallelization
592 !%Description
593 !% (experimental) If enabled, <tt>Octopus</tt> will use an MPI virtual
594 !% topology to map the processors. This can improve performance
595 !% for certain interconnection systems.
596 !%End
597 call parse_variable(namespace, 'MeshUseTopology', .false., use_topo)
598
599 if (use_topo) then
600 ! At the moment we still need the global partition. This will be removed in near future.
601 safe_allocate(part_vec(1:mesh%np_global))
602 call partition_get_global(mesh%partition, part_vec(1:mesh%np_global))
603
604
605 ! generate a table of neighbours
606
607 safe_allocate(nb(1:mesh%mpi_grp%size, 1:mesh%mpi_grp%size))
608 nb = .false.
609
610 do ipg = 1, mesh%np_global
611 ipart = part_vec(ipg)
612 call mesh_global_index_to_coords(mesh, ipg, idx)
613 do jj = 1, stencil%size
614 jx = idx + stencil%points(:, jj)
615 jpg = mesh_global_index_from_coords(mesh, jx)
616 if (jpg > 0 .and. jpg <= mesh%np_global) then
617 jpart = part_vec(jpg)
618 if (ipart /= jpart ) nb(ipart, jpart) = .true.
619 end if
620 end do
621 end do
622 safe_deallocate_a(part_vec)
623
624 ! now generate the information of the graph
625
626 safe_allocate(gindex(1:mesh%mpi_grp%size))
627 safe_allocate(gedges(1:count(nb)))
628
629 ! and now generate it
630 iedge = 0
631 do ipart = 1, mesh%mpi_grp%size
632 do jpart = 1, mesh%mpi_grp%size
633 if (nb(ipart, jpart)) then
634 iedge = iedge + 1
635 gedges(iedge) = jpart - 1
636 end if
637 end do
638 gindex(ipart) = iedge
639 end do
640
641 assert(iedge == count(nb))
642
643 reorder = .true.
644 call mpi_graph_create(mesh%mpi_grp%comm, mesh%mpi_grp%size, gindex, gedges, reorder, graph_comm)
645
646 ! we have a new communicator
647 call mpi_grp_init(mesh%mpi_grp, graph_comm)
648
649 safe_deallocate_a(nb)
650 safe_deallocate_a(gindex)
651 safe_deallocate_a(gedges)
652
653 end if
654
655 if (optional_default(regenerate, .false.)) call par_vec_end(mesh%pv)
656 call par_vec_init(mesh%mpi_grp, mesh%np_global, mesh%idx, stencil,&
657 space, mesh%partition, mesh%pv, namespace)
658
659 ! check the number of ghost neighbours in parallel
660 nnb = 0
661 jpart = mesh%pv%partno
662 do ipart = 1, mesh%pv%npart
663 if (ipart == jpart) cycle
664 if (mesh%pv%ghost_scounts(ipart) /= 0) nnb = nnb + 1
665 end do
666 assert(nnb >= 0 .and. nnb < mesh%pv%npart)
667
668 ! Set local point numbers.
669 mesh%np = mesh%pv%np_local
670 mesh%np_part = mesh%np + mesh%pv%np_ghost + mesh%pv%np_bndry
671
672 !%Variable PartitionPrint
673 !%Type logical
674 !%Default true
675 !%Section Execution::Parallelization
676 !%Description
677 !% (experimental) If disabled, <tt>Octopus</tt> will not compute
678 !% nor print the partition information, such as local points,
679 !% no. of neighbours, ghost points and boundary points.
680 !%End
681 call parse_variable(namespace, 'PartitionPrint', .true., partition_print)
682
683 if (partition_print) then
684 call mesh_partition_write_info(mesh, namespace=namespace)
685 call mesh_partition_messages_debug(mesh, namespace)
686 end if
687#endif
688
690 end subroutine do_partition
691
692
693 ! ---------------------------------------------------------
695 subroutine mesh_get_vol_pp()
696
697 integer :: ip, np
698
700
701 np = 1
702 if (mesh%use_curvilinear) np = mesh%np_part
703 ! If no local point, we should not try to access the arrays
704 if (mesh%np_part == 0) np = 0
705
706 safe_allocate(mesh%vol_pp(1:np))
707
708 do ip = 1, np
709 mesh%vol_pp(ip) = product(mesh%spacing)
710 end do
711
712 do ip = 1, np
713 mesh%vol_pp(ip) = mesh%vol_pp(ip)*mesh%coord_system%jacobian_determinant(mesh%chi(:, ip))
714 end do
715
716 if (mesh%use_curvilinear .or. mesh%np_part == 0) then
717 mesh%volume_element = m_one
718 else
719 mesh%volume_element = mesh%vol_pp(1)
720 end if
721
723 end subroutine mesh_get_vol_pp
724
725 end subroutine mesh_init_stage_3
726
731 subroutine rebalance_array(grp, data_input, data_output, output_sizes)
732 type(mpi_grp_t), intent(in) :: grp
733 integer(int64), contiguous, intent(in) :: data_input(:)
734 integer(int64), allocatable, intent(out) :: data_output(:)
735 integer, allocatable, optional, intent(out) :: output_sizes(:)
736
737 integer, allocatable :: initial_sizes(:), final_sizes(:)
738 integer(int64), allocatable :: initial_offsets(:), final_offsets(:)
739 integer, allocatable :: scounts(:), sdispls(:)
740 integer, allocatable :: rcounts(:), rdispls(:)
741 integer :: irank
742 integer(int64) :: itmp
743
744 push_sub(rebalance_array)
745
746 ! collect current sizes of distributed array
747 safe_allocate(initial_sizes(0:grp%size-1))
748 call grp%allgather(size(data_input), 1, mpi_integer, initial_sizes(0), 1, mpi_integer)
749 safe_allocate(initial_offsets(0:grp%size))
750 initial_offsets(0) = 0
751 do irank = 1, grp%size
752 initial_offsets(irank) = initial_offsets(irank-1) + initial_sizes(irank-1)
753 end do
754
755 ! now redistribute the arrays
756 ! use block data decomposition of grid indices
757 safe_allocate(final_offsets(0:grp%size))
758 safe_allocate(final_sizes(0:grp%size-1))
759
760 do irank = 0, grp%size
761 final_offsets(irank) = sum(int(initial_sizes, int64)) * irank/grp%size
762 end do
763 do irank = 0, grp%size - 1
764 assert(final_offsets(irank + 1) - final_offsets(irank) < huge(0_int32))
765 final_sizes(irank) = int(final_offsets(irank + 1) - final_offsets(irank), int32)
766 end do
767
768 safe_allocate(scounts(0:grp%size-1))
769 safe_allocate(sdispls(0:grp%size-1))
770 safe_allocate(rcounts(0:grp%size-1))
771 safe_allocate(rdispls(0:grp%size-1))
772 ! determine communication pattern
773 scounts = 0
774 do irank = 0, grp%size - 1
775 ! get overlap of initial and final distribution
776 itmp = min(final_offsets(irank+1), initial_offsets(grp%rank+1)) - &
777 max(final_offsets(irank), initial_offsets(grp%rank))
778 assert(itmp < huge(0_int32))
779 if (itmp < 0) then
780 scounts(irank) = 0
781 else
782 scounts(irank) = int(itmp, int32)
783 end if
784 end do
785 sdispls(0) = 0
786 do irank = 1, grp%size - 1
787 sdispls(irank) = sdispls(irank - 1) + scounts(irank - 1)
788 end do
789 assert(sum(int(scounts, int64)) < huge(0_int32))
790 assert(sum(scounts) == initial_sizes(grp%rank))
791
792 rcounts = 0
793 do irank = 0, grp%size - 1
794 ! get overlap of initial and final distribution
795 itmp = min(final_offsets(grp%rank+1), initial_offsets(irank+1)) - &
796 max(final_offsets(grp%rank), initial_offsets(irank))
797 assert(itmp < huge(0_int32))
798 if (itmp < 0) then
799 rcounts(irank) = 0
800 else
801 rcounts(irank) = int(itmp, int32)
802 end if
803 end do
804 rdispls(0) = 0
805 do irank = 1, grp%size - 1
806 rdispls(irank) = rdispls(irank - 1) + rcounts(irank - 1)
807 end do
808 ! check for consistency between sending and receiving
809 assert(sum(rcounts) == final_sizes(grp%rank))
810
811 safe_allocate(data_output(1:final_sizes(grp%rank)))
812 call grp%alltoallv(data_input, scounts, sdispls, mpi_integer8, &
813 data_output, rcounts, rdispls, mpi_integer8)
814
815 ! save final sizes of array if optional argument present
816 if (present(output_sizes)) then
817 safe_allocate(output_sizes(0:grp%size-1))
818 output_sizes(:) = final_sizes(:)
819 end if
820
821 safe_deallocate_a(final_offsets)
822 safe_deallocate_a(final_sizes)
823
824 safe_deallocate_a(scounts)
825 safe_deallocate_a(sdispls)
826 safe_deallocate_a(rcounts)
827 safe_deallocate_a(rdispls)
828
829
830 pop_sub(rebalance_array)
831 end subroutine rebalance_array
832
837 subroutine reorder_points(namespace, space, grp, idx, grid_to_spatial, grid_to_spatial_reordered)
838 type(namespace_t), intent(in) :: namespace
839 class(space_t), intent(in) :: space
840 type(mpi_grp_t), intent(in) :: grp
841 type(index_t), intent(in) :: idx
842 integer(int64), intent(in) :: grid_to_spatial(:)
843 integer(int64), allocatable, intent(out) :: grid_to_spatial_reordered(:)
844
845 integer :: bsize(space%dim), order, default
846 integer :: nn, idir, ipg, ip, number_of_blocks(space%dim)
847 type(block_t) :: blk
848 integer, parameter :: &
849 ORDER_BLOCKS = 1, &
850 order_original = 2, &
851 order_cube = 3
852 integer :: point(1:space%dim)
853 integer(int64), allocatable :: reorder_indices(:), reorder_recv(:)
854 integer, allocatable :: index_map(:), indices(:)
855 integer(int64), allocatable :: grid_to_spatial_recv(:)
856 integer, allocatable :: initial_sizes(:)
857 integer(int64), allocatable :: initial_offsets(:)
858 integer(int64) :: istart, iend, indstart, indend, spatial_size
859 integer :: irank, local_size, num_recv
860 integer :: iunique, nunique
861 integer :: direction
862 logical :: increase_with_dimension
863
864 integer, allocatable :: scounts(:), sdispls(:), rcounts(:), rdispls(:)
865 integer(int64), allocatable :: spatial_cutoff(:)
866
867 push_sub(reorder_points)
868
869 !%Variable MeshOrder
870 !%Type integer
871 !%Section Execution::Optimization
872 !%Description
873 !% This variable controls how the grid points are mapped to a
874 !% linear array for global arrays. For runs that are parallel
875 !% in domains, the local mesh order may be different (see
876 !% <tt>MeshLocalOrder</tt>).
877 !% The default is blocks when serial in domains and cube when
878 !% parallel in domains with the local mesh order set to blocks.
879 !%Option order_blocks 1
880 !% The grid is mapped using small parallelepipedic grids. The size
881 !% of the blocks is controlled by <tt>MeshBlockSize</tt>.
882 !%Option order_original 2
883 !% The original order of the indices is used to map the grid.
884 !%Option order_cube 3
885 !% The grid is mapped using a full cube, i.e. without blocking.
886 !%End
887 default = order_blocks
888 call parse_variable(namespace, 'MeshOrder', default, order)
889 ! no reordering in 1D necessary
890 if (space%dim == 1) then
891 order = order_original
892 end if
893
894 !%Variable MeshBlockDirection
895 !%Type integer
896 !%Section Execution::Optimization
897 !%Description
898 !% Determines the direction in which the dimensions are chosen to compute
899 !% the blocked index for sorting the mesh points (see MeshBlockSize).
900 !% The default is increase_with_dimensions, corresponding to xyz ordering
901 !% in 3D.
902 !%Option increase_with_dimension 1
903 !% The fastest changing index is in the first dimension, i.e., in 3D this
904 !% corresponds to ordering in xyz directions.
905 !%Option decrease_with_dimension 2
906 !% The fastest changing index is in the last dimension, i.e., in 3D this
907 !% corresponds to ordering in zyx directions.
908 !%End
909 call parse_variable(namespace, 'MeshBlockDirection', 1, direction)
910 increase_with_dimension = direction == 1
911 if (direction /= 1 .and. direction /= 2) then
912 call messages_input_error(namespace, 'MeshBlockDirection')
913 end if
914
915 select case (order)
916 case (order_original)
917 ! only copy points, they stay in their original ordering
918 safe_allocate(grid_to_spatial_reordered(1:size(grid_to_spatial)))
919 grid_to_spatial_reordered(1:size(grid_to_spatial)) = grid_to_spatial(1:size(grid_to_spatial))
920 case (order_blocks, order_cube)
921 if (order == order_cube) then
922 bsize = idx%nr(2, :) - idx%nr(1, :) + 1
923 else
924 !%Variable MeshBlockSize
925 !%Type block
926 !%Section Execution::Optimization
927 !%Description
928 !% To improve memory-access locality when calculating derivatives,
929 !% <tt>Octopus</tt> arranges mesh points in blocks. This variable
930 !% controls the size of this blocks in the different
931 !% directions. The default is selected according to the value of
932 !% the <tt>StatesBlockSize</tt> variable. (This variable only affects the
933 !% performance of <tt>Octopus</tt> and not the results.)
934 !%End
935 if (conf%target_states_block_size < 16) then
936 bsize(1) = 80 * 4 / abs(conf%target_states_block_size)
937 if (space%dim > 1) bsize(2) = 4
938 if (space%dim > 2) bsize(3:) = 10
939 else
940 bsize(1) = max(4 * 16 / abs(conf%target_states_block_size), 1)
941 if (space%dim > 1) bsize(2) = 15
942 if (space%dim > 2) bsize(3:) = 15
943 end if
944
945 if (parse_block(namespace, 'MeshBlockSize', blk) == 0) then
946 nn = parse_block_cols(blk, 0)
947 if (nn /= space%dim) then
948 message(1) = "Error: number of entries in MeshBlockSize must match the number of dimensions."
949 call messages_fatal(1, namespace=namespace)
950 end if
951 do idir = 1, nn
952 call parse_block_integer(blk, 0, idir - 1, bsize(idir))
953 end do
954 end if
955 end if
956
957 number_of_blocks = (idx%nr(2, :) - idx%nr(1, :) + 1) / bsize + 1
958
959
960 ! do the global reordering in parallel, use block data decomposition of global indices
961 ! reorder indices along blocked parallelepiped curve
962
963 ! collect current sizes of distributed array
964 safe_allocate(initial_sizes(0:grp%size-1))
965 call grp%allgather(size(grid_to_spatial), 1, mpi_integer, initial_sizes(0), 1, mpi_integer)
966 safe_allocate(initial_offsets(0:grp%size))
967 initial_offsets(0) = 0
968 do irank = 1, grp%size
969 initial_offsets(irank) = initial_offsets(irank-1) + initial_sizes(irank-1)
970 end do
971
972 ! get local range and size
973 istart = initial_offsets(grp%rank)
974 iend = initial_offsets(grp%rank + 1) - 1
975 assert(iend - istart + 1 < huge(0_int32))
976 local_size = int(iend - istart + 1, int32)
977 assert(local_size == initial_sizes(grp%rank))
978
979 ! compute new indices locally
980 safe_allocate(reorder_indices(1:local_size))
981 safe_allocate(indices(1:local_size))
982 safe_allocate(grid_to_spatial_reordered(1:local_size))
983 !$omp parallel do private(point)
984 do ip = 1, local_size
985 call index_spatial_to_point(idx, space%dim, grid_to_spatial(ip), point)
986 point = point + idx%offset
987 reorder_indices(ip) = get_blocked_index(space%dim, point, bsize, number_of_blocks, increase_with_dimension)
988 end do
989 ! parallel sort according to the new indices
990 ! sort the local array
991 call sort(reorder_indices, indices)
992 ! save reordered indices to send to other processes
993 !$omp parallel do
994 do ip = 1, local_size
995 grid_to_spatial_reordered(ip) = grid_to_spatial(indices(ip))
996 end do
997
998 ! get minimum and maximum
999 if(local_size > 0) then
1000 indstart = reorder_indices(1)
1001 indend = reorder_indices(local_size)
1002 else
1003 indstart = huge(1_int64)
1004 indend = 0
1005 end if
1006 call grp%allreduce_inplace(indstart, 1, mpi_integer8, mpi_min)
1007 call grp%allreduce_inplace(indend, 1, mpi_integer8, mpi_max)
1008 spatial_size = indend - indstart + 1
1009
1010 ! get index ranges for each rank
1011 safe_allocate(spatial_cutoff(0:grp%size-1))
1012 do irank = 0, grp%size - 1
1013 spatial_cutoff(irank) = spatial_size * (irank+1)/grp%size + indstart
1014 end do
1015
1016 safe_allocate(scounts(0:grp%size-1))
1017 safe_allocate(sdispls(0:grp%size-1))
1018 safe_allocate(rcounts(0:grp%size-1))
1019 safe_allocate(rdispls(0:grp%size-1))
1020 ! get send counts
1021 scounts = 0
1022 irank = 0
1023 ! the indices are ordered, so we can go through them and increase
1024 ! the rank to which they are associated to when we cross a cutoff
1025 do ip = 1, local_size
1026 if (reorder_indices(ip) >= spatial_cutoff(irank)) then
1027 ! this do loop is needed in case some ranks do not have any points
1028 do while (reorder_indices(ip) >= spatial_cutoff(irank))
1029 irank = irank + 1
1030 end do
1031 assert(irank < grp%size)
1032 end if
1033 scounts(irank) = scounts(irank) + 1
1034 end do
1035 safe_deallocate_a(spatial_cutoff)
1036 assert(sum(scounts) == local_size)
1037
1038 ! compute communication pattern (sdispls, rcounts, rdispls)
1039 sdispls(0) = 0
1040 do irank = 1, grp%size - 1
1041 sdispls(irank) = sdispls(irank - 1) + scounts(irank - 1)
1042 end do
1043
1044 call grp%alltoall(scounts, 1, mpi_integer, &
1045 rcounts, 1, mpi_integer)
1046
1047 rdispls(0) = 0
1048 do irank = 1, grp%size - 1
1049 rdispls(irank) = rdispls(irank - 1) + rcounts(irank - 1)
1050 end do
1051
1052 ! make sure the arrays get allocated also if we do not receive anything
1053 num_recv = max(sum(rcounts), 1)
1054 ! communicate the locally sorted indices
1055 safe_allocate(reorder_recv(1:num_recv))
1056 call grp%alltoallv(reorder_indices, scounts, sdispls, mpi_integer8, &
1057 reorder_recv, rcounts, rdispls, mpi_integer8)
1058 safe_deallocate_a(reorder_indices)
1059
1060 ! communicate the corresponding spatial indices
1061 safe_allocate(grid_to_spatial_recv(1:num_recv))
1062 call grp%alltoallv(grid_to_spatial_reordered, scounts, sdispls, mpi_integer8, &
1063 grid_to_spatial_recv, rcounts, rdispls, mpi_integer8)
1064 safe_deallocate_a(grid_to_spatial_reordered)
1065
1066 ! do k-way merge of sorted indices
1067 safe_allocate(reorder_indices(1:num_recv))
1068 safe_allocate(index_map(1:num_recv))
1069 if (sum(rcounts) > 0) then
1070 call merge_sorted_arrays(reorder_recv, rcounts, reorder_indices, index_map)
1071
1072 ! get number of unique indices, needed for boundary
1073 nunique = 1
1074 do ipg = 2, sum(rcounts)
1075 if (reorder_indices(ipg) /= reorder_indices(ipg-1)) then
1076 nunique = nunique + 1
1077 end if
1078 end do
1079
1080 ! reorder according to new order, but remove duplicate entries
1081 safe_allocate(grid_to_spatial_reordered(1:nunique))
1082 iunique = 1
1083 grid_to_spatial_reordered(iunique) = grid_to_spatial_recv(index_map(1))
1084 do ipg = 2, sum(rcounts)
1085 if (reorder_indices(ipg) /= reorder_indices(ipg-1)) then
1086 iunique = iunique + 1
1087 grid_to_spatial_reordered(iunique) = grid_to_spatial_recv(index_map(ipg))
1088 end if
1089 end do
1090 else
1091 safe_allocate(grid_to_spatial_reordered(1:0))
1092 end if
1093
1094 safe_deallocate_a(initial_offsets)
1095 safe_deallocate_a(initial_sizes)
1096
1097 safe_deallocate_a(reorder_indices)
1098 safe_deallocate_a(reorder_recv)
1099
1100 safe_deallocate_a(grid_to_spatial_recv)
1101 safe_deallocate_a(index_map)
1102 safe_deallocate_a(indices)
1103
1104 safe_deallocate_a(scounts)
1105 safe_deallocate_a(sdispls)
1106 safe_deallocate_a(rcounts)
1107 safe_deallocate_a(rdispls)
1108
1109 end select
1110 pop_sub(reorder_points)
1111 end subroutine reorder_points
1112
1115 subroutine get_sizes_offsets(local_size, sizes, offsets, mpi_grp)
1116 integer, intent(in) :: local_size
1117 integer, allocatable, intent(out) :: sizes(:)
1118 integer(int64), allocatable, intent(out) :: offsets(:)
1119 type(mpi_grp_t), intent(in) :: mpi_grp
1120
1121 integer :: irank
1122
1123 push_sub(get_sizes_offsets)
1124
1125 safe_allocate(sizes(0:mpi_grp%size-1))
1126 call mpi_grp%allgather(local_size, 1, mpi_integer, sizes(0), 1, mpi_integer)
1127 safe_allocate(offsets(0:mpi_grp%size))
1128 offsets(0) = 0
1129 do irank = 1, mpi_grp%size
1130 offsets(irank) = offsets(irank-1) + sizes(irank-1)
1131 end do
1132
1133 pop_sub(get_sizes_offsets)
1134 end subroutine get_sizes_offsets
1135
1136end module mesh_init_oct_m
1137
1138!! Local Variables:
1139!! mode: f90
1140!! coding: utf-8
1141!! End:
Box bounds along some axes.
Definition: box.F90:180
This is the common interface to a sorting routine. It performs the shell algorithm,...
Definition: sort.F90:156
double log(double __x) __attribute__((__nothrow__
subroutine do_partition()
Definition: mesh_init.F90:601
subroutine mesh_get_vol_pp()
calculate the volume of integration
Definition: mesh_init.F90:609
real(real64), parameter, public box_boundary_delta
Definition: box.F90:134
This module handles the calculation mode.
integer, parameter, public p_strategy_domains
parallelization in domains
real(real64), parameter, public m_two
Definition: global.F90:202
subroutine, public global_end()
Finalise parser varinfo file, and MPI.
Definition: global.F90:494
real(real64), parameter, public m_zero
Definition: global.F90:200
type(conf_t), public conf
Global instance of Octopus configuration.
Definition: global.F90:190
real(real64), parameter, public m_one
Definition: global.F90:201
This module implements a simple hash table for non-negative integer keys and integer values.
Definition: iihash.F90:127
integer function, public lihash_lookup(h, key, found)
Look up a value in the hash table h. If found is present, it indicates if key could be found in the t...
Definition: iihash.F90:336
subroutine, public lihash_insert(h, key, val)
Insert a (key, val) pair into the hash table h.
Definition: iihash.F90:310
subroutine, public lihash_end(h)
Free a hash table.
Definition: iihash.F90:288
subroutine, public lihash_init(h)
Initialize a hash table h.
Definition: iihash.F90:265
This module implements the index, used for the mesh points.
Definition: index.F90:124
subroutine, public index_init(idx, dim)
This subroutine allocates memory and initializes some components.
Definition: index.F90:220
integer(int64) function, public get_blocked_index(dim, point, bsize, number_of_blocks, increase_with_dimensions)
Definition: index.F90:499
subroutine, public index_spatial_to_point(idx, dim, ispatial, point)
Definition: index.F90:400
integer, parameter, public idx_hilbert
Definition: index.F90:169
subroutine, public index_point_to_spatial(idx, dim, ispatial, point)
Definition: index.F90:418
integer, parameter, public idx_cubic
Definition: index.F90:169
This module is intended to contain "only mathematical" functions and procedures.
Definition: math.F90:117
subroutine, public merge_sorted_arrays(array, sizes, merged, index_map)
This module contains subroutines, related to the initialization of the mesh.
Definition: mesh_init.F90:119
subroutine rebalance_array(grp, data_input, data_output, output_sizes)
re-distribute the points to improve load balancing
Definition: mesh_init.F90:645
subroutine, public mesh_init_stage_3(mesh, namespace, space, stencil, mc, parent, regenerate)
When running parallel in domains, stencil and np_stencil are needed to compute the ghost points....
Definition: mesh_init.F90:531
subroutine, public mesh_init_stage_1(mesh, namespace, space, box, coord_system, spacing, enlarge)
First stage mesh initialization.
Definition: mesh_init.F90:172
subroutine get_sizes_offsets(local_size, sizes, offsets, mpi_grp)
return the sizes and offsets of a distributed array for all tasks of a mpi group.
Definition: mesh_init.F90:1029
subroutine reorder_points(namespace, space, grp, idx, grid_to_spatial, grid_to_spatial_reordered)
reorder the points in the grid according to the variables MeshOrder and MeshLocalOrder
Definition: mesh_init.F90:751
subroutine, public mesh_init_stage_2(mesh, namespace, space, box, stencil, grp, regenerate)
This subroutine creates the global array of spatial indices and the inverse mapping.
Definition: mesh_init.F90:292
This module defines the meshes, which are used in Octopus.
Definition: mesh.F90:120
subroutine, public mesh_global_index_to_coords(mesh, ipg, ix)
Given a global point index, this function returns the set of integer coordinates of the point.
Definition: mesh.F90:928
integer(int64) function, public mesh_global_index_from_coords(mesh, ix)
This function returns the true global index of the point for a given vector of integer coordinates.
Definition: mesh.F90:919
subroutine, public mesh_local_index_to_coords(mesh, ip, ix)
Given a local point index, this function returns the set of integer coordinates of the point.
Definition: mesh.F90:950
integer(int64) function, public mesh_local2global(mesh, ip)
This function returns the global mesh index for a given local index.
Definition: mesh.F90:962
real(real64) function, dimension(1:mesh%box%dim), public mesh_x_global(mesh, ipg)
Given a global point index, this function returns the coordinates of the point.
Definition: mesh.F90:817
subroutine, public mesh_partition_from_parent(mesh, parent)
create a mesh partition from a given parent mesh
subroutine, public mesh_partition_write_info(mesh, iunit, namespace)
subroutine, public mesh_partition_messages_debug(mesh, namespace)
subroutine, public mesh_partition(mesh, namespace, space, lapl_stencil, vsize)
This routine converts the mesh given by grid points into a graph.
subroutine, public mesh_partition_dump(restart, mesh, vsize, ierr)
subroutine, public mesh_partition_load(restart, mesh, ierr)
subroutine, public messages_end()
Definition: messages.F90:273
subroutine, public messages_warning(no_lines, all_nodes, namespace)
Definition: messages.F90:525
subroutine, public print_date(str)
Definition: messages.F90:983
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
Definition: messages.F90:162
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
Definition: messages.F90:410
subroutine, public messages_input_error(namespace, var, details, row, column)
Definition: messages.F90:691
This module contains some common usage patterns of MPI routines.
Definition: mpi_lib.F90:117
subroutine mpi_grp_init(grp, comm)
Initialize MPI group instance.
Definition: mpi.F90:341
This module handles the communicators for the various parallelization strategies.
Definition: multicomm.F90:147
Some general things and nomenclature:
Definition: par_vec.F90:173
subroutine, public par_vec_end(pv)
Deallocate memory used by pv.
Definition: par_vec.F90:746
subroutine, public par_vec_init(mpi_grp, np_global, idx, stencil, space, partition, pv, namespace)
Initializes a par_vec_type object (parallel vector).
Definition: par_vec.F90:296
integer function, public parse_block(namespace, name, blk, check_varinfo_)
Definition: parser.F90:623
subroutine, public partition_get_global(partition, part_global, root)
Returns the global partition. If root is present, the partition is gathered only in that node....
Definition: partition.F90:391
subroutine, public profiling_end(namespace)
Definition: profiling.F90:415
integer, parameter, public restart_partition
Definition: restart.F90:156
integer, parameter, public restart_type_dump
Definition: restart.F90:184
integer, parameter, public restart_type_load
Definition: restart.F90:184
This module is intended to contain "only mathematical" functions and procedures.
Definition: sort.F90:119
This module defines stencils used in Octopus.
Definition: stencil.F90:137
This module is intended to contain simple general-purpose utility functions and procedures.
Definition: utils.F90:120
subroutine, public make_array_larger(array, new_size)
Definition: utils.F90:557
class to tell whether a point is inside or outside
Definition: box.F90:143
Describes mesh distribution to nodes.
Definition: mesh.F90:187
This is defined even when running serial.
Definition: mpi.F90:144
Stores all communicators and groups.
Definition: multicomm.F90:208
The class representing the stencil, which is used for non-local mesh operations.
Definition: stencil.F90:165
int true(void)